/* * NVIDIA Tegra Video decoder driver * * Copyright (C) 2016-2017 Dmitry Osipenko <digetx@gmail.com> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version * 2 of the License, or (at your option) any later version. */#include<linux/clk.h>#include<linux/dma-buf.h>#include<linux/genalloc.h>#include<linux/interrupt.h>#include<linux/iopoll.h>#include<linux/miscdevice.h>#include<linux/module.h>#include<linux/of_device.h>#include<linux/pm_runtime.h>#include<linux/reset.h>#include<linux/slab.h>#include<linux/uaccess.h>#include<soc/tegra/pmc.h>#include"uapi.h"#define ICMDQUE_WR 0x00#define CMDQUE_CONTROL 0x08#define INTR_STATUS 0x18#define BSE_INT_ENB 0x40#define BSE_CONFIG 0x44#define BSE_ICMDQUE_EMPTY BIT(3)#define BSE_DMA_BUSY BIT(23)structvideo_frame{structdma_buf_attachment*y_dmabuf_attachment;structdma_buf_attachment*cb_dmabuf_attachment;structdma_buf_attachment*cr_dmabuf_attachment;structdma_buf_attachment*aux_dmabuf_attachment;structsg_table*y_sgt;structsg_table*cb_sgt;structsg_table*cr_sgt;structsg_table*aux_sgt;dma_addr_ty_addr;dma_addr_tcb_addr;dma_addr_tcr_addr;dma_addr_taux_addr;u32frame_num;u32flags;};structtegra_vde{void__iomem*sxe;void__iomem*bsev;void__iomem*mbe;void__iomem*ppe;void__iomem*mce;void__iomem*tfe;void__iomem*ppb;void__iomem*vdma;void__iomem*frameid;structmutexlock;structmiscdevicemiscdev;structreset_control*rst;structreset_control*rst_mc;structgen_pool*iram_pool;structcompletiondecode_completion;structclk*clk;dma_addr_tiram_lists_addr;u32*iram;};static__maybe_unusedcharconst*tegra_vde_reg_base_name(structtegra_vde*vde,void__iomem*base){if(vde->sxe==base)return"SXE";if(vde->bsev==base)return"BSEV";if(vde->mbe==base)return"MBE";if(vde->ppe==base)return"PPE";if(vde->mce==base)return"MCE";if(vde->tfe==base)return