Skip to contentSkip to conversation

input: keyboard: Add keys driver for the LPC32xx SoC

PATCH RESEND Superseded Roland Stigge 3 participants 4 messages Jun 11, 2012 – Jun 24, 2012

Subsystems (4)

v4 of 9 Superseded Latest is v9 →

lore
Share & tools
lore
#0 lore raw

PATCH RESEND v4 1/1 input: keyboard: Add keys driver for the LPC32xx SoC

This patch adds a driver for the key scan interface of the LPC32xx SoC

For the DT binding: Acked-by: Rob Herring <[email protected]>

---
Applies to v3.5-rc2

Changes since v3:
* Make driver DT-only since LPC32xx is converted to DT anyway now.
* Use MATRIX_SCAN_CODE()
* Use matrix_keypad_build_keymap()
* Emit MSC_SCAN also
* Use PTR_ERR() on error handling
* Rename return value to error
* Removed unnecessary '&' on initializations with function pointers
* Use CONFIG_PM_SLEEP, dev_pm_ops, SIMPLE_DEV_PM_OPS instead of CONFIG_PM
* Removed devm_*() management
* Re-enabled clock for period of probe()

Changes since v2:
* Fixed case of lpc32XX_* -> lpc32xx_*
* Removed unnecessary casts
* Removed unnecessary unlikely()
* Use unsigned for key bits
* Included Russell's lpc32xx_mod_states() algorithm change suggestion
* Replaced (res == NULL) with (!res)
* clk_enable() -> clk_prepare_enable()
* Moved clk_prepare_enable() and clk_disable_unprepare() to input's open()/close() callbacks to save power
* Handle clk_prepare_enable() return value appropriately
* DT: Use "keypad,num-rows", "keypad,num-columns" and "linux,keymap" properties

Changes since v1:
* Removed devm_kfree(), lpc32XX_free_dt(), iounmap(), release_mem_region()
* Changed __raw_writel()+__raw_readl() to writel()+readl()

Thanks to Axel Lin, Russell King, Rob Herring and Dmitry Torokhov for reviewing!

 Documentation/devicetree/bindings/input/lpc32xx-key.txt |   28 +
 drivers/input/keyboard/Kconfig                          |   10 
 drivers/input/keyboard/Makefile                         |    1 
 drivers/input/keyboard/lpc32xx-keys.c                   |  377 ++++++++++++++++
 4 files changed, 416 insertions(+)
Documentation/devicetree/bindings/input/lpc32xx-key.txt new file +28 -0
@@ -0,0 +1,28 @@
+NXP LPC32xx Key Scan Interface
+
+Required Properties:
+- compatible: Should be "nxp,lpc3220-key"
+- reg: Physical base address of the controller and length of memory mapped
+  region.
+- interrupts: The interrupt number to the cpu.
+- keypad,num-rows: Number of rows and columns, e.g. 1: 1x1, 6: 6x6
+- keypad,num-columns: Must be equal to keypad,num-rows since LPC32xx only
+  supports square matrices
+- nxp,debounce-delay-ms: Debounce delay in ms
+- nxp,scan-delay-ms: Repeated scan period in ms
+- linux,keymap: the key-code to be reported when the key is pressed
+  and released, see also
+  Documentation/devicetree/bindings/input/matrix-keymap.txt
+
+Example:
+
+	key at 40050000 {
+		compatible = "nxp,lpc3220-key";
+		reg = <0x40050000 0x1000>;
+		interrupts = <54 0>;
+		keypad,num-rows = <1>;
+		keypad,num-columns = <1>;
+		nxp,debounce-delay-ms = <3>;
+		nxp,scan-delay-ms = <34>;
+		linux,keymap = <0x00000002>;
+	};
drivers/input/keyboard/Kconfig +10 -0
@@ -332,6 +332,16 @@ config KEYBOARD_LOCOMO
 	  To compile this driver as a module, choose M here: the
 	  module will be called locomokbd.
 
+config KEYBOARD_LPC32XX
+	tristate "LPC32XX matrix key scanner support"
+	depends on ARCH_LPC32XX && OF
+	help
+	  Say Y here if you want to use NXP LPC32XX SoC key scanner interface,
+	  connected to a key matrix.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called lpc32xx-keys.
+
 config KEYBOARD_MAPLE
 	tristate "Maple bus keyboard"
 	depends on SH_DREAMCAST && MAPLE
drivers/input/keyboard/Makefile +1 -0
@@ -26,6 +26,7 @@ obj-$(CONFIG_KEYBOARD_LKKBD)		+= lkkbd.o
 obj-$(CONFIG_KEYBOARD_LM8323)		+= lm8323.o
 obj-$(CONFIG_KEYBOARD_LM8333)		+= lm8333.o
 obj-$(CONFIG_KEYBOARD_LOCOMO)		+= locomokbd.o
+obj-$(CONFIG_KEYBOARD_LPC32XX)		+= lpc32xx-keys.o
 obj-$(CONFIG_KEYBOARD_MAPLE)		+= maple_keyb.o
 obj-$(CONFIG_KEYBOARD_MATRIX)		+= matrix_keypad.o
 obj-$(CONFIG_KEYBOARD_MAX7359)		+= max7359_keypad.o
drivers/input/keyboard/lpc32xx-keys.c new file +377 -0

377 lines not on this page · raw message

#1 lore raw

drivers/input/keyboard/lpc32xx-keys.c line 82

Quoted 7 lines · Roland Stigge
drivers/input/keyboard/lpc32xx-keys.c new file +7 -0
+
+struct lpc32xx_kscan_drv {
+	struct input_dev *input;
+	struct lpc32xx_kscan_cfg *kscancfg;
+	struct clk *clk;
+	void __iomem *kscan_base;
+	int irq;

Do you really need this irq field? It is used in the probe and remove only.

Quoted 4 lines
drivers/input/keyboard/lpc32xx-keys.c new file +4 -0
+	u8 lastkeystates[8];
+	u32 io_p_start;
+	u32 io_p_size;
+};
maintainer
#2 lore raw
In reply to Roland Stigge
Quoted 4 lines · Roland Stigge

This patch adds a driver for the key scan interface of the LPC32xx SoC

For the DT binding: Acked-by: Rob Herring <[email protected]>

Not a real review, just a quick question - if th driver is DT-only now do we need to have the platform data or it would make more sense to read DT-bindings and fill the main device structure directly?

Thanks.

drivers/input/keyboard/lpc32xx-keys.c line 269

Quoted 4 lines
drivers/input/keyboard/lpc32xx-keys.c new file +4 -0
+
+	matrix_keypad_build_keymap(NULL, NULL, kscandat->kscancfg->matrix_sz,
+				   kscandat->kscancfg->matrix_sz,
+				   kscandat->kscancfg->keymap, kscandat->input);

This function may fail now.

Signature · 1 line
Dmitry
#3 lore raw
Quoted 9 lines · Dmitry Torokhov
Quoted 4 lines · Roland Stigge

This patch adds a driver for the key scan interface of the LPC32xx SoC

For the DT binding: Acked-by: Rob Herring <[email protected]>

Not a real review, just a quick question - if th driver is DT-only now do we need to have the platform data or it would make more sense to read DT-bindings and fill the main device structure directly?

And:

Quoted 6 lines

drivers/input/keyboard/lpc32xx-keys.c line 269

Quoted 4 lines
drivers/input/keyboard/lpc32xx-keys.c new file +4 -0
+
+	matrix_keypad_build_keymap(NULL, NULL, kscandat->kscancfg->matrix_sz,
+				   kscandat->kscancfg->matrix_sz,
+				   kscandat->kscancfg->keymap, kscandat->input);

This function may fail now.

I'm addressing both issues in a updated patch.

Thanks for the feedback,

Roland