aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mfd/ti_am335x_tscadc.c
diff options
context:
space:
mode:
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>2013-05-29 11:39:02 -0400
committerSebastian Andrzej Siewior <bigeasy@linutronix.de>2013-06-12 12:50:23 -0400
commit18926edebcb82ca325abf843293801d4ff43436a (patch)
tree17b4966968b04bc4e61a8ca87ed21642e472f583 /drivers/mfd/ti_am335x_tscadc.c
parent9a28b8834c55f7315fb1a7c487f836472fd37bf9 (diff)
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.c20
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)
91 struct clk *clk; 91 struct clk *clk;
92 struct device_node *node = pdev->dev.of_node; 92 struct device_node *node = pdev->dev.of_node;
93 struct mfd_cell *cell; 93 struct mfd_cell *cell;
94 struct property *prop;
95 const __be32 *cur;
96 u32 val;
94 int err, ctrl; 97 int err, ctrl;
95 int clk_value, clock_rate; 98 int clk_value, clock_rate;
96 int tsc_wires = 0, adc_channels = 0, total_channels; 99 int tsc_wires = 0, adc_channels = 0, total_channels;
100 int readouts = 0;
97 101
98 if (!pdev->dev.of_node) { 102 if (!pdev->dev.of_node) {
99 dev_err(&pdev->dev, "Could not find valid DT data.\n"); 103 dev_err(&pdev->dev, "Could not find valid DT data.\n");
@@ -102,10 +106,17 @@ static int ti_tscadc_probe(struct platform_device *pdev)
102 106
103 node = of_get_child_by_name(pdev->dev.of_node, "tsc"); 107 node = of_get_child_by_name(pdev->dev.of_node, "tsc");
104 of_property_read_u32(node, "ti,wires", &tsc_wires); 108 of_property_read_u32(node, "ti,wires", &tsc_wires);
109 of_property_read_u32(node, "ti,coordiante-readouts", &readouts);
105 110
106 node = of_get_child_by_name(pdev->dev.of_node, "adc"); 111 node = of_get_child_by_name(pdev->dev.of_node, "adc");
107 of_property_read_u32(node, "ti,adc-channels", &adc_channels); 112 of_property_for_each_u32(node, "ti,adc-channels", prop, cur, val) {
108 113 adc_channels++;
114 if (val > 7) {
115 dev_err(&pdev->dev, " PIN numbers are 0..7 (not %d)\n",
116 val);
117 return -EINVAL;
118 }
119 }
109 total_channels = tsc_wires + adc_channels; 120 total_channels = tsc_wires + adc_channels;
110 if (total_channels > 8) { 121 if (total_channels > 8) {
111 dev_err(&pdev->dev, "Number of i/p channels more than 8\n"); 122 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)
116 return -EINVAL; 127 return -EINVAL;
117 } 128 }
118 129
130 if (readouts * 2 + 2 + adc_channels > 16) {
131 dev_err(&pdev->dev, "Too many step configurations requested\n");
132 return -EINVAL;
133 }
134
119 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 135 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
120 if (!res) { 136 if (!res) {
121 dev_err(&pdev->dev, "no memory resource defined.\n"); 137 dev_err(&pdev->dev, "no memory resource defined.\n");