ARM: S3C2410: H1940: Add keys device
[firefly-linux-kernel-4.4.55.git] / arch / arm / mach-s3c2410 / mach-h1940.c
index 1a81fe12ccd77287efe159adbc52e03056a467eb..07564404fb8995e6ab4a5773ccb43a1a7413e462 100644 (file)
@@ -23,6 +23,8 @@
 #include <linux/platform_device.h>
 #include <linux/io.h>
 #include <linux/gpio.h>
+#include <linux/input.h>
+#include <linux/gpio_keys.h>
 #include <linux/pwm_backlight.h>
 #include <linux/i2c.h>
 #include <video/platform_lcd.h>
@@ -162,29 +164,10 @@ struct gpio_chip h1940_latch_gpiochip = {
        .get                    = h1940_gpiolib_latch_get,
 };
 
-static void h1940_udc_pullup(enum s3c2410_udc_cmd_e cmd)
-{
-       printk(KERN_DEBUG "udc: pullup(%d)\n",cmd);
-
-       switch (cmd)
-       {
-               case S3C2410_UDC_P_ENABLE :
-                       gpio_set_value(H1940_LATCH_USB_DP, 1);
-                       break;
-               case S3C2410_UDC_P_DISABLE :
-                       gpio_set_value(H1940_LATCH_USB_DP, 0);
-                       break;
-               case S3C2410_UDC_P_RESET :
-                       break;
-               default:
-                       break;
-       }
-}
-
 static struct s3c2410_udc_mach_info h1940_udc_cfg __initdata = {
-       .udc_command            = h1940_udc_pullup,
        .vbus_pin               = S3C2410_GPG(5),
        .vbus_pin_inverted      = 1,
+       .pullup_pin             = H1940_LATCH_USB_DP,
 };
 
 static struct s3c2410_ts_mach_info h1940_ts_cfg __initdata = {
@@ -381,7 +364,44 @@ static struct i2c_board_info h1940_i2c_devices[] = {
        },
 };
 
+#define DECLARE_BUTTON(p, k, n, w)     \
+       {                               \
+               .gpio           = p,    \
+               .code           = k,    \
+               .desc           = n,    \
+               .wakeup         = w,    \
+               .active_low     = 1,    \
+       }
+
+static struct gpio_keys_button h1940_buttons[] = {
+       DECLARE_BUTTON(S3C2410_GPF(0),       KEY_POWER,          "Power", 1),
+       DECLARE_BUTTON(S3C2410_GPF(6),       KEY_ENTER,         "Select", 1),
+       DECLARE_BUTTON(S3C2410_GPF(7),      KEY_RECORD,         "Record", 0),
+       DECLARE_BUTTON(S3C2410_GPG(0),         KEY_F11,       "Calendar", 0),
+       DECLARE_BUTTON(S3C2410_GPG(2),         KEY_F12,       "Contacts", 0),
+       DECLARE_BUTTON(S3C2410_GPG(3),        KEY_MAIL,           "Mail", 0),
+       DECLARE_BUTTON(S3C2410_GPG(6),        KEY_LEFT,     "Left_arrow", 0),
+       DECLARE_BUTTON(S3C2410_GPG(7),    KEY_HOMEPAGE,           "Home", 0),
+       DECLARE_BUTTON(S3C2410_GPG(8),       KEY_RIGHT,    "Right_arrow", 0),
+       DECLARE_BUTTON(S3C2410_GPG(9),          KEY_UP,       "Up_arrow", 0),
+       DECLARE_BUTTON(S3C2410_GPG(10),       KEY_DOWN,     "Down_arrow", 0),
+};
+
+static struct gpio_keys_platform_data h1940_buttons_data = {
+       .buttons        = h1940_buttons,
+       .nbuttons       = ARRAY_SIZE(h1940_buttons),
+};
+
+static struct platform_device h1940_dev_buttons = {
+       .name           = "gpio-keys",
+       .id             = -1,
+       .dev            = {
+               .platform_data  = &h1940_buttons_data,
+       }
+};
+
 static struct platform_device *h1940_devices[] __initdata = {
+       &h1940_dev_buttons,
        &s3c_device_ohci,
        &s3c_device_lcd,
        &s3c_device_wdt,
@@ -475,9 +495,6 @@ static void __init h1940_init(void)
        gpio_direction_output(H1940_LATCH_LCD_P4, 0);
        gpio_direction_output(H1940_LATCH_MAX1698_nSHUTDOWN, 0);
 
-       gpio_request(H1940_LATCH_USB_DP, "USB pullup");
-       gpio_direction_output(H1940_LATCH_USB_DP, 0);
-
        gpio_request(H1940_LATCH_SD_POWER, "SD power");
        gpio_direction_output(H1940_LATCH_SD_POWER, 0);