]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/arm/mach-omap2/devices.c
ARM: OMAP: Clean-up MMC device init
[linux-2.6-omap-h63xx.git] / arch / arm / mach-omap2 / devices.c
index f0e601c78c47ac9aebec4059e1eb94ddebb0a142..ba0e098cc0f1b86f7c30b35ff33be9eef5154ca2 100644 (file)
 #include <asm/mach-types.h>
 #include <asm/mach/map.h>
 
+#include <mach/control.h>
 #include <mach/tc.h>
 #include <mach/board.h>
 #include <mach/mux.h>
 #include <mach/gpio.h>
 #include <mach/eac.h>
+#include <mach/mmc.h>
 
 #if defined(CONFIG_VIDEO_OMAP2) || defined(CONFIG_VIDEO_OMAP2_MODULE)
 
@@ -354,6 +356,115 @@ static void omap_init_sha1_md5(void)
 static inline void omap_init_sha1_md5(void) { }
 #endif
 
+/*-------------------------------------------------------------------------*/
+
+#if    defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE) || \
+       defined(CONFIG_MMC_OMAP_HS) || defined(CONFIG_MMC_OMAP_HS_MODULE)
+
+#define        OMAP2_MMC1_BASE         0x4809c000
+#define        OMAP2_MMC1_END          (OMAP2_MMC1_BASE + 0x1fc)
+#define        OMAP2_MMC1_INT          INT_24XX_MMC_IRQ
+
+#define        OMAP2_MMC2_BASE         0x480b4000
+#define        OMAP2_MMC2_END          (OMAP2_MMC2_BASE + 0x1fc)
+#define        OMAP2_MMC2_INT          INT_24XX_MMC2_IRQ
+
+static u64 omap2_mmc1_dmamask = 0xffffffff;
+
+static struct resource omap2_mmc1_resources[] = {
+       {
+               .start          = OMAP2_MMC1_BASE,
+               .end            = OMAP2_MMC1_END,
+               .flags          = IORESOURCE_MEM,
+       },
+       {
+               .start          = OMAP2_MMC1_INT,
+               .flags          = IORESOURCE_IRQ,
+       },
+};
+
+static struct platform_device omap2_mmc1_device = {
+       .name           = "mmci-omap",
+       .id             = 1,
+       .dev = {
+               .dma_mask       = &omap2_mmc1_dmamask,
+       },
+       .num_resources  = ARRAY_SIZE(omap2_mmc1_resources),
+       .resource       = omap2_mmc1_resources,
+};
+
+static u64 omap2_mmc2_dmamask = 0xffffffff;
+
+static struct resource omap2_mmc2_resources[] = {
+       {
+               .start          = OMAP2_MMC2_BASE,
+               .end            = OMAP2_MMC2_END,
+               .flags          = IORESOURCE_MEM,
+       },
+       {
+               .start          = OMAP2_MMC2_INT,
+               .flags          = IORESOURCE_IRQ,
+       },
+};
+
+static struct platform_device omap2_mmc2_device = {
+       .name           = "mmci-omap",
+       .id             = 2,
+       .dev = {
+               .dma_mask       = &omap2_mmc2_dmamask,
+       },
+       .num_resources  = ARRAY_SIZE(omap2_mmc2_resources),
+       .resource       = omap2_mmc2_resources,
+};
+
+static inline void omap2_mmc_mux(struct omap_mmc_platform_data *info)
+{
+       if (!cpu_is_omap2420())
+               return;
+
+       if (info->slots[0].enabled) {
+               omap_cfg_reg(H18_24XX_MMC_CMD);
+               omap_cfg_reg(H15_24XX_MMC_CLKI);
+               omap_cfg_reg(G19_24XX_MMC_CLKO);
+               omap_cfg_reg(F20_24XX_MMC_DAT0);
+               omap_cfg_reg(F19_24XX_MMC_DAT_DIR0);
+               omap_cfg_reg(G18_24XX_MMC_CMD_DIR);
+               if (info->slots[0].wire4) {
+                       omap_cfg_reg(H14_24XX_MMC_DAT1);
+                       omap_cfg_reg(E19_24XX_MMC_DAT2);
+                       omap_cfg_reg(D19_24XX_MMC_DAT3);
+                       omap_cfg_reg(E20_24XX_MMC_DAT_DIR1);
+                       omap_cfg_reg(F18_24XX_MMC_DAT_DIR2);
+                       omap_cfg_reg(E18_24XX_MMC_DAT_DIR3);
+               }
+
+               /*
+                * Use internal loop-back in MMC/SDIO Module Input Clock
+                * selection
+                */
+               if (info->slots[0].internal_clock) {
+                       u32 v = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0);
+                       v |= (1 << 24);
+                       omap_ctrl_writel(v, OMAP2_CONTROL_DEVCONF0);
+               }
+       }
+}
+
+void omap2_init_mmc(struct omap_mmc_platform_data *info)
+{
+       if (!info)
+               return;
+
+       omap2_mmc_mux(info);
+       omap2_mmc1_device.dev.platform_data = info;
+       omap2_mmc2_device.dev.platform_data = info;
+       omap_init_mmc(info, &omap2_mmc1_device, &omap2_mmc2_device);
+}
+
+#endif
+
+/*-------------------------------------------------------------------------*/
+
 #if defined(CONFIG_HDQ_MASTER_OMAP) || defined(CONFIG_HDQ_MASTER_OMAP_MODULE)
 #if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3430)
 #define OMAP_HDQ_BASE  0x480B2000