Commit 48fceb7d authored by Lee Jones's avatar Lee Jones Committed by Dmitry Torokhov

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: default avatarArnd Bergmann <arnd@arndb.de>
Acked-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent 31fbcda7
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
#include <linux/regulator/consumer.h> #include <linux/regulator/consumer.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/gpio.h> #include <linux/gpio.h>
#include <linux/of.h>
#include <linux/of_gpio.h>
#define PEN_DOWN_INTR 0 #define PEN_DOWN_INTR 0
#define MAX_FINGERS 2 #define MAX_FINGERS 2
...@@ -445,6 +447,45 @@ static void bu21013_cs_disable(struct bu21013_ts_data *bu21013_data) ...@@ -445,6 +447,45 @@ static void bu21013_cs_disable(struct bu21013_ts_data *bu21013_data)
gpio_free(bu21013_data->chip->cs_pin); gpio_free(bu21013_data->chip->cs_pin);
} }
#ifdef CONFIG_OF
static const struct bu21013_platform_device *
bu21013_parse_dt(struct device *dev)
{
struct device_node *np = dev->of_node;
struct bu21013_platform_device *pdata;
if (!np) {
dev_err(dev, "no device tree or platform data\n");
return ERR_PTR(-EINVAL);
}
pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
if (!pdata)
return ERR_PTR(-ENOMEM);
pdata->y_flip = pdata->x_flip = false;
pdata->x_flip = of_property_read_bool(np, "rohm,flip-x");
pdata->y_flip = of_property_read_bool(np, "rohm,flip-y");
of_property_read_u32(np, "rohm,touch-max-x", &pdata->touch_x_max);
of_property_read_u32(np, "rohm,touch-max-y", &pdata->touch_y_max);
pdata->touch_pin = of_get_named_gpio(np, "touch-gpio", 0);
pdata->cs_pin = of_get_named_gpio(np, "reset-gpio", 0);
pdata->ext_clk = false;
return pdata;
}
#else
static inline const struct bu21013_platform_device *
bu21013_parse_dt(struct device *dev)
{
dev_err(dev, "no platform data available\n");
return ERR_PTR(-EINVAL);
}
#endif
/** /**
* bu21013_probe() - initializes the i2c-client touchscreen driver * bu21013_probe() - initializes the i2c-client touchscreen driver
...@@ -457,10 +498,10 @@ static void bu21013_cs_disable(struct bu21013_ts_data *bu21013_data) ...@@ -457,10 +498,10 @@ static void bu21013_cs_disable(struct bu21013_ts_data *bu21013_data)
static int bu21013_probe(struct i2c_client *client, static int bu21013_probe(struct i2c_client *client,
const struct i2c_device_id *id) const struct i2c_device_id *id)
{ {
const struct bu21013_platform_device *pdata =
dev_get_platdata(&client->dev);
struct bu21013_ts_data *bu21013_data; struct bu21013_ts_data *bu21013_data;
struct input_dev *in_dev; struct input_dev *in_dev;
const struct bu21013_platform_device *pdata =
client->dev.platform_data;
int error; int error;
if (!i2c_check_functionality(client->adapter, if (!i2c_check_functionality(client->adapter,
...@@ -470,8 +511,9 @@ static int bu21013_probe(struct i2c_client *client, ...@@ -470,8 +511,9 @@ static int bu21013_probe(struct i2c_client *client,
} }
if (!pdata) { if (!pdata) {
dev_err(&client->dev, "platform data not defined\n"); pdata = bu21013_parse_dt(&client->dev);
return -EINVAL; if (IS_ERR(pdata))
return PTR_ERR(pdata);
} }
if (!gpio_is_valid(pdata->touch_pin)) { if (!gpio_is_valid(pdata->touch_pin)) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment