tsc2005 DT binding
Subsystems (3)
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 (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
Signature · 1 line
1.8.4.3
PATCH 1/2 Input: tsc2005: add DT support
This adds DT support to the tsc2005 touchscreen
driver.
--- drivers/input/touchscreen/tsc2005.c | 95 ++++++++++++++++++++++++++++++------- 1 file changed, 78 insertions(+), 17 deletions(-)
drivers/input/touchscreen/tsc2005.c +78 -17
@@ -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);
Signature · 1 line
1.8.4.3
PATCH 2/2 Documentation: dt: Document TSC2005 DT binding
In reply to Sebastian ReichelAdd devicetree binding documentation for TSC2005 touchscreen.
--- .../bindings/input/touchscreen/tsc2005.txt | 49 ++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 Documentation/devicetree/bindings/input/touchscreen/tsc2005.txt
Documentation/devicetree/bindings/input/touchscreen/tsc2005.txt new file +49 -0
@@ -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>; + }; +}
Signature · 1 line
1.8.4.3
Re: [PATCH 2/2] Documentation: dt: Document TSC2005 DT binding
Quoted 31 lines · Sebastian Reichel
Add devicetree binding documentation for TSC2005 touchscreen.
Signed-off-by Sebastian Reichel <[email protected]>--- .../bindings/input/touchscreen/tsc2005.txt | 49 ++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 Documentation/devicetree/bindings/input/touchscreen/tsc2005.txtDocumentation/devicetree/bindings/input/touchscreen/tsc2005.txt new file +17
-0@@ -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
Documentation/devicetree/bindings/input/touchscreen/tsc2005.txt line 27
Quoted 10 lines
Documentation/devicetree/bindings/input/touchscreen/tsc2005.txt new file +10
-0+ (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
Quoted 28 lines
Documentation/devicetree/bindings/input/touchscreen/tsc2005.txt new file +21
-0+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>; + }; +}Signature · 6 lines
1.8.4.3 -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/2] Documentation: dt: Document TSC2005 DT binding
Quoted 15 lines · Tony Lindgren
Quoted 15 lines
Documentation/devicetree/bindings/input/touchscreen/tsc2005.txt new file +15
-0+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)
Quoted 8 lines
Documentation/devicetree/bindings/input/touchscreen/tsc2005.txt line 27
Quoted 3 lines
+ - ti,esd-recovery-timeout-ms : integer, if the touchscreen does not respond after
Documentation/devicetree/bindings/input/touchscreen/tsc2005.txt new file +2
-0+ 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_matchtable 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
Re: [PATCH 2/2] Documentation: dt: Document TSC2005 DT binding
Quoted 25 lines · Sebastian Reichel
Quoted 15 lines · Tony Lindgren
Quoted 15 lines
Documentation/devicetree/bindings/input/touchscreen/tsc2005.txt new file +15
-0+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)Quoted 8 lines
Documentation/devicetree/bindings/input/touchscreen/tsc2005.txt line 27
Quoted 3 lines
+ - ti,esd-recovery-timeout-ms : integer, if the touchscreen does not respond after
Documentation/devicetree/bindings/input/touchscreen/tsc2005.txt new file +2
-0+ 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_matchtable 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.
Quoted 3 lines
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