AM335XEVM: Volume Keys Support Added.
[sitara-epos/sitara-epos-kernel.git] / arch / arm / mach-omap2 / board-am335xevm.c
index f35d65ea10987dc8ed2952559778d2ebb6fbeffb..231faa5c0f3adfea3d5418a31d7c853ff3c3eb0f 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/gpio.h>
 #include <linux/spi/spi.h>
 #include <linux/spi/flash.h>
+#include <linux/gpio_keys.h>
 #include <linux/input.h>
 #include <linux/input/matrix_keypad.h>
 #include <linux/mtd/mtd.h>
@@ -662,6 +663,57 @@ static void matrix_keypad_init(int evm_id, int profile)
        }
 }
 
+
+/* pinmux for keypad device */
+static struct pinmux_config volume_keys_pin_mux[] = {
+       {"spi0_sclk.gpio0_2",  OMAP_MUX_MODE7 | AM33XX_PIN_INPUT},
+       {"spi0_d0.gpio0_3",    OMAP_MUX_MODE7 | AM33XX_PIN_INPUT},
+       {NULL, 0},
+};
+
+/* Configure GPIOs for Volume Keys */
+static struct gpio_keys_button am335x_evm_volume_gpio_buttons[] = {
+       {
+               .code                   = KEY_VOLUMEUP,
+               .gpio                   = GPIO_TO_PIN(0, 2),
+               .active_low             = true,
+               .desc                   = "volume-up",
+               .type                   = EV_KEY,
+               .wakeup                 = 1,
+       },
+       {
+               .code                   = KEY_VOLUMEDOWN,
+               .gpio                   = GPIO_TO_PIN(0, 3),
+               .active_low             = true,
+               .desc                   = "volume-down",
+               .type                   = EV_KEY,
+               .wakeup                 = 1,
+       },
+};
+
+static struct gpio_keys_platform_data am335x_evm_volume_gpio_key_info = {
+       .buttons        = am335x_evm_volume_gpio_buttons,
+       .nbuttons       = ARRAY_SIZE(am335x_evm_volume_gpio_buttons),
+};
+
+static struct platform_device am335x_evm_volume_keys = {
+       .name   = "gpio-keys",
+       .id     = -1,
+       .dev    = {
+               .platform_data  = &am335x_evm_volume_gpio_key_info,
+       },
+};
+
+static void volume_keys_init(int evm_id, int profile)
+{
+       int err;
+
+       setup_pin_mux(volume_keys_pin_mux);
+       err = platform_device_register(&am335x_evm_volume_keys);
+       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
@@ -1289,6 +1341,7 @@ static struct evm_dev_cfg gen_purp_evm_dev_cfg[] = {
        {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},
+       {volume_keys_init,  DEV_ON_DGHTR_BRD, PROFILE_0},
        {NULL, 0, 0},
 };