Skip to contentSkip to conversation

keypad platform_data and 24xx support refresh

PATCH In review Komal Shah 2 participants 5 messages Jan 15, 2006 – Jan 17, 2006

Subsystems (5)
lore
Share & tools
lore

Komal Shah

author
#0 lore raw

PATCH 1/1 keypad platform_data and 24xx support refresh

Tony,

Attached patch is refresh against the latest git head, from the earlier patch as per following thread.

[a]
http://linux.omap.com/pipermail/linux-omap-open-source/2005-December/005889.html

Tested for h4 and built for h3/h2/osk. Not able to build for inno1510/1610/730 as the reason mentioned in the McBSP thread.

All the comments mentioned there[a] still remains. Please apply this patch after my earlier two patches

[1]. [PATCH] fix linking
http://linux.omap.com/pipermail/linux-omap-open-source/2006-January/006191.html

[2]. [PATCH] fix compile h3
http://linux.omap.com/pipermail/linux-omap-open-source/2006-January/006193.html

---Komal Shah
http://komalshah.blogspot.com/

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

arch/arm/mach-omap1/board-h2.c +67 -0
index 5840e78..a387381 100644
@@ -26,6 +26,7 @@
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/nand.h>
 #include <linux/mtd/partitions.h>
+#include <linux/input.h>
 
 #include <asm/hardware.h>
 #include <asm/mach-types.h>
@@ -38,10 +39,50 @@
 #include <asm/arch/tc.h>
 #include <asm/arch/irda.h>
 #include <asm/arch/usb.h>
+#include <asm/arch/keypad.h>
 #include <asm/arch/common.h>
 
 extern int omap_gpio_init(void);
 
+static int h2_keymap[] = {
+	KEY(0, 0, KEY_LEFT),
+	KEY(0, 1, KEY_RIGHT),
+	KEY(0, 2, KEY_3),
+	KEY(0, 3, KEY_F10),
+	KEY(0, 4, KEY_F5),
+	KEY(0, 5, KEY_9),
+	KEY(1, 0, KEY_DOWN),
+	KEY(1, 1, KEY_UP),
+	KEY(1, 2, KEY_2),
+	KEY(1, 3, KEY_F9),
+	KEY(1, 4, KEY_F7),
+	KEY(1, 5, KEY_0),
+	KEY(2, 0, KEY_ENTER),
+	KEY(2, 1, KEY_6),
+	KEY(2, 2, KEY_1),
+	KEY(2, 3, KEY_F2),
+	KEY(2, 4, KEY_F6),
+	KEY(2, 5, KEY_HOME),
+	KEY(3, 0, KEY_8),
+	KEY(3, 1, KEY_5),
+	KEY(3, 2, KEY_F12),
+	KEY(3, 3, KEY_F3),
+	KEY(3, 4, KEY_F8),
+	KEY(3, 5, KEY_END),
+	KEY(4, 0, KEY_7),
+	KEY(4, 1, KEY_4),
+	KEY(4, 2, KEY_F11),
+	KEY(4, 3, KEY_F1),
+	KEY(4, 4, KEY_F4),
+	KEY(4, 5, KEY_ESC),
+	KEY(5, 0, KEY_F13),
+	KEY(5, 1, KEY_F14),
+	KEY(5, 2, KEY_F15),
+	KEY(5, 3, KEY_F16),
+	KEY(5, 4, KEY_SLEEP),
+	0
+};
+
 static struct mtd_partition h2_nor_partitions[] = {
 	/* bootloader (U-Boot, etc) in first sector */
 	{
@@ -172,6 +213,31 @@ static struct platform_device h2_smc91x_
 	.resource	= h2_smc91x_resources,
 };
 
+static struct resource h2_kp_resources[] = {
+	[0] = {
+		.start	= INT_KEYBOARD,
+		.end	= INT_KEYBOARD,
+		.flags	= IORESOURCE_IRQ,
+	},
+};
+
+static struct omap_kp_platform_data h2_kp_data = {
+	.rows	= 8,
+	.cols	= 8,
+	.keymap = h2_keymap,
+	.rep	= 1,
+};
+
+static struct platform_device h2_kp_device = {
+	.name		= "omap-keypad",
+	.id		= -1,
+	.dev		= {
+		.platform_data = &h2_kp_data,
+	},
+	.num_resources	= ARRAY_SIZE(h2_kp_resources),
+	.resource	= h2_kp_resources,
+};
+
 #define H2_IRDA_FIRSEL_GPIO_PIN	17
 
 static int h2_transceiver_mode(struct device *dev, int state)
@@ -210,6 +276,7 @@ static struct platform_device *h2_device
 	&h2_nand_device,
 	&h2_smc91x_device,
 	&h2_irda_device,
+	&h2_kp_device,
 };
 
 static void __init h2_init_smc91x(void)
arch/arm/mach-omap1/board-h3.c +70 -0

104 lines not on this page · raw message

arch/arm/mach-omap1/board-innovator.c +42 -0

74 lines not on this page · raw message

arch/arm/mach-omap1/board-osk.c +41 -0

66 lines not on this page · raw message

arch/arm/mach-omap1/board-perseus2.c +61 -0

86 lines not on this page · raw message

arch/arm/mach-omap2/board-h4.c +52 -0

79 lines not on this page · raw message

arch/arm/mach-omap2/mux.c +20 -0
index 1a906d8..d3cef53 100644
@@ -71,6 +71,26 @@ MUX_CFG_24XX("P20_24XX_TSC_IRQ",	0x108,	
 MUX_CFG_24XX("K15_24XX_UART3_TX",	0x118,	0,	0,	0,	1)
 MUX_CFG_24XX("K14_24XX_UART3_RX",	0x119,	0,	0,	0,	1)
 
+/* Keypad GPIO*/
+MUX_CFG_24XX("T19_24XX_KBR0",		0x106,	3,	1,	1,	1)
+MUX_CFG_24XX("R19_24XX_KBR1",		0x107,	3,	1,	1,	1)
+MUX_CFG_24XX("V18_24XX_KBR2",		0x139,	3,	1,	1,	1)
+MUX_CFG_24XX("M21_24XX_KBR3",		0xc9,	3,	1,	1,	1)
+MUX_CFG_24XX("E5__24XX_KBR4",		0x138,	3,	1,	1,	1)
+MUX_CFG_24XX("M18_24XX_KBR5",		0x10e,	3,	1,	1,	1)
+MUX_CFG_24XX("R20_24XX_KBC0",		0x108,	3,	0,	0,	1)
+MUX_CFG_24XX("M14_24XX_KBC1",		0x109,	3,	0,	0,	1)
+MUX_CFG_24XX("H19_24XX_KBC2",		0x114,	3,	0,	0,	1)
+MUX_CFG_24XX("V17_24XX_KBC3",		0x135,	3,	0,	0,	1)
+MUX_CFG_24XX("P21_24XX_KBC4",		0xca,	3,	0,	0,	1)
+MUX_CFG_24XX("L14_24XX_KBC5",		0x10f,	3,	0,	0,	1)
+MUX_CFG_24XX("N19_24XX_KBC6",		0x110,	3,	0,	0,	1)
+
+/* 24xx Meneluase Keypad GPIO */
+MUX_CFG_24XX("B3__24XX_KBR5",		0x30,	3,	1,	1,	1)
+MUX_CFG_24XX("AA4_24XX_KBC2",		0xe7,	3,	0,	0,	1)
+MUX_CFG_24XX("B13_24XX_KBC6",		0x110,	3,	0,	0,	1)
+
 };
 
 int __init omap2_mux_init(void)
arch/arm/plat-omap/devices.c +21 -6
index 640e507..572f86d 100644
@@ -24,6 +24,7 @@
 #include <asm/arch/board.h>
 #include <asm/arch/mux.h>
 #include <asm/arch/gpio.h>
+#include <asm/arch/menelaus.h>
 
 
 void omap_nop_release(struct device *dev)
@@ -99,10 +100,6 @@ static inline void omap_init_i2c(void) {
 
 /*-------------------------------------------------------------------------*/
 #if	defined(CONFIG_KEYBOARD_OMAP) || defined(CONFIG_KEYBOARD_OMAP_MODULE)
-static struct platform_device omap_kp_device = {
-	.name	   = "omap-keypad",
-	.id	     = -1,
-};
 
 static void omap_init_kp(void)
 {
@@ -131,9 +128,27 @@ static void omap_init_kp(void)
 		omap_cfg_reg(E4_730_KBC2);
 		omap_cfg_reg(F4_730_KBC3);
 		omap_cfg_reg(E3_730_KBC4);
+	} else if (machine_is_omap_h4()) {
+		omap_cfg_reg(T19_24XX_KBR0);
+		omap_cfg_reg(R19_24XX_KBR1);
+		omap_cfg_reg(V18_24XX_KBR2);
+		omap_cfg_reg(M21_24XX_KBR3);
+		omap_cfg_reg(E5__24XX_KBR4);
+		if (omap_has_menelaus()) {
+			omap_cfg_reg(B3__24XX_KBR5);
+			omap_cfg_reg(AA4_24XX_KBC2);
+			omap_cfg_reg(B13_24XX_KBC6);
+		} else {
+			omap_cfg_reg(M18_24XX_KBR5);
+			omap_cfg_reg(H19_24XX_KBC2);
+			omap_cfg_reg(N19_24XX_KBC6);
+		}
+		omap_cfg_reg(R20_24XX_KBC0);
+		omap_cfg_reg(M14_24XX_KBC1);
+		omap_cfg_reg(V17_24XX_KBC3);
+		omap_cfg_reg(P21_24XX_KBC4);
+		omap_cfg_reg(L14_24XX_KBC5);
 	}
-
-	(void) platform_device_register(&omap_kp_device);
 }
 #else
 static inline void omap_init_kp(void) {}
drivers/input/keyboard/Kconfig +1 -1
index a52757c..303915d 100644
@@ -196,7 +196,7 @@ config KEYBOARD_HIL
 
 config KEYBOARD_OMAP
 	tristate "TI OMAP keypad support"
-	depends on ARCH_OMAP1
+	depends on (ARCH_OMAP1 || ARCH_OMAP2)
 	help
 	  Say Y here if you want to use the OMAP keypad.
 
drivers/input/keyboard/omap-keypad.c +158 -135

396 lines not on this page · raw message

include/asm-arm/arch-omap/mux.h +19 -0
index 27d54c0..7a1a28a 100644
@@ -427,6 +427,25 @@ enum omap24xx_index {
 	K15_24XX_UART3_TX,
 	K14_24XX_UART3_RX,
 
+	/* Keypad GPIO*/
+	T19_24XX_KBR0,
+	R19_24XX_KBR1,
+	V18_24XX_KBR2,
+	M21_24XX_KBR3,
+	E5__24XX_KBR4,
+	M18_24XX_KBR5,
+	R20_24XX_KBC0,
+	M14_24XX_KBC1,
+	H19_24XX_KBC2,
+	V17_24XX_KBC3,
+	P21_24XX_KBC4,
+	L14_24XX_KBC5,
+	N19_24XX_KBC6,
+
+	/* 24xx Meneluas Keypad GPIO */
+	B3__24XX_KBR5,
+	AA4_24XX_KBC2,
+	B13_24XX_KBC6,
 };
 
 #ifdef	CONFIG_OMAP_MUX
#1 lore raw
Quoted 2 lines · ext Komal Shah

Attached patch is refresh against the latest git head, from the earlier patch as per following thread.

Looks good, except:

drivers/input/keyboard/omap-keypad.c line 61

Quoted 6 lines
drivers/input/keyboard/omap-keypad.c +5 -0
+#ifdef CONFIG_MACH_OMAP_H4
+#define NUM_ROWS 6
+#define NUM_COLS 7
 
+static unsigned int row_gpio_num[NUM_ROWS] = { 88, 89, 124, 11, 6, 96 };
+static unsigned int col_gpio_num[NUM_COLS] = { 90, 91, 100, 36, 12, 97, 98 };

Why not use the platform_data for this information, too? It's kind of bad to assume this for all the 2420 boards.

Quoted 3 lines
 static int test_keymap[] = {
        KEY(0, 0, KEY_F4),
        KEY(1, 0, KEY_LEFT),

This can go away, too. We'll put it into board-nokia770.c.

drivers/input/keyboard/omap-keypad.c static int test_keymap[] = { · line 89

Quoted 2 lines
drivers/input/keyboard/omap-keypad.c +2 -0
+#ifdef CONFIG_MACH_OMAP_H4
+static void set_col_gpio_val(u8 value)

Not H4 but OMAP2.

Quoted 1 line

+ if (machine_is_omap_h4()) {

Ditto.

There's also a fairly important patch we haven't published yet. The patch provides a work-around to the "ghost key" problem that happens when necessary precautions have not been made in the keypad HW design. If there are three (or more) keys pressed at the same time, and they form a triangle on the keypad matrix, the HW thinks there are some extra keys pressed.

Unfortunately I don't have time now to come up with a proper patch, but I've put our version of the driver here:
http://jemmari.tky.hut.fi/~jey/omap-keypad.c

Cheers,
Juha

author
#2 lore raw
Quoted 6 lines · --- Juha Yrjölä

Looks good, except:

Quoted 3 lines
drivers/input/keyboard/omap-keypad.c +3 -0
+#ifdef CONFIG_MACH_OMAP_H4
+#define NUM_ROWS 6
+#define NUM_COLS 7
Quoted 8 lines
Quoted 1 line

+static unsigned int row_gpio_num[NUM_ROWS] = { 88, 89, 124, 11, 6,

96 };

Quoted 1 line

+static unsigned int col_gpio_num[NUM_COLS] = { 90, 91, 100, 36,

12, 97, 98 };

Why not use the platform_data for this information, too? It's kind of
bad to assume this for all the 2420 boards.

Yes, it is in my TODO.

http://linux.omap.com/pipermail/linux-omap-open-source/2005-December/005889.html

Quoted 6 lines
Quoted 4 lines
 static int test_keymap[] = {
        KEY(0, 0, KEY_F4),
        KEY(1, 0, KEY_LEFT),

This can go away, too. We'll put it into board-nokia770.c.

Ok.

Quoted 5 lines

drivers/input/keyboard/omap-keypad.c static int test_keymap[] = { · line 89

Quoted 3 lines
drivers/input/keyboard/omap-keypad.c +2 -0
+#ifdef CONFIG_MACH_OMAP_H4
+static void set_col_gpio_val(u8 value)

Not H4 but OMAP2.

Why? If 2430 falls into OMAP2 class then it's EVM design for keyboard is using TWL4030 i2c interface to read the values. Richard can clarify on this.

Quoted 4 lines
Quoted 2 lines

+ if (machine_is_omap_h4()) {

Ditto.

Let's see, depends upon 2430 design, otherwise h4 looks good to me.

Quoted 10 lines

There's also a fairly important patch we haven't published yet. The patch provides a work-around to the "ghost key" problem that happens when necessary precautions have not been made in the keypad HW design.
If there are three (or more) keys pressed at the same time, and they form a triangle on the keypad matrix, the HW thinks there are some extra
keys pressed.

Quoted 4 lines

Unfortunately I don't have time now to come up with a proper patch, but
I've put our version of the driver here:
http://jemmari.tky.hut.fi/~jey/omap-keypad.c

Ok, I will try to merge it when I release the new patch. (May be this weekend).

---Komal Shah
http://komalshah.blogspot.com/

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

#3 lore raw
Quoted 8 lines · ext Komal Shah
Quoted 4 lines

drivers/input/keyboard/omap-keypad.c static int test_keymap[] = { · line 89

Quoted 2 lines
drivers/input/keyboard/omap-keypad.c +2 -0
+#ifdef CONFIG_MACH_OMAP_H4
+static void set_col_gpio_val(u8 value)

Not H4 but OMAP2.

Why? If 2430 falls into OMAP2 class then it's EVM design for keyboard is using TWL4030 i2c interface to read the values. Richard can clarify on this.

Only generic keypad drivers are supposed to live in omap-keypad.c. I had the impression that using GPIOs is the standard way of implementing a keypad on OMAP2xxx CPUs (if you don't use an external keypad chip, that is). Is this not the case? Keypads handled by companion chips most likely will not share a lot of code with the OMAP-specific driver, so they naturally belong to a separate driver.

Cheers,
Juha

author
#4 lore raw
Quoted 9 lines · --- Juha Yrjölä

Only generic keypad drivers are supposed to live in omap-keypad.c. I had the impression that using GPIOs is the standard way of implementing
a keypad on OMAP2xxx CPUs (if you don't use an external keypad chip, that is). Is this not the case? Keypads handled by companion chips most likely will not share a lot of code with the OMAP-specific driver,
so they naturally belong to a separate driver.

Fine, I agree with you and 2430 will have separate file in this case.

---Komal Shah
http://komalshah.blogspot.com/

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com