tsc2005 DT binding
Subsystems (3)
v4 cover tsc2005 DT binding
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. The n900 platform code will be removed in the near future (3.17?) and the driver can be simplified once that has happened.
Changes since v3 [0]:
* Move common touchscreen DT handling code into its own file
* Add regulator support to tsc2005 driver
* Added N900 DTS patch for completeness. It should go via Tony's Tree of course.
[0] https://lkml.org/lkml/2014/4/25/694
-- Sebastian
Sebastian Reichel (4):
Input: add common DT binding for touchscreens
Input: tsc2005: add DT support
Documentation: dt: Document TSC2005 DT binding
DTS: ARM: OMAP3-N900: Add tsc2005 support
.../bindings/input/touchscreen/touchscreen.txt | 27 +++++ .../bindings/input/touchscreen/tsc2005.txt | 42 +++++++ arch/arm/boot/dts/omap3-n900.dts | 17 ++- drivers/input/touchscreen/Kconfig | 4 + drivers/input/touchscreen/Makefile | 1 + drivers/input/touchscreen/of_touchscreen.c | 44 ++++++++ drivers/input/touchscreen/tsc2005.c | 122 +++++++++++++++++---- include/linux/input/touchscreen.h | 22 ++++ 8 files changed, 258 insertions(+), 21 deletions(-) create mode 100644 Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt create mode 100644 Documentation/devicetree/bindings/input/touchscreen/tsc2005.txt create mode 100644 drivers/input/touchscreen/of_touchscreen.c create mode 100644 include/linux/input/touchscreen.h
Signature · 6 lines
2.0.0.rc2 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v4 1/4 Input: add common DT binding for touchscreens
Add common DT binding documentation for touchscreen devices and implement input_parse_touchscreen_of_params, which parses the common properties and configures the input device accordingly.
The method currently does not interpret the axis inversion properties, since there is no matching flag in the generic linux input device.
--- .../bindings/input/touchscreen/touchscreen.txt | 27 +++++++++++++ drivers/input/touchscreen/Kconfig | 4 ++ drivers/input/touchscreen/Makefile | 1 + drivers/input/touchscreen/of_touchscreen.c | 44 ++++++++++++++++++++++ include/linux/input/touchscreen.h | 22 +++++++++++ 5 files changed, 98 insertions(+) create mode 100644 Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt create mode 100644 drivers/input/touchscreen/of_touchscreen.c create mode 100644 include/linux/input/touchscreen.h
Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt new file +27 -0
@@ -0,0 +1,27 @@ +General Touchscreen Properties: + +Optional properties for Touchscreens: + - touchscreen-size-x : horizontal resolution of touchscreen + (in pixels) + - touchscreen-size-y : vertical resolution of touchscreen + (in pixels) + - touchscreen-max-pressure : maximum reported pressure (arbitrary range + dependent on the controller) + - touchscreen-fuzz-x : horizontal noise value of the absolute input + device (in pixels) + - touchscreen-fuzz-y : vertical noise value of the absolute input + device (in pixels) + - touchscreen-fuzz-pressure : pressure noise value of the absolute input + device (arbitrary range dependent on the + controller) + - touchscreen-inverted-x : X axis is inverted (boolean) + - touchscreen-inverted-y : Y axis is inverted (boolean) + +Deprecated properties for Touchscreens: + - x-size : deprecated name for touchscreen-size-x + - y-size : deprecated name for touchscreen-size-y + - moving-threshold : deprecated name for a combination of + touchscreen-fuzz-x and touchscreen-fuzz-y + - contact-threshold : deprecated name for touchscreen-fuzz-pressure + - x-invert : deprecated name for touchscreen-inverted-x + - y-invert : deprecated name for touchscreen-inverted-y
drivers/input/touchscreen/Kconfig +4 -0
@@ -11,6 +11,10 @@ menuconfig INPUT_TOUCHSCREEN if INPUT_TOUCHSCREEN +config OF_TOUCHSCREEN + def_tristate INPUT + depends on INPUT && OF + config TOUCHSCREEN_88PM860X tristate "Marvell 88PM860x touchscreen" depends on MFD_88PM860X
drivers/input/touchscreen/Makefile +1 -0
@@ -6,6 +6,7 @@ wm97xx-ts-y := wm97xx-core.o +obj-$(CONFIG_OF_TOUCHSCREEN) += of_touchscreen.o obj-$(CONFIG_TOUCHSCREEN_88PM860X) += 88pm860x-ts.o obj-$(CONFIG_TOUCHSCREEN_AD7877) += ad7877.o obj-$(CONFIG_TOUCHSCREEN_AD7879) += ad7879.o
drivers/input/touchscreen/of_touchscreen.c new file +44 -0
44 lines not on this page · raw message
include/linux/input/touchscreen.h new file +22 -0
@@ -0,0 +1,22 @@ +/* +* Copyright (c) 2014 Sebastian Reichel <[email protected]> +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License version 2 as published by +* the Free Software Foundation. +*/ + +#ifndef _TOUCHSCREEN_H +#define _TOUCHSCREEN_H + +#include <linux/input.h> + +#if defined(CONFIG_OF ) +void touchscreen_parse_of_params (struct input_dev *dev); +#else +static inline void touchscreen_parse_of_params (struct input_dev *dev) { +return ; +} +#endif + +#endif
Signature · 1 line
2.0.0.rc2
PATCH v4 2/4 Input: tsc2005: add DT support
In reply to Sebastian ReichelThis adds DT support to the tsc2005 touchscreen driver. It also adds regulator support to the driver if booted via DT.
--- drivers/input/touchscreen/tsc2005.c | 122 ++++++++++++++++++++++++++++++------ 1 file changed, 102 insertions(+), 20 deletions(-)
drivers/input/touchscreen/tsc2005.c +102 -20
@@ -25,11 +25,15 @@#include <linux/kernel.h> #include <linux/module.h> #include <linux/input.h> +#include <linux/input/touchscreen.h> #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> +#include <linux/regulator/consumer.h> /* * The touchscreen interface operates as follows:
@@ -100,6 +104,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 +152,9 @@ struct tsc2005 {bool pen_down; +struct regulator *vio; + +int reset_gpio;void (*set_reset)(bool enable); };
@@ -337,6 +349,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 +375,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 +434,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 +479,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 +529,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 +592,47 @@ static void tsc2005_setup_spi_xfer(struct tsc2005 *ts)static int tsc2005_probe (struct spi_device *spi) {const struct tsc2005_platform_data *pdata =dev_get_platdata (&spi->dev); +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 max_x =MAX_12BIT ; +unsigned int max_y =MAX_12BIT ; +unsigned int max_p =MAX_12BIT ; +unsigned int fudge_x =TSC2005_DEF_X_FUZZ ; +unsigned int fudge_y =TSC2005_DEF_Y_FUZZ ; +unsigned int fudge_p =TSC2005_DEF_P_FUZZ ; +unsigned int x_plate_ohm =TSC2005_DEF_RESISTOR ; +unsigned int esd_timeout;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; + 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 =TSC2005_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); + } + spi->mode =SPI_MODE_0 ; spi->bits_per_word =8 ;if (!spi->max_speed_hz)
@@ -612,9 +650,37 @@ 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-gpios" ,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-gpios" ); +if (error) { +dev_err (&spi->dev,"error requesting reset gpio: %d\n" , + error); +return error; + } + + ts->vio =devm_regulator_get (&spi->dev,"vio" ); +if (IS_ERR (ts->vio)) { + error =PTR_ERR (ts->vio); +dev_err (&spi->dev,"vio regulator missing (%d)" , error); +return error; + } + }else { + ts->reset_gpio =-1 ; + ts->set_reset = pdata->set_reset; + }mutex_init (&ts->mutex);
@@ -639,6 +705,9 @@ static int tsc2005_probe(struct spi_device *spi)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_of_params (input_dev); + input_dev->open = tsc2005_open; input_dev->close = tsc2005_close;
@@ -656,12 +725,19 @@ static int tsc2005_probe(struct spi_device *spi)return error; } +/* enable regulator for DT */ +if (ts->vio) { + error =regulator_enable (ts->vio); +if (error) +return error; + } +spi_set_drvdata (spi, ts); error =sysfs_create_group (&spi->dev.kobj, &tsc2005_attr_group);if (error) {dev_err (&spi->dev,"Failed to create sysfs attributes, err: %d\n" , error); -return error; + goto disable_regulator; } error =input_register_device (ts->idev);
@@ -676,6 +752,9 @@ static int tsc2005_probe(struct spi_device *spi) err_remove_sysfs:sysfs_remove_group (&spi->dev.kobj, &tsc2005_attr_group); +disable_regulator: +if (ts->vio) +regulator_disable (ts->vio);return error; }
@@ -685,6 +764,9 @@ static int tsc2005_remove(struct spi_device *spi)sysfs_remove_group (&ts->spi->dev.kobj, &tsc2005_attr_group); +if (ts->vio) +regulator_disable (ts->vio); +return 0 ; }
Signature · 1 line
2.0.0.rc2
PATCH v4 3/4 Documentation: dt: Document TSC2005 DT binding
In reply to Sebastian ReichelAdd devicetree binding documentation for TSC2005 touchscreen.
--- .../bindings/input/touchscreen/tsc2005.txt | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 Documentation/devicetree/bindings/input/touchscreen/tsc2005.txt
Documentation/devicetree/bindings/input/touchscreen/tsc2005.txt new file +42 -0
@@ -0,0 +1,42 @@ +* Texas Instruments tsc2005 touchscreen controller + +Required properties: + - compatible : "ti,tsc2005" + - reg : SPI device address + - spi-max-frequency : Maximal SPI speed + - interrupts : IRQ specifier + - reset-gpios : GPIO specifier + - vio-supply : Regulator specifier + +Optional properties: + - ti,x-plate-ohms : 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. + - properties defined in touchscreen.txt + +Example: + +&mcspi1 { + tsc2005@0 { + compatible = "ti,tsc2005"; + spi-max-frequency = <6000000>; + reg = <0>; + + vio-supply = <&vio>; + + reset-gpios = <&gpio4 8 GPIO_ACTIVE_HIGH>; /* 104 */ + interrupts-extended = <&gpio4 4 IRQ_TYPE_EDGE_RISING>; /* 100 */ + + touchscreen-fuzz-x = <4>; + touchscreen-fuzz-y = <7>; + touchscreen-fuzz-pressure = <2>; + touchscreen-max-x = <4096>; + touchscreen-max-y = <4096>; + touchscreen-max-pressure = <2048>; + + ti,x-plate-ohms = <280>; + ti,esd-recovery-timeout-ms = <8000>; + }; +}
Signature · 1 line
2.0.0.rc2
PATCH v4 4/4 DTS: ARM: OMAP3-N900: Add tsc2005 support
In reply to Sebastian ReichelThis adds support for the tsc2005 touchscreen
to the Nokia N900 DTS file.
--- arch/arm/boot/dts/omap3-n900.dts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
arch/arm/boot/dts/omap3-n900.dts +16 -1
@@ -580,9 +580,24 @@ * Also... order in the device tree actually matters here. */ tsc2005@0 { - compatible = "tsc2005"; + compatible = "ti,tsc2005"; spi-max-frequency = <6000000>; reg = <0>; + + vio-supply = <&vio>; + + reset-gpios = <&gpio4 8 GPIO_ACTIVE_HIGH>; /* 104 */ + interrupts-extended = <&gpio4 4 IRQ_TYPE_EDGE_RISING>; /* 100 */ + + touchscreen-fuzz-x = <4>; + touchscreen-fuzz-y = <7>; + touchscreen-fuzz-pressure = <2>; + touchscreen-max-x = <4096>; + touchscreen-max-y = <4096>; + touchscreen-max-pressure = <2048>; + + ti,x-plate-ohms = <280>; + ti,esd-recovery-timeout-ms = <8000>; }; acx565akm@2 {
Signature · 1 line
2.0.0.rc2
Re: [PATCHv4 4/4] DTS: ARM: OMAP3-N900: Add tsc2005 support
Quoted 4 lines · Sebastian Reichel
This adds support for the tsc2005 touchscreen
to the Nokia N900 DTS file.Signed-off-by Sebastian Reichel <[email protected]>
Dmitry, if no other comments, feel free to pick this one too. This does not seem to conflict with anything I have queued:
Quoted 42 lines
--- arch/arm/boot/dts/omap3-n900.dts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)arch/arm/boot/dts/omap3-n900.dts +16
-1@@ -580,9 +580,24 @@ * Also... order in the device tree actually matters here. */ tsc2005@0 { - compatible = "tsc2005"; + compatible = "ti,tsc2005"; spi-max-frequency = <6000000>; reg = <0>; + + vio-supply = <&vio>; + + reset-gpios = <&gpio4 8 GPIO_ACTIVE_HIGH>; /* 104 */ + interrupts-extended = <&gpio4 4 IRQ_TYPE_EDGE_RISING>; /* 100 */ + + touchscreen-fuzz-x = <4>; + touchscreen-fuzz-y = <7>; + touchscreen-fuzz-pressure = <2>; + touchscreen-max-x = <4096>; + touchscreen-max-y = <4096>; + touchscreen-max-pressure = <2048>; + + ti,x-plate-ohms = <280>; + ti,esd-recovery-timeout-ms = <8000>; }; acx565akm@2 {Signature · 7 lines
2.0.0.rc2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 9 lines · Sebastian Reichel
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. The n900 platform code will be removed in the near future (3.17?) and the driver can be simplified once that has happened.
Quoted 5 lines
Changes since v3 [0]:
* Move common touchscreen DT handling code into its own file
* Add regulator support to tsc2005 driver
* Added N900 DTS patch for completeness. It should go via Tony's Tree of course.
ping! It would be nice to have this in 3.16, since it makes the N900 usable with the mainline kernel when booted in DT mode. The DT bindings haven't changed for more than 3 weeks, so we don't need to wait longer for feedback from the DT maintainers AFAIK.
-- Sebastian
Dmitry Torokhov
maintainerQuoted 16 lines · Sebastian Reichel
Quoted 9 lines · Sebastian Reichel
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. The n900 platform code will be removed in the near future (3.17?) and the driver can be simplified once that has happened.
Quoted 5 lines
Changes since v3 [0]:
* Move common touchscreen DT handling code into its own file
* Add regulator support to tsc2005 driver
* Added N900 DTS patch for completeness. It should go via Tony's Tree of course.
Quoted 5 lines
ping! It would be nice to have this in 3.16, since it makes the N900 usable with the mainline kernel when booted in DT mode. The DT bindings haven't changed for more than 3 weeks, so we don't need to wait longer for feedback from the DT maintainers AFAIK.
Sebastian,
I applied the series, could you please take a peek at my 'next' branch to make sure I did not miss anything?
Thanks.
Signature · 1 line
Dmitry
Hi Dmitry,
Quoted 10 lines · Dmitry Torokhov
Quoted 6 lines · Sebastian Reichel
On Wed, May 21, 2014 at 07:36:10PM +0200, Sebastian Reichel wrote:
ping! It would be nice to have this in 3.16, since it makes the N900 usable with the mainline kernel when booted in DT mode. The DT bindings haven't changed for more than 3 weeks, so we don't need to wait longer for feedback from the DT maintainers AFAIK.I applied the series, could you please take a peek at my 'next' branch to make sure I did not miss anything?
Patches look ok, I also tested the branch on the phone and get events after running the selftest once (which resets the controller). Without running the selftest no events get reported. I will have a look at that in the next days.
-- Sebastian