aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/touchscreen/stmpe-ts.c
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 /drivers/input/touchscreen/stmpe-ts.c
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>
Diffstat (limited to 'drivers/input/touchscreen/stmpe-ts.c')
-rw-r--r--drivers/input/touchscreen/stmpe-ts.c65
1 files changed, 47 insertions, 18 deletions
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