Subject: [E3-hacking] [PATCH] OMAP: Fix broken omap-keypad

From: Janusz Krzysztofik <[email-masked]>
Date: Wed, 21 Oct 2009 16:20:29 +0200

Hi,
Commit 4f5433324d1e29cf234d5b1b14782c0fc2948298 had made machines that use new 
matrix_keypad based drivers happy while breaking those that still use old
omap-keypad driver. The patch fixes omap-keypad device for my Amstrad Delta
(tested) and probably 11 more OMAP1 based machines. It leaves a potential
similiar problem on OMAP2 H4 machine not addressed.

I would say that those new, matrix_keypad based drivers should be corrected to
simply not include arch/arm/plat-omap/include/mach/keypad.h, which should keep
serving omap-keypad based machines until they are all upgraded to use 
matrix_keypad.

Created against linux-2.6.32-rc5

Signed-off-by: Janusz Krzysztofik <[email-masked]>

---
--- linux-2.6.32-rc5/arch/arm/plat-omap/include/mach/keypad.h.orig	2009-10-16 02:41:50.000000000 +0200
+++ linux-2.6.32-rc5/arch/arm/plat-omap/include/mach/keypad.h	2009-10-21 15:32:37.000000000 +0200
@@ -10,7 +10,9 @@
 #ifndef ASMARM_ARCH_KEYPAD_H
 #define ASMARM_ARCH_KEYPAD_H
 
+#ifndef CONFIG_ARCH_OMAP1
 #include <linux/input/matrix_keypad.h>
+#endif
 
 struct omap_kp_platform_data {
 	int rows;
@@ -38,5 +40,11 @@ struct omap_kp_platform_data {
 #define KEY_PERSISTENT		0x00800000
 #define KEYNUM_MASK		0x00EFFFFF
 
+#ifdef CONFIG_ARCH_OMAP1
+#define KEY(col, row, val) (((col) << 28) | ((row) << 24) | (val))
+#define PERSISTENT_KEY(col, row) (((col) << 28) | ((row) << 24) | \
+						KEY_PERSISTENT)
+#endif
+
 #endif

---

From: Tony Lindgren <[email-masked]>
Date: Wed, 21 Oct 2009 08:59:40 -0700

> serving omap-keypad based machines until they are all upgraded to use 

Hmm, yeah let's try to do that instead.

> +++ linux-2.6.32-rc5/arch/arm/plat-omap/include/mach/keypad.h	2009-10-21 15:32:37.000000000 +0200

I guess we only need to patch a few board-*.c files currently,
maybe only board-rx51.c?

> +#define PERSISTENT_KEY(col, row) (((col) << 28) | ((row) << 24) | \

Maybe we should add:

#warning: Please update the board to use matrix_keypad.h instead

Regards,

Tony

---

From: Janusz Krzysztofik <[email-masked]>
Date: Wed, 21 Oct 2009 20:09:37 +0200

Wednesday 21 October 2009 17:59:40 Tony Lindgren napisał(a):
> > Commit 4f5433324d1e29cf234d5b1b14782c0fc2948298 had made machines that
> > use new matrix_keypad based drivers happy while breaking those that still
> > use old omap-keypad driver. The patch fixes omap-keypad device for my
> > Amstrad Delta (tested) and probably 11 more OMAP1 based machines. It
> > leaves a potential similiar problem on OMAP2 H4 machine not addressed.
> >
> > I would say that those new, matrix_keypad based drivers should be
> > corrected to simply not include arch/arm/plat-omap/include/mach/keypad.h,
> > which should keep serving omap-keypad based machines until they are all
> > upgraded to use matrix_keypad.
>
> ...

Here you are.

Created against linux-2.6.32-rc5.
Compile tested with omap_3430sdp_defconfig and rx51_defconfig.

---
diff -upr linux-2.6.32-rc5.orig/arch/arm/mach-omap2/board-3430sdp.c linux-2.6.32-rc5.fixed/arch/arm/mach-omap2/board-3430sdp.c
--- linux-2.6.32-rc5.orig/arch/arm/mach-omap2/board-3430sdp.c	2009-10-16 02:41:50.000000000 +0200
+++ linux-2.6.32-rc5.fixed/arch/arm/mach-omap2/board-3430sdp.c	2009-10-21 19:28:48.000000000 +0200
@@ -17,6 +17,7 @@
 #include <linux/platform_device.h>
 #include <linux/delay.h>
 #include <linux/input.h>
+#include <linux/input/matrix_keypad.h>
 #include <linux/spi/spi.h>
 #include <linux/spi/ads7846.h>
 #include <linux/i2c/twl4030.h>
@@ -38,7 +39,6 @@
 #include <mach/gpmc.h>
 
 #include <mach/control.h>
-#include <mach/keypad.h>
 #include <mach/gpmc-smc91x.h>
 
 #include "sdram-qimonda-hyb18m512160af-6.h"
diff -upr linux-2.6.32-rc5.orig/arch/arm/mach-omap2/board-ldp.c linux-2.6.32-rc5.fixed/arch/arm/mach-omap2/board-ldp.c
--- linux-2.6.32-rc5.orig/arch/arm/mach-omap2/board-ldp.c	2009-10-16 02:41:50.000000000 +0200
+++ linux-2.6.32-rc5.fixed/arch/arm/mach-omap2/board-ldp.c	2009-10-21 19:30:03.000000000 +0200
@@ -16,6 +16,7 @@
 #include <linux/platform_device.h>
 #include <linux/delay.h>
 #include <linux/input.h>
+#include <linux/input/matrix_keypad.h>
 #include <linux/gpio_keys.h>
 #include <linux/workqueue.h>
 #include <linux/err.h>
@@ -41,7 +42,6 @@
 #include <asm/delay.h>
 #include <mach/control.h>
 #include <mach/usb.h>
-#include <mach/keypad.h>
 
 #include "mmc-twl4030.h"
 
diff -upr linux-2.6.32-rc5.orig/arch/arm/mach-omap2/board-omap3evm.c linux-2.6.32-rc5.fixed/arch/arm/mach-omap2/board-omap3evm.c
--- linux-2.6.32-rc5.orig/arch/arm/mach-omap2/board-omap3evm.c	2009-10-16 02:41:50.000000000 +0200
+++ linux-2.6.32-rc5.fixed/arch/arm/mach-omap2/board-omap3evm.c	2009-10-21 19:30:16.000000000 +0200
@@ -20,6 +20,7 @@
 #include <linux/clk.h>
 #include <linux/gpio.h>
 #include <linux/input.h>
+#include <linux/input/matrix_keypad.h>
 #include <linux/leds.h>
 
 #include <linux/spi/spi.h>
@@ -37,7 +38,6 @@
 #include <mach/usb.h>
 #include <mach/common.h>
 #include <mach/mcspi.h>
-#include <mach/keypad.h>
 
 #include "sdram-micron-mt46h32m32lf-6.h"
 #include "mmc-twl4030.h"
diff -upr linux-2.6.32-rc5.orig/arch/arm/mach-omap2/board-omap3pandora.c linux-2.6.32-rc5.fixed/arch/arm/mach-omap2/board-omap3pandora.c
--- linux-2.6.32-rc5.orig/arch/arm/mach-omap2/board-omap3pandora.c	2009-10-16 02:41:50.000000000 +0200
+++ linux-2.6.32-rc5.fixed/arch/arm/mach-omap2/board-omap3pandora.c	2009-10-21 19:28:03.000000000 +0200
@@ -27,6 +27,7 @@
 #include <linux/i2c/twl4030.h>
 #include <linux/leds.h>
 #include <linux/input.h>
+#include <linux/input/matrix_keypad.h>
 #include <linux/gpio_keys.h>
 
 #include <asm/mach-types.h>
@@ -39,7 +40,6 @@
 #include <mach/hardware.h>
 #include <mach/mcspi.h>
 #include <mach/usb.h>
-#include <mach/keypad.h>
 #include <mach/mux.h>
 
 #include "sdram-micron-mt46h32m32lf-6.h"
diff -upr linux-2.6.32-rc5.orig/arch/arm/mach-omap2/board-rx51-peripherals.c linux-2.6.32-rc5.fixed/arch/arm/mach-omap2/board-rx51-peripherals.c
--- linux-2.6.32-rc5.orig/arch/arm/mach-omap2/board-rx51-peripherals.c	2009-10-16 02:41:50.000000000 +0200
+++ linux-2.6.32-rc5.fixed/arch/arm/mach-omap2/board-rx51-peripherals.c	2009-10-21 19:29:31.000000000 +0200
@@ -12,6 +12,7 @@
 #include <linux/init.h>
 #include <linux/platform_device.h>
 #include <linux/input.h>
+#include <linux/input/matrix_keypad.h>
 #include <linux/spi/spi.h>
 #include <linux/i2c.h>
 #include <linux/i2c/twl4030.h>
@@ -27,7 +28,6 @@
 #include <mach/common.h>
 #include <mach/dma.h>
 #include <mach/gpmc.h>
-#include <mach/keypad.h>
 #include <mach/onenand.h>
 #include <mach/gpmc-smc91x.h>
 
diff -upr linux-2.6.32-rc5.orig/arch/arm/mach-omap2/board-rx51.c linux-2.6.32-rc5.fixed/arch/arm/mach-omap2/board-rx51.c
--- linux-2.6.32-rc5.orig/arch/arm/mach-omap2/board-rx51.c	2009-10-16 02:41:50.000000000 +0200
+++ linux-2.6.32-rc5.fixed/arch/arm/mach-omap2/board-rx51.c	2009-10-21 19:25:33.000000000 +0200
@@ -26,7 +26,6 @@
 #include <mach/mux.h>
 #include <mach/board.h>
 #include <mach/common.h>
-#include <mach/keypad.h>
 #include <mach/dma.h>
 #include <mach/gpmc.h>
 #include <mach/usb.h>
diff -upr linux-2.6.32-rc5.orig/arch/arm/mach-omap2/board-zoom2.c linux-2.6.32-rc5.fixed/arch/arm/mach-omap2/board-zoom2.c
--- linux-2.6.32-rc5.orig/arch/arm/mach-omap2/board-zoom2.c	2009-10-16 02:41:50.000000000 +0200
+++ linux-2.6.32-rc5.fixed/arch/arm/mach-omap2/board-zoom2.c	2009-10-21 19:29:52.000000000 +0200
@@ -13,6 +13,7 @@
 #include <linux/init.h>
 #include <linux/platform_device.h>
 #include <linux/input.h>
+#include <linux/input/matrix_keypad.h>
 #include <linux/gpio.h>
 #include <linux/i2c/twl4030.h>
 #include <linux/regulator/machine.h>
@@ -22,7 +23,6 @@
 
 #include <mach/common.h>
 #include <mach/usb.h>
-#include <mach/keypad.h>
 
 #include "mmc-twl4030.h"
 #include "sdram-micron-mt46h32m32lf-6.h"
diff -upr linux-2.6.32-rc5.orig/arch/arm/plat-omap/include/mach/keypad.h linux-2.6.32-rc5.fixed/arch/arm/plat-omap/include/mach/keypad.h
--- linux-2.6.32-rc5.orig/arch/arm/plat-omap/include/mach/keypad.h	2009-10-16 02:41:50.000000000 +0200
+++ linux-2.6.32-rc5.fixed/arch/arm/plat-omap/include/mach/keypad.h	2009-10-21 19:41:35.000000000 +0200
@@ -10,7 +10,7 @@
 #ifndef ASMARM_ARCH_KEYPAD_H
 #define ASMARM_ARCH_KEYPAD_H
 
-#include <linux/input/matrix_keypad.h>
+#warning: Please update the board to use matrix_keypad.h instead
 
 struct omap_kp_platform_data {
 	int rows;
@@ -37,6 +37,9 @@ struct omap_kp_platform_data {

 #endif

---

From: Tony Lindgren <[email-masked]>
Date: Thu, 22 Oct 2009 11:49:59 -0700

> Compile tested with omap_3430sdp_defconfig and rx51_defconfig.

Thanks, adding this to omap-fixes.

Tony