davinci: da850/omap-l138: add support for SoC suspend
[safe/jmp/linux-2.6] / arch / arm / mach-davinci / board-da830-evm.c
index ea9bc25..dc19870 100644 (file)
 #define DA830_EMIF25_ASYNC_DATA_CE3_BASE       0x62000000
 #define DA830_EMIF25_CONTROL_BASE              0x68000000
 
-static struct at24_platform_data da830_evm_i2c_eeprom_info = {
-       .byte_len       = SZ_256K / 8,
-       .page_size      = 64,
-       .flags          = AT24_FLAG_ADDR16,
-       .setup          = davinci_get_mac_addr,
-       .context        = (void *)0x7f00,
-};
-
-static int da830_evm_ui_expander_setup(struct i2c_client *client, int gpio,
-               unsigned ngpio, void *context)
-{
-       gpio_request(gpio + 6, "MUX_MODE");
-#ifdef CONFIG_DA830_UI_LCD
-       gpio_direction_output(gpio + 6, 0);
-#else /* Must be NAND or NOR */
-       gpio_direction_output(gpio + 6, 1);
-#endif
-       return 0;
-}
-
-static int da830_evm_ui_expander_teardown(struct i2c_client *client, int gpio,
-               unsigned ngpio, void *context)
-{
-       gpio_free(gpio + 6);
-       return 0;
-}
-
-static struct pcf857x_platform_data da830_evm_ui_expander_info = {
-       .gpio_base      = DAVINCI_N_GPIO,
-       .setup          = da830_evm_ui_expander_setup,
-       .teardown       = da830_evm_ui_expander_teardown,
-};
-
-static struct i2c_board_info __initdata da830_evm_i2c_devices[] = {
-       {
-               I2C_BOARD_INFO("24c256", 0x50),
-               .platform_data  = &da830_evm_i2c_eeprom_info,
-       },
-       {
-               I2C_BOARD_INFO("tlv320aic3x", 0x18),
-       },
-       {
-               I2C_BOARD_INFO("pcf8574", 0x3f),
-               .platform_data  = &da830_evm_ui_expander_info,
-       },
-};
-
-static struct davinci_i2c_platform_data da830_evm_i2c_0_pdata = {
-       .bus_freq       = 100,  /* kHz */
-       .bus_delay      = 0,    /* usec */
-};
-
 /*
  * USB1 VBUS is controlled by GPIO1[15], over-current is reported on GPIO2[4].
  */
@@ -164,7 +112,7 @@ static __init void da830_evm_usb_init(void)
         * Set up USB clock/mode in the CFGCHIP2 register.
         * FYI:  CFGCHIP2 is 0x0000ef00 initially.
         */
-       cfgchip2 = __raw_readl(DA8XX_SYSCFG_VIRT(DA8XX_CFGCHIP2_REG));
+       cfgchip2 = __raw_readl(DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP2_REG));
 
        /* USB2.0 PHY reference clock is 24 MHz */
        cfgchip2 &= ~CFGCHIP2_REFFREQ;
@@ -191,7 +139,7 @@ static __init void da830_evm_usb_init(void)
        cfgchip2 |=  CFGCHIP2_SESENDEN | CFGCHIP2_VBDTCTEN;
 #endif
 
-       __raw_writel(cfgchip2, DA8XX_SYSCFG_VIRT(DA8XX_CFGCHIP2_REG));
+       __raw_writel(cfgchip2, DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP2_REG));
 
        /* USB_REFCLKIN is not used. */
        ret = davinci_cfg_reg(DA830_USB0_DRVVBUS);
@@ -290,6 +238,8 @@ static int da830_evm_mmc_get_ro(int index)
 static struct davinci_mmc_config da830_evm_mmc_config = {
        .get_ro                 = da830_evm_mmc_get_ro,
        .wires                  = 4,
+       .max_freq               = 50000000,
+       .caps                   = MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED,
        .version                = MMC_CTLR_VERSION_2,
 };
 
@@ -320,6 +270,26 @@ static inline void da830_evm_init_mmc(void)
        }
 }
 
+/*
+ * UI board NAND/NOR flashes only use 8-bit data bus.
+ */
+static const short da830_evm_emif25_pins[] = {
+       DA830_EMA_D_0, DA830_EMA_D_1, DA830_EMA_D_2, DA830_EMA_D_3,
+       DA830_EMA_D_4, DA830_EMA_D_5, DA830_EMA_D_6, DA830_EMA_D_7,
+       DA830_EMA_A_0, DA830_EMA_A_1, DA830_EMA_A_2, DA830_EMA_A_3,
+       DA830_EMA_A_4, DA830_EMA_A_5, DA830_EMA_A_6, DA830_EMA_A_7,
+       DA830_EMA_A_8, DA830_EMA_A_9, DA830_EMA_A_10, DA830_EMA_A_11,
+       DA830_EMA_A_12, DA830_EMA_BA_0, DA830_EMA_BA_1, DA830_NEMA_WE,
+       DA830_NEMA_CS_2, DA830_NEMA_CS_3, DA830_NEMA_OE, DA830_EMA_WAIT_0,
+       -1
+};
+
+#if defined(CONFIG_MMC_DAVINCI) || defined(CONFIG_MMC_DAVINCI_MODULE)
+#define HAS_MMC        1
+#else
+#define HAS_MMC        0
+#endif
+
 #ifdef CONFIG_DA830_UI_NAND
 static struct mtd_partition da830_evm_nand_partitions[] = {
        /* bootloader (U-Boot, etc) in first sector */
@@ -410,26 +380,106 @@ static struct platform_device da830_evm_nand_device = {
        .num_resources  = ARRAY_SIZE(da830_evm_nand_resources),
        .resource       = da830_evm_nand_resources,
 };
+
+static inline void da830_evm_init_nand(int mux_mode)
+{
+       int ret;
+
+       if (HAS_MMC) {
+               pr_warning("WARNING: both MMC/SD and NAND are "
+                               "enabled, but they share AEMIF pins.\n"
+                               "\tDisable MMC/SD for NAND support.\n");
+               return;
+       }
+
+       ret = da8xx_pinmux_setup(da830_evm_emif25_pins);
+       if (ret)
+               pr_warning("da830_evm_init: emif25 mux setup failed: %d\n",
+                               ret);
+
+       ret = platform_device_register(&da830_evm_nand_device);
+       if (ret)
+               pr_warning("da830_evm_init: NAND device not registered.\n");
+
+       gpio_direction_output(mux_mode, 1);
+}
+#else
+static inline void da830_evm_init_nand(int mux_mode) { }
 #endif
 
-static struct platform_device *da830_evm_devices[] __initdata = {
-#ifdef CONFIG_DA830_UI_NAND
-       &da830_evm_nand_device,
+#ifdef CONFIG_DA830_UI_LCD
+static inline void da830_evm_init_lcdc(int mux_mode)
+{
+       int ret;
+
+       ret = da8xx_pinmux_setup(da830_lcdcntl_pins);
+       if (ret)
+               pr_warning("da830_evm_init: lcdcntl mux setup failed: %d\n",
+                               ret);
+
+       ret = da8xx_register_lcdc(&sharp_lcd035q3dg01_pdata);
+       if (ret)
+               pr_warning("da830_evm_init: lcd setup failed: %d\n", ret);
+
+       gpio_direction_output(mux_mode, 0);
+}
+#else
+static inline void da830_evm_init_lcdc(int mux_mode) { }
 #endif
+
+static struct at24_platform_data da830_evm_i2c_eeprom_info = {
+       .byte_len       = SZ_256K / 8,
+       .page_size      = 64,
+       .flags          = AT24_FLAG_ADDR16,
+       .setup          = davinci_get_mac_addr,
+       .context        = (void *)0x7f00,
 };
 
-/*
- * UI board NAND/NOR flashes only use 8-bit data bus.
- */
-static const short da830_evm_emif25_pins[] = {
-       DA830_EMA_D_0, DA830_EMA_D_1, DA830_EMA_D_2, DA830_EMA_D_3,
-       DA830_EMA_D_4, DA830_EMA_D_5, DA830_EMA_D_6, DA830_EMA_D_7,
-       DA830_EMA_A_0, DA830_EMA_A_1, DA830_EMA_A_2, DA830_EMA_A_3,
-       DA830_EMA_A_4, DA830_EMA_A_5, DA830_EMA_A_6, DA830_EMA_A_7,
-       DA830_EMA_A_8, DA830_EMA_A_9, DA830_EMA_A_10, DA830_EMA_A_11,
-       DA830_EMA_A_12, DA830_EMA_BA_0, DA830_EMA_BA_1, DA830_NEMA_WE,
-       DA830_NEMA_CS_2, DA830_NEMA_CS_3, DA830_NEMA_OE, DA830_EMA_WAIT_0,
-       -1
+static int __init da830_evm_ui_expander_setup(struct i2c_client *client,
+               int gpio, unsigned ngpio, void *context)
+{
+       gpio_request(gpio + 6, "UI MUX_MODE");
+
+       /* Drive mux mode low to match the default without UI card */
+       gpio_direction_output(gpio + 6, 0);
+
+       da830_evm_init_lcdc(gpio + 6);
+
+       da830_evm_init_nand(gpio + 6);
+
+       return 0;
+}
+
+static int da830_evm_ui_expander_teardown(struct i2c_client *client, int gpio,
+               unsigned ngpio, void *context)
+{
+       gpio_free(gpio + 6);
+       return 0;
+}
+
+static struct pcf857x_platform_data __initdata da830_evm_ui_expander_info = {
+       .gpio_base      = DAVINCI_N_GPIO,
+       .setup          = da830_evm_ui_expander_setup,
+       .teardown       = da830_evm_ui_expander_teardown,
+};
+
+static struct i2c_board_info __initdata da830_evm_i2c_devices[] = {
+       {
+               I2C_BOARD_INFO("24c256", 0x50),
+               .platform_data  = &da830_evm_i2c_eeprom_info,
+       },
+       {
+               I2C_BOARD_INFO("tlv320aic3x", 0x18),
+       },
+       {
+               I2C_BOARD_INFO("pcf8574", 0x3f),
+               .platform_data  = &da830_evm_ui_expander_info,
+       },
+};
+
+static struct davinci_i2c_platform_data da830_evm_i2c_0_pdata = {
+       .bus_freq       = 100,  /* kHz */
+       .bus_delay      = 0,    /* usec */
 };
 
 static __init void da830_evm_init(void)
@@ -486,29 +536,6 @@ static __init void da830_evm_init(void)
 
        da830_evm_init_mmc();
 
-#ifdef CONFIG_DA830_UI
-#ifdef CONFIG_DA830_UI_LCD
-       ret = da8xx_pinmux_setup(da830_lcdcntl_pins);
-       if (ret)
-               pr_warning("da830_evm_init: lcdcntl mux setup failed: %d\n",
-                               ret);
-
-       ret = da8xx_register_lcdc(&sharp_lcd035q3dg01_pdata);
-       if (ret)
-               pr_warning("da830_evm_init: lcd setup failed: %d\n", ret);
-#else /* Must be NAND or NOR */
-       ret = da8xx_pinmux_setup(da830_evm_emif25_pins);
-       if (ret)
-               pr_warning("da830_evm_init: emif25 mux setup failed: %d\n",
-                               ret);
-
-       ret = platform_add_devices(da830_evm_devices,
-                       ARRAY_SIZE(da830_evm_devices));
-       if (ret)
-               pr_warning("da830_evm_init: EVM devices not added\n");
-#endif
-#endif
-
        ret = da8xx_register_rtc();
        if (ret)
                pr_warning("da830_evm_init: rtc setup failed: %d\n", ret);