From 10bc762628429e4259fa9338ef40bfdcfa1eb2c4 Mon Sep 17 00:00:00 2001 From: Hongzhang Yang Date: Mon, 12 Aug 2013 15:38:07 +0800 Subject: [PATCH] ENGR00274761-3 Upgrade VPU driver for Linux 3.10 kernel Modify mxc_vpu.c to adapt to kernel 3.10 change - Remove all references to header files in mach folder - Include linux/clk.h instead of mach/clock.h - Call device_reset instead of imx_src_reset_vpu - Dummy PU and PM api callings before they are ready - Dummy cpu_is_mx5? api callings - Remove VM_RESERVED flags - Call gen_pool instead of iram_alloc Modify mxc_vpu.h - Change CONFIG_ARCH_MX6 to CONFIG_SOC_IMX6Q Modify Kconfig: - Change ARCH_MX? to SOC_IMX?, remove ARCH_MX3/ARCH_MX37 because for MX3 series only SOC_IMX31 and SOC_IMX35 are defined in Linux 3.10, and these chips don't have VPU. Need to add SOC_IMX37 to VPU Kconfig if MX37 could be supported later. Add VPU to config and build path - mxc/Kconfig - mxc/Makefile Signed-off-by: Hongzhang Yang --- drivers/mxc/Kconfig | 1 + drivers/mxc/Makefile | 1 + drivers/mxc/vpu/Kconfig | 2 +- drivers/mxc/vpu/mxc_vpu.c | 89 ++++++++++++++++++++++++++++++++++----- include/linux/mxc_vpu.h | 8 ++-- 5 files changed, 86 insertions(+), 15 deletions(-) diff --git a/drivers/mxc/Kconfig b/drivers/mxc/Kconfig index 5b69a03d25f3..8aa5640059fd 100644 --- a/drivers/mxc/Kconfig +++ b/drivers/mxc/Kconfig @@ -14,6 +14,7 @@ config MXC_IPU source "drivers/mxc/gpu-viv/Kconfig" source "drivers/mxc/ipu3/Kconfig" source "drivers/mxc/asrc/Kconfig" +source "drivers/mxc/vpu/Kconfig" endmenu diff --git a/drivers/mxc/Makefile b/drivers/mxc/Makefile index f180fbb03207..e18b67adb9e7 100644 --- a/drivers/mxc/Makefile +++ b/drivers/mxc/Makefile @@ -1,3 +1,4 @@ obj-$(CONFIG_MXC_GPU_VIV) += gpu-viv/ obj-$(CONFIG_MXC_IPU_V3) += ipu3/ obj-$(CONFIG_MXC_ASRC) += asrc/ +obj-$(CONFIG_MXC_VPU) += vpu/ diff --git a/drivers/mxc/vpu/Kconfig b/drivers/mxc/vpu/Kconfig index 6562697f25f5..520209601dbe 100644 --- a/drivers/mxc/vpu/Kconfig +++ b/drivers/mxc/vpu/Kconfig @@ -6,7 +6,7 @@ menu "MXC VPU(Video Processing Unit) support" config MXC_VPU tristate "Support for MXC VPU(Video Processing Unit)" - depends on (ARCH_MX3 || ARCH_MX27 || ARCH_MX37 || ARCH_MX5 || ARCH_MX6) + depends on (SOC_IMX27 || SOC_IMX5 || SOC_IMX6Q) default y ---help--- The VPU codec device provides codec function for H.264/MPEG4/H.263, diff --git a/drivers/mxc/vpu/mxc_vpu.c b/drivers/mxc/vpu/mxc_vpu.c index a16c31f9c5c8..9baeeb4e3a51 100644 --- a/drivers/mxc/vpu/mxc_vpu.c +++ b/drivers/mxc/vpu/mxc_vpu.c @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include @@ -46,23 +45,33 @@ #include #include #include +#include + #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 5, 0) #include #include -#include -#include -#include -#endif -#include -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 5, 0) #include -#else -#include #endif + +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 10, 0) +#include #include #include - #include +#endif + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 0) +#include +#include +#include +#include +#include +#elif LINUX_VERSION_CODE >= KERNEL_VERSION(3, 5, 0) +#include +#include +#else +#include +#endif /* Define one new pgprot which combined uncached and XN(never executable) */ #define pgprot_noncachedxn(prot) \ @@ -86,6 +95,11 @@ struct iram_setting { u32 end; }; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 0) +static struct gen_pool *iram_pool; +static u32 iram_base; +#endif + static LIST_HEAD(head); static int vpu_major; @@ -155,6 +169,39 @@ static int cpu_is_mx6q(void) } #endif +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 0) +static void imx_src_reset_vpu(void) +{ + device_reset(&vpu_pdev->dev); +} + +static void imx_gpc_power_up_pu(int on) +{ +} + +static void request_bus_freq(int freq) +{ +} + +static void release_bus_freq(int freq) +{ +} + +static int cpu_is_mx53(void) +{ + return 0; +} + +static int cpu_is_mx51(void) +{ + return 0; +} + +#define VM_RESERVED 0 +#define BUS_FREQ_HIGH 0 + +#endif + /*! * Private function to alloc dma buffer * @return status 0 success. @@ -826,7 +873,25 @@ static int vpu_dev_probe(struct platform_device *pdev) err = of_property_read_u32(np, "iramsize", (u32 *)&iramsize); if (!err && iramsize) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 0) + { + iram_pool = of_get_named_gen_pool(np, "iram", 0); + if (!iram_pool) { + printk(KERN_ERR "iram pool not available\n"); + return -ENOMEM; + } + + iram_base = gen_pool_alloc(iram_pool, iramsize); + if (!iram_base) { + printk(KERN_ERR "unable to alloc iram\n"); + return -ENOMEM; + } + + addr = gen_pool_virt_to_phys(iram_pool, iram_base); + } +#else iram_alloc(iramsize, &addr); +#endif if (addr == 0) iram.start = iram.end = 0; else { @@ -959,7 +1024,11 @@ static int vpu_dev_remove(struct platform_device *pdev) iounmap(vpu_base); #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 5, 0) if (iram.start) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 0) + gen_pool_free(iram_pool, iram_base, iram.end-iram.start+1); +#else iram_free(iram.start, iram.end-iram.start+1); +#endif #else if (vpu_plat && vpu_plat->iram_enable && vpu_plat->iram_size) iram_free(iram.start, vpu_plat->iram_size); diff --git a/include/linux/mxc_vpu.h b/include/linux/mxc_vpu.h index 7869d59c5eec..27f9377856aa 100644 --- a/include/linux/mxc_vpu.h +++ b/include/linux/mxc_vpu.h @@ -16,15 +16,15 @@ */ /*! - * @file plat-mxc/include/mach/mxc_vpu.h + * @file linux/mxc_vpu.h * * @brief VPU system initialization and file operation definition * * @ingroup VPU */ -#ifndef __ASM_ARCH_MXC_VPU_H__ -#define __ASM_ARCH_MXC_VPU_H__ +#ifndef __LINUX_MXC_VPU_H__ +#define __LINUX_MXC_VPU_H__ #include @@ -79,7 +79,7 @@ struct vpu_mem_desc { #define BIT_FRAME_MEM_CTRL BIT_WORK_CTRL_BUF_REG(4) #define BIT_BIT_STREAM_PARAM BIT_WORK_CTRL_BUF_REG(5) -#ifndef CONFIG_ARCH_MX6 +#ifndef CONFIG_SOC_IMX6Q #define BIT_RESET_CTRL 0x11C #else #define BIT_RESET_CTRL 0x128 -- 2.39.2