From c434c15d28c82d92e55897bd265c423e9ab69362 Mon Sep 17 00:00:00 2001 From: Tony Lindgren Date: Wed, 24 Sep 2008 14:21:49 +0300 Subject: [PATCH] ARM: OMAP: Get rid of controller vs slot confusion, initialize MMC devices dynamically 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 --- arch/arm/mach-omap1/board-h2-mmc.c | 98 +++++------------ arch/arm/mach-omap1/board-h2.c | 29 ++--- arch/arm/mach-omap1/board-h3-mmc.c | 102 +++++------------- arch/arm/mach-omap1/board-h3.c | 14 --- arch/arm/mach-omap1/board-innovator.c | 43 ++++++-- arch/arm/mach-omap1/board-nokia770.c | 73 ++++++++++--- arch/arm/mach-omap1/board-palmte.c | 13 --- arch/arm/mach-omap1/board-palmz71.c | 14 --- arch/arm/mach-omap1/board-sx1-mmc.c | 80 ++------------ arch/arm/mach-omap1/board-sx1.c | 14 --- arch/arm/mach-omap1/board-voiceblue.c | 13 --- arch/arm/mach-omap1/clock.h | 3 +- arch/arm/mach-omap1/devices.c | 117 +++++++-------------- arch/arm/mach-omap2/board-apollon-mmc.c | 12 +-- arch/arm/mach-omap2/board-h4-mmc.c | 12 +-- arch/arm/mach-omap2/board-n800-mmc.c | 23 ++-- arch/arm/mach-omap2/clock24xx.h | 3 +- arch/arm/mach-omap2/clock34xx.h | 10 +- arch/arm/mach-omap2/devices.c | 113 ++++++++------------ arch/arm/mach-omap2/hsmmc.c | 13 ++- arch/arm/plat-omap/devices.c | 41 ++++++-- arch/arm/plat-omap/include/mach/board-h2.h | 6 +- arch/arm/plat-omap/include/mach/board-h3.h | 4 +- arch/arm/plat-omap/include/mach/mmc.h | 46 +++++--- drivers/mmc/host/omap.c | 1 + drivers/mmc/host/omap_hsmmc.c | 2 + 26 files changed, 367 insertions(+), 532 deletions(-) diff --git a/arch/arm/mach-omap1/board-h2-mmc.c b/arch/arm/mach-omap1/board-h2-mmc.c index 37031e01773..4fbe367063b 100644 --- a/arch/arm/mach-omap1/board-h2-mmc.c +++ b/arch/arm/mach-omap1/board-h2-mmc.c @@ -12,93 +12,56 @@ * published by the Free Software Foundation. */ +#include + +#include + #include #include #include -#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 diff --git a/arch/arm/mach-omap1/board-h2.c b/arch/arm/mach-omap1/board-h2.c index ac51d255aa0..2c12dfa8c09 100644 --- a/arch/arm/mach-omap1/board-h2.c +++ b/arch/arm/mach-omap1/board-h2.c @@ -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) diff --git a/arch/arm/mach-omap1/board-h3-mmc.c b/arch/arm/mach-omap1/board-h3-mmc.c index 44e9d536587..c906db0ba86 100644 --- a/arch/arm/mach-omap1/board-h3-mmc.c +++ b/arch/arm/mach-omap1/board-h3-mmc.c @@ -12,97 +12,56 @@ * published by the Free Software Foundation. */ +#include + +#include + #include #include #include -#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 diff --git a/arch/arm/mach-omap1/board-h3.c b/arch/arm/mach-omap1/board-h3.c index 0c1b001626f..c333db18cb1 100644 --- a/arch/arm/mach-omap1/board-h3.c +++ b/arch/arm/mach-omap1/board-h3.c @@ -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) diff --git a/arch/arm/mach-omap1/board-innovator.c b/arch/arm/mach-omap1/board-innovator.c index 9ed0feff6fb..7a97f6b5357 100644 --- a/arch/arm/mach-omap1/board-innovator.c +++ b/arch/arm/mach-omap1/board-innovator.c @@ -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) diff --git a/arch/arm/mach-omap1/board-nokia770.c b/arch/arm/mach-omap1/board-nokia770.c index 6e96a9d81ad..7b28f4da214 100644 --- a/arch/arm/mach-omap1/board-nokia770.c +++ b/arch/arm/mach-omap1/board-nokia770.c @@ -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) diff --git a/arch/arm/mach-omap1/board-palmte.c b/arch/arm/mach-omap1/board-palmte.c index 992ade0aa80..ee49e2ccf1f 100644 --- a/arch/arm/mach-omap1/board-palmte.c +++ b/arch/arm/mach-omap1/board-palmte.c @@ -45,7 +45,6 @@ #include #include #include -#include 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) diff --git a/arch/arm/mach-omap1/board-palmz71.c b/arch/arm/mach-omap1/board-palmz71.c index 5c75b9a4d52..e8116c51259 100644 --- a/arch/arm/mach-omap1/board-palmz71.c +++ b/arch/arm/mach-omap1/board-palmz71.c @@ -43,7 +43,6 @@ #include #include #include -#include #include #include @@ -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 diff --git a/arch/arm/mach-omap1/board-sx1-mmc.c b/arch/arm/mach-omap1/board-sx1-mmc.c index 524d22de1d5..66a4d7d5255 100644 --- a/arch/arm/mach-omap1/board-sx1-mmc.c +++ b/arch/arm/mach-omap1/board-sx1-mmc.c @@ -18,26 +18,14 @@ #include #include -#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 diff --git a/arch/arm/mach-omap1/board-sx1.c b/arch/arm/mach-omap1/board-sx1.c index 0d235e7facd..e9ba5dc5074 100644 --- a/arch/arm/mach-omap1/board-sx1.c +++ b/arch/arm/mach-omap1/board-sx1.c @@ -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 */ diff --git a/arch/arm/mach-omap1/board-voiceblue.c b/arch/arm/mach-omap1/board-voiceblue.c index 57be5298f53..069ca8d48aa 100644 --- a/arch/arm/mach-omap1/board-voiceblue.c +++ b/arch/arm/mach-omap1/board-voiceblue.c @@ -34,7 +34,6 @@ #include #include #include -#include 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) diff --git a/arch/arm/mach-omap1/clock.h b/arch/arm/mach-omap1/clock.h index f8ad19f3c9d..44eda0f83b3 100644 --- a/arch/arm/mach-omap1/clock.h +++ b/arch/arm/mach-omap1/clock.h @@ -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, diff --git a/arch/arm/mach-omap1/devices.c b/arch/arm/mach-omap1/devices.c index 97b472c25cd..e89d241144c 100644 --- a/arch/arm/mach-omap1/devices.c +++ b/arch/arm/mach-omap1/devices.c @@ -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 diff --git a/arch/arm/mach-omap2/board-apollon-mmc.c b/arch/arm/mach-omap2/board-apollon-mmc.c index a33e8ca9114..35c2c07b08d 100644 --- a/arch/arm/mach-omap2/board-apollon-mmc.c +++ b/arch/arm/mach-omap2/board-apollon-mmc.c @@ -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 */ diff --git a/arch/arm/mach-omap2/board-h4-mmc.c b/arch/arm/mach-omap2/board-h4-mmc.c index 169c5ee8b74..06119e9d0f9 100644 --- a/arch/arm/mach-omap2/board-h4-mmc.c +++ b/arch/arm/mach-omap2/board-h4-mmc.c @@ -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 diff --git a/arch/arm/mach-omap2/board-n800-mmc.c b/arch/arm/mach-omap2/board-n800-mmc.c index bcbba9440bf..2cf8213f729 100644 --- a/arch/arm/mach-omap2/board-n800-mmc.c +++ b/arch/arm/mach-omap2/board-n800-mmc.c @@ -19,7 +19,7 @@ #include #include -#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 diff --git a/arch/arm/mach-omap2/clock24xx.h b/arch/arm/mach-omap2/clock24xx.h index f11d16e7ba3..2900a4a64dd 100644 --- a/arch/arm/mach-omap2/clock24xx.h +++ b/arch/arm/mach-omap2/clock24xx.h @@ -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, diff --git a/arch/arm/mach-omap2/clock34xx.h b/arch/arm/mach-omap2/clock34xx.h index 857c059d305..8ce7097544f 100644 --- a/arch/arm/mach-omap2/clock34xx.h +++ b/arch/arm/mach-omap2/clock34xx.h @@ -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, diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c index ba0e098cc0f..32550a55fa4 100644 --- a/arch/arm/mach-omap2/devices.c +++ b/arch/arm/mach-omap2/devices.c @@ -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 diff --git a/arch/arm/mach-omap2/hsmmc.c b/arch/arm/mach-omap2/hsmmc.c index 7334d86aa87..32b517b2a3f 100644 --- a/arch/arm/mach-omap2/hsmmc.c +++ b/arch/arm/mach-omap2/hsmmc.c @@ -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 diff --git a/arch/arm/plat-omap/devices.c b/arch/arm/plat-omap/devices.c index f633697aa50..1ad179d7d73 100644 --- a/arch/arm/plat-omap/devices.c +++ b/arch/arm/plat-omap/devices.c @@ -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 diff --git a/arch/arm/plat-omap/include/mach/board-h2.h b/arch/arm/plat-omap/include/mach/board-h2.h index 2a050e9be65..15531c8dc0e 100644 --- a/arch/arm/plat-omap/include/mach/board-h2.h +++ b/arch/arm/plat-omap/include/mach/board-h2.h @@ -29,13 +29,13 @@ #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 */ diff --git a/arch/arm/plat-omap/include/mach/board-h3.h b/arch/arm/plat-omap/include/mach/board-h3.h index 14909dc7858..1888326da7e 100644 --- a/arch/arm/plat-omap/include/mach/board-h3.h +++ b/arch/arm/plat-omap/include/mach/board-h3.h @@ -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 */ diff --git a/arch/arm/plat-omap/include/mach/mmc.h b/arch/arm/plat-omap/include/mach/mmc.h index af391e6a16d..2f20789bd25 100644 --- a/arch/arm/plat-omap/include/mach/mmc.h +++ b/arch/arm/plat-omap/include/mach/mmc.h @@ -17,11 +17,25 @@ #include +#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 diff --git a/drivers/mmc/host/omap.c b/drivers/mmc/host/omap.c index 608829423c2..086e6de6bfb 100644 --- a/drivers/mmc/host/omap.c +++ b/drivers/mmc/host/omap.c @@ -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; diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c index 997f0dccd42..75e3a16274e 100644 --- a/drivers/mmc/host/omap_hsmmc.c +++ b/drivers/mmc/host/omap_hsmmc.c @@ -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; -- 2.41.1