* [PATCH] input: keyboard: Add devicetree support for lm8333
@ 2016-10-27 19:17 Gordan Markus
[not found] ` <1477595854-9059-1-git-send-email-gordan.markus-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
0 siblings, 1 reply; 4+ messages in thread
From: Gordan Markus @ 2016-10-27 19:17 UTC (permalink / raw)
To: devicetree-u79uwXL29TY76Z2rM5mHXA; +Cc: Gordan Markuš
This adds LM8333 devicetree parsing for the keypad part.
Optional properties to specify the keypad driver active
time and debounce time.
Signed-off-by: Gordan Markuš <gordan.markus-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
.../devicetree/bindings/input/ti,lm8333.txt | 45 ++++++++++++++++++
drivers/input/keyboard/lm8333.c | 54 ++++++++++++++++++++++
2 files changed, 99 insertions(+)
create mode 100644 Documentation/devicetree/bindings/input/ti,lm8333.txt
diff --git a/Documentation/devicetree/bindings/input/ti,lm8333.txt b/Documentation/devicetree/bindings/input/ti,lm8333.txt
new file mode 100644
index 0000000..4100d48
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/ti,lm8333.txt
@@ -0,0 +1,45 @@
+LM8333 Keypad
+
+Required properties:
+- compatible: Compatible property value should be "ti,lm8333".
+
+- reg: Physical base address of the peripheral and length of memory mapped
+ region.
+
+- interrupts: The interrupt number for the peripheral.
+
+- linux,keymap: The keymap to use
+ (see Documentation/devicetree/bindings/input/matrix-keymap.txt)
+
+Optional properties:
+- ti,active-time: Specify the time during which the keypad is scanned after
+ the last key is released, before entering Halt mode.
+ The active time must be longer than the debounce time.
+ Default 500 ms.
+
+- ti,debounce-time: Specify the keypad debounce time.
+ This can be used for reliable scanning of keyboards with noisy contacts.
+ Default 10 ms.
+
+Example:
+input {
+ compatible = "ti,lm8333";
+ reg = <0x51>;
+ interrupts = <5>;
+
+ ti,active-time = <750>;
+ ti,debounce-time = <20>;
+
+ linux,keymap = <
+ 0x0001001e
+ 0x00020030
+ 0x0003002e
+ 0x00040020
+ 0x00050012
+ 0x00060021
+ 0x00070022
+ 0x00080023
+ 0x01010017
+ 0x01020024
+ 0x01030025>;
+};
diff --git a/drivers/input/keyboard/lm8333.c b/drivers/input/keyboard/lm8333.c
index c717e8f..adb7d64 100644
--- a/drivers/input/keyboard/lm8333.c
+++ b/drivers/input/keyboard/lm8333.c
@@ -128,6 +128,51 @@ static irqreturn_t lm8333_irq_thread(int irq, void *data)
return IRQ_HANDLED;
}
+static struct lm8333_platform_data *lm8333_parse_dt(struct i2c_client *client)
+{
+ struct device_node *np = client->dev.of_node;
+ struct lm8333_platform_data *pdata;
+ struct matrix_keymap_data *matrix_data;
+ u32 *keymap;
+ u32 prop;
+ int len;
+
+ pdata = devm_kzalloc(&client->dev, sizeof(pdata),
+ GFP_KERNEL);
+ if (!pdata)
+ return ERR_PTR(-ENOMEM);
+
+ if (!of_property_read_u32(np, "ti,active-time", &prop))
+ pdata->active_time = prop;
+
+ if (!of_property_read_u32(np, "ti,debounce-time", &prop))
+ pdata->debounce_time = prop;
+ else
+ pdata->debounce_time = 10;
+
+ if (!of_get_property(np, "linux,keymap", &prop))
+ len = prop / sizeof(u32);
+ else {
+ dev_err(&client->dev, "no keymap data defined\n");
+ return ERR_PTR(-EINVAL);
+ }
+
+ keymap = devm_kzalloc(&client->dev, sizeof(len) * len, GFP_KERNEL);
+ matrix_data = devm_kzalloc(&client->dev, sizeof(matrix_data),
+ GFP_KERNEL);
+ if (!matrix_data || !keymap)
+ return ERR_PTR(-ENOMEM);
+
+ if (!of_property_read_u32_array(np, "linux,keymap", keymap, len)) {
+ matrix_data->keymap_size = len;
+ matrix_data->keymap = keymap;
+
+ pdata->matrix_data = matrix_data;
+ }
+
+ return pdata;
+}
+
static int lm8333_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
@@ -137,6 +182,15 @@ static int lm8333_probe(struct i2c_client *client,
struct input_dev *input;
int err, active_time;
+ if (!pdata && client->dev.of_node) {
+ pdata = lm8333_parse_dt(client);
+ if (IS_ERR(pdata)) {
+ dev_err(&client->dev,
+ "could not parse configuration\n");
+ return IS_ERR(pdata);
+ }
+ }
+
if (!pdata)
return -EINVAL;
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] input: keyboard: Add devicetree support for lm8333
[not found] ` <1477595854-9059-1-git-send-email-gordan.markus-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2016-10-31 5:32 ` Rob Herring
2016-10-31 20:37 ` Gordan Markuš
0 siblings, 1 reply; 4+ messages in thread
From: Rob Herring @ 2016-10-31 5:32 UTC (permalink / raw)
To: Gordan Markus; +Cc: devicetree-u79uwXL29TY76Z2rM5mHXA
On Thu, Oct 27, 2016 at 09:17:34PM +0200, Gordan Markus wrote:
> This adds LM8333 devicetree parsing for the keypad part.
> Optional properties to specify the keypad driver active
> time and debounce time.
>
> Signed-off-by: Gordan Markuš <gordan.markus-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> ---
> .../devicetree/bindings/input/ti,lm8333.txt | 45 ++++++++++++++++++
It is preferred that bindings be a separate patch.
> drivers/input/keyboard/lm8333.c | 54 ++++++++++++++++++++++
> 2 files changed, 99 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/input/ti,lm8333.txt
>
> diff --git a/Documentation/devicetree/bindings/input/ti,lm8333.txt b/Documentation/devicetree/bindings/input/ti,lm8333.txt
> new file mode 100644
> index 0000000..4100d48
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/input/ti,lm8333.txt
> @@ -0,0 +1,45 @@
> +LM8333 Keypad
> +
> +Required properties:
> +- compatible: Compatible property value should be "ti,lm8333".
> +
> +- reg: Physical base address of the peripheral and length of memory mapped
> + region.
> +
> +- interrupts: The interrupt number for the peripheral.
> +
> +- linux,keymap: The keymap to use
> + (see Documentation/devicetree/bindings/input/matrix-keymap.txt)
> +
> +Optional properties:
> +- ti,active-time: Specify the time during which the keypad is scanned after
> + the last key is released, before entering Halt mode.
> + The active time must be longer than the debounce time.
> + Default 500 ms.
Add a unit suffix.
> +
> +- ti,debounce-time: Specify the keypad debounce time.
> + This can be used for reliable scanning of keyboards with noisy contacts.
> + Default 10 ms.
Don't we have a common property for this?
> +
> +Example:
> +input {
> + compatible = "ti,lm8333";
> + reg = <0x51>;
> + interrupts = <5>;
> +
> + ti,active-time = <750>;
> + ti,debounce-time = <20>;
> +
> + linux,keymap = <
> + 0x0001001e
> + 0x00020030
> + 0x0003002e
> + 0x00040020
> + 0x00050012
> + 0x00060021
> + 0x00070022
> + 0x00080023
> + 0x01010017
> + 0x01020024
> + 0x01030025>;
> +};
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] input: keyboard: Add devicetree support for lm8333
2016-10-31 5:32 ` Rob Herring
@ 2016-10-31 20:37 ` Gordan Markuš
2016-10-31 21:33 ` Rob Herring
0 siblings, 1 reply; 4+ messages in thread
From: Gordan Markuš @ 2016-10-31 20:37 UTC (permalink / raw)
To: devicetree-u79uwXL29TY76Z2rM5mHXA; +Cc: Rob Herring
On Mon, 2016-10-31 at 00:32 -0500, Rob Herring wrote:
> On Thu, Oct 27, 2016 at 09:17:34PM +0200, Gordan Markus wrote:
> > This adds LM8333 devicetree parsing for the keypad part.
> > Optional properties to specify the keypad driver active
> > time and debounce time.
> >
> > Signed-off-by: Gordan Markuš <gordan.markus-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> > ---
> > .../devicetree/bindings/input/ti,lm8333.txt | 45 ++++++++++++++++++
>
> It is preferred that bindings be a separate patch.
Thanks Rob.
Just to be clear, should I create a new thread with two patches?
>
> > drivers/input/keyboard/lm8333.c | 54 ++++++++++++++++++++++
> > 2 files changed, 99 insertions(+)
> > create mode 100644 Documentation/devicetree/bindings/input/ti,lm8333.txt
> >
> > diff --git a/Documentation/devicetree/bindings/input/ti,lm8333.txt b/Documentation/devicetree/bindings/input/ti,lm8333.txt
> > new file mode 100644
> > index 0000000..4100d48
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/input/ti,lm8333.txt
> > @@ -0,0 +1,45 @@
> > +LM8333 Keypad
> > +
> > +Required properties:
> > +- compatible: Compatible property value should be "ti,lm8333".
> > +
> > +- reg: Physical base address of the peripheral and length of memory mapped
> > + region.
> > +
> > +- interrupts: The interrupt number for the peripheral.
> > +
> > +- linux,keymap: The keymap to use
> > + (see Documentation/devicetree/bindings/input/matrix-keymap.txt)
> > +
> > +Optional properties:
> > +- ti,active-time: Specify the time during which the keypad is scanned after
> > + the last key is released, before entering Halt mode.
> > + The active time must be longer than the debounce time.
> > + Default 500 ms.
>
> Add a unit suffix.
The property will be renamed to "ti,active-time-ms".
>
> > +
> > +- ti,debounce-time: Specify the keypad debounce time.
> > + This can be used for reliable scanning of keyboards with noisy contacts.
> > + Default 10 ms.
>
> Don't we have a common property for this?
There isn't a common property, as far as I can tell.
Different devices have different debounce time properties.
Furthermore, the property should have a unit sufix as well, i.e.
it should be renamed to "ti,debounce-time-ms", right?
Gordan
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] input: keyboard: Add devicetree support for lm8333
2016-10-31 20:37 ` Gordan Markuš
@ 2016-10-31 21:33 ` Rob Herring
0 siblings, 0 replies; 4+ messages in thread
From: Rob Herring @ 2016-10-31 21:33 UTC (permalink / raw)
To: Gordan Markuš; +Cc: devicetree-u79uwXL29TY76Z2rM5mHXA
On Mon, Oct 31, 2016 at 3:37 PM, Gordan Markuš <gordan.markus-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> On Mon, 2016-10-31 at 00:32 -0500, Rob Herring wrote:
>> On Thu, Oct 27, 2016 at 09:17:34PM +0200, Gordan Markus wrote:
>> > This adds LM8333 devicetree parsing for the keypad part.
>> > Optional properties to specify the keypad driver active
>> > time and debounce time.
>> >
>> > Signed-off-by: Gordan Markuš <gordan.markus-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>> > ---
>> > .../devicetree/bindings/input/ti,lm8333.txt | 45 ++++++++++++++++++
>>
>> It is preferred that bindings be a separate patch.
>
> Thanks Rob.
> Just to be clear, should I create a new thread with two patches?
Considering changes are needed, yes.
>> > drivers/input/keyboard/lm8333.c | 54 ++++++++++++++++++++++
>> > 2 files changed, 99 insertions(+)
>> > create mode 100644 Documentation/devicetree/bindings/input/ti,lm8333.txt
>> >
>> > diff --git a/Documentation/devicetree/bindings/input/ti,lm8333.txt b/Documentation/devicetree/bindings/input/ti,lm8333.txt
>> > new file mode 100644
>> > index 0000000..4100d48
>> > --- /dev/null
>> > +++ b/Documentation/devicetree/bindings/input/ti,lm8333.txt
>> > @@ -0,0 +1,45 @@
>> > +LM8333 Keypad
>> > +
>> > +Required properties:
>> > +- compatible: Compatible property value should be "ti,lm8333".
>> > +
>> > +- reg: Physical base address of the peripheral and length of memory mapped
>> > + region.
>> > +
>> > +- interrupts: The interrupt number for the peripheral.
>> > +
>> > +- linux,keymap: The keymap to use
>> > + (see Documentation/devicetree/bindings/input/matrix-keymap.txt)
>> > +
>> > +Optional properties:
>> > +- ti,active-time: Specify the time during which the keypad is scanned after
>> > + the last key is released, before entering Halt mode.
>> > + The active time must be longer than the debounce time.
>> > + Default 500 ms.
>>
>> Add a unit suffix.
>
> The property will be renamed to "ti,active-time-ms".
>
>>
>> > +
>> > +- ti,debounce-time: Specify the keypad debounce time.
>> > + This can be used for reliable scanning of keyboards with noisy contacts.
>> > + Default 10 ms.
>>
>> Don't we have a common property for this?
>
> There isn't a common property, as far as I can tell.
> Different devices have different debounce time properties.
Looks like we have 2 at least: debounce-interval and
debounce-delay-ms. I'd go with the latter as it has units.
And there's lots of other variations. Don't add yet another one.
$ git grep debounce Documentation/devicetree/bindings/input/
Documentation/devicetree/bindings/input/ads7846.txt:
ti,debounce-max Max number of additional readings per
Documentation/devicetree/bindings/input/ads7846.txt:
ti,debounce-tol Tolerance used for filtering (u16).
Documentation/devicetree/bindings/input/ads7846.txt:
ti,debounce-rep Additional consecutive good readings
Documentation/devicetree/bindings/input/ads7846.txt:
ti,pendown-gpio-debounce Platform specific debounce time for
the
Documentation/devicetree/bindings/input/brcm,bcm-keypad.txt:-
col-debounce-filter-period: The debounce period for the Column filter.
Documentation/devicetree/bindings/input/brcm,bcm-keypad.txt:-
status-debounce-filter-period: The debounce period for the Status
filter.
Documentation/devicetree/bindings/input/brcm,bcm-keypad.txt:
col-debounce-filter-period = <5>;
Documentation/devicetree/bindings/input/gpio-keys-polled.txt: -
debounce-interval: Debouncing interval time in milliseconds.
Documentation/devicetree/bindings/input/gpio-keys.txt: -
debounce-interval: Debouncing interval time in milliseconds.
Documentation/devicetree/bindings/input/gpio-matrix-keypad.txt:-
debounce-delay-ms: debounce interval in milliseconds
Documentation/devicetree/bindings/input/gpio-matrix-keypad.txt:
debounce-delay-ms = <5>;
Documentation/devicetree/bindings/input/lpc32xx-key.txt:-
nxp,debounce-delay-ms: Debounce delay in ms
Documentation/devicetree/bindings/input/lpc32xx-key.txt:
nxp,debounce-delay-ms = <3>;
Documentation/devicetree/bindings/input/nvidia,tegra20-kbc.txt:-
nvidia,debounce-delay-ms: delay in milliseconds per row scan for
debouncing
Documentation/devicetree/bindings/input/nvidia,tegra20-kbc.txt:
nvidia,debounce-delay-ms = <640>;
Documentation/devicetree/bindings/input/pxa27x-keypad.txt:-
marvell,debounce-interval : How long time the key will be
Documentation/devicetree/bindings/input/pxa27x-keypad.txt: is
debounce interval for direct key and bit[15:0] is debounce
Documentation/devicetree/bindings/input/pxa27x-keypad.txt:
marvell,debounce-interval = <0x001e001e>;
Documentation/devicetree/bindings/input/qcom,pm8941-pwrkey.txt:- debounce:
Documentation/devicetree/bindings/input/qcom,pm8941-pwrkey.txt:
debounce = <15625>;
Documentation/devicetree/bindings/input/qcom,pm8xxx-keypad.txt:- debounce:
Documentation/devicetree/bindings/input/qcom,pm8xxx-keypad.txt:
debounce = <15>;
Documentation/devicetree/bindings/input/qcom,pm8xxx-pwrkey.txt:- debounce:
Documentation/devicetree/bindings/input/qcom,pm8xxx-pwrkey.txt:
debounce = <15625>;
Documentation/devicetree/bindings/input/st-keyscan.txt:-
st,debounce_us: Debouncing interval time in microseconds
Documentation/devicetree/bindings/input/st-keyscan.txt: st,debounce_us = <5000>;
Documentation/devicetree/bindings/input/stmpe-keypad.txt: -
debounce-interval : Debouncing interval time in milliseconds
Documentation/devicetree/bindings/input/stmpe-keypad.txt:
debounce-interval = <64>;
Documentation/devicetree/bindings/input/ti,palmas-pwrbutton.txt:-
ti,palmas-pwron-debounce-milli-seconds: Duration in milliseconds
Documentation/devicetree/bindings/input/ti,palmas-pwrbutton.txt:
ti,palmas-pwron-debounce-milli-seconds = <15>;
Documentation/devicetree/bindings/input/touchscreen/brcm,iproc-touchscreen.txt:-
debounce_timeout: Each step is 512 us. Valid 0-255
Documentation/devicetree/bindings/input/touchscreen/brcm,iproc-touchscreen.txt:
debounce_timeout = <40>;
Documentation/devicetree/bindings/input/touchscreen/fsl-mx25-tcq.txt:
- fsl,pen-debounce-ns: Pen debounce time in nanoseconds.
Rob
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-10-31 21:33 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-27 19:17 [PATCH] input: keyboard: Add devicetree support for lm8333 Gordan Markus
[not found] ` <1477595854-9059-1-git-send-email-gordan.markus-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-10-31 5:32 ` Rob Herring
2016-10-31 20:37 ` Gordan Markuš
2016-10-31 21:33 ` Rob Herring
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.