stmpe-ts.c (3152657f104ce9b0f80793c92a745d5e97b43812) stmpe-ts.c (e4b88e19897f1039fd83f1630517becafc0dd163)
1/*
2 * STMicroelectronics STMPE811 Touchscreen Driver
3 *
4 * (C) 2010 Luotao Fu <l.fu@pengutronix.de>
5 * All rights reserved.
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the

--- 253 unchanged lines hidden (view full) ---

262
263 stmpe_set_bits(ts->stmpe, STMPE_REG_TSC_CTRL,
264 STMPE_TSC_CTRL_TSC_EN, 0);
265}
266
267static void stmpe_ts_get_platform_info(struct platform_device *pdev,
268 struct stmpe_touch *ts)
269{
1/*
2 * STMicroelectronics STMPE811 Touchscreen Driver
3 *
4 * (C) 2010 Luotao Fu <l.fu@pengutronix.de>
5 * All rights reserved.
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the

--- 253 unchanged lines hidden (view full) ---

262
263 stmpe_set_bits(ts->stmpe, STMPE_REG_TSC_CTRL,
264 STMPE_TSC_CTRL_TSC_EN, 0);
265}
266
267static void stmpe_ts_get_platform_info(struct platform_device *pdev,
268 struct stmpe_touch *ts)
269{
270 struct stmpe *stmpe = dev_get_drvdata(pdev->dev.parent);
271 struct device_node *np = pdev->dev.of_node;
270 struct device_node *np = pdev->dev.of_node;
272 struct stmpe_ts_platform_data *ts_pdata = NULL;
271 u32 val;
273
272
274 ts->stmpe = stmpe;
275
276 if (stmpe->pdata && stmpe->pdata->ts) {
277 ts_pdata = stmpe->pdata->ts;
278
279 ts->sample_time = ts_pdata->sample_time;
280 ts->mod_12b = ts_pdata->mod_12b;
281 ts->ref_sel = ts_pdata->ref_sel;
282 ts->adc_freq = ts_pdata->adc_freq;
283 ts->ave_ctrl = ts_pdata->ave_ctrl;
284 ts->touch_det_delay = ts_pdata->touch_det_delay;
285 ts->settling = ts_pdata->settling;
286 ts->fraction_z = ts_pdata->fraction_z;
287 ts->i_drive = ts_pdata->i_drive;
288 } else if (np) {
289 u32 val;
290
273 if (np) {
291 if (!of_property_read_u32(np, "st,sample-time", &val))
292 ts->sample_time = val;
293 if (!of_property_read_u32(np, "st,mod-12b", &val))
294 ts->mod_12b = val;
295 if (!of_property_read_u32(np, "st,ref-sel", &val))
296 ts->ref_sel = val;
297 if (!of_property_read_u32(np, "st,adc-freq", &val))
298 ts->adc_freq = val;

--- 7 unchanged lines hidden (view full) ---

306 ts->fraction_z = val;
307 if (!of_property_read_u32(np, "st,i-drive", &val))
308 ts->i_drive = val;
309 }
310}
311
312static int stmpe_input_probe(struct platform_device *pdev)
313{
274 if (!of_property_read_u32(np, "st,sample-time", &val))
275 ts->sample_time = val;
276 if (!of_property_read_u32(np, "st,mod-12b", &val))
277 ts->mod_12b = val;
278 if (!of_property_read_u32(np, "st,ref-sel", &val))
279 ts->ref_sel = val;
280 if (!of_property_read_u32(np, "st,adc-freq", &val))
281 ts->adc_freq = val;

--- 7 unchanged lines hidden (view full) ---

289 ts->fraction_z = val;
290 if (!of_property_read_u32(np, "st,i-drive", &val))
291 ts->i_drive = val;
292 }
293}
294
295static int stmpe_input_probe(struct platform_device *pdev)
296{
297 struct stmpe *stmpe = dev_get_drvdata(pdev->dev.parent);
314 struct stmpe_touch *ts;
315 struct input_dev *idev;
316 int error;
317 int ts_irq;
318
319 ts_irq = platform_get_irq_byname(pdev, "FIFO_TH");
320 if (ts_irq < 0)
321 return ts_irq;
322
323 ts = devm_kzalloc(&pdev->dev, sizeof(*ts), GFP_KERNEL);
324 if (!ts)
325 return -ENOMEM;
326
327 idev = devm_input_allocate_device(&pdev->dev);
328 if (!idev)
329 return -ENOMEM;
330
331 platform_set_drvdata(pdev, ts);
298 struct stmpe_touch *ts;
299 struct input_dev *idev;
300 int error;
301 int ts_irq;
302
303 ts_irq = platform_get_irq_byname(pdev, "FIFO_TH");
304 if (ts_irq < 0)
305 return ts_irq;
306
307 ts = devm_kzalloc(&pdev->dev, sizeof(*ts), GFP_KERNEL);
308 if (!ts)
309 return -ENOMEM;
310
311 idev = devm_input_allocate_device(&pdev->dev);
312 if (!idev)
313 return -ENOMEM;
314
315 platform_set_drvdata(pdev, ts);
316 ts->stmpe = stmpe;
332 ts->idev = idev;
333 ts->dev = &pdev->dev;
334
335 stmpe_ts_get_platform_info(pdev, ts);
336
337 INIT_DELAYED_WORK(&ts->work, stmpe_work);
338
339 error = devm_request_threaded_irq(&pdev->dev, ts_irq,

--- 6 unchanged lines hidden (view full) ---

346
347 error = stmpe_init_hw(ts);
348 if (error)
349 return error;
350
351 idev->name = STMPE_TS_NAME;
352 idev->phys = STMPE_TS_NAME"/input0";
353 idev->id.bustype = BUS_I2C;
317 ts->idev = idev;
318 ts->dev = &pdev->dev;
319
320 stmpe_ts_get_platform_info(pdev, ts);
321
322 INIT_DELAYED_WORK(&ts->work, stmpe_work);
323
324 error = devm_request_threaded_irq(&pdev->dev, ts_irq,

--- 6 unchanged lines hidden (view full) ---

331
332 error = stmpe_init_hw(ts);
333 if (error)
334 return error;
335
336 idev->name = STMPE_TS_NAME;
337 idev->phys = STMPE_TS_NAME"/input0";
338 idev->id.bustype = BUS_I2C;
354 idev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
355 idev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
356
357 idev->open = stmpe_ts_open;
358 idev->close = stmpe_ts_close;
359
360 input_set_drvdata(idev, ts);
361
339
340 idev->open = stmpe_ts_open;
341 idev->close = stmpe_ts_close;
342
343 input_set_drvdata(idev, ts);
344
345 input_set_capability(idev, EV_KEY, BTN_TOUCH);
362 input_set_abs_params(idev, ABS_X, 0, XY_MASK, 0, 0);
363 input_set_abs_params(idev, ABS_Y, 0, XY_MASK, 0, 0);
364 input_set_abs_params(idev, ABS_PRESSURE, 0x0, 0xff, 0, 0);
365
366 error = input_register_device(idev);
367 if (error) {
368 dev_err(&pdev->dev, "Could not register input device\n");
369 return error;

--- 8 unchanged lines hidden (view full) ---

378
379 stmpe_disable(ts->stmpe, STMPE_BLOCK_TOUCHSCREEN);
380
381 return 0;
382}
383
384static struct platform_driver stmpe_ts_driver = {
385 .driver = {
346 input_set_abs_params(idev, ABS_X, 0, XY_MASK, 0, 0);
347 input_set_abs_params(idev, ABS_Y, 0, XY_MASK, 0, 0);
348 input_set_abs_params(idev, ABS_PRESSURE, 0x0, 0xff, 0, 0);
349
350 error = input_register_device(idev);
351 if (error) {
352 dev_err(&pdev->dev, "Could not register input device\n");
353 return error;

--- 8 unchanged lines hidden (view full) ---

362
363 stmpe_disable(ts->stmpe, STMPE_BLOCK_TOUCHSCREEN);
364
365 return 0;
366}
367
368static struct platform_driver stmpe_ts_driver = {
369 .driver = {
386 .name = STMPE_TS_NAME,
387 },
370 .name = STMPE_TS_NAME,
371 },
388 .probe = stmpe_input_probe,
389 .remove = stmpe_ts_remove,
390};
391module_platform_driver(stmpe_ts_driver);
392
372 .probe = stmpe_input_probe,
373 .remove = stmpe_ts_remove,
374};
375module_platform_driver(stmpe_ts_driver);
376
377static const struct of_device_id stmpe_ts_ids[] = {
378 { .compatible = "st,stmpe-ts", },
379 { },
380};
381MODULE_DEVICE_TABLE(of, stmpe_ts_ids);
382
393MODULE_AUTHOR("Luotao Fu <l.fu@pengutronix.de>");
394MODULE_DESCRIPTION("STMPEXXX touchscreen driver");
395MODULE_LICENSE("GPL");
383MODULE_AUTHOR("Luotao Fu <l.fu@pengutronix.de>");
384MODULE_DESCRIPTION("STMPEXXX touchscreen driver");
385MODULE_LICENSE("GPL");
396MODULE_ALIAS("platform:" STMPE_TS_NAME);