aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVipul Kumar Samar <vipulkumar.samar@st.com>2012-11-23 02:42:12 -0500
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2012-11-23 02:47:09 -0500
commit037db524a2015607031c70a7935153120601b908 (patch)
tree82387672d07b8fb9d1fcd0098692256de20895cd
parentedbe265d245b0fe05c43e96e52554dacae5dcc70 (diff)
Input: stmpe-ts - add DT support for stmpe touchscreen
This patch allows the STMPE Touchscreen driver to be successfully probed and initialised when Device Tree support is enabled. Bindings are mentioned in Documentation too. Signed-off-by: Vipul Kumar Samar <vipulkumar.samar@st.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
-rw-r--r--Documentation/devicetree/bindings/input/touchscreen/stmpe.txt43
-rw-r--r--drivers/input/touchscreen/stmpe-ts.c65
-rw-r--r--drivers/mfd/stmpe.c1
3 files changed, 91 insertions, 18 deletions
diff --git a/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt b/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt
new file mode 100644
index 000000000000..127baa31a77a
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt
@@ -0,0 +1,43 @@
1STMPE Touchscreen
2----------------
3
4Required properties:
5 - compatible: "st,stmpe-ts"
6
7Optional properties:
8- st,sample-time: ADC converstion time in number of clock. (0 -> 36 clocks, 1 ->
9 44 clocks, 2 -> 56 clocks, 3 -> 64 clocks, 4 -> 80 clocks, 5 -> 96 clocks, 6
10 -> 144 clocks), recommended is 4.
11- st,mod-12b: ADC Bit mode (0 -> 10bit ADC, 1 -> 12bit ADC)
12- st,ref-sel: ADC reference source (0 -> internal reference, 1 -> external
13 reference)
14- st,adc-freq: ADC Clock speed (0 -> 1.625 MHz, 1 -> 3.25 MHz, 2 || 3 -> 6.5 MHz)
15- st,ave-ctrl: Sample average control (0 -> 1 sample, 1 -> 2 samples, 2 -> 4
16 samples, 3 -> 8 samples)
17- st,touch-det-delay: Touch detect interrupt delay (0 -> 10 us, 1 -> 50 us, 2 ->
18 100 us, 3 -> 500 us, 4-> 1 ms, 5 -> 5 ms, 6 -> 10 ms, 7 -> 50 ms) recommended
19 is 3
20- st,settling: Panel driver settling time (0 -> 10 us, 1 -> 100 us, 2 -> 500 us, 3
21 -> 1 ms, 4 -> 5 ms, 5 -> 10 ms, 6 for 50 ms, 7 -> 100 ms) recommended is 2
22- st,fraction-z: Length of the fractional part in z (fraction-z ([0..7]) = Count of
23 the fractional part) recommended is 7
24- st,i-drive: current limit value of the touchscreen drivers (0 -> 20 mA typical 35
25 mA max, 1 -> 50 mA typical 80 mA max)
26
27Node name must be stmpe_touchscreen and should be child node of stmpe node to
28which it belongs.
29
30Example:
31
32 stmpe_touchscreen {
33 compatible = "st,stmpe-ts";
34 st,sample-time = <4>;
35 st,mod-12b = <1>;
36 st,ref-sel = <0>;
37 st,adc-freq = <1>;
38 st,ave-ctrl = <1>;
39 st,touch-det-delay = <2>;
40 st,settling = <2>;
41 st,fraction-z = <7>;
42 st,i-drive = <1>;
43 };
diff --git a/drivers/input/touchscreen/stmpe-ts.c b/drivers/input/touchscreen/stmpe-ts.c
index b3f75032deac..43e796747f4b 100644
--- a/drivers/input/touchscreen/stmpe-ts.c
+++ b/drivers/input/touchscreen/stmpe-ts.c
@@ -17,6 +17,7 @@
17#include <linux/interrupt.h> 17#include <linux/interrupt.h>
18#include <linux/init.h> 18#include <linux/init.h>
19#include <linux/device.h> 19#include <linux/device.h>
20#include <linux/of.h>
20#include <linux/platform_device.h> 21#include <linux/platform_device.h>
21#include <linux/input.h> 22#include <linux/input.h>
22#include <linux/slab.h> 23#include <linux/slab.h>
@@ -262,11 +263,53 @@ static void stmpe_ts_close(struct input_dev *dev)
262 STMPE_TSC_CTRL_TSC_EN, 0); 263 STMPE_TSC_CTRL_TSC_EN, 0);
263} 264}
264 265
265static int __devinit stmpe_input_probe(struct platform_device *pdev) 266static void stmpe_ts_get_platform_info(struct platform_device *pdev,
267 struct stmpe_touch *ts)
266{ 268{
267 struct stmpe *stmpe = dev_get_drvdata(pdev->dev.parent); 269 struct stmpe *stmpe = dev_get_drvdata(pdev->dev.parent);
268 const struct stmpe_platform_data *pdata = stmpe->pdata; 270 struct device_node *np = pdev->dev.of_node;
269 const struct stmpe_ts_platform_data *ts_pdata = NULL; 271 struct stmpe_ts_platform_data *ts_pdata = NULL;
272
273 ts->stmpe = stmpe;
274
275 if (stmpe->pdata && stmpe->pdata->ts) {
276 ts_pdata = stmpe->pdata->ts;
277
278 ts->sample_time = ts_pdata->sample_time;
279 ts->mod_12b = ts_pdata->mod_12b;
280 ts->ref_sel = ts_pdata->ref_sel;
281 ts->adc_freq = ts_pdata->adc_freq;
282 ts->ave_ctrl = ts_pdata->ave_ctrl;
283 ts->touch_det_delay = ts_pdata->touch_det_delay;
284 ts->settling = ts_pdata->settling;
285 ts->fraction_z = ts_pdata->fraction_z;
286 ts->i_drive = ts_pdata->i_drive;
287 } else if (np) {
288 u32 val;
289
290 if (!of_property_read_u32(np, "st,sample-time", &val))
291 ts->sample_time = val;
292 if (!of_property_read_u32(np, "st,mod-12b", &val))
293 ts->mod_12b = val;
294 if (!of_property_read_u32(np, "st,ref-sel", &val))
295 ts->ref_sel = val;
296 if (!of_property_read_u32(np, "st,adc-freq", &val))
297 ts->adc_freq = val;
298 if (!of_property_read_u32(np, "st,ave-ctrl", &val))
299 ts->ave_ctrl = val;
300 if (!of_property_read_u32(np, "st,touch-det-delay", &val))
301 ts->touch_det_delay = val;
302 if (!of_property_read_u32(np, "st,settling", &val))
303 ts->settling = val;
304 if (!of_property_read_u32(np, "st,fraction-z", &val))
305 ts->fraction_z = val;
306 if (!of_property_read_u32(np, "st,i-drive", &val))
307 ts->i_drive = val;
308 }
309}
310
311static int __devinit stmpe_input_probe(struct platform_device *pdev)
312{
270 struct stmpe_touch *ts; 313 struct stmpe_touch *ts;
271 struct input_dev *idev; 314 struct input_dev *idev;
272 int error; 315 int error;
@@ -285,24 +328,10 @@ static int __devinit stmpe_input_probe(struct platform_device *pdev)
285 return -ENOMEM; 328 return -ENOMEM;
286 329
287 platform_set_drvdata(pdev, ts); 330 platform_set_drvdata(pdev, ts);
288 ts->stmpe = stmpe;
289 ts->idev = idev; 331 ts->idev = idev;
290 ts->dev = &pdev->dev; 332 ts->dev = &pdev->dev;
291 333
292 if (pdata) 334 stmpe_ts_get_platform_info(pdev, ts);
293 ts_pdata = pdata->ts;
294
295 if (ts_pdata) {
296 ts->sample_time = ts_pdata->sample_time;
297 ts->mod_12b = ts_pdata->mod_12b;
298 ts->ref_sel = ts_pdata->ref_sel;
299 ts->adc_freq = ts_pdata->adc_freq;
300 ts->ave_ctrl = ts_pdata->ave_ctrl;
301 ts->touch_det_delay = ts_pdata->touch_det_delay;
302 ts->settling = ts_pdata->settling;
303 ts->fraction_z = ts_pdata->fraction_z;
304 ts->i_drive = ts_pdata->i_drive;
305 }
306 335
307 INIT_DELAYED_WORK(&ts->work, stmpe_work); 336 INIT_DELAYED_WORK(&ts->work, stmpe_work);
308 337
diff --git a/drivers/mfd/stmpe.c b/drivers/mfd/stmpe.c
index c94f521f392c..55c7b9531ad4 100644
--- a/drivers/mfd/stmpe.c
+++ b/drivers/mfd/stmpe.c
@@ -411,6 +411,7 @@ static struct resource stmpe_ts_resources[] = {
411 411
412static struct mfd_cell stmpe_ts_cell = { 412static struct mfd_cell stmpe_ts_cell = {
413 .name = "stmpe-ts", 413 .name = "stmpe-ts",
414 .of_compatible = "st,stmpe-ts",
414 .resources = stmpe_ts_resources, 415 .resources = stmpe_ts_resources,
415 .num_resources = ARRAY_SIZE(stmpe_ts_resources), 416 .num_resources = ARRAY_SIZE(stmpe_ts_resources),
416}; 417};