aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/devicetree/bindings/input/touchscreen/auo_pixcir_ts.txt30
-rw-r--r--drivers/input/touchscreen/auo-pixcir-ts.c74
2 files changed, 99 insertions, 5 deletions
diff --git a/Documentation/devicetree/bindings/input/touchscreen/auo_pixcir_ts.txt b/Documentation/devicetree/bindings/input/touchscreen/auo_pixcir_ts.txt
new file mode 100644
index 000000000000..f40f21c642b9
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/touchscreen/auo_pixcir_ts.txt
@@ -0,0 +1,30 @@
1* AUO in-cell touchscreen controller using Pixcir sensors
2
3Required properties:
4- compatible: must be "auo,auo_pixcir_ts"
5- reg: I2C address of the chip
6- interrupts: interrupt to which the chip is connected
7- gpios: gpios the chip is connected to
8 first one is the interrupt gpio and second one the reset gpio
9- x-size: horizontal resolution of touchscreen
10- y-size: vertical resolution of touchscreen
11
12Example:
13
14 i2c@00000000 {
15 /* ... */
16
17 auo_pixcir_ts@5c {
18 compatible = "auo,auo_pixcir_ts";
19 reg = <0x5c>;
20 interrupts = <2 0>;
21
22 gpios = <&gpf 2 0 2>, /* INT */
23 <&gpf 5 1 0>; /* RST */
24
25 x-size = <800>;
26 y-size = <600>;
27 };
28
29 /* ... */
30 };
diff --git a/drivers/input/touchscreen/auo-pixcir-ts.c b/drivers/input/touchscreen/auo-pixcir-ts.c
index c0a2483b30cb..dfa6d5463ef7 100644
--- a/drivers/input/touchscreen/auo-pixcir-ts.c
+++ b/drivers/input/touchscreen/auo-pixcir-ts.c
@@ -31,6 +31,8 @@
31#include <linux/delay.h> 31#include <linux/delay.h>
32#include <linux/gpio.h> 32#include <linux/gpio.h>
33#include <linux/input/auo-pixcir-ts.h> 33#include <linux/input/auo-pixcir-ts.h>
34#include <linux/of.h>
35#include <linux/of_gpio.h>
34 36
35/* 37/*
36 * Coordinate calculation: 38 * Coordinate calculation:
@@ -479,19 +481,72 @@ unlock:
479} 481}
480#endif 482#endif
481 483
482static SIMPLE_DEV_PM_OPS(auo_pixcir_pm_ops, auo_pixcir_suspend, 484static SIMPLE_DEV_PM_OPS(auo_pixcir_pm_ops,
483 auo_pixcir_resume); 485 auo_pixcir_suspend, auo_pixcir_resume);
486
487#ifdef CONFIG_OF
488static struct auo_pixcir_ts_platdata *auo_pixcir_parse_dt(struct device *dev)
489{
490 struct auo_pixcir_ts_platdata *pdata;
491 struct device_node *np = dev->of_node;
492
493 if (!np)
494 return ERR_PTR(-ENOENT);
495
496 pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
497 if (!pdata) {
498 dev_err(dev, "failed to allocate platform data\n");
499 return ERR_PTR(-ENOMEM);
500 }
501
502 pdata->gpio_int = of_get_gpio(np, 0);
503 if (!gpio_is_valid(pdata->gpio_int)) {
504 dev_err(dev, "failed to get interrupt gpio\n");
505 return ERR_PTR(-EINVAL);
506 }
507
508 pdata->gpio_rst = of_get_gpio(np, 1);
509 if (!gpio_is_valid(pdata->gpio_rst)) {
510 dev_err(dev, "failed to get reset gpio\n");
511 return ERR_PTR(-EINVAL);
512 }
513
514 if (of_property_read_u32(np, "x-size", &pdata->x_max)) {
515 dev_err(dev, "failed to get x-size property\n");
516 return ERR_PTR(-EINVAL);
517 }
518
519 if (of_property_read_u32(np, "y-size", &pdata->y_max)) {
520 dev_err(dev, "failed to get y-size property\n");
521 return ERR_PTR(-EINVAL);
522 }
523
524 /* default to asserting the interrupt when the screen is touched */
525 pdata->int_setting = AUO_PIXCIR_INT_TOUCH_IND;
526
527 return pdata;
528}
529#else
530static struct auo_pixcir_ts_platdata *auo_pixcir_parse_dt(struct device *dev)
531{
532 return ERR_PTR(-EINVAL);
533}
534#endif
484 535
485static int auo_pixcir_probe(struct i2c_client *client, 536static int auo_pixcir_probe(struct i2c_client *client,
486 const struct i2c_device_id *id) 537 const struct i2c_device_id *id)
487{ 538{
488 const struct auo_pixcir_ts_platdata *pdata = client->dev.platform_data; 539 const struct auo_pixcir_ts_platdata *pdata;
489 struct auo_pixcir_ts *ts; 540 struct auo_pixcir_ts *ts;
490 struct input_dev *input_dev; 541 struct input_dev *input_dev;
491 int ret; 542 int ret;
492 543
493 if (!pdata) 544 pdata = dev_get_platdata(&client->dev);
494 return -EINVAL; 545 if (!pdata) {
546 pdata = auo_pixcir_parse_dt(&client->dev);
547 if (IS_ERR(pdata))
548 return PTR_ERR(pdata);
549 }
495 550
496 ts = kzalloc(sizeof(struct auo_pixcir_ts), GFP_KERNEL); 551 ts = kzalloc(sizeof(struct auo_pixcir_ts), GFP_KERNEL);
497 if (!ts) 552 if (!ts)
@@ -647,11 +702,20 @@ static const struct i2c_device_id auo_pixcir_idtable[] = {
647}; 702};
648MODULE_DEVICE_TABLE(i2c, auo_pixcir_idtable); 703MODULE_DEVICE_TABLE(i2c, auo_pixcir_idtable);
649 704
705#ifdef CONFIG_OF
706static struct of_device_id auo_pixcir_ts_dt_idtable[] = {
707 { .compatible = "auo,auo_pixcir_ts" },
708 {},
709};
710MODULE_DEVICE_TABLE(of, auo_pixcir_ts_dt_idtable);
711#endif
712
650static struct i2c_driver auo_pixcir_driver = { 713static struct i2c_driver auo_pixcir_driver = {
651 .driver = { 714 .driver = {
652 .owner = THIS_MODULE, 715 .owner = THIS_MODULE,
653 .name = "auo_pixcir_ts", 716 .name = "auo_pixcir_ts",
654 .pm = &auo_pixcir_pm_ops, 717 .pm = &auo_pixcir_pm_ops,
718 .of_match_table = of_match_ptr(auo_pixcir_ts_dt_idtable),
655 }, 719 },
656 .probe = auo_pixcir_probe, 720 .probe = auo_pixcir_probe,
657 .remove = auo_pixcir_remove, 721 .remove = auo_pixcir_remove,