aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input
diff options
context:
space:
mode:
authorLee Jones <lee.jones@linaro.org>2012-09-28 09:35:43 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2012-11-28 02:05:19 -0500
commit48fceb7d37cde11edf342c5095fa8815365c299f (patch)
tree97da5a94b9612da5c20a3e0d5432e8f04caebcc6 /drivers/input
parent31fbcda71489d8cbe2b82819eaab4818524e3a49 (diff)
Input: bu21013_ts - add support for Device Tree booting
Now we can register the BU21013_ts touch screen when booting with Device Tree enabled. Here we parse all the necessary components previously expected to be passed from platform data. Acked-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Lee Jones <lee.jones@linaro.org> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers/input')
-rw-r--r--drivers/input/touchscreen/bu21013_ts.c50
1 files changed, 46 insertions, 4 deletions
diff --git a/drivers/input/touchscreen/bu21013_ts.c b/drivers/input/touchscreen/bu21013_ts.c
index c6f6a04ec673..b9b5ddad6658 100644
--- a/drivers/input/touchscreen/bu21013_ts.c
+++ b/drivers/input/touchscreen/bu21013_ts.c
@@ -15,6 +15,8 @@
15#include <linux/regulator/consumer.h> 15#include <linux/regulator/consumer.h>
16#include <linux/module.h> 16#include <linux/module.h>
17#include <linux/gpio.h> 17#include <linux/gpio.h>
18#include <linux/of.h>
19#include <linux/of_gpio.h>
18 20
19#define PEN_DOWN_INTR 0 21#define PEN_DOWN_INTR 0
20#define MAX_FINGERS 2 22#define MAX_FINGERS 2
@@ -445,6 +447,45 @@ static void bu21013_cs_disable(struct bu21013_ts_data *bu21013_data)
445 gpio_free(bu21013_data->chip->cs_pin); 447 gpio_free(bu21013_data->chip->cs_pin);
446} 448}
447 449
450#ifdef CONFIG_OF
451static const struct bu21013_platform_device *
452bu21013_parse_dt(struct device *dev)
453{
454 struct device_node *np = dev->of_node;
455 struct bu21013_platform_device *pdata;
456
457 if (!np) {
458 dev_err(dev, "no device tree or platform data\n");
459 return ERR_PTR(-EINVAL);
460 }
461
462 pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
463 if (!pdata)
464 return ERR_PTR(-ENOMEM);
465
466 pdata->y_flip = pdata->x_flip = false;
467
468 pdata->x_flip = of_property_read_bool(np, "rohm,flip-x");
469 pdata->y_flip = of_property_read_bool(np, "rohm,flip-y");
470
471 of_property_read_u32(np, "rohm,touch-max-x", &pdata->touch_x_max);
472 of_property_read_u32(np, "rohm,touch-max-y", &pdata->touch_y_max);
473
474 pdata->touch_pin = of_get_named_gpio(np, "touch-gpio", 0);
475 pdata->cs_pin = of_get_named_gpio(np, "reset-gpio", 0);
476
477 pdata->ext_clk = false;
478
479 return pdata;
480}
481#else
482static inline const struct bu21013_platform_device *
483bu21013_parse_dt(struct device *dev)
484{
485 dev_err(dev, "no platform data available\n");
486 return ERR_PTR(-EINVAL);
487}
488#endif
448 489
449/** 490/**
450 * bu21013_probe() - initializes the i2c-client touchscreen driver 491 * bu21013_probe() - initializes the i2c-client touchscreen driver
@@ -457,10 +498,10 @@ static void bu21013_cs_disable(struct bu21013_ts_data *bu21013_data)
457static int bu21013_probe(struct i2c_client *client, 498static int bu21013_probe(struct i2c_client *client,
458 const struct i2c_device_id *id) 499 const struct i2c_device_id *id)
459{ 500{
501 const struct bu21013_platform_device *pdata =
502 dev_get_platdata(&client->dev);
460 struct bu21013_ts_data *bu21013_data; 503 struct bu21013_ts_data *bu21013_data;
461 struct input_dev *in_dev; 504 struct input_dev *in_dev;
462 const struct bu21013_platform_device *pdata =
463 client->dev.platform_data;
464 int error; 505 int error;
465 506
466 if (!i2c_check_functionality(client->adapter, 507 if (!i2c_check_functionality(client->adapter,
@@ -470,8 +511,9 @@ static int bu21013_probe(struct i2c_client *client,
470 } 511 }
471 512
472 if (!pdata) { 513 if (!pdata) {
473 dev_err(&client->dev, "platform data not defined\n"); 514 pdata = bu21013_parse_dt(&client->dev);
474 return -EINVAL; 515 if (IS_ERR(pdata))
516 return PTR_ERR(pdata);
475 } 517 }
476 518
477 if (!gpio_is_valid(pdata->touch_pin)) { 519 if (!gpio_is_valid(pdata->touch_pin)) {