Merge branch 'topic/asoc' into for-linus
[linux-3.10.git] / arch / sh / boards / mach-ecovec24 / setup.c
index a17dbb3..7bdb572 100644 (file)
@@ -11,6 +11,9 @@
 #include <linux/init.h>
 #include <linux/device.h>
 #include <linux/platform_device.h>
+#include <linux/mfd/sh_mobile_sdhi.h>
+#include <linux/mmc/host.h>
+#include <linux/mmc/sh_mmcif.h>
 #include <linux/mtd/physmap.h>
 #include <linux/gpio.h>
 #include <linux/interrupt.h>
 #include <linux/spi/spi.h>
 #include <linux/spi/sh_msiof.h>
 #include <linux/spi/mmc_spi.h>
-#include <linux/mmc/host.h>
 #include <linux/input.h>
 #include <linux/input/sh_keysc.h>
-#include <linux/mfd/sh_mobile_sdhi.h>
 #include <video/sh_mobile_lcdc.h>
 #include <sound/sh_fsi.h>
 #include <media/sh_mobile_ceu.h>
@@ -138,7 +139,7 @@ static struct resource sh_eth_resources[] = {
        },
 };
 
-struct sh_eth_plat_data sh_eth_plat = {
+static struct sh_eth_plat_data sh_eth_plat = {
        .phy = 0x1f, /* SMSC LAN8700 */
        .edmac_endian = EDMAC_LITTLE_ENDIAN,
        .ether_link_active_low = 1
@@ -158,7 +159,7 @@ static struct platform_device sh_eth_device = {
 };
 
 /* USB0 host */
-void usb0_port_power(int port, int power)
+static void usb0_port_power(int port, int power)
 {
        gpio_set_value(GPIO_PTB4, power);
 }
@@ -194,7 +195,7 @@ static struct platform_device usb0_host_device = {
 };
 
 /* USB1 host/function */
-void usb1_port_power(int port, int power)
+static void usb1_port_power(int port, int power)
 {
        gpio_set_value(GPIO_PTB5, power);
 }
@@ -230,14 +231,41 @@ static struct platform_device usb1_common_device = {
 };
 
 /* LCDC */
+const static struct fb_videomode ecovec_lcd_modes[] = {
+       {
+               .name           = "Panel",
+               .xres           = 800,
+               .yres           = 480,
+               .left_margin    = 220,
+               .right_margin   = 110,
+               .hsync_len      = 70,
+               .upper_margin   = 20,
+               .lower_margin   = 5,
+               .vsync_len      = 5,
+               .sync           = 0, /* hsync and vsync are active low */
+       },
+};
+
+const static struct fb_videomode ecovec_dvi_modes[] = {
+       {
+               .name           = "DVI",
+               .xres           = 1280,
+               .yres           = 720,
+               .left_margin    = 220,
+               .right_margin   = 110,
+               .hsync_len      = 40,
+               .upper_margin   = 20,
+               .lower_margin   = 5,
+               .vsync_len      = 5,
+               .sync = 0, /* hsync and vsync are active low */
+       },
+};
+
 static struct sh_mobile_lcdc_info lcdc_info = {
        .ch[0] = {
                .interface_type = RGB18,
                .chan = LCDC_CHAN_MAINLCD,
                .bpp = 16,
-               .lcd_cfg = {
-                       .sync = 0, /* hsync and vsync are active low */
-               },
                .lcd_size_cfg = { /* 7.0 inch */
                        .width = 152,
                        .height = 91,
@@ -420,7 +448,7 @@ static int ts_init(void)
        return 0;
 }
 
-struct tsc2007_platform_data tsc2007_info = {
+static struct tsc2007_platform_data tsc2007_info = {
        .model                  = 2007,
        .x_plate_ohms           = 180,
        .get_pendown_state      = ts_get_pendown_state,
@@ -435,14 +463,17 @@ static struct i2c_board_info ts_i2c_clients = {
 };
 
 #ifdef CONFIG_MFD_SH_MOBILE_SDHI
-/* SHDI0 */
+/* SDHI0 */
 static void sdhi0_set_pwr(struct platform_device *pdev, int state)
 {
        gpio_set_value(GPIO_PTB6, state);
 }
 
 static struct sh_mobile_sdhi_info sdhi0_info = {
-       .set_pwr = sdhi0_set_pwr,
+       .dma_slave_tx   = SHDMA_SLAVE_SDHI0_TX,
+       .dma_slave_rx   = SHDMA_SLAVE_SDHI0_RX,
+       .set_pwr        = sdhi0_set_pwr,
+       .tmio_caps      = MMC_CAP_SDIO_IRQ | MMC_CAP_POWER_OFF_CARD,
 };
 
 static struct resource sdhi0_resources[] = {
@@ -471,14 +502,18 @@ static struct platform_device sdhi0_device = {
        },
 };
 
-/* SHDI1 */
+#if !defined(CONFIG_MMC_SH_MMCIF)
+/* SDHI1 */
 static void sdhi1_set_pwr(struct platform_device *pdev, int state)
 {
        gpio_set_value(GPIO_PTB7, state);
 }
 
 static struct sh_mobile_sdhi_info sdhi1_info = {
-       .set_pwr = sdhi1_set_pwr,
+       .dma_slave_tx   = SHDMA_SLAVE_SDHI1_TX,
+       .dma_slave_rx   = SHDMA_SLAVE_SDHI1_RX,
+       .tmio_caps      = MMC_CAP_SDIO_IRQ | MMC_CAP_POWER_OFF_CARD,
+       .set_pwr        = sdhi1_set_pwr,
 };
 
 static struct resource sdhi1_resources[] = {
@@ -506,6 +541,7 @@ static struct platform_device sdhi1_device = {
                .hwblk_id = HWBLK_SDHI1,
        },
 };
+#endif /* CONFIG_MMC_SH_MMCIF */
 
 #else
 
@@ -613,7 +649,6 @@ static struct soc_camera_link tw9910_link = {
        .bus_id         = 1,
        .power          = tw9910_power,
        .board_info     = &i2c_camera[0],
-       .module_name    = "tw9910",
        .priv           = &tw9910_info,
 };
 
@@ -637,7 +672,6 @@ static struct soc_camera_link mt9t112_link1 = {
        .power          = mt9t112_power1,
        .bus_id         = 0,
        .board_info     = &i2c_camera[1],
-       .module_name    = "mt9t112",
        .priv           = &mt9t112_info1,
 };
 
@@ -660,7 +694,6 @@ static struct soc_camera_link mt9t112_link2 = {
        .power          = mt9t112_power2,
        .bus_id         = 1,
        .board_info     = &i2c_camera[2],
-       .module_name    = "mt9t112",
        .priv           = &mt9t112_info2,
 };
 
@@ -689,40 +722,8 @@ static struct platform_device camera_devices[] = {
 };
 
 /* FSI */
-/*
- * FSI-B use external clock which came from da7210.
- * So, we should change parent of fsi
- */
-#define FCLKBCR                0xa415000c
-static void fsimck_init(struct clk *clk)
-{
-       u32 status = __raw_readl(clk->enable_reg);
-
-       /* use external clock */
-       status &= ~0x000000ff;
-       status |= 0x00000080;
-
-       __raw_writel(status, clk->enable_reg);
-}
-
-static struct clk_ops fsimck_clk_ops = {
-       .init = fsimck_init,
-};
-
-static struct clk fsimckb_clk = {
-       .name           = "fsimckb_clk",
-       .id             = -1,
-       .ops            = &fsimck_clk_ops,
-       .enable_reg     = (void __iomem *)FCLKBCR,
-       .rate           = 0, /* unknown */
-};
-
-struct sh_fsi_platform_info fsi_info = {
-       .portb_flags = SH_FSI_BRS_INV |
-                      SH_FSI_OUT_SLAVE_MODE |
-                      SH_FSI_IN_SLAVE_MODE |
-                      SH_FSI_OFMT(I2S) |
-                      SH_FSI_IFMT(I2S),
+static struct sh_fsi_platform_info fsi_info = {
+       .portb_flags = SH_FSI_BRS_INV,
 };
 
 static struct resource fsi_resources[] = {
@@ -751,6 +752,122 @@ static struct platform_device fsi_device = {
        },
 };
 
+/* IrDA */
+static struct resource irda_resources[] = {
+       [0] = {
+               .name   = "IrDA",
+               .start  = 0xA45D0000,
+               .end    = 0xA45D0049,
+               .flags  = IORESOURCE_MEM,
+       },
+       [1] = {
+               .start  = 20,
+               .flags  = IORESOURCE_IRQ,
+       },
+};
+
+static struct platform_device irda_device = {
+       .name           = "sh_sir",
+       .num_resources  = ARRAY_SIZE(irda_resources),
+       .resource       = irda_resources,
+};
+
+#include <media/ak881x.h>
+#include <media/sh_vou.h>
+
+static struct ak881x_pdata ak881x_pdata = {
+       .flags = AK881X_IF_MODE_SLAVE,
+};
+
+static struct i2c_board_info ak8813 = {
+       I2C_BOARD_INFO("ak8813", 0x20),
+       .platform_data = &ak881x_pdata,
+};
+
+static struct sh_vou_pdata sh_vou_pdata = {
+       .bus_fmt        = SH_VOU_BUS_8BIT,
+       .flags          = SH_VOU_HSYNC_LOW | SH_VOU_VSYNC_LOW,
+       .board_info     = &ak8813,
+       .i2c_adap       = 0,
+};
+
+static struct resource sh_vou_resources[] = {
+       [0] = {
+               .start  = 0xfe960000,
+               .end    = 0xfe962043,
+               .flags  = IORESOURCE_MEM,
+       },
+       [1] = {
+               .start  = 55,
+               .flags  = IORESOURCE_IRQ,
+       },
+};
+
+static struct platform_device vou_device = {
+       .name           = "sh-vou",
+       .id             = -1,
+       .num_resources  = ARRAY_SIZE(sh_vou_resources),
+       .resource       = sh_vou_resources,
+       .dev            = {
+               .platform_data  = &sh_vou_pdata,
+       },
+       .archdata       = {
+               .hwblk_id       = HWBLK_VOU,
+       },
+};
+
+#if defined(CONFIG_MMC_SH_MMCIF)
+/* SH_MMCIF */
+static void mmcif_set_pwr(struct platform_device *pdev, int state)
+{
+       gpio_set_value(GPIO_PTB7, state);
+}
+
+static void mmcif_down_pwr(struct platform_device *pdev)
+{
+       gpio_set_value(GPIO_PTB7, 0);
+}
+
+static struct resource sh_mmcif_resources[] = {
+       [0] = {
+               .name   = "SH_MMCIF",
+               .start  = 0xA4CA0000,
+               .end    = 0xA4CA00FF,
+               .flags  = IORESOURCE_MEM,
+       },
+       [1] = {
+               /* MMC2I */
+               .start  = 29,
+               .flags  = IORESOURCE_IRQ,
+       },
+       [2] = {
+               /* MMC3I */
+               .start  = 30,
+               .flags  = IORESOURCE_IRQ,
+       },
+};
+
+static struct sh_mmcif_plat_data sh_mmcif_plat = {
+       .set_pwr        = mmcif_set_pwr,
+       .down_pwr       = mmcif_down_pwr,
+       .sup_pclk       = 0, /* SH7724: Max Pclk/2 */
+       .caps           = MMC_CAP_4_BIT_DATA |
+                         MMC_CAP_8_BIT_DATA |
+                         MMC_CAP_NEEDS_POLL,
+       .ocr            = MMC_VDD_32_33 | MMC_VDD_33_34,
+};
+
+static struct platform_device sh_mmcif_device = {
+       .name           = "sh_mmcif",
+       .id             = 0,
+       .dev            = {
+               .platform_data          = &sh_mmcif_plat,
+       },
+       .num_resources  = ARRAY_SIZE(sh_mmcif_resources),
+       .resource       = sh_mmcif_resources,
+};
+#endif
+
 static struct platform_device *ecovec_devices[] __initdata = {
        &heartbeat_device,
        &nor_flash_device,
@@ -763,7 +880,9 @@ static struct platform_device *ecovec_devices[] __initdata = {
        &keysc_device,
 #ifdef CONFIG_MFD_SH_MOBILE_SDHI
        &sdhi0_device,
+#if !defined(CONFIG_MMC_SH_MMCIF)
        &sdhi1_device,
+#endif
 #else
        &msiof0_device,
 #endif
@@ -771,8 +890,14 @@ static struct platform_device *ecovec_devices[] __initdata = {
        &camera_devices[1],
        &camera_devices[2],
        &fsi_device,
+       &irda_device,
+       &vou_device,
+#if defined(CONFIG_MMC_SH_MMCIF)
+       &sh_mmcif_device,
+#endif
 };
 
+#ifdef CONFIG_I2C
 #define EEPROM_ADDR 0x50
 static u8 mac_read(struct i2c_adapter *a, u8 command)
 {
@@ -814,7 +939,15 @@ static void __init sh_eth_init(struct sh_eth_plat_data *pd)
                pd->mac_addr[i] = mac_read(a, 0x10 + i);
                msleep(10);
        }
+
+       i2c_put_adapter(a);
 }
+#else
+static void __init sh_eth_init(struct sh_eth_plat_data *pd)
+{
+       pr_err("unable to read sh_eth MAC address\n");
+}
+#endif
 
 #define PORT_HIZA 0xA4050158
 #define IODRIVEA  0xA405018A
@@ -829,7 +962,8 @@ static int __init arch_setup(void)
        struct clk *clk;
 
        /* register board specific self-refresh code */
-       sh_mobile_register_self_refresh(SUSP_SH_STANDBY | SUSP_SH_SF,
+       sh_mobile_register_self_refresh(SUSP_SH_STANDBY | SUSP_SH_SF |
+                                       SUSP_SH_RSTANDBY,
                                        &ecovec24_sdram_enter_start,
                                        &ecovec24_sdram_enter_end,
                                        &ecovec24_sdram_leave_start,
@@ -940,33 +1074,18 @@ static int __init arch_setup(void)
        if (gpio_get_value(GPIO_PTE6)) {
                /* DVI */
                lcdc_info.clock_source                  = LCDC_CLK_EXTERNAL;
-               lcdc_info.ch[0].clock_divider           = 1,
-               lcdc_info.ch[0].lcd_cfg.name            = "DVI";
-               lcdc_info.ch[0].lcd_cfg.xres            = 1280;
-               lcdc_info.ch[0].lcd_cfg.yres            = 720;
-               lcdc_info.ch[0].lcd_cfg.left_margin     = 220;
-               lcdc_info.ch[0].lcd_cfg.right_margin    = 110;
-               lcdc_info.ch[0].lcd_cfg.hsync_len       = 40;
-               lcdc_info.ch[0].lcd_cfg.upper_margin    = 20;
-               lcdc_info.ch[0].lcd_cfg.lower_margin    = 5;
-               lcdc_info.ch[0].lcd_cfg.vsync_len       = 5;
+               lcdc_info.ch[0].clock_divider           = 1;
+               lcdc_info.ch[0].lcd_cfg                 = ecovec_dvi_modes;
+               lcdc_info.ch[0].num_cfg                 = ARRAY_SIZE(ecovec_dvi_modes);
 
                gpio_set_value(GPIO_PTA2, 1);
                gpio_set_value(GPIO_PTU1, 1);
        } else {
                /* Panel */
-
                lcdc_info.clock_source                  = LCDC_CLK_PERIPHERAL;
-               lcdc_info.ch[0].clock_divider           = 2,
-               lcdc_info.ch[0].lcd_cfg.name            = "Panel";
-               lcdc_info.ch[0].lcd_cfg.xres            = 800;
-               lcdc_info.ch[0].lcd_cfg.yres            = 480;
-               lcdc_info.ch[0].lcd_cfg.left_margin     = 220;
-               lcdc_info.ch[0].lcd_cfg.right_margin    = 110;
-               lcdc_info.ch[0].lcd_cfg.hsync_len       = 70;
-               lcdc_info.ch[0].lcd_cfg.upper_margin    = 20;
-               lcdc_info.ch[0].lcd_cfg.lower_margin    = 5;
-               lcdc_info.ch[0].lcd_cfg.vsync_len       = 5;
+               lcdc_info.ch[0].clock_divider           = 2;
+               lcdc_info.ch[0].lcd_cfg                 = ecovec_lcd_modes;
+               lcdc_info.ch[0].num_cfg                 = ARRAY_SIZE(ecovec_lcd_modes);
 
                gpio_set_value(GPIO_PTR1, 1);
 
@@ -1054,6 +1173,7 @@ static int __init arch_setup(void)
        gpio_request(GPIO_PTB6, NULL);
        gpio_direction_output(GPIO_PTB6, 0);
 
+#if !defined(CONFIG_MMC_SH_MMCIF)
        /* enable SDHI1 on CN12 (needs DS2.6,7 set to ON,OFF) */
        gpio_request(GPIO_FN_SDHI1CD,  NULL);
        gpio_request(GPIO_FN_SDHI1WP,  NULL);
@@ -1068,6 +1188,7 @@ static int __init arch_setup(void)
 
        /* I/O buffer drive ability is high for SDHI1 */
        __raw_writew((__raw_readw(IODRIVEA) & ~0x3000) | 0x2000 , IODRIVEA);
+#endif /* CONFIG_MMC_SH_MMCIF */
 #else
        /* enable MSIOF0 on CN11 (needs DS2.4 set to OFF) */
        gpio_request(GPIO_FN_MSIOF0_TXD, NULL);
@@ -1105,13 +1226,22 @@ static int __init arch_setup(void)
        gpio_request(GPIO_FN_FSIOBLRCK,  NULL);
        gpio_request(GPIO_FN_CLKAUDIOBO, NULL);
 
+       /* set SPU2 clock to 83.4 MHz */
+       clk = clk_get(NULL, "spu_clk");
+       if (!IS_ERR(clk)) {
+               clk_set_rate(clk, clk_round_rate(clk, 83333333));
+               clk_put(clk);
+       }
+
        /* change parent of FSI B */
        clk = clk_get(NULL, "fsib_clk");
-       clk_register(&fsimckb_clk);
-       clk_set_parent(clk, &fsimckb_clk);
-       clk_set_rate(clk, 11000);
-       clk_set_rate(&fsimckb_clk, 11000);
-       clk_put(clk);
+       if (!IS_ERR(clk)) {
+               /* 48kHz dummy clock was used to make sure 1/1 divide */
+               clk_set_rate(&sh7724_fsimckb_clk, 48000);
+               clk_set_parent(clk, &sh7724_fsimckb_clk);
+               clk_set_rate(clk, 48000);
+               clk_put(clk);
+       }
 
        gpio_request(GPIO_PTU0, NULL);
        gpio_direction_output(GPIO_PTU0, 0);
@@ -1123,8 +1253,35 @@ static int __init arch_setup(void)
 
        /* set VPU clock to 166 MHz */
        clk = clk_get(NULL, "vpu_clk");
-       clk_set_rate(clk, clk_round_rate(clk, 166000000));
-       clk_put(clk);
+       if (!IS_ERR(clk)) {
+               clk_set_rate(clk, clk_round_rate(clk, 166000000));
+               clk_put(clk);
+       }
+
+       /* enable IrDA */
+       gpio_request(GPIO_FN_IRDA_OUT, NULL);
+       gpio_request(GPIO_FN_IRDA_IN,  NULL);
+       gpio_request(GPIO_PTU5, NULL);
+       gpio_direction_output(GPIO_PTU5, 0);
+
+#if defined(CONFIG_MMC_SH_MMCIF)
+       /* enable MMCIF (needs DS2.6,7 set to OFF,ON) */
+       gpio_request(GPIO_FN_MMC_D7, NULL);
+       gpio_request(GPIO_FN_MMC_D6, NULL);
+       gpio_request(GPIO_FN_MMC_D5, NULL);
+       gpio_request(GPIO_FN_MMC_D4, NULL);
+       gpio_request(GPIO_FN_MMC_D3, NULL);
+       gpio_request(GPIO_FN_MMC_D2, NULL);
+       gpio_request(GPIO_FN_MMC_D1, NULL);
+       gpio_request(GPIO_FN_MMC_D0, NULL);
+       gpio_request(GPIO_FN_MMC_CLK, NULL);
+       gpio_request(GPIO_FN_MMC_CMD, NULL);
+       gpio_request(GPIO_PTB7, NULL);
+       gpio_direction_output(GPIO_PTB7, 0);
+
+       /* I/O buffer drive ability is high for MMCIF */
+       __raw_writew((__raw_readw(IODRIVEA) & ~0x3000) | 0x2000 , IODRIVEA);
+#endif
 
        /* enable I2C device */
        i2c_register_board_info(0, i2c0_devices,
@@ -1133,6 +1290,40 @@ static int __init arch_setup(void)
        i2c_register_board_info(1, i2c1_devices,
                                ARRAY_SIZE(i2c1_devices));
 
+#if defined(CONFIG_VIDEO_SH_VOU) || defined(CONFIG_VIDEO_SH_VOU_MODULE)
+       /* VOU */
+       gpio_request(GPIO_FN_DV_D15, NULL);
+       gpio_request(GPIO_FN_DV_D14, NULL);
+       gpio_request(GPIO_FN_DV_D13, NULL);
+       gpio_request(GPIO_FN_DV_D12, NULL);
+       gpio_request(GPIO_FN_DV_D11, NULL);
+       gpio_request(GPIO_FN_DV_D10, NULL);
+       gpio_request(GPIO_FN_DV_D9, NULL);
+       gpio_request(GPIO_FN_DV_D8, NULL);
+       gpio_request(GPIO_FN_DV_CLKI, NULL);
+       gpio_request(GPIO_FN_DV_CLK, NULL);
+       gpio_request(GPIO_FN_DV_VSYNC, NULL);
+       gpio_request(GPIO_FN_DV_HSYNC, NULL);
+
+       /* AK8813 power / reset sequence */
+       gpio_request(GPIO_PTG4, NULL);
+       gpio_request(GPIO_PTU3, NULL);
+       /* Reset */
+       gpio_direction_output(GPIO_PTG4, 0);
+       /* Power down */
+       gpio_direction_output(GPIO_PTU3, 1);
+
+       udelay(10);
+
+       /* Power up, reset */
+       gpio_set_value(GPIO_PTU3, 0);
+
+       udelay(10);
+
+       /* Remove reset */
+       gpio_set_value(GPIO_PTG4, 1);
+#endif
+
        return platform_add_devices(ecovec_devices,
                                    ARRAY_SIZE(ecovec_devices));
 }