* [PATCH 1/3] Input: tsc2005 - add OF device table
@ 2017-02-11 0:06 Dmitry Torokhov
2017-02-11 0:06 ` [PATCH 2/3] Input: tsc2004/5 - fix regulator handling Dmitry Torokhov
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Dmitry Torokhov @ 2017-02-11 0:06 UTC (permalink / raw)
To: linux-input
Cc: Sebastian Reichel, Pali Rohár, Michael Welling, linux-kernel
To be prepared for SPI module loading using full compatible strings from
device tree, let's add OF module device table data.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
drivers/input/touchscreen/tsc2005.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/drivers/input/touchscreen/tsc2005.c b/drivers/input/touchscreen/tsc2005.c
index f2c5f0e47f77..e02b69f40ad8 100644
--- a/drivers/input/touchscreen/tsc2005.c
+++ b/drivers/input/touchscreen/tsc2005.c
@@ -18,8 +18,9 @@
* GNU General Public License for more details.
*/
-#include <linux/module.h>
#include <linux/input.h>
+#include <linux/module.h>
+#include <linux/of.h>
#include <linux/spi/spi.h>
#include <linux/regmap.h>
#include "tsc200x-core.h"
@@ -77,9 +78,18 @@ static int tsc2005_remove(struct spi_device *spi)
return tsc200x_remove(&spi->dev);
}
+#ifdef CONFIG_OF
+static const struct of_device_id tsc2005_of_match[] = {
+ { .compatible = "ti,tsc2005" },
+ { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, tsc2005_of_match);
+#endif
+
static struct spi_driver tsc2005_driver = {
.driver = {
.name = "tsc2005",
+ .of_match_table = of_match_ptr(tsc2005_of_match),
.pm = &tsc200x_pm_ops,
},
.probe = tsc2005_probe,
--
2.11.0.483.g087da7b7c-goog
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/3] Input: tsc2004/5 - fix regulator handling
2017-02-11 0:06 [PATCH 1/3] Input: tsc2005 - add OF device table Dmitry Torokhov
@ 2017-02-11 0:06 ` Dmitry Torokhov
2017-02-11 17:02 ` Sebastian Reichel
2017-02-11 0:06 ` [PATCH 3/3] Input: tsc2004/5 - switch to using generic device properties Dmitry Torokhov
2017-02-11 17:03 ` [PATCH 1/3] Input: tsc2005 - add OF device table Sebastian Reichel
2 siblings, 1 reply; 6+ messages in thread
From: Dmitry Torokhov @ 2017-02-11 0:06 UTC (permalink / raw)
To: linux-input
Cc: Sebastian Reichel, Pali Rohár, Michael Welling, linux-kernel
In case of an optional regulator missing regulator core will return
ERR_PTR(-ENOENT) and not NULL, so the check for missing regulator is
incorrect. Also, the regulator is not optional, it may simply be missing
from platform decsription, so let's use devm_regulator_get() and rely on
regulator core to give us dummy supply when real one is not available.
Fixes: d257f2980feb ("Input: tsc2005 - convert to gpiod")
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
Sebastian, I am wondering, what regulator this is. If it is IO VDD,
then I think we activate it too late (i.e. we are truing to shut off
the controller before we turn the regulator on. If it is sensor VDD,
then we probably need to mention it, and also add IO VVD supply as
well.
drivers/input/touchscreen/tsc200x-core.c | 19 +++++++------------
1 file changed, 7 insertions(+), 12 deletions(-)
diff --git a/drivers/input/touchscreen/tsc200x-core.c b/drivers/input/touchscreen/tsc200x-core.c
index b7059ed8872e..1c14a38e3748 100644
--- a/drivers/input/touchscreen/tsc200x-core.c
+++ b/drivers/input/touchscreen/tsc200x-core.c
@@ -527,10 +527,10 @@ int tsc200x_probe(struct device *dev, int irq, const struct input_id *tsc_id,
return error;
}
- ts->vio = devm_regulator_get_optional(dev, "vio");
+ ts->vio = devm_regulator_get(dev, "vio");
if (IS_ERR(ts->vio)) {
error = PTR_ERR(ts->vio);
- dev_err(dev, "vio regulator missing (%d)", error);
+ dev_err(dev, "error acquiring vio regulator: %d", error);
return error;
}
@@ -587,12 +587,9 @@ int tsc200x_probe(struct device *dev, int irq, const struct input_id *tsc_id,
return error;
}
- /* enable regulator for DT */
- if (ts->vio) {
- error = regulator_enable(ts->vio);
- if (error)
- return error;
- }
+ error = regulator_enable(ts->vio);
+ if (error)
+ return error;
dev_set_drvdata(dev, ts);
error = sysfs_create_group(&dev->kobj, &tsc200x_attr_group);
@@ -615,8 +612,7 @@ int tsc200x_probe(struct device *dev, int irq, const struct input_id *tsc_id,
err_remove_sysfs:
sysfs_remove_group(&dev->kobj, &tsc200x_attr_group);
disable_regulator:
- if (ts->vio)
- regulator_disable(ts->vio);
+ regulator_disable(ts->vio);
return error;
}
EXPORT_SYMBOL_GPL(tsc200x_probe);
@@ -627,8 +623,7 @@ int tsc200x_remove(struct device *dev)
sysfs_remove_group(&dev->kobj, &tsc200x_attr_group);
- if (ts->vio)
- regulator_disable(ts->vio);
+ regulator_disable(ts->vio);
return 0;
}
--
2.11.0.483.g087da7b7c-goog
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/3] Input: tsc2004/5 - switch to using generic device properties
2017-02-11 0:06 [PATCH 1/3] Input: tsc2005 - add OF device table Dmitry Torokhov
2017-02-11 0:06 ` [PATCH 2/3] Input: tsc2004/5 - fix regulator handling Dmitry Torokhov
@ 2017-02-11 0:06 ` Dmitry Torokhov
2017-02-11 17:37 ` Sebastian Reichel
2017-02-11 17:03 ` [PATCH 1/3] Input: tsc2005 - add OF device table Sebastian Reichel
2 siblings, 1 reply; 6+ messages in thread
From: Dmitry Torokhov @ 2017-02-11 0:06 UTC (permalink / raw)
To: linux-input
Cc: Sebastian Reichel, Pali Rohár, Michael Welling, linux-kernel
Instead of supporting legacy platform data (of which we have no mainline
users) and OF-based properties, let's switch to generic device properties.
This will still allow legacy boards to use the driver (by defining property
sets and attaching them to the drivers) and will simplify probe and make
driver usable on ACPI-based systems as well.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
drivers/input/touchscreen/tsc200x-core.c | 93 +++++++++++---------------------
include/linux/spi/tsc2005.h | 34 ------------
2 files changed, 30 insertions(+), 97 deletions(-)
delete mode 100644 include/linux/spi/tsc2005.h
diff --git a/drivers/input/touchscreen/tsc200x-core.c b/drivers/input/touchscreen/tsc200x-core.c
index 1c14a38e3748..88ea5e1b72ae 100644
--- a/drivers/input/touchscreen/tsc200x-core.c
+++ b/drivers/input/touchscreen/tsc200x-core.c
@@ -27,7 +27,6 @@
#include <linux/delay.h>
#include <linux/pm.h>
#include <linux/of.h>
-#include <linux/spi/tsc2005.h>
#include <linux/regulator/consumer.h>
#include <linux/regmap.h>
#include <linux/gpio/consumer.h>
@@ -114,7 +113,6 @@ struct tsc200x {
struct regulator *vio;
struct gpio_desc *reset_gpio;
- void (*set_reset)(bool enable);
int (*tsc200x_cmd)(struct device *dev, u8 cmd);
int irq;
};
@@ -227,12 +225,13 @@ static void tsc200x_stop_scan(struct tsc200x *ts)
ts->tsc200x_cmd(ts->dev, TSC200X_CMD_STOP);
}
-static void tsc200x_set_reset(struct tsc200x *ts, bool enable)
+static void tsc200x_reset(struct tsc200x *ts)
{
- if (ts->reset_gpio)
- gpiod_set_value_cansleep(ts->reset_gpio, enable);
- else if (ts->set_reset)
- ts->set_reset(enable);
+ if (ts->reset_gpio) {
+ gpiod_set_value_cansleep(ts->reset_gpio, 1);
+ usleep_range(100, 500); /* only 10us required */
+ gpiod_set_value_cansleep(ts->reset_gpio, 0);
+ }
}
/* must be called with ts->mutex held */
@@ -253,7 +252,7 @@ static void __tsc200x_enable(struct tsc200x *ts)
{
tsc200x_start_scan(ts);
- if (ts->esd_timeout && (ts->set_reset || ts->reset_gpio)) {
+ if (ts->esd_timeout && ts->reset_gpio) {
ts->last_valid_interrupt = jiffies;
schedule_delayed_work(&ts->esd_work,
round_jiffies_relative(
@@ -310,9 +309,7 @@ static ssize_t tsc200x_selftest_show(struct device *dev,
}
/* hardware reset */
- tsc200x_set_reset(ts, false);
- usleep_range(100, 500); /* only 10us required */
- tsc200x_set_reset(ts, true);
+ tsc200x_reset(ts);
if (!success)
goto out;
@@ -354,7 +351,7 @@ static umode_t tsc200x_attr_is_visible(struct kobject *kobj,
umode_t mode = attr->mode;
if (attr == &dev_attr_selftest.attr) {
- if (!ts->set_reset && !ts->reset_gpio)
+ if (!ts->reset_gpio)
mode = 0;
}
@@ -404,9 +401,7 @@ static void tsc200x_esd_work(struct work_struct *work)
tsc200x_update_pen_state(ts, 0, 0, 0);
- tsc200x_set_reset(ts, false);
- usleep_range(100, 500); /* only 10us required */
- tsc200x_set_reset(ts, true);
+ tsc200x_reset(ts);
enable_irq(ts->irq);
tsc200x_start_scan(ts);
@@ -454,26 +449,12 @@ int tsc200x_probe(struct device *dev, int irq, const struct input_id *tsc_id,
struct regmap *regmap,
int (*tsc200x_cmd)(struct device *dev, u8 cmd))
{
- const struct tsc2005_platform_data *pdata = dev_get_platdata(dev);
- struct device_node *np = dev->of_node;
-
struct tsc200x *ts;
struct input_dev *input_dev;
- unsigned int max_x = MAX_12BIT;
- unsigned int max_y = MAX_12BIT;
- unsigned int max_p = MAX_12BIT;
- unsigned int fudge_x = TSC200X_DEF_X_FUZZ;
- unsigned int fudge_y = TSC200X_DEF_Y_FUZZ;
- unsigned int fudge_p = TSC200X_DEF_P_FUZZ;
- unsigned int x_plate_ohm = TSC200X_DEF_RESISTOR;
- unsigned int esd_timeout;
+ u32 x_plate_ohm;
+ u32 esd_timeout;
int error;
- if (!np && !pdata) {
- dev_err(dev, "no platform data\n");
- return -ENODEV;
- }
-
if (irq <= 0) {
dev_err(dev, "no irq\n");
return -ENODEV;
@@ -487,23 +468,6 @@ int tsc200x_probe(struct device *dev, int irq, const struct input_id *tsc_id,
return -ENODEV;
}
- if (pdata) {
- fudge_x = pdata->ts_x_fudge;
- fudge_y = pdata->ts_y_fudge;
- fudge_p = pdata->ts_pressure_fudge;
- max_x = pdata->ts_x_max;
- max_y = pdata->ts_y_max;
- max_p = pdata->ts_pressure_max;
- x_plate_ohm = pdata->ts_x_plate_ohm;
- esd_timeout = pdata->esd_timeout_ms;
- } else {
- x_plate_ohm = TSC200X_DEF_RESISTOR;
- of_property_read_u32(np, "ti,x-plate-ohms", &x_plate_ohm);
- esd_timeout = 0;
- of_property_read_u32(np, "ti,esd-recovery-timeout-ms",
- &esd_timeout);
- }
-
ts = devm_kzalloc(dev, sizeof(*ts), GFP_KERNEL);
if (!ts)
return -ENOMEM;
@@ -517,8 +481,13 @@ int tsc200x_probe(struct device *dev, int irq, const struct input_id *tsc_id,
ts->idev = input_dev;
ts->regmap = regmap;
ts->tsc200x_cmd = tsc200x_cmd;
- ts->x_plate_ohm = x_plate_ohm;
- ts->esd_timeout = esd_timeout;
+
+ error = device_property_read_u32(dev, "ti,x-plate-ohms", &x_plate_ohm);
+ ts->x_plate_ohm = error ? TSC200X_DEF_RESISTOR : x_plate_ohm;
+
+ error = device_property_read_u32(dev, "ti,esd-recovery-timeout-ms",
+ &esd_timeout);
+ ts->esd_timeout = error ? 0 : esd_timeout;
ts->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
if (IS_ERR(ts->reset_gpio)) {
@@ -534,9 +503,6 @@ int tsc200x_probe(struct device *dev, int irq, const struct input_id *tsc_id,
return error;
}
- if (!ts->reset_gpio && pdata)
- ts->set_reset = pdata->set_reset;
-
mutex_init(&ts->mutex);
spin_lock_init(&ts->lock);
@@ -559,22 +525,23 @@ int tsc200x_probe(struct device *dev, int irq, const struct input_id *tsc_id,
input_dev->phys = ts->phys;
input_dev->id = *tsc_id;
- input_dev->dev.parent = dev;
- input_dev->evbit[0] = BIT(EV_ABS) | BIT(EV_KEY);
- input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
-
- input_set_abs_params(input_dev, ABS_X, 0, max_x, fudge_x, 0);
- input_set_abs_params(input_dev, ABS_Y, 0, max_y, fudge_y, 0);
- input_set_abs_params(input_dev, ABS_PRESSURE, 0, max_p, fudge_p, 0);
-
- if (np)
- touchscreen_parse_properties(input_dev, false, NULL);
input_dev->open = tsc200x_open;
input_dev->close = tsc200x_close;
input_set_drvdata(input_dev, ts);
+ input_set_capability(input_dev, EV_KEY, BTN_TOUCH);
+
+ input_set_abs_params(input_dev, ABS_X,
+ 0, MAX_12BIT, TSC200X_DEF_X_FUZZ, 0);
+ input_set_abs_params(input_dev, ABS_Y,
+ 0, MAX_12BIT, TSC200X_DEF_Y_FUZZ, 0);
+ input_set_abs_params(input_dev, ABS_PRESSURE,
+ 0, MAX_12BIT, TSC200X_DEF_P_FUZZ, 0);
+
+ touchscreen_parse_properties(input_dev, false, NULL);
+
/* Ensure the touchscreen is off */
tsc200x_stop_scan(ts);
diff --git a/include/linux/spi/tsc2005.h b/include/linux/spi/tsc2005.h
deleted file mode 100644
index 563b3b1799a8..000000000000
--- a/include/linux/spi/tsc2005.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * This file is part of TSC2005 touchscreen driver
- *
- * Copyright (C) 2009-2010 Nokia Corporation
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
-
-#ifndef _LINUX_SPI_TSC2005_H
-#define _LINUX_SPI_TSC2005_H
-
-#include <linux/types.h>
-
-struct tsc2005_platform_data {
- int ts_pressure_max;
- int ts_pressure_fudge;
- int ts_x_max;
- int ts_x_fudge;
- int ts_y_max;
- int ts_y_fudge;
- int ts_x_plate_ohm;
- unsigned int esd_timeout_ms;
- void (*set_reset)(bool enable);
-};
-
-#endif
--
2.11.0.483.g087da7b7c-goog
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 2/3] Input: tsc2004/5 - fix regulator handling
2017-02-11 0:06 ` [PATCH 2/3] Input: tsc2004/5 - fix regulator handling Dmitry Torokhov
@ 2017-02-11 17:02 ` Sebastian Reichel
0 siblings, 0 replies; 6+ messages in thread
From: Sebastian Reichel @ 2017-02-11 17:02 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: linux-input, Pali Rohár, Michael Welling, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 2954 bytes --]
Hi Dmitry,
On Fri, Feb 10, 2017 at 04:06:22PM -0800, Dmitry Torokhov wrote:
> In case of an optional regulator missing regulator core will return
> ERR_PTR(-ENOENT) and not NULL, so the check for missing regulator is
> incorrect. Also, the regulator is not optional, it may simply be missing
> from platform decsription, so let's use devm_regulator_get() and rely on
> regulator core to give us dummy supply when real one is not available.
>
> Fixes: d257f2980feb ("Input: tsc2005 - convert to gpiod")
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Acked-By: Sebastian Reichel <sre@kernel.org>
> ---
>
> Sebastian, I am wondering, what regulator this is.
On N900 the same regultor is connected to I/OVDD & SNSVDD.
> If it is IO VDD, then I think we activate it too late (i.e. we are
> truing to shut off the controller before we turn the regulator on.
Yes, it should be moved.
> If it is sensor VDD, then we probably need to mention it, and also
> add IO VVD supply as well.
-- Sebastian
>
> drivers/input/touchscreen/tsc200x-core.c | 19 +++++++------------
> 1 file changed, 7 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/input/touchscreen/tsc200x-core.c b/drivers/input/touchscreen/tsc200x-core.c
> index b7059ed8872e..1c14a38e3748 100644
> --- a/drivers/input/touchscreen/tsc200x-core.c
> +++ b/drivers/input/touchscreen/tsc200x-core.c
> @@ -527,10 +527,10 @@ int tsc200x_probe(struct device *dev, int irq, const struct input_id *tsc_id,
> return error;
> }
>
> - ts->vio = devm_regulator_get_optional(dev, "vio");
> + ts->vio = devm_regulator_get(dev, "vio");
> if (IS_ERR(ts->vio)) {
> error = PTR_ERR(ts->vio);
> - dev_err(dev, "vio regulator missing (%d)", error);
> + dev_err(dev, "error acquiring vio regulator: %d", error);
> return error;
> }
>
> @@ -587,12 +587,9 @@ int tsc200x_probe(struct device *dev, int irq, const struct input_id *tsc_id,
> return error;
> }
>
> - /* enable regulator for DT */
> - if (ts->vio) {
> - error = regulator_enable(ts->vio);
> - if (error)
> - return error;
> - }
> + error = regulator_enable(ts->vio);
> + if (error)
> + return error;
>
> dev_set_drvdata(dev, ts);
> error = sysfs_create_group(&dev->kobj, &tsc200x_attr_group);
> @@ -615,8 +612,7 @@ int tsc200x_probe(struct device *dev, int irq, const struct input_id *tsc_id,
> err_remove_sysfs:
> sysfs_remove_group(&dev->kobj, &tsc200x_attr_group);
> disable_regulator:
> - if (ts->vio)
> - regulator_disable(ts->vio);
> + regulator_disable(ts->vio);
> return error;
> }
> EXPORT_SYMBOL_GPL(tsc200x_probe);
> @@ -627,8 +623,7 @@ int tsc200x_remove(struct device *dev)
>
> sysfs_remove_group(&dev->kobj, &tsc200x_attr_group);
>
> - if (ts->vio)
> - regulator_disable(ts->vio);
> + regulator_disable(ts->vio);
>
> return 0;
> }
> --
> 2.11.0.483.g087da7b7c-goog
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/3] Input: tsc2005 - add OF device table
2017-02-11 0:06 [PATCH 1/3] Input: tsc2005 - add OF device table Dmitry Torokhov
2017-02-11 0:06 ` [PATCH 2/3] Input: tsc2004/5 - fix regulator handling Dmitry Torokhov
2017-02-11 0:06 ` [PATCH 3/3] Input: tsc2004/5 - switch to using generic device properties Dmitry Torokhov
@ 2017-02-11 17:03 ` Sebastian Reichel
2 siblings, 0 replies; 6+ messages in thread
From: Sebastian Reichel @ 2017-02-11 17:03 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: linux-input, Pali Rohár, Michael Welling, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 337 bytes --]
Hi,
On Fri, Feb 10, 2017 at 04:06:21PM -0800, Dmitry Torokhov wrote:
> To be prepared for SPI module loading using full compatible strings from
> device tree, let's add OF module device table data.
>
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Reviewed-By: Sebastian Reichel <sre@kernel.org>
-- Sebastian
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 3/3] Input: tsc2004/5 - switch to using generic device properties
2017-02-11 0:06 ` [PATCH 3/3] Input: tsc2004/5 - switch to using generic device properties Dmitry Torokhov
@ 2017-02-11 17:37 ` Sebastian Reichel
0 siblings, 0 replies; 6+ messages in thread
From: Sebastian Reichel @ 2017-02-11 17:37 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: linux-input, Pali Rohár, Michael Welling, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 8851 bytes --]
Hi,
On Fri, Feb 10, 2017 at 04:06:23PM -0800, Dmitry Torokhov wrote:
> Instead of supporting legacy platform data (of which we have no mainline
> users) and OF-based properties, let's switch to generic device properties.
> This will still allow legacy boards to use the driver (by defining property
> sets and attaching them to the drivers) and will simplify probe and make
> driver usable on ACPI-based systems as well.
Reviewed-By: Sebastian Reichel <sre@kernel.org>
FYI: The last & only platform data user of tsc2005 was N900, which was
removed in 9b7141d01a76 (ARM: OMAP2+: Drop legacy board file for n900).
-- Sebastian
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> ---
> drivers/input/touchscreen/tsc200x-core.c | 93 +++++++++++---------------------
> include/linux/spi/tsc2005.h | 34 ------------
> 2 files changed, 30 insertions(+), 97 deletions(-)
> delete mode 100644 include/linux/spi/tsc2005.h
>
> diff --git a/drivers/input/touchscreen/tsc200x-core.c b/drivers/input/touchscreen/tsc200x-core.c
> index 1c14a38e3748..88ea5e1b72ae 100644
> --- a/drivers/input/touchscreen/tsc200x-core.c
> +++ b/drivers/input/touchscreen/tsc200x-core.c
> @@ -27,7 +27,6 @@
> #include <linux/delay.h>
> #include <linux/pm.h>
> #include <linux/of.h>
> -#include <linux/spi/tsc2005.h>
> #include <linux/regulator/consumer.h>
> #include <linux/regmap.h>
> #include <linux/gpio/consumer.h>
> @@ -114,7 +113,6 @@ struct tsc200x {
> struct regulator *vio;
>
> struct gpio_desc *reset_gpio;
> - void (*set_reset)(bool enable);
> int (*tsc200x_cmd)(struct device *dev, u8 cmd);
> int irq;
> };
> @@ -227,12 +225,13 @@ static void tsc200x_stop_scan(struct tsc200x *ts)
> ts->tsc200x_cmd(ts->dev, TSC200X_CMD_STOP);
> }
>
> -static void tsc200x_set_reset(struct tsc200x *ts, bool enable)
> +static void tsc200x_reset(struct tsc200x *ts)
> {
> - if (ts->reset_gpio)
> - gpiod_set_value_cansleep(ts->reset_gpio, enable);
> - else if (ts->set_reset)
> - ts->set_reset(enable);
> + if (ts->reset_gpio) {
> + gpiod_set_value_cansleep(ts->reset_gpio, 1);
> + usleep_range(100, 500); /* only 10us required */
> + gpiod_set_value_cansleep(ts->reset_gpio, 0);
> + }
> }
>
> /* must be called with ts->mutex held */
> @@ -253,7 +252,7 @@ static void __tsc200x_enable(struct tsc200x *ts)
> {
> tsc200x_start_scan(ts);
>
> - if (ts->esd_timeout && (ts->set_reset || ts->reset_gpio)) {
> + if (ts->esd_timeout && ts->reset_gpio) {
> ts->last_valid_interrupt = jiffies;
> schedule_delayed_work(&ts->esd_work,
> round_jiffies_relative(
> @@ -310,9 +309,7 @@ static ssize_t tsc200x_selftest_show(struct device *dev,
> }
>
> /* hardware reset */
> - tsc200x_set_reset(ts, false);
> - usleep_range(100, 500); /* only 10us required */
> - tsc200x_set_reset(ts, true);
> + tsc200x_reset(ts);
>
> if (!success)
> goto out;
> @@ -354,7 +351,7 @@ static umode_t tsc200x_attr_is_visible(struct kobject *kobj,
> umode_t mode = attr->mode;
>
> if (attr == &dev_attr_selftest.attr) {
> - if (!ts->set_reset && !ts->reset_gpio)
> + if (!ts->reset_gpio)
> mode = 0;
> }
>
> @@ -404,9 +401,7 @@ static void tsc200x_esd_work(struct work_struct *work)
>
> tsc200x_update_pen_state(ts, 0, 0, 0);
>
> - tsc200x_set_reset(ts, false);
> - usleep_range(100, 500); /* only 10us required */
> - tsc200x_set_reset(ts, true);
> + tsc200x_reset(ts);
>
> enable_irq(ts->irq);
> tsc200x_start_scan(ts);
> @@ -454,26 +449,12 @@ int tsc200x_probe(struct device *dev, int irq, const struct input_id *tsc_id,
> struct regmap *regmap,
> int (*tsc200x_cmd)(struct device *dev, u8 cmd))
> {
> - const struct tsc2005_platform_data *pdata = dev_get_platdata(dev);
> - struct device_node *np = dev->of_node;
> -
> struct tsc200x *ts;
> struct input_dev *input_dev;
> - unsigned int max_x = MAX_12BIT;
> - unsigned int max_y = MAX_12BIT;
> - unsigned int max_p = MAX_12BIT;
> - unsigned int fudge_x = TSC200X_DEF_X_FUZZ;
> - unsigned int fudge_y = TSC200X_DEF_Y_FUZZ;
> - unsigned int fudge_p = TSC200X_DEF_P_FUZZ;
> - unsigned int x_plate_ohm = TSC200X_DEF_RESISTOR;
> - unsigned int esd_timeout;
> + u32 x_plate_ohm;
> + u32 esd_timeout;
> int error;
>
> - if (!np && !pdata) {
> - dev_err(dev, "no platform data\n");
> - return -ENODEV;
> - }
> -
> if (irq <= 0) {
> dev_err(dev, "no irq\n");
> return -ENODEV;
> @@ -487,23 +468,6 @@ int tsc200x_probe(struct device *dev, int irq, const struct input_id *tsc_id,
> return -ENODEV;
> }
>
> - if (pdata) {
> - fudge_x = pdata->ts_x_fudge;
> - fudge_y = pdata->ts_y_fudge;
> - fudge_p = pdata->ts_pressure_fudge;
> - max_x = pdata->ts_x_max;
> - max_y = pdata->ts_y_max;
> - max_p = pdata->ts_pressure_max;
> - x_plate_ohm = pdata->ts_x_plate_ohm;
> - esd_timeout = pdata->esd_timeout_ms;
> - } else {
> - x_plate_ohm = TSC200X_DEF_RESISTOR;
> - of_property_read_u32(np, "ti,x-plate-ohms", &x_plate_ohm);
> - esd_timeout = 0;
> - of_property_read_u32(np, "ti,esd-recovery-timeout-ms",
> - &esd_timeout);
> - }
> -
> ts = devm_kzalloc(dev, sizeof(*ts), GFP_KERNEL);
> if (!ts)
> return -ENOMEM;
> @@ -517,8 +481,13 @@ int tsc200x_probe(struct device *dev, int irq, const struct input_id *tsc_id,
> ts->idev = input_dev;
> ts->regmap = regmap;
> ts->tsc200x_cmd = tsc200x_cmd;
> - ts->x_plate_ohm = x_plate_ohm;
> - ts->esd_timeout = esd_timeout;
> +
> + error = device_property_read_u32(dev, "ti,x-plate-ohms", &x_plate_ohm);
> + ts->x_plate_ohm = error ? TSC200X_DEF_RESISTOR : x_plate_ohm;
> +
> + error = device_property_read_u32(dev, "ti,esd-recovery-timeout-ms",
> + &esd_timeout);
> + ts->esd_timeout = error ? 0 : esd_timeout;
>
> ts->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
> if (IS_ERR(ts->reset_gpio)) {
> @@ -534,9 +503,6 @@ int tsc200x_probe(struct device *dev, int irq, const struct input_id *tsc_id,
> return error;
> }
>
> - if (!ts->reset_gpio && pdata)
> - ts->set_reset = pdata->set_reset;
> -
> mutex_init(&ts->mutex);
>
> spin_lock_init(&ts->lock);
> @@ -559,22 +525,23 @@ int tsc200x_probe(struct device *dev, int irq, const struct input_id *tsc_id,
>
> input_dev->phys = ts->phys;
> input_dev->id = *tsc_id;
> - input_dev->dev.parent = dev;
> - input_dev->evbit[0] = BIT(EV_ABS) | BIT(EV_KEY);
> - input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
> -
> - input_set_abs_params(input_dev, ABS_X, 0, max_x, fudge_x, 0);
> - input_set_abs_params(input_dev, ABS_Y, 0, max_y, fudge_y, 0);
> - input_set_abs_params(input_dev, ABS_PRESSURE, 0, max_p, fudge_p, 0);
> -
> - if (np)
> - touchscreen_parse_properties(input_dev, false, NULL);
>
> input_dev->open = tsc200x_open;
> input_dev->close = tsc200x_close;
>
> input_set_drvdata(input_dev, ts);
>
> + input_set_capability(input_dev, EV_KEY, BTN_TOUCH);
> +
> + input_set_abs_params(input_dev, ABS_X,
> + 0, MAX_12BIT, TSC200X_DEF_X_FUZZ, 0);
> + input_set_abs_params(input_dev, ABS_Y,
> + 0, MAX_12BIT, TSC200X_DEF_Y_FUZZ, 0);
> + input_set_abs_params(input_dev, ABS_PRESSURE,
> + 0, MAX_12BIT, TSC200X_DEF_P_FUZZ, 0);
> +
> + touchscreen_parse_properties(input_dev, false, NULL);
> +
> /* Ensure the touchscreen is off */
> tsc200x_stop_scan(ts);
>
> diff --git a/include/linux/spi/tsc2005.h b/include/linux/spi/tsc2005.h
> deleted file mode 100644
> index 563b3b1799a8..000000000000
> --- a/include/linux/spi/tsc2005.h
> +++ /dev/null
> @@ -1,34 +0,0 @@
> -/*
> - * This file is part of TSC2005 touchscreen driver
> - *
> - * Copyright (C) 2009-2010 Nokia Corporation
> - *
> - * This program is free software; you can redistribute it and/or modify
> - * it under the terms of the GNU General Public License as published by
> - * the Free Software Foundation; either version 2 of the License, or
> - * (at your option) any later version.
> - *
> - * This program is distributed in the hope that it will be useful,
> - * but WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> - * GNU General Public License for more details.
> - */
> -
> -#ifndef _LINUX_SPI_TSC2005_H
> -#define _LINUX_SPI_TSC2005_H
> -
> -#include <linux/types.h>
> -
> -struct tsc2005_platform_data {
> - int ts_pressure_max;
> - int ts_pressure_fudge;
> - int ts_x_max;
> - int ts_x_fudge;
> - int ts_y_max;
> - int ts_y_fudge;
> - int ts_x_plate_ohm;
> - unsigned int esd_timeout_ms;
> - void (*set_reset)(bool enable);
> -};
> -
> -#endif
> --
> 2.11.0.483.g087da7b7c-goog
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-02-11 17:37 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-11 0:06 [PATCH 1/3] Input: tsc2005 - add OF device table Dmitry Torokhov
2017-02-11 0:06 ` [PATCH 2/3] Input: tsc2004/5 - fix regulator handling Dmitry Torokhov
2017-02-11 17:02 ` Sebastian Reichel
2017-02-11 0:06 ` [PATCH 3/3] Input: tsc2004/5 - switch to using generic device properties Dmitry Torokhov
2017-02-11 17:37 ` Sebastian Reichel
2017-02-11 17:03 ` [PATCH 1/3] Input: tsc2005 - add OF device table Sebastian Reichel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).