tsc2005 DT binding
Subsystems (3)
v3 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.16?) and the driver can be simplified once that has happened.
Changes since v2 [0]:
* rename "ti,x-plate-resistance" to "ti,x-plate-ohms", so that the same property name is used for tsc2005 and tsc2007
* document "x-size" and "y-size" as deprecated form of touchscreen-size-x and touchscreen-size-y
* add documentation for "touchscreen-inverted-x" and "touchscreen-inverted-y" to the common touchscreen binding and mark "x-invert" and "y-invert" as deprecated.
* add units to the property descriptions in the common touchscreen binding Documentation
* document "moving-threshold" as deprecated form of "touchscreen-fuzz-x" and "touchscreen-fuzz-y" combination
* document "contact-threshold" as deprecated form of "touchscreen-fuzz-pressure"
[0] https://lkml.org/lkml/2014/4/5/103
-- Sebastian
Sebastian Reichel (5):
Input: add common DT binding for touchscreens
Input: tsc2005: use dev_err for error messages
Input: tsc2005: convert driver to use devm_*
Input: tsc2005: add DT support
Documentation: dt: Document TSC2005 DT binding
.../bindings/input/touchscreen/touchscreen.txt | 27 +++++ .../bindings/input/touchscreen/tsc2005.txt | 39 +++++++ drivers/input/input.c | 34 ++++++ drivers/input/touchscreen/tsc2005.c | 130 ++++++++++++++------- include/linux/input.h | 8 ++ 5 files changed, 197 insertions(+), 41 deletions(-) create mode 100644 Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt create mode 100644 Documentation/devicetree/bindings/input/touchscreen/tsc2005.txt
Signature · 6 lines
1.9.2 -- 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 v3 1/5 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/input.c | 34 ++++++++++++++++++++++ include/linux/input.h | 8 +++++ 3 files changed, 69 insertions(+) create mode 100644 Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt
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/input.c +34 -0
@@ -27,6 +27,7 @@#include <linux/device.h> #include <linux/mutex.h> #include <linux/rcupdate.h> +#include <linux/of.h> #include "input-compat.h" MODULE_AUTHOR ("Vojtech Pavlik <[email protected]>" );
@@ -2398,6 +2399,39 @@ void input_free_minor(unsigned int minor) }EXPORT_SYMBOL (input_free_minor); +#if defined(CONFIG_OF ) +/** +* input_parse_touchscreen_of_params - parse common touchscreen DT properties +* @dev: device that should be parsed +* +* This function parses common DT properties for touchscreens and setups the +* input device accordingly. The function keeps previously setuped default +* values if no value is specified via DT. +*/ +void input_parse_touchscreen_of_params (struct input_dev *dev) +{ +struct device_node *np = dev->dev.parent->of_node; +struct input_absinfo *absinfo; + +input_alloc_absinfo (dev); +if (!dev->absinfo) +return ; + + absinfo = &dev->absinfo[ABS_X ]; +of_property_read_u32 (np,"touchscreen-size-x" , &absinfo->maximum); +of_property_read_u32 (np,"touchscreen-fuzz-x" , &absinfo->fuzz); + + absinfo = &dev->absinfo[ABS_Y ]; +of_property_read_u32 (np,"touchscreen-size-y" , &absinfo->maximum); +of_property_read_u32 (np,"touchscreen-fuzz-y" , &absinfo->fuzz); + + absinfo = &dev->absinfo[ABS_PRESSURE ]; +of_property_read_u32 (np,"touchscreen-max-pressure" , &absinfo->maximum); +of_property_read_u32 (np,"touchscreen-fuzz-pressure" , &absinfo->fuzz); +} +EXPORT_SYMBOL (input_parse_touchscreen_of_params); +#endif +static int __init input_init (void ) {int err;
include/linux/input.h +8 -0
@@ -531,4 +531,12 @@ int input_ff_erase(struct input_dev *dev, int effect_id, struct file *file);int input_ff_create_memless (struct input_dev *dev,void *data,int (*play_effect)(struct input_dev *,void *,struct ff_effect *)); +#if defined(CONFIG_OF ) +void input_parse_touchscreen_of_params (struct input_dev *dev); +#else +static inline void input_parse_touchscreen_of_params (struct input_dev *dev) { +return ; +} +#endif +#endif
Signature · 1 line
1.9.2
Re: [PATCHv3 1/5] Input: add common DT binding for touchscreens
Quoted 8 lines · Sebastian Reichel
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.
Signed-off-by Sebastian Reichel <[email protected]>
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [PATCHv3 1/5] Input: add common DT binding for touchscreens
In reply to Sebastian ReichelQuoted 29 lines · Sebastian Reichel
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.
Signed-off-by Sebastian Reichel <[email protected]>--- .../bindings/input/touchscreen/touchscreen.txt | 27 +++++++++++++++++ drivers/input/input.c | 34 ++++++++++++++++++++++ include/linux/input.h | 8 +++++ 3 files changed, 69 insertions(+) create mode 100644 Documentation/devicetree/bindings/input/touchscreen/touchscreen.txtDocumentation/devicetree/bindings/input/touchscreen/touchscreen.txt new file +8
-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
Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt line 18
Quoted 10 lines
Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt new file +10
-0+ 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)
We probably also need something to swap x and y depending on the display orientation in addition to the touchscreen-inverted-x and y. Just swapping x and y is not enough depending if we rotate by 270 degrees instead of 90 degrees.
Naturally that part can be added later.
Regards,
That
Dmitry Torokhov
maintainerRe: [PATCHv3 1/5] Input: add common DT binding for touchscreens
Quoted 30 lines · Tony Lindgren
Quoted 29 lines · Sebastian Reichel
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.
Signed-off-by Sebastian Reichel <[email protected]>--- .../bindings/input/touchscreen/touchscreen.txt | 27 +++++++++++++++++ drivers/input/input.c | 34 ++++++++++++++++++++++ include/linux/input.h | 8 +++++ 3 files changed, 69 insertions(+) create mode 100644 Documentation/devicetree/bindings/input/touchscreen/touchscreen.txtDocumentation/devicetree/bindings/input/touchscreen/touchscreen.txt new file +8
-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
Quoted 8 lines
Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt line 16
Quoted 8 lines
Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt new file +8
-0+ 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)
Fuzz seems like linux-specific property, not generic one.
Quoted 9 lines
Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt line 18
Quoted 2 lines
Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt new file +2
-0+ - touchscreen-inverted-x : X axis is inverted (boolean) + - touchscreen-inverted-y : Y axis is inverted (boolean)We probably also need something to swap x and y depending on the display orientation in addition to the touchscreen-inverted-x and y. Just swapping x and y is not enough depending if we rotate by 270 degrees instead of 90 degrees.
Naturally that part can be added later.
So far we've been relying on upper layers (such as tslib) to perform such transformations rather than re-implementing it in every driver. Are we saying that we need to implement this in input core?
Thanks.
Signature · 1 line
Dmitry
Re: [PATCHv3 1/5] Input: add common DT binding for touchscreens
Quoted 51 lines · Dmitry Torokhov
Quoted 30 lines · Tony Lindgren
Quoted 29 lines · Sebastian Reichel
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.
Signed-off-by Sebastian Reichel <[email protected]>--- .../bindings/input/touchscreen/touchscreen.txt | 27 +++++++++++++++++ drivers/input/input.c | 34 ++++++++++++++++++++++ include/linux/input.h | 8 +++++ 3 files changed, 69 insertions(+) create mode 100644 Documentation/devicetree/bindings/input/touchscreen/touchscreen.txtDocumentation/devicetree/bindings/input/touchscreen/touchscreen.txt new file +8
-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 rangeQuoted 8 lines
Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt line 16
Quoted 8 lines
Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt new file +8
-0+ 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)Fuzz seems like linux-specific property, not generic one.
Quoted 8 lines
Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt line 18
Quoted 2 lines
Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt new file +2
-0+ - touchscreen-inverted-x : X axis is inverted (boolean) + - touchscreen-inverted-y : Y axis is inverted (boolean)We probably also need something to swap x and y depending on the display orientation in addition to the touchscreen-inverted-x and y. Just swapping x and y is not enough depending if we rotate by 270 degrees instead of 90 degrees.
Quoted 5 lines
Quoted 1 line
Naturally that part can be added later.
So far we've been relying on upper layers (such as tslib) to perform such transformations rather than re-implementing it in every driver. Are we saying that we need to implement this in input core?
We seem to have that already partially implemented at least with ti,swap-xy in Documentation/devicetree/bindings/input/ads7846.txt.
But that only works for the 90 degree rotation case as it's missing something similar to touchscreen-inverted-x I just noticed few days ago while trying to make some legacy code disappear :)
No idea where rotation should be specified. But if the panel is rotated based on the DT property or kernel cmdline, probably the touchscreen should be too? In most cases touchscreens are integrated together with the LCD panel, and they are not separate like other input devices.
Regards,
Tony
Re: [PATCHv3 1/5] Input: add common DT binding for touchscreens
In reply to Dmitry TorokhovQuoted 33 lines · Dmitry Torokhov
Quoted 32 lines · Tony Lindgren
Quoted 31 lines · Sebastian Reichel
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.
Signed-off-by Sebastian Reichel <[email protected]>--- .../bindings/input/touchscreen/touchscreen.txt | 27 +++++++++++++++++ drivers/input/input.c | 34 ++++++++++++++++++++++ include/linux/input.h | 8 +++++ 3 files changed, 69 insertions(+) create mode 100644 Documentation/devicetree/bindings/input/touchscreen/touchscreen.txtDocumentation/devicetree/bindings/input/touchscreen/touchscreen.txt new file +10
-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
Quoted 8 lines
Quoted 6 lines
Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt line 16
Quoted 6 lines
Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt new file +6
-0+ 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)Fuzz seems like linux-specific property, not generic one.
I don't know about the term "fuzz", but the idea is pretty generic IMHO. It's similar to debouncing switches/buttons.
Quoted 8 lines
Quoted 8 lines
Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt line 18
Quoted 2 lines
Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt new file +2
-0+ - touchscreen-inverted-x : X axis is inverted (boolean) + - touchscreen-inverted-y : Y axis is inverted (boolean)We probably also need something to swap x and y depending on the display orientation in addition to the touchscreen-inverted-x and y. Just swapping x and y is not enough depending if we rotate by 270 degrees instead of 90 degrees.
Quoted 5 lines
Quoted 1 line
Naturally that part can be added later.
So far we've been relying on upper layers (such as tslib) to perform such transformations rather than re-implementing it in every driver. Are we saying that we need to implement this in input core?
I would appreciate to add this later to move on with this patchset. Having the N900's touchscreen working via DT in 3.16 would be nice now that the display is working :)
-- Sebastian
Dmitry Torokhov
maintainerRe: [PATCHv3 1/5] Input: add common DT binding for touchscreens
Quoted 43 lines · Sebastian Reichel
Quoted 33 lines · Dmitry Torokhov
Quoted 32 lines · Tony Lindgren
Quoted 31 lines · Sebastian Reichel
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.
Signed-off-by Sebastian Reichel <[email protected]>--- .../bindings/input/touchscreen/touchscreen.txt | 27 +++++++++++++++++ drivers/input/input.c | 34 ++++++++++++++++++++++ include/linux/input.h | 8 +++++ 3 files changed, 69 insertions(+) create mode 100644 Documentation/devicetree/bindings/input/touchscreen/touchscreen.txtDocumentation/devicetree/bindings/input/touchscreen/touchscreen.txt new file +10
-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 inputQuoted 8 lines
Quoted 6 lines
Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt line 16
Quoted 6 lines
Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt new file +6
-0+ 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)Fuzz seems like linux-specific property, not generic one.
Quoted 2 lines
I don't know about the term "fuzz", but the idea is pretty generic IMHO. It's similar to debouncing switches/buttons.
OK, fair enough.
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt line 18
Quoted 3 lines
Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt new file +2
-0+ - touchscreen-inverted-x : X axis is inverted (boolean) + - touchscreen-inverted-y : Y axis is inverted (boolean)We probably also need something to swap x and y depending on the display orientation in addition to the touchscreen-inverted-x and y. Just swapping x and y is not enough depending if we rotate by 270 degrees instead of 90 degrees.
Naturally that part can be added later.
Quoted 8 lines
Quoted 3 lines
So far we've been relying on upper layers (such as tslib) to perform such transformations rather than re-implementing it in every driver. Are we saying that we need to implement this in input core?
I would appreciate to add this later to move on with this patchset. Having the N900's touchscreen working via DT in 3.16 would be nice now that the display is working :)
Please remove the "inverted" bits and move touchscreen OF parsing into a separate file/module, similarly to support for sparse and matrix keymaps that we have - it does not really belong to input core.
Thanks.
Signature · 1 line
Dmitry
PATCH v3 2/5 Input: tsc2005: use dev_err for error messages
In reply to Sebastian ReichelChange some dev_dbg() invocations to dev_err() ones, because they are supposed to output error messages.
--- drivers/input/touchscreen/tsc2005.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/input/touchscreen/tsc2005.c +2 -2
@@ -579,7 +579,7 @@ static int tsc2005_probe(struct spi_device *spi)int error;if (!pdata) { -dev_dbg (&spi->dev,"no platform data\n" ); +dev_err (&spi->dev,"no platform data\n" );return -ENODEV ; }
@@ -591,7 +591,7 @@ static int tsc2005_probe(struct spi_device *spi) max_p = pdata->ts_pressure_max ? :MAX_12BIT ;if (spi->irq <=0 ) { -dev_dbg (&spi->dev,"no irq\n" ); +dev_err (&spi->dev,"no irq\n" );return -ENODEV ; }
Signature · 1 line
1.9.2
Re: [PATCHv3 2/5] Input: tsc2005: use dev_err for error messages
Quoted 4 lines · Sebastian Reichel
Change some
dev_dbg()invocations todev_err()ones, because they are supposed to output error messages.Signed-off-by Sebastian Reichel <[email protected]>
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [PATCHv3 2/5] Input: tsc2005: use dev_err for error messages
In reply to Sebastian ReichelQuoted 4 lines · Sebastian Reichel
Change some
dev_dbg()invocations todev_err()ones, because they are supposed to output error messages.Signed-off-by Sebastian Reichel <[email protected]>
Applied, thank you.
Quoted 29 lines
--- drivers/input/touchscreen/tsc2005.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/input/touchscreen/tsc2005.c +2
-2@@ -579,7 +579,7 @@ static int tsc2005_probe(struct spi_device *spi)int error;if (!pdata) { -dev_dbg (&spi->dev,"no platform data\n" ); +dev_err (&spi->dev,"no platform data\n" );return -ENODEV ; }@@ -591,7 +591,7 @@ static int tsc2005_probe(struct spi_device *spi) max_p = pdata->ts_pressure_max ? :MAX_12BIT ;if (spi->irq <=0 ) { -dev_dbg (&spi->dev,"no irq\n" ); +dev_err (&spi->dev,"no irq\n" );return -ENODEV ; }Signature · 1 line
1.9.2
Signature · 1 line
Dmitry
PATCH v3 3/5 Input: tsc2005: convert driver to use devm_*
In reply to Sebastian ReichelSimplify the driver by using managed resources for memory allocation of internal struct, input device allocation and irq request.
--- drivers/input/touchscreen/tsc2005.c | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-)
drivers/input/touchscreen/tsc2005.c +10 -20
@@ -604,12 +604,10 @@ static int tsc2005_probe(struct spi_device *spi)if (error)return error; - ts =kzalloc (sizeof (*ts),GFP_KERNEL ); - input_dev =input_allocate_device (); -if (!ts || !input_dev) { - error = -ENOMEM ; - goto err_free_mem; - } + ts =devm_kzalloc (&spi->dev,sizeof (*ts),GFP_KERNEL ); + input_dev =devm_input_allocate_device (&spi->dev); +if (!ts || !input_dev) +return -ENOMEM ; ts->spi = spi; ts->idev = input_dev;
@@ -649,12 +647,13 @@ static int tsc2005_probe(struct spi_device *spi)/* Ensure the touchscreen is off */ tsc2005_stop_scan (ts); - error =request_threaded_irq (spi->irq,NULL , tsc2005_irq_thread, -IRQF_TRIGGER_RISING |IRQF_ONESHOT , -"tsc2005" , ts); + error =devm_request_threaded_irq (&spi->dev, spi->irq,NULL , + tsc2005_irq_thread, +IRQF_TRIGGER_RISING |IRQF_ONESHOT , +"tsc2005" , ts);if (error) {dev_err (&spi->dev,"Failed to request irq, err: %d\n" , error); - goto err_free_mem; +return error; }spi_set_drvdata (spi, ts);
@@ -662,7 +661,7 @@ static int tsc2005_probe(struct spi_device *spi)if (error) {dev_err (&spi->dev,"Failed to create sysfs attributes, err: %d\n" , error); - goto err_clear_drvdata; +return error; } error =input_register_device (ts->idev);
@@ -677,11 +676,6 @@ static int tsc2005_probe(struct spi_device *spi) err_remove_sysfs:sysfs_remove_group (&spi->dev.kobj, &tsc2005_attr_group); -err_clear_drvdata: -free_irq (spi->irq, ts); -err_free_mem: -input_free_device (input_dev); -kfree (ts);return error; }
@@ -691,10 +685,6 @@ static int tsc2005_remove(struct spi_device *spi)sysfs_remove_group (&ts->spi->dev.kobj, &tsc2005_attr_group); -free_irq (ts->spi->irq, ts); -input_unregister_device (ts->idev); -kfree (ts); -return 0 ; }
Signature · 1 line
1.9.2
Re: [PATCHv3 3/5] Input: tsc2005: convert driver to use devm_*
Quoted 4 lines · Sebastian Reichel
Simplify the driver by using managed resources for memory allocation of internal struct, input device allocation and irq request.
Signed-off-by Sebastian Reichel <[email protected]>
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [PATCHv3 3/5] Input: tsc2005: convert driver to use devm_*
In reply to Sebastian ReichelQuoted 4 lines · Sebastian Reichel
Simplify the driver by using managed resources for memory allocation of internal struct, input device allocation and irq request.
Signed-off-by Sebastian Reichel <[email protected]>
Applied, thank you.
Quoted 78 lines
--- drivers/input/touchscreen/tsc2005.c | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-)drivers/input/touchscreen/tsc2005.c +10
-20@@ -604,12 +604,10 @@ static int tsc2005_probe(struct spi_device *spi)if (error)return error; - ts =kzalloc (sizeof (*ts),GFP_KERNEL ); - input_dev =input_allocate_device (); -if (!ts || !input_dev) { - error = -ENOMEM ; - goto err_free_mem; - } + ts =devm_kzalloc (&spi->dev,sizeof (*ts),GFP_KERNEL ); + input_dev =devm_input_allocate_device (&spi->dev); +if (!ts || !input_dev) +return -ENOMEM ; ts->spi = spi; ts->idev = input_dev;@@ -649,12 +647,13 @@ static int tsc2005_probe(struct spi_device *spi)/* Ensure the touchscreen is off */ tsc2005_stop_scan (ts); - error =request_threaded_irq (spi->irq,NULL , tsc2005_irq_thread, -IRQF_TRIGGER_RISING |IRQF_ONESHOT , -"tsc2005" , ts); + error =devm_request_threaded_irq (&spi->dev, spi->irq,NULL , + tsc2005_irq_thread, +IRQF_TRIGGER_RISING |IRQF_ONESHOT , +"tsc2005" , ts);if (error) {dev_err (&spi->dev,"Failed to request irq, err: %d\n" , error); - goto err_free_mem; +return error; }spi_set_drvdata (spi, ts);@@ -662,7 +661,7 @@ static int tsc2005_probe(struct spi_device *spi)if (error) {dev_err (&spi->dev,"Failed to create sysfs attributes, err: %d\n" , error); - goto err_clear_drvdata; +return error; } error =input_register_device (ts->idev);@@ -677,11 +676,6 @@ static int tsc2005_probe(struct spi_device *spi) err_remove_sysfs:sysfs_remove_group (&spi->dev.kobj, &tsc2005_attr_group); -err_clear_drvdata: -free_irq (spi->irq, ts); -err_free_mem: -input_free_device (input_dev); -kfree (ts);return error; }@@ -691,10 +685,6 @@ static int tsc2005_remove(struct spi_device *spi)sysfs_remove_group (&ts->spi->dev.kobj, &tsc2005_attr_group); -free_irq (ts->spi->irq, ts); -input_unregister_device (ts->idev); -kfree (ts); -return 0 ; }Signature · 1 line
1.9.2
Signature · 1 line
Dmitry
PATCH v3 4/5 Input: tsc2005: add DT support
In reply to Sebastian ReichelThis adds DT support to the tsc2005 touchscreen
driver.
--- drivers/input/touchscreen/tsc2005.c | 96 +++++++++++++++++++++++++++++-------- 1 file changed, 77 insertions(+), 19 deletions(-)
drivers/input/touchscreen/tsc2005.c +77 -19
@@ -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,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 +646,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-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; + } + }else { + ts->reset_gpio =-1 ; + ts->set_reset = pdata->set_reset; + }mutex_init (&ts->mutex);
@@ -639,6 +694,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) +input_parse_touchscreen_of_params (input_dev); + input_dev->open = tsc2005_open; input_dev->close = tsc2005_close;
Signature · 1 line
1.9.2
Re: [PATCHv3 4/5] Input: tsc2005: add DT support
Quoted 6 lines · Sebastian Reichel
This adds DT support to the tsc2005 touchscreen
driver.Signed-off-by Sebastian Reichel <[email protected]>
drivers/input/touchscreen/tsc2005.c line 109
Quoted 8 lines
drivers/input/touchscreen/tsc2005.c +4
-0@@ -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
IMO using defines insteaed of plain numbers does not help readability much, but ....
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
PATCH v3 5/5 Documentation: dt: Document TSC2005 DT binding
In reply to Sebastian ReichelAdd devicetree binding documentation for TSC2005 touchscreen.
--- .../bindings/input/touchscreen/tsc2005.txt | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 Documentation/devicetree/bindings/input/touchscreen/tsc2005.txt
Documentation/devicetree/bindings/input/touchscreen/tsc2005.txt new file +39 -0
@@ -0,0 +1,39 @@ +* 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 + +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>; + + reset-gpios = <&gpio4 8 GPIO_ACTIVE_HIGH>; /* 104 */ + interrupts-extended = <&gpio4 4 IRQ_TYPE_NONE>; /* 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
1.9.2
Re: [PATCHv3 5/5] Documentation: dt: Document TSC2005 DT binding
Quoted 2 lines · Sebastian Reichel
Add devicetree binding documentation for TSC2005 touchscreen.
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Quoted 8 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.16?) and the driver can be simplified once that has happened.
Ping. It would be nice to see this patchset in 3.16, since its the last important hardware component missing for N900 DT boot.
-- Sebastian
Aaro Koskinen
Acked-byHi,
Quoted 5 lines · Sebastian Reichel
Quoted 4 lines · Sebastian Reichel
This adds device tree support for the tsc2005 touchscreen controller, which is currently only used by the Nokia N900 board.
Quoted 7 lines
Quoted 4 lines
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.16?) and the driver can be simplified once that has happened.
Ping. It would be nice to see this patchset in 3.16, since its the last important hardware component missing for N900 DT boot.
FWIW, for all these patches feel free to add:
Thanks for great work,
A.