fimc-is: Replace hard coded PMU register access with regmap calls
authorMarek Szyprowski <m.szyprowski@samsung.com>
Fri, 7 Aug 2015 08:36:26 +0000 (10:36 +0200)
committerInki Dae <inki.dae@samsung.com>
Mon, 3 Dec 2018 00:56:49 +0000 (09:56 +0900)
Change-Id: Ifa9cccbbe68ff937c5ade1539592f5db0876edfb
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
drivers/media/platform/exynos/fimc-is/fimc-is-core.h
drivers/media/platform/exynos/fimc-is/fimc-is-device-companion.c
drivers/media/platform/exynos/fimc-is/fimc-is-device-ischain.c
drivers/media/platform/exynos/fimc-is/fimc-is-dt.c
drivers/media/platform/exynos/fimc-is/fimc-is-hw-ischain.c
drivers/media/platform/exynos/fimc-is/fimc-is-regs.h

index 7d28be6c8e05db08bb72eecf9b9fcebc3dc91776..a73809d53705be55abacf1015e4114c351f4382f 100644 (file)
@@ -224,6 +224,7 @@ struct fimc_is_core {
        struct platform_device                  *pdev;
        struct resource                         *regs_res;
        void __iomem                            *regs;
+       struct regmap                           *pmu_regmap;
        int                                     irq;
        u32                                     id;
        u32                                     debug_cnt;
index 553d2894e927fad28a68c2270ca0031f2f2c276f..d75a08e22ed975ec1627224f01eb2c06589d5305 100644 (file)
@@ -451,7 +451,6 @@ p_err:
 int fimc_is_companion_close(struct fimc_is_device_companion *device)
 {
        int ret = 0;
-       u32 timeout;
        struct fimc_is_core *core = (struct fimc_is_core *)dev_get_drvdata(fimc_is_dev);
        if (!core) {
                err("core is NULL");
@@ -468,7 +467,9 @@ int fimc_is_companion_close(struct fimc_is_device_companion *device)
 
 #if defined(CONFIG_PM_RUNTIME)
        pm_runtime_put_sync(&device->pdev->dev);
+#if 0
        if (core != NULL && !test_bit(FIMC_IS_ISCHAIN_POWER_ON, &core->state)) {
+               u32 timeout;
                warn("only companion device closing after open..");
                timeout = 2000;
                while ((readl(PMUREG_CAM1_STATUS) & 0x1) && timeout) {
@@ -481,6 +482,7 @@ int fimc_is_companion_close(struct fimc_is_device_companion *device)
                        err("CAM1 power down failed(CAM1:0x%08x, A5:0x%08x)\n",
                                        readl(PMUREG_CAM1_STATUS), readl(PMUREG_ISP_ARM_STATUS));
        }
+#endif
 #else
        fimc_is_companion_runtime_suspend(&device->pdev->dev);
 #endif /* CONFIG_PM_RUNTIME */
index 98a6ceeac68dde03c9eae234e9f4be1fd5c42d5a..a2ba7f534e47cba03260fd7f1aa35cd9bd227b6a 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/vmalloc.h>
 #include <linux/kthread.h>
 #include <linux/debugfs.h>
+#include <linux/regmap.h>
 #include <linux/syscalls.h>
 #include <linux/bug.h>
 
@@ -1204,9 +1205,11 @@ static int fimc_is_ischain_loadcalb(struct fimc_is_device_ischain *device,
                mwarn("calibration loading is success", device);
        return ret;
 }
+
 static void fimc_is_ischain_forcedown(struct fimc_is_device_ischain *this,
        bool on)
 {
+#if 0
        if (on) {
                printk(KERN_INFO "Set low poweroff mode\n");
                __raw_writel(0x0, PMUREG_ISP_ARM_OPTION);
@@ -1218,29 +1221,48 @@ static void fimc_is_ischain_forcedown(struct fimc_is_device_ischain *this,
                __raw_writel(0x8, PMUREG_ISP_LOW_POWER_OFF);
                this->force_down = false;
        }
+#endif
 }
 
 static void fimc_is_a5_power(struct device *dev, int power_flags)
 {
-       u32 timeout;
+       struct fimc_is_core *core;
+       int timeout;
+       u32 val;
+
+       if (!fimc_is_dev) {
+               err("fimc_is_dev is not yet probed");
+               BUG();
+       }
+
+       core = (struct fimc_is_core *)dev_get_drvdata(fimc_is_dev);
+       if (!core) {
+               err("core is NULL");
+               BUG();
+       }
 
        /* configuration */
-       __raw_writel(power_flags, PMUREG_ISP_ARM_CONFIGURATION);
+       regmap_write(core->pmu_regmap, PMUREG_ISP_ARM_CONFIGURATION, power_flags);
 
        /* option */
        if (power_flags) {
                /* A5 enable[15] */
-               writel((1 << 15), PMUREG_ISP_ARM_OPTION);
+               regmap_write(core->pmu_regmap, PMUREG_ISP_ARM_OPTION, (1 << 15));
        }
 
        /* status */
        timeout = 1000;
-       while ((__raw_readl(PMUREG_ISP_ARM_STATUS) & 0x1) != power_flags) {
-               if (timeout == 0)
-                       err("%s can't control power(%d), timeout\n", __func__, power_flags);
-               timeout--;
-               udelay(1);
+       while (timeout) {
+               regmap_read(core->pmu_regmap, PMUREG_ISP_ARM_STATUS, &val);
+               if ((val & 0x1) != power_flags) {
+                       timeout--;
+                       udelay(1);
+               } else {
+                       break;
+               }
        }
+       if (timeout == 0)
+               err("%s can't control power(%d), timeout\n", __func__, power_flags);
 }
 
 int fimc_is_ischain_power(struct fimc_is_device_ischain *device, int on)
@@ -1331,7 +1353,8 @@ int fimc_is_ischain_power(struct fimc_is_device_ischain *device, int on)
                        merr("secure configuration is fail[0x131E0004:%08X]", device, debug);
 
                /* To guarantee FW restart */
-               if (__raw_readl(PMUREG_ISP_ARM_STATUS) & 0x1) {
+               regmap_read(core->pmu_regmap, PMUREG_ISP_ARM_STATUS, &val);
+               if (val & 0x1) {
                        fimc_is_a5_power(dev, 0);
                }
 
index 4ab888bca54cd08cfec2182545ff077cc2a8e252..94069d193cedf815be7d821a334ff97936d08ad4 100644 (file)
@@ -16,6 +16,8 @@
 #include <media/exynos_mc.h>
 #include <linux/of.h>
 #include <linux/of_gpio.h>
+#include <linux/regmap.h>
+#include <linux/mfd/syscon.h>
 
 #include "fimc-is-core.h"
 #include "fimc-is-dt.h"
@@ -276,6 +278,10 @@ int fimc_is_parse_children_dt(struct device *dev, struct fimc_is_core *core)
                if (i >= 0 || i < FIMC_IS_MAX_NODES)
                        core->csis_np[i] = child;
        }
+
+       core->pmu_regmap = syscon_regmap_lookup_by_phandle(np,
+                                               "samsung,pmureg-phandle");
+
        return 0;
 }
 
index 953e65247e5bb565bb0b10c5d6ae9a195f1855da..fb3dc98eb435419d09f27b54844b69174b2d8a71 100644 (file)
@@ -30,6 +30,7 @@
 int fimc_is_runtime_suspend_post(struct device *dev)
 {
        int ret = 0;
+#if 0
        u32 timeout;
 
        timeout = 2000;
@@ -59,7 +60,7 @@ int fimc_is_runtime_suspend_post(struct device *dev)
                err("CAM1 power down failed(CAM1:0x%08x, A5:0x%08x)\n",
                        readl(PMUREG_CAM1_STATUS), readl(PMUREG_ISP_ARM_STATUS));
 
-
+#endif
        return ret;
 }
 
index 7fa1a13ba38a70754d150a2553ecf185a765e1b3..b12a1945bbbbde15c862baf643e7b2a8faf63f75 100644 (file)
 #define ISSR62                 (MCUCTL+0x178)
 #define ISSR63                 (MCUCTL+0x17c)
 
-#define PMUREG_ISP_ARM_CONFIGURATION           (S5P_VA_PMU  + 0x2580)
-#define PMUREG_ISP_ARM_STATUS                  (S5P_VA_PMU  + 0x2584)
-#define PMUREG_ISP_ARM_OPTION                  (S5P_VA_PMU  + 0x2588)
-#define PMUREG_ISP_LOW_POWER_OFF               (S5P_VA_PMU  + 0x0004)
-#define PMUREG_ISP_CONFIGURATION               (S5P_VA_PMU  + 0x4140)
-#define PMUREG_ISP_STATUS                      (S5P_VA_PMU  + 0x4144)
-
-#define PMUREG_CAM0_STATUS                     (S5P_VA_PMU  + 0x4024)
-#define PMUREG_CAM1_STATUS                     (S5P_VA_PMU  + 0x40A4)
+#define PMUREG_ISP_ARM_CONFIGURATION           (0x2580)
+#define PMUREG_ISP_ARM_STATUS                  (0x2584)
+#define PMUREG_ISP_ARM_OPTION                  (0x2588)
+#define PMUREG_ISP_LOW_POWER_OFF               (0x0004)
+#define PMUREG_ISP_CONFIGURATION               (0x4140)
+#define PMUREG_ISP_STATUS                      (0x4144)
 
 #define SYSREG_GSCBLK_CFG1                     (S3C_VA_SYS + 0x0224)
 #define SYSREG_ISPBLK_CFG                      (S3C_VA_SYS + 0x022C)
-
 /* GIC for FIMC-IS*/
 #define PA_FIMC_IS_GIC_C                       (0x141E0000)
 #define PA_FIMC_IS_GIC_D                       (0x141F0000)