aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNaveen Krishna Chatradhi <ch.naveen@samsung.com>2014-09-16 04:58:00 -0400
committerJonathan Cameron <jic23@kernel.org>2014-11-05 10:30:09 -0500
commitfafb37cfae6d228c0026fcf31d02e1c3db2e78ee (patch)
treefed1489f6e6e14df17cf5d175e137bd8089f0a1e
parentb6d5be57024a8edcc91d0c2549d63c68d67a2257 (diff)
iio: exyno-adc: use syscon for PMU register access
This patch updates the IIO based ADC driver to use syscon and regmap APIs to access and use PMU registers instead of remapping the PMU registers in the driver. Signed-off-by: Naveen Krishna Chatradhi <ch.naveen@samsung.com> To: linux-iio@vger.kernel.org Acked-by: Kukjin Kim <kgene.kim@samsung.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
-rw-r--r--drivers/iio/adc/exynos_adc.c30
1 files changed, 21 insertions, 9 deletions
diff --git a/drivers/iio/adc/exynos_adc.c b/drivers/iio/adc/exynos_adc.c
index 43620fd4c66a..fe0317745436 100644
--- a/drivers/iio/adc/exynos_adc.c
+++ b/drivers/iio/adc/exynos_adc.c
@@ -39,6 +39,8 @@
39#include <linux/iio/iio.h> 39#include <linux/iio/iio.h>
40#include <linux/iio/machine.h> 40#include <linux/iio/machine.h>
41#include <linux/iio/driver.h> 41#include <linux/iio/driver.h>
42#include <linux/mfd/syscon.h>
43#include <linux/regmap.h>
42 44
43/* S3C/EXYNOS4412/5250 ADC_V1 registers definitions */ 45/* S3C/EXYNOS4412/5250 ADC_V1 registers definitions */
44#define ADC_V1_CON(x) ((x) + 0x00) 46#define ADC_V1_CON(x) ((x) + 0x00)
@@ -90,11 +92,14 @@
90 92
91#define EXYNOS_ADC_TIMEOUT (msecs_to_jiffies(100)) 93#define EXYNOS_ADC_TIMEOUT (msecs_to_jiffies(100))
92 94
95#define EXYNOS_ADCV1_PHY_OFFSET 0x0718
96#define EXYNOS_ADCV2_PHY_OFFSET 0x0720
97
93struct exynos_adc { 98struct exynos_adc {
94 struct exynos_adc_data *data; 99 struct exynos_adc_data *data;
95 struct device *dev; 100 struct device *dev;
96 void __iomem *regs; 101 void __iomem *regs;
97 void __iomem *enable_reg; 102 struct regmap *pmu_map;
98 struct clk *clk; 103 struct clk *clk;
99 struct clk *sclk; 104 struct clk *sclk;
100 unsigned int irq; 105 unsigned int irq;
@@ -110,6 +115,7 @@ struct exynos_adc_data {
110 int num_channels; 115 int num_channels;
111 bool needs_sclk; 116 bool needs_sclk;
112 bool needs_adc_phy; 117 bool needs_adc_phy;
118 int phy_offset;
113 u32 mask; 119 u32 mask;
114 120
115 void (*init_hw)(struct exynos_adc *info); 121 void (*init_hw)(struct exynos_adc *info);
@@ -183,7 +189,7 @@ static void exynos_adc_v1_init_hw(struct exynos_adc *info)
183 u32 con1; 189 u32 con1;
184 190
185 if (info->data->needs_adc_phy) 191 if (info->data->needs_adc_phy)
186 writel(1, info->enable_reg); 192 regmap_write(info->pmu_map, info->data->phy_offset, 1);
187 193
188 /* set default prescaler values and Enable prescaler */ 194 /* set default prescaler values and Enable prescaler */
189 con1 = ADC_V1_CON_PRSCLV(49) | ADC_V1_CON_PRSCEN; 195 con1 = ADC_V1_CON_PRSCLV(49) | ADC_V1_CON_PRSCEN;
@@ -198,7 +204,7 @@ static void exynos_adc_v1_exit_hw(struct exynos_adc *info)
198 u32 con; 204 u32 con;
199 205
200 if (info->data->needs_adc_phy) 206 if (info->data->needs_adc_phy)
201 writel(0, info->enable_reg); 207 regmap_write(info->pmu_map, info->data->phy_offset, 0);
202 208
203 con = readl(ADC_V1_CON(info->regs)); 209 con = readl(ADC_V1_CON(info->regs));
204 con |= ADC_V1_CON_STANDBY; 210 con |= ADC_V1_CON_STANDBY;
@@ -225,6 +231,7 @@ static const struct exynos_adc_data exynos_adc_v1_data = {
225 .num_channels = MAX_ADC_V1_CHANNELS, 231 .num_channels = MAX_ADC_V1_CHANNELS,
226 .mask = ADC_DATX_MASK, /* 12 bit ADC resolution */ 232 .mask = ADC_DATX_MASK, /* 12 bit ADC resolution */
227 .needs_adc_phy = true, 233 .needs_adc_phy = true,
234 .phy_offset = EXYNOS_ADCV1_PHY_OFFSET,
228 235
229 .init_hw = exynos_adc_v1_init_hw, 236 .init_hw = exynos_adc_v1_init_hw,
230 .exit_hw = exynos_adc_v1_exit_hw, 237 .exit_hw = exynos_adc_v1_exit_hw,
@@ -314,7 +321,7 @@ static void exynos_adc_v2_init_hw(struct exynos_adc *info)
314 u32 con1, con2; 321 u32 con1, con2;
315 322
316 if (info->data->needs_adc_phy) 323 if (info->data->needs_adc_phy)
317 writel(1, info->enable_reg); 324 regmap_write(info->pmu_map, info->data->phy_offset, 1);
318 325
319 con1 = ADC_V2_CON1_SOFT_RESET; 326 con1 = ADC_V2_CON1_SOFT_RESET;
320 writel(con1, ADC_V2_CON1(info->regs)); 327 writel(con1, ADC_V2_CON1(info->regs));
@@ -332,7 +339,7 @@ static void exynos_adc_v2_exit_hw(struct exynos_adc *info)
332 u32 con; 339 u32 con;
333 340
334 if (info->data->needs_adc_phy) 341 if (info->data->needs_adc_phy)
335 writel(0, info->enable_reg); 342 regmap_write(info->pmu_map, info->data->phy_offset, 0);
336 343
337 con = readl(ADC_V2_CON1(info->regs)); 344 con = readl(ADC_V2_CON1(info->regs));
338 con &= ~ADC_CON_EN_START; 345 con &= ~ADC_CON_EN_START;
@@ -362,6 +369,7 @@ static const struct exynos_adc_data exynos_adc_v2_data = {
362 .num_channels = MAX_ADC_V2_CHANNELS, 369 .num_channels = MAX_ADC_V2_CHANNELS,
363 .mask = ADC_DATX_MASK, /* 12 bit ADC resolution */ 370 .mask = ADC_DATX_MASK, /* 12 bit ADC resolution */
364 .needs_adc_phy = true, 371 .needs_adc_phy = true,
372 .phy_offset = EXYNOS_ADCV2_PHY_OFFSET,
365 373
366 .init_hw = exynos_adc_v2_init_hw, 374 .init_hw = exynos_adc_v2_init_hw,
367 .exit_hw = exynos_adc_v2_exit_hw, 375 .exit_hw = exynos_adc_v2_exit_hw,
@@ -374,6 +382,7 @@ static const struct exynos_adc_data exynos3250_adc_data = {
374 .mask = ADC_DATX_MASK, /* 12 bit ADC resolution */ 382 .mask = ADC_DATX_MASK, /* 12 bit ADC resolution */
375 .needs_sclk = true, 383 .needs_sclk = true,
376 .needs_adc_phy = true, 384 .needs_adc_phy = true,
385 .phy_offset = EXYNOS_ADCV1_PHY_OFFSET,
377 386
378 .init_hw = exynos_adc_v2_init_hw, 387 .init_hw = exynos_adc_v2_init_hw,
379 .exit_hw = exynos_adc_v2_exit_hw, 388 .exit_hw = exynos_adc_v2_exit_hw,
@@ -558,10 +567,13 @@ static int exynos_adc_probe(struct platform_device *pdev)
558 567
559 568
560 if (info->data->needs_adc_phy) { 569 if (info->data->needs_adc_phy) {
561 mem = platform_get_resource(pdev, IORESOURCE_MEM, 1); 570 info->pmu_map = syscon_regmap_lookup_by_phandle(
562 info->enable_reg = devm_ioremap_resource(&pdev->dev, mem); 571 pdev->dev.of_node,
563 if (IS_ERR(info->enable_reg)) 572 "samsung,syscon-phandle");
564 return PTR_ERR(info->enable_reg); 573 if (IS_ERR(info->pmu_map)) {
574 dev_err(&pdev->dev, "syscon regmap lookup failed.\n");
575 return PTR_ERR(info->pmu_map);
576 }
565 } 577 }
566 578
567 irq = platform_get_irq(pdev, 0); 579 irq = platform_get_irq(pdev, 0);