diff options
author | Heiko Stübner <heiko@sntech.de> | 2013-02-23 15:08:55 -0500 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2013-02-24 22:10:18 -0500 |
commit | 7241443f67bb352183bcfd7e3b807b87f2777b5d (patch) | |
tree | 24643c68bf0b3dfac6825fd5df0f0bad91546f98 /drivers | |
parent | 38e83f7f9169400047aa3033d643891da1b00441 (diff) |
Input: auo_pixcir_ts - add devicetree support
Add the necessary code to create the needed platformdata from devicetree
informations.
The interrupt mode of the chip is not set via devicetree, as it is not
a property of the hardware but instead only a preferred type of operation.
This should probably be made settable via configfs in the future.
The option set as default is the mode the datasheet mentions as default.
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/input/touchscreen/auo-pixcir-ts.c | 74 |
1 files changed, 69 insertions, 5 deletions
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 | ||
482 | static SIMPLE_DEV_PM_OPS(auo_pixcir_pm_ops, auo_pixcir_suspend, | 484 | static SIMPLE_DEV_PM_OPS(auo_pixcir_pm_ops, |
483 | auo_pixcir_resume); | 485 | auo_pixcir_suspend, auo_pixcir_resume); |
486 | |||
487 | #ifdef CONFIG_OF | ||
488 | static 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 | ||
530 | static struct auo_pixcir_ts_platdata *auo_pixcir_parse_dt(struct device *dev) | ||
531 | { | ||
532 | return ERR_PTR(-EINVAL); | ||
533 | } | ||
534 | #endif | ||
484 | 535 | ||
485 | static int auo_pixcir_probe(struct i2c_client *client, | 536 | static 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 | }; |
648 | MODULE_DEVICE_TABLE(i2c, auo_pixcir_idtable); | 703 | MODULE_DEVICE_TABLE(i2c, auo_pixcir_idtable); |
649 | 704 | ||
705 | #ifdef CONFIG_OF | ||
706 | static struct of_device_id auo_pixcir_ts_dt_idtable[] = { | ||
707 | { .compatible = "auo,auo_pixcir_ts" }, | ||
708 | {}, | ||
709 | }; | ||
710 | MODULE_DEVICE_TABLE(of, auo_pixcir_ts_dt_idtable); | ||
711 | #endif | ||
712 | |||
650 | static struct i2c_driver auo_pixcir_driver = { | 713 | static 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, |