]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/arm/mach-omap2/board-2430sdp.c
ARM: OMAP: Fix gpio by switching to generic gpio calls
[linux-2.6-omap-h63xx.git] / arch / arm / mach-omap2 / board-2430sdp.c
index 24688efaa445f08939fc4fbafa4b2ab0f0aee51c..5d2933d7a75dcceeb7d8a8367837d698a196ddd8 100644 (file)
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/partitions.h>
 #include <linux/delay.h>
+#include <linux/input.h>
+#include <linux/i2c/twl4030.h>
 #include <linux/err.h>
 #include <linux/clk.h>
 #include <linux/io.h>
+#include <linux/spi/spi.h>
+#include <linux/spi/ads7846.h>
 
 #include <mach/hardware.h>
 #include <asm/mach-types.h>
 #include <mach/gpio.h>
 #include <mach/mux.h>
 #include <mach/board.h>
+#include <mach/usb-musb.h>
 #include <mach/common.h>
+#include <mach/keypad.h>
 #include <mach/gpmc.h>
+#include <mach/mcspi.h>
+
+
+#include "mmc-twl4030.h"
 
 
 #define        SDP2430_FLASH_CS        0
 #define        SDP2430_SMC91X_CS       5
 
+/* GPIO used for TSC2046 (touchscreen)
+ *
+ * Also note that the tsc2046 is the same silicon as the ads7846, so
+ * that driver is used for the touchscreen. */
+#define TS_GPIO                 24
+
+#define TWL4030_MSECURE_GPIO   118
+#define SECONDARY_LCD_GPIO     147
+
 static struct mtd_partition sdp2430_partitions[] = {
        /* bootloader (U-Boot, etc) in first sector */
        {
@@ -106,6 +125,11 @@ static struct resource sdp2430_smc91x_resources[] = {
        },
 };
 
+static struct platform_device sdp2430_lcd_device = {
+       .name           = "sdp2430_lcd",
+       .id             = -1,
+};
+
 static struct platform_device sdp2430_smc91x_device = {
        .name           = "smc91x",
        .id             = -1,
@@ -113,9 +137,125 @@ static struct platform_device sdp2430_smc91x_device = {
        .resource       = sdp2430_smc91x_resources,
 };
 
+/*
+ * Key mapping for 2430 SDP board
+ */
+
+static int sdp2430_keymap[] = {
+       KEY(0, 0, KEY_LEFT),
+       KEY(0, 1, KEY_RIGHT),
+       KEY(0, 2, KEY_A),
+       KEY(0, 3, KEY_B),
+       KEY(0, 4, KEY_C),
+       KEY(1, 0, KEY_DOWN),
+       KEY(1, 1, KEY_UP),
+       KEY(1, 2, KEY_E),
+       KEY(1, 3, KEY_F),
+       KEY(1, 4, KEY_G),
+       KEY(2, 0, KEY_ENTER),
+       KEY(2, 1, KEY_I),
+       KEY(2, 2, KEY_J),
+       KEY(2, 3, KEY_K),
+       KEY(2, 4, KEY_3),
+       KEY(3, 0, KEY_M),
+       KEY(3, 1, KEY_N),
+       KEY(3, 2, KEY_O),
+       KEY(3, 3, KEY_P),
+       KEY(3, 4, KEY_Q),
+       KEY(4, 0, KEY_R),
+       KEY(4, 1, KEY_4),
+       KEY(4, 2, KEY_T),
+       KEY(4, 3, KEY_U),
+       KEY(4, 4, KEY_D),
+       KEY(5, 0, KEY_V),
+       KEY(5, 1, KEY_W),
+       KEY(5, 2, KEY_L),
+       KEY(5, 3, KEY_S),
+       KEY(5, 4, KEY_H),
+       0
+};
+
+static struct twl4030_keypad_data sdp2430_kp_data = {
+       .rows           = 5,
+       .cols           = 6,
+       .keymap         = sdp2430_keymap,
+       .keymapsize     = ARRAY_SIZE(sdp2430_keymap),
+       .rep            = 1,
+};
+
+static int __init msecure_init(void)
+{
+       int ret = 0;
+
+#ifdef CONFIG_RTC_DRV_TWL4030
+       ret = gpio_request(TWL4030_MSECURE_GPIO, "msecure");
+       if (ret < 0) {
+               printk(KERN_ERR "msecure_init: can't reserve GPIO:%d !\n",
+                       TWL4030_MSECURE_GPIO);
+               goto out;
+       }
+       /*
+        * TWL4030 will be in secure mode if msecure line from OMAP is low.
+        * Make msecure line high in order to change the TWL4030 RTC time
+        * and calender registers.
+        */
+       gpio_direction_output(TWL4030_MSECURE_GPIO, 1);
+out:
+#endif
+
+       return ret;
+}
+
 static struct platform_device *sdp2430_devices[] __initdata = {
        &sdp2430_smc91x_device,
        &sdp2430_flash_device,
+       &sdp2430_lcd_device,
+};
+
+static void ads7846_dev_init(void)
+{
+       if (gpio_request(TS_GPIO, "ads7846 irq") < 0)
+               printk(KERN_ERR "can't get ads746 pen down GPIO\n");
+
+       gpio_direction_input(TS_GPIO);
+
+       omap_set_gpio_debounce(TS_GPIO, 1);
+       omap_set_gpio_debounce_time(TS_GPIO, 0xa);
+}
+
+static int ads7846_get_pendown_state(void)
+{
+       return !gpio_get_value(TS_GPIO);
+}
+
+static struct ads7846_platform_data tsc2046_config __initdata = {
+       .get_pendown_state = ads7846_get_pendown_state,
+       .keep_vref_on      = 1,
+};
+
+static struct omap2_mcspi_device_config tsc2046_mcspi_config = {
+       .turbo_mode     = 0,
+       .single_channel = 0,  /* 0: slave, 1: master */
+};
+
+static struct omap_lcd_config sdp2430_lcd_config __initdata = {
+       .ctrl_name      = "internal",
+};
+
+static struct spi_board_info sdp2430_spi_board_info[] __initdata = {
+       [0] = {
+               /*
+                * TSC2046 operates at a max freqency of 2MHz, so
+                * operate slightly below at 1.5MHz
+                */
+               .modalias        = "ads7846",
+               .bus_num         = 1,
+               .chip_select     = 0,
+               .max_speed_hz    = 1500000,
+               .controller_data = &tsc2046_mcspi_config,
+               .irq             = OMAP_GPIO_IRQ(TS_GPIO),
+               .platform_data   = &tsc2046_config,
+       },
 };
 
 static inline void __init sdp2430_init_smc91x(void)
@@ -168,13 +308,13 @@ static inline void __init sdp2430_init_smc91x(void)
        sdp2430_smc91x_resources[0].end = cs_mem_base + 0x30f;
        udelay(100);
 
-       if (omap_request_gpio(OMAP24XX_ETHR_GPIO_IRQ) < 0) {
+       if (gpio_request(OMAP24XX_ETHR_GPIO_IRQ, "SMC91x irq") < 0) {
                printk(KERN_ERR "Failed to request GPIO%d for smc91x IRQ\n",
                        OMAP24XX_ETHR_GPIO_IRQ);
                gpmc_cs_free(eth_cs);
                goto out;
        }
-       omap_set_gpio_direction(OMAP24XX_ETHR_GPIO_IRQ, 1);
+       gpio_direction_input(OMAP24XX_ETHR_GPIO_IRQ);
 
 out:
        clk_disable(gpmc_fck);
@@ -183,7 +323,7 @@ out:
 
 static void __init omap_2430sdp_init_irq(void)
 {
-       omap2_init_common_hw();
+       omap2_init_common_hw(NULL);
        omap_init_irq();
        omap_gpio_init();
        sdp2430_init_smc91x();
@@ -193,16 +333,93 @@ static struct omap_uart_config sdp2430_uart_config __initdata = {
        .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
 };
 
-static struct omap_board_config_kernel sdp2430_config[] = {
+static
+struct omap_serial_console_config sdp2430_serial_console_config __initdata = {
+       .console_uart = 1,
+       .console_speed = 115200,
+};
+
+static struct omap_board_config_kernel sdp2430_config[] __initdata = {
        {OMAP_TAG_UART, &sdp2430_uart_config},
+       {OMAP_TAG_LCD, &sdp2430_lcd_config},
+       {OMAP_TAG_SERIAL_CONSOLE, &sdp2430_serial_console_config},
+};
+
+
+static struct twl4030_gpio_platform_data sdp2430_gpio_data = {
+       .gpio_base      = OMAP_MAX_GPIO_LINES,
+       .irq_base       = TWL4030_GPIO_IRQ_BASE,
+       .irq_end        = TWL4030_GPIO_IRQ_END,
+};
+
+static struct twl4030_usb_data sdp2430_usb_data = {
+       .usb_mode       = T2_USB_MODE_ULPI,
+};
+
+static struct twl4030_madc_platform_data sdp2430_madc_data = {
+       .irq_line       = 1,
+};
+
+static struct twl4030_platform_data sdp2430_twldata = {
+       .irq_base       = TWL4030_IRQ_BASE,
+       .irq_end        = TWL4030_IRQ_END,
+
+       /* platform_data for children goes here */
+       .gpio           = &sdp2430_gpio_data,
+       .madc           = &sdp2430_madc_data,
+       .keypad         = &sdp2430_kp_data,
+       .usb            = &sdp2430_usb_data,
+};
+
+static struct i2c_board_info __initdata sdp2430_i2c_boardinfo[] = {
+       {
+               I2C_BOARD_INFO("twl4030", 0x48),
+               .flags = I2C_CLIENT_WAKE,
+               .irq = INT_24XX_SYS_NIRQ,
+               .platform_data = &sdp2430_twldata,
+       },
+};
+
+static int __init omap2430_i2c_init(void)
+{
+       omap_register_i2c_bus(1, 400, NULL, 0);
+       omap_register_i2c_bus(2, 2600, sdp2430_i2c_boardinfo,
+                       ARRAY_SIZE(sdp2430_i2c_boardinfo));
+       return 0;
+}
+
+static struct twl4030_hsmmc_info mmc[] __initdata = {
+       {
+               .mmc            = 1,
+               .wires          = 4,
+               .gpio_cd        = -EINVAL,
+               .gpio_wp        = -EINVAL,
+               .ext_clock      = 1,
+       },
+       {}      /* Terminator */
 };
 
 static void __init omap_2430sdp_init(void)
 {
+       omap2430_i2c_init();
+
        platform_add_devices(sdp2430_devices, ARRAY_SIZE(sdp2430_devices));
        omap_board_config = sdp2430_config;
        omap_board_config_size = ARRAY_SIZE(sdp2430_config);
        omap_serial_init();
+
+       msecure_init();
+
+       sdp2430_flash_init();
+       usb_musb_init();
+
+       spi_register_board_info(sdp2430_spi_board_info,
+                               ARRAY_SIZE(sdp2430_spi_board_info));
+       ads7846_dev_init();
+       twl4030_mmc_init(mmc);
+
+       /* turn off secondary LCD backlight */
+       gpio_direction_output(SECONDARY_LCD_GPIO, 0);
 }
 
 static void __init omap_2430sdp_map_io(void)