aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iio
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/iio
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/iio')
-rw-r--r--drivers/iio/adc/ti_am335x_adc.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c
index 9db352e413e4..543b9c42ac5f 100644
--- a/drivers/iio/adc/ti_am335x_adc.c
+++ b/drivers/iio/adc/ti_am335x_adc.c
@@ -42,10 +42,20 @@ static void tiadc_writel(struct tiadc_device *adc, unsigned int reg,
42 writel(val, adc->mfd_tscadc->tscadc_base + reg); 42 writel(val, adc->mfd_tscadc->tscadc_base + reg);
43} 43}
44 44
45static u32 get_adc_step_mask(struct tiadc_device *adc_dev)
46{
47 u32 step_en;
48
49 step_en = ((1 << adc_dev->channels) - 1);
50 step_en <<= TOTAL_STEPS - adc_dev->channels + 1;
51 return step_en;
52}
53
45static void tiadc_step_config(struct tiadc_device *adc_dev) 54static void tiadc_step_config(struct tiadc_device *adc_dev)
46{ 55{
47 unsigned int stepconfig; 56 unsigned int stepconfig;
48 int i, channels = 0, steps; 57 int i, channels = 0, steps;
58 u32 step_en;
49 59
50 /* 60 /*
51 * There are 16 configurable steps and 8 analog input 61 * There are 16 configurable steps and 8 analog input
@@ -69,7 +79,8 @@ static void tiadc_step_config(struct tiadc_device *adc_dev)
69 STEPCONFIG_OPENDLY); 79 STEPCONFIG_OPENDLY);
70 channels++; 80 channels++;
71 } 81 }
72 tiadc_writel(adc_dev, REG_SE, STPENB_STEPENB); 82 step_en = get_adc_step_mask(adc_dev);
83 am335x_tsc_se_set(adc_dev->mfd_tscadc, step_en);
73} 84}
74 85
75static int tiadc_channel_init(struct iio_dev *indio_dev, int channels) 86static int tiadc_channel_init(struct iio_dev *indio_dev, int channels)
@@ -127,7 +138,7 @@ static int tiadc_read_raw(struct iio_dev *indio_dev,
127 if (i == chan->channel) 138 if (i == chan->channel)
128 *val = readx1 & 0xfff; 139 *val = readx1 & 0xfff;
129 } 140 }
130 tiadc_writel(adc_dev, REG_SE, STPENB_STEPENB); 141 am335x_tsc_se_update(adc_dev->mfd_tscadc);
131 142
132 return IIO_VAL_INT; 143 return IIO_VAL_INT;
133} 144}
@@ -191,10 +202,15 @@ err_ret:
191static int tiadc_remove(struct platform_device *pdev) 202static int tiadc_remove(struct platform_device *pdev)
192{ 203{
193 struct iio_dev *indio_dev = platform_get_drvdata(pdev); 204 struct iio_dev *indio_dev = platform_get_drvdata(pdev);
205 struct tiadc_device *adc_dev = iio_priv(indio_dev);
206 u32 step_en;
194 207
195 iio_device_unregister(indio_dev); 208 iio_device_unregister(indio_dev);
196 tiadc_channels_remove(indio_dev); 209 tiadc_channels_remove(indio_dev);
197 210
211 step_en = get_adc_step_mask(adc_dev);
212 am335x_tsc_se_clr(adc_dev->mfd_tscadc, step_en);
213
198 iio_device_free(indio_dev); 214 iio_device_free(indio_dev);
199 215
200 return 0; 216 return 0;