* [PATCH 0/2] tsc2005 DT binding
@ 2013-12-05 23:09 Sebastian Reichel
2013-12-05 23:09 ` [PATCH 1/2] Input: tsc2005: add DT support Sebastian Reichel
2013-12-05 23:09 ` [PATCH 2/2] Documentation: dt: Document TSC2005 DT binding Sebastian Reichel
0 siblings, 2 replies; 6+ messages in thread
From: Sebastian Reichel @ 2013-12-05 23:09 UTC (permalink / raw)
To: Sebastian Reichel, Dmitry Torokhov, Dmitry Torokhov, linux-input
Cc: Rob Herring, Pawel Moll, Mark Rutland, Stephen Warren,
Ian Campbell, Rob Landley, Grant Likely, devicetree, linux-omap,
linux-kernel, Sebastian Reichel
Hi,
This adds device tree support for the tsc2005 touchscreen
controller, which is currently only used by the Nokia N900
board.
The patch does not update the reset pin handling for platform
data based probe to avoid merge conflicts (Tony will remove
the Nokia N900 boardcode in 3.14). The platform data based
probe can be removed once the N900 boardcode is gone.
-- Sebastian
Sebastian Reichel (2):
Input: tsc2005: add DT support
Documentation: dt: Document TSC2005 DT binding
.../bindings/input/touchscreen/tsc2005.txt | 49 +++++++++++
drivers/input/touchscreen/tsc2005.c | 95 ++++++++++++++++++----
2 files changed, 127 insertions(+), 17 deletions(-)
create mode 100644 Documentation/devicetree/bindings/input/touchscreen/tsc2005.txt
--
1.8.4.3
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] Input: tsc2005: add DT support
2013-12-05 23:09 [PATCH 0/2] tsc2005 DT binding Sebastian Reichel
@ 2013-12-05 23:09 ` Sebastian Reichel
2013-12-05 23:09 ` [PATCH 2/2] Documentation: dt: Document TSC2005 DT binding Sebastian Reichel
1 sibling, 0 replies; 6+ messages in thread
From: Sebastian Reichel @ 2013-12-05 23:09 UTC (permalink / raw)
To: Sebastian Reichel, Dmitry Torokhov, Dmitry Torokhov, linux-input
Cc: Rob Herring, Pawel Moll, Mark Rutland, Stephen Warren,
Ian Campbell, Rob Landley, Grant Likely, devicetree, linux-omap,
linux-kernel, Sebastian Reichel
This adds DT support to the tsc2005 touchscreen
driver.
Signed-off-by: Sebastian Reichel <sre@debian.org>
---
drivers/input/touchscreen/tsc2005.c | 95 ++++++++++++++++++++++++++++++-------
1 file changed, 78 insertions(+), 17 deletions(-)
diff --git a/drivers/input/touchscreen/tsc2005.c b/drivers/input/touchscreen/tsc2005.c
index 7a6ff52..b50986b 100644
--- a/drivers/input/touchscreen/tsc2005.c
+++ b/drivers/input/touchscreen/tsc2005.c
@@ -28,6 +28,8 @@
#include <linux/interrupt.h>
#include <linux/delay.h>
#include <linux/pm.h>
+#include <linux/of.h>
+#include <linux/of_gpio.h>
#include <linux/spi/spi.h>
#include <linux/spi/tsc2005.h>
@@ -100,6 +102,11 @@
TSC2005_CFR2_AVG_7)
#define MAX_12BIT 0xfff
+#define TSC2005_DEF_X_FUZZ 4
+#define TSC2005_DEF_Y_FUZZ 8
+#define TSC2005_DEF_P_FUZZ 2
+#define TSC2005_DEF_RESISTOR 280
+
#define TSC2005_SPI_MAX_SPEED_HZ 10000000
#define TSC2005_PENUP_TIME_MS 40
@@ -143,6 +150,7 @@ struct tsc2005 {
bool pen_down;
+ int reset_gpio;
void (*set_reset)(bool enable);
};
@@ -337,6 +345,14 @@ static void tsc2005_stop_scan(struct tsc2005 *ts)
tsc2005_cmd(ts, TSC2005_CMD_STOP);
}
+static void tsc2005_set_reset(struct tsc2005 *ts, bool enable)
+{
+ if (ts->reset_gpio >= 0)
+ gpio_set_value(ts->reset_gpio, enable);
+ else if (ts->set_reset)
+ ts->set_reset(enable);
+}
+
/* must be called with ts->mutex held */
static void __tsc2005_disable(struct tsc2005 *ts)
{
@@ -355,7 +371,7 @@ static void __tsc2005_enable(struct tsc2005 *ts)
{
tsc2005_start_scan(ts);
- if (ts->esd_timeout && ts->set_reset) {
+ if (ts->esd_timeout && (ts->set_reset || ts->reset_gpio)) {
ts->last_valid_interrupt = jiffies;
schedule_delayed_work(&ts->esd_work,
round_jiffies_relative(
@@ -414,9 +430,9 @@ static ssize_t tsc2005_selftest_show(struct device *dev,
}
/* hardware reset */
- ts->set_reset(false);
+ tsc2005_set_reset(ts, false);
usleep_range(100, 500); /* only 10us required */
- ts->set_reset(true);
+ tsc2005_set_reset(ts, true);
if (!success)
goto out;
@@ -459,7 +475,7 @@ static umode_t tsc2005_attr_is_visible(struct kobject *kobj,
umode_t mode = attr->mode;
if (attr == &dev_attr_selftest.attr) {
- if (!ts->set_reset)
+ if (!ts->set_reset && !ts->reset_gpio)
mode = 0;
}
@@ -509,9 +525,9 @@ static void tsc2005_esd_work(struct work_struct *work)
tsc2005_update_pen_state(ts, 0, 0, 0);
- ts->set_reset(false);
+ tsc2005_set_reset(ts, false);
usleep_range(100, 500); /* only 10us required */
- ts->set_reset(true);
+ tsc2005_set_reset(ts, true);
enable_irq(ts->spi->irq);
tsc2005_start_scan(ts);
@@ -572,29 +588,53 @@ static void tsc2005_setup_spi_xfer(struct tsc2005 *ts)
static int tsc2005_probe(struct spi_device *spi)
{
const struct tsc2005_platform_data *pdata = spi->dev.platform_data;
+ struct device_node *np = spi->dev.of_node;
struct tsc2005 *ts;
struct input_dev *input_dev;
unsigned int max_x, max_y, max_p;
unsigned int fudge_x, fudge_y, fudge_p;
+ unsigned int esd_timeout, x_plate_ohm;
int error;
- if (!pdata) {
+ if (!np && !pdata) {
dev_err(&spi->dev, "no platform data\n");
return -ENODEV;
}
- fudge_x = pdata->ts_x_fudge ? : 4;
- fudge_y = pdata->ts_y_fudge ? : 8;
- fudge_p = pdata->ts_pressure_fudge ? : 2;
- max_x = pdata->ts_x_max ? : MAX_12BIT;
- max_y = pdata->ts_y_max ? : MAX_12BIT;
- max_p = pdata->ts_pressure_max ? : MAX_12BIT;
-
if (spi->irq <= 0) {
dev_err(&spi->dev, "no irq\n");
return -ENODEV;
}
+ if (pdata) {
+ fudge_x = pdata->ts_x_fudge ? : TSC2005_DEF_X_FUZZ;
+ fudge_y = pdata->ts_y_fudge ? : TSC2005_DEF_Y_FUZZ;
+ fudge_p = pdata->ts_pressure_fudge ? : TSC2005_DEF_P_FUZZ;
+ max_x = pdata->ts_x_max ? : MAX_12BIT;
+ max_y = pdata->ts_y_max ? : MAX_12BIT;
+ max_p = pdata->ts_pressure_max ? : MAX_12BIT;
+ x_plate_ohm = pdata->ts_x_plate_ohm ? : TSC2005_DEF_RESISTOR;
+ esd_timeout = pdata->esd_timeout_ms;
+ } else {
+ fudge_x = TSC2005_DEF_X_FUZZ;
+ of_property_read_u32(np, "ti,fuzz-x", &fudge_x);
+ fudge_y = TSC2005_DEF_Y_FUZZ;
+ of_property_read_u32(np, "ti,fuzz-y", &fudge_y);
+ fudge_p = TSC2005_DEF_P_FUZZ;
+ of_property_read_u32(np, "ti,fuzz-pressure", &fudge_p);
+ max_x = MAX_12BIT;
+ of_property_read_u32(np, "ti,max-x", &max_x);
+ max_y = MAX_12BIT;
+ of_property_read_u32(np, "ti,max-y", &max_y);
+ max_p = MAX_12BIT;
+ of_property_read_u32(np, "ti,max-pressure", &max_p);
+ x_plate_ohm = TSC2005_DEF_RESISTOR;
+ of_property_read_u32(np, "ti,x-plate-resistance", &x_plate_ohm);
+ esd_timeout = 0;
+ of_property_read_u32(np, "ti,esd-recovery-timeout-ms",
+ &esd_timeout);
+ }
+
spi->mode = SPI_MODE_0;
spi->bits_per_word = 8;
if (!spi->max_speed_hz)
@@ -612,9 +652,30 @@ static int tsc2005_probe(struct spi_device *spi)
ts->spi = spi;
ts->idev = input_dev;
- ts->x_plate_ohm = pdata->ts_x_plate_ohm ? : 280;
- ts->esd_timeout = pdata->esd_timeout_ms;
- ts->set_reset = pdata->set_reset;
+ ts->x_plate_ohm = x_plate_ohm;
+ ts->esd_timeout = esd_timeout;
+
+ if (np) {
+ ts->reset_gpio = of_get_named_gpio(np, "reset-gpio", 0);
+ if (ts->reset_gpio == -EPROBE_DEFER)
+ return ts->reset_gpio;
+ if (ts->reset_gpio < 0) {
+ dev_err(&spi->dev, "error acquiring reset gpio: %d\n",
+ ts->reset_gpio);
+ return ts->reset_gpio;
+ }
+
+ error = devm_gpio_request_one(&spi->dev, ts->reset_gpio, 0,
+ "reset-gpio");
+ if (error) {
+ dev_err(&spi->dev, "error requesting reset gpio: %d\n",
+ error);
+ return error;
+ }
+ } else {
+ ts->reset_gpio = -1;
+ ts->set_reset = pdata->set_reset;
+ }
mutex_init(&ts->mutex);
--
1.8.4.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] Documentation: dt: Document TSC2005 DT binding
2013-12-05 23:09 [PATCH 0/2] tsc2005 DT binding Sebastian Reichel
2013-12-05 23:09 ` [PATCH 1/2] Input: tsc2005: add DT support Sebastian Reichel
@ 2013-12-05 23:09 ` Sebastian Reichel
2013-12-09 17:46 ` Tony Lindgren
1 sibling, 1 reply; 6+ messages in thread
From: Sebastian Reichel @ 2013-12-05 23:09 UTC (permalink / raw)
To: Sebastian Reichel, Dmitry Torokhov, Dmitry Torokhov, linux-input
Cc: Rob Herring, Pawel Moll, Mark Rutland, Stephen Warren,
Ian Campbell, Rob Landley, Grant Likely, devicetree, linux-omap,
linux-kernel, Sebastian Reichel
Add devicetree binding documentation for TSC2005 touchscreen.
Signed-off-by: Sebastian Reichel <sre@debian.org>
---
.../bindings/input/touchscreen/tsc2005.txt | 49 ++++++++++++++++++++++
1 file changed, 49 insertions(+)
create mode 100644 Documentation/devicetree/bindings/input/touchscreen/tsc2005.txt
diff --git a/Documentation/devicetree/bindings/input/touchscreen/tsc2005.txt b/Documentation/devicetree/bindings/input/touchscreen/tsc2005.txt
new file mode 100644
index 0000000..4e7df0b
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/touchscreen/tsc2005.txt
@@ -0,0 +1,49 @@
+* TSC2005 Touchscreen
+
+Required properties:
+ - compatible : "ti,tsc2005"
+ - reg : SPI device address
+ - spi-max-frequency : Maximal SPI speed
+ - interrupts : IRQ specifier
+ - reset-gpio : GPIO specifier
+
+Optional properties:
+ - ti,fuzz-x : integer, X noise value of the touchscreen
+ (defaults to 4)
+ - ti,fuzz-y : integer, Y noise value of the touchscreen
+ (defaults to 8)
+ - ti,fuzz-pressure : integer, pressure noise value of the touchscreen
+ (defaults to 2)
+ - ti,max-x : integer, maximum reported x value
+ (defaults to 4096)
+ - ti,max-y : integer, maximum reported y value
+ (defaults to 4096)
+ - ti,max-pressure : integer, maximum reported pressure
+ (defaults to 4096)
+ - ti,x-plate-resistance : integer, resistance of the touchscreen's X plates
+ in ohm (defaults to 280)
+ - ti,esd-recovery-timeout-ms : integer, if the touchscreen does not respond after
+ the configured time (in milli seconds), the driver
+ will reset it. This is disabled by default.
+
+Example:
+
+&mcspi1 {
+ tsc2005@0 {
+ compatible = "ti,tsc2005";
+ spi-max-frequency = <6000000>;
+ reg = <0>;
+ reset-gpio = <&gpio4 8 GPIO_ACTIVE_HIGH>; /* 104 */
+ interrupt-parent = <&gpio4>;
+ interrupts = <4 IRQ_TYPE_NONE>; /* gpio line 100 */
+
+ ti,fuzz-x = <4>;
+ ti,fuzz-y = <7>;
+ ti,fuzz-pressure = <2>;
+ ti,max-x = <4096>;
+ ti,max-y = <4096>;
+ ti,max-pressure = <2048>;
+ ti,x-plate-resistance = <280>;
+ ti,esd-recovery-timeout-ms = <8000>;
+ };
+}
--
1.8.4.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] Documentation: dt: Document TSC2005 DT binding
2013-12-05 23:09 ` [PATCH 2/2] Documentation: dt: Document TSC2005 DT binding Sebastian Reichel
@ 2013-12-09 17:46 ` Tony Lindgren
2013-12-09 18:24 ` Sebastian Reichel
0 siblings, 1 reply; 6+ messages in thread
From: Tony Lindgren @ 2013-12-09 17:46 UTC (permalink / raw)
To: Sebastian Reichel
Cc: Sebastian Reichel, Dmitry Torokhov, Dmitry Torokhov, linux-input,
Rob Herring, Pawel Moll, Mark Rutland, Stephen Warren,
Ian Campbell, Rob Landley, Grant Likely, devicetree, linux-omap,
linux-kernel
* Sebastian Reichel <sre@debian.org> [131205 15:11]:
> Add devicetree binding documentation for TSC2005 touchscreen.
>
> Signed-off-by: Sebastian Reichel <sre@debian.org>
> ---
> .../bindings/input/touchscreen/tsc2005.txt | 49 ++++++++++++++++++++++
> 1 file changed, 49 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/input/touchscreen/tsc2005.txt
>
> diff --git a/Documentation/devicetree/bindings/input/touchscreen/tsc2005.txt b/Documentation/devicetree/bindings/input/touchscreen/tsc2005.txt
> new file mode 100644
> index 0000000..4e7df0b
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/input/touchscreen/tsc2005.txt
> @@ -0,0 +1,49 @@
> +* TSC2005 Touchscreen
> +
> +Required properties:
> + - compatible : "ti,tsc2005"
> + - reg : SPI device address
> + - spi-max-frequency : Maximal SPI speed
> + - interrupts : IRQ specifier
> + - reset-gpio : GPIO specifier
> +
> +Optional properties:
> + - ti,fuzz-x : integer, X noise value of the touchscreen
> + (defaults to 4)
> + - ti,fuzz-y : integer, Y noise value of the touchscreen
> + (defaults to 8)
> + - ti,fuzz-pressure : integer, pressure noise value of the touchscreen
> + (defaults to 2)
> + - ti,max-x : integer, maximum reported x value
> + (defaults to 4096)
> + - ti,max-y : integer, maximum reported y value
> + (defaults to 4096)
> + - ti,max-pressure : integer, maximum reported pressure
> + (defaults to 4096)
> + - ti,x-plate-resistance : integer, resistance of the touchscreen's X plates
> + in ohm (defaults to 280)
> + - ti,esd-recovery-timeout-ms : integer, if the touchscreen does not respond after
> + the configured time (in milli seconds), the driver
> + will reset it. This is disabled by default.
Instead of adding these optional ti,* properties you can set them in the
driver directly in the of_match table based on the compatible flag. Then
you can pass compatible flag like ti,tsc2005-nokia-n900, or the name of
the LCD panel. Most likely these depend on the LCD panel selected.
Regards,
Tony
> +Example:
> +
> +&mcspi1 {
> + tsc2005@0 {
> + compatible = "ti,tsc2005";
> + spi-max-frequency = <6000000>;
> + reg = <0>;
> + reset-gpio = <&gpio4 8 GPIO_ACTIVE_HIGH>; /* 104 */
> + interrupt-parent = <&gpio4>;
> + interrupts = <4 IRQ_TYPE_NONE>; /* gpio line 100 */
> +
> + ti,fuzz-x = <4>;
> + ti,fuzz-y = <7>;
> + ti,fuzz-pressure = <2>;
> + ti,max-x = <4096>;
> + ti,max-y = <4096>;
> + ti,max-pressure = <2048>;
> + ti,x-plate-resistance = <280>;
> + ti,esd-recovery-timeout-ms = <8000>;
> + };
> +}
> --
> 1.8.4.3
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] Documentation: dt: Document TSC2005 DT binding
2013-12-09 17:46 ` Tony Lindgren
@ 2013-12-09 18:24 ` Sebastian Reichel
2013-12-10 0:06 ` Tony Lindgren
0 siblings, 1 reply; 6+ messages in thread
From: Sebastian Reichel @ 2013-12-09 18:24 UTC (permalink / raw)
To: Tony Lindgren
Cc: Dmitry Torokhov, Dmitry Torokhov, linux-input, Rob Herring,
Pawel Moll, Mark Rutland, Stephen Warren, Ian Campbell,
Rob Landley, Grant Likely, devicetree, linux-omap, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1501 bytes --]
On Mon, Dec 09, 2013 at 09:46:38AM -0800, Tony Lindgren wrote:
> > +Optional properties:
> > + - ti,fuzz-x : integer, X noise value of the touchscreen
> > + (defaults to 4)
> > + - ti,fuzz-y : integer, Y noise value of the touchscreen
> > + (defaults to 8)
> > + - ti,fuzz-pressure : integer, pressure noise value of the touchscreen
> > + (defaults to 2)
> > + - ti,max-x : integer, maximum reported x value
> > + (defaults to 4096)
> > + - ti,max-y : integer, maximum reported y value
> > + (defaults to 4096)
> > + - ti,max-pressure : integer, maximum reported pressure
> > + (defaults to 4096)
> > + - ti,x-plate-resistance : integer, resistance of the touchscreen's X plates
> > + in ohm (defaults to 280)
> > + - ti,esd-recovery-timeout-ms : integer, if the touchscreen does not respond after
> > + the configured time (in milli seconds), the driver
> > + will reset it. This is disabled by default.
>
> Instead of adding these optional ti,* properties you can set them in the
> driver directly in the of_match table based on the compatible flag. Then
> you can pass compatible flag like ti,tsc2005-nokia-n900, or the name of
> the LCD panel. Most likely these depend on the LCD panel selected.
I could certainly do this, but it would move the board specific data
from the boardcode into the driver. That looks contra-productive to
me. Is there a good reason to do it this way?
-- Sebastian
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] Documentation: dt: Document TSC2005 DT binding
2013-12-09 18:24 ` Sebastian Reichel
@ 2013-12-10 0:06 ` Tony Lindgren
0 siblings, 0 replies; 6+ messages in thread
From: Tony Lindgren @ 2013-12-10 0:06 UTC (permalink / raw)
To: Dmitry Torokhov, Dmitry Torokhov, linux-input, Rob Herring,
Pawel Moll, Mark Rutland, Stephen Warren, Ian Campbell,
Rob Landley, Grant Likely, devicetree, linux-omap, linux-kernel
* Sebastian Reichel <sre@debian.org> [131209 10:25]:
> On Mon, Dec 09, 2013 at 09:46:38AM -0800, Tony Lindgren wrote:
> > > +Optional properties:
> > > + - ti,fuzz-x : integer, X noise value of the touchscreen
> > > + (defaults to 4)
> > > + - ti,fuzz-y : integer, Y noise value of the touchscreen
> > > + (defaults to 8)
> > > + - ti,fuzz-pressure : integer, pressure noise value of the touchscreen
> > > + (defaults to 2)
> > > + - ti,max-x : integer, maximum reported x value
> > > + (defaults to 4096)
> > > + - ti,max-y : integer, maximum reported y value
> > > + (defaults to 4096)
> > > + - ti,max-pressure : integer, maximum reported pressure
> > > + (defaults to 4096)
> > > + - ti,x-plate-resistance : integer, resistance of the touchscreen's X plates
> > > + in ohm (defaults to 280)
> > > + - ti,esd-recovery-timeout-ms : integer, if the touchscreen does not respond after
> > > + the configured time (in milli seconds), the driver
> > > + will reset it. This is disabled by default.
> >
> > Instead of adding these optional ti,* properties you can set them in the
> > driver directly in the of_match table based on the compatible flag. Then
> > you can pass compatible flag like ti,tsc2005-nokia-n900, or the name of
> > the LCD panel. Most likely these depend on the LCD panel selected.
>
> I could certainly do this, but it would move the board specific data
> from the boardcode into the driver. That looks contra-productive to
> me. Is there a good reason to do it this way?
You can leave out the custom properties that way for something that probably
should be grouped by the touchpanel type connected as the values are the
same.
So for example just a few compatible flags like ti,tsc2005-panel-abc and
ti,tsc2005-panel-xyz we could potentially cover all the configurations
we're aware of without any need for custom properties. And this is way
easier to support in the long run assuming we don't end up with tons of
compatible flags. Of course if we end up with a new compatible flag for
each configuration, then it makes sense to set up the custom properties,
but I doubt that's the case here.
Regards,
Tony
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-12-10 0:06 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-05 23:09 [PATCH 0/2] tsc2005 DT binding Sebastian Reichel
2013-12-05 23:09 ` [PATCH 1/2] Input: tsc2005: add DT support Sebastian Reichel
2013-12-05 23:09 ` [PATCH 2/2] Documentation: dt: Document TSC2005 DT binding Sebastian Reichel
2013-12-09 17:46 ` Tony Lindgren
2013-12-09 18:24 ` Sebastian Reichel
2013-12-10 0:06 ` Tony Lindgren
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).