AM335XEVM: Matrix GPIO Keypad support added
authorGoutam Kumar <goutam.kumar@ti.com>
Wed, 28 Sep 2011 08:45:53 +0000 (14:15 +0530)
committerVaibhav Hiremath <hvaibhav@ti.com>
Mon, 23 Jan 2012 19:14:36 +0000 (00:44 +0530)
This patch adds support for GPIO based Matric(2 x 3) Keypad.

Signed-off-by: Goutam Kumar <goutam.kumar@ti.com>
Signed-off-by: Hebbar, Gururaja <gururaja.hebbar@ti.com>
Signed-off-by: Patil, Rachna <rachna@ti.com>
Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
arch/arm/configs/am335x_evm_defconfig
arch/arm/mach-omap2/board-am335xevm.c
arch/arm/mach-omap2/mux33xx.c

index c815718f7fbee0f4fde5ca9a0114c439fca6be84..3cd671860a8120e12c26f58533ba3bf6a06b7018 100644 (file)
@@ -1079,13 +1079,13 @@ CONFIG_INPUT_EVDEV=y
 CONFIG_INPUT_KEYBOARD=y
 # CONFIG_KEYBOARD_ADP5588 is not set
 # CONFIG_KEYBOARD_ADP5589 is not set
-CONFIG_KEYBOARD_ATKBD=y
+# CONFIG_KEYBOARD_ATKBD is not set
 # CONFIG_KEYBOARD_QT1070 is not set
 # CONFIG_KEYBOARD_QT2160 is not set
 # CONFIG_KEYBOARD_LKKBD is not set
 CONFIG_KEYBOARD_GPIO=y
 # CONFIG_KEYBOARD_TCA6416 is not set
-# CONFIG_KEYBOARD_MATRIX is not set
+CONFIG_KEYBOARD_MATRIX=y
 # CONFIG_KEYBOARD_MAX7359 is not set
 # CONFIG_KEYBOARD_MCS is not set
 # CONFIG_KEYBOARD_MPR121 is not set
index 425a69312868bb58751548a668bc08458082eb19..f35d65ea10987dc8ed2952559778d2ebb6fbeffb 100644 (file)
@@ -21,6 +21,8 @@
 #include <linux/gpio.h>
 #include <linux/spi/spi.h>
 #include <linux/spi/flash.h>
+#include <linux/input.h>
+#include <linux/input/matrix_keypad.h>
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/nand.h>
 #include <linux/mtd/partitions.h>
@@ -594,6 +596,72 @@ static void setup_pin_mux(struct pinmux_config *pin_mux)
 
 }
 
+/* Matrix GPIO Keypad Support for profile-0 only: TODO */
+
+/* pinmux for keypad device */
+static struct pinmux_config matrix_keypad_pin_mux[] = {
+       {"gpmc_a5.gpio1_21",  OMAP_MUX_MODE7 | AM33XX_PIN_OUTPUT},
+       {"gpmc_a6.gpio1_22",  OMAP_MUX_MODE7 | AM33XX_PIN_OUTPUT},
+       {"gpmc_a9.gpio1_25",  OMAP_MUX_MODE7 | AM33XX_PIN_INPUT},
+       {"gpmc_a10.gpio1_26", OMAP_MUX_MODE7 | AM33XX_PIN_INPUT},
+       {"gpmc_a11.gpio1_27", OMAP_MUX_MODE7 | AM33XX_PIN_INPUT},
+       {NULL, 0},
+};
+
+/* Keys mapping */
+static const uint32_t am335x_evm_matrix_keys[] = {
+       KEY(0, 0, KEY_MENU),
+       KEY(1, 0, KEY_BACK),
+       KEY(2, 0, KEY_LEFT),
+
+       KEY(0, 1, KEY_RIGHT),
+       KEY(1, 1, KEY_ENTER),
+       KEY(2, 1, KEY_DOWN),
+};
+
+const struct matrix_keymap_data am335x_evm_keymap_data = {
+       .keymap      = am335x_evm_matrix_keys,
+       .keymap_size = ARRAY_SIZE(am335x_evm_matrix_keys),
+};
+
+static const unsigned int am335x_evm_keypad_row_gpios[] = {
+       GPIO_TO_PIN(1, 25), GPIO_TO_PIN(1, 26), GPIO_TO_PIN(1, 27)
+};
+
+static const unsigned int am335x_evm_keypad_col_gpios[] = {
+       GPIO_TO_PIN(1, 21), GPIO_TO_PIN(1, 22)
+};
+
+static struct matrix_keypad_platform_data am335x_evm_keypad_platform_data = {
+       .keymap_data       = &am335x_evm_keymap_data,
+       .row_gpios         = am335x_evm_keypad_row_gpios,
+       .num_row_gpios     = ARRAY_SIZE(am335x_evm_keypad_row_gpios),
+       .col_gpios         = am335x_evm_keypad_col_gpios,
+       .num_col_gpios     = ARRAY_SIZE(am335x_evm_keypad_col_gpios),
+       .active_low        = false,
+       .debounce_ms       = 5,
+       .col_scan_delay_us = 2,
+};
+
+static struct platform_device am335x_evm_keyboard = {
+       .name  = "matrix-keypad",
+       .id    = -1,
+       .dev   = {
+               .platform_data = &am335x_evm_keypad_platform_data,
+       },
+};
+
+static void matrix_keypad_init(int evm_id, int profile)
+{
+       int err;
+
+       setup_pin_mux(matrix_keypad_pin_mux);
+       err = platform_device_register(&am335x_evm_keyboard);
+       if (err) {
+               pr_err("failed to register matrix keypad (2x3) device\n");
+       }
+}
+
 /*
 * @evm_id - evm id which needs to be configured
 * @dev_cfg - single evm structure which includes
@@ -1220,6 +1288,7 @@ static struct evm_dev_cfg gen_purp_evm_dev_cfg[] = {
                                                                PROFILE_5)},
        {wl12xx_init,   DEV_ON_BASEBOARD, (PROFILE_0 | PROFILE_3 | PROFILE_5)},
        {d_can_init,    DEV_ON_DGHTR_BRD, PROFILE_1},
+       {matrix_keypad_init, DEV_ON_DGHTR_BRD, PROFILE_0},
        {NULL, 0, 0},
 };
 
index ff1151dc5163ceb45a20d5f3a89810afde8cb7a4..4a43fc1a2bed041bb584406200d286fc6ea0d537 100644 (file)
@@ -94,25 +94,25 @@ static struct omap_mux __initdata am33xx_muxmodes[] = {
                "gpmc_a20", NULL, NULL, NULL),
        _AM33XX_MUXENTRY(GPMC_A5, 0,
                "gpmc_a5", "mii2_txd0", "rgmii2_td0", "rmii2_txd0",
-               "gpmc_a21", NULL, NULL, NULL),
+               "gpmc_a21", NULL, NULL, "gpio1_21"),
        _AM33XX_MUXENTRY(GPMC_A6, 0,
                "gpmc_a6", "mii2_txclk", "rgmii2_tclk", "mmc2_dat4",
-               "gpmc_a22", NULL, NULL, NULL),
+               "gpmc_a22", NULL, NULL, "gpio1_22"),
        _AM33XX_MUXENTRY(GPMC_A7, 0,
                "gpmc_a7", "mii2_rxclk", "rgmii2_rclk", "mmc2_dat5",
                NULL, NULL, NULL, NULL),
        _AM33XX_MUXENTRY(GPMC_A8, 0,
                "gpmc_a8", "mii2_rxd3", "rgmii2_rd3", "mmc2_dat6",
-               NULL, NULL, "mcasp0_aclkx", NULL),
+               NULL, NULL, "mcasp0_aclkx", "gpio1_24"),
        _AM33XX_MUXENTRY(GPMC_A9, 0,
                "gpmc_a9", "mii2_rxd2", "rgmii2_rd2", "mmc2_dat7",
-               NULL, NULL, "mcasp0_fsx", NULL),
+               NULL, NULL, "mcasp0_fsx", "gpio1_25"),
        _AM33XX_MUXENTRY(GPMC_A10, 0,
                "gpmc_a10", "mii2_rxd1", "rgmii2_rd1", "rmii2_rxd1",
-               NULL, NULL, "mcasp0_axr0", NULL),
+               NULL, NULL, "mcasp0_axr0", "gpio1_26"),
        _AM33XX_MUXENTRY(GPMC_A11, 0,
                "gpmc_a11", "mii2_rxd0", "rgmii2_rd0", "rmii2_rxd0",
-               NULL, NULL, "mcasp0_axr1", NULL),
+               NULL, NULL, "mcasp0_axr1", "gpio1_27"),
        _AM33XX_MUXENTRY(GPMC_WAIT0, 0,
                "gpmc_wait0", "mii2_crs", NULL, "rmii2_crs_dv",
                "mmc1_sdcd", NULL, NULL, NULL),