Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Input: pixcir_i2c_ts - add device tree support

Provide device tree support and binding information. Also provide support
for a new chip "pixcir_tangoc".

Signed-off-by: Roger Quadros <rogerq@ti.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

Roger Quadros and committed by
Dmitry Torokhov
a4054596 36874c7e

+104
+26
Documentation/devicetree/bindings/input/touchscreen/pixcir_i2c_ts.txt
··· 1 + * Pixcir I2C touchscreen controllers 2 + 3 + Required properties: 4 + - compatible: must be "pixcir,pixcir_ts" or "pixcir,pixcir_tangoc" 5 + - reg: I2C address of the chip 6 + - interrupts: interrupt to which the chip is connected 7 + - attb-gpio: GPIO connected to the ATTB line of the chip 8 + - touchscreen-size-x: horizontal resolution of touchscreen (in pixels) 9 + - touchscreen-size-y: vertical resolution of touchscreen (in pixels) 10 + 11 + Example: 12 + 13 + i2c@00000000 { 14 + /* ... */ 15 + 16 + pixcir_ts@5c { 17 + compatible = "pixcir,pixcir_ts"; 18 + reg = <0x5c>; 19 + interrupts = <2 0>; 20 + attb-gpio = <&gpf 2 0 2>; 21 + touchscreen-size-x = <800>; 22 + touchscreen-size-y = <600>; 23 + }; 24 + 25 + /* ... */ 26 + };
+1
Documentation/devicetree/bindings/vendor-prefixes.txt
··· 99 99 phytec PHYTEC Messtechnik GmbH 100 100 picochip Picochip Ltd 101 101 plathome Plat'Home Co., Ltd. 102 + pixcir PIXCIR MICROELECTRONICS Co., Ltd 102 103 powervr PowerVR (deprecated, use img) 103 104 qca Qualcomm Atheros, Inc. 104 105 qcom Qualcomm Technologies, Inc
+77
drivers/input/touchscreen/pixcir_i2c_ts.c
··· 26 26 #include <linux/input/mt.h> 27 27 #include <linux/input/pixcir_ts.h> 28 28 #include <linux/gpio.h> 29 + #include <linux/of.h> 30 + #include <linux/of_gpio.h> 31 + #include <linux/of_device.h> 29 32 30 33 #define PIXCIR_MAX_SLOTS 5 /* Max fingers supported by driver */ 31 34 ··· 410 407 static SIMPLE_DEV_PM_OPS(pixcir_dev_pm_ops, 411 408 pixcir_i2c_ts_suspend, pixcir_i2c_ts_resume); 412 409 410 + #ifdef CONFIG_OF 411 + static const struct of_device_id pixcir_of_match[]; 412 + 413 + static struct pixcir_ts_platform_data *pixcir_parse_dt(struct device *dev) 414 + { 415 + struct pixcir_ts_platform_data *pdata; 416 + struct device_node *np = dev->of_node; 417 + const struct of_device_id *match; 418 + 419 + match = of_match_device(of_match_ptr(pixcir_of_match), dev); 420 + if (!match) 421 + return ERR_PTR(-EINVAL); 422 + 423 + pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); 424 + if (!pdata) 425 + return ERR_PTR(-ENOMEM); 426 + 427 + pdata->chip = *(const struct pixcir_i2c_chip_data *)match->data; 428 + 429 + pdata->gpio_attb = of_get_named_gpio(np, "attb-gpio", 0); 430 + /* gpio_attb validity is checked in probe */ 431 + 432 + if (of_property_read_u32(np, "touchscreen-size-x", &pdata->x_max)) { 433 + dev_err(dev, "Failed to get touchscreen-size-x property\n"); 434 + return ERR_PTR(-EINVAL); 435 + } 436 + pdata->x_max -= 1; 437 + 438 + if (of_property_read_u32(np, "touchscreen-size-y", &pdata->y_max)) { 439 + dev_err(dev, "Failed to get touchscreen-size-y property\n"); 440 + return ERR_PTR(-EINVAL); 441 + } 442 + pdata->y_max -= 1; 443 + 444 + dev_dbg(dev, "%s: x %d, y %d, gpio %d\n", __func__, 445 + pdata->x_max + 1, pdata->y_max + 1, pdata->gpio_attb); 446 + 447 + return pdata; 448 + } 449 + #else 450 + static struct pixcir_ts_platform_data *pixcir_parse_dt(struct device *dev) 451 + { 452 + return ERR_PTR(-EINVAL); 453 + } 454 + #endif 455 + 413 456 static int pixcir_i2c_ts_probe(struct i2c_client *client, 414 457 const struct i2c_device_id *id) 415 458 { 416 459 const struct pixcir_ts_platform_data *pdata = 417 460 dev_get_platdata(&client->dev); 418 461 struct device *dev = &client->dev; 462 + struct device_node *np = dev->of_node; 419 463 struct pixcir_i2c_ts_data *tsdata; 420 464 struct input_dev *input; 421 465 int error; 466 + 467 + if (np && !pdata) { 468 + pdata = pixcir_parse_dt(dev); 469 + if (IS_ERR(pdata)) 470 + return PTR_ERR(pdata); 471 + } 422 472 423 473 if (!pdata) { 424 474 dev_err(&client->dev, "platform data not defined\n"); ··· 578 522 579 523 static const struct i2c_device_id pixcir_i2c_ts_id[] = { 580 524 { "pixcir_ts", 0 }, 525 + { "pixcir_tangoc", 0 }, 581 526 { } 582 527 }; 583 528 MODULE_DEVICE_TABLE(i2c, pixcir_i2c_ts_id); 529 + 530 + #ifdef CONFIG_OF 531 + static const struct pixcir_i2c_chip_data pixcir_ts_data = { 532 + .max_fingers = 2, 533 + /* no hw id support */ 534 + }; 535 + 536 + static const struct pixcir_i2c_chip_data pixcir_tangoc_data = { 537 + .max_fingers = 5, 538 + .has_hw_ids = true, 539 + }; 540 + 541 + static const struct of_device_id pixcir_of_match[] = { 542 + { .compatible = "pixcir,pixcir_ts", .data = &pixcir_ts_data }, 543 + { .compatible = "pixcir,pixcir_tangoc", .data = &pixcir_tangoc_data }, 544 + { } 545 + }; 546 + MODULE_DEVICE_TABLE(of, pixcir_of_match); 547 + #endif 584 548 585 549 static struct i2c_driver pixcir_i2c_ts_driver = { 586 550 .driver = { 587 551 .owner = THIS_MODULE, 588 552 .name = "pixcir_ts", 589 553 .pm = &pixcir_dev_pm_ops, 554 + .of_match_table = of_match_ptr(pixcir_of_match), 590 555 }, 591 556 .probe = pixcir_i2c_ts_probe, 592 557 .remove = pixcir_i2c_ts_remove,