From ec804073b6fc445bb6b1dd38caaf9a9da9a30e88 Mon Sep 17 00:00:00 2001 From: Hongzhang Yang Date: Wed, 18 Jun 2014 13:40:44 +0800 Subject: [PATCH] ENGR00318931-1 Enable VPU driver on kernel 3.14 Kernel 3.14 manages regulator using generic power domain which is covered by pm_runtime API. - Don't use PU regulator API - Use pm_runtime API only Signed-off-by: Hongzhang Yang --- drivers/mxc/vpu/mxc_vpu.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/drivers/mxc/vpu/mxc_vpu.c b/drivers/mxc/vpu/mxc_vpu.c index edb8c947359e..0e4497f833d7 100644 --- a/drivers/mxc/vpu/mxc_vpu.c +++ b/drivers/mxc/vpu/mxc_vpu.c @@ -1,5 +1,5 @@ /* - * Copyright 2006-2013 Freescale Semiconductor, Inc. All Rights Reserved. + * Copyright 2006-2014 Freescale Semiconductor, Inc. All Rights Reserved. */ /* @@ -145,9 +145,11 @@ static int vpu_jpu_irq; static unsigned int regBk[64]; static unsigned int pc_before_suspend; #endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 14, 0) #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 5, 0) || LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 0) static struct regulator *vpu_regulator; #endif +#endif static atomic_t clk_cnt_from_ioc = ATOMIC_INIT(0); #define READ_REG(x) readl_relaxed(vpu_base + x) @@ -186,6 +188,7 @@ static long vpu_power_get(bool on) { long ret = 0; +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 14, 0) if (on) { #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 5, 0) vpu_regulator = regulator_get(NULL, "cpu_vddvpu"); @@ -200,30 +203,39 @@ static long vpu_power_get(bool on) regulator_put(vpu_regulator); #endif } +#endif return ret; } static void vpu_power_up(bool on) { -#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 5, 0) || LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 0) - int ret = 0; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 5, 0) + if (on) + pm_runtime_get_sync(vpu_dev); +#endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 14, 0) +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 5, 0) || LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 0) if (on) { if (!IS_ERR(vpu_regulator)) { - ret = regulator_enable(vpu_regulator); - if (ret) + if (regulator_enable(vpu_regulator)) dev_err(vpu_dev, "failed to power up vpu\n"); } } else { if (!IS_ERR(vpu_regulator)) { - ret = regulator_disable(vpu_regulator); - if (ret) + if (regulator_disable(vpu_regulator)) dev_err(vpu_dev, "failed to power down vpu\n"); } } #else imx_gpc_power_up_pu(on); #endif +#endif + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 5, 0) + if (!on) + pm_runtime_put_sync_suspend(vpu_dev); +#endif } #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 0) @@ -376,10 +388,6 @@ static int vpu_open(struct inode *inode, struct file *filp) mutex_lock(&vpu_data.lock); if (open_count++ == 0) { - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 5, 0) - pm_runtime_get_sync(vpu_dev); -#endif vpu_power_up(true); #ifdef CONFIG_SOC_IMX6Q @@ -771,10 +779,6 @@ static int vpu_release(struct inode *inode, struct file *filp) } vpu_power_up(false); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 5, 0) - pm_runtime_put_sync_suspend(vpu_dev); -#endif - } mutex_unlock(&vpu_data.lock); -- 2.39.2