diff options
author | Sebastian Andrzej Siewior <bigeasy@linutronix.de> | 2013-05-29 17:39:02 +0200 |
---|---|---|
committer | Sebastian Andrzej Siewior <bigeasy@linutronix.de> | 2013-06-12 18:50:23 +0200 |
commit | 18926edebcb82ca325abf843293801d4ff43436a (patch) | |
tree | 17b4966968b04bc4e61a8ca87ed21642e472f583 /drivers/mfd/ti_am335x_tscadc.c | |
parent | input: ti_am335x_tsc: return IRQ_NONE if there was no IRQ for us (diff) | |
download | linux-18926edebcb82ca325abf843293801d4ff43436a.tar.xz linux-18926edebcb82ca325abf843293801d4ff43436a.zip |
iio: ti_am335x_adc: Allow to specify input line
The TSC part allows to specify the input lines. The IIO part assumes
that it usues always the last few, that means if IIO has adc-channels
set to 2 it will use channel 6 and 7. However it might make sense to use
only 6.
This patch changes the device property (which was introduced recently
and was never in an official release) in a way that the user can specify
which of the AIN lines should be used. In Addition to this, the name is
now AINx where x is the channel number i.e. for AIN6 we would have 6.
Prior this, it always started counting at 0 which is confusing. In
addition to this, it also checks for correct step number during reading
and does not rely on proper FIFO depth.
Acked-by: Jonathan Cameron <jic23@kernel.org>
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.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c index 253233915009..b003a16ba227 100644 --- a/drivers/mfd/ti_am335x_tscadc.c +++ b/drivers/mfd/ti_am335x_tscadc.c @@ -91,9 +91,13 @@ static int ti_tscadc_probe(struct platform_device *pdev) struct clk *clk; struct device_node *node = pdev->dev.of_node; struct mfd_cell *cell; + struct property *prop; + const __be32 *cur; + u32 val; int err, ctrl; int clk_value, clock_rate; int tsc_wires = 0, adc_channels = 0, total_channels; + int readouts = 0; if (!pdev->dev.of_node) { dev_err(&pdev->dev, "Could not find valid DT data.\n"); @@ -102,10 +106,17 @@ static int ti_tscadc_probe(struct platform_device *pdev) node = of_get_child_by_name(pdev->dev.of_node, "tsc"); of_property_read_u32(node, "ti,wires", &tsc_wires); + of_property_read_u32(node, "ti,coordiante-readouts", &readouts); node = of_get_child_by_name(pdev->dev.of_node, "adc"); - of_property_read_u32(node, "ti,adc-channels", &adc_channels); - + of_property_for_each_u32(node, "ti,adc-channels", prop, cur, val) { + adc_channels++; + if (val > 7) { + dev_err(&pdev->dev, " PIN numbers are 0..7 (not %d)\n", + val); + return -EINVAL; + } + } total_channels = tsc_wires + adc_channels; if (total_channels > 8) { dev_err(&pdev->dev, "Number of i/p channels more than 8\n"); @@ -116,6 +127,11 @@ static int ti_tscadc_probe(struct platform_device *pdev) return -EINVAL; } + if (readouts * 2 + 2 + adc_channels > 16) { + dev_err(&pdev->dev, "Too many step configurations requested\n"); + return -EINVAL; + } + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { dev_err(&pdev->dev, "no memory resource defined.\n"); |