aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mfd/ti_am335x_tscadc.c
diff options
context:
space:
mode:
authorPatil, Rachna <rachna@ti.com>2013-01-23 22:45:05 -0500
committerSebastian Andrzej Siewior <bigeasy@linutronix.de>2013-06-12 12:03:55 -0400
commitabeccee40320245a2a6a006dc8466a703cbd1d5e (patch)
tree1c6709c2d53fd65f77a226abab9a552e5ce73fb5 /drivers/mfd/ti_am335x_tscadc.c
parenta9bce1b03c2199e66d36cda8aac675338bc074a7 (diff)
input: ti_am33x_tsc: Step enable bits made configurable
Current code has hard coded value written to step enable bits. Now the bits are updated based on how many steps are needed to be configured got from platform data. The user needs to take care not to exceed the count more than 16. While using ADC and TSC one should take care to set this parameter correctly. Sebastian added the common lock and moved the code, that manipulates the steps, from into the mfd module. Signed-off-by: Patil, Rachna <rachna@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Diffstat (limited to 'drivers/mfd/ti_am335x_tscadc.c')
-rw-r--r--drivers/mfd/ti_am335x_tscadc.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
index 772ea2adb539..90ccfc07e16b 100644
--- a/drivers/mfd/ti_am335x_tscadc.c
+++ b/drivers/mfd/ti_am335x_tscadc.c
@@ -48,6 +48,32 @@ static const struct regmap_config tscadc_regmap_config = {
48 .val_bits = 32, 48 .val_bits = 32,
49}; 49};
50 50
51void am335x_tsc_se_update(struct ti_tscadc_dev *tsadc)
52{
53 tscadc_writel(tsadc, REG_SE, tsadc->reg_se_cache);
54}
55EXPORT_SYMBOL_GPL(am335x_tsc_se_update);
56
57void am335x_tsc_se_set(struct ti_tscadc_dev *tsadc, u32 val)
58{
59 spin_lock(&tsadc->reg_lock);
60 tsadc->reg_se_cache |= val;
61 spin_unlock(&tsadc->reg_lock);
62
63 am335x_tsc_se_update(tsadc);
64}
65EXPORT_SYMBOL_GPL(am335x_tsc_se_set);
66
67void am335x_tsc_se_clr(struct ti_tscadc_dev *tsadc, u32 val)
68{
69 spin_lock(&tsadc->reg_lock);
70 tsadc->reg_se_cache &= ~val;
71 spin_unlock(&tsadc->reg_lock);
72
73 am335x_tsc_se_update(tsadc);
74}
75EXPORT_SYMBOL_GPL(am335x_tsc_se_clr);
76
51static void tscadc_idle_config(struct ti_tscadc_dev *config) 77static void tscadc_idle_config(struct ti_tscadc_dev *config)
52{ 78{
53 unsigned int idleconfig; 79 unsigned int idleconfig;
@@ -129,6 +155,7 @@ static int ti_tscadc_probe(struct platform_device *pdev)
129 goto ret; 155 goto ret;
130 } 156 }
131 157
158 spin_lock_init(&tscadc->reg_lock);
132 pm_runtime_enable(&pdev->dev); 159 pm_runtime_enable(&pdev->dev);
133 pm_runtime_get_sync(&pdev->dev); 160 pm_runtime_get_sync(&pdev->dev);
134 161
@@ -239,7 +266,7 @@ static int tscadc_resume(struct device *dev)
239 CNTRLREG_STEPID | CNTRLREG_4WIRE; 266 CNTRLREG_STEPID | CNTRLREG_4WIRE;
240 tscadc_writel(tscadc_dev, REG_CTRL, ctrl); 267 tscadc_writel(tscadc_dev, REG_CTRL, ctrl);
241 tscadc_idle_config(tscadc_dev); 268 tscadc_idle_config(tscadc_dev);
242 tscadc_writel(tscadc_dev, REG_SE, STPENB_STEPENB); 269 am335x_tsc_se_update(tscadc_dev);
243 restore = tscadc_readl(tscadc_dev, REG_CTRL); 270 restore = tscadc_readl(tscadc_dev, REG_CTRL);
244 tscadc_writel(tscadc_dev, REG_CTRL, 271 tscadc_writel(tscadc_dev, REG_CTRL,
245 (restore | CNTRLREG_TSCSSENB)); 272 (restore | CNTRLREG_TSCSSENB));