diff options
author | Sushaanth Srirangapathi <sushaanth.s@ti.com> | 2016-02-01 11:58:49 +0530 |
---|---|---|
committer | Sekhar Nori <nsekhar@ti.com> | 2020-07-21 11:00:06 +0530 |
commit | 24155e637ca4c91d6ac52637fded9cee32da1f6d (patch) | |
tree | 0747841906be870ef755df60c5cc86a5af76eb27 | |
parent | 7cd868f8e0f2255c14b7a1cbdd2f95a1b03358c3 (diff) | |
download | linux-davinci-24155e637ca4c91d6ac52637fded9cee32da1f6d.tar.gz |
Input: tps6507x-ts - Add device tree support
Add device tree support for TPS6507x touchscreen input device.
Signed-off-by: Sushaanth Srirangapathi <sushaanth.s@ti.com>
Signed-off-by: Sekhar Nori <nsekhar@ti.com>
-rw-r--r-- | drivers/input/touchscreen/tps6507x-ts.c | 51 |
1 files changed, 47 insertions, 4 deletions
diff --git a/drivers/input/touchscreen/tps6507x-ts.c b/drivers/input/touchscreen/tps6507x-ts.c index 357a3108f2e570..c39d74ee707cb6 100644 --- a/drivers/input/touchscreen/tps6507x-ts.c +++ b/drivers/input/touchscreen/tps6507x-ts.c @@ -18,6 +18,7 @@ #include <linux/slab.h> #include <linux/input.h> #include <linux/platform_device.h> +#include <linux/of.h> #include <linux/mfd/tps6507x.h> #include <linux/input/tps6507x-ts.h> #include <linux/delay.h> @@ -31,6 +32,10 @@ TPS6507X_ADCONFIG_INPUT_REAL_TSC) #define TPS6507X_ADCONFIG_POWER_DOWN_TS (TPS6507X_ADCONFIG_INPUT_REAL_TSC) +#define TPS6507X_VENDOR 0 +#define TPS6507X_PRODUCT 65070 +#define TPS6507X_VERSION 0x100 + struct ts_event { u16 x; u16 y; @@ -197,6 +202,44 @@ done: tps6507x_adc_standby(tsc); } +static struct tps6507x_board *tps6507x_ts_parse_dt_reg_data( + struct platform_device *pdev) { + struct tps6507x_board *tps_board; + struct device_node *np = pdev->dev.parent->of_node; + struct touchscreen_init_data *reg_data; + struct device_node *touchscreen; + u32 min_pressure; + + tps_board = devm_kzalloc(&pdev->dev, sizeof(*tps_board), + GFP_KERNEL); + if (!tps_board) + return NULL; + + touchscreen = of_get_child_by_name(np, "touchscreen"); + if (!touchscreen) { + dev_err(&pdev->dev, "touchscreen node not found\n"); + return NULL; + } + + reg_data = devm_kzalloc(&pdev->dev, sizeof(struct touchscreen_init_data), + GFP_KERNEL); + if (!reg_data) + return NULL; + + reg_data->poll_period = TSC_DEFAULT_POLL_PERIOD; + reg_data->vendor = TPS6507X_VENDOR; + reg_data->product = TPS6507X_PRODUCT; + reg_data->version = TPS6507X_VERSION; + if (!of_property_read_u32(touchscreen, "ti,min-pressure", + &min_pressure)) + reg_data->min_pressure = min_pressure; + else + reg_data->min_pressure = TPS_DEFAULT_MIN_PRESSURE; + tps_board->tps6507x_ts_init_data = reg_data; + + return tps_board; +} + static int tps6507x_ts_probe(struct platform_device *pdev) { struct tps6507x_dev *tps6507x_dev = dev_get_drvdata(pdev->dev.parent); @@ -211,10 +254,10 @@ static int tps6507x_ts_probe(struct platform_device *pdev) * coming from the board-evm file. */ tps_board = dev_get_platdata(tps6507x_dev->dev); - if (!tps_board) { - dev_err(tps6507x_dev->dev, - "Could not find tps6507x platform data\n"); - return -ENODEV; + + if (IS_ENABLED(CONFIG_OF) && !tps_board && + tps6507x_dev->dev->of_node) { + tps_board = tps6507x_ts_parse_dt_reg_data(pdev); } /* |