* [PATCH v3 1/2] input: keyboard: Add devicetree support for lm8333 @ 2017-06-29 12:22 Gordan Markuš [not found] ` <20170629122220.12425-3-gordan.markus-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 0 siblings, 1 reply; 10+ messages in thread From: Gordan Markuš @ 2017-06-29 12:22 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> --- drivers/input/keyboard/lm8333.c | 54 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/drivers/input/keyboard/lm8333.c b/drivers/input/keyboard/lm8333.c index c717e8f..f1508c5 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-ms", &prop)) + pdata->active_time = prop; + + if (!of_property_read_u32(np, "debounce-delay-ms", &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; -- 2.9.3 -- 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] 10+ messages in thread
[parent not found: <20170629122220.12425-3-gordan.markus-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>]
* [PATCH v3 2/2] input: keyboard: Add lm8333 devicetree bindings [not found] ` <20170629122220.12425-3-gordan.markus-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> @ 2017-06-29 12:22 ` Gordan Markuš [not found] ` <20170629122220.12425-4-gordan.markus-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 0 siblings, 1 reply; 10+ messages in thread From: Gordan Markuš @ 2017-06-29 12:22 UTC (permalink / raw) To: devicetree-u79uwXL29TY76Z2rM5mHXA; +Cc: Gordan Markuš This adds LM8333 devicetree bindings documentation. Signed-off-by: Gordan Markuš <gordan.markus-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> --- .../devicetree/bindings/input/ti,lm8333.txt | 45 ++++++++++++++++++++++ 1 file changed, 45 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..dda01e2 --- /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-ms: 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. + +- debounce-delay-ms: 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-ms = <750>; + debounce-delay-ms = <20>; + + linux,keymap = < + 0x0001001e + 0x00020030 + 0x0003002e + 0x00040020 + 0x00050012 + 0x00060021 + 0x00070022 + 0x00080023 + 0x01010017 + 0x01020024 + 0x01030025>; +}; -- 2.9.3 -- 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] 10+ messages in thread
[parent not found: <20170629122220.12425-4-gordan.markus-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>]
* Re: [PATCH v3 2/2] input: keyboard: Add lm8333 devicetree bindings [not found] ` <20170629122220.12425-4-gordan.markus-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> @ 2017-07-06 16:09 ` Rob Herring 2017-07-07 7:22 ` [PATCH v4 1/2] input: keyboard: Add devicetree support for lm8333 Gordan Markuš 2017-07-07 7:22 ` [PATCH v4 2/2] input: keyboard: Add lm8333 devicetree bindings Gordan Markuš 0 siblings, 2 replies; 10+ messages in thread From: Rob Herring @ 2017-07-06 16:09 UTC (permalink / raw) To: Gordan Markuš; +Cc: devicetree-u79uwXL29TY76Z2rM5mHXA On Thu, Jun 29, 2017 at 02:22:20PM +0200, Gordan Markuš wrote: > This adds LM8333 devicetree bindings documentation. > > Signed-off-by: Gordan Markuš <gordan.markus-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > --- > .../devicetree/bindings/input/ti,lm8333.txt | 45 ++++++++++++++++++++++ > 1 file changed, 45 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..dda01e2 > --- /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. Isn't this I2C based? With that fixed, Acked-by: Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> -- 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] 10+ messages in thread
* [PATCH v4 1/2] input: keyboard: Add devicetree support for lm8333 2017-07-06 16:09 ` Rob Herring @ 2017-07-07 7:22 ` Gordan Markuš 2017-07-07 7:22 ` [PATCH v4 2/2] input: keyboard: Add lm8333 devicetree bindings Gordan Markuš 1 sibling, 0 replies; 10+ messages in thread From: Gordan Markuš @ 2017-07-07 7:22 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> --- drivers/input/keyboard/lm8333.c | 54 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/drivers/input/keyboard/lm8333.c b/drivers/input/keyboard/lm8333.c index c717e8f..f1508c5 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-ms", &prop)) + pdata->active_time = prop; + + if (!of_property_read_u32(np, "debounce-delay-ms", &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; -- 2.9.3 -- 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] 10+ messages in thread
* [PATCH v4 2/2] input: keyboard: Add lm8333 devicetree bindings 2017-07-06 16:09 ` Rob Herring 2017-07-07 7:22 ` [PATCH v4 1/2] input: keyboard: Add devicetree support for lm8333 Gordan Markuš @ 2017-07-07 7:22 ` Gordan Markuš [not found] ` <20170707072258.13881-4-gordan.markus-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 1 sibling, 1 reply; 10+ messages in thread From: Gordan Markuš @ 2017-07-07 7:22 UTC (permalink / raw) To: devicetree-u79uwXL29TY76Z2rM5mHXA; +Cc: Gordan Markuš This adds LM8333 devicetree bindings documentation. Signed-off-by: Gordan Markuš <gordan.markus-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> --- .../devicetree/bindings/input/ti,lm8333.txt | 45 ++++++++++++++++++++++ 1 file changed, 45 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..567f3ef --- /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: The I2C address of the device. + +- 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-ms: 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. + +- debounce-delay-ms: 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-ms = <750>; + debounce-delay-ms = <20>; + + linux,keymap = < + 0x0001001e + 0x00020030 + 0x0003002e + 0x00040020 + 0x00050012 + 0x00060021 + 0x00070022 + 0x00080023 + 0x01010017 + 0x01020024 + 0x01030025>; +}; -- 2.9.3 -- 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] 10+ messages in thread
[parent not found: <20170707072258.13881-4-gordan.markus-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>]
* Re: [PATCH v4 2/2] input: keyboard: Add lm8333 devicetree bindings [not found] ` <20170707072258.13881-4-gordan.markus-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> @ 2017-07-07 13:42 ` Rob Herring 2017-07-13 12:12 ` [PATCH v3 1/2] input: keyboard: Add devicetree support for lm8333 Gordan Markuš 2017-07-13 12:13 ` [PATCH v3 2/2] input: keyboard: Add lm8333 devicetree bindings Gordan Markuš 0 siblings, 2 replies; 10+ messages in thread From: Rob Herring @ 2017-07-07 13:42 UTC (permalink / raw) To: Gordan Markuš; +Cc: devicetree-u79uwXL29TY76Z2rM5mHXA On Fri, Jul 07, 2017 at 09:22:58AM +0200, Gordan Markuš wrote: > This adds LM8333 devicetree bindings documentation. > > Signed-off-by: Gordan Markuš <gordan.markus-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > --- > .../devicetree/bindings/input/ti,lm8333.txt | 45 ++++++++++++++++++++++ > 1 file changed, 45 insertions(+) > create mode 100644 Documentation/devicetree/bindings/input/ti,lm8333.txt I acked v3. Please add acks when posting new versions. 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] 10+ messages in thread
* [PATCH v3 1/2] input: keyboard: Add devicetree support for lm8333 2017-07-07 13:42 ` Rob Herring @ 2017-07-13 12:12 ` Gordan Markuš 2017-07-13 12:13 ` [PATCH v3 2/2] input: keyboard: Add lm8333 devicetree bindings Gordan Markuš 1 sibling, 0 replies; 10+ messages in thread From: Gordan Markuš @ 2017-07-13 12:12 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> --- drivers/input/keyboard/lm8333.c | 54 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/drivers/input/keyboard/lm8333.c b/drivers/input/keyboard/lm8333.c index c717e8f..f1508c5 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-ms", &prop)) + pdata->active_time = prop; + + if (!of_property_read_u32(np, "debounce-delay-ms", &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; -- 2.9.3 -- 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] 10+ messages in thread
* [PATCH v3 2/2] input: keyboard: Add lm8333 devicetree bindings 2017-07-07 13:42 ` Rob Herring 2017-07-13 12:12 ` [PATCH v3 1/2] input: keyboard: Add devicetree support for lm8333 Gordan Markuš @ 2017-07-13 12:13 ` Gordan Markuš [not found] ` <20170713121300.29530-4-gordan.markus-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 1 sibling, 1 reply; 10+ messages in thread From: Gordan Markuš @ 2017-07-13 12:13 UTC (permalink / raw) To: devicetree-u79uwXL29TY76Z2rM5mHXA; +Cc: Gordan Markuš This adds LM8333 devicetree bindings documentation. Signed-off-by: Gordan Markuš <gordan.markus-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> --- .../devicetree/bindings/input/ti,lm8333.txt | 45 ++++++++++++++++++++++ 1 file changed, 45 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..567f3ef --- /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: The I2C address of the device. + +- 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-ms: 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. + +- debounce-delay-ms: 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-ms = <750>; + debounce-delay-ms = <20>; + + linux,keymap = < + 0x0001001e + 0x00020030 + 0x0003002e + 0x00040020 + 0x00050012 + 0x00060021 + 0x00070022 + 0x00080023 + 0x01010017 + 0x01020024 + 0x01030025>; +}; -- 2.9.3 -- 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] 10+ messages in thread
[parent not found: <20170713121300.29530-4-gordan.markus-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>]
* Re: [PATCH v3 2/2] input: keyboard: Add lm8333 devicetree bindings [not found] ` <20170713121300.29530-4-gordan.markus-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> @ 2017-07-14 14:38 ` Rob Herring 0 siblings, 0 replies; 10+ messages in thread From: Rob Herring @ 2017-07-14 14:38 UTC (permalink / raw) To: Gordan Markuš; +Cc: devicetree-u79uwXL29TY76Z2rM5mHXA On Thu, Jul 13, 2017 at 02:13:00PM +0200, Gordan Markuš wrote: > This adds LM8333 devicetree bindings documentation. > > Signed-off-by: Gordan Markuš <gordan.markus-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > --- > .../devicetree/bindings/input/ti,lm8333.txt | 45 ++++++++++++++++++++++ > 1 file changed, 45 insertions(+) > create mode 100644 Documentation/devicetree/bindings/input/ti,lm8333.txt This is the 2nd v3 you posted and I acked v4... 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] 10+ messages in thread
* [PATCH v3] 1/2] input: keyboard: Add devicetree support for lm8333 @ 2017-06-29 8:18 Gordan Markuš 0 siblings, 0 replies; 10+ messages in thread From: Gordan Markuš @ 2017-06-29 8:18 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> --- drivers/input/keyboard/lm8333.c | 54 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/drivers/input/keyboard/lm8333.c b/drivers/input/keyboard/lm8333.c index c717e8f..f1508c5 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-ms", &prop)) + pdata->active_time = prop; + + if (!of_property_read_u32(np, "debounce-delay-ms", &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; -- 2.9.3 -- 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] 10+ messages in thread
end of thread, other threads:[~2017-07-14 14:38 UTC | newest] Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2017-06-29 12:22 [PATCH v3 1/2] input: keyboard: Add devicetree support for lm8333 Gordan Markuš [not found] ` <20170629122220.12425-3-gordan.markus-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 2017-06-29 12:22 ` [PATCH v3 2/2] input: keyboard: Add lm8333 devicetree bindings Gordan Markuš [not found] ` <20170629122220.12425-4-gordan.markus-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 2017-07-06 16:09 ` Rob Herring 2017-07-07 7:22 ` [PATCH v4 1/2] input: keyboard: Add devicetree support for lm8333 Gordan Markuš 2017-07-07 7:22 ` [PATCH v4 2/2] input: keyboard: Add lm8333 devicetree bindings Gordan Markuš [not found] ` <20170707072258.13881-4-gordan.markus-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 2017-07-07 13:42 ` Rob Herring 2017-07-13 12:12 ` [PATCH v3 1/2] input: keyboard: Add devicetree support for lm8333 Gordan Markuš 2017-07-13 12:13 ` [PATCH v3 2/2] input: keyboard: Add lm8333 devicetree bindings Gordan Markuš [not found] ` <20170713121300.29530-4-gordan.markus-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 2017-07-14 14:38 ` Rob Herring -- strict thread matches above, loose matches on Subject: below -- 2017-06-29 8:18 [PATCH v3] 1/2] input: keyboard: Add devicetree support for lm8333 Gordan Markuš
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.