Input: wm831x - Add driver for Wolfson WM831x PMIC touchscreen controllers
PATCH 1/1 Input: wm831x - Add driver for Wolfson WM831x PMIC touchscreen controllers
Some of the WM831x series of PMICs from Wolfson Microelectronics include a resistive touchscreen controller. Implement support for these controllers within the input API.
Platform data is supported to allow configuration of system parameters such as selection between four and five wire touchscreens and for specification of optional direct to CPU IRQs for sample availability and for pen down. Use of this feature for at least the data IRQ is strongly recommended.
Thanks to Julien Boibessot for extensive testing and detailed feedback.
--- drivers/input/touchscreen/Kconfig | 10 + drivers/input/touchscreen/Makefile | 1 + drivers/input/touchscreen/wm831x-ts.c | 370 +++++++++++++++++++++++++++++++++ include/linux/mfd/wm831x/pdata.h | 1 + 4 files changed, 382 insertions(+), 0 deletions(-) create mode 100644 drivers/input/touchscreen/wm831x-ts.c
drivers/input/touchscreen/Kconfig +10 -0
@@ -423,6 +423,16 @@ config TOUCHSCREEN_UCB1400 To compile this driver as a module, choose M here: the module will be called ucb1400_ts. +config TOUCHSCREEN_WM831X + tristate "Support for WM831x touchscreen controllers" + depends on MFD_WM831X + help + This enables support for the touchscreen controller on the WM831x + series of PMICs. + + To compile this driver as a module, choose M here: the + module will be called wm831x-ts. + config TOUCHSCREEN_WM97XX tristate "Support for WM97xx AC97 touchscreen controllers" depends on AC97_BUS
drivers/input/touchscreen/Makefile +1 -0
@@ -48,6 +48,7 @@ obj-$(CONFIG_TOUCHSCREEN_TOUCHWIN) += touchwin.o obj-$(CONFIG_TOUCHSCREEN_TSC2007) += tsc2007.o obj-$(CONFIG_TOUCHSCREEN_UCB1400) += ucb1400_ts.o obj-$(CONFIG_TOUCHSCREEN_WACOM_W8001) += wacom_w8001.o +obj-$(CONFIG_TOUCHSCREEN_WM831X) += wm831x-ts.o obj-$(CONFIG_TOUCHSCREEN_WM97XX) += wm97xx-ts.o wm97xx-ts-$(CONFIG_TOUCHSCREEN_WM9705) += wm9705.o wm97xx-ts-$(CONFIG_TOUCHSCREEN_WM9712) += wm9712.o
drivers/input/touchscreen/wm831x-ts.c new file +370 -0
370 lines not on this page · raw message
include/linux/mfd/wm831x/pdata.h +1 -0
@@ -81,6 +81,7 @@ struct wm831x_touch_pdata {int rpu;/** Pen down sensitivity resistor divider */ int pressure;/** Report pressure (boolean) */ int data_irq;/** Touch data ready IRQ */ +int pd_irq;/** Touch pendown detect IRQ */ };enum wm831x_watchdog_action {
Signature · 1 line
1.7.2.3
Dmitry Torokhov
maintainerHi Mark,
Quoted 9 lines · Mark Brown
Some of the WM831x series of PMICs from Wolfson Microelectronics include a resistive touchscreen controller. Implement support for these controllers within the input API.
Platform data is supported to allow configuration of system parameters such as selection between four and five wire touchscreens and for specification of optional direct to CPU IRQs for sample availability and for pen down. Use of this feature for at least the data IRQ is strongly recommended.
Quoted 4 lines
Thanks to Julien Boibessot for extensive testing and detailed feedback.
Signed-off-by Mark Brown <[email protected]>Tested-by Julien Boibessot <[email protected]>
Just a couple small concerns here:
drivers/input/touchscreen/wm831x-ts.c line 68
Quoted 6 lines
drivers/input/touchscreen/wm831x-ts.c new file +6
-0+ +struct wm831x_ts { +struct input_dev *input_dev; +struct wm831x *wm831x; +int data_irq; +int pd_irq;
Maybe make irqs unsigned?
drivers/input/touchscreen/wm831x-ts.c line 189
Quoted 13 lines
drivers/input/touchscreen/wm831x-ts.c new file +13
-0+ +static void wm831x_ts_input_close (struct input_dev *idev) +{ +struct wm831x_ts *wm831x_ts =input_get_drvdata (idev); +struct wm831x *wm831x = wm831x_ts->wm831x; + +wm831x_set_bits (wm831x,WM831X_TOUCH_CONTROL_1 , +WM831X_TCH_ENA |WM831X_TCH_CVT_ENA | +WM831X_TCH_X_ENA |WM831X_TCH_Y_ENA | +WM831X_TCH_Z_ENA ,0 ); + +if (wm831x_ts->pen_down) +disable_irq_nosync (wm831x_ts->data_irq);
Why nosync?
Quoted 14 lines
drivers/input/touchscreen/wm831x-ts.c new file +14
-0+ + ret =request_threaded_irq (wm831x_ts->data_irq,NULL , + wm831x_ts_data_irq, +IRQF_ONESHOT , +"Touchscreen data" , wm831x_ts); +if (ret <0 ) { +dev_err (&pdev->dev,"Failed to request data IRQ %d: %d\n" , + wm831x_ts->data_irq, ret); + goto err_alloc; + } +disable_irq (wm831x_ts->data_irq); + + ret = request_threaded_irq(wm831x_ts->pd_irq, NULL, + wm831x_ts_pen_down_irq, IRQF_ONESHOT,
drivers/input/touchscreen/wm831x-ts.c line 290
Quoted 10 lines
drivers/input/touchscreen/wm831x-ts.c new file +10
-0+ "Touchscreen pen down", wm831x_ts); +if (ret <0 ) { +dev_err (&pdev->dev,"Failed to request pen down IRQ %d: %d\n" , + wm831x_ts->pd_irq, ret); + goto err_data_irq; + } + +platform_set_drvdata (pdev, wm831x_ts); + + input_dev =input_allocate_device ();
Are we 100% sure it is impossible for the 2 irqs above to fire up before we get here? Like if we happen to have hardware in half-active state while binding?
I'd feel safer if we allocated input device earlier, together with the touchscreen structure.
Thanks.
Signature · 1 line
Dmitry
Quoted 6 lines · Dmitry Torokhov
drivers/input/touchscreen/wm831x-ts.c line 68
Quoted 2 lines · Mark Brown
drivers/input/touchscreen/wm831x-ts.c new file +2
-0+int data_irq; +int pd_irq;Maybe make irqs unsigned?
I guess.
Quoted 6 lines
Quoted 6 lines
drivers/input/touchscreen/wm831x-ts.c new file +6
-0+static void wm831x_ts_input_close (struct input_dev *idev) +{ +struct wm831x_ts *wm831x_ts =input_get_drvdata (idev); +struct wm831x *wm831x = wm831x_ts->wm831x; + + wm831x_set_bits(wm831x, WM831X_TOUCH_CONTROL_1,
Quoted 8 lines
drivers/input/touchscreen/wm831x-ts.c line 189
Quoted 6 lines
drivers/input/touchscreen/wm831x-ts.c new file +6
-0+WM831X_TCH_ENA |WM831X_TCH_CVT_ENA | +WM831X_TCH_X_ENA |WM831X_TCH_Y_ENA | + WM831X_TCH_Z_ENA, 0); + +if (wm831x_ts->pen_down) +disable_irq_nosync (wm831x_ts->data_irq);Why nosync?
Cut'n'paste from the pen up handling in the data IRQ (which obviously does need to be nosync due to the fact that it runs from IRQ context).
Quoted 5 lines
drivers/input/touchscreen/wm831x-ts.c line 290
Quoted 1 line
drivers/input/touchscreen/wm831x-ts.c new file +1
-0+ input_dev =input_allocate_device ();Are we 100% sure it is impossible for the 2 irqs above to fire up before we get here? Like if we happen to have hardware in half-active state while binding?
It's spectacularly unlikely - in the sort of hardware this device is useful for nothing below Linux would realistically want to talk to the touchscreen and since the IRQs are threaded they can't be shared.
Dmitry Torokhov
maintainerQuoted 34 lines · Mark Brown
Quoted 6 lines · Dmitry Torokhov
drivers/input/touchscreen/wm831x-ts.c line 68
Quoted 2 lines · Mark Brown
drivers/input/touchscreen/wm831x-ts.c new file +2
-0+int data_irq; +int pd_irq;Maybe make irqs unsigned?
I guess.
Quoted 6 lines
Quoted 6 lines
drivers/input/touchscreen/wm831x-ts.c new file +6
-0+static void wm831x_ts_input_close (struct input_dev *idev) +{ +struct wm831x_ts *wm831x_ts =input_get_drvdata (idev); +struct wm831x *wm831x = wm831x_ts->wm831x; + + wm831x_set_bits(wm831x, WM831X_TOUCH_CONTROL_1,Quoted 8 lines
drivers/input/touchscreen/wm831x-ts.c line 189
Quoted 6 lines
drivers/input/touchscreen/wm831x-ts.c new file +6
-0+WM831X_TCH_ENA |WM831X_TCH_CVT_ENA | +WM831X_TCH_X_ENA |WM831X_TCH_Y_ENA | + WM831X_TCH_Z_ENA, 0); + +if (wm831x_ts->pen_down) +disable_irq_nosync (wm831x_ts->data_irq);Why nosync?
Cut'n'paste from the pen up handling in the data IRQ (which obviously does need to be nosync due to the fact that it runs from IRQ context).
Quoted 5 lines
drivers/input/touchscreen/wm831x-ts.c line 290
Quoted 1 line
drivers/input/touchscreen/wm831x-ts.c new file +1
-0+ input_dev =input_allocate_device ();Are we 100% sure it is impossible for the 2 irqs above to fire up before we get here? Like if we happen to have hardware in half-active state while binding?
Quoted 3 lines
It's spectacularly unlikely - in the sort of hardware this device is useful for nothing below Linux would realistically want to talk to the touchscreen and since the IRQs are threaded they can't be shared.
Would you please move input allocation still - even if it works fine with your device the code might be used as an example by other authors... and there should be no penalties for your driver if you allocate just a tad earlier.
Thanks a lot!
Signature · 1 line
Dmitry
Dmitry Torokhov
maintainerQuoted 35 lines · Dmitry Torokhov
Quoted 34 lines · Mark Brown
Quoted 6 lines · Dmitry Torokhov
drivers/input/touchscreen/wm831x-ts.c line 68
Quoted 2 lines · Mark Brown
drivers/input/touchscreen/wm831x-ts.c new file +2
-0+int data_irq; +int pd_irq;Maybe make irqs unsigned?
I guess.
Quoted 6 lines
Quoted 6 lines
drivers/input/touchscreen/wm831x-ts.c new file +6
-0+static void wm831x_ts_input_close (struct input_dev *idev) +{ +struct wm831x_ts *wm831x_ts =input_get_drvdata (idev); +struct wm831x *wm831x = wm831x_ts->wm831x; + + wm831x_set_bits(wm831x, WM831X_TOUCH_CONTROL_1,Quoted 8 lines
drivers/input/touchscreen/wm831x-ts.c line 189
Quoted 6 lines
drivers/input/touchscreen/wm831x-ts.c new file +6
-0+WM831X_TCH_ENA |WM831X_TCH_CVT_ENA | +WM831X_TCH_X_ENA |WM831X_TCH_Y_ENA | + WM831X_TCH_Z_ENA, 0); + +if (wm831x_ts->pen_down) +disable_irq_nosync (wm831x_ts->data_irq);Why nosync?
Cut'n'paste from the pen up handling in the data IRQ (which obviously does need to be nosync due to the fact that it runs from IRQ context).
Quoted 5 lines
drivers/input/touchscreen/wm831x-ts.c line 290
Quoted 1 line
drivers/input/touchscreen/wm831x-ts.c new file +1
-0+ input_dev =input_allocate_device ();Are we 100% sure it is impossible for the 2 irqs above to fire up before we get here? Like if we happen to have hardware in half-active state while binding?
Quoted 9 lines
Quoted 3 lines
It's spectacularly unlikely - in the sort of hardware this device is useful for nothing below Linux would realistically want to talk to the touchscreen and since the IRQs are threaded they can't be shared.
Would you please move input allocation still - even if it works fine with your device the code might be used as an example by other authors... and there should be no penalties for your driver if you allocate just a tad earlier.
Ah, you did already. Thank you.
Signature · 1 line
Dmitry