* [PATCH v2 1/3] Input: imx_keypad - Add device tree support
@ 2013-01-01 3:21 Liu Ying
2013-01-01 3:21 ` [PATCH v2 2/3] ARM: dts: imx: Add imx51 KPP entry Liu Ying
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Liu Ying @ 2013-01-01 3:21 UTC (permalink / raw)
To: grant.likely, rob.herring, rob, linux, dmitry.torokhov, shawn.guo,
s.hauer, linus.walleij, cjb, broonie
Cc: linux-arm-kernel, linux-input, linux-doc, liu.y.victor, Liu Ying
This patch adds device tree support for imx keypad driver.
Signed-off-by: Liu Ying <Ying.Liu@freescale.com>
---
Changes since v1:
- Parse the array keypad->keycodes[] to get row and column
mask value instead of parsing DT-supplied data again.
- Remove the pinctrl related code which sets row and column
key pins.
- Leave matrix_keypad_build_keymap() to determine platform
data and DT-supplied data precedence.
- Change DT compatible string from 'fsl,imx-kpp' to 'fsl,
<soc>-kpp'.
---
.../devicetree/bindings/input/imx-keypad.txt | 53 ++++++++++++++++++
drivers/input/keyboard/imx_keypad.c | 59 ++++++++++++++------
2 files changed, 94 insertions(+), 18 deletions(-)
create mode 100644 Documentation/devicetree/bindings/input/imx-keypad.txt
diff --git a/Documentation/devicetree/bindings/input/imx-keypad.txt b/Documentation/devicetree/bindings/input/imx-keypad.txt
new file mode 100644
index 0000000..2ebaf7d
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/imx-keypad.txt
@@ -0,0 +1,53 @@
+* Freescale i.MX Keypad Port(KPP) device tree bindings
+
+The KPP is designed to interface with a keypad matrix with 2-point contact
+or 3-point contact keys. The KPP is designed to simplify the software task
+of scanning a keypad matrix. The KPP is capable of detecting, debouncing,
+and decoding one or multiple keys pressed simultaneously on a keypad.
+
+Required SoC Specific Properties:
+- compatible: Should be "fsl,<soc>-kpp".
+
+- reg: Physical base address of the KPP and length of memory mapped
+ region.
+
+- interrupts: The KPP interrupt number to the CPU(s).
+
+- clocks: The clock provided by the SoC to the KPP. Some SoCs use dummy
+clock(The clock for the KPP is provided by the SoCs automatically).
+
+Required Board Specific Properties:
+- pinctrl-names: The definition can be found at
+pinctrl/pinctrl-bindings.txt.
+
+- pinctrl-0: The definition can be found at
+pinctrl/pinctrl-bindings.txt.
+
+- linux,keymap: The definition can be found at
+bindings/input/matrix-keymap.txt.
+
+Example:
+kpp: kpp@73f94000 {
+ compatible = "fsl,imx51-kpp", "fsl,imx21-kpp";
+ reg = <0x73f94000 0x4000>;
+ interrupts = <60>;
+ clocks = <&clks 0>;
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_kpp_1>;
+ linux,keymap = <0x00000067 /* KEY_UP */
+ 0x0001006c /* KEY_DOWN */
+ 0x00020072 /* KEY_VOLUMEDOWN */
+ 0x00030066 /* KEY_HOME */
+ 0x0100006a /* KEY_RIGHT */
+ 0x01010069 /* KEY_LEFT */
+ 0x0102001c /* KEY_ENTER */
+ 0x01030073 /* KEY_VOLUMEUP */
+ 0x02000040 /* KEY_F6 */
+ 0x02010042 /* KEY_F8 */
+ 0x02020043 /* KEY_F9 */
+ 0x02030044 /* KEY_F10 */
+ 0x0300003b /* KEY_F1 */
+ 0x0301003c /* KEY_F2 */
+ 0x0302003d /* KEY_F3 */
+ 0x03030074>; /* KEY_POWER */
+};
diff --git a/drivers/input/keyboard/imx_keypad.c b/drivers/input/keyboard/imx_keypad.c
index 6d150e3..16eaba8 100644
--- a/drivers/input/keyboard/imx_keypad.c
+++ b/drivers/input/keyboard/imx_keypad.c
@@ -20,6 +20,7 @@
#include <linux/jiffies.h>
#include <linux/kernel.h>
#include <linux/module.h>
+#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/slab.h>
#include <linux/timer.h>
@@ -414,15 +415,38 @@ open_err:
return -EIO;
}
+static struct of_device_id imx_keypad_of_match[] = {
+ { .compatible = "fsl,imx21-kpp", },
+ { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, imx_keypad_of_match);
+
+#ifdef CONFIG_OF
+static inline int imx_keypad_check_dt(struct platform_device *pdev)
+{
+ struct device_node *np = pdev->dev.of_node;
+
+ if (!np)
+ return -ENODEV;
+
+ return 0;
+}
+#else
+static inline int imx_keypad_check_dt(struct platform_device *pdev)
+{
+ return -ENODEV;
+}
+#endif
+
static int imx_keypad_probe(struct platform_device *pdev)
{
const struct matrix_keymap_data *keymap_data = pdev->dev.platform_data;
struct imx_keypad *keypad;
struct input_dev *input_dev;
struct resource *res;
- int irq, error, i;
+ int irq, error, i, row, col, row_shift;
- if (keymap_data == NULL) {
+ if (keymap_data == NULL && imx_keypad_check_dt(pdev)) {
dev_err(&pdev->dev, "no keymap defined\n");
return -EINVAL;
}
@@ -480,22 +504,6 @@ static int imx_keypad_probe(struct platform_device *pdev)
goto failed_unmap;
}
- /* Search for rows and cols enabled */
- for (i = 0; i < keymap_data->keymap_size; i++) {
- keypad->rows_en_mask |= 1 << KEY_ROW(keymap_data->keymap[i]);
- keypad->cols_en_mask |= 1 << KEY_COL(keymap_data->keymap[i]);
- }
-
- if (keypad->rows_en_mask > ((1 << MAX_MATRIX_KEY_ROWS) - 1) ||
- keypad->cols_en_mask > ((1 << MAX_MATRIX_KEY_COLS) - 1)) {
- dev_err(&pdev->dev,
- "invalid key data (too many rows or colums)\n");
- error = -EINVAL;
- goto failed_clock_put;
- }
- dev_dbg(&pdev->dev, "enabled rows mask: %x\n", keypad->rows_en_mask);
- dev_dbg(&pdev->dev, "enabled cols mask: %x\n", keypad->cols_en_mask);
-
/* Init the Input device */
input_dev->name = pdev->name;
input_dev->id.bustype = BUS_HOST;
@@ -512,6 +520,20 @@ static int imx_keypad_probe(struct platform_device *pdev)
goto failed_clock_put;
}
+ /* Search for rows and cols enabled */
+ row_shift = get_count_order(MAX_MATRIX_KEY_COLS);
+ for (row = 0; row < MAX_MATRIX_KEY_ROWS; row++) {
+ for (col = 0; col < MAX_MATRIX_KEY_COLS; col++) {
+ i = (row << row_shift) + col;
+ if (keypad->keycodes[i]) {
+ keypad->rows_en_mask |= 1 << row;
+ keypad->cols_en_mask |= 1 << col;
+ }
+ }
+ }
+ dev_dbg(&pdev->dev, "enabled rows mask: %x\n", keypad->rows_en_mask);
+ dev_dbg(&pdev->dev, "enabled cols mask: %x\n", keypad->cols_en_mask);
+
__set_bit(EV_REP, input_dev->evbit);
input_set_capability(input_dev, EV_MSC, MSC_SCAN);
input_set_drvdata(input_dev, keypad);
@@ -631,6 +653,7 @@ static struct platform_driver imx_keypad_driver = {
.name = "imx-keypad",
.owner = THIS_MODULE,
.pm = &imx_kbd_pm_ops,
+ .of_match_table = of_match_ptr(imx_keypad_of_match),
},
.probe = imx_keypad_probe,
.remove = imx_keypad_remove,
--
1.7.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v2 2/3] ARM: dts: imx: Add imx51 KPP entry
2013-01-01 3:21 [PATCH v2 1/3] Input: imx_keypad - Add device tree support Liu Ying
@ 2013-01-01 3:21 ` Liu Ying
2013-01-03 7:14 ` Shawn Guo
2013-01-01 3:21 ` [PATCH v2 3/3] ARM i.MX51 babbage: Add keypad support Liu Ying
2013-01-03 7:11 ` [PATCH v2 1/3] Input: imx_keypad - Add device tree support Shawn Guo
2 siblings, 1 reply; 6+ messages in thread
From: Liu Ying @ 2013-01-01 3:21 UTC (permalink / raw)
To: grant.likely, rob.herring, rob, linux, dmitry.torokhov, shawn.guo,
s.hauer, linus.walleij, cjb, broonie
Cc: linux-arm-kernel, linux-input, linux-doc, liu.y.victor, Liu Ying
1) Add KPP device node entry.
2) Add one KPP pinctrl entry.
Signed-off-by: Liu Ying <Ying.Liu@freescale.com>
---
arch/arm/boot/dts/imx51.dtsi | 23 +++++++++++++++++++++++
1 files changed, 23 insertions(+), 0 deletions(-)
diff --git a/arch/arm/boot/dts/imx51.dtsi b/arch/arm/boot/dts/imx51.dtsi
index 1f5d45e..6bda4dc 100644
--- a/arch/arm/boot/dts/imx51.dtsi
+++ b/arch/arm/boot/dts/imx51.dtsi
@@ -221,6 +221,14 @@
#interrupt-cells = <2>;
};
+ kpp: kpp@73f94000 {
+ compatible = "fsl,imx51-kpp", "fsl,imx21-kpp";
+ reg = <0x73f94000 0x4000>;
+ interrupts = <60>;
+ clocks = <&clks 0>;
+ status = "disabled";
+ };
+
wdog1: wdog@73f98000 {
compatible = "fsl,imx51-wdt", "fsl,imx21-wdt";
reg = <0x73f98000 0x4000>;
@@ -410,6 +418,21 @@
>;
};
};
+
+ kpp {
+ pinctrl_kpp_1: kppgrp-1 {
+ fsl,pins = <
+ 438 0xe0 /* MX51_PAD_KEY_ROW0__KEY_ROW0 */
+ 439 0xe0 /* MX51_PAD_KEY_ROW1__KEY_ROW1 */
+ 440 0xe0 /* MX51_PAD_KEY_ROW2__KEY_ROW2 */
+ 441 0xe0 /* MX51_PAD_KEY_ROW3__KEY_ROW3 */
+ 442 0xe8 /* MX51_PAD_KEY_COL0__KEY_COL0 */
+ 444 0xe8 /* MX51_PAD_KEY_COL1__KEY_COL1 */
+ 446 0xe8 /* MX51_PAD_KEY_COL2__KEY_COL2 */
+ 448 0xe8 /* MX51_PAD_KEY_COL3__KEY_COL3 */
+ >;
+ };
+ };
};
pwm1: pwm@73fb4000 {
--
1.7.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v2 3/3] ARM i.MX51 babbage: Add keypad support
2013-01-01 3:21 [PATCH v2 1/3] Input: imx_keypad - Add device tree support Liu Ying
2013-01-01 3:21 ` [PATCH v2 2/3] ARM: dts: imx: Add imx51 KPP entry Liu Ying
@ 2013-01-01 3:21 ` Liu Ying
2013-01-03 7:11 ` [PATCH v2 1/3] Input: imx_keypad - Add device tree support Shawn Guo
2 siblings, 0 replies; 6+ messages in thread
From: Liu Ying @ 2013-01-01 3:21 UTC (permalink / raw)
To: grant.likely, rob.herring, rob, linux, dmitry.torokhov, shawn.guo,
s.hauer, linus.walleij, cjb, broonie
Cc: linux-arm-kernel, linux-input, linux-doc, liu.y.victor, Liu Ying
The keypad is on the accessory board of i.MX51 babbage
main board and is driven by Keypad Port(KPP) in SoC.
The keymap is the same to i.MX25 3stack platform as
the accessory board schematic tells that it is designed
in this way.
Signed-off-by: Liu Ying <Ying.Liu@freescale.com>
---
arch/arm/boot/dts/imx51-babbage.dts | 22 ++++++++++++++++++++++
1 files changed, 22 insertions(+), 0 deletions(-)
diff --git a/arch/arm/boot/dts/imx51-babbage.dts b/arch/arm/boot/dts/imx51-babbage.dts
index 567e7ee..a9bb799 100644
--- a/arch/arm/boot/dts/imx51-babbage.dts
+++ b/arch/arm/boot/dts/imx51-babbage.dts
@@ -281,3 +281,25 @@
mux-ext-port = <3>;
};
};
+
+&kpp {
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_kpp_1>;
+ linux,keymap = <0x00000067 /* KEY_UP */
+ 0x0001006c /* KEY_DOWN */
+ 0x00020072 /* KEY_VOLUMEDOWN */
+ 0x00030066 /* KEY_HOME */
+ 0x0100006a /* KEY_RIGHT */
+ 0x01010069 /* KEY_LEFT */
+ 0x0102001c /* KEY_ENTER */
+ 0x01030073 /* KEY_VOLUMEUP */
+ 0x02000040 /* KEY_F6 */
+ 0x02010042 /* KEY_F8 */
+ 0x02020043 /* KEY_F9 */
+ 0x02030044 /* KEY_F10 */
+ 0x0300003b /* KEY_F1 */
+ 0x0301003c /* KEY_F2 */
+ 0x0302003d /* KEY_F3 */
+ 0x03030074>; /* KEY_POWER */
+ status = "okay";
+};
--
1.7.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2 1/3] Input: imx_keypad - Add device tree support
2013-01-01 3:21 [PATCH v2 1/3] Input: imx_keypad - Add device tree support Liu Ying
2013-01-01 3:21 ` [PATCH v2 2/3] ARM: dts: imx: Add imx51 KPP entry Liu Ying
2013-01-01 3:21 ` [PATCH v2 3/3] ARM i.MX51 babbage: Add keypad support Liu Ying
@ 2013-01-03 7:11 ` Shawn Guo
2013-01-03 13:06 ` Liu Ying
2 siblings, 1 reply; 6+ messages in thread
From: Shawn Guo @ 2013-01-03 7:11 UTC (permalink / raw)
To: Liu Ying
Cc: broonie, linux, linux-doc, liu.y.victor, s.hauer, dmitry.torokhov,
rob.herring, grant.likely, rob, linux-input, cjb, linus.walleij,
linux-arm-kernel
On Tue, Jan 01, 2013 at 11:21:13AM +0800, Liu Ying wrote:
> +#ifdef CONFIG_OF
> +static inline int imx_keypad_check_dt(struct platform_device *pdev)
> +{
> + struct device_node *np = pdev->dev.of_node;
> +
> + if (!np)
> + return -ENODEV;
> +
> + return 0;
> +}
> +#else
> +static inline int imx_keypad_check_dt(struct platform_device *pdev)
> +{
> + return -ENODEV;
> +}
> +#endif
> +
> static int imx_keypad_probe(struct platform_device *pdev)
> {
> const struct matrix_keymap_data *keymap_data = pdev->dev.platform_data;
> struct imx_keypad *keypad;
> struct input_dev *input_dev;
> struct resource *res;
> - int irq, error, i;
> + int irq, error, i, row, col, row_shift;
>
> - if (keymap_data == NULL) {
> + if (keymap_data == NULL && imx_keypad_check_dt(pdev)) {
Shouldn't the following just equally work?
if (keymap_data == NULL && pdev->dev.of_node == NULL) {
Shawn
> dev_err(&pdev->dev, "no keymap defined\n");
> return -EINVAL;
> }
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 2/3] ARM: dts: imx: Add imx51 KPP entry
2013-01-01 3:21 ` [PATCH v2 2/3] ARM: dts: imx: Add imx51 KPP entry Liu Ying
@ 2013-01-03 7:14 ` Shawn Guo
0 siblings, 0 replies; 6+ messages in thread
From: Shawn Guo @ 2013-01-03 7:14 UTC (permalink / raw)
To: Liu Ying
Cc: broonie, linux, linux-doc, liu.y.victor, s.hauer, dmitry.torokhov,
rob.herring, grant.likely, rob, linux-input, cjb, linus.walleij,
linux-arm-kernel
On Tue, Jan 01, 2013 at 11:21:14AM +0800, Liu Ying wrote:
> 1) Add KPP device node entry.
> 2) Add one KPP pinctrl entry.
>
> Signed-off-by: Liu Ying <Ying.Liu@freescale.com>
Patches #2 and #3 look good to me. Will apply them after Dmitry
applies the first one.
Shawn
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 1/3] Input: imx_keypad - Add device tree support
2013-01-03 7:11 ` [PATCH v2 1/3] Input: imx_keypad - Add device tree support Shawn Guo
@ 2013-01-03 13:06 ` Liu Ying
0 siblings, 0 replies; 6+ messages in thread
From: Liu Ying @ 2013-01-03 13:06 UTC (permalink / raw)
To: Shawn Guo
Cc: Liu Ying, grant.likely, rob.herring, rob, linux, dmitry.torokhov,
s.hauer, linus.walleij, cjb, broonie, linux-arm-kernel,
linux-input, linux-doc
2013/1/3 Shawn Guo <shawn.guo@linaro.org>:
> On Tue, Jan 01, 2013 at 11:21:13AM +0800, Liu Ying wrote:
>> +#ifdef CONFIG_OF
>> +static inline int imx_keypad_check_dt(struct platform_device *pdev)
>> +{
>> + struct device_node *np = pdev->dev.of_node;
>> +
>> + if (!np)
>> + return -ENODEV;
>> +
>> + return 0;
>> +}
>> +#else
>> +static inline int imx_keypad_check_dt(struct platform_device *pdev)
>> +{
>> + return -ENODEV;
>> +}
>> +#endif
>> +
>> static int imx_keypad_probe(struct platform_device *pdev)
>> {
>> const struct matrix_keymap_data *keymap_data = pdev->dev.platform_data;
>> struct imx_keypad *keypad;
>> struct input_dev *input_dev;
>> struct resource *res;
>> - int irq, error, i;
>> + int irq, error, i, row, col, row_shift;
>>
>> - if (keymap_data == NULL) {
>> + if (keymap_data == NULL && imx_keypad_check_dt(pdev)) {
>
> Shouldn't the following just equally work?
>
> if (keymap_data == NULL && pdev->dev.of_node == NULL) {
>
> Shawn
Yes, it looks better. I will do the change. Thanks.
>
>> dev_err(&pdev->dev, "no keymap defined\n");
>> return -EINVAL;
>> }
>
--
Liu Ying
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-01-03 13:06 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-01 3:21 [PATCH v2 1/3] Input: imx_keypad - Add device tree support Liu Ying
2013-01-01 3:21 ` [PATCH v2 2/3] ARM: dts: imx: Add imx51 KPP entry Liu Ying
2013-01-03 7:14 ` Shawn Guo
2013-01-01 3:21 ` [PATCH v2 3/3] ARM i.MX51 babbage: Add keypad support Liu Ying
2013-01-03 7:11 ` [PATCH v2 1/3] Input: imx_keypad - Add device tree support Shawn Guo
2013-01-03 13:06 ` Liu Ying
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).