Commit 5edc297a6924963dff70471f2dd51442d1bbf603

Authored by Goutam Kumar
Committed by Hebbar, Gururaja
1 parent a7cb0a4c2f
Exists in master

AM335XEVM: Matrix GPIO Keypad support added

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>

Showing 3 changed files with 82 additions and 7 deletions Side-by-side Diff

arch/arm/configs/am335x_evm_defconfig
... ... @@ -1079,13 +1079,13 @@
1079 1079 CONFIG_INPUT_KEYBOARD=y
1080 1080 # CONFIG_KEYBOARD_ADP5588 is not set
1081 1081 # CONFIG_KEYBOARD_ADP5589 is not set
1082   -CONFIG_KEYBOARD_ATKBD=y
  1082 +# CONFIG_KEYBOARD_ATKBD is not set
1083 1083 # CONFIG_KEYBOARD_QT1070 is not set
1084 1084 # CONFIG_KEYBOARD_QT2160 is not set
1085 1085 # CONFIG_KEYBOARD_LKKBD is not set
1086 1086 CONFIG_KEYBOARD_GPIO=y
1087 1087 # CONFIG_KEYBOARD_TCA6416 is not set
1088   -# CONFIG_KEYBOARD_MATRIX is not set
  1088 +CONFIG_KEYBOARD_MATRIX=y
1089 1089 # CONFIG_KEYBOARD_MAX7359 is not set
1090 1090 # CONFIG_KEYBOARD_MCS is not set
1091 1091 # CONFIG_KEYBOARD_MPR121 is not set
arch/arm/mach-omap2/board-am335xevm.c
... ... @@ -20,6 +20,10 @@
20 20 #include <linux/gpio.h>
21 21 #include <linux/spi/spi.h>
22 22 #include <linux/spi/flash.h>
  23 +#ifdef CONFIG_KEYBOARD_MATRIX
  24 +#include <linux/input.h>
  25 +#include <linux/input/matrix_keypad.h>
  26 +#endif
23 27 #include <linux/mtd/mtd.h>
24 28 #include <linux/mtd/nand.h>
25 29 #include <linux/mtd/partitions.h>
... ... @@ -583,6 +587,74 @@
583 587  
584 588 }
585 589  
  590 +/* Matrix GPIO Keypad Support for profile-0 only: TODO */
  591 +#ifdef CONFIG_KEYBOARD_MATRIX
  592 +
  593 +/* pinmux for keypad device */
  594 +static struct pinmux_config matrix_keypad_pin_mux[] = {
  595 + {"gpmc_a5.gpio1_21", OMAP_MUX_MODE7 | AM33XX_PIN_OUTPUT},
  596 + {"gpmc_a8.gpio1_24", OMAP_MUX_MODE7 | AM33XX_PIN_OUTPUT},
  597 + {"gpmc_a9.gpio1_25", OMAP_MUX_MODE7 | AM33XX_PIN_INPUT},
  598 + {"gpmc_a10.gpio1_26", OMAP_MUX_MODE7 | AM33XX_PIN_INPUT},
  599 + {"gpmc_a11.gpio1_27", OMAP_MUX_MODE7 | AM33XX_PIN_INPUT},
  600 + {NULL, 0},
  601 +};
  602 +
  603 +/* Keys mapping */
  604 +static const uint32_t am335x_evm_matrix_keys[] = {
  605 + KEY(0, 0, KEY_MENU),
  606 + KEY(1, 0, KEY_BACK),
  607 + KEY(2, 0, KEY_LEFT),
  608 +
  609 + KEY(0, 1, KEY_RIGHT),
  610 + KEY(1, 1, KEY_ENTER),
  611 + KEY(2, 1, KEY_DOWN),
  612 +};
  613 +
  614 +const struct matrix_keymap_data am335x_evm_keymap_data = {
  615 + .keymap = am335x_evm_matrix_keys,
  616 + .keymap_size = ARRAY_SIZE(am335x_evm_matrix_keys),
  617 +};
  618 +
  619 +static const unsigned int am335x_evm_keypad_row_gpios[] = {
  620 + GPIO_TO_PIN(1, 25), GPIO_TO_PIN(1, 26), GPIO_TO_PIN(1, 27)
  621 +};
  622 +
  623 +static const unsigned int am335x_evm_keypad_col_gpios[] = {
  624 + GPIO_TO_PIN(1, 21), GPIO_TO_PIN(1, 24)
  625 +};
  626 +
  627 +static struct matrix_keypad_platform_data am335x_evm_keypad_platform_data = {
  628 + .keymap_data = &am335x_evm_keymap_data,
  629 + .row_gpios = am335x_evm_keypad_row_gpios,
  630 + .num_row_gpios = ARRAY_SIZE(am335x_evm_keypad_row_gpios),
  631 + .col_gpios = am335x_evm_keypad_col_gpios,
  632 + .num_col_gpios = ARRAY_SIZE(am335x_evm_keypad_col_gpios),
  633 + .active_low = false,
  634 + .debounce_ms = 5,
  635 + .col_scan_delay_us = 2,
  636 +};
  637 +
  638 +static struct platform_device am335x_evm_keyboard = {
  639 + .name = "matrix-keypad",
  640 + .id = -1,
  641 + .dev = {
  642 + .platform_data = &am335x_evm_keypad_platform_data,
  643 + },
  644 +};
  645 +
  646 +static void matrix_keypad_init(int evm_id, int profile)
  647 +{
  648 + int err;
  649 +
  650 + setup_pin_mux(matrix_keypad_pin_mux);
  651 + err = platform_device_register(&am335x_evm_keyboard);
  652 + if (err) {
  653 + pr_err("failed to register matrix keypad (2x3) device\n");
  654 + }
  655 +}
  656 +#endif
  657 +
586 658 /*
587 659 * @evm_id - evm id which needs to be configured
588 660 * @dev_cfg - single evm structure which includes
... ... @@ -1321,6 +1393,9 @@
1321 1393 {wl12xx_init, DEV_ON_BASEBOARD, (PROFILE_0 | PROFILE_3 | PROFILE_5)},
1322 1394 {d_can0_init, DEV_ON_BASEBOARD, PROFILE_1},
1323 1395 {d_can1_init, DEV_ON_BASEBOARD, PROFILE_4},
  1396 +#ifdef CONFIG_KEYBOARD_MATRIX
  1397 + {matrix_keypad_init, DEV_ON_DGHTR_BRD, PROFILE_0},
  1398 +#endif
1324 1399 {NULL, 0, 0},
1325 1400 };
1326 1401  
arch/arm/mach-omap2/mux33xx.c
... ... @@ -94,7 +94,7 @@
94 94 "gpmc_a20", NULL, NULL, NULL),
95 95 _AM33XX_MUXENTRY(GPMC_A5, 0,
96 96 "gpmc_a5", "mii2_txd0", "rgmii2_td0", "rmii2_txd0",
97   - "gpmc_a21", NULL, NULL, NULL),
  97 + "gpmc_a21", NULL, NULL, "gpio1_21"),
98 98 _AM33XX_MUXENTRY(GPMC_A6, 0,
99 99 "gpmc_a6", "mii2_txclk", "rgmii2_tclk", "mmc2_dat4",
100 100 "gpmc_a22", NULL, NULL, NULL),
101 101  
102 102  
103 103  
... ... @@ -103,16 +103,16 @@
103 103 NULL, NULL, NULL, NULL),
104 104 _AM33XX_MUXENTRY(GPMC_A8, 0,
105 105 "gpmc_a8", "mii2_rxd3", "rgmii2_rd3", "mmc2_dat6",
106   - NULL, NULL, "mcasp0_aclkx", NULL),
  106 + NULL, NULL, "mcasp0_aclkx", "gpio1_24"),
107 107 _AM33XX_MUXENTRY(GPMC_A9, 0,
108 108 "gpmc_a9", "mii2_rxd2", "rgmii2_rd2", "mmc2_dat7",
109   - NULL, NULL, "mcasp0_fsx", NULL),
  109 + NULL, NULL, "mcasp0_fsx", "gpio1_25"),
110 110 _AM33XX_MUXENTRY(GPMC_A10, 0,
111 111 "gpmc_a10", "mii2_rxd1", "rgmii2_rd1", "rmii2_rxd1",
112   - NULL, NULL, "mcasp0_axr0", NULL),
  112 + NULL, NULL, "mcasp0_axr0", "gpio1_26"),
113 113 _AM33XX_MUXENTRY(GPMC_A11, 0,
114 114 "gpmc_a11", "mii2_rxd0", "rgmii2_rd0", "rmii2_rxd0",
115   - NULL, NULL, "mcasp0_axr1", NULL),
  115 + NULL, NULL, "mcasp0_axr1", "gpio1_27"),
116 116 _AM33XX_MUXENTRY(GPMC_WAIT0, 0,
117 117 "gpmc_wait0", "mii2_crs", NULL, "rmii2_crs_dv",
118 118 "mmc1_sdcd", NULL, NULL, NULL),