* [PATCHv3 0/2] twl4030-keypad DT binding
@ 2013-11-08 22:14 Sebastian Reichel
2013-11-08 22:14 ` [PATCHv3 1/2] Input: twl4030-keypad - add device tree support Sebastian Reichel
` (2 more replies)
0 siblings, 3 replies; 15+ messages in thread
From: Sebastian Reichel @ 2013-11-08 22:14 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-doc,
linux-kernel, Sebastian Reichel
Hi,
Add device tree support for the twl4030 keypad, which is
for example used in the Nokia N900.
Changes since v2 [0]:
* Removed patches, which add twl4030-keypad node to
omap3 and nokia n900 dts files. I will send these to
Benoit once this patchset is queued.
* Split devicetree binding documentation into its own
patch.
* Fix typo in documentation
[0] https://lkml.org/lkml/2013/10/22/141
-- Sebastian
Sebastian Reichel (2):
Input: twl4030-keypad - add device tree support
dt: binding documentation for twl4030-keypad
.../devicetree/bindings/input/twl4030-keypad.txt | 31 ++++++++
drivers/input/keyboard/twl4030_keypad.c | 91 ++++++++++++++++++----
2 files changed, 105 insertions(+), 17 deletions(-)
create mode 100644 Documentation/devicetree/bindings/input/twl4030-keypad.txt
--
1.8.4.rc3
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCHv3 1/2] Input: twl4030-keypad - add device tree support
2013-11-08 22:14 [PATCHv3 0/2] twl4030-keypad DT binding Sebastian Reichel
@ 2013-11-08 22:14 ` Sebastian Reichel
2013-11-11 22:19 ` Pavel Machek
2013-11-08 22:14 ` [PATCHv3 2/2] dt: binding documentation for twl4030-keypad Sebastian Reichel
2013-11-30 16:53 ` [PATCHv4 0/2] twl4030-keypad DT binding Sebastian Reichel
2 siblings, 1 reply; 15+ messages in thread
From: Sebastian Reichel @ 2013-11-08 22:14 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-doc,
linux-kernel, Sebastian Reichel
Add device tree support for twl4030 keypad driver.
Tested on Nokia N900.
Signed-off-by: Sebastian Reichel <sre@debian.org>
---
drivers/input/keyboard/twl4030_keypad.c | 91 +++++++++++++++++++++++++++------
1 file changed, 74 insertions(+), 17 deletions(-)
diff --git a/drivers/input/keyboard/twl4030_keypad.c b/drivers/input/keyboard/twl4030_keypad.c
index d2d178c..034c312 100644
--- a/drivers/input/keyboard/twl4030_keypad.c
+++ b/drivers/input/keyboard/twl4030_keypad.c
@@ -33,6 +33,7 @@
#include <linux/platform_device.h>
#include <linux/i2c/twl.h>
#include <linux/slab.h>
+#include <linux/of.h>
/*
* The TWL4030 family chips include a keypad controller that supports
@@ -60,6 +61,7 @@
struct twl4030_keypad {
unsigned short keymap[TWL4030_KEYMAP_SIZE];
u16 kp_state[TWL4030_MAX_ROWS];
+ bool no_autorepeat;
unsigned n_rows;
unsigned n_cols;
unsigned irq;
@@ -324,6 +326,31 @@ static int twl4030_kp_program(struct twl4030_keypad *kp)
return 0;
}
+#if IS_ENABLED(CONFIG_OF)
+static int twl4030_keypad_parse_dt(struct device *dev,
+ struct twl4030_keypad *keypad_data)
+{
+ struct device_node *np = dev->of_node;
+ int err;
+
+ err = matrix_keypad_parse_of_params(dev, &keypad_data->n_rows,
+ &keypad_data->n_cols);
+ if (err)
+ return err;
+
+ if (of_get_property(np, "linux,input-no-autorepeat", NULL))
+ keypad_data->no_autorepeat = true;
+
+ return 0;
+}
+#else
+static inline int twl4030_keypad_parse_dt(struct device *dev,
+ struct twl4030_keypad *keypad_data)
+{
+ return -ENOSYS;
+}
+#endif
+
/*
* Registers keypad device with input subsystem
* and configures TWL4030 keypad registers
@@ -331,20 +358,12 @@ static int twl4030_kp_program(struct twl4030_keypad *kp)
static int twl4030_kp_probe(struct platform_device *pdev)
{
struct twl4030_keypad_data *pdata = pdev->dev.platform_data;
- const struct matrix_keymap_data *keymap_data;
+ const struct matrix_keymap_data *keymap_data = NULL;
struct twl4030_keypad *kp;
struct input_dev *input;
u8 reg;
int error;
- if (!pdata || !pdata->rows || !pdata->cols || !pdata->keymap_data ||
- pdata->rows > TWL4030_MAX_ROWS || pdata->cols > TWL4030_MAX_COLS) {
- dev_err(&pdev->dev, "Invalid platform_data\n");
- return -EINVAL;
- }
-
- keymap_data = pdata->keymap_data;
-
kp = kzalloc(sizeof(*kp), GFP_KERNEL);
input = input_allocate_device();
if (!kp || !input) {
@@ -352,13 +371,9 @@ static int twl4030_kp_probe(struct platform_device *pdev)
goto err1;
}
- /* Get the debug Device */
- kp->dbg_dev = &pdev->dev;
- kp->input = input;
-
- kp->n_rows = pdata->rows;
- kp->n_cols = pdata->cols;
- kp->irq = platform_get_irq(pdev, 0);
+ /* get the debug device */
+ kp->dbg_dev = &pdev->dev;
+ kp->input = input;
/* setup input device */
input->name = "TWL4030 Keypad";
@@ -370,6 +385,36 @@ static int twl4030_kp_probe(struct platform_device *pdev)
input->id.product = 0x0001;
input->id.version = 0x0003;
+ if (pdata) {
+ if (!pdata->rows || !pdata->cols || !pdata->keymap_data) {
+ dev_err(&pdev->dev, "Missing platform_data\n");
+ error = -EINVAL;
+ goto err1;
+ }
+
+ kp->n_rows = pdata->rows;
+ kp->n_cols = pdata->cols;
+ kp->no_autorepeat = !pdata->rep;
+ keymap_data = pdata->keymap_data;
+ } else {
+ error = twl4030_keypad_parse_dt(&pdev->dev, kp);
+ if (error)
+ goto err1;
+ }
+
+ if (kp->n_rows > TWL4030_MAX_ROWS || kp->n_cols > TWL4030_MAX_COLS) {
+ dev_err(&pdev->dev, "Invalid rows/cols amount specified in platform/devicetree data\n");
+ error = -EINVAL;
+ goto err1;
+ }
+
+ kp->irq = platform_get_irq(pdev, 0);
+ if (!kp->irq) {
+ dev_err(&pdev->dev, "no keyboard irq assigned\n");
+ error = -EINVAL;
+ goto err1;
+ }
+
error = matrix_keypad_build_keymap(keymap_data, NULL,
TWL4030_MAX_ROWS,
1 << TWL4030_ROW_SHIFT,
@@ -381,7 +426,7 @@ static int twl4030_kp_probe(struct platform_device *pdev)
input_set_capability(input, EV_MSC, MSC_SCAN);
/* Enable auto repeat feature of Linux input subsystem */
- if (pdata->rep)
+ if (!kp->no_autorepeat)
__set_bit(EV_REP, input->evbit);
error = input_register_device(input);
@@ -443,6 +488,17 @@ static int twl4030_kp_remove(struct platform_device *pdev)
return 0;
}
+#if IS_ENABLED(CONFIG_OF)
+static const struct of_device_id twl4030_keypad_dt_match_table[] = {
+ { .compatible = "ti,twl4030-keypad" },
+ {},
+};
+MODULE_DEVICE_TABLE(of, twl4030_keypad_dt_match_table);
+#define twl4030_keypad_dt_match of_match_ptr(twl4030_keypad_dt_match_table)
+#else
+#define twl4030_keypad_dt_match NULL
+#endif
+
/*
* NOTE: twl4030 are multi-function devices connected via I2C.
* So this device is a child of an I2C parent, thus it needs to
@@ -455,6 +511,7 @@ static struct platform_driver twl4030_kp_driver = {
.driver = {
.name = "twl4030_keypad",
.owner = THIS_MODULE,
+ .of_match_table = twl4030_keypad_dt_match,
},
};
module_platform_driver(twl4030_kp_driver);
--
1.8.4.rc3
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCHv3 2/2] dt: binding documentation for twl4030-keypad
2013-11-08 22:14 [PATCHv3 0/2] twl4030-keypad DT binding Sebastian Reichel
2013-11-08 22:14 ` [PATCHv3 1/2] Input: twl4030-keypad - add device tree support Sebastian Reichel
@ 2013-11-08 22:14 ` Sebastian Reichel
2013-11-30 16:53 ` [PATCHv4 0/2] twl4030-keypad DT binding Sebastian Reichel
2 siblings, 0 replies; 15+ messages in thread
From: Sebastian Reichel @ 2013-11-08 22:14 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-doc,
linux-kernel, Sebastian Reichel
Add devicetree binding documentation for twl4030-keypad.
Signed-off-by: Sebastian Reichel <sre@debian.org>
---
.../devicetree/bindings/input/twl4030-keypad.txt | 31 ++++++++++++++++++++++
1 file changed, 31 insertions(+)
create mode 100644 Documentation/devicetree/bindings/input/twl4030-keypad.txt
diff --git a/Documentation/devicetree/bindings/input/twl4030-keypad.txt b/Documentation/devicetree/bindings/input/twl4030-keypad.txt
new file mode 100644
index 0000000..901d10f
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/twl4030-keypad.txt
@@ -0,0 +1,31 @@
+* TWL4030's Keypad Controller device tree bindings
+
+TWL4030's Keypad controller is used to interface a SoC with a matrix-type
+keypad device. The keypad controller supports multiple row and column lines.
+A key can be placed at each intersection of a unique row and a unique column.
+The keypad controller can sense a key-press and key-release and report the
+event using a interrupt to the cpu.
+
+This binding is based on the matrix-keymap binding with the following
+changes:
+
+ * keypad,num-rows and keypad,num-columns are required.
+
+Required SoC Specific Properties:
+- compatible: should be one of the following
+ - "ti,twl4030-keypad": For controllers compatible with twl4030 keypad
+ controller.
+- interrupt: should be one of the following
+ - <1>: For controllers compatible with twl4030 keypad controller.
+
+Optional Properties specific to linux:
+- linux,keypad-no-autorepeat: do not enable autorepeat feature.
+
+Example:
+ twl_keypad: keypad {
+ compatible = "ti,twl4030-keypad";
+ interrupts = <1>;
+ keypad,num-rows = <8>;
+ keypad,num-columns = <8>;
+ linux,keypad-no-autorepeat;
+ };
--
1.8.4.rc3
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCHv3 1/2] Input: twl4030-keypad - add device tree support
2013-11-08 22:14 ` [PATCHv3 1/2] Input: twl4030-keypad - add device tree support Sebastian Reichel
@ 2013-11-11 22:19 ` Pavel Machek
2013-11-12 3:25 ` Sebastian Reichel
0 siblings, 1 reply; 15+ messages in thread
From: Pavel Machek @ 2013-11-11 22:19 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-doc,
linux-kernel
Hi!
> + if (of_get_property(np, "linux,input-no-autorepeat", NULL))
> + keypad_data->no_autorepeat = true;
>From 2/2:
+Optional Properties specific to linux:
+- linux,keypad-no-autorepeat: do not enable autorepeat feature.
I'm confused now.
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCHv3 1/2] Input: twl4030-keypad - add device tree support
2013-11-11 22:19 ` Pavel Machek
@ 2013-11-12 3:25 ` Sebastian Reichel
2013-11-17 18:28 ` Pavel Machek
0 siblings, 1 reply; 15+ messages in thread
From: Sebastian Reichel @ 2013-11-12 3:25 UTC (permalink / raw)
To: Pavel Machek
Cc: Dmitry Torokhov, Dmitry Torokhov, linux-input, Rob Herring,
Pawel Moll, Mark Rutland, Stephen Warren, Ian Campbell,
Rob Landley, Grant Likely, devicetree, linux-doc, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1515 bytes --]
Hi,
On Mon, Nov 11, 2013 at 11:19:41PM +0100, Pavel Machek wrote:
> > + if (of_get_property(np, "linux,input-no-autorepeat", NULL))
> > + keypad_data->no_autorepeat = true;
>
> From 2/2:
>
> +Optional Properties specific to linux:
> +- linux,keypad-no-autorepeat: do not enable autorepeat feature.
>
> I'm confused now.
good catch! That happens when one tries to mimic other drivers :/
I just checked all DT input drivers for autorepeat keyword:
DRIVER CODE DOCUMENTATION
twl4030-keypad linux,input-no-autorepeat linux,keypad-no-autorepeat
omap4-keypad linux,input-no-autorepeat linux,keypad-no-autorepeat
samsung-keypad linux,input-no-autorepeat linux,keypad-no-autorepeat
stmpe-keypad st,no-autorepeat st,no-autorepeat
spear-keyboard autorepeat autorepeat
tca8418-keypad keypad,autorepeat --- not documented ---
gpio-matrix-keypad linux,no-autorepeat linux,no-autorepeat
gpio-keys-polled autorepeat autorepeat
gpio-keys autorepeat --- no documentation ---
Any suggestions how to continue fixing this mess? I guess first of
all the documentation of omap4-keypad, samsung-keypad and of course
the new twl4030-keypad driver should be fixed.
Next it would be nice to choose one standard property name for this
and use it for twl4030-keypad. I suggest to use "linux,input-no-autorepeat".
-- Sebastian
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCHv3 1/2] Input: twl4030-keypad - add device tree support
2013-11-12 3:25 ` Sebastian Reichel
@ 2013-11-17 18:28 ` Pavel Machek
2013-11-18 3:58 ` Dmitry Torokhov
0 siblings, 1 reply; 15+ messages in thread
From: Pavel Machek @ 2013-11-17 18:28 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-doc, linux-kernel
Hi!
> On Mon, Nov 11, 2013 at 11:19:41PM +0100, Pavel Machek wrote:
> > > + if (of_get_property(np, "linux,input-no-autorepeat", NULL))
> > > + keypad_data->no_autorepeat = true;
> >
> > From 2/2:
> >
> > +Optional Properties specific to linux:
> > +- linux,keypad-no-autorepeat: do not enable autorepeat feature.
> >
> > I'm confused now.
>
> good catch! That happens when one tries to mimic other drivers :/
>
> I just checked all DT input drivers for autorepeat keyword:
>
> DRIVER CODE DOCUMENTATION
> twl4030-keypad linux,input-no-autorepeat linux,keypad-no-autorepeat
> omap4-keypad linux,input-no-autorepeat linux,keypad-no-autorepeat
> samsung-keypad linux,input-no-autorepeat linux,keypad-no-autorepeat
> stmpe-keypad st,no-autorepeat st,no-autorepeat
> spear-keyboard autorepeat autorepeat
> tca8418-keypad keypad,autorepeat --- not documented ---
> gpio-matrix-keypad linux,no-autorepeat linux,no-autorepeat
> gpio-keys-polled autorepeat autorepeat
> gpio-keys autorepeat --- no documentation ---
>
> Any suggestions how to continue fixing this mess? I guess first of
> all the documentation of omap4-keypad, samsung-keypad and of course
> the new twl4030-keypad driver should be fixed.
>
> Next it would be nice to choose one standard property name for this
> and use it for twl4030-keypad. I suggest to use "linux,input-no-autorepeat".
I'd suggest just simple "autorepeat", so that we get rid of ugly double-negation.
But I guess this is not too important as long as it is consistent... And I'm not
even sure consistency is huge issue.
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCHv3 1/2] Input: twl4030-keypad - add device tree support
2013-11-17 18:28 ` Pavel Machek
@ 2013-11-18 3:58 ` Dmitry Torokhov
2013-11-19 12:50 ` Pavel Machek
0 siblings, 1 reply; 15+ messages in thread
From: Dmitry Torokhov @ 2013-11-18 3:58 UTC (permalink / raw)
To: Pavel Machek
Cc: linux-input, Rob Herring, Pawel Moll, Mark Rutland,
Stephen Warren, Ian Campbell, Rob Landley, Grant Likely,
devicetree, linux-doc, linux-kernel
On Sun, Nov 17, 2013 at 07:28:40PM +0100, Pavel Machek wrote:
> Hi!
>
> > On Mon, Nov 11, 2013 at 11:19:41PM +0100, Pavel Machek wrote:
> > > > + if (of_get_property(np, "linux,input-no-autorepeat", NULL))
> > > > + keypad_data->no_autorepeat = true;
> > >
> > > From 2/2:
> > >
> > > +Optional Properties specific to linux:
> > > +- linux,keypad-no-autorepeat: do not enable autorepeat feature.
> > >
> > > I'm confused now.
> >
> > good catch! That happens when one tries to mimic other drivers :/
> >
> > I just checked all DT input drivers for autorepeat keyword:
> >
> > DRIVER CODE DOCUMENTATION
> > twl4030-keypad linux,input-no-autorepeat linux,keypad-no-autorepeat
> > omap4-keypad linux,input-no-autorepeat linux,keypad-no-autorepeat
> > samsung-keypad linux,input-no-autorepeat linux,keypad-no-autorepeat
> > stmpe-keypad st,no-autorepeat st,no-autorepeat
> > spear-keyboard autorepeat autorepeat
> > tca8418-keypad keypad,autorepeat --- not documented ---
> > gpio-matrix-keypad linux,no-autorepeat linux,no-autorepeat
> > gpio-keys-polled autorepeat autorepeat
> > gpio-keys autorepeat --- no documentation ---
> >
> > Any suggestions how to continue fixing this mess? I guess first of
> > all the documentation of omap4-keypad, samsung-keypad and of course
> > the new twl4030-keypad driver should be fixed.
> >
> > Next it would be nice to choose one standard property name for this
> > and use it for twl4030-keypad. I suggest to use "linux,input-no-autorepeat".
>
> I'd suggest just simple "autorepeat", so that we get rid of ugly double-negation.
The idea was that majority of setups want autorepeat so in the absence
of the property autorepeat is turned on.
Thanks.
--
Dmitry
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCHv3 1/2] Input: twl4030-keypad - add device tree support
2013-11-18 3:58 ` Dmitry Torokhov
@ 2013-11-19 12:50 ` Pavel Machek
2013-11-24 17:17 ` Sebastian Reichel
0 siblings, 1 reply; 15+ messages in thread
From: Pavel Machek @ 2013-11-19 12:50 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: linux-input, Rob Herring, Pawel Moll, Mark Rutland,
Stephen Warren, Ian Campbell, Rob Landley, Grant Likely,
devicetree, linux-doc, linux-kernel
Hi!
> > > DRIVER CODE DOCUMENTATION
> > > twl4030-keypad linux,input-no-autorepeat linux,keypad-no-autorepeat
> > > omap4-keypad linux,input-no-autorepeat linux,keypad-no-autorepeat
> > > samsung-keypad linux,input-no-autorepeat linux,keypad-no-autorepeat
> > > stmpe-keypad st,no-autorepeat st,no-autorepeat
> > > spear-keyboard autorepeat autorepeat
> > > tca8418-keypad keypad,autorepeat --- not documented ---
> > > gpio-matrix-keypad linux,no-autorepeat linux,no-autorepeat
> > > gpio-keys-polled autorepeat autorepeat
> > > gpio-keys autorepeat --- no documentation ---
> > >
> > > Any suggestions how to continue fixing this mess? I guess first of
> > > all the documentation of omap4-keypad, samsung-keypad and of course
> > > the new twl4030-keypad driver should be fixed.
> > >
> > > Next it would be nice to choose one standard property name for this
> > > and use it for twl4030-keypad. I suggest to use "linux,input-no-autorepeat".
> >
> > I'd suggest just simple "autorepeat", so that we get rid of ugly double-negation.
> The idea was that majority of setups want autorepeat so in the absence
> of the property autorepeat is turned on.
I see... but autorepeat on by default makes sense on devices that are
usually querty keybaords, but does not make sense on devices that are
usually phone keypads or power buttons.
So my proposal is:
1) driver decides if it makes sense to autorepeat by default or not.
2) dts says autorepeat=0 or autorepeat=1
That way, we get dts that get chance to work on other OSes, get rid of
double negations, and get right defaults when autorepeat is not
specified.
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCHv3 1/2] Input: twl4030-keypad - add device tree support
2013-11-19 12:50 ` Pavel Machek
@ 2013-11-24 17:17 ` Sebastian Reichel
0 siblings, 0 replies; 15+ messages in thread
From: Sebastian Reichel @ 2013-11-24 17:17 UTC (permalink / raw)
To: Pavel Machek
Cc: Dmitry Torokhov, linux-input, Rob Herring, Pawel Moll,
Mark Rutland, Stephen Warren, Ian Campbell, Rob Landley,
Grant Likely, devicetree, linux-doc, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 774 bytes --]
Hi,
> > > I'd suggest just simple "autorepeat", so that we get rid of ugly double-negation.
> > The idea was that majority of setups want autorepeat so in the absence
> > of the property autorepeat is turned on.
>
> I see... but autorepeat on by default makes sense on devices that are
> usually querty keybaords, but does not make sense on devices that are
> usually phone keypads or power buttons.
>
> So my proposal is:
>
> 1) driver decides if it makes sense to autorepeat by default or not.
>
> 2) dts says autorepeat=0 or autorepeat=1
>
> That way, we get dts that get chance to work on other OSes, get rid of
> double negations, and get right defaults when autorepeat is not
> specified.
Sounds fine to me. Any objections?
-- Sebastian
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCHv4 0/2] twl4030-keypad DT binding
2013-11-08 22:14 [PATCHv3 0/2] twl4030-keypad DT binding Sebastian Reichel
2013-11-08 22:14 ` [PATCHv3 1/2] Input: twl4030-keypad - add device tree support Sebastian Reichel
2013-11-08 22:14 ` [PATCHv3 2/2] dt: binding documentation for twl4030-keypad Sebastian Reichel
@ 2013-11-30 16:53 ` Sebastian Reichel
2013-11-30 16:53 ` [PATCHv4 1/2] Input: twl4030-keypad - add device tree support Sebastian Reichel
` (2 more replies)
2 siblings, 3 replies; 15+ messages in thread
From: Sebastian Reichel @ 2013-11-30 16:53 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-doc,
linux-kernel, Sebastian Reichel
Hi,
Add device tree support for the twl4030 keypad, which is
for example used in the Nokia N900.
Changes since v3 [0]:
* Removed support for disabling autorepeat via DT. There
is still discussion going on, how the standard binding
should look like. On the other hand everyone agrees,
that autorepeat should be default for keypads.
* Remove useless twl4030_keypad_dt_match
[0] https://lkml.org/lkml/2013/11/8/463
-- Sebastian
Sebastian Reichel (2):
Input: twl4030-keypad - add device tree support
dt: binding documentation for twl4030-keypad
.../devicetree/bindings/input/twl4030-keypad.txt | 27 +++++++++
drivers/input/keyboard/twl4030_keypad.c | 65 ++++++++++++++++------
2 files changed, 75 insertions(+), 17 deletions(-)
create mode 100644 Documentation/devicetree/bindings/input/twl4030-keypad.txt
--
1.8.4.3
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCHv4 1/2] Input: twl4030-keypad - add device tree support
2013-11-30 16:53 ` [PATCHv4 0/2] twl4030-keypad DT binding Sebastian Reichel
@ 2013-11-30 16:53 ` Sebastian Reichel
2013-11-30 16:53 ` [PATCHv4 2/2] dt: binding documentation for twl4030-keypad Sebastian Reichel
2014-01-04 5:40 ` [PATCHv4 0/2] twl4030-keypad DT binding Sebastian Reichel
2 siblings, 0 replies; 15+ messages in thread
From: Sebastian Reichel @ 2013-11-30 16:53 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-doc,
linux-kernel, Sebastian Reichel
Add device tree support for twl4030 keypad driver.
Tested on Nokia N900.
Signed-off-by: Sebastian Reichel <sre@debian.org>
---
drivers/input/keyboard/twl4030_keypad.c | 65 ++++++++++++++++++++++++---------
1 file changed, 48 insertions(+), 17 deletions(-)
diff --git a/drivers/input/keyboard/twl4030_keypad.c b/drivers/input/keyboard/twl4030_keypad.c
index d2d178c..5d0cffb 100644
--- a/drivers/input/keyboard/twl4030_keypad.c
+++ b/drivers/input/keyboard/twl4030_keypad.c
@@ -33,6 +33,7 @@
#include <linux/platform_device.h>
#include <linux/i2c/twl.h>
#include <linux/slab.h>
+#include <linux/of.h>
/*
* The TWL4030 family chips include a keypad controller that supports
@@ -60,6 +61,7 @@
struct twl4030_keypad {
unsigned short keymap[TWL4030_KEYMAP_SIZE];
u16 kp_state[TWL4030_MAX_ROWS];
+ bool autorepeat;
unsigned n_rows;
unsigned n_cols;
unsigned irq;
@@ -331,20 +333,12 @@ static int twl4030_kp_program(struct twl4030_keypad *kp)
static int twl4030_kp_probe(struct platform_device *pdev)
{
struct twl4030_keypad_data *pdata = pdev->dev.platform_data;
- const struct matrix_keymap_data *keymap_data;
+ const struct matrix_keymap_data *keymap_data = NULL;
struct twl4030_keypad *kp;
struct input_dev *input;
u8 reg;
int error;
- if (!pdata || !pdata->rows || !pdata->cols || !pdata->keymap_data ||
- pdata->rows > TWL4030_MAX_ROWS || pdata->cols > TWL4030_MAX_COLS) {
- dev_err(&pdev->dev, "Invalid platform_data\n");
- return -EINVAL;
- }
-
- keymap_data = pdata->keymap_data;
-
kp = kzalloc(sizeof(*kp), GFP_KERNEL);
input = input_allocate_device();
if (!kp || !input) {
@@ -352,13 +346,9 @@ static int twl4030_kp_probe(struct platform_device *pdev)
goto err1;
}
- /* Get the debug Device */
- kp->dbg_dev = &pdev->dev;
- kp->input = input;
-
- kp->n_rows = pdata->rows;
- kp->n_cols = pdata->cols;
- kp->irq = platform_get_irq(pdev, 0);
+ /* get the debug device */
+ kp->dbg_dev = &pdev->dev;
+ kp->input = input;
/* setup input device */
input->name = "TWL4030 Keypad";
@@ -370,6 +360,38 @@ static int twl4030_kp_probe(struct platform_device *pdev)
input->id.product = 0x0001;
input->id.version = 0x0003;
+ if (pdata) {
+ if (!pdata->rows || !pdata->cols || !pdata->keymap_data) {
+ dev_err(&pdev->dev, "Missing platform_data\n");
+ error = -EINVAL;
+ goto err1;
+ }
+
+ kp->n_rows = pdata->rows;
+ kp->n_cols = pdata->cols;
+ kp->autorepeat = pdata->rep;
+ keymap_data = pdata->keymap_data;
+ } else {
+ error = matrix_keypad_parse_of_params(&pdev->dev, &kp->n_rows,
+ &kp->n_cols);
+ kp->autorepeat = true;
+ if (error)
+ goto err1;
+ }
+
+ if (kp->n_rows > TWL4030_MAX_ROWS || kp->n_cols > TWL4030_MAX_COLS) {
+ dev_err(&pdev->dev, "Invalid rows/cols amount specified in platform/devicetree data\n");
+ error = -EINVAL;
+ goto err1;
+ }
+
+ kp->irq = platform_get_irq(pdev, 0);
+ if (!kp->irq) {
+ dev_err(&pdev->dev, "no keyboard irq assigned\n");
+ error = -EINVAL;
+ goto err1;
+ }
+
error = matrix_keypad_build_keymap(keymap_data, NULL,
TWL4030_MAX_ROWS,
1 << TWL4030_ROW_SHIFT,
@@ -381,7 +403,7 @@ static int twl4030_kp_probe(struct platform_device *pdev)
input_set_capability(input, EV_MSC, MSC_SCAN);
/* Enable auto repeat feature of Linux input subsystem */
- if (pdata->rep)
+ if (kp->autorepeat)
__set_bit(EV_REP, input->evbit);
error = input_register_device(input);
@@ -443,6 +465,14 @@ static int twl4030_kp_remove(struct platform_device *pdev)
return 0;
}
+#if IS_ENABLED(CONFIG_OF)
+static const struct of_device_id twl4030_keypad_dt_match_table[] = {
+ { .compatible = "ti,twl4030-keypad" },
+ {},
+};
+MODULE_DEVICE_TABLE(of, twl4030_keypad_dt_match_table);
+#endif
+
/*
* NOTE: twl4030 are multi-function devices connected via I2C.
* So this device is a child of an I2C parent, thus it needs to
@@ -455,6 +485,7 @@ static struct platform_driver twl4030_kp_driver = {
.driver = {
.name = "twl4030_keypad",
.owner = THIS_MODULE,
+ .of_match_table = of_match_ptr(twl4030_keypad_dt_match_table),
},
};
module_platform_driver(twl4030_kp_driver);
--
1.8.4.3
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCHv4 2/2] dt: binding documentation for twl4030-keypad
2013-11-30 16:53 ` [PATCHv4 0/2] twl4030-keypad DT binding Sebastian Reichel
2013-11-30 16:53 ` [PATCHv4 1/2] Input: twl4030-keypad - add device tree support Sebastian Reichel
@ 2013-11-30 16:53 ` Sebastian Reichel
2014-01-04 5:40 ` [PATCHv4 0/2] twl4030-keypad DT binding Sebastian Reichel
2 siblings, 0 replies; 15+ messages in thread
From: Sebastian Reichel @ 2013-11-30 16:53 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-doc,
linux-kernel, Sebastian Reichel
Add devicetree binding documentation for twl4030-keypad.
Signed-off-by: Sebastian Reichel <sre@debian.org>
---
.../devicetree/bindings/input/twl4030-keypad.txt | 27 ++++++++++++++++++++++
1 file changed, 27 insertions(+)
create mode 100644 Documentation/devicetree/bindings/input/twl4030-keypad.txt
diff --git a/Documentation/devicetree/bindings/input/twl4030-keypad.txt b/Documentation/devicetree/bindings/input/twl4030-keypad.txt
new file mode 100644
index 0000000..e4be2f7
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/twl4030-keypad.txt
@@ -0,0 +1,27 @@
+* TWL4030's Keypad Controller device tree bindings
+
+TWL4030's Keypad controller is used to interface a SoC with a matrix-type
+keypad device. The keypad controller supports multiple row and column lines.
+A key can be placed at each intersection of a unique row and a unique column.
+The keypad controller can sense a key-press and key-release and report the
+event using a interrupt to the cpu.
+
+This binding is based on the matrix-keymap binding with the following
+changes:
+
+ * keypad,num-rows and keypad,num-columns are required.
+
+Required SoC Specific Properties:
+- compatible: should be one of the following
+ - "ti,twl4030-keypad": For controllers compatible with twl4030 keypad
+ controller.
+- interrupt: should be one of the following
+ - <1>: For controllers compatible with twl4030 keypad controller.
+
+Example:
+ twl_keypad: keypad {
+ compatible = "ti,twl4030-keypad";
+ interrupts = <1>;
+ keypad,num-rows = <8>;
+ keypad,num-columns = <8>;
+ };
--
1.8.4.3
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCHv4 0/2] twl4030-keypad DT binding
2013-11-30 16:53 ` [PATCHv4 0/2] twl4030-keypad DT binding Sebastian Reichel
2013-11-30 16:53 ` [PATCHv4 1/2] Input: twl4030-keypad - add device tree support Sebastian Reichel
2013-11-30 16:53 ` [PATCHv4 2/2] dt: binding documentation for twl4030-keypad Sebastian Reichel
@ 2014-01-04 5:40 ` Sebastian Reichel
2014-01-04 8:49 ` Dmitry Torokhov
2 siblings, 1 reply; 15+ messages in thread
From: Sebastian Reichel @ 2014-01-04 5:40 UTC (permalink / raw)
To: Dmitry Torokhov, Dmitry Torokhov, linux-input
Cc: Rob Herring, Pawel Moll, Mark Rutland, Stephen Warren,
Ian Campbell, Rob Landley, Grant Likely, devicetree, linux-doc,
linux-kernel
[-- Attachment #1: Type: text/plain, Size: 85 bytes --]
Dmitry,
What's the status of this patch? Can you queue this for 3.14?
-- Sebastian
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCHv4 0/2] twl4030-keypad DT binding
2014-01-04 5:40 ` [PATCHv4 0/2] twl4030-keypad DT binding Sebastian Reichel
@ 2014-01-04 8:49 ` Dmitry Torokhov
2014-01-05 3:50 ` Sebastian Reichel
0 siblings, 1 reply; 15+ messages in thread
From: Dmitry Torokhov @ 2014-01-04 8:49 UTC (permalink / raw)
To: linux-input, Rob Herring, Pawel Moll, Mark Rutland,
Stephen Warren, Ian Campbell, Rob Landley, Grant Likely,
devicetree, linux-doc, linux-kernel
Hi Sebastian,
On Sat, Jan 04, 2014 at 06:40:06AM +0100, Sebastian Reichel wrote:
> Dmitry,
>
> What's the status of this patch? Can you queue this for 3.14?
I just queued it.
Thanks.
--
Dmitry
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCHv4 0/2] twl4030-keypad DT binding
2014-01-04 8:49 ` Dmitry Torokhov
@ 2014-01-05 3:50 ` Sebastian Reichel
0 siblings, 0 replies; 15+ messages in thread
From: Sebastian Reichel @ 2014-01-05 3:50 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: linux-input, Rob Herring, Pawel Moll, Mark Rutland,
Stephen Warren, Ian Campbell, Rob Landley, Grant Likely,
devicetree, linux-doc, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 255 bytes --]
On Sat, Jan 04, 2014 at 12:49:01AM -0800, Dmitry Torokhov wrote:
> On Sat, Jan 04, 2014 at 06:40:06AM +0100, Sebastian Reichel wrote:
> > What's the status of this patch? Can you queue this for 3.14?
>
> I just queued it.
Thanks.
-- Sebastian
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2014-01-05 3:51 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-08 22:14 [PATCHv3 0/2] twl4030-keypad DT binding Sebastian Reichel
2013-11-08 22:14 ` [PATCHv3 1/2] Input: twl4030-keypad - add device tree support Sebastian Reichel
2013-11-11 22:19 ` Pavel Machek
2013-11-12 3:25 ` Sebastian Reichel
2013-11-17 18:28 ` Pavel Machek
2013-11-18 3:58 ` Dmitry Torokhov
2013-11-19 12:50 ` Pavel Machek
2013-11-24 17:17 ` Sebastian Reichel
2013-11-08 22:14 ` [PATCHv3 2/2] dt: binding documentation for twl4030-keypad Sebastian Reichel
2013-11-30 16:53 ` [PATCHv4 0/2] twl4030-keypad DT binding Sebastian Reichel
2013-11-30 16:53 ` [PATCHv4 1/2] Input: twl4030-keypad - add device tree support Sebastian Reichel
2013-11-30 16:53 ` [PATCHv4 2/2] dt: binding documentation for twl4030-keypad Sebastian Reichel
2014-01-04 5:40 ` [PATCHv4 0/2] twl4030-keypad DT binding Sebastian Reichel
2014-01-04 8:49 ` Dmitry Torokhov
2014-01-05 3:50 ` Sebastian Reichel
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).