[COMMON] iio: exynos_adc: add IDLE_IP updates.
authorMatthew Leung <matt.leung@samsung.com>
Fri, 24 Apr 2015 11:00:17 +0000 (20:00 +0900)
committerJaehyoung Choi <jkkkkk.choi@samsung.com>
Wed, 9 May 2018 11:27:50 +0000 (20:27 +0900)
Change-Id: I304eb532e6827b504790768514626b00dec4931d
Signed-off-by: Matthew Leung <matt.leung@samsung.com>
Signed-off-by: Kyungwoo Kang <kwoo.kang@samsung.com>
drivers/iio/adc/exynos_adc.c

index 4d0cb971e145361e747da08cbcaaec4643898569..63f43be7c94dde5f13b45cdb62f7e681a5f2057d 100644 (file)
@@ -43,7 +43,7 @@
 #include <linux/mfd/syscon.h>
 #include <linux/regmap.h>
 
-#include <linux/platform_data/touchscreen-s3c2410.h>
+#include <soc/samsung/exynos-powermode.h>
 
 /* S3C/EXYNOS4412/5250 ADC_V1 registers definitions */
 #define ADC_V1_CON(x)          ((x) + 0x00)
@@ -154,10 +154,7 @@ struct exynos_adc {
 
        u32                     value;
        unsigned int            version;
-
-       bool                    read_ts;
-       u32                     ts_x;
-       u32                     ts_y;
+       int                     idle_ip_index;
 };
 
 struct exynos_adc_data {
@@ -237,13 +234,14 @@ static int exynos_adc_enable_access(struct exynos_adc *info)
 {
        int ret;
 
+       exynos_update_ip_idle_status(info->idle_ip_index, 0);
        if (info->needs_adc_phy)
                regmap_write(info->pmu_map, info->data->phy_offset, 1);
 
        if (info->vdd) {
                ret = regulator_enable(info->vdd);
                if (ret)
-                       return ret;
+                       goto err;
        }
 
        ret = exynos_adc_prepare_clk(info);
@@ -261,7 +259,11 @@ err_unprepare_clk:
 err_disable_reg:
        if (info->vdd)
                regulator_disable(info->vdd);
+err:
+       if (info->needs_adc_phy)
+               regmap_write(info->pmu_map, info->data->phy_offset, 0);
 
+       exynos_update_ip_idle_status(info->idle_ip_index, 1);
        return ret;
 }
 
@@ -274,6 +276,7 @@ static void exynos_adc_disable_access(struct exynos_adc *info)
 
        if (info->needs_adc_phy)
                regmap_write(info->pmu_map, info->data->phy_offset, 0);
+       exynos_update_ip_idle_status(info->idle_ip_index, 1);
 }
 
 static void exynos_adc_v1_init_hw(struct exynos_adc *info)
@@ -667,6 +670,9 @@ static int exynos_read_raw(struct iio_dev *indio_dev,
                ret = IIO_VAL_INT;
        }
 
+       if (info->data->exit_hw)
+               info->data->exit_hw(info);
+
        disable_irq(info->irq);
        exynos_adc_disable_access(info);
 err_unlock:
@@ -950,6 +956,7 @@ static int exynos_adc_probe(struct platform_device *pdev)
        info->tsirq = irq;
 
        info->dev = &pdev->dev;
+       info->idle_ip_index = exynos_get_idle_ip_index(dev_name(&pdev->dev));
 
        init_completion(&info->completion);