input: keyboard: Add keys driver for the LPC32xx SoC
Subsystems (6)
PATCH v4 1/2 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-rc1
Please pick this patch for the input subsystem.
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 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
PATCH v4 2/2 ARM: LPC32xx: Make platform use key driver
This patch connects the lpc32xx-key driver to the LPC32xx platform (via lpc32xx.dtsi), and more specifically to the reference board via its dts file. The clock.c file needs to be changed to match the automatic device name to its clock.
---
Applies to v3.5-rc1
Please pick this patch for the arm-soc subsystem.
Changes since v3:
* None
Changes since v2:
* DT: Use "keypad,num-rows", "keypad,num-columns" and "linux,keymap" properties
arch/arm/boot/dts/lpc32xx.dtsi | 2 ++ arch/arm/boot/dts/phy3250.dts | 9 +++++++++ arch/arm/mach-lpc32xx/clock.c | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-)
arch/arm/boot/dts/lpc32xx.dtsi +2 -0
@@ -249,6 +249,8 @@ key at 40050000 { compatible = "nxp,lpc3220-key"; reg = <0x40050000 0x1000>; + interrupts = <54 0>; + status = "disable"; }; };
arch/arm/boot/dts/phy3250.dts +9 -0
@@ -135,6 +135,15 @@ tsc at 40048000 { status = "okay"; }; + + key at 40050000 { + status = "okay"; + keypad,num-rows = <1>; + keypad,num-columns = <1>; + nxp,debounce-delay-ms = <3>; + nxp,scan-delay-ms = <34>; + linux,keymap = <0x00000002>; + }; }; };
arch/arm/mach-lpc32xx/clock.c +1 -1
@@ -1131,7 +1131,7 @@ static struct clk_lookup lookups[] = {CLKDEV_INIT ("31020300.i2c" ,NULL , &clk_i2c2),CLKDEV_INIT ("dev:ssp0" ,NULL , &clk_ssp0),CLKDEV_INIT ("dev:ssp1" ,NULL , &clk_ssp1), -CLKDEV_INIT ("lpc32xx_keys.0" ,NULL , &clk_kscan), +CLKDEV_INIT ("40050000.key" ,NULL , &clk_kscan),CLKDEV_INIT ("20020000.flash" ,NULL , &clk_nand),CLKDEV_INIT ("200a8000.flash" ,NULL , &clk_nand_mlc), CLKDEV_INIT("40048000.adc", NULL, &clk_adc),