]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
ARM: OMAP: Get rid of controller vs slot confusion, initialize MMC devices dynamically
authorTony Lindgren <tony@atomide.com>
Wed, 24 Sep 2008 11:21:49 +0000 (14:21 +0300)
committerTony Lindgren <tony@atomide.com>
Wed, 24 Sep 2008 14:19:09 +0000 (17:19 +0300)
Big MMC init clean up:

- Remove enabled field from slots. It is really intended to mean enabled controller,
  not enabled slot. Some controllers can have multiple multiplexed slots connected
  to the first controller, such as H4 and N8X0.

- Initialize MMC devices dynamically as suggested by Russell King

- Fix omap1 mmc clock instance numbers

- Also attempt to fix massive omap1 MMC breakage caused by patch
  138ab9f8321f67c71984ca43222efa71b0a0a0a9. Remove obviously broken
  MMC configurations for now. MMC is still not working for any
  omap1 boards.

Signed-off-by: Tony Lindgren <tony@atomide.com>
26 files changed:
arch/arm/mach-omap1/board-h2-mmc.c
arch/arm/mach-omap1/board-h2.c
arch/arm/mach-omap1/board-h3-mmc.c
arch/arm/mach-omap1/board-h3.c
arch/arm/mach-omap1/board-innovator.c
arch/arm/mach-omap1/board-nokia770.c
arch/arm/mach-omap1/board-palmte.c
arch/arm/mach-omap1/board-palmz71.c
arch/arm/mach-omap1/board-sx1-mmc.c
arch/arm/mach-omap1/board-sx1.c
arch/arm/mach-omap1/board-voiceblue.c
arch/arm/mach-omap1/clock.h
arch/arm/mach-omap1/devices.c
arch/arm/mach-omap2/board-apollon-mmc.c
arch/arm/mach-omap2/board-h4-mmc.c
arch/arm/mach-omap2/board-n800-mmc.c
arch/arm/mach-omap2/clock24xx.h
arch/arm/mach-omap2/clock34xx.h
arch/arm/mach-omap2/devices.c
arch/arm/mach-omap2/hsmmc.c
arch/arm/plat-omap/devices.c
arch/arm/plat-omap/include/mach/board-h2.h
arch/arm/plat-omap/include/mach/board-h3.h
arch/arm/plat-omap/include/mach/mmc.h
drivers/mmc/host/omap.c
drivers/mmc/host/omap_hsmmc.c

index 37031e01773c93805e1b3560397ba795aff69701..4fbe367063b233c8ead9ef3c22ea5154a51fe944 100644 (file)
  * published by the Free Software Foundation.
  */
 
+#include <linux/platform_device.h>
+
+#include <linux/i2c/tps65010.h>
+
 #include <mach/mmc.h>
 #include <mach/gpio.h>
 #include <mach/mmc.h>
 
-#ifdef CONFIG_MMC_OMAP
-static int slot_cover_open;
-static struct device *mmc_device;
+#if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE)
 
-static int h2_mmc_set_power(struct device *dev, int slot, int power_on,
+static int mmc_set_power(struct device *dev, int slot, int power_on,
                                int vdd)
 {
-#ifdef CONFIG_MMC_DEBUG
-       dev_dbg(dev, "Set slot %d power: %s (vdd %d)\n", slot + 1,
-               power_on ? "on" : "off", vdd);
-#endif
-       if (slot != 0) {
-               dev_err(dev, "No such slot %d\n", slot + 1);
-               return -ENODEV;
-       }
-
-       return 0;
-}
-
-static int h2_mmc_set_bus_mode(struct device *dev, int slot, int bus_mode)
-{
-#ifdef CONFIG_MMC_DEBUG
-       dev_dbg(dev, "Set slot %d bus_mode %s\n", slot + 1,
-               bus_mode == MMC_BUSMODE_OPENDRAIN ? "open-drain" : "push-pull");
-#endif
-       if (slot != 0) {
-               dev_err(dev, "No such slot %d\n", slot + 1);
-               return -ENODEV;
-       }
+       if (power_on)
+               gpio_direction_output(H2_TPS_GPIO_MMC_PWR_EN, 1);
+       else
+               gpio_direction_output(H2_TPS_GPIO_MMC_PWR_EN, 0);
 
        return 0;
 }
 
-static int h2_mmc_get_cover_state(struct device *dev, int slot)
-{
-       BUG_ON(slot != 0);
-
-       return slot_cover_open;
-}
-
-void h2_mmc_slot_cover_handler(void *arg, int state)
-{
-       if (mmc_device == NULL)
-               return;
-
-       slot_cover_open = state;
-       omap_mmc_notify_cover_event(mmc_device, 0, state);
-}
-
-static int h2_mmc_late_init(struct device *dev)
-{
-       int ret = 0;
-
-       mmc_device = dev;
-
-       return ret;
-}
-
-static void h2_mmc_cleanup(struct device *dev)
-{
-}
-
-static struct omap_mmc_platform_data h2_mmc_data = {
+/*
+ * H2 could use the following functions tested:
+ * - mmc_get_cover_state that uses OMAP_MPUIO(1)
+ * - mmc_get_wp that uses OMAP_MPUIO(3)
+ */
+static struct omap_mmc_platform_data mmc1_data = {
        .nr_slots                       = 1,
-       .switch_slot                    = NULL,
-       .init                           = h2_mmc_late_init,
-       .cleanup                        = h2_mmc_cleanup,
+       .dma_mask                       = 0xffffffff,
        .slots[0]       = {
-               .enabled                = 1,
-               .wire4                  = 1,
-               .set_power              = h2_mmc_set_power,
-               .set_bus_mode           = h2_mmc_set_bus_mode,
-               .get_ro                 = NULL,
-               .get_cover_state        = h2_mmc_get_cover_state,
+               .set_power              = mmc_set_power,
                .ocr_mask               = MMC_VDD_28_29 | MMC_VDD_30_31 |
                                          MMC_VDD_32_33 | MMC_VDD_33_34,
                .name                   = "mmcblk",
        },
 };
 
+static struct omap_mmc_platform_data *mmc_data[OMAP16XX_NR_MMC];
+
 void __init h2_mmc_init(void)
 {
-       omap1_init_mmc(&h2_mmc_data);
+       int ret;
+
+       ret = gpio_request(H2_TPS_GPIO_MMC_PWR_EN, "MMC power");
+       if (ret < 0)
+               return;
+       gpio_direction_output(H2_TPS_GPIO_MMC_PWR_EN, 0);
+
+       mmc_data[0] = &mmc1_data;
+       omap1_init_mmc(mmc_data, OMAP16XX_NR_MMC);
 }
 
 #else
@@ -107,7 +70,4 @@ void __init h2_mmc_init(void)
 {
 }
 
-void h2_mmc_slot_cover_handler(void *arg, int state)
-{
-}
 #endif
index ac51d255aa0c9b553167e458b3826d9388fe4cf0..2c12dfa8c09502b944bbb66b31e8dde34577a191 100644 (file)
@@ -437,10 +437,25 @@ static void __init h2_init_smc91x(void)
        }
 }
 
+static int tps_setup(struct i2c_client *client, void *context)
+{
+       tps65010_config_vregs1(TPS_LDO2_ENABLE | TPS_VLDO2_3_0V |
+                               TPS_LDO1_ENABLE | TPS_VLDO1_3_0V);
+
+       return 0;
+}
+
+static struct tps65010_board tps_board = {
+       .base           = H2_TPS_GPIO_BASE,
+       .outmask        = 0x0f,
+       .setup          = tps_setup,
+};
+
 static struct i2c_board_info __initdata h2_i2c_board_info[] = {
        {
                I2C_BOARD_INFO("tps65010", 0x48),
                .irq            = OMAP_GPIO_IRQ(58),
+               .platform_data  = &tps_board,
        }, {
                I2C_BOARD_INFO("isp1301_omap", 0x2d),
                .irq            = OMAP_GPIO_IRQ(2),
@@ -484,18 +499,6 @@ static struct omap_board_config_kernel h2_config[] __initdata = {
        { OMAP_TAG_LCD,         &h2_lcd_config },
 };
 
-static struct omap_gpio_switch h2_gpio_switches[] __initdata = {
-       {
-               .name                   = "mmc_slot",
-               .gpio                   = OMAP_MPUIO(1),
-               .type                   = OMAP_GPIO_SWITCH_TYPE_COVER,
-               .debounce_rising        = 100,
-               .debounce_falling       = 0,
-               .notify                 = h2_mmc_slot_cover_handler,
-               .notify_data            = NULL,
-       },
-};
-
 #define H2_NAND_RB_GPIO_PIN    62
 
 static int h2_nand_dev_ready(struct omap_nand_platform_data *data)
@@ -547,8 +550,6 @@ static void __init h2_init(void)
        omap_register_i2c_bus(1, 100, h2_i2c_board_info,
                              ARRAY_SIZE(h2_i2c_board_info));
        h2_mmc_init();
-       omap_register_gpio_switches(h2_gpio_switches,
-                                   ARRAY_SIZE(h2_gpio_switches));
 }
 
 static void __init h2_map_io(void)
index 44e9d536587a49c2ceb236ed287b7ce49ff5696c..c906db0ba8603a506184fd5f6cd2feac62f6b4b2 100644 (file)
  * published by the Free Software Foundation.
  */
 
+#include <linux/platform_device.h>
+
+#include <linux/i2c/tps65010.h>
+
 #include <mach/mmc.h>
 #include <mach/gpio.h>
 #include <mach/mmc.h>
 
-#ifdef CONFIG_MMC_OMAP
-static int slot_cover_open;
-static struct device *mmc_device;
+#if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE)
 
-static int h3_mmc_set_power(struct device *dev, int slot, int power_on,
+static int mmc_set_power(struct device *dev, int slot, int power_on,
                                int vdd)
 {
-#ifdef CONFIG_MMC_DEBUG
-       dev_dbg(dev, "Set slot %d power: %s (vdd %d)\n", slot + 1,
-               power_on ? "on" : "off", vdd);
-#endif
-       if (slot != 0) {
-               dev_err(dev, "No such slot %d\n", slot + 1);
-               return -ENODEV;
-       }
+       if (power_on)
+               gpio_direction_output(H3_TPS_GPIO_MMC_PWR_EN, 1);
+       else
+               gpio_direction_output(H3_TPS_GPIO_MMC_PWR_EN, 0);
 
        return 0;
 }
 
-static int h3_mmc_set_bus_mode(struct device *dev, int slot, int bus_mode)
-{
-       int ret = 0;
-
-#ifdef CONFIG_MMC_DEBUG
-       dev_dbg(dev, "Set slot %d bus_mode %s\n", slot + 1,
-               bus_mode == MMC_BUSMODE_OPENDRAIN ? "open-drain" : "push-pull");
-#endif
-       if (slot != 0) {
-               dev_err(dev, "No such slot %d\n", slot + 1);
-               return -ENODEV;
-       }
-
-       /* Treated on upper level */
-
-       return bus_mode;
-}
-
-static int h3_mmc_get_cover_state(struct device *dev, int slot)
-{
-       BUG_ON(slot != 0);
-
-       return slot_cover_open;
-}
-
-void h3_mmc_slot_cover_handler(void *arg, int state)
-{
-       if (mmc_device == NULL)
-               return;
-
-       slot_cover_open = state;
-       omap_mmc_notify_cover_event(mmc_device, 0, state);
-}
-
-static int h3_mmc_late_init(struct device *dev)
-{
-       int ret = 0;
-
-       mmc_device = dev;
-
-       return ret;
-}
-
-static void h3_mmc_cleanup(struct device *dev)
-{
-}
-
-static struct omap_mmc_platform_data h3_mmc_data = {
+/*
+ * H3 could use the following functions tested:
+ * - mmc_get_cover_state that uses OMAP_MPUIO(1)
+ * - mmc_get_wp that maybe uses OMAP_MPUIO(3)
+ */
+static struct omap_mmc_platform_data mmc1_data = {
        .nr_slots                       = 1,
-       .switch_slot                    = NULL,
-       .init                           = h3_mmc_late_init,
-       .cleanup                        = h3_mmc_cleanup,
+       .dma_mask                       = 0xffffffff,
        .slots[0]       = {
-               .enabled                = 1,
-               .wire4                  = 1,
-               .set_power              = h3_mmc_set_power,
-               .set_bus_mode           = h3_mmc_set_bus_mode,
-               .get_ro                 = NULL,
-               .get_cover_state        = h3_mmc_get_cover_state,
+               .set_power              = mmc_set_power,
                .ocr_mask               = MMC_VDD_28_29 | MMC_VDD_30_31 |
                                          MMC_VDD_32_33 | MMC_VDD_33_34,
                .name                   = "mmcblk",
        },
 };
 
+static struct omap_mmc_platform_data *mmc_data[OMAP16XX_NR_MMC];
+
 void __init h3_mmc_init(void)
 {
-       omap1_init_mmc(&h3_mmc_data);
+       int ret;
+
+       ret = gpio_request(H3_TPS_GPIO_MMC_PWR_EN, "MMC power");
+       if (ret < 0)
+               return;
+       gpio_direction_output(H3_TPS_GPIO_MMC_PWR_EN, 0);
+
+       mmc_data[0] = &mmc1_data;
+       omap1_init_mmc(mmc_data, OMAP16XX_NR_MMC);
 }
 
 #else
@@ -111,7 +70,4 @@ void __init h3_mmc_init(void)
 {
 }
 
-void h3_mmc_slot_cover_handler(void *arg, int state)
-{
-}
 #endif
index 0c1b001626f4ccfe042294e7071f3a6b370c4907..c333db18cb178f125339220474318b06ad975791 100644 (file)
@@ -476,18 +476,6 @@ static struct omap_board_config_kernel h3_config[] __initdata = {
        { OMAP_TAG_LCD,         &h3_lcd_config },
 };
 
-static struct omap_gpio_switch h3_gpio_switches[] __initdata = {
-       {
-               .name                   = "mmc_slot",
-               .gpio                   = OMAP_MPUIO(1),
-               .type                   = OMAP_GPIO_SWITCH_TYPE_COVER,
-               .debounce_rising        = 100,
-               .debounce_falling       = 0,
-               .notify                 = h3_mmc_slot_cover_handler,
-               .notify_data            = NULL,
-       },
-};
-
 #define H3_NAND_RB_GPIO_PIN    10
 
 static int nand_dev_ready(struct omap_nand_platform_data *data)
@@ -643,8 +631,6 @@ static void __init h3_init(void)
        omap_register_i2c_bus(1, 100, h3_i2c_board_info,
                              ARRAY_SIZE(h3_i2c_board_info));
        h3_mmc_init();
-       omap_register_gpio_switches(h3_gpio_switches,
-                                   ARRAY_SIZE(h3_gpio_switches));
 }
 
 static void __init h3_init_smc91x(void)
index 9ed0feff6fbc2844442333c87bd05e6e6c13d889..7a97f6b5357a62329a3244a36970fae27d2fc024 100644 (file)
@@ -361,18 +361,49 @@ static struct omap_lcd_config innovator1610_lcd_config __initdata = {
 };
 #endif
 
-static struct omap_mmc_platform_data innovator_mmc_data = {
+#if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE)
+
+static int mmc_set_power(struct device *dev, int slot, int power_on,
+                               int vdd)
+{
+       if (power_on)
+               fpga_write(fpga_read(OMAP1510_FPGA_POWER) | (1 << 3),
+                               OMAP1510_FPGA_POWER);
+       else
+               fpga_write(fpga_read(OMAP1510_FPGA_POWER) & ~(1 << 3),
+                               OMAP1510_FPGA_POWER);
+
+       return 0;
+}
+
+/*
+ * Innovator could use the following functions tested:
+ * - mmc_get_wp that uses OMAP_MPUIO(3)
+ * - mmc_get_cover_state that uses FPGA F4 UIO43
+ */
+static struct omap_mmc_platform_data mmc1_data = {
        .nr_slots                       = 1,
        .slots[0]       = {
-               .enabled                = 1,
+               .set_power              = mmc_set_power,
                .wire4                  = 1,
-               .wp_pin                 = OMAP_MPUIO(3),
-               .power_pin              = -1,   /* FPGA F3 UIO42 */
-               .switch_pin             = -1,   /* FPGA F4 UIO43 */
                .name                   = "mmcblk",
        },
 };
 
+static struct omap_mmc_platform_data *mmc_data[OMAP16XX_NR_MMC];
+
+void __init innovator_mmc_init(void)
+{
+       mmc_data[0] = &mmc1_data;
+       omap1_init_mmc(mmc_data, OMAP15XX_NR_MMC);
+}
+
+#else
+static inline void innovator_mmc_init(void)
+{
+}
+#endif
+
 static struct omap_uart_config innovator_uart_config __initdata = {
        .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
 };
@@ -414,7 +445,7 @@ static void __init innovator_init(void)
        omap_board_config_size = ARRAY_SIZE(innovator_config);
        omap_serial_init();
        omap_register_i2c_bus(1, 100, NULL, 0);
-       omap1_init_mmc(&innovator_mmc_data);
+       innovator_mmc_init();
 }
 
 static void __init innovator_map_io(void)
index 6e96a9d81ad739c046e009a016c9963010f7d962..7b28f4da214a63a907e637cf5888018698a3b8f5 100644 (file)
@@ -216,27 +216,66 @@ static struct omap_usb_config nokia770_usb_config __initdata = {
        .pins[0]        = 6,
 };
 
-static struct omap_mmc_platform_data nokia770_mmc_data = {
-       .nr_slots                       = 2,
+#if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE)
+
+#define NOKIA770_GPIO_MMC_POWER                41
+#define NOKIA770_GPIO_MMC_SWITCH       23
+
+static int nokia770_mmc_set_power(struct device *dev, int slot, int power_on,
+                               int vdd)
+{
+       if (power_on)
+               gpio_set_value(NOKIA770_GPIO_MMC_POWER, 1);
+       else
+               gpio_set_value(NOKIA770_GPIO_MMC_POWER, 0);
+
+       return 0;
+}
+
+static int nokia770_mmc_get_cover_state(struct device *dev, int slot)
+{
+       return gpio_get_value(NOKIA770_GPIO_MMC_SWITCH);
+}
+
+static struct omap_mmc_platform_data nokia770_mmc2_data = {
+       .nr_slots                       = 1,
+       .dma_mask                       = 0xffffffff,
        .slots[0]       = {
-               .enabled                = 0,
-               .wire4                  = 0,
-               .wp_pin                 = -1,
-               .power_pin              = -1,
-               .switch_pin             = -1,
+               .set_power              = nokia770_mmc_set_power,
+               .get_cover_state        = nokia770_mmc_get_cover_state,
                .name                   = "mmcblk",
        },
-       .slots[1]       = {
-               .enabled                = 0,
-               .wire4                  = 0,
-               .wp_pin                 = -1,
-               .power_pin              = -1,
-               .switch_pin             = -1,
-               .name                   = "mmcblk",
-       },
-
 };
 
+static struct omap_mmc_platform_data *nokia770_mmc_data[OMAP16XX_NR_MMC];
+
+static void __init nokia770_mmc_init(void)
+{
+       int ret;
+
+       ret = gpio_request(NOKIA770_GPIO_MMC_POWER, "MMC power");
+       if (ret < 0)
+               return;
+       gpio_direction_output(NOKIA770_GPIO_MMC_POWER, 0);
+
+       ret = gpio_request(NOKIA770_GPIO_MMC_SWITCH, "MMC cover");
+       if (ret < 0) {
+               gpio_free(NOKIA770_GPIO_MMC_POWER);
+               return;
+       }
+       gpio_direction_input(NOKIA770_GPIO_MMC_SWITCH);
+
+       /* Only the second MMC controller is used */
+       nokia770_mmc_data[1] = &nokia770_mmc2_data;
+       omap1_init_mmc(nokia770_mmc_data, OMAP16XX_NR_MMC);
+}
+
+#else
+static inline void nokia770_mmc_init(void)
+{
+}
+#endif
+
 static struct omap_board_config_kernel nokia770_config[] __initdata = {
        { OMAP_TAG_USB,         NULL },
 };
@@ -382,7 +421,7 @@ static void __init omap_nokia770_init(void)
        hwa742_dev_init();
        ads7846_dev_init();
        mipid_dev_init();
-       omap1_init_mmc(&nokia770_mmc_data);
+       nokia770_mmc_init();
 }
 
 static void __init omap_nokia770_map_io(void)
index 992ade0aa8092af47ee371fcb4de0154e8870dd3..ee49e2ccf1f99d833cbbb4ab08580a00c8412ead 100644 (file)
@@ -45,7 +45,6 @@
 #include <mach/mcbsp.h>
 #include <mach/omap-alsa.h>
 #include <mach/gpio-switch.h>
-#include <mach/mmc.h>
 
 static void __init omap_palmte_init_irq(void)
 {
@@ -197,17 +196,6 @@ static struct omap_usb_config palmte_usb_config __initdata = {
        .pins[0]        = 2,
 };
 
-static struct omap_mmc_platform_data palmzte_mmc_data = {
-       .nr_slots                       = 1,
-       .slots[0]       = {
-               .enabled                = 1,
-               .wp_pin                 = PALMTE_MMC_WP_GPIO,
-               .power_pin              = PALMTE_MMC_POWER_GPIO,
-               .switch_pin             = PALMTE_MMC_SWITCH_GPIO,
-               .name                   = "mmcblk",
-       },
-};
-
 static struct omap_lcd_config palmte_lcd_config __initdata = {
        .ctrl_name      = "internal",
 };
@@ -410,7 +398,6 @@ static void __init omap_palmte_init(void)
        palmte_misc_gpio_setup();
        omap_serial_init();
        omap_register_i2c_bus(1, 100, NULL, 0);
-       omap1_init_mmc(&palmte_mmc_data);
 }
 
 static void __init omap_palmte_map_io(void)
index 5c75b9a4d52c87ba8c37cf30d12f0beaf8bfe7bc..e8116c5125909a5e5583232818fa617a0b866158 100644 (file)
@@ -43,7 +43,6 @@
 #include <mach/keypad.h>
 #include <mach/common.h>
 #include <mach/omap-alsa.h>
-#include <mach/mmc.h>
 
 #include <linux/spi/spi.h>
 #include <linux/spi/ads7846.h>
@@ -268,18 +267,6 @@ static struct omap_usb_config palmz71_usb_config __initdata = {
        .pins[0]        = 2,
 };
 
-static struct omap_mmc_platform_data palmz71_mmc_data = {
-       .nr_slots                       = 1,
-       .slots[0]       = {
-               .enabled                = 1,
-               .wire4                  = 0,
-               .wp_pin                 = PALMZ71_MMC_WP_GPIO,
-               .power_pin              = -1,
-               .switch_pin             = PALMZ71_MMC_IN_GPIO,
-               .name                   = "mmcblk",
-       },
-};
-
 static struct omap_lcd_config palmz71_lcd_config __initdata = {
        .ctrl_name = "internal",
 };
@@ -367,7 +354,6 @@ omap_palmz71_init(void)
        omap_serial_init();
        omap_register_i2c_bus(1, 100, NULL, 0);
        palmz71_gpio_setup(0);
-       omap1_init_mmc(&palmz71_mmc_data);
 }
 
 static void __init
index 524d22de1d5ee22e60ebd8d69179c0b1cb5b8a6d..66a4d7d5255d2f767c18cf370b074e4472ff451c 100644 (file)
 #include <mach/mmc.h>
 #include <mach/gpio.h>
 
-#ifdef CONFIG_MMC_OMAP
-static int slot_cover_open;
-static struct device *mmc_device;
+#if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE)
 
-static int sx1_mmc_set_power(struct device *dev, int slot, int power_on,
+static int mmc_set_power(struct device *dev, int slot, int power_on,
                                int vdd)
 {
        int err;
        u8 dat = 0;
 
-#ifdef CONFIG_MMC_DEBUG
-       dev_dbg(dev, "Set slot %d power: %s (vdd %d)\n", slot + 1,
-               power_on ? "on" : "off", vdd);
-#endif
-
-       if (slot != 0) {
-               dev_err(dev, "No such slot %d\n", slot + 1);
-               return -ENODEV;
-       }
-
        err = sx1_i2c_read_byte(SOFIA_I2C_ADDR, SOFIA_POWER1_REG, &dat);
        if (err < 0)
                return err;
@@ -50,70 +38,23 @@ static int sx1_mmc_set_power(struct device *dev, int slot, int power_on,
        return sx1_i2c_write_byte(SOFIA_I2C_ADDR, SOFIA_POWER1_REG, dat);
 }
 
-static int sx1_mmc_set_bus_mode(struct device *dev, int slot, int bus_mode)
-{
-#ifdef CONFIG_MMC_DEBUG
-       dev_dbg(dev, "Set slot %d bus_mode %s\n", slot + 1,
-               bus_mode == MMC_BUSMODE_OPENDRAIN ? "open-drain" : "push-pull");
-#endif
-       if (slot != 0) {
-               dev_err(dev, "No such slot %d\n", slot + 1);
-               return -ENODEV;
-       }
-
-       return 0;
-}
-
-static int sx1_mmc_get_cover_state(struct device *dev, int slot)
-{
-       BUG_ON(slot != 0);
-
-       return slot_cover_open;
-}
-
-void sx1_mmc_slot_cover_handler(void *arg, int state)
-{
-       if (mmc_device == NULL)
-               return;
-
-       slot_cover_open = state;
-       omap_mmc_notify_cover_event(mmc_device, 0, state);
-}
-
-static int sx1_mmc_late_init(struct device *dev)
-{
-       int ret = 0;
-
-       mmc_device = dev;
-
-       return ret;
-}
-
-static void sx1_mmc_cleanup(struct device *dev)
-{
-}
-
-static struct omap_mmc_platform_data sx1_mmc_data = {
+/* Cover switch is at OMAP_MPUIO(3) */
+static struct omap_mmc_platform_data mmc1_data = {
        .nr_slots                       = 1,
-       .switch_slot                    = NULL,
-       .init                           = sx1_mmc_late_init,
-       .cleanup                        = sx1_mmc_cleanup,
        .slots[0]       = {
-               .enabled                = 1,
-               .wire4                  = 0,
-               .set_power              = sx1_mmc_set_power,
-               .set_bus_mode           = sx1_mmc_set_bus_mode,
-               .get_ro                 = NULL,
-               .get_cover_state        = sx1_mmc_get_cover_state,
+               .set_power              = mmc_set_power,
                .ocr_mask               = MMC_VDD_28_29 | MMC_VDD_30_31 |
                                          MMC_VDD_32_33 | MMC_VDD_33_34,
                .name                   = "mmcblk",
        },
 };
 
+static struct omap_mmc_platform_data *mmc_data[OMAP15XX_NR_MMC];
+
 void __init sx1_mmc_init(void)
 {
-       omap1_init_mmc(&sx1_mmc_data);
+       mmc_data[0] = &mmc1_data;
+       omap1_init_mmc(mmc_data, OMAP15XX_NR_MMC);
 }
 
 #else
@@ -122,7 +63,4 @@ void __init sx1_mmc_init(void)
 {
 }
 
-void sx1_mmc_slot_cover_handler(void *arg, int state)
-{
-}
 #endif
index 0d235e7facdbd22f034803cb5e0291f3167498ee..e9ba5dc5074a0bdb2beaece26931e43ff3f57d9c 100644 (file)
@@ -410,18 +410,6 @@ static struct omap_board_config_kernel sx1_config[] __initdata = {
        { OMAP_TAG_UART,        &sx1_uart_config },
 };
 
-static struct omap_gpio_switch sx1_gpio_switches[] __initdata = {
-       {
-               .name                   = "mmc_slot",
-               .gpio                   = OMAP_MPUIO(3),
-               .type                   = OMAP_GPIO_SWITCH_TYPE_COVER,
-               .debounce_rising        = 100,
-               .debounce_falling       = 0,
-               .notify                 = sx1_mmc_slot_cover_handler,
-               .notify_data            = NULL,
-       },
-};
-
 /*-----------------------------------------*/
 
 static void __init omap_sx1_init(void)
@@ -433,8 +421,6 @@ static void __init omap_sx1_init(void)
        omap_serial_init();
        omap_register_i2c_bus(1, 100, NULL, 0);
        sx1_mmc_init();
-       omap_register_gpio_switches(sx1_gpio_switches,
-                                   ARRAY_SIZE(sx1_gpio_switches));
 
        /* turn on USB power */
        /* sx1_setusbpower(1); cant do it here because i2c is not ready */
index 57be5298f539e103981b0c2f4023a1c77bfa4357..069ca8d48aa33cb4bc8e8fb37716a84fa292aa1f 100644 (file)
@@ -34,7 +34,6 @@
 #include <mach/mux.h>
 #include <mach/tc.h>
 #include <mach/usb.h>
-#include <mach/mmc.h>
 
 static struct plat_serial8250_port voiceblue_ports[] = {
        {
@@ -141,16 +140,6 @@ static struct omap_usb_config voiceblue_usb_config __initdata = {
        .pins[2]        = 6,
 };
 
-static struct omap_mmc_platform_data voiceblue_mmc_data = {
-       .nr_slots                       = 1,
-       .slots[0]       = {
-               .enabled                = 1,
-               .power_pin              = 2,
-               .switch_pin             = -1,
-               .name                   = "mmcblk",
-       },
-};
-
 static struct omap_uart_config voiceblue_uart_config __initdata = {
        .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
 };
@@ -204,8 +193,6 @@ static void __init voiceblue_init(void)
         * (it is connected through invertor) */
        omap_writeb(0x00, OMAP_LPG1_LCR);
        omap_writeb(0x00, OMAP_LPG1_PMR);       /* Disable clock */
-
-       omap1_init_mmc(&voiceblue_mmc_data);
 }
 
 static void __init voiceblue_map_io(void)
index f8ad19f3c9d8ceb4e6df63e14e718f0de8e6ee94..44eda0f83b3aa708a8457f4ee8917017609593d5 100644 (file)
@@ -703,7 +703,6 @@ static struct clk bclk_16xx = {
 
 static struct clk mmc1_ck = {
        .name           = "mmc_ck",
-       .id             = 1,
        /* Functional clock is direct from ULPD, interface clock is ARMPER */
        .parent         = &armper_ck.clk,
        .rate           = 48000000,
@@ -718,7 +717,7 @@ static struct clk mmc1_ck = {
 
 static struct clk mmc2_ck = {
        .name           = "mmc_ck",
-       .id             = 2,
+       .id             = 1,
        /* Functional clock is direct from ULPD, interface clock is ARMPER */
        .parent         = &armper_ck.clk,
        .rate           = 48000000,
index 97b472c25cd9ade864be93d075b8c5c35717bcdc..e89d241144cbe46362d6af16642c8e3e06c82b88 100644 (file)
@@ -104,71 +104,10 @@ static inline void omap_init_mbox(void) { }
 
 #if    defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE)
 
-#define        OMAP1_MMC1_BASE         0xfffb7800
-#define        OMAP1_MMC1_END          (OMAP1_MMC1_BASE + 0x7f)
-#define OMAP1_MMC1_INT         INT_MMC
-
-#define        OMAP1_MMC2_BASE         0xfffb7c00      /* omap16xx only */
-#define        OMAP1_MMC2_END          (OMAP1_MMC2_BASE + 0x7f)
-#define        OMAP1_MMC2_INT          INT_1610_MMC2
-
-static u64 omap1_mmc1_dmamask = 0xffffffff;
-
-static struct resource omap1_mmc1_resources[] = {
-       {
-               .start          = OMAP1_MMC1_BASE,
-               .end            = OMAP1_MMC1_END,
-               .flags          = IORESOURCE_MEM,
-       },
-       {
-               .start          = OMAP1_MMC1_INT,
-               .flags          = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device omap1_mmc1_device = {
-       .name           = "mmci-omap",
-       .id             = 1,
-       .dev = {
-               .dma_mask       = &omap1_mmc1_dmamask,
-       },
-       .num_resources  = ARRAY_SIZE(omap1_mmc1_resources),
-       .resource       = omap1_mmc1_resources,
-};
-
-#if defined(CONFIG_ARCH_OMAP16XX)
-
-static u64 omap1_mmc2_dmamask = 0xffffffff;
-
-static struct resource omap1_mmc2_resources[] = {
-       {
-               .start          = OMAP1_MMC2_BASE,
-               .end            = OMAP1_MMC2_END,
-               .flags          = IORESOURCE_MEM,
-       },
-       {
-               .start          = OMAP1_MMC2_INT,
-               .flags          = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device omap1_mmc2_device = {
-       .name           = "mmci-omap",
-       .id             = 2,
-       .dev = {
-               .dma_mask       = &omap1_mmc2_dmamask,
-       },
-       .num_resources  = ARRAY_SIZE(omap1_mmc2_resources),
-       .resource       = omap1_mmc2_resources,
-};
-#define OMAP1_MMC2_DEVICE      &omap1_mmc2_device
-#else
-#define OMAP1_MMC2_DEVICE      &omap1_mmc1_device      /* Dummy */
-#endif
-
-static inline void omap1_mmc_mux(struct omap_mmc_platform_data *info)
+static inline void omap1_mmc_mux(struct omap_mmc_platform_data *mmc_controller,
+                       int controller_nr)
 {
-       if (info->slots[0].enabled) {
+       if (controller_nr == 0) {
                omap_cfg_reg(MMC_CMD);
                omap_cfg_reg(MMC_CLK);
                omap_cfg_reg(MMC_DAT0);
@@ -177,23 +116,23 @@ static inline void omap1_mmc_mux(struct omap_mmc_platform_data *info)
                        omap_cfg_reg(P19_1710_MMC_CMDDIR);
                        omap_cfg_reg(P20_1710_MMC_DATDIR0);
                }
-               if (info->slots[0].wire4) {
+               if (mmc_controller->slots[0].wire4) {
                        omap_cfg_reg(MMC_DAT1);
                        /* NOTE: DAT2 can be on W10 (here) or M15 */
-                       if (!info->slots[0].nomux)
+                       if (!mmc_controller->slots[0].nomux)
                                omap_cfg_reg(MMC_DAT2);
                        omap_cfg_reg(MMC_DAT3);
                }
        }
 
        /* Block 2 is on newer chips, and has many pinout options */
-       if (cpu_is_omap16xx() && info->slots[1].enabled) {
-               if (!info->slots[1].nomux) {
+       if (cpu_is_omap16xx() && controller_nr == 1) {
+               if (!mmc_controller->slots[1].nomux) {
                        omap_cfg_reg(Y8_1610_MMC2_CMD);
                        omap_cfg_reg(Y10_1610_MMC2_CLK);
                        omap_cfg_reg(R18_1610_MMC2_CLKIN);
                        omap_cfg_reg(W8_1610_MMC2_DAT0);
-                       if (info->slots[1].wire4) {
+                       if (mmc_controller->slots[1].wire4) {
                                omap_cfg_reg(V8_1610_MMC2_DAT1);
                                omap_cfg_reg(W15_1610_MMC2_DAT2);
                                omap_cfg_reg(R10_1610_MMC2_DAT3);
@@ -212,18 +151,38 @@ static inline void omap1_mmc_mux(struct omap_mmc_platform_data *info)
        }
 }
 
-void omap1_init_mmc(struct omap_mmc_platform_data *info)
+void __init omap1_init_mmc(struct omap_mmc_platform_data **mmc_data,
+                       int nr_controllers)
 {
-       if (!info)
-               return;
-
-       omap1_mmc_mux(info);
-       platform_set_drvdata(&omap1_mmc1_device, info);
-
-       if (cpu_is_omap16xx())
-               platform_set_drvdata(OMAP1_MMC2_DEVICE, info);
+       int i;
+
+       for (i = 0; i < nr_controllers; i++) {
+               unsigned long base, size;
+               unsigned int irq = 0;
+
+               if (!mmc_data[i])
+                       continue;
+
+               omap1_mmc_mux(mmc_data[i], i);
+
+               switch (i) {
+               case 0:
+                       base = OMAP1_MMC1_BASE;
+                       irq = INT_MMC;
+                       break;
+               case 1:
+                       if (!cpu_is_omap16xx())
+                               return;
+                       base = OMAP1_MMC2_BASE;
+                       irq = INT_1610_MMC2;
+                       break;
+               default:
+                       continue;
+               }
+               size = OMAP1_MMC_SIZE;
 
-       omap_init_mmc(info, &omap1_mmc1_device, OMAP1_MMC2_DEVICE);
+               omap_mmc_add(i, base, size, irq, mmc_data[i]);
+       };
 }
 
 #endif
index a33e8ca9114a1cc2deb7f3b8224aac8ed73183b8..35c2c07b08d0a27749127ebde5e78966246b383f 100644 (file)
@@ -62,13 +62,12 @@ static void apollon_mmc_cleanup(struct device *dev)
 /*
  * Note: If you want to detect card feature, please assign GPIO 37
  */
-static struct omap_mmc_platform_data apollon_mmc_data = {
+static struct omap_mmc_platform_data mmc1_data = {
        .nr_slots                       = 1,
-       .switch_slot                    = NULL,
        .init                           = apollon_mmc_late_init,
        .cleanup                        = apollon_mmc_cleanup,
+       .dma_mask                       = 0xffffffff,
        .slots[0]       = {
-               .enabled                = 1,
                .wire4                  = 1,
 
                /*
@@ -79,17 +78,18 @@ static struct omap_mmc_platform_data apollon_mmc_data = {
 
                .set_power              = apollon_mmc_set_power,
                .set_bus_mode           = apollon_mmc_set_bus_mode,
-               .get_ro                 = NULL,
-               .get_cover_state        = NULL,
                .ocr_mask               = MMC_VDD_30_31 | MMC_VDD_31_32 |
                                          MMC_VDD_32_33 | MMC_VDD_33_34,
                .name                   = "mmcblk",
        },
 };
 
+static struct omap_mmc_platform_data *mmc_data[OMAP24XX_NR_MMC];
+
 void __init apollon_mmc_init(void)
 {
-       omap2_init_mmc(&apollon_mmc_data);
+       mmc_data[0] = &mmc1_data;
+       omap2_init_mmc(mmc_data, OMAP24XX_NR_MMC);
 }
 
 #else  /* !CONFIG_MMC_OMAP */
index 169c5ee8b742c54122a460000045fe93656d6807..06119e9d0f9fdd96b97aafa18d6298bf059f5e47 100644 (file)
@@ -224,17 +224,16 @@ static void h4_mmc_cleanup(struct device *dev)
        menelaus_unregister_mmc_callback();
 }
 
-static struct omap_mmc_platform_data h4_mmc_data = {
+static struct omap_mmc_platform_data mmc1_data = {
        .nr_slots               = 2,
        .switch_slot            = h4_mmc_switch_slot,
        .init                   = h4_mmc_late_init,
        .cleanup                = h4_mmc_cleanup,
+       .dma_mask               = 0xffffffff,
        .slots[0] = {
-               .enabled        = 1,
                .wire4          = 1,
                .set_power      = h4_mmc_set_power,
                .set_bus_mode   = h4_mmc_set_bus_mode,
-               .get_ro         = NULL,
                .get_cover_state= h4_mmc_slot1_cover_state,
                .ocr_mask       = MMC_VDD_165_195 |
                                  MMC_VDD_28_29 | MMC_VDD_30_31 |
@@ -242,11 +241,9 @@ static struct omap_mmc_platform_data h4_mmc_data = {
                .name           = "slot1",
        },
        .slots[1] = {
-               .enabled        = 1,
                .wire4          = 1,
                .set_power      = h4_mmc_set_power,
                .set_bus_mode   = h4_mmc_set_bus_mode,
-               .get_ro         = NULL,
                .get_cover_state= h4_mmc_slot2_cover_state,
                .ocr_mask       = MMC_VDD_165_195 | MMC_VDD_20_21 |
                                  MMC_VDD_21_22 | MMC_VDD_22_23 | MMC_VDD_23_24 |
@@ -257,9 +254,12 @@ static struct omap_mmc_platform_data h4_mmc_data = {
        },
 };
 
+static struct omap_mmc_platform_data *mmc_data[OMAP24XX_NR_MMC];
+
 void __init h4_mmc_init(void)
 {
-       omap2_init_mmc(&h4_mmc_data);
+       mmc_data[0] = &mmc1_data;
+       omap2_init_mmc(mmc_data, OMAP24XX_NR_MMC);
 }
 
 #else
index bcbba9440bf16632cdef77e655f5abd1fbe9f055..2cf8213f729c37a4d93a8d19d348bc3b82574969 100644 (file)
@@ -19,7 +19,7 @@
 #include <mach/gpio.h>
 #include <mach/mmc.h>
 
-#ifdef CONFIG_MMC_OMAP
+#if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE)
 
 static const int slot_switch_gpio = 96;
 
@@ -296,19 +296,22 @@ static void n800_mmc_cleanup(struct device *dev)
        }
 }
 
-static struct omap_mmc_platform_data n800_mmc_data = {
+/*
+ * MMC controller1 has two slots that are multiplexed via I2C.
+ * MMC controller2 is not in use.
+ */
+static struct omap_mmc_platform_data mmc1_data = {
        .nr_slots               = 2,
        .switch_slot            = n800_mmc_switch_slot,
        .init                   = n800_mmc_late_init,
        .cleanup                = n800_mmc_cleanup,
        .shutdown               = n800_mmc_shutdown,
        .max_freq               = 24000000,
+       .dma_mask               = 0xffffffff,
        .slots[0] = {
-               .enabled        = 1,
                .wire4          = 1,
                .set_power      = n800_mmc_set_power,
                .set_bus_mode   = n800_mmc_set_bus_mode,
-               .get_ro         = NULL,
                .get_cover_state= n800_mmc_get_cover_state,
                .ocr_mask       = MMC_VDD_165_195 | MMC_VDD_30_31 |
                                  MMC_VDD_32_33   | MMC_VDD_33_34,
@@ -317,7 +320,6 @@ static struct omap_mmc_platform_data n800_mmc_data = {
        .slots[1] = {
                .set_power      = n800_mmc_set_power,
                .set_bus_mode   = n800_mmc_set_bus_mode,
-               .get_ro         = NULL,
                .get_cover_state= n800_mmc_get_cover_state,
                .ocr_mask       = MMC_VDD_165_195 | MMC_VDD_20_21 |
                                  MMC_VDD_21_22 | MMC_VDD_22_23 | MMC_VDD_23_24 |
@@ -328,11 +330,13 @@ static struct omap_mmc_platform_data n800_mmc_data = {
        },
 };
 
+static struct omap_mmc_platform_data *mmc_data[OMAP24XX_NR_MMC];
+
 void __init n800_mmc_init(void)
 
 {
        if (machine_is_nokia_n810()) {
-               n800_mmc_data.slots[0].name = "external";
+               n800_mmc1_data.slots[0].name = "external";
 
                /*
                 * Some Samsung Movinand chips do not like open-ended
@@ -340,8 +344,8 @@ void __init n800_mmc_init(void)
                 * while doing so. Reducing the number of blocks in
                 * the transfer or delays in clock disable do not help
                 */
-               n800_mmc_data.slots[1].name = "internal";
-               n800_mmc_data.slots[1].ban_openended = 1;
+               n800_mmc1_data.slots[1].name = "internal";
+               n800_mmc1_data.slots[1].ban_openended = 1;
        }
 
        if (omap_request_gpio(slot_switch_gpio) < 0)
@@ -361,7 +365,8 @@ void __init n800_mmc_init(void)
                omap_set_gpio_direction(n810_slot2_pw_vdd, 0);
        }
 
-       omap2_init_mmc(&n800_mmc_data);
+       mmc_data[0] = &mmc1_data;
+       omap2_init_mmc(mmc_data, OMAP24XX_NR_MMC);
 }
 #else
 
index f11d16e7ba3e389106516828307f021f7743c08a..2900a4a64dd281622a8bc7fd57245a4c0d661ab4 100644 (file)
@@ -2812,7 +2812,6 @@ static struct clk mdm_intc_ick = {
 
 static struct clk mmchsdb1_fck = {
        .name           = "mmchsdb_fck",
-       .id             = 1,
        .parent         = &func_32k_ck,
        .prcm_mod       = CORE_MOD,
        .flags          = CLOCK_IN_OMAP243X,
@@ -2824,7 +2823,7 @@ static struct clk mmchsdb1_fck = {
 
 static struct clk mmchsdb2_fck = {
        .name           = "mmchsdb_fck",
-       .id             = 2,
+       .id             = 1,
        .parent         = &func_32k_ck,
        .prcm_mod       = CORE_MOD,
        .flags          = CLOCK_IN_OMAP243X,
index 857c059d3050348f7bc418239e750ad842cd6030..8ce7097544f52063ed61fb54bf222b80ad8ea52f 100644 (file)
@@ -1411,7 +1411,7 @@ static struct clk core_96m_fck = {
 
 static struct clk mmchs3_fck = {
        .name           = "mmchs_fck",
-       .id             = 3,
+       .id             = 2,
        .parent         = &core_96m_fck,
        .prcm_mod       = CORE_MOD,
        .enable_reg     = CM_FCLKEN1,
@@ -1424,7 +1424,7 @@ static struct clk mmchs3_fck = {
 
 static struct clk mmchs2_fck = {
        .name           = "mmchs_fck",
-       .id             = 2,
+       .id             = 1,
        .parent         = &core_96m_fck,
        .prcm_mod       = CORE_MOD,
        .enable_reg     = CM_FCLKEN1,
@@ -1449,7 +1449,6 @@ static struct clk mspro_fck = {
 
 static struct clk mmchs1_fck = {
        .name           = "mmchs_fck",
-       .id             = 1,
        .parent         = &core_96m_fck,
        .prcm_mod       = CORE_MOD,
        .enable_reg     = CM_FCLKEN1,
@@ -1868,7 +1867,7 @@ static struct clk usbtll_ick = {
 
 static struct clk mmchs3_ick = {
        .name           = "mmchs_ick",
-       .id             = 3,
+       .id             = 2,
        .parent         = &core_l4_ick,
        .prcm_mod       = CORE_MOD,
        .enable_reg     = CM_ICLKEN1,
@@ -1930,7 +1929,7 @@ static struct clk des2_ick = {
 
 static struct clk mmchs2_ick = {
        .name           = "mmchs_ick",
-       .id             = 2,
+       .id             = 1,
        .parent         = &core_l4_ick,
        .prcm_mod       = CORE_MOD,
        .enable_reg     = CM_ICLKEN1,
@@ -1943,7 +1942,6 @@ static struct clk mmchs2_ick = {
 
 static struct clk mmchs1_ick = {
        .name           = "mmchs_ick",
-       .id             = 1,
        .parent         = &core_l4_ick,
        .prcm_mod       = CORE_MOD,
        .enable_reg     = CM_ICLKEN1,
index ba0e098cc0f1b86f7c30b35ff33be9eef5154ca2..32550a55fa4db8cf7ae7a9b657c62f275f00cae0 100644 (file)
@@ -361,75 +361,17 @@ static inline void omap_init_sha1_md5(void) { }
 #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)
+static inline void omap2_mmc_mux(struct omap_mmc_platform_data *mmc_controller,
+                       int controller_nr)
 {
-       if (!cpu_is_omap2420())
-               return;
-
-       if (info->slots[0].enabled) {
+       if (cpu_is_omap2420() && controller_nr == 0) {
                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) {
+               if (mmc_controller->slots[0].wire4) {
                        omap_cfg_reg(H14_24XX_MMC_DAT1);
                        omap_cfg_reg(E19_24XX_MMC_DAT2);
                        omap_cfg_reg(D19_24XX_MMC_DAT3);
@@ -442,7 +384,7 @@ static inline void omap2_mmc_mux(struct omap_mmc_platform_data *info)
                 * Use internal loop-back in MMC/SDIO Module Input Clock
                 * selection
                 */
-               if (info->slots[0].internal_clock) {
+               if (mmc_controller->slots[0].internal_clock) {
                        u32 v = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0);
                        v |= (1 << 24);
                        omap_ctrl_writel(v, OMAP2_CONTROL_DEVCONF0);
@@ -450,15 +392,46 @@ static inline void omap2_mmc_mux(struct omap_mmc_platform_data *info)
        }
 }
 
-void omap2_init_mmc(struct omap_mmc_platform_data *info)
+void __init omap2_init_mmc(struct omap_mmc_platform_data **mmc_data,
+                       int nr_controllers)
 {
-       if (!info)
-               return;
+       int i;
+
+       for (i = 0; i < nr_controllers; i++) {
+               unsigned long base, size;
+               unsigned int irq = 0;
+
+               if (!mmc_data[i])
+                       continue;
+
+               omap2_mmc_mux(mmc_data[i], i);
+
+               switch (i) {
+               case 0:
+                       base = OMAP2_MMC1_BASE;
+                       irq = INT_24XX_MMC_IRQ;
+                       break;
+               case 1:
+                       base = OMAP2_MMC2_BASE;
+                       irq = INT_24XX_MMC2_IRQ;
+                       break;
+               case 2:
+                       if (!cpu_is_omap34xx())
+                               return;
+                       base = OMAP3_MMC3_BASE;
+                       irq = INT_34XX_MMC3_IRQ;
+                       break;
+               default:
+                       continue;
+               }
+
+               if (cpu_is_omap2420())
+                       size = OMAP2420_MMC_SIZE;
+               else
+                       size = HSMMC_SIZE;
 
-       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);
+               omap_mmc_add(i, base, size, irq, mmc_data[i]);
+       };
 }
 
 #endif
index 7334d86aa87c7ca61b89e1f46ded850a3ad169e2..32b517b2a3f41336a2f780145aa1dcafdba4b7db 100644 (file)
@@ -255,22 +255,18 @@ err:
        return 1;
 }
 
-static struct omap_mmc_platform_data hsmmc_data = {
+static struct omap_mmc_platform_data mmc1_data = {
        .nr_slots                       = 1,
-       .switch_slot                    = NULL,
        .init                           = hsmmc_late_init,
        .cleanup                        = hsmmc_cleanup,
 #ifdef CONFIG_PM
        .suspend                        = hsmmc_suspend,
        .resume                         = hsmmc_resume,
 #endif
+       .dma_mask                       = 0xffffffff,
        .slots[0] = {
-               .enabled                = 1,
                .wire4                  = 1,
                .set_power              = hsmmc_set_power,
-               .set_bus_mode           = NULL,
-               .get_ro                 = NULL,
-               .get_cover_state        = NULL,
                .ocr_mask               = MMC_VDD_32_33 | MMC_VDD_33_34 |
                                                MMC_VDD_165_195,
                .name                   = "first slot",
@@ -280,9 +276,12 @@ static struct omap_mmc_platform_data hsmmc_data = {
        },
 };
 
+static struct omap_mmc_platform_data *hsmmc_data[OMAP34XX_NR_MMC];
+
 void __init hsmmc_init(void)
 {
-       omap2_init_mmc(&hsmmc_data);
+       hsmmc_data[0] = &mmc1_data;
+       omap2_init_mmc(hsmmc_data, OMAP34XX_NR_MMC);
 }
 
 #else
index f633697aa50f58512a249d591c27661455831612..1ad179d7d73a52cc12dc66c0a159e883a61c290f 100644 (file)
@@ -194,20 +194,43 @@ void omap_mcbsp_register_board_cfg(struct omap_mcbsp_platform_data *config,
 #if    defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE) || \
        defined(CONFIG_MMC_OMAP_HS) || defined(CONFIG_MMC_OMAP_HS_MODULE)
 
+#define OMAP_MMC_NR_RES                2
+
 /*
  * Register MMC devices. Called from mach-omap1 and mach-omap2 device init.
  */
-void omap_init_mmc(struct omap_mmc_platform_data *info,
-               struct platform_device *pdev1, struct platform_device *pdev2)
+int __init omap_mmc_add(int id, unsigned long base, unsigned long size,
+               unsigned int irq, struct omap_mmc_platform_data *data)
 {
-       if (!info)
-               return;
-
-       if (info->slots[0].enabled && pdev1)
-               (void) platform_device_register(pdev1);
+       struct platform_device *pdev;
+       struct resource res[OMAP_MMC_NR_RES];
+       int ret;
+
+       pdev = platform_device_alloc("mmci-omap", id);
+       if (!pdev)
+               return -ENOMEM;
+
+       memset(res, 0, OMAP_MMC_NR_RES * sizeof(struct resource));
+       res[0].start = base;
+       res[0].end = base + size - 1;
+       res[0].flags = IORESOURCE_MEM;
+       res[1].start = res[1].end = irq;
+       res[1].flags = IORESOURCE_IRQ;
+
+       ret = platform_device_add_resources(pdev, res, ARRAY_SIZE(res));
+       if (ret == 0)
+               ret = platform_device_add_data(pdev, data, sizeof(*data));
+       if (ret)
+               goto fail;
+
+       ret = platform_device_add(pdev);
+       if (ret)
+               goto fail;
+       return 0;
 
-       if (info->slots[1].enabled && pdev2)
-               (void) platform_device_register(pdev2);
+fail:
+       platform_device_put(pdev);
+       return ret;
 }
 
 #endif
index 2a050e9be65f9089612eaadef6446831e891b293..15531c8dc0e63bf3110503da7b43905f723bf29f 100644 (file)
 #ifndef __ASM_ARCH_OMAP_H2_H
 #define __ASM_ARCH_OMAP_H2_H
 
-/* Placeholder for H2 specific defines */
-
 /* At OMAP1610 Innovator the Ethernet is directly connected to CS1 */
 #define OMAP1610_ETHR_START            0x04000300
 
+#define H2_TPS_GPIO_BASE               (OMAP_MAX_GPIO_LINES + 16 /* MPUIO */)
+#      define H2_TPS_GPIO_MMC_PWR_EN   (H2_TPS_GPIO_BASE + 3)
+
 extern void h2_mmc_init(void);
-extern void h2_mmc_slot_cover_handler(void *arg, int state);
 
 #endif /*  __ASM_ARCH_OMAP_H2_H */
 
index 14909dc7858a397d23c23be0e3b5bec1aec02e61..1888326da7ea325805f4052a8230439ecf1b235e 100644 (file)
@@ -30,7 +30,9 @@
 /* In OMAP1710 H3 the Ethernet is directly connected to CS1 */
 #define OMAP1710_ETHR_START            0x04000300
 
+#define H3_TPS_GPIO_BASE               (OMAP_MAX_GPIO_LINES + 16 /* MPUIO */)
+#      define H3_TPS_GPIO_MMC_PWR_EN   (H3_TPS_GPIO_BASE + 4)
+
 extern void h3_mmc_init(void);
-extern void h3_mmc_slot_cover_handler(void *arg, int state);
 
 #endif /*  __ASM_ARCH_OMAP_H3_H */
index af391e6a16ddb74e1e4ca97e45ff6a7adff7b562..2f20789bd256a2c78b31d6baa220036fe5858155 100644 (file)
 
 #include <mach/board.h>
 
+#define OMAP15XX_NR_MMC                1
+#define OMAP16XX_NR_MMC                2
+#define OMAP1_MMC_SIZE         0x080
+#define OMAP1_MMC1_BASE                0xfffb7800
+#define OMAP1_MMC2_BASE                0xfffb7c00      /* omap16xx only */
+
+#define OMAP24XX_NR_MMC                2
+#define OMAP34XX_NR_MMC                3
+#define OMAP2420_MMC_SIZE      OMAP1_MMC_SIZE
+#define HSMMC_SIZE             0x200
+#define OMAP2_MMC1_BASE                0x4809c000
+#define OMAP2_MMC2_BASE                0x480b4000
+#define OMAP3_MMC3_BASE                0x480ad000
+
 #define OMAP_MMC_MAX_SLOTS     2
 
 struct omap_mmc_platform_data {
 
-       /* number of slots on board */
+       /* number of slots per controller */
        unsigned nr_slots:2;
 
        /* set if your board has components or wiring that limits the
@@ -40,9 +54,9 @@ struct omap_mmc_platform_data {
        int (*suspend)(struct device *dev, int slot);
        int (*resume)(struct device *dev, int slot);
 
-       struct omap_mmc_slot_data {
+       u64 dma_mask;
 
-               unsigned enabled:1;
+       struct omap_mmc_slot_data {
 
                /*
                 * nomux means "standard" muxing is wrong on this board, and
@@ -60,7 +74,6 @@ struct omap_mmc_platform_data {
                unsigned internal_clock:1;
                s16 power_pin;
                s16 switch_pin;
-               s16 wp_pin;
 
                int (* set_bus_mode)(struct device *dev, int slot, int bus_mode);
                int (* set_power)(struct device *dev, int slot, int power_on, int vdd);
@@ -69,8 +82,8 @@ struct omap_mmc_platform_data {
                /* return MMC cover switch state, can be NULL if not supported.
                 *
                 * possible return values:
-                *   0 - open
-                *   1 - closed
+                *   0 - closed
+                *   1 - open
                 */
                int (* get_cover_state)(struct device *dev, int slot);
 
@@ -91,20 +104,25 @@ extern void omap_mmc_notify_cover_event(struct device *dev, int slot, int is_clo
 
 #if    defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE) || \
        defined(CONFIG_MMC_OMAP_HS) || defined(CONFIG_MMC_OMAP_HS_MODULE)
-void omap1_init_mmc(struct omap_mmc_platform_data *info);
-void omap2_init_mmc(struct omap_mmc_platform_data *info);
-void omap_init_mmc(struct omap_mmc_platform_data *info,
-               struct platform_device *pdev1, struct platform_device *pdev2);
+void omap1_init_mmc(struct omap_mmc_platform_data **mmc_data,
+                               int nr_controllers);
+void omap2_init_mmc(struct omap_mmc_platform_data **mmc_data,
+                               int nr_controllers);
+int omap_mmc_add(int id, unsigned long base, unsigned long size,
+                       unsigned int irq, struct omap_mmc_platform_data *data);
 #else
-static inline void omap1_init_mmc(struct omap_mmc_platform_data *info)
+static inline void omap1_init_mmc(struct omap_mmc_platform_data **mmc_data,
+                               int nr_controllers)
 {
 }
-static inline void omap2_init_mmc(struct omap_mmc_platform_data *info)
+static inline void omap2_init_mmc(struct omap_mmc_platform_data **mmc_data,
+                               int nr_controllers)
 {
 }
-static inline void omap_init_mmc(struct omap_mmc_platform_data *info,
-               struct platform_device *pdev1, struct platform_device *pdev2)
+static inline int omap_mmc_add(int id, unsigned long base, unsigned long size,
+               unsigned int irq, struct omap_mmc_platform_data *data)
 {
+       return 0;
 }
 #endif
 
index 608829423c22fc66db336359b771b13f829d693f..086e6de6bfb477a52e10cbd6e5ef1c090a487dbf 100644 (file)
@@ -1451,6 +1451,7 @@ static int __init mmc_omap_probe(struct platform_device *pdev)
        host->irq = irq;
 
        host->use_dma = 1;
+       host->dev->dma_mask = &pdata->dma_mask;
        host->dma_ch = -1;
 
        host->irq = irq;
index 997f0dccd4209b231877b9cffc526fe196cdcad3..75e3a16274edc62ff01bec161c5fb13eaa9d3601 100644 (file)
@@ -816,7 +816,9 @@ static int __init omap_mmc_probe(struct platform_device *pdev)
        host            = mmc_priv(mmc);
        host->mmc       = mmc;
        host->pdata     = pdata;
+       host->dev       = &pdev->dev;
        host->use_dma   = 1;
+       host->dev->dma_mask = &pdata->dma_mask;
        host->dma_ch    = -1;
        host->irq       = irq;
        host->id        = pdev->id;