Merge branches 'misc', 'eeepc-laptop' and 'bugzilla-14445' into release
[safe/jmp/linux-2.6] / arch / arm / mach-pxa / spitz.c
index da85327..82ff573 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/kernel.h>
 #include <linux/platform_device.h>
 #include <linux/delay.h>
+#include <linux/gpio_keys.h>
 #include <linux/gpio.h>
 #include <linux/leds.h>
 #include <linux/mtd/physmap.h>
@@ -24,6 +25,7 @@
 #include <linux/spi/ads7846.h>
 #include <linux/spi/corgi_lcd.h>
 #include <linux/mtd/sharpsl.h>
+#include <linux/input/matrix_keypad.h>
 
 #include <asm/setup.h>
 #include <asm/mach-types.h>
@@ -111,6 +113,26 @@ static unsigned long spitz_pin_config[] __initdata = {
        GPIO105_GPIO,   /* SPITZ_GPIO_CF_IRQ */
        GPIO106_GPIO,   /* SPITZ_GPIO_CF2_IRQ */
 
+       /* GPIO matrix keypad */
+       GPIO88_GPIO,    /* column 0 */
+       GPIO23_GPIO,    /* column 1 */
+       GPIO24_GPIO,    /* column 2 */
+       GPIO25_GPIO,    /* column 3 */
+       GPIO26_GPIO,    /* column 4 */
+       GPIO27_GPIO,    /* column 5 */
+       GPIO52_GPIO,    /* column 6 */
+       GPIO103_GPIO,   /* column 7 */
+       GPIO107_GPIO,   /* column 8 */
+       GPIO108_GPIO,   /* column 9 */
+       GPIO114_GPIO,   /* column 10 */
+       GPIO12_GPIO,    /* row 0 */
+       GPIO17_GPIO,    /* row 1 */
+       GPIO91_GPIO,    /* row 2 */
+       GPIO34_GPIO,    /* row 3 */
+       GPIO36_GPIO,    /* row 4 */
+       GPIO38_GPIO,    /* row 5 */
+       GPIO39_GPIO,    /* row 6 */
+
        /* I2C */
        GPIO117_I2C_SCL,
        GPIO118_I2C_SDA,
@@ -242,9 +264,152 @@ EXPORT_SYMBOL(spitzscoop2_device);
 /*
  * Spitz Keyboard Device
  */
+#define SPITZ_KEY_CALENDAR     KEY_F1
+#define SPITZ_KEY_ADDRESS      KEY_F2
+#define SPITZ_KEY_FN           KEY_F3
+#define SPITZ_KEY_CANCEL       KEY_F4
+#define SPITZ_KEY_EXOK         KEY_F5
+#define SPITZ_KEY_EXCANCEL     KEY_F6
+#define SPITZ_KEY_EXJOGDOWN    KEY_F7
+#define SPITZ_KEY_EXJOGUP      KEY_F8
+#define SPITZ_KEY_JAP1         KEY_LEFTALT
+#define SPITZ_KEY_JAP2         KEY_RIGHTCTRL
+#define SPITZ_KEY_SYNC         KEY_F9
+#define SPITZ_KEY_MAIL         KEY_F10
+#define SPITZ_KEY_OK           KEY_F11
+#define SPITZ_KEY_MENU         KEY_F12
+
+static const uint32_t spitzkbd_keymap[] = {
+       KEY(0, 0, KEY_LEFTCTRL),
+       KEY(0, 1, KEY_1),
+       KEY(0, 2, KEY_3),
+       KEY(0, 3, KEY_5),
+       KEY(0, 4, KEY_6),
+       KEY(0, 5, KEY_7),
+       KEY(0, 6, KEY_9),
+       KEY(0, 7, KEY_0),
+       KEY(0, 8, KEY_BACKSPACE),
+       KEY(0, 9, SPITZ_KEY_EXOK),      /* EXOK */
+       KEY(0, 10, SPITZ_KEY_EXCANCEL), /* EXCANCEL */
+       KEY(1, 1, KEY_2),
+       KEY(1, 2, KEY_4),
+       KEY(1, 3, KEY_R),
+       KEY(1, 4, KEY_Y),
+       KEY(1, 5, KEY_8),
+       KEY(1, 6, KEY_I),
+       KEY(1, 7, KEY_O),
+       KEY(1, 8, KEY_P),
+       KEY(1, 9, SPITZ_KEY_EXJOGDOWN), /* EXJOGDOWN */
+       KEY(1, 10, SPITZ_KEY_EXJOGUP),  /* EXJOGUP */
+       KEY(2, 0, KEY_TAB),
+       KEY(2, 1, KEY_Q),
+       KEY(2, 2, KEY_E),
+       KEY(2, 3, KEY_T),
+       KEY(2, 4, KEY_G),
+       KEY(2, 5, KEY_U),
+       KEY(2, 6, KEY_J),
+       KEY(2, 7, KEY_K),
+       KEY(3, 0, SPITZ_KEY_ADDRESS),   /* ADDRESS */
+       KEY(3, 1, KEY_W),
+       KEY(3, 2, KEY_S),
+       KEY(3, 3, KEY_F),
+       KEY(3, 4, KEY_V),
+       KEY(3, 5, KEY_H),
+       KEY(3, 6, KEY_M),
+       KEY(3, 7, KEY_L),
+       KEY(3, 9, KEY_RIGHTSHIFT),
+       KEY(4, 0, SPITZ_KEY_CALENDAR),  /* CALENDAR */
+       KEY(4, 1, KEY_A),
+       KEY(4, 2, KEY_D),
+       KEY(4, 3, KEY_C),
+       KEY(4, 4, KEY_B),
+       KEY(4, 5, KEY_N),
+       KEY(4, 6, KEY_DOT),
+       KEY(4, 8, KEY_ENTER),
+       KEY(4, 9, KEY_LEFTSHIFT),
+       KEY(5, 0, SPITZ_KEY_MAIL),      /* MAIL */
+       KEY(5, 1, KEY_Z),
+       KEY(5, 2, KEY_X),
+       KEY(5, 3, KEY_MINUS),
+       KEY(5, 4, KEY_SPACE),
+       KEY(5, 5, KEY_COMMA),
+       KEY(5, 7, KEY_UP),
+       KEY(5, 10, SPITZ_KEY_FN),       /* FN */
+       KEY(6, 0, KEY_SYSRQ),
+       KEY(6, 1, SPITZ_KEY_JAP1),      /* JAP1 */
+       KEY(6, 2, SPITZ_KEY_JAP2),      /* JAP2 */
+       KEY(6, 3, SPITZ_KEY_CANCEL),    /* CANCEL */
+       KEY(6, 4, SPITZ_KEY_OK),        /* OK */
+       KEY(6, 5, SPITZ_KEY_MENU),      /* MENU */
+       KEY(6, 6, KEY_LEFT),
+       KEY(6, 7, KEY_DOWN),
+       KEY(6, 8, KEY_RIGHT),
+};
+
+static const struct matrix_keymap_data spitzkbd_keymap_data = {
+       .keymap         = spitzkbd_keymap,
+       .keymap_size    = ARRAY_SIZE(spitzkbd_keymap),
+};
+
+static const uint32_t spitzkbd_row_gpios[] =
+               { 12, 17, 91, 34, 36, 38, 39 };
+static const uint32_t spitzkbd_col_gpios[] =
+               { 88, 23, 24, 25, 26, 27, 52, 103, 107, 108, 114 };
+
+static struct matrix_keypad_platform_data spitzkbd_pdata = {
+       .keymap_data            = &spitzkbd_keymap_data,
+       .row_gpios              = spitzkbd_row_gpios,
+       .col_gpios              = spitzkbd_col_gpios,
+       .num_row_gpios          = ARRAY_SIZE(spitzkbd_row_gpios),
+       .num_col_gpios          = ARRAY_SIZE(spitzkbd_col_gpios),
+       .col_scan_delay_us      = 10,
+       .debounce_ms            = 10,
+       .wakeup                 = 1,
+};
+
 static struct platform_device spitzkbd_device = {
-       .name           = "spitz-keyboard",
+       .name           = "matrix-keypad",
        .id             = -1,
+       .dev            = {
+               .platform_data = &spitzkbd_pdata,
+       },
+};
+
+
+static struct gpio_keys_button spitz_gpio_keys[] = {
+       {
+               .type   = EV_PWR,
+               .code   = KEY_SUSPEND,
+               .gpio   = SPITZ_GPIO_ON_KEY,
+               .desc   = "On/Off",
+               .wakeup = 1,
+       },
+       /* Two buttons detecting the lid state */
+       {
+               .type   = EV_SW,
+               .code   = 0,
+               .gpio   = SPITZ_GPIO_SWA,
+               .desc   = "\feffDisplay Down",
+       },
+       {
+               .type   = EV_SW,
+               .code   = 1,
+               .gpio   = SPITZ_GPIO_SWB,
+               .desc   = "\feffLid Closed",
+       },
+};
+
+static struct gpio_keys_platform_data spitz_gpio_keys_platform_data = {
+       .buttons        = spitz_gpio_keys,
+       .nbuttons       = ARRAY_SIZE(spitz_gpio_keys),
+};
+
+static struct platform_device spitz_gpio_keys_device = {
+       .name   = "gpio-keys",
+       .id     = -1,
+       .dev    = {
+               .platform_data  = &spitz_gpio_keys_platform_data,
+       },
 };
 
 
@@ -296,6 +461,7 @@ static struct ads7846_platform_data spitz_ads7846_info = {
        .vref_delay_usecs       = 100,
        .x_plate_ohms           = 419,
        .y_plate_ohms           = 486,
+       .pressure_max           = 1024,
        .gpio_pendown           = SPITZ_GPIO_TP_INT,
        .wait_for_sync          = spitz_wait_for_hsync,
 };
@@ -433,50 +599,10 @@ static struct pxaohci_platform_data spitz_ohci_platform_data = {
 /*
  * Irda
  */
-static int spitz_irda_startup(struct device *dev)
-{
-       int rc;
-
-       rc = gpio_request(SPITZ_GPIO_IR_ON, "IrDA on");
-       if (rc)
-               goto err;
-
-       rc = gpio_direction_output(SPITZ_GPIO_IR_ON, 1);
-       if (rc)
-               goto err_dir;
-
-       return 0;
-
-err_dir:
-       gpio_free(SPITZ_GPIO_IR_ON);
-err:
-       return rc;
-}
-
-static void spitz_irda_shutdown(struct device *dev)
-{
-       gpio_free(SPITZ_GPIO_IR_ON);
-}
-
-static void spitz_irda_transceiver_mode(struct device *dev, int mode)
-{
-       gpio_set_value(SPITZ_GPIO_IR_ON, mode & IR_OFF);
-       pxa2xx_transceiver_mode(dev, mode);
-}
-
-#ifdef CONFIG_MACH_AKITA
-static void akita_irda_transceiver_mode(struct device *dev, int mode)
-{
-       gpio_set_value(AKITA_GPIO_IR_ON, mode & IR_OFF);
-       pxa2xx_transceiver_mode(dev, mode);
-}
-#endif
 
 static struct pxaficp_platform_data spitz_ficp_platform_data = {
+/* .gpio_pwdown is set in spitz_init() and akita_init() accordingly */
        .transceiver_cap        = IR_SIRMODE | IR_OFF,
-       .transceiver_mode       = spitz_irda_transceiver_mode,
-       .startup                = spitz_irda_startup,
-       .shutdown               = spitz_irda_shutdown,
 };
 
 
@@ -601,6 +727,7 @@ static struct platform_device sharpsl_rom_device = {
 static struct platform_device *devices[] __initdata = {
        &spitzscoop_device,
        &spitzkbd_device,
+       &spitz_gpio_keys_device,
        &spitzled_device,
        &sharpsl_nand_device,
        &sharpsl_rom_device,
@@ -655,6 +782,8 @@ static void __init common_init(void)
 #if defined(CONFIG_MACH_SPITZ) || defined(CONFIG_MACH_BORZOI)
 static void __init spitz_init(void)
 {
+       spitz_ficp_platform_data.gpio_pwdown = SPITZ_GPIO_IR_ON;
+
        platform_scoop_config = &spitz_pcmcia_config;
 
        common_init();
@@ -697,7 +826,7 @@ static struct nand_ecclayout akita_oobinfo = {
 
 static void __init akita_init(void)
 {
-       spitz_ficp_platform_data.transceiver_mode = akita_irda_transceiver_mode;
+       spitz_ficp_platform_data.gpio_pwdown = AKITA_GPIO_IR_ON;
 
        sharpsl_nand_platform_data.badblock_pattern = &sharpsl_akita_bbt;
        sharpsl_nand_platform_data.ecc_layout = &akita_oobinfo;