ARM: SAMSUNG: Add keypad device support
Subsystems (5)
PATCH v2 1/5 ARM: SAMSUNG: Add keypad device support
This patch adds samsung keypad device definition for samsung cpus.
--- arch/arm/plat-samsung/Kconfig | 7 ++- arch/arm/plat-samsung/Makefile | 1 + arch/arm/plat-samsung/dev-keypad.c | 50 +++++++++++++++++++ arch/arm/plat-samsung/include/plat/devs.h | 2 + arch/arm/plat-samsung/include/plat/keypad.h | 57 ++++++++++++++++++++++ arch/arm/plat-samsung/include/plat/regs-keypad.h | 49 +++++++++++++++++++ 6 files changed, 165 insertions(+), 1 deletions(-) create mode 100644 arch/arm/plat-samsung/dev-keypad.c create mode 100644 arch/arm/plat-samsung/include/plat/keypad.h create mode 100644 arch/arm/plat-samsung/include/plat/regs-keypad.h
arch/arm/plat-samsung/Kconfig +6 -1
@@ -225,7 +225,12 @@ config S3C64XX_DEV_SPI config SAMSUNG_DEV_TS bool help - Common in platform device definitions for touchscreen device + Common in platform device definitions for touchscreen device + +config SAMSUNG_DEV_KEYPAD + bool + help + Compile in platform device definitions for keypad # DMA
arch/arm/plat-samsung/Makefile +1 -0
@@ -50,6 +50,7 @@ obj-$(CONFIG_S3C_DEV_RTC) += dev-rtc.o obj-$(CONFIG_SAMSUNG_DEV_ADC) += dev-adc.o obj-$(CONFIG_SAMSUNG_DEV_TS) += dev-ts.o +obj-$(CONFIG_SAMSUNG_DEV_KEYPAD) += dev-keypad.o # DMA support
arch/arm/plat-samsung/dev-keypad.c new file +50 -0
50 lines not on this page · raw message
arch/arm/plat-samsung/include/plat/devs.h +2 -0
@@ -100,6 +100,8 @@ extern struct platform_device s5pc100_device_iis0;extern struct platform_device s5pc100_device_iis1;extern struct platform_device s5pc100_device_iis2; +extern struct platform_device samsung_device_keypad; +/* s3c2440 specific devices */ #ifdef CONFIG_CPU_S3C2440
arch/arm/plat-samsung/include/plat/keypad.h new file +57 -0
57 lines not on this page · raw message
arch/arm/plat-samsung/include/plat/regs-keypad.h new file +49 -0
49 lines not on this page · raw message
Signature · 1 line
1.7.0.4
PATCH v2 2/5 ARM: S5PV210: Add keypad device helpers
This patch adds the keypad device platform helpers for S5PV210 cpu.
--- arch/arm/mach-s5pv210/Kconfig | 5 ++++ arch/arm/mach-s5pv210/Makefile | 1 + arch/arm/mach-s5pv210/include/mach/map.h | 3 ++ arch/arm/mach-s5pv210/setup-keypad.c | 34 ++++++++++++++++++++++++++++++ 4 files changed, 43 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-s5pv210/setup-keypad.c
arch/arm/mach-s5pv210/Kconfig +5 -0
@@ -32,6 +32,11 @@ config S5PV210_SETUP_FB_24BPP help Common setup code for S5PV210 with an 24bpp RGB display helper. +config S5PV210_SETUP_KEYPAD + bool + help + Common setup code for keypad. + config S5PV210_SETUP_SDHCI bool select S5PV210_SETUP_SDHCI_GPIO
arch/arm/mach-s5pv210/Makefile +1 -0
@@ -31,5 +31,6 @@ obj-$(CONFIG_S5PC110_DEV_ONENAND) += dev-onenand.o obj-$(CONFIG_S5PV210_SETUP_FB_24BPP) += setup-fb-24bpp.o obj-$(CONFIG_S5PV210_SETUP_I2C1) += setup-i2c1.o obj-$(CONFIG_S5PV210_SETUP_I2C2) += setup-i2c2.o +obj-$(CONFIG_S5PV210_SETUP_KEYPAD) += setup-keypad.o obj-$(CONFIG_S5PV210_SETUP_SDHCI) += setup-sdhci.o obj-$(CONFIG_S5PV210_SETUP_SDHCI_GPIO) += setup-sdhci-gpio.o
arch/arm/mach-s5pv210/include/mach/map.h +3 -0
@@ -32,6 +32,8 @@#define S5PV210_PA_SPI0 0xE1300000#define S5PV210_PA_SPI1 0xE1400000 +#define S5PV210_PA_KEYPAD (0xE1600000) +#define S5PV210_PA_IIC0 (0xE1800000)#define S5PV210_PA_IIC1 (0xFAB00000)#define S5PV210_PA_IIC2 (0xE1A00000)
@@ -104,5 +106,6 @@#define S3C_PA_WDT S5PV210_PA_WATCHDOG#define SAMSUNG_PA_ADC S5PV210_PA_ADC +#define SAMSUNG_PA_KEYPAD S5PV210_PA_KEYPAD#endif /* __ASM_ARCH_MAP_H */
arch/arm/mach-s5pv210/setup-keypad.c new file +34 -0
@@ -0,0 +1,34 @@ +/* +* linux/arch/arm/mach-s5pv210/setup-keypad.c +* +* Copyright (C) 2010 Samsung Electronics Co.Ltd +* Author: Joonyoung Shim <[email protected]> +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the +* Free Software Foundation; either version 2 of the License, or (at your +* option) any later version. +* +*/ + +#include <linux/gpio.h> +#include <plat/gpio-cfg.h> + +void samsung_keypad_cfg_gpio (unsigned int rows,unsigned int cols) +{ +unsigned int gpio, end; + +/* Set all the necessary GPH3 pins to special-function 3 */ + end =S5PV210_GPH3 (rows); +for (gpio =S5PV210_GPH3 (0 ); gpio < end; gpio++) { +s3c_gpio_cfgpin (gpio,S3C_GPIO_SFN (3 )); +s3c_gpio_setpull (gpio,S3C_GPIO_PULL_NONE ); + } + +/* Set all the necessary GPH2 pins to special-function 3 */ + end =S5PV210_GPH2 (cols); +for (gpio =S5PV210_GPH2 (0 ); gpio < end; gpio++) { +s3c_gpio_cfgpin (gpio,S3C_GPIO_SFN (3 )); +s3c_gpio_setpull (gpio,S3C_GPIO_PULL_NONE ); + } +}
Signature · 1 line
1.7.0.4
PATCH v2 3/5 ARM: S5PV210: Add keypad device to the GONI board
In reply to Joonyoung ShimThis patch is to support keypad device to the GONI board.
--- arch/arm/mach-s5pv210/Kconfig | 2 ++ arch/arm/mach-s5pv210/mach-goni.c | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 0 deletions(-)
arch/arm/mach-s5pv210/Kconfig +2 -0
@@ -64,7 +64,9 @@ config MACH_GONI bool "GONI" select CPU_S5PV210 select ARCH_SPARSEMEM_ENABLE + select S5PV210_SETUP_KEYPAD select S5PC110_DEV_ONENAND + select SAMSUNG_DEV_KEYPAD help Machine support for Samsung GONI board S5PC110(MCP) is one of package option of S5PV210
arch/arm/mach-s5pv210/mach-goni.c +26 -0
@@ -25,6 +25,7 @@#include <plat/s5pv210.h> #include <plat/devs.h> #include <plat/cpu.h> +#include <plat/keypad.h> /* Following are default values for UCON, ULCON and UFCON UART registers */ #define S5PV210_UCON_DEFAULT (S3C2410_UCON_TXILEVEL | \
@@ -71,8 +72,30 @@ static struct s3c2410_uartcfg goni_uartcfgs[] __initdata = { }, }; +/* KEYPAD */ +static uint32_t keymap[]__initdata = { +/* KEY(row, col, keycode) */ +KEY (0 ,1 ,KEY_MENU ),/* Send */ +KEY (0 ,2 ,KEY_BACK ),/* End */ +KEY (1 ,1 ,KEY_CONFIG ),/* Half shot */ +KEY (1 ,2 ,KEY_VOLUMEUP ), +KEY (2 ,1 ,KEY_CAMERA ),/* Full shot */ +KEY (2 ,2 ,KEY_VOLUMEDOWN ), +}; + +static struct matrix_keymap_data keymap_data__initdata = { + .keymap = keymap, + .keymap_size =ARRAY_SIZE (keymap), +}; + +static struct samsung_kp_platdata keypad_data__initdata = { + .keymap_data = &keymap_data, + .rows =3 , + .cols =3 , +};static struct platform_device *goni_devices[]__initdata = { &s5pc110_device_onenand, + &samsung_device_keypad, };static void __init goni_map_io (void )
@@ -84,6 +107,9 @@ static void __init goni_map_io(void)static void __init goni_machine_init (void ) { +/* KEYPAD */ +samsung_kp_set_platdata (&keypad_data); +platform_add_devices (goni_devices,ARRAY_SIZE (goni_devices)); }
Signature · 1 line
1.7.0.4
PATCH v2 4/5 ARM: S5PV210: Add keypad device to the Aquila board
In reply to Joonyoung ShimThis patch is to support keypad device to the Aquila board.
--- arch/arm/mach-s5pv210/Kconfig | 2 ++ arch/arm/mach-s5pv210/mach-aquila.c | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 0 deletions(-)
arch/arm/mach-s5pv210/Kconfig +2 -0
@@ -55,8 +55,10 @@ config MACH_AQUILA select CPU_S5PV210 select ARCH_SPARSEMEM_ENABLE select S5PV210_SETUP_FB_24BPP + select S5PV210_SETUP_KEYPAD select S3C_DEV_FB select S5PC110_DEV_ONENAND + select SAMSUNG_DEV_KEYPAD help Machine support for the Samsung Aquila target based on S5PC110 SoC
arch/arm/mach-s5pv210/mach-aquila.c +25 -0
@@ -28,6 +28,7 @@#include <plat/devs.h> #include <plat/cpu.h> #include <plat/fb.h> +#include <plat/keypad.h> /* Following are default values for UCON, ULCON and UFCON UART registers */ #define S5PV210_UCON_DEFAULT (S3C2410_UCON_TXILEVEL | \
@@ -116,9 +117,30 @@ static struct s3c_fb_platdata aquila_lcd_pdata __initdata = { .setup_gpio = s5pv210_fb_gpio_setup_24bpp, }; +/* KEYPAD */ +static uint32_t keymap[]__initdata = { +/* KEY(row, col, keycode) */ +KEY (0 ,0 ,KEY_CAMERA ),/* Full Shot */ +KEY (0 ,1 ,KEY_VOLUMEUP ), +KEY (1 ,0 ,KEY_CONFIG ),/* Halt Shot */ +KEY (1 ,1 ,KEY_VOLUMEDOWN ), +}; + +static struct matrix_keymap_data keymap_data__initdata = { + .keymap = keymap, + .keymap_size =ARRAY_SIZE (keymap), +}; + +static struct samsung_kp_platdata keypad_data__initdata = { + .keymap_data = &keymap_data, + .rows =2 , + .cols =3 , +}; +static struct platform_device *aquila_devices[]__initdata = { &s3c_device_fb, &s5pc110_device_onenand, + &samsung_device_keypad, };static void __init aquila_map_io (void )
@@ -133,6 +155,9 @@ static void __init aquila_machine_init(void)/* FB */ s3c_fb_set_platdata (&aquila_lcd_pdata); +/* KEYPAD */ +samsung_kp_set_platdata (&keypad_data); +platform_add_devices (aquila_devices,ARRAY_SIZE (aquila_devices)); }
Signature · 1 line
1.7.0.4
PATCH v2 5/5 input: samsung-keypad - Add samsung keypad driver
In reply to Joonyoung ShimThis patch adds support for keypad driver running on Samsung cpus. This driver is tested on GONI and Aquila board using S5PC110 cpu.
--- drivers/input/keyboard/Kconfig | 9 + drivers/input/keyboard/Makefile | 1 + drivers/input/keyboard/samsung-keypad.c | 364 +++++++++++++++++++++++++++++++ 3 files changed, 374 insertions(+), 0 deletions(-) create mode 100644 drivers/input/keyboard/samsung-keypad.c
drivers/input/keyboard/Kconfig +9 -0
@@ -342,6 +342,15 @@ config KEYBOARD_PXA930_ROTARY To compile this driver as a module, choose M here: the module will be called pxa930_rotary. +config KEYBOARD_SAMSUNG + tristate "Samsung keypad support" + depends on SAMSUNG_DEV_KEYPAD + help + Say Y here if you want to use the Samsung keypad. + + To compile this driver as a module, choose M here: the + module will be called samsung-keypad. + config KEYBOARD_STOWAWAY tristate "Stowaway keyboard" select SERIO
drivers/input/keyboard/Makefile +1 -0
@@ -32,6 +32,7 @@ obj-$(CONFIG_KEYBOARD_OPENCORES) += opencores-kbd.o obj-$(CONFIG_KEYBOARD_PXA27x) += pxa27x_keypad.o obj-$(CONFIG_KEYBOARD_PXA930_ROTARY) += pxa930_rotary.o obj-$(CONFIG_KEYBOARD_QT2160) += qt2160.o +obj-$(CONFIG_KEYBOARD_SAMSUNG) += samsung-keypad.o obj-$(CONFIG_KEYBOARD_SH_KEYSC) += sh_keysc.o obj-$(CONFIG_KEYBOARD_STOWAWAY) += stowaway.o obj-$(CONFIG_KEYBOARD_SUNKBD) += sunkbd.o
drivers/input/keyboard/samsung-keypad.c new file +364 -0
364 lines not on this page · raw message
Signature · 1 line
1.7.0.4
PATCH v2 5/5 input: samsung-keypad - Add samsung keypad driver
Dne Ne 30. kv?tna 2010 05:06:24 Joonyoung Shim napsal(a):
Quoted 95 lines
This patch adds support for keypad driver running on Samsung cpus. This driver is tested on GONI and Aquila board using S5PC110 cpu.
Signed-off-by Joonyoung Shim <[email protected]>Signed-off-by Kyungmin Park <[email protected]>--- drivers/input/keyboard/Kconfig | 9 + drivers/input/keyboard/Makefile | 1 + drivers/input/keyboard/samsung-keypad.c | 364 +++++++++++++++++++++++++++++++ 3 files changed, 374 insertions(+), 0 deletions(-) create mode 100644 drivers/input/keyboard/samsung-keypad.c(quoted diff) +0
-0b/drivers/input/keyboard/Kconfig index d8fa5d7..bf6a50f 100644
drivers/input/keyboard/Kconfig +9
-0@@ -342,6 +342,15 @@ config KEYBOARD_PXA930_ROTARY To compile this driver as a module, choose M here: the module will be called pxa930_rotary. +config KEYBOARD_SAMSUNG + tristate "Samsung keypad support" + depends on SAMSUNG_DEV_KEYPAD + help + Say Y here if you want to use the Samsung keypad. + + To compile this driver as a module, choose M here: the + module will be called samsung-keypad. + config KEYBOARD_STOWAWAY tristate "Stowaway keyboard" select SERIO(quoted diff) +0
-0b/drivers/input/keyboard/Makefile index 4596d0c..8f973ed 100644
drivers/input/keyboard/Makefile +1
-0@@ -32,6 +32,7 @@ obj-$(CONFIG_KEYBOARD_OPENCORES) += opencores-kbd.o obj-$(CONFIG_KEYBOARD_PXA27x) += pxa27x_keypad.o obj-$(CONFIG_KEYBOARD_PXA930_ROTARY) += pxa930_rotary.o obj-$(CONFIG_KEYBOARD_QT2160) += qt2160.o +obj-$(CONFIG_KEYBOARD_SAMSUNG) += samsung-keypad.o obj-$(CONFIG_KEYBOARD_SH_KEYSC) += sh_keysc.o obj-$(CONFIG_KEYBOARD_STOWAWAY) += stowaway.o obj-$(CONFIG_KEYBOARD_SUNKBD) += sunkbd.o(quoted diff) +0
-0
b/drivers/input/keyboard/samsung-keypad.cnew file mode 100644 index 0000000..f4bcf97drivers/input/keyboard/samsung-keypad.c new file +8
-0@@ -0,0 +1,364 @@ +/* +* samsung-keypad.c -- Samsung keypad driver +* +* Copyright (C) 2010 Samsung Electronics Co.Ltd +* Author: Joonyoung Shim <[email protected]> +* Author: Donghwa Lee <[email protected]> +* +* This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version.
+ */drivers/input/keyboard/samsung-keypad.c new file +30
-0+ +#include <linux/clk.h> +#include <linux/delay.h> +#include <linux/err.h> +#include <linux/init.h> +#include <linux/input.h> +#include <linux/interrupt.h> +#include <linux/io.h> +#include <linux/module.h> +#include <linux/platform_device.h> +#include <linux/slab.h> +#include <plat/cpu.h> +#include <plat/keypad.h> +#include <plat/regs-keypad.h> + +struct samsung_kp { +struct input_dev *input_dev; +struct timer_list timer; +struct clk *clk; +struct work_struct work; +void __iomem *base; +unsigned short *keycodes; +unsigned int row_shift; +unsigned int rows; +unsigned int cols; +unsigned int row_state[SAMSUNG_MAX_COLS ]; +int irq; +}; + +static void samsung_kp_scan(struct samsung_kp *keypad, unsigned int
*row_state) +{drivers/input/keyboard/samsung-keypad.c new file +1
-0+unsigned int col;
drivers/input/keyboard/samsung-keypad.c line 54
Quoted 10 lines
drivers/input/keyboard/samsung-keypad.c new file +10
-0+unsigned int val; + +for (col =0 ; col < keypad->cols; col++) { +#if CONFIG_ARCH_S5PV210 + val =S5PV210_KEYIFCOLEN_MASK ; + val &= ~(1 << col) <<8 ; +#else + val =SAMSUNG_KEYIFCOL_MASK ; + val &= ~(1 << col); +#endif
No, what if you want to run this on both S5PV210 and some other samsung soc? Fix the #if CONFIG_ARCH_S5PV210 please. Maybe like this:
if (cpu_is_s5pv210()) {} else {} ?
The rest looks good.
Cheers!
PATCH v2 5/5 input: samsung-keypad - Add samsung keypad driver
Quoted 111 lines · Marek Vasut
Dne Ne 30. kv??tna 2010 05:06:24 Joonyoung Shim napsal(a):
Quoted 95 lines
This patch adds support for keypad driver running on Samsung cpus. This driver is tested on GONI and Aquila board using S5PC110 cpu.
Signed-off-by Joonyoung Shim <[email protected]>Signed-off-by Kyungmin Park <[email protected]>--- drivers/input/keyboard/Kconfig | 9 + drivers/input/keyboard/Makefile | 1 + drivers/input/keyboard/samsung-keypad.c | 364 +++++++++++++++++++++++++++++++ 3 files changed, 374 insertions(+), 0 deletions(-) create mode 100644 drivers/input/keyboard/samsung-keypad.c(quoted diff) +0
-0b/drivers/input/keyboard/Kconfig index d8fa5d7..bf6a50f 100644
drivers/input/keyboard/Kconfig +9
-0@@ -342,6 +342,15 @@ config KEYBOARD_PXA930_ROTARY To compile this driver as a module, choose M here: the module will be called pxa930_rotary. +config KEYBOARD_SAMSUNG + tristate "Samsung keypad support" + depends on SAMSUNG_DEV_KEYPAD + help + Say Y here if you want to use the Samsung keypad. + + To compile this driver as a module, choose M here: the + module will be called samsung-keypad. + config KEYBOARD_STOWAWAY tristate "Stowaway keyboard" select SERIO(quoted diff) +0
-0b/drivers/input/keyboard/Makefile index 4596d0c..8f973ed 100644
drivers/input/keyboard/Makefile +1
-0@@ -32,6 +32,7 @@ obj-$(CONFIG_KEYBOARD_OPENCORES) += opencores-kbd.o obj-$(CONFIG_KEYBOARD_PXA27x) += pxa27x_keypad.o obj-$(CONFIG_KEYBOARD_PXA930_ROTARY) += pxa930_rotary.o obj-$(CONFIG_KEYBOARD_QT2160) += qt2160.o +obj-$(CONFIG_KEYBOARD_SAMSUNG) += samsung-keypad.o obj-$(CONFIG_KEYBOARD_SH_KEYSC) += sh_keysc.o obj-$(CONFIG_KEYBOARD_STOWAWAY) += stowaway.o obj-$(CONFIG_KEYBOARD_SUNKBD) += sunkbd.o(quoted diff) +0
-0
b/drivers/input/keyboard/samsung-keypad.cnew file mode 100644 index 0000000..f4bcf97drivers/input/keyboard/samsung-keypad.c new file +8
-0@@ -0,0 +1,364 @@ +/* +* samsung-keypad.c -- Samsung keypad driver +* +* Copyright (C) 2010 Samsung Electronics Co.Ltd +* Author: Joonyoung Shim <[email protected]> +* Author: Donghwa Lee <[email protected]> +* +* This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version.
+ */drivers/input/keyboard/samsung-keypad.c new file +30
-0+ +#include <linux/clk.h> +#include <linux/delay.h> +#include <linux/err.h> +#include <linux/init.h> +#include <linux/input.h> +#include <linux/interrupt.h> +#include <linux/io.h> +#include <linux/module.h> +#include <linux/platform_device.h> +#include <linux/slab.h> +#include <plat/cpu.h> +#include <plat/keypad.h> +#include <plat/regs-keypad.h> + +struct samsung_kp { +struct input_dev *input_dev; +struct timer_list timer; +struct clk *clk; +struct work_struct work; +void __iomem *base; +unsigned short *keycodes; +unsigned int row_shift; +unsigned int rows; +unsigned int cols; +unsigned int row_state[SAMSUNG_MAX_COLS ]; +int irq; +}; + +static void samsung_kp_scan(struct samsung_kp *keypad, unsigned int
*row_state) +{drivers/input/keyboard/samsung-keypad.c new file +1
-0+unsigned int col;drivers/input/keyboard/samsung-keypad.c line 54
Quoted 10 lines
drivers/input/keyboard/samsung-keypad.c new file +10
-0+unsigned int val; + +for (col =0 ; col < keypad->cols; col++) { +#if CONFIG_ARCH_S5PV210 + val =S5PV210_KEYIFCOLEN_MASK ; + val &= ~(1 << col) <<8 ; +#else + val =SAMSUNG_KEYIFCOL_MASK ; + val &= ~(1 << col); +#endif No, what if you want to run this on both S5PV210 and some other samsung soc? Fix the #if
CONFIG_ARCH_S5PV210please. Maybe like this:
Quoted 1 line
if (
cpu_is_s5pv210()) {} else {} ?
We very specifically made a choice not to use cpu_is_xxx a long time ago, there's other better ways to do this, either by passing data about the soc into the driver or by renaming the platform-device.
Signature · 4 lines
Ben Q: What's a light-year? A: One-third less calories than a regular year.
PATCH v2 5/5 input: samsung-keypad - Add samsung keypad driver
In reply to Joonyoung ShimQuoted 12 lines · Joonyoung Shim
This patch adds support for keypad driver running on Samsung cpus. This driver is tested on GONI and Aquila board using S5PC110 cpu.
Signed-off-by Joonyoung Shim <[email protected]>Signed-off-by Kyungmin Park <[email protected]>--- drivers/input/keyboard/Kconfig | 9 + drivers/input/keyboard/Makefile | 1 + drivers/input/keyboard/samsung-keypad.c | 364 +++++++++++++++++++++++++++++++ 3 files changed, 374 insertions(+), 0 deletions(-) create mode 100644 drivers/input/keyboard/samsung-keypad.c
Sorry for bothering.
Please use following patch because of typo of prior patch.
PATCH v2 5/5 input: samsung-keypad - Add samsung keypad driver
In reply to Joonyoung ShimQuoted 64 lines · Joonyoung Shim
This patch adds support for keypad driver running on Samsung cpus. This driver is tested on GONI and Aquila board using S5PC110 cpu.
Signed-off-by Joonyoung Shim <[email protected]>Signed-off-by Kyungmin Park <[email protected]>--- drivers/input/keyboard/Kconfig | 9 + drivers/input/keyboard/Makefile | 1 + drivers/input/keyboard/samsung-keypad.c | 364 +++++++++++++++++++++++++++++++ 3 files changed, 374 insertions(+), 0 deletions(-) create mode 100644 drivers/input/keyboard/samsung-keypad.cdrivers/input/keyboard/Kconfig +9
-0@@ -342,6 +342,15 @@ config KEYBOARD_PXA930_ROTARY To compile this driver as a module, choose M here: the module will be called pxa930_rotary. +config KEYBOARD_SAMSUNG + tristate "Samsung keypad support" + depends on SAMSUNG_DEV_KEYPAD + help + Say Y here if you want to use the Samsung keypad. + + To compile this driver as a module, choose M here: the + module will be called samsung-keypad. + config KEYBOARD_STOWAWAY tristate "Stowaway keyboard" select SERIOdrivers/input/keyboard/Makefile +1
-0@@ -32,6 +32,7 @@ obj-$(CONFIG_KEYBOARD_OPENCORES) += opencores-kbd.o obj-$(CONFIG_KEYBOARD_PXA27x) += pxa27x_keypad.o obj-$(CONFIG_KEYBOARD_PXA930_ROTARY) += pxa930_rotary.o obj-$(CONFIG_KEYBOARD_QT2160) += qt2160.o +obj-$(CONFIG_KEYBOARD_SAMSUNG) += samsung-keypad.o obj-$(CONFIG_KEYBOARD_SH_KEYSC) += sh_keysc.o obj-$(CONFIG_KEYBOARD_STOWAWAY) += stowaway.o obj-$(CONFIG_KEYBOARD_SUNKBD) += sunkbd.odrivers/input/keyboard/samsung-keypad.c new file +14
-0@@ -0,0 +1,364 @@ +/* +* samsung-keypad.c -- Samsung keypad driver +* +* Copyright (C) 2010 Samsung Electronics Co.Ltd +* Author: Joonyoung Shim <[email protected]> +* Author: Donghwa Lee <[email protected]> +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the +* Free Software Foundation; either version 2 of the License, or (at your +* option) any later version. +*/ + +#include <linux/clk.h>
drivers/input/keyboard/samsung-keypad.c line 24
Quoted 10 lines
drivers/input/keyboard/samsung-keypad.c new file +10
-0+#include <linux/delay.h> +#include <linux/err.h> +#include <linux/init.h> +#include <linux/input.h> +#include <linux/interrupt.h> +#include <linux/io.h> +#include <linux/module.h> +#include <linux/platform_device.h> +#include <linux/slab.h> +#include <plat/cpu.h>
you should _not_ be including <plat/cpu.h> here. and it looks form the rest of the file that there's nothing from it being used.
Quoted 20 lines
drivers/input/keyboard/samsung-keypad.c new file +20
-0+#include <plat/keypad.h> +#include <plat/regs-keypad.h> + +struct samsung_kp { +struct input_dev *input_dev; +struct timer_list timer; +struct clk *clk; +struct work_struct work; +void __iomem *base; +unsigned short *keycodes; +unsigned int row_shift; +unsigned int rows; +unsigned int cols; +unsigned int row_state[SAMSUNG_MAX_COLS ]; +int irq; +}; + +static void samsung_kp_scan (struct samsung_kp *keypad,unsigned int *row_state) +{ +unsigned int col;
drivers/input/keyboard/samsung-keypad.c line 54
Quoted 10 lines
drivers/input/keyboard/samsung-keypad.c new file +10
-0+unsigned int val; + +for (col =0 ; col < keypad->cols; col++) { +#if CONFIG_ARCH_S5PV210 + val =S5PV210_KEYIFCOLEN_MASK ; + val &= ~(1 << col) <<8 ; +#else + val =SAMSUNG_KEYIFCOL_MASK ; + val &= ~(1 << col); +#endif
no platform specific #ifdefs
Quoted 106 lines
drivers/input/keyboard/samsung-keypad.c new file +106
-0+writel (val, keypad->base +SAMSUNG_KEYIFCOL ); +mdelay (1 ); + + val =readl (keypad->base +SAMSUNG_KEYIFROW ); + row_state[col] = ~val & ((1 << keypad->rows) -1 ); + } + +/* KEYIFCOL reg clear */ +writel (0 , keypad->base +SAMSUNG_KEYIFCOL ); +} + +static void samsung_kp_worker (struct work_struct *work) +{ + struct samsung_kp *keypad = container_of(work, struct samsung_kp, work); +unsigned int row_state[SAMSUNG_MAX_COLS ]; +unsigned int val; +unsigned int changed; +unsigned int pressed; +unsigned int key_down =0 ; +int col, row; + +clk_enable (keypad->clk); + + val =readl (keypad->base +SAMSUNG_KEYIFSTSCLR ); + +/* interrupt clear */ +writel (~0x0 , keypad->base +SAMSUNG_KEYIFSTSCLR ); + + val =readl (keypad->base +SAMSUNG_KEYIFCON ); + val &= ~(SAMSUNG_INT_F_EN |SAMSUNG_INT_R_EN ); +writel (val, keypad->base +SAMSUNG_KEYIFCON ); + +samsung_kp_scan (keypad, row_state); + +for (col =0 ; col < keypad->cols; col++) { + changed = row_state[col] ^ keypad->row_state[col]; + key_down |= row_state[col]; +if (!changed) +continue ; + +for (row =0 ; row < keypad->rows; row++) { +if (!(changed & (1 << row))) +continue ; + + pressed = row_state[col] & (1 << row); + +dev_dbg (&keypad->input_dev->dev, +"key %s, row: %d, col: %d\n" , + pressed ?"pressed" :"released" , row, col); + + val =MATRIX_SCAN_CODE (row, col, keypad->row_shift); + +input_report_key (keypad->input_dev, + keypad->keycodes[val], pressed); +input_sync (keypad->input_dev); + } + } +memcpy (keypad->row_state, row_state,sizeof (row_state)); + +if (key_down) +mod_timer (&keypad->timer, jiffies +HZ /20 ); +else { +/* enable interrupt bit */ + val =readl (keypad->base +SAMSUNG_KEYIFCON ); + val |= (SAMSUNG_INT_F_EN |SAMSUNG_INT_R_EN ); +writel (val, keypad->base +SAMSUNG_KEYIFCON ); +enable_irq (keypad->irq); + } +clk_disable (keypad->clk); +} + +static irqreturn_t samsung_kp_interrupt (int irq,void *dev_id) +{ +struct samsung_kp *keypad = dev_id; + +if (!work_pending (&keypad->work)) { +disable_irq_nosync (keypad->irq); +schedule_work (&keypad->work); + } + +return IRQ_HANDLED ; +} + +static void samsung_kp_timer (unsigned long data) +{ +struct samsung_kp *keypad = (struct samsung_kp *)data; + +schedule_work (&keypad->work); +} + +static int __devinit samsung_kp_probe (struct platform_device *pdev) +{ +const struct samsung_kp_platdata *pdata; +const struct matrix_keymap_data *keymap_data; +struct samsung_kp *keypad; +struct resource *res; +struct input_dev *input_dev; +unsigned short *keycodes; +unsigned int row_shift; +unsigned int val; +int ret; + + pdata = pdev->dev.platform_data; +if (!pdata) { +dev_err (&pdev->dev,"no platform data defined\n" ); +return -EINVAL ;
drivers/input/keyboard/samsung-keypad.c line 170
Quoted 10 lines
drivers/input/keyboard/samsung-keypad.c new file +10
-0+ } + + keymap_data = pdata->keymap_data; +if (!keymap_data) { +dev_err (&pdev->dev,"no keymap data defined\n" ); +return -EINVAL ; + } + +if ((pdata->rows <=0 ) || (pdata->rows >SAMSUNG_MAX_ROWS )) +return -EINVAL ;
how about making pdata->rows unsigned then if -ve values are illegal
drivers/input/keyboard/samsung-keypad.c line 182
Quoted 11 lines
drivers/input/keyboard/samsung-keypad.c new file +11
-0+if ((pdata->cols <=0 ) || (pdata->cols >SAMSUNG_MAX_COLS )) +return -EINVAL ; + +/* initialize the gpio */ +if (pdata->cfg_gpio) + pdata->cfg_gpio (pdata->rows, pdata->cols); + + row_shift =get_count_order (pdata->cols); + keypad =kzalloc (sizeof (*keypad),GFP_KERNEL ); + keycodes =kzalloc ((pdata->rows << row_shift) *sizeof (*keycodes), +GFP_KERNEL );
you could allocate this in one go.
Quoted 190 lines
drivers/input/keyboard/samsung-keypad.c new file +182
-0+ input_dev =input_allocate_device (); +if (!keypad || !keycodes || !input_dev) { + ret = -ENOMEM ; + goto err_free_mem; + } + + res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); +if (!res) { + ret = -ENODEV ; + goto err_free_mem; + } + + keypad->base =ioremap (res->start,resource_size (res)); +if (!keypad->base) { + ret = -EBUSY ; + goto err_free_mem; + } + + keypad->clk =clk_get (&pdev->dev,"keypad" ); +if (IS_ERR (keypad->clk)) { +dev_err (&pdev->dev,"failed to get keypad clk\n" ); + ret =PTR_ERR (keypad->clk); + goto err_unmap_base; + } +clk_enable (keypad->clk); + + keypad->input_dev = input_dev; + keypad->keycodes = keycodes; + keypad->row_shift = row_shift; + keypad->rows = pdata->rows; + keypad->cols = pdata->cols; + +INIT_WORK (&keypad->work, samsung_kp_worker); + +setup_timer (&keypad->timer, samsung_kp_timer, (unsigned long )keypad); + +/* enable interrupt and wakeup bit */ + val =SAMSUNG_INT_F_EN |SAMSUNG_INT_R_EN |SAMSUNG_WAKEUPEN ; +writel (val, keypad->base +SAMSUNG_KEYIFCON ); + +/* KEYIFCOL reg clear */ +writel (0 , keypad->base +SAMSUNG_KEYIFCOL ); + + keypad->irq =platform_get_irq (pdev,0 ); +if (keypad->irq <0 ) { + ret = keypad->irq; + goto err_disable_clk; + } + + ret =request_irq (keypad->irq, samsung_kp_interrupt,0 , +dev_name (&pdev->dev), keypad); + +if (ret) + goto err_disable_clk; + + input_dev->name = pdev->name; + input_dev->id.bustype =BUS_HOST ; + input_dev->dev.parent = &pdev->dev; + + input_dev->evbit[0 ] =BIT_MASK (EV_KEY ); +if (pdata->rep) + input_dev->evbit[0 ] |=BIT_MASK (EV_REP ); + + input_dev->keycode = keycodes; + input_dev->keycodesize =sizeof (*keycodes); + input_dev->keycodemax = pdata->rows << row_shift; + +matrix_keypad_build_keymap (keymap_data, row_shift, + input_dev->keycode, input_dev->keybit); + + ret =input_register_device (keypad->input_dev); +if (ret) + goto err_free_irq; + +platform_set_drvdata (pdev, keypad); +clk_disable (keypad->clk); + +return 0 ; + +err_free_irq: +free_irq (keypad->irq, keypad); +err_disable_clk: +clk_disable (keypad->clk); +clk_put (keypad->clk); +err_unmap_base: +iounmap (keypad->base); +err_free_mem: +input_free_device (input_dev); +kfree (keycodes); +kfree (keypad); + +return ret; +} + +static int __devexit samsung_kp_remove(struct platform_device *pdev) +{ +struct samsung_kp *keypad =platform_get_drvdata (pdev); + +free_irq (keypad->irq, keypad); +cancel_work_sync (&keypad->work); +del_timer_sync (&keypad->timer); + +platform_set_drvdata (pdev,NULL ); +input_unregister_device (keypad->input_dev); + +clk_disable (keypad->clk); +clk_put (keypad->clk); + +iounmap (keypad->base); +kfree (keypad->keycodes); +kfree (keypad); + +return 0 ; +} + +#ifdef CONFIG_PM +static int samsung_kp_suspend (struct device *dev) +{ +struct platform_device *pdev =to_platform_device (dev); +struct samsung_kp *keypad =platform_get_drvdata (pdev); + +disable_irq (keypad->irq); + +return 0 ; +} + +static int samsung_kp_resume (struct device pdev) +{ +struct platform_device *pdev =to_platform_device (dev); +struct samsung_kp *keypad =platform_get_drvdata (pdev); +unsigned int val; + +clk_enable (keypad->clk); + +/* enable interrupt and wakeup bit */ + val =SAMSUNG_INT_F_EN |SAMSUNG_INT_R_EN |SAMSUNG_WAKEUPEN ; +writel (val, keypad->base +SAMSUNG_KEYIFCON ); + +/* KEYIFCOL reg clear */ +writel (0 , keypad->base +SAMSUNG_KEYIFCOL ); + +enable_irq (keypad->irq); +clk_disable (keypad->clk); + +return 0 ; +} + +static const struct dev_pm_ops samsung_kp_pm_ops = { + .suspend = samsung_kp_suspend, + .resume = samsung_kp_resume, +}; +#endif + +static struct platform_driver samsung_kp_driver = { + .probe = samsung_kp_probe, + .remove =__devexit_p (samsung_kp_remove), + .driver = { + .name ="samsung-keypad" , + .owner =THIS_MODULE , +#ifdef CONFIG_PM + .pm = &samsung_kp_pm_ops, +#endif + }, +}; + +static int __init samsung_kp_init (void ) +{ +return platform_driver_register (&samsung_kp_driver); +} + +static void __exit samsung_kp_exit(void) +{ +platform_driver_unregister (&samsung_kp_driver); +} + +module_init (samsung_kp_init); +module_exit (samsung_kp_exit); + +MODULE_DESCRIPTION ("Samsung keypad driver" ); +MODULE_AUTHOR ("Joonyoung Shim <[email protected]>" ); +MODULE_AUTHOR ("Donghwa Lee <[email protected]>" ); +MODULE_LICENSE ("GPL" );Signature · 7 lines
1.7.0.4 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel at lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Signature · 5 lines
-- Ben Q: What's a light-year? A: One-third less calories than a regular year.
PATCH v2 5/5 input: samsung-keypad - Add samsung keypad driver
Quoted 70 lines · Ben Dooks
Quoted 69 lines · Joonyoung Shim
This patch adds support for keypad driver running on Samsung cpus. This driver is tested on GONI and Aquila board using S5PC110 cpu.
Signed-off-by Joonyoung Shim <[email protected]>Signed-off-by Kyungmin Park <[email protected]>--- drivers/input/keyboard/Kconfig | 9 + drivers/input/keyboard/Makefile | 1 + drivers/input/keyboard/samsung-keypad.c | 364 +++++++++++++++++++++++++++++++ 3 files changed, 374 insertions(+), 0 deletions(-) create mode 100644 drivers/input/keyboard/samsung-keypad.cdrivers/input/keyboard/Kconfig +9
-0@@ -342,6 +342,15 @@ config KEYBOARD_PXA930_ROTARY To compile this driver as a module, choose M here: the module will be called pxa930_rotary. +config KEYBOARD_SAMSUNG + tristate "Samsung keypad support" + depends on SAMSUNG_DEV_KEYPAD + help + Say Y here if you want to use the Samsung keypad. + + To compile this driver as a module, choose M here: the + module will be called samsung-keypad. + config KEYBOARD_STOWAWAY tristate "Stowaway keyboard" select SERIOdrivers/input/keyboard/Makefile +1
-0@@ -32,6 +32,7 @@ obj-$(CONFIG_KEYBOARD_OPENCORES) += opencores-kbd.o obj-$(CONFIG_KEYBOARD_PXA27x) += pxa27x_keypad.o obj-$(CONFIG_KEYBOARD_PXA930_ROTARY) += pxa930_rotary.o obj-$(CONFIG_KEYBOARD_QT2160) += qt2160.o +obj-$(CONFIG_KEYBOARD_SAMSUNG) += samsung-keypad.o obj-$(CONFIG_KEYBOARD_SH_KEYSC) += sh_keysc.o obj-$(CONFIG_KEYBOARD_STOWAWAY) += stowaway.o obj-$(CONFIG_KEYBOARD_SUNKBD) += sunkbd.odrivers/input/keyboard/samsung-keypad.c new file +19
-0@@ -0,0 +1,364 @@ +/* +* samsung-keypad.c -- Samsung keypad driver +* +* Copyright (C) 2010 Samsung Electronics Co.Ltd +* Author: Joonyoung Shim <[email protected]> +* Author: Donghwa Lee <[email protected]> +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the +* Free Software Foundation; either version 2 of the License, or (at your +* option) any later version. +*/ + +#include <linux/clk.h> +#include <linux/delay.h> +#include <linux/err.h> +#include <linux/init.h> +#include <linux/input.h> +#include <linux/interrupt.h>
Quoted 9 lines
drivers/input/keyboard/samsung-keypad.c line 24
Quoted 5 lines
drivers/input/keyboard/samsung-keypad.c new file +5
-0+#include <linux/io.h> +#include <linux/module.h> +#include <linux/platform_device.h> +#include <linux/slab.h> +#include <plat/cpu.h> you should _not_ be including <
plat/cpu.h> here. and it looks form the rest of the file that there's nothing from it being used.
Yes, i will remove it.
Quoted 24 lines
Quoted 24 lines
drivers/input/keyboard/samsung-keypad.c new file +24
-0+#include <plat/keypad.h> +#include <plat/regs-keypad.h> + +struct samsung_kp { +struct input_dev *input_dev; +struct timer_list timer; +struct clk *clk; +struct work_struct work; +void __iomem *base; +unsigned short *keycodes; +unsigned int row_shift; +unsigned int rows; +unsigned int cols; +unsigned int row_state[SAMSUNG_MAX_COLS ]; +int irq; +}; + +static void samsung_kp_scan (struct samsung_kp *keypad,unsigned int *row_state) +{ +unsigned int col; +unsigned int val; + +for (col =0 ; col < keypad->cols; col++) { +#if CONFIG_ARCH_S5PV210
Quoted 9 lines
drivers/input/keyboard/samsung-keypad.c line 54
Quoted 6 lines
drivers/input/keyboard/samsung-keypad.c new file +6
-0+ val =S5PV210_KEYIFCOLEN_MASK ; + val &= ~(1 << col) <<8 ; +#else + val =SAMSUNG_KEYIFCOL_MASK ; + val &= ~(1 << col); +#endif no platform specific #ifdefs
OK, i will find other ways.
Quoted 111 lines
Quoted 111 lines
drivers/input/keyboard/samsung-keypad.c new file +111
-0+writel (val, keypad->base +SAMSUNG_KEYIFCOL ); +mdelay (1 ); + + val =readl (keypad->base +SAMSUNG_KEYIFROW ); + row_state[col] = ~val & ((1 << keypad->rows) -1 ); + } + +/* KEYIFCOL reg clear */ +writel (0 , keypad->base +SAMSUNG_KEYIFCOL ); +} + +static void samsung_kp_worker (struct work_struct *work) +{ + struct samsung_kp *keypad = container_of(work, struct samsung_kp, work); +unsigned int row_state[SAMSUNG_MAX_COLS ]; +unsigned int val; +unsigned int changed; +unsigned int pressed; +unsigned int key_down =0 ; +int col, row; + +clk_enable (keypad->clk); + + val =readl (keypad->base +SAMSUNG_KEYIFSTSCLR ); + +/* interrupt clear */ +writel (~0x0 , keypad->base +SAMSUNG_KEYIFSTSCLR ); + + val =readl (keypad->base +SAMSUNG_KEYIFCON ); + val &= ~(SAMSUNG_INT_F_EN |SAMSUNG_INT_R_EN ); +writel (val, keypad->base +SAMSUNG_KEYIFCON ); + +samsung_kp_scan (keypad, row_state); + +for (col =0 ; col < keypad->cols; col++) { + changed = row_state[col] ^ keypad->row_state[col]; + key_down |= row_state[col]; +if (!changed) +continue ; + +for (row =0 ; row < keypad->rows; row++) { +if (!(changed & (1 << row))) +continue ; + + pressed = row_state[col] & (1 << row); + +dev_dbg (&keypad->input_dev->dev, +"key %s, row: %d, col: %d\n" , + pressed ?"pressed" :"released" , row, col); + + val =MATRIX_SCAN_CODE (row, col, keypad->row_shift); + +input_report_key (keypad->input_dev, + keypad->keycodes[val], pressed); +input_sync (keypad->input_dev); + } + } +memcpy (keypad->row_state, row_state,sizeof (row_state)); + +if (key_down) +mod_timer (&keypad->timer, jiffies +HZ /20 ); +else { +/* enable interrupt bit */ + val =readl (keypad->base +SAMSUNG_KEYIFCON ); + val |= (SAMSUNG_INT_F_EN |SAMSUNG_INT_R_EN ); +writel (val, keypad->base +SAMSUNG_KEYIFCON ); +enable_irq (keypad->irq); + } +clk_disable (keypad->clk); +} + +static irqreturn_t samsung_kp_interrupt (int irq,void *dev_id) +{ +struct samsung_kp *keypad = dev_id; + +if (!work_pending (&keypad->work)) { +disable_irq_nosync (keypad->irq); +schedule_work (&keypad->work); + } + +return IRQ_HANDLED ; +} + +static void samsung_kp_timer (unsigned long data) +{ +struct samsung_kp *keypad = (struct samsung_kp *)data; + +schedule_work (&keypad->work); +} + +static int __devinit samsung_kp_probe (struct platform_device *pdev) +{ +const struct samsung_kp_platdata *pdata; +const struct matrix_keymap_data *keymap_data; +struct samsung_kp *keypad; +struct resource *res; +struct input_dev *input_dev; +unsigned short *keycodes; +unsigned int row_shift; +unsigned int val; +int ret; + + pdata = pdev->dev.platform_data; +if (!pdata) { +dev_err (&pdev->dev,"no platform data defined\n" ); +return -EINVAL ; + } + + keymap_data = pdata->keymap_data; +if (!keymap_data) { +dev_err (&pdev->dev,"no keymap data defined\n" );
Quoted 9 lines
drivers/input/keyboard/samsung-keypad.c line 170
Quoted 5 lines
drivers/input/keyboard/samsung-keypad.c new file +5
-0+return -EINVAL ; + } + +if ((pdata->rows <=0 ) || (pdata->rows >SAMSUNG_MAX_ROWS )) +return -EINVAL ;how about making
pdata->rowsunsigned then if -ve values are illegal
Ah, pdata->rows is unsigned. This is unnecessary checking.
Quoted 5 lines
Quoted 5 lines
drivers/input/keyboard/samsung-keypad.c new file +5
-0+if ((pdata->cols <=0 ) || (pdata->cols >SAMSUNG_MAX_COLS )) +return -EINVAL ; + +/* initialize the gpio */ +if (pdata->cfg_gpio)
Quoted 9 lines
drivers/input/keyboard/samsung-keypad.c line 182
Quoted 6 lines
drivers/input/keyboard/samsung-keypad.c new file +6
-0+ pdata->cfg_gpio (pdata->rows, pdata->cols); + + row_shift =get_count_order (pdata->cols); + keypad =kzalloc (sizeof (*keypad),GFP_KERNEL ); + keycodes =kzalloc ((pdata->rows << row_shift) *sizeof (*keycodes), +GFP_KERNEL );you could allocate this in one go.
Hmm, how i do it? Do you mean to allocate keypad and keycodes together?
Quoted 191 lines
Quoted 190 lines
drivers/input/keyboard/samsung-keypad.c new file +182
-0+ input_dev =input_allocate_device (); +if (!keypad || !keycodes || !input_dev) { + ret = -ENOMEM ; + goto err_free_mem; + } + + res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); +if (!res) { + ret = -ENODEV ; + goto err_free_mem; + } + + keypad->base =ioremap (res->start,resource_size (res)); +if (!keypad->base) { + ret = -EBUSY ; + goto err_free_mem; + } + + keypad->clk =clk_get (&pdev->dev,"keypad" ); +if (IS_ERR (keypad->clk)) { +dev_err (&pdev->dev,"failed to get keypad clk\n" ); + ret =PTR_ERR (keypad->clk); + goto err_unmap_base; + } +clk_enable (keypad->clk); + + keypad->input_dev = input_dev; + keypad->keycodes = keycodes; + keypad->row_shift = row_shift; + keypad->rows = pdata->rows; + keypad->cols = pdata->cols; + +INIT_WORK (&keypad->work, samsung_kp_worker); + +setup_timer (&keypad->timer, samsung_kp_timer, (unsigned long )keypad); + +/* enable interrupt and wakeup bit */ + val =SAMSUNG_INT_F_EN |SAMSUNG_INT_R_EN |SAMSUNG_WAKEUPEN ; +writel (val, keypad->base +SAMSUNG_KEYIFCON ); + +/* KEYIFCOL reg clear */ +writel (0 , keypad->base +SAMSUNG_KEYIFCOL ); + + keypad->irq =platform_get_irq (pdev,0 ); +if (keypad->irq <0 ) { + ret = keypad->irq; + goto err_disable_clk; + } + + ret =request_irq (keypad->irq, samsung_kp_interrupt,0 , +dev_name (&pdev->dev), keypad); + +if (ret) + goto err_disable_clk; + + input_dev->name = pdev->name; + input_dev->id.bustype =BUS_HOST ; + input_dev->dev.parent = &pdev->dev; + + input_dev->evbit[0 ] =BIT_MASK (EV_KEY ); +if (pdata->rep) + input_dev->evbit[0 ] |=BIT_MASK (EV_REP ); + + input_dev->keycode = keycodes; + input_dev->keycodesize =sizeof (*keycodes); + input_dev->keycodemax = pdata->rows << row_shift; + +matrix_keypad_build_keymap (keymap_data, row_shift, + input_dev->keycode, input_dev->keybit); + + ret =input_register_device (keypad->input_dev); +if (ret) + goto err_free_irq; + +platform_set_drvdata (pdev, keypad); +clk_disable (keypad->clk); + +return 0 ; + +err_free_irq: +free_irq (keypad->irq, keypad); +err_disable_clk: +clk_disable (keypad->clk); +clk_put (keypad->clk); +err_unmap_base: +iounmap (keypad->base); +err_free_mem: +input_free_device (input_dev); +kfree (keycodes); +kfree (keypad); + +return ret; +} + +static int __devexit samsung_kp_remove(struct platform_device *pdev) +{ +struct samsung_kp *keypad =platform_get_drvdata (pdev); + +free_irq (keypad->irq, keypad); +cancel_work_sync (&keypad->work); +del_timer_sync (&keypad->timer); + +platform_set_drvdata (pdev,NULL ); +input_unregister_device (keypad->input_dev); + +clk_disable (keypad->clk); +clk_put (keypad->clk); + +iounmap (keypad->base); +kfree (keypad->keycodes); +kfree (keypad); + +return 0 ; +} + +#ifdef CONFIG_PM +static int samsung_kp_suspend (struct device *dev) +{ +struct platform_device *pdev =to_platform_device (dev); +struct samsung_kp *keypad =platform_get_drvdata (pdev); + +disable_irq (keypad->irq); + +return 0 ; +} + +static int samsung_kp_resume (struct device pdev) +{ +struct platform_device *pdev =to_platform_device (dev); +struct samsung_kp *keypad =platform_get_drvdata (pdev); +unsigned int val; + +clk_enable (keypad->clk); + +/* enable interrupt and wakeup bit */ + val =SAMSUNG_INT_F_EN |SAMSUNG_INT_R_EN |SAMSUNG_WAKEUPEN ; +writel (val, keypad->base +SAMSUNG_KEYIFCON ); + +/* KEYIFCOL reg clear */ +writel (0 , keypad->base +SAMSUNG_KEYIFCOL ); + +enable_irq (keypad->irq); +clk_disable (keypad->clk); + +return 0 ; +} + +static const struct dev_pm_ops samsung_kp_pm_ops = { + .suspend = samsung_kp_suspend, + .resume = samsung_kp_resume, +}; +#endif + +static struct platform_driver samsung_kp_driver = { + .probe = samsung_kp_probe, + .remove =__devexit_p (samsung_kp_remove), + .driver = { + .name ="samsung-keypad" , + .owner =THIS_MODULE , +#ifdef CONFIG_PM + .pm = &samsung_kp_pm_ops, +#endif + }, +}; + +static int __init samsung_kp_init (void ) +{ +return platform_driver_register (&samsung_kp_driver); +} + +static void __exit samsung_kp_exit(void) +{ +platform_driver_unregister (&samsung_kp_driver); +} + +module_init (samsung_kp_init); +module_exit (samsung_kp_exit); + +MODULE_DESCRIPTION ("Samsung keypad driver" ); +MODULE_AUTHOR ("Joonyoung Shim <[email protected]>" ); +MODULE_AUTHOR ("Donghwa Lee <[email protected]>" ); +MODULE_LICENSE ("GPL" );Signature · 7 lines
1.7.0.4 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel at lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v2 5/5 input: samsung-keypad - Add samsung keypad driver
Quoted 5 lines · Joonyoung Shim
Quoted 5 lines
drivers/input/keyboard/samsung-keypad.c line 142
Quoted 5 lines
drivers/input/keyboard/samsung-keypad.c new file +5
-0+static void samsung_kp_timer (unsigned long data) +{ +struct samsung_kp *keypad = (struct samsung_kp *)data; + +schedule_work (&keypad->work);
would schedule_delayed_work() avoid the need for a timer here?
Quoted 8 lines
Quoted 6 lines
drivers/input/keyboard/samsung-keypad.c line 182
Quoted 3 lines
drivers/input/keyboard/samsung-keypad.c new file +3
-0+ keypad =kzalloc (sizeof (*keypad),GFP_KERNEL ); + keycodes =kzalloc ((pdata->rows << row_shift) *sizeof (*keycodes), +GFP_KERNEL );you could allocate this in one go.
Hmm, how i do it? Do you mean to allocate keypad and keycodes together?
There's a couple of ways to do this, they may of course be not the nicest ways.
make the last entry of the first (know size) structure a unsized array. as so:
struct a {
...
struct b t[];
}
then do
struct a *my_a;
my_a = kzalloc(sizeof(struct a ) + sizeof(struct b) * nr_b);or by incrementing the pointer:
struct a *my_a; struct b *my_b; my_a = kzalloc(sizeof(struct a ) + sizeof(struct b) * nr_b); my_b = (struct b *)(my_a + 1);
Quoted 1 line
Quoted 1 line
drivers/input/keyboard/samsung-keypad.c line 201
Quoted 1 line
drivers/input/keyboard/samsung-keypad.c new file +1
-0+ keypad->clk =clk_get (&pdev->dev,"keypad" );
I'm going to get rid of this practice, it should be clk_get(&pdev->dev, NULL), see up-comming clock changes.
Quoted 4 lines
Quoted 4 lines
drivers/input/keyboard/samsung-keypad.c line 235
Quoted 4 lines
drivers/input/keyboard/samsung-keypad.c new file +4
-0+ ret =request_irq (keypad->irq, samsung_kp_interrupt,0 , +dev_name (&pdev->dev), keypad); + +if (ret)
NO PRINT HERE?
Quoted 121 lines
Quoted 121 lines
Quoted 121 lines
drivers/input/keyboard/samsung-keypad.c new file +121
-0+ goto err_disable_clk; + + input_dev->name = pdev->name; + input_dev->id.bustype =BUS_HOST ; + input_dev->dev.parent = &pdev->dev; + + input_dev->evbit[0 ] =BIT_MASK (EV_KEY ); +if (pdata->rep) + input_dev->evbit[0 ] |=BIT_MASK (EV_REP ); + + input_dev->keycode = keycodes; + input_dev->keycodesize =sizeof (*keycodes); + input_dev->keycodemax = pdata->rows << row_shift; + +matrix_keypad_build_keymap (keymap_data, row_shift, + input_dev->keycode, input_dev->keybit); + + ret =input_register_device (keypad->input_dev); +if (ret) + goto err_free_irq; + +platform_set_drvdata (pdev, keypad); +clk_disable (keypad->clk); + +return 0 ; + +err_free_irq: +free_irq (keypad->irq, keypad); +err_disable_clk: +clk_disable (keypad->clk); +clk_put (keypad->clk); +err_unmap_base: +iounmap (keypad->base); +err_free_mem: +input_free_device (input_dev); +kfree (keycodes); +kfree (keypad); + +return ret; +} + +static int __devexit samsung_kp_remove(struct platform_device *pdev) +{ +struct samsung_kp *keypad =platform_get_drvdata (pdev); + +free_irq (keypad->irq, keypad); +cancel_work_sync (&keypad->work); +del_timer_sync (&keypad->timer); + +platform_set_drvdata (pdev,NULL ); +input_unregister_device (keypad->input_dev); + +clk_disable (keypad->clk); +clk_put (keypad->clk); + +iounmap (keypad->base); +kfree (keypad->keycodes); +kfree (keypad); + +return 0 ; +} + +#ifdef CONFIG_PM +static int samsung_kp_suspend (struct device *dev) +{ +struct platform_device *pdev =to_platform_device (dev); +struct samsung_kp *keypad =platform_get_drvdata (pdev); + +disable_irq (keypad->irq); + +return 0 ; +} + +static int samsung_kp_resume (struct device pdev) +{ +struct platform_device *pdev =to_platform_device (dev); +struct samsung_kp *keypad =platform_get_drvdata (pdev); +unsigned int val; + +clk_enable (keypad->clk); + +/* enable interrupt and wakeup bit */ + val =SAMSUNG_INT_F_EN |SAMSUNG_INT_R_EN |SAMSUNG_WAKEUPEN ; +writel (val, keypad->base +SAMSUNG_KEYIFCON ); + +/* KEYIFCOL reg clear */ +writel (0 , keypad->base +SAMSUNG_KEYIFCOL ); + +enable_irq (keypad->irq); +clk_disable (keypad->clk); + +return 0 ; +} + +static const struct dev_pm_ops samsung_kp_pm_ops = { + .suspend = samsung_kp_suspend, + .resume = samsung_kp_resume, +}; +#endif + +static struct platform_driver samsung_kp_driver = { + .probe = samsung_kp_probe, + .remove =__devexit_p (samsung_kp_remove), + .driver = { + .name ="samsung-keypad" , + .owner =THIS_MODULE , +#ifdef CONFIG_PM + .pm = &samsung_kp_pm_ops, +#endif + }, +}; + +static int __init samsung_kp_init (void ) +{ +return platform_driver_register (&samsung_kp_driver); +} + +static void __exit samsung_kp_exit(void) +{ +platform_driver_unregister (&samsung_kp_driver); +}
Quoted 8 lines
Quoted 8 lines
drivers/input/keyboard/samsung-keypad.c line 364
Quoted 8 lines
drivers/input/keyboard/samsung-keypad.c new file +8
-0+ +module_init (samsung_kp_init); +module_exit (samsung_kp_exit); + +MODULE_DESCRIPTION ("Samsung keypad driver" ); +MODULE_AUTHOR ("Joonyoung Shim <[email protected]>" ); +MODULE_AUTHOR ("Donghwa Lee <[email protected]>" ); +MODULE_LICENSE ("GPL" );
You missed MODULE_ALIAS() for your platform device name
Signature · 4 lines
Ben Q: What's a light-year? A: One-third less calories than a regular year.
PATCH v2 5/5 input: samsung-keypad - Add samsung keypad driver
Quoted 10 lines · Ben Dooks
Quoted 5 lines · Joonyoung Shim
Quoted 5 lines
drivers/input/keyboard/samsung-keypad.c line 142
Quoted 5 lines
drivers/input/keyboard/samsung-keypad.c new file +5
-0+static void samsung_kp_timer (unsigned long data) +{ +struct samsung_kp *keypad = (struct samsung_kp *)data; + +schedule_work (&keypad->work);would
schedule_delayed_work()avoid the need for a timer here?
Right. I will use schedule_delayed_work().
Quoted 23 lines
Quoted 7 lines
Quoted 6 lines
drivers/input/keyboard/samsung-keypad.c line 182
Quoted 4 lines
drivers/input/keyboard/samsung-keypad.c new file +3
-0+ keypad =kzalloc (sizeof (*keypad),GFP_KERNEL ); + keycodes =kzalloc ((pdata->rows << row_shift) *sizeof (*keycodes), +GFP_KERNEL );you could allocate this in one go.
Hmm, how i do it? Do you mean to allocate keypad and keycodes together?
There's a couple of ways to do this, they may of course be not the nicest ways.
make the last entry of the first (know size) structure a unsized array. as so:
struct a { ... struct b t[]; }then do
struct a *my_a; my_a = kzalloc(sizeof(struct a ) + sizeof(struct b) * nr_b);
Quoted 7 lines
or by incrementing the pointer:
struct a *my_a; struct b *my_b; my_a = kzalloc(sizeof(struct a ) + sizeof(struct b) * nr_b); my_b = (struct b *)(my_a + 1);
I have modified such as follow:
- keypad = kzalloc(sizeof(*keypad), GFP_KERNEL);
- keycodes = kzalloc((pdata->rows << row_shift) * sizeof(*keycodes),
- GFP_KERNEL);
+ /* alloc with keycodes memory */
+ keypad = kzalloc(sizeof(*keypad) + sizeof(*keycodes) *
+ (pdata->rows << row_shift), GFP_KERNEL);
input_dev = input_allocate_device();
- if (!keypad || !keycodes || !input_dev) {
+ if (!keypad || !input_dev) { ret = -ENOMEM;
goto err_free_mem;
}
+ keycodes = (unsigned short *)(keypad + 1);
Quoted 5 lines
Quoted 1 line
Quoted 1 line
drivers/input/keyboard/samsung-keypad.c line 201
Quoted 1 line
drivers/input/keyboard/samsung-keypad.c new file +1
-0+ keypad->clk =clk_get (&pdev->dev,"keypad" );I'm going to get rid of this practice, it should be
clk_get(&pdev->dev, NULL), see up-comming clock changes.
It is not difficult to modify this if your clock changes are no problem.
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
drivers/input/keyboard/samsung-keypad.c line 235
Quoted 5 lines
drivers/input/keyboard/samsung-keypad.c new file +4
-0+ ret =request_irq (keypad->irq, samsung_kp_interrupt,0 , +dev_name (&pdev->dev), keypad); + +if (ret)NO PRINT HERE?
I will add.
Quoted 123 lines
Quoted 123 lines
Quoted 123 lines
Quoted 123 lines
drivers/input/keyboard/samsung-keypad.c new file +123
-0+ goto err_disable_clk; + + input_dev->name = pdev->name; + input_dev->id.bustype =BUS_HOST ; + input_dev->dev.parent = &pdev->dev; + + input_dev->evbit[0 ] =BIT_MASK (EV_KEY ); +if (pdata->rep) + input_dev->evbit[0 ] |=BIT_MASK (EV_REP ); + + input_dev->keycode = keycodes; + input_dev->keycodesize =sizeof (*keycodes); + input_dev->keycodemax = pdata->rows << row_shift; + +matrix_keypad_build_keymap (keymap_data, row_shift, + input_dev->keycode, input_dev->keybit); + + ret =input_register_device (keypad->input_dev); +if (ret) + goto err_free_irq; + +platform_set_drvdata (pdev, keypad); +clk_disable (keypad->clk); + +return 0 ; + +err_free_irq: +free_irq (keypad->irq, keypad); +err_disable_clk: +clk_disable (keypad->clk); +clk_put (keypad->clk); +err_unmap_base: +iounmap (keypad->base); +err_free_mem: +input_free_device (input_dev); +kfree (keycodes); +kfree (keypad); + +return ret; +} + +static int __devexit samsung_kp_remove(struct platform_device *pdev) +{ +struct samsung_kp *keypad =platform_get_drvdata (pdev); + +free_irq (keypad->irq, keypad); +cancel_work_sync (&keypad->work); +del_timer_sync (&keypad->timer); + +platform_set_drvdata (pdev,NULL ); +input_unregister_device (keypad->input_dev); + +clk_disable (keypad->clk); +clk_put (keypad->clk); + +iounmap (keypad->base); +kfree (keypad->keycodes); +kfree (keypad); + +return 0 ; +} + +#ifdef CONFIG_PM +static int samsung_kp_suspend (struct device *dev) +{ +struct platform_device *pdev =to_platform_device (dev); +struct samsung_kp *keypad =platform_get_drvdata (pdev); + +disable_irq (keypad->irq); + +return 0 ; +} + +static int samsung_kp_resume (struct device pdev) +{ +struct platform_device *pdev =to_platform_device (dev); +struct samsung_kp *keypad =platform_get_drvdata (pdev); +unsigned int val; + +clk_enable (keypad->clk); + +/* enable interrupt and wakeup bit */ + val =SAMSUNG_INT_F_EN |SAMSUNG_INT_R_EN |SAMSUNG_WAKEUPEN ; +writel (val, keypad->base +SAMSUNG_KEYIFCON ); + +/* KEYIFCOL reg clear */ +writel (0 , keypad->base +SAMSUNG_KEYIFCOL ); + +enable_irq (keypad->irq); +clk_disable (keypad->clk); + +return 0 ; +} + +static const struct dev_pm_ops samsung_kp_pm_ops = { + .suspend = samsung_kp_suspend, + .resume = samsung_kp_resume, +}; +#endif + +static struct platform_driver samsung_kp_driver = { + .probe = samsung_kp_probe, + .remove =__devexit_p (samsung_kp_remove), + .driver = { + .name ="samsung-keypad" , + .owner =THIS_MODULE , +#ifdef CONFIG_PM + .pm = &samsung_kp_pm_ops, +#endif + }, +}; + +static int __init samsung_kp_init (void ) +{ +return platform_driver_register (&samsung_kp_driver); +} + +static void __exit samsung_kp_exit(void) +{ +platform_driver_unregister (&samsung_kp_driver); +} + +module_init (samsung_kp_init);
Quoted 9 lines
Quoted 6 lines
Quoted 6 lines
drivers/input/keyboard/samsung-keypad.c line 364
Quoted 6 lines
drivers/input/keyboard/samsung-keypad.c new file +6
-0+module_exit (samsung_kp_exit); + +MODULE_DESCRIPTION ("Samsung keypad driver" ); +MODULE_AUTHOR ("Joonyoung Shim <[email protected]>" ); +MODULE_AUTHOR ("Donghwa Lee <[email protected]>" ); +MODULE_LICENSE ("GPL" );You missed
MODULE_ALIAS()for your platform device name
I will add.
Thanks.
PATCH v2 5/5 input: samsung-keypad - Add samsung keypad driver
In reply to Ben DooksHello,
Quoted 5 lines · Ben Dooks
Quoted 1 line
Quoted 1 line
drivers/input/keyboard/samsung-keypad.c line 201
Quoted 1 line
drivers/input/keyboard/samsung-keypad.c new file +1
-0+ keypad->clk =clk_get (&pdev->dev,"keypad" );I'm going to get rid of this practice, it should be
clk_get(&pdev->dev, NULL),
see up-comming clock changes.
Good idea, but how do you want to handle some special/additional clocks? Like for example mmc_bus or fimc_sclk clocks?
Best regards
--
Marek Szyprowski
Samsung Poland R&D Center
PATCH v2 1/5 ARM: SAMSUNG: Add keypad device support
In reply to Joonyoung ShimDne Ne 30. kv?tna 2010 05:06:20 Joonyoung Shim napsal(a):
Quoted 151 lines
This patch adds samsung keypad device definition for samsung cpus.
Signed-off-by Joonyoung Shim <[email protected]>Signed-off-by Kyungmin Park <[email protected]>--- arch/arm/plat-samsung/Kconfig | 7 ++- arch/arm/plat-samsung/Makefile | 1 + arch/arm/plat-samsung/dev-keypad.c | 50 +++++++++++++++++++ arch/arm/plat-samsung/include/plat/devs.h | 2 + arch/arm/plat-samsung/include/plat/keypad.h | 57 ++++++++++++++++++++++ arch/arm/plat-samsung/include/plat/regs-keypad.h | 49 +++++++++++++++++++ 6 files changed, 165 insertions(+), 1 deletions(-) create mode 100644 arch/arm/plat-samsung/dev-keypad.c create mode 100644 arch/arm/plat-samsung/include/plat/keypad.h create mode 100644 arch/arm/plat-samsung/include/plat/regs-keypad.harch/arm/plat-samsung/Kconfig +6
-1@@ -225,7 +225,12 @@ config S3C64XX_DEV_SPI config SAMSUNG_DEV_TS bool help - Common in platform device definitions for touchscreen device + Common in platform device definitions for touchscreen device + +config SAMSUNG_DEV_KEYPAD + bool + help + Compile in platform device definitions for keypad # DMA(quoted diff) +0
-0b/arch/arm/plat-samsung/Makefile index 228c2ad..ef00c47 100644
arch/arm/plat-samsung/Makefile +1
-0@@ -50,6 +50,7 @@ obj-$(CONFIG_S3C_DEV_RTC) += dev-rtc.o obj-$(CONFIG_SAMSUNG_DEV_ADC) += dev-adc.o obj-$(CONFIG_SAMSUNG_DEV_TS) += dev-ts.o +obj-$(CONFIG_SAMSUNG_DEV_KEYPAD) += dev-keypad.o # DMA support(quoted diff) +0
-0
b/arch/arm/plat-samsung/dev-keypad.cnew file mode 100644 index 0000000..70e2e2darch/arm/plat-samsung/dev-keypad.c new file +7
-0@@ -0,0 +1,50 @@ +/* +* linux/arch/arm/plat-samsung/dev-keypad.c +* +* Copyright (C) 2010 Samsung Electronics Co.Ltd +* Author: Joonyoung Shim <[email protected]> +* +* This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version.
+ *
+ */arch/arm/plat-samsung/dev-keypad.c new file +38
-0+ +#include <linux/platform_device.h> +#include <mach/irqs.h> +#include <mach/map.h> +#include <plat/cpu.h> +#include <plat/devs.h> +#include <plat/keypad.h> + +static struct resource samsung_kp_resources[] = { + [0 ] = { + .start =SAMSUNG_PA_KEYPAD , + .end =SAMSUNG_PA_KEYPAD +0x20 -1 , + .flags =IORESOURCE_MEM , + }, + [1 ] = { + .start =IRQ_KEYPAD , + .end =IRQ_KEYPAD , + .flags =IORESOURCE_IRQ , + }, +}; + +struct platform_device samsung_device_keypad = { + .name ="samsung-keypad" , + .id =-1 , + .num_resources =ARRAY_SIZE (samsung_kp_resources), + .resource = samsung_kp_resources, +}; + +void __init samsung_kp_set_platdata (struct samsung_kp_platdata *pd) +{ +struct samsung_kp_platdata *npd; + + npd =s3c_set_platdata (pd,sizeof (struct samsung_kp_platdata ), + &samsung_device_keypad); + +if (!npd->cfg_gpio) + npd->cfg_gpio = samsung_keypad_cfg_gpio; +}(quoted diff) +0
-0
b/arch/arm/plat-samsung/include/plat/devs.hindex 6760999..c06386b 100644arch/arm/plat-samsung/include/plat/devs.h +2
-0@@ -100,6 +100,8 @@ extern struct platform_device s5pc100_device_iis0;extern struct platform_device s5pc100_device_iis1;extern struct platform_device s5pc100_device_iis2; +extern struct platform_device samsung_device_keypad; +/* s3c2440 specific devices */ #ifdef CONFIG_CPU_S3C2440 (quoted diff) +0
-0
b/arch/arm/plat-samsung/include/plat/keypad.hnew file mode 100644 index 0000000..d144f42arch/arm/plat-samsung/include/plat/keypad.h new file +9
-0@@ -0,0 +1,57 @@ +/* +* linux/arch/arm/plat-samsung/include/plat/keypad.h +* +* Copyright (C) 2010 Samsung Electronics Co.Ltd +* Author: Joonyoung Shim <[email protected]> +* +* Samsung Platform - Keypad platform data definitions +* +* This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version.
+ *
+ */arch/arm/plat-samsung/include/plat/keypad.h new file +15
-0+ +#ifndef __PLAT_SAMSUNG_KEYPAD_H +#define __PLAT_SAMSUNG_KEYPAD_H + +#include <linux/input/matrix_keypad.h> + +#define SAMSUNG_MAX_ROWS 8 +#define SAMSUNG_MAX_COLS 8 + +/** +* struct samsung_kp_platdata() - Platform device data for Samsung Keypad +* @keymap_data: pointer to &matrix_keymap_data +* @rows: number of keypad row supported. +* @cols: number of keypad col supported. +* @rep: flag for repeat setting.
arch/arm/plat-samsung/include/plat/keypad.h line 39
Quoted 10 lines
arch/arm/plat-samsung/include/plat/keypad.h new file +10
-0+* @cfg_gpio: configure the GPIO. +* +* Initialisation data specific to either the machine or the platform +* for the device driver to use or call-back when configuring gpio. +*/ +struct samsung_kp_platdata { +const struct matrix_keymap_data *keymap_data; +unsigned int rows; +unsigned int cols; +unsigned int rep;
I don't know, maybe using uint32_t here? On ARM, it doesn't matter so far as int will be always 32bit, but maybe we should just type the variables well ?
Guys, what do you think ?
Otherwise this change looks ok to me.
Quoted 73 lines
arch/arm/plat-samsung/include/plat/keypad.h new file +18
-0+ + void (*cfg_gpio)(unsigned int rows, unsigned int cols); +}; + +/** +* samsung_kp_set_platdata - Set platform data for Samsung Keypad device. +* @pd: Platform data to register to device. +* +* Register the given platform data for use with Samsung Keypad device. +* The call will copy the platform data, so the board definitions can +* make the structure itself __initdata. +*/ +extern void samsung_kp_set_platdata (struct samsung_kp_platdata *pd); + +/* defined by architecture to configure gpio */ +extern void samsung_keypad_cfg_gpio (unsigned int rows,unsigned int cols); + +#endif /* __PLAT_SAMSUNG_KEYPAD_H */ (quoted diff) +0
-0
b/arch/arm/plat-samsung/include/plat/regs-keypad.hnew file mode 100644 index 0000000..1a8c046arch/arm/plat-samsung/include/plat/regs-keypad.h new file +7
-0@@ -0,0 +1,49 @@ +/* +* linux/arch/arm/plat-samsung/include/plat/regs-keypad.h +* +* Copyright (C) 2010 Samsung Electronics Co.Ltd +* Author: Joonyoung Shim <[email protected]> +* +* This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version.
+ *
+ */arch/arm/plat-samsung/include/plat/regs-keypad.h new file +37
-0+ +#ifndef __SAMSUNG_KEYPAD_H__ +#define __SAMSUNG_KEYPAD_H__ + +#define SAMSUNG_KEYIFCON 0x00 +#define SAMSUNG_KEYIFSTSCLR 0x04 +#define SAMSUNG_KEYIFCOL 0x08 +#define SAMSUNG_KEYIFROW 0x0c +#define SAMSUNG_KEYIFFC 0x10 + +/* SAMSUNG_KEYIFCON */ +#define SAMSUNG_INT_F_EN (1 << 0) +#define SAMSUNG_INT_R_EN (1 << 1) +#define SAMSUNG_DF_EN (1 << 2) +#define SAMSUNG_FC_EN (1 << 3) +#define SAMSUNG_WAKEUPEN (1 << 4) + +/* SAMSUNG_KEYIFSTSCLR */ +#define SAMSUNG_P_INT_MASK (0xff << 0) +#define SAMSUNG_R_INT_MASK (0xff << 8) +#define SAMSUNG_R_INT_OFFSET 8 +#define S5PV210_P_INT_MASK (0x3fff << 0) +#define S5PV210_R_INT_MASK (0x3fff << 16) +#define S5PV210_R_INT_OFFSET 16 + +/* SAMSUNG_KEYIFCOL */ +#define SAMSUNG_KEYIFCOL_MASK (0xff << 0) +#define S5PV210_KEYIFCOLEN_MASK (0xff << 8) + +/* SAMSUNG_KEYIFROW */ +#define SAMSUNG_KEYIFROW_MASK (0xff << 0) +#define S5PV210_KEYIFROW_MASK (0x3fff << 0) + +/* SAMSUNG_KEYIFFC */ +#define SAMSUNG_KEYIFFC_MASK (0x3ff << 0) + +#endif /* __SAMSUNG_KEYPAD_H__ */
PATCH v2 1/5 ARM: SAMSUNG: Add keypad device support
Quoted 9 lines · Marek Vasut
Dne Ne 30. kv?tna 2010 05:06:20 Joonyoung Shim napsal(a):
Quoted 5 lines
+struct
samsung_kp_platdata{
+ ? ? const structmatrix_keymap_data*keymap_data;
+ ? ? unsigned int ? ? ? ? ? ?rows;
+ ? ? unsigned int ? ? ? ? ? ?cols;
+ ? ? unsigned int ? ? ? ? ? ?rep;I don't know, maybe using
uint32_there? On ARM, it doesn't matter so far as int will be always 32bit, but maybe we should just type the variables well ?
I thought int was 32bits on all archs
PATCH v2 1/5 ARM: SAMSUNG: Add keypad device support
Quoted 8 lines · Jassi Brar
Quoted 7 lines · Marek Vasut
Dne Ne 30. kv??tna 2010 05:06:20 Joonyoung Shim napsal(a):
Quoted 5 lines
+struct
samsung_kp_platdata{
+ ? ? const structmatrix_keymap_data*keymap_data;
+ ? ? unsigned int ? ? ? ? ? ?rows;
+ ? ? unsigned int ? ? ? ? ? ?cols;
+ ? ? unsigned int ? ? ? ? ? ?rep;
Quoted 4 lines
Quoted 2 lines
I don't know, maybe using
uint32_there? On ARM, it doesn't matter so far as int will be always 32bit, but maybe we should just type the variables well ?I thought int was 32bits on all archs
No, the C standard doesn't make any guarantees about the size of types, it is up to the implementation of the compiler. If I rember correctly the only guarantee in the lanugage definition is that char->short->int->long be that the next up the line be at-least as a big as the one before.
For this, unsigned int should be fine. unsigned short would probably be fine too. I'm not going to worry too much about this.
Signature · 4 lines
Ben Q: What's a light-year? A: One-third less calories than a regular year.
PATCH v2 1/5 ARM: SAMSUNG: Add keypad device support
Quoted 12 lines · Ben Dooks
Quoted 11 lines · Jassi Brar
Quoted 9 lines · Marek Vasut
Dne Ne 30. kv??tna 2010 05:06:20 Joonyoung Shim napsal(a):
Quoted 5 lines
+struct
samsung_kp_platdata{
+ ? ? const structmatrix_keymap_data*keymap_data;
+ ? ? unsigned int ? ? ? ? ? ?rows;
+ ? ? unsigned int ? ? ? ? ? ?cols;
+ ? ? unsigned int ? ? ? ? ? ?rep;I don't know, maybe using
uint32_there? On ARM, it doesn't matter so far as int will be always 32bit, but maybe we should just type the variables well ?
Quoted 6 lines
Quoted 1 line
I thought int was 32bits on all archs
No, the C standard doesn't make any guarantees about the size of types, it is up to the implementation of the compiler. If I rember correctly the only guarantee in the lanugage definition is that
char->short->int->longbe that the next up the line be at-least as a ?big as the one before.
I believe on most implementations, if not all, sizeof char, short and int are resp
1, 2 and 4 bytes. whereas long denotes the native capacity of the arch.
PATCH v2 1/5 ARM: SAMSUNG: Add keypad device support
Quoted 15 lines · Jassi Brar
Quoted 14 lines · Ben Dooks
Quoted 12 lines · Jassi Brar
Quoted 9 lines · Marek Vasut
Dne Ne 30. kv??tna 2010 05:06:20 Joonyoung Shim napsal(a):
Quoted 5 lines
+struct
samsung_kp_platdata{
+ ? ? const structmatrix_keymap_data*keymap_data;
+ ? ? unsigned int ? ? ? ? ? ?rows;
+ ? ? unsigned int ? ? ? ? ? ?cols;
+ ? ? unsigned int ? ? ? ? ? ?rep;I don't know, maybe using
uint32_there? On ARM, it doesn't matter so far as int will be always 32bit, but maybe we should just type the variables well ?I thought int was 32bits on all archs
Quoted 7 lines
Quoted 4 lines
No, the C standard doesn't make any guarantees about the size of types, it is up to the implementation of the compiler. If I rember correctly the only guarantee in the lanugage definition is that
char->short->int->longbe that the next up the line be at-least as a ?big as the one before.I believe on most implementations, if not all, sizeof char, short and int are resp
1, 2 and 4 bytes. whereas long denotes the native capacity of the arch.
Mostly, but that is up to the compiler/arch combination, not defined by the main C standard. It may be defned by the arch C standard.
Signature · 4 lines
Ben Q: What's a light-year? A: One-third less calories than a regular year.
PATCH v2 1/5 ARM: SAMSUNG: Add keypad device support
In reply to Jassi BrarQuoted 3 lines · Jassi Brar
I believe on most implementations, if not all, sizeof char, short and int are resp
1, 2 and 4 bytes. whereas long denotes the native capacity of the arch.
This is very common for interoperability with code making the assumption that you just made but you shouldn't rely on it, the C standard just specifies minimum sizes and requires that char <= short <= int <= long. The common issues to run into are int being made the native word size and not having any sub word types@all.
Dmitry Torokhov
maintainerPATCH v2 1/5 ARM: SAMSUNG: Add keypad device support
In reply to Marek VasutQuoted 11 lines · Marek Vasut
Dne Ne 30. kv?tna 2010 05:06:20 Joonyoung Shim napsal(a):
arch/arm/plat-samsung/include/plat/keypad.h line 39
Quoted 6 lines
+ */
arch/arm/plat-samsung/include/plat/keypad.h new file +5
-0+struct samsung_kp_platdata { +const struct matrix_keymap_data *keymap_data; +unsigned int rows; +unsigned int cols; +unsigned int rep;I don't know, maybe using
uint32_there? On ARM, it doesn't matter so far as int will be always 32bit, but maybe we should just type the variables well ?
Quoted 2 lines
Guys, what do you think ?
I think unsigned int is fine, we do not care about particular size, just need "big enough". I'd change 'rep' to be a boolean though.
Thanks.
Signature · 1 line
Dmitry
PATCH v2 1/5 ARM: SAMSUNG: Add keypad device support
Quoted 11 lines · Dmitry Torokhov
Quoted 10 lines · Marek Vasut
Dne Ne 30. kv?tna 2010 05:06:20 Joonyoung Shim napsal(a):
arch/arm/plat-samsung/include/plat/keypad.h line 39
Quoted 6 lines
+ */
arch/arm/plat-samsung/include/plat/keypad.h new file +5
-0+struct samsung_kp_platdata { +const struct matrix_keymap_data *keymap_data; +unsigned int rows; +unsigned int cols; +unsigned int rep;I don't know, maybe using
uint32_there? On ARM, it doesn't matter so far as int will be always 32bit, but maybe we should just type the variables well ?
Quoted 6 lines
Quoted 2 lines
Guys, what do you think ?
I think unsigned int is fine, we do not care about particular size, just need "big enough". I'd change 'rep' to be a boolean though.
I will modify 'rep' to unsinged int rep:1;
PATCH v2 1/5 ARM: SAMSUNG: Add keypad device support
In reply to Joonyoung ShimQuoted 5 lines · Joonyoung Shim
This patch adds samsung keypad device definition for samsung cpus.
Signed-off-by Joonyoung Shim <[email protected]>Signed-off-by Kyungmin Park <[email protected]>
Quoted 9 lines
--- arch/arm/plat-samsung/Kconfig | 7 ++- arch/arm/plat-samsung/Makefile | 1 + arch/arm/plat-samsung/dev-keypad.c | 50 +++++++++++++++++++ arch/arm/plat-samsung/include/plat/devs.h | 2 + arch/arm/plat-samsung/include/plat/keypad.h | 57 ++++++++++++++++++++++ arch/arm/plat-samsung/include/plat/regs-keypad.h | 49
+++++++++++++++++++
Quoted 10 lines
6 files changed, 165 insertions(+), 1 deletions(-) create mode 100644 arch/arm/plat-samsung/dev-keypad.c create mode 100644 arch/arm/plat-samsung/include/plat/keypad.h create mode 100644 arch/arm/plat-samsung/include/plat/regs-keypad.harch/arm/plat-samsung/Kconfig +0
-0
arch/arm/plat-samsung/Kconfig config S3C64XX_DEV_SPI · line 229
Quoted 6 lines
arch/arm/plat-samsung/Kconfig +2
-1@@ -225,7 +225,12 @@ config S3C64XX_DEV_SPI config SAMSUNG_DEV_TS bool help - Common in platform device definitions for touchscreen device + Common in platform device definitions for touchscreen device +
Above changing is not for keypad.
Review
Quoted 8 lines
arch/arm/plat-samsung/Kconfig +4
-0+config SAMSUNG_DEV_KEYPAD + bool + help + Compile in platform device definitions for keypad # DMA(quoted diff) +0
-0
b/arch/arm/plat-samsung/Makefile
Review
Quoted 12 lines
index 228c2ad..ef00c47 100644
arch/arm/plat-samsung/Makefile +1
-0@@ -50,6 +50,7 @@ obj-$(CONFIG_S3C_DEV_RTC) += dev-rtc.o obj-$(CONFIG_SAMSUNG_DEV_ADC) += dev-adc.o obj-$(CONFIG_SAMSUNG_DEV_TS) += dev-ts.o +obj-$(CONFIG_SAMSUNG_DEV_KEYPAD) += dev-keypad.o # DMA support(quoted diff) +0
-0
b/arch/arm/plat-samsung/dev-
arch/arm/plat-samsung/dev-keypad.c line 7
Quoted 13 lines
keypad.c
new file mode 100644
index 0000000..70e2e2darch/arm/plat-samsung/dev-keypad.c new file +7
-0@@ -0,0 +1,50 @@ +/* +* linux/arch/arm/plat-samsung/dev-keypad.c +* +* Copyright (C) 2010 Samsung Electronics Co.Ltd +* Author: Joonyoung Shim <[email protected]> +* +* This program is free software; you can redistribute it and/or modify
it
arch/arm/plat-samsung/dev-keypad.c line 8
Quoted 1 line
arch/arm/plat-samsung/dev-keypad.c new file +1
-0+* under the terms of the GNU General Public License as published by
the
arch/arm/plat-samsung/dev-keypad.c line 9
Quoted 1 line
arch/arm/plat-samsung/dev-keypad.c new file +1
-0+* Free Software Foundation; either version 2 of the License, or (at
your
arch/arm/plat-samsung/dev-keypad.c line 21
Quoted 12 lines
arch/arm/plat-samsung/dev-keypad.c new file +12
-0+* option) any later version. +* +*/ + +#include <linux/platform_device.h> +#include <mach/irqs.h> +#include <mach/map.h> +#include <plat/cpu.h> +#include <plat/devs.h> +#include <plat/keypad.h> + +static struct resource samsung_kp_resources[] = {
How about samsung_keypad_resources easily to reading?
Quoted 50 lines
arch/arm/plat-samsung/dev-keypad.c new file +29
-0+ [0 ] = { + .start =SAMSUNG_PA_KEYPAD , + .end =SAMSUNG_PA_KEYPAD +0x20 -1 , + .flags =IORESOURCE_MEM , + }, + [1 ] = { + .start =IRQ_KEYPAD , + .end =IRQ_KEYPAD , + .flags =IORESOURCE_IRQ , + }, +}; + +struct platform_device samsung_device_keypad = { + .name ="samsung-keypad" , + .id =-1 , + .num_resources =ARRAY_SIZE (samsung_kp_resources), + .resource = samsung_kp_resources, +}; + +void __init samsung_kp_set_platdata (struct samsung_kp_platdata *pd) +{ +struct samsung_kp_platdata *npd; + + npd =s3c_set_platdata (pd,sizeof (struct samsung_kp_platdata ), + &samsung_device_keypad); + +if (!npd->cfg_gpio) + npd->cfg_gpio = samsung_keypad_cfg_gpio; +}arch/arm/plat- renamed from arch/arm/plat-samsung/include/plat/devs.h +0
-0
samsung/include/plat/devs.h
index 6760999..c06386b 100644arch/arm/plat-samsung/include/plat/devs.h +2
-0@@ -100,6 +100,8 @@ extern struct platform_device s5pc100_device_iis0;extern struct platform_device s5pc100_device_iis1;extern struct platform_device s5pc100_device_iis2; +extern struct platform_device samsung_device_keypad; +/* s3c2440 specific devices */ #ifdef CONFIG_CPU_S3C2440 arch/arm/plat- renamed from arch/arm/plat-samsung/include/plat/keypad.h +0
-0
samsung/include/plat/keypad.h
new file mode 100644
index 0000000..d144f42
arch/arm/plat-samsung/include/plat/keypad.h line 9
Quoted 9 lines
arch/arm/plat-samsung/include/plat/keypad.h new file +9
-0@@ -0,0 +1,57 @@ +/* +* linux/arch/arm/plat-samsung/include/plat/keypad.h +* +* Copyright (C) 2010 Samsung Electronics Co.Ltd +* Author: Joonyoung Shim <[email protected]> +* +* Samsung Platform - Keypad platform data definitions +* +* This program is free software; you can redistribute it and/or modify
it
arch/arm/plat-samsung/include/plat/keypad.h line 10
Quoted 1 line
arch/arm/plat-samsung/include/plat/keypad.h new file +1
-0+* under the terms of the GNU General Public License as published by
the
arch/arm/plat-samsung/include/plat/keypad.h line 11
Quoted 1 line
arch/arm/plat-samsung/include/plat/keypad.h new file +1
-0+* Free Software Foundation; either version 2 of the License, or (at
your
arch/arm/plat-samsung/include/plat/keypad.h line 22
Quoted 11 lines
arch/arm/plat-samsung/include/plat/keypad.h new file +11
-0+* option) any later version. +* +*/ + +#ifndef __PLAT_SAMSUNG_KEYPAD_H +#define __PLAT_SAMSUNG_KEYPAD_H + +#include <linux/input/matrix_keypad.h> + +#define SAMSUNG_MAX_ROWS 8 +#define SAMSUNG_MAX_COLS 8
Is the MAX really 8?
S5PV210 & S5PC110 has 2 slots supporting 14 rows * 8 columns and 8 rows * 8 columns.
So just SAMSUNG_KEYPAD_ROWS is 8.
Review
Quoted 36 lines
arch/arm/plat-samsung/include/plat/keypad.h new file +35
-0+ +/** +* struct samsung_kp_platdata() - Platform device data for Samsung Keypad +* @keymap_data: pointer to &matrix_keymap_data +* @rows: number of keypad row supported. +* @cols: number of keypad col supported. +* @rep: flag for repeat setting. +* @cfg_gpio: configure the GPIO. +* +* Initialisation data specific to either the machine or the platform +* for the device driver to use or call-back when configuring gpio. +*/ +struct samsung_kp_platdata { +const struct matrix_keymap_data *keymap_data; +unsigned int rows; +unsigned int cols; +unsigned int rep; + +void (*cfg_gpio)(unsigned int rows,unsigned int cols); +}; + +/** +* samsung_kp_set_platdata - Set platform data for Samsung Keypad device. +* @pd: Platform data to register to device. +* +* Register the given platform data for use with Samsung Keypad device. +* The call will copy the platform data, so the board definitions can +* make the structure itself __initdata. +*/ +extern void samsung_kp_set_platdata (struct samsung_kp_platdata *pd); + +/* defined by architecture to configure gpio */ +extern void samsung_keypad_cfg_gpio (unsigned int rows,unsigned int cols); + +#endif /* __PLAT_SAMSUNG_KEYPAD_H */ (quoted diff) +0
-0
b/arch/arm/plat-
arch/arm/plat-samsung/include/plat/regs-keypad.h line 7
Quoted 13 lines
samsung/include/plat/regs-keypad.h
new file mode 100644
index 0000000..1a8c046arch/arm/plat-samsung/include/plat/regs-keypad.h new file +7
-0@@ -0,0 +1,49 @@ +/* +* linux/arch/arm/plat-samsung/include/plat/regs-keypad.h +* +* Copyright (C) 2010 Samsung Electronics Co.Ltd +* Author: Joonyoung Shim <[email protected]> +* +* This program is free software; you can redistribute it and/or modify
it
arch/arm/plat-samsung/include/plat/regs-keypad.h line 8
Quoted 1 line
arch/arm/plat-samsung/include/plat/regs-keypad.h new file +1
-0+* under the terms of the GNU General Public License as published by
the
arch/arm/plat-samsung/include/plat/regs-keypad.h line 9
Quoted 1 line
arch/arm/plat-samsung/include/plat/regs-keypad.h new file +1
-0+* Free Software Foundation; either version 2 of the License, or (at
your
Quoted 9 lines
arch/arm/plat-samsung/include/plat/regs-keypad.h new file +9
-0+* option) any later version. +* +*/ + +#ifndef __SAMSUNG_KEYPAD_H__ +#define __SAMSUNG_KEYPAD_H__ + +#define SAMSUNG_KEYIFCON 0x00 +#define SAMSUNG_KEYIFSTSCLR 0x04
arch/arm/plat-samsung/include/plat/regs-keypad.h line 28
Quoted 10 lines
arch/arm/plat-samsung/include/plat/regs-keypad.h new file +10
-0+#define SAMSUNG_KEYIFCOL 0x08 +#define SAMSUNG_KEYIFROW 0x0c +#define SAMSUNG_KEYIFFC 0x10 + +/* SAMSUNG_KEYIFCON */ +#define SAMSUNG_INT_F_EN (1 << 0) +#define SAMSUNG_INT_R_EN (1 << 1) +#define SAMSUNG_DF_EN (1 << 2) +#define SAMSUNG_FC_EN (1 << 3) +#define SAMSUNG_WAKEUPEN (1 << 4)
Needs KEYIF in the definition name for avoid confusing.
Quoted 22 lines
arch/arm/plat-samsung/include/plat/regs-keypad.h new file +21
-1+ +/* SAMSUNG_KEYIFSTSCLR */ +#define SAMSUNG_P_INT_MASK (0xff << 0) +#define SAMSUNG_R_INT_MASK (0xff << 8) +#define SAMSUNG_R_INT_OFFSET 8 +#define S5PV210_P_INT_MASK (0x3fff << 0) +#define S5PV210_R_INT_MASK (0x3fff << 16) +#define S5PV210_R_INT_OFFSET 16 + +/* SAMSUNG_KEYIFCOL */ +#define SAMSUNG_KEYIFCOL_MASK (0xff << 0) +#define S5PV210_KEYIFCOLEN_MASK (0xff << 8) + +/* SAMSUNG_KEYIFROW */ +#define SAMSUNG_KEYIFROW_MASK (0xff << 0) +#define S5PV210_KEYIFROW_MASK (0x3fff << 0) + +/* SAMSUNG_KEYIFFC */ +#define SAMSUNG_KEYIFFC_MASK (0x3ff << 0) + +#endif /* __SAMSUNG_KEYPAD_H__ */ --
Quoted 1 line
1.7.0.4
Thanks.
Best regards,
Kgene.
--
Kukjin Kim <[email protected]>, Senior Engineer, SW Solution Development Team, Samsung Electronics Co., Ltd.
PATCH v2 1/5 ARM: SAMSUNG: Add keypad device support
Dne Po 31. kv?tna 2010 02:06:48 Kukjin Kim napsal(a):
Quoted 96 lines
Quoted 10 lines · Joonyoung Shim
This patch adds samsung keypad device definition for samsung cpus.
Signed-off-by Joonyoung Shim <[email protected]>Signed-off-by Kyungmin Park <[email protected]>---
arch/arm/plat-samsung/Kconfig | 7 ++- arch/arm/plat-samsung/Makefile | 1 + arch/arm/plat-samsung/dev-keypad.c | 50Quoted 8 lines
+++++++++++++++++++
arch/arm/plat-samsung/include/plat/devs.h | 2 + arch/arm/plat-samsung/include/plat/keypad.h | 57++++++++++++++++++++++
arch/arm/plat-samsung/include/plat/regs-keypad.h | 49+++++++++++++++++++
Quoted 10 lines
6 files changed, 165 insertions(+), 1 deletions(-) create mode 100644 arch/arm/plat-samsung/dev-keypad.c create mode 100644 arch/arm/plat-samsung/include/plat/keypad.h create mode 100644 arch/arm/plat-samsung/include/plat/regs-keypad.h(quoted diff) +0
-0b/arch/arm/plat-samsung/Kconfig index 2753fb3..3ef2df7 100644
arch/arm/plat-samsung/Kconfig config S3C64XX_DEV_SPI · line 232
Quoted 9 lines
arch/arm/plat-samsung/Kconfig +2
-1@@ -225,7 +225,12 @@ config S3C64XX_DEV_SPI config SAMSUNG_DEV_TS bool help - Common in platform device definitions for touchscreen device + Common in platform device definitions for touchscreen device +Above changing is not for keypad.
Review
Quoted 8 lines
arch/arm/plat-samsung/Kconfig +4
-0+config SAMSUNG_DEV_KEYPAD + bool + help + Compile in platform device definitions for keypad# DMA
(quoted diff) +0
-0b/arch/arm/plat-samsung/Makefile
Review
Quoted 13 lines
index 228c2ad..ef00c47 100644
arch/arm/plat-samsung/Makefile +1
-0@@ -50,6 +50,7 @@ obj-$(CONFIG_S3C_DEV_RTC) += dev-rtc.o obj-$(CONFIG_SAMSUNG_DEV_ADC) += dev-adc.o obj-$(CONFIG_SAMSUNG_DEV_TS) += dev-ts.o +obj-$(CONFIG_SAMSUNG_DEV_KEYPAD) += dev-keypad.o # DMA support(quoted diff) +0
-0b/arch/arm/plat-samsung/dev-
Quoted 13 lines
keypad.c
new file mode 100644
index 0000000..70e2e2darch/arm/plat-samsung/dev-keypad.c new file +7
-0@@ -0,0 +1,50 @@ +/* +* linux/arch/arm/plat-samsung/dev-keypad.c +* +* Copyright (C) 2010 Samsung Electronics Co.Ltd +* Author: Joonyoung Shim <[email protected]> +* +* This program is free software; you can redistribute it and/or Quoted 1 line
modify
it
Quoted 1 line
+ * under the terms of the GNU General Public License as published by
the
Quoted 1 line
+ * Free Software Foundation; either version 2 of the License, or (at
your
Quoted 14 lines
arch/arm/plat-samsung/dev-keypad.c line 21
Quoted 12 lines
+ * option) any later version.
+ *
+ */arch/arm/plat-samsung/dev-keypad.c new file +9
-0+ +#include <linux/platform_device.h> +#include <mach/irqs.h> +#include <mach/map.h> +#include <plat/cpu.h> +#include <plat/devs.h> +#include <plat/keypad.h> + +static struct resource samsung_kp_resources[] = {How about
samsung_keypad_resourceseasily to reading?
IMO doesn't matter ... kp is fine and it's well known acronym anyway.
Quoted 89 lines
Quoted 63 lines
arch/arm/plat-samsung/dev-keypad.c new file +29
-0+ [0 ] = { + .start =SAMSUNG_PA_KEYPAD , + .end =SAMSUNG_PA_KEYPAD +0x20 -1 , + .flags =IORESOURCE_MEM , + }, + [1 ] = { + .start =IRQ_KEYPAD , + .end =IRQ_KEYPAD , + .flags =IORESOURCE_IRQ , + }, +}; + +struct platform_device samsung_device_keypad = { + .name ="samsung-keypad" , + .id =-1 , + .num_resources =ARRAY_SIZE (samsung_kp_resources), + .resource = samsung_kp_resources, +}; + +void __init samsung_kp_set_platdata (struct samsung_kp_platdata *pd) +{ +struct samsung_kp_platdata *npd; + + npd =s3c_set_platdata (pd,sizeof (struct samsung_kp_platdata ), + &samsung_device_keypad); + +if (!npd->cfg_gpio) + npd->cfg_gpio = samsung_keypad_cfg_gpio; +}arch/arm/plat- renamed from arch/arm/plat-samsung/include/plat/devs.h +0
-0
samsung/include/plat/devs.h
index 6760999..c06386b 100644arch/arm/plat-samsung/include/plat/devs.h +2
-0@@ -100,6 +100,8 @@ extern struct platform_device s5pc100_device_iis0;extern struct platform_device s5pc100_device_iis1;extern struct platform_device s5pc100_device_iis2; +extern struct platform_device samsung_device_keypad; +/* s3c2440 specific devices */ #ifdef
CONFIG_CPU_S3C2440arch/arm/plat- renamed from arch/arm/plat-samsung/include/plat/keypad.h +0
-0
samsung/include/plat/keypad.h
new file mode 100644
index 0000000..d144f42arch/arm/plat-samsung/include/plat/keypad.h new file +9
-0@@ -0,0 +1,57 @@ +/* +* linux/arch/arm/plat-samsung/include/plat/keypad.h +* +* Copyright (C) 2010 Samsung Electronics Co.Ltd +* Author: Joonyoung Shim <[email protected]> +* +* Samsung Platform - Keypad platform data definitions +* +* This program is free software; you can redistribute it and/or Quoted 1 line
modify
it
Quoted 1 line
+ * under the terms of the GNU General Public License as published by
the
Quoted 1 line
+ * Free Software Foundation; either version 2 of the License, or (at
your
arch/arm/plat-samsung/include/plat/keypad.h line 22
Quoted 11 lines
+ * option) any later version.
+ *
+ */arch/arm/plat-samsung/include/plat/keypad.h new file +8
-0+ +#ifndef __PLAT_SAMSUNG_KEYPAD_H +#define __PLAT_SAMSUNG_KEYPAD_H + +#include <linux/input/matrix_keypad.h> + +#define SAMSUNG_MAX_ROWS 8 +#define SAMSUNG_MAX_COLS 8Is the MAX really 8?
Quoted 4 lines
S5PV210 & S5PC110 has 2 slots supporting 14 rows * 8 columns and 8 rows * 8 columns.
So just
SAMSUNG_KEYPAD_ROWSis 8.
Maybe pass this as pdata ?
Quoted 123 lines
Review
Quoted 37 lines
arch/arm/plat-samsung/include/plat/keypad.h new file +3
-0+ +/** +* struct samsung_kp_platdata() - Platform device data for Samsung Keypad + * @keymap_data: pointer to
&matrix_keymap_data
+ * @rows: number of keypad row supported.
+ * @cols: number of keypad col supported.
+ * @rep: flag for repeat setting.
+ * @cfg_gpio: configure the GPIO.
+ *
+ * Initialisation data specific to either the machine or the platform
+ * for the device driver to use or call-back when configuring gpio.
+ */arch/arm/plat-samsung/include/plat/keypad.h new file +11
-0+struct samsung_kp_platdata { +const struct matrix_keymap_data *keymap_data; +unsigned int rows; +unsigned int cols; +unsigned int rep; + +void (*cfg_gpio)(unsigned int rows,unsigned int cols); +}; + +/** +* samsung_kp_set_platdata - Set platform data for Samsung Keypad device. + * @pd: Platform data to register to device.
+ *
+ * Register the given platform data for use with Samsung Keypad device.
+ * The call will copy the platform data, so the board definitions can
+ * make the structure itself__initdata.
+ */arch/arm/plat-samsung/include/plat/keypad.h new file +4
-0+extern void samsung_kp_set_platdata (struct samsung_kp_platdata *pd); + +/* defined by architecture to configure gpio */ +extern void samsung_keypad_cfg_gpio(unsigned int rows, unsigned intcols); +
arch/arm/plat-samsung/include/plat/keypad.h new file +1
-0+#endif /* __PLAT_SAMSUNG_KEYPAD_H */ (quoted diff) +0
-0b/arch/arm/plat-
Quoted 13 lines
samsung/include/plat/regs-keypad.h
new file mode 100644
index 0000000..1a8c046arch/arm/plat-samsung/include/plat/regs-keypad.h new file +7
-0@@ -0,0 +1,49 @@ +/* +* linux/arch/arm/plat-samsung/include/plat/regs-keypad.h +* +* Copyright (C) 2010 Samsung Electronics Co.Ltd +* Author: Joonyoung Shim <[email protected]> +* +* This program is free software; you can redistribute it and/or Quoted 1 line
modify
it
Quoted 1 line
+ * under the terms of the GNU General Public License as published by
the
Quoted 1 line
+ * Free Software Foundation; either version 2 of the License, or (at
your
Quoted 9 lines
+ * option) any later version.
+ *
+ */arch/arm/plat-samsung/include/plat/regs-keypad.h new file +6
-0+ +#ifndef __SAMSUNG_KEYPAD_H__ +#define __SAMSUNG_KEYPAD_H__ + +#define SAMSUNG_KEYIFCON 0x00 +#define SAMSUNG_KEYIFSTSCLR 0x04arch/arm/plat-samsung/include/plat/regs-keypad.h line 28
Quoted 10 lines
arch/arm/plat-samsung/include/plat/regs-keypad.h new file +10
-0+#define SAMSUNG_KEYIFCOL 0x08 +#define SAMSUNG_KEYIFROW 0x0c +#define SAMSUNG_KEYIFFC 0x10 + +/* SAMSUNG_KEYIFCON */ +#define SAMSUNG_INT_F_EN (1 << 0) +#define SAMSUNG_INT_R_EN (1 << 1) +#define SAMSUNG_DF_EN (1 << 2) +#define SAMSUNG_FC_EN (1 << 3) +#define SAMSUNG_WAKEUPEN (1 << 4)Needs KEYIF in the definition name for avoid confusing.
Quoted 22 lines
arch/arm/plat-samsung/include/plat/regs-keypad.h new file +21
-1+ +/* SAMSUNG_KEYIFSTSCLR */ +#define SAMSUNG_P_INT_MASK (0xff << 0) +#define SAMSUNG_R_INT_MASK (0xff << 8) +#define SAMSUNG_R_INT_OFFSET 8 +#define S5PV210_P_INT_MASK (0x3fff << 0) +#define S5PV210_R_INT_MASK (0x3fff << 16) +#define S5PV210_R_INT_OFFSET 16 + +/* SAMSUNG_KEYIFCOL */ +#define SAMSUNG_KEYIFCOL_MASK (0xff << 0) +#define S5PV210_KEYIFCOLEN_MASK (0xff << 8) + +/* SAMSUNG_KEYIFROW */ +#define SAMSUNG_KEYIFROW_MASK (0xff << 0) +#define S5PV210_KEYIFROW_MASK (0x3fff << 0) + +/* SAMSUNG_KEYIFFC */ +#define SAMSUNG_KEYIFFC_MASK (0x3ff << 0) + +#endif /* __SAMSUNG_KEYPAD_H__ */ --Quoted 1 line
1.7.0.4
Thanks.
Best regards,
Kgene.
--
Kukjin Kim <[email protected]>, Senior Engineer, SW Solution Development Team, Samsung Electronics Co., Ltd.--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 1/5 ARM: SAMSUNG: Add keypad device support
In reply to Kukjin KimQuoted 20 lines · Kukjin Kim
Quoted 4 lines · Joonyoung Shim
This patch adds samsung keypad device definition for samsung cpus.
Signed-off-by Joonyoung Shim <[email protected]>Signed-off-by Kyungmin Park <[email protected]>Quoted 9 lines
--- arch/arm/plat-samsung/Kconfig | 7 ++- arch/arm/plat-samsung/Makefile | 1 + arch/arm/plat-samsung/dev-keypad.c | 50 +++++++++++++++++++ arch/arm/plat-samsung/include/plat/devs.h | 2 + arch/arm/plat-samsung/include/plat/keypad.h | 57 ++++++++++++++++++++++ arch/arm/plat-samsung/include/plat/regs-keypad.h | 49+++++++++++++++++++
Quoted 5 lines
6 files changed, 165 insertions(+), 1 deletions(-) create mode 100644 arch/arm/plat-samsung/dev-keypad.c create mode 100644 arch/arm/plat-samsung/include/plat/keypad.h create mode 100644 arch/arm/plat-samsung/include/plat/regs-keypad.h
Quoted 14 lines
arch/arm/plat-samsung/Kconfig config S3C64XX_DEV_SPI · line 229
Quoted 11 lines
arch/arm/plat-samsung/Kconfig +2
-1@@ -225,7 +225,12 @@ config S3C64XX_DEV_SPI config SAMSUNG_DEV_TS bool help - Common in platform device definitions for touchscreen device + Common in platform device definitions for touchscreen device +Above changing is not for keypad.
OK, but this give a warning of checkpatch to me.
Quoted 40 lines
Review
Quoted 8 lines
arch/arm/plat-samsung/Kconfig +4
-0+config SAMSUNG_DEV_KEYPAD + bool + help + Compile in platform device definitions for keypad # DMA(quoted diff) +0
-0b/arch/arm/plat-samsung/Makefile
Review
Quoted 12 lines
index 228c2ad..ef00c47 100644
arch/arm/plat-samsung/Makefile +1
-0@@ -50,6 +50,7 @@ obj-$(CONFIG_S3C_DEV_RTC) += dev-rtc.o obj-$(CONFIG_SAMSUNG_DEV_ADC) += dev-adc.o obj-$(CONFIG_SAMSUNG_DEV_TS) += dev-ts.o +obj-$(CONFIG_SAMSUNG_DEV_KEYPAD) += dev-keypad.o # DMA support(quoted diff) +0
-0b/arch/arm/plat-samsung/dev-
arch/arm/plat-samsung/dev-keypad.c line 7
Quoted 13 lines
keypad.c
new file mode 100644
index 0000000..70e2e2darch/arm/plat-samsung/dev-keypad.c new file +7
-0@@ -0,0 +1,50 @@ +/* +* linux/arch/arm/plat-samsung/dev-keypad.c +* +* Copyright (C) 2010 Samsung Electronics Co.Ltd +* Author: Joonyoung Shim <[email protected]> +* +* This program is free software; you can redistribute it and/or modify it
arch/arm/plat-samsung/dev-keypad.c line 8
Quoted 1 line
arch/arm/plat-samsung/dev-keypad.c new file +1
-0+* under the terms of the GNU General Public License as published by the
arch/arm/plat-samsung/dev-keypad.c line 9
Quoted 1 line
arch/arm/plat-samsung/dev-keypad.c new file +1
-0+* Free Software Foundation; either version 2 of the License, or (at your
Quoted 15 lines
arch/arm/plat-samsung/dev-keypad.c line 21
Quoted 12 lines
arch/arm/plat-samsung/dev-keypad.c new file +12
-0+* option) any later version. +* +*/ + +#include <linux/platform_device.h> +#include <mach/irqs.h> +#include <mach/map.h> +#include <plat/cpu.h> +#include <plat/devs.h> +#include <plat/keypad.h> + +static struct resource samsung_kp_resources[] = {How about
samsung_keypad_resourceseasily to reading?
OK, i will rename from kp to keypad and it needs to change at the keypad driver too.
Quoted 78 lines
Quoted 50 lines
arch/arm/plat-samsung/dev-keypad.c new file +29
-0+ [0 ] = { + .start =SAMSUNG_PA_KEYPAD , + .end =SAMSUNG_PA_KEYPAD +0x20 -1 , + .flags =IORESOURCE_MEM , + }, + [1 ] = { + .start =IRQ_KEYPAD , + .end =IRQ_KEYPAD , + .flags =IORESOURCE_IRQ , + }, +}; + +struct platform_device samsung_device_keypad = { + .name ="samsung-keypad" , + .id =-1 , + .num_resources =ARRAY_SIZE (samsung_kp_resources), + .resource = samsung_kp_resources, +}; + +void __init samsung_kp_set_platdata (struct samsung_kp_platdata *pd) +{ +struct samsung_kp_platdata *npd; + + npd =s3c_set_platdata (pd,sizeof (struct samsung_kp_platdata ), + &samsung_device_keypad); + +if (!npd->cfg_gpio) + npd->cfg_gpio = samsung_keypad_cfg_gpio; +}arch/arm/plat- renamed from arch/arm/plat-samsung/include/plat/devs.h +0
-0
samsung/include/plat/devs.h
index 6760999..c06386b 100644arch/arm/plat-samsung/include/plat/devs.h +2
-0@@ -100,6 +100,8 @@ extern struct platform_device s5pc100_device_iis0;extern struct platform_device s5pc100_device_iis1;extern struct platform_device s5pc100_device_iis2; +extern struct platform_device samsung_device_keypad; +/* s3c2440 specific devices */ #ifdef CONFIG_CPU_S3C2440 arch/arm/plat- renamed from arch/arm/plat-samsung/include/plat/keypad.h +0
-0
samsung/include/plat/keypad.h
new file mode 100644
index 0000000..d144f42arch/arm/plat-samsung/include/plat/keypad.h line 9
Quoted 9 lines
arch/arm/plat-samsung/include/plat/keypad.h new file +9
-0@@ -0,0 +1,57 @@ +/* +* linux/arch/arm/plat-samsung/include/plat/keypad.h +* +* Copyright (C) 2010 Samsung Electronics Co.Ltd +* Author: Joonyoung Shim <[email protected]> +* +* Samsung Platform - Keypad platform data definitions +* +* This program is free software; you can redistribute it and/or modify it
arch/arm/plat-samsung/include/plat/keypad.h line 10
Quoted 1 line
arch/arm/plat-samsung/include/plat/keypad.h new file +1
-0+* under the terms of the GNU General Public License as published by the
arch/arm/plat-samsung/include/plat/keypad.h line 11
Quoted 1 line
arch/arm/plat-samsung/include/plat/keypad.h new file +1
-0+* Free Software Foundation; either version 2 of the License, or (at your
arch/arm/plat-samsung/include/plat/keypad.h line 22
Quoted 11 lines
arch/arm/plat-samsung/include/plat/keypad.h new file +11
-0+* option) any later version. +* +*/ + +#ifndef __PLAT_SAMSUNG_KEYPAD_H +#define __PLAT_SAMSUNG_KEYPAD_H + +#include <linux/input/matrix_keypad.h> + +#define SAMSUNG_MAX_ROWS 8 +#define SAMSUNG_MAX_COLS 8Is the MAX really 8?
Quoted 5 lines
S5PV210 & S5PC110 has 2 slots supporting 14 rows * 8 columns and 8 rows * 8 columns.
So just
SAMSUNG_KEYPAD_ROWSis 8.
Right, but i don't have a board to support 14 rows keypad. We can add supporting 14 rows keypad later.
Quoted 68 lines
Review
Quoted 36 lines
arch/arm/plat-samsung/include/plat/keypad.h new file +35
-0+ +/** +* struct samsung_kp_platdata() - Platform device data for Samsung Keypad +* @keymap_data: pointer to &matrix_keymap_data +* @rows: number of keypad row supported. +* @cols: number of keypad col supported. +* @rep: flag for repeat setting. +* @cfg_gpio: configure the GPIO. +* +* Initialisation data specific to either the machine or the platform +* for the device driver to use or call-back when configuring gpio. +*/ +struct samsung_kp_platdata { +const struct matrix_keymap_data *keymap_data; +unsigned int rows; +unsigned int cols; +unsigned int rep; + +void (*cfg_gpio)(unsigned int rows,unsigned int cols); +}; + +/** +* samsung_kp_set_platdata - Set platform data for Samsung Keypad device. +* @pd: Platform data to register to device. +* +* Register the given platform data for use with Samsung Keypad device. +* The call will copy the platform data, so the board definitions can +* make the structure itself __initdata. +*/ +extern void samsung_kp_set_platdata (struct samsung_kp_platdata *pd); + +/* defined by architecture to configure gpio */ +extern void samsung_keypad_cfg_gpio (unsigned int rows,unsigned int cols); + +#endif /* __PLAT_SAMSUNG_KEYPAD_H */ (quoted diff) +0
-0b/arch/arm/plat-
arch/arm/plat-samsung/include/plat/regs-keypad.h line 7
Quoted 13 lines
samsung/include/plat/regs-keypad.h
new file mode 100644
index 0000000..1a8c046arch/arm/plat-samsung/include/plat/regs-keypad.h new file +7
-0@@ -0,0 +1,49 @@ +/* +* linux/arch/arm/plat-samsung/include/plat/regs-keypad.h +* +* Copyright (C) 2010 Samsung Electronics Co.Ltd +* Author: Joonyoung Shim <[email protected]> +* +* This program is free software; you can redistribute it and/or modify it
arch/arm/plat-samsung/include/plat/regs-keypad.h line 8
Quoted 1 line
arch/arm/plat-samsung/include/plat/regs-keypad.h new file +1
-0+* under the terms of the GNU General Public License as published by the
arch/arm/plat-samsung/include/plat/regs-keypad.h line 9
Quoted 1 line
arch/arm/plat-samsung/include/plat/regs-keypad.h new file +1
-0+* Free Software Foundation; either version 2 of the License, or (at your
Quoted 13 lines
arch/arm/plat-samsung/include/plat/regs-keypad.h new file +13
-0+* option) any later version. +* +*/ + +#ifndef __SAMSUNG_KEYPAD_H__ +#define __SAMSUNG_KEYPAD_H__ + +#define SAMSUNG_KEYIFCON 0x00 +#define SAMSUNG_KEYIFSTSCLR 0x04 +#define SAMSUNG_KEYIFCOL 0x08 +#define SAMSUNG_KEYIFROW 0x0c +#define SAMSUNG_KEYIFFC 0x10 +
Quoted 9 lines
arch/arm/plat-samsung/include/plat/regs-keypad.h line 28
Quoted 6 lines
arch/arm/plat-samsung/include/plat/regs-keypad.h new file +6
-0+/* SAMSUNG_KEYIFCON */ +#define SAMSUNG_INT_F_EN (1 << 0) +#define SAMSUNG_INT_R_EN (1 << 1) +#define SAMSUNG_DF_EN (1 << 2) +#define SAMSUNG_FC_EN (1 << 3) +#define SAMSUNG_WAKEUPEN (1 << 4)Needs KEYIF in the definition name for avoid confusing.
OK, i will rename it.
Quoted 38 lines
Quoted 22 lines
arch/arm/plat-samsung/include/plat/regs-keypad.h new file +21
-1+ +/* SAMSUNG_KEYIFSTSCLR */ +#define SAMSUNG_P_INT_MASK (0xff << 0) +#define SAMSUNG_R_INT_MASK (0xff << 8) +#define SAMSUNG_R_INT_OFFSET 8 +#define S5PV210_P_INT_MASK (0x3fff << 0) +#define S5PV210_R_INT_MASK (0x3fff << 16) +#define S5PV210_R_INT_OFFSET 16 + +/* SAMSUNG_KEYIFCOL */ +#define SAMSUNG_KEYIFCOL_MASK (0xff << 0) +#define S5PV210_KEYIFCOLEN_MASK (0xff << 8) + +/* SAMSUNG_KEYIFROW */ +#define SAMSUNG_KEYIFROW_MASK (0xff << 0) +#define S5PV210_KEYIFROW_MASK (0x3fff << 0) + +/* SAMSUNG_KEYIFFC */ +#define SAMSUNG_KEYIFFC_MASK (0x3ff << 0) + +#endif /* __SAMSUNG_KEYPAD_H__ */ --Quoted 1 line
1.7.0.4
Thanks.
Best regards,
Kgene.
--
Kukjin Kim <[email protected]>, Senior Engineer, SW Solution Development Team, Samsung Electronics Co., Ltd.--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html