diff options
author | Johan Rudholm <johan.rudholm@axis.com> | 2014-11-06 08:46:54 -0500 |
---|---|---|
committer | Ulf Hansson <ulf.hansson@linaro.org> | 2014-11-26 08:30:57 -0500 |
commit | 2d079c43bc5ade7b41610b356bf117e14037a584 (patch) | |
tree | 0e9989d510abb38ee1da09154b18c1701ba20c1d /drivers/mmc | |
parent | 80412ca8abf087354891108d2f888ad3de56e73c (diff) |
mmc: core: consistent handling of initial values
mmc_do_hw_reset(), mmc_power_up() and mmc_power_off() all set similar
initial values for bus_mode, bus_width, chip_select and timing. Let's
make this handling simpler and more consistent by sticking them
together in a common function. This will introduce small changes in
behavior in the following places:
mmc_power_off():
For SPI hosts, explicitly set bus_mode = MMC_BUSMODE_PUSHPULL and
chip_select = MMC_CS_HIGH, before we left them as they were.
For non-SPI hosts, set bus_mode = MMC_BUSMODE_PUSHPULL instead of
MMC_BUSMODE_OPENDRAIN as before.
These two changes should not be a problem since the device will be
powered off anyway.
mmc_do_hw_reset():
Always set bus_mode = MMC_BUSMODE_PUSHPULL, as required by SD/SDIO
cards. MMC cards require MMC_BUSMODE_OPENDRAIN, but this is taken
care of by mmc_init_card() and mmc_attach_mmc().
Signed-off-by: Johan Rudholm <johanru@axis.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Diffstat (limited to 'drivers/mmc')
-rw-r--r-- | drivers/mmc/core/core.c | 47 | ||||
-rw-r--r-- | drivers/mmc/core/core.h | 1 |
2 files changed, 23 insertions, 25 deletions
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index a32bea23e70c..5bda29bff8eb 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c | |||
@@ -1099,6 +1099,22 @@ void mmc_set_bus_width(struct mmc_host *host, unsigned int width) | |||
1099 | mmc_host_clk_release(host); | 1099 | mmc_host_clk_release(host); |
1100 | } | 1100 | } |
1101 | 1101 | ||
1102 | /* | ||
1103 | * Set initial state after a power cycle or a hw_reset. | ||
1104 | */ | ||
1105 | void mmc_set_initial_state(struct mmc_host *host) | ||
1106 | { | ||
1107 | if (mmc_host_is_spi(host)) | ||
1108 | host->ios.chip_select = MMC_CS_HIGH; | ||
1109 | else | ||
1110 | host->ios.chip_select = MMC_CS_DONTCARE; | ||
1111 | host->ios.bus_mode = MMC_BUSMODE_PUSHPULL; | ||
1112 | host->ios.bus_width = MMC_BUS_WIDTH_1; | ||
1113 | host->ios.timing = MMC_TIMING_LEGACY; | ||
1114 | |||
1115 | mmc_set_ios(host); | ||
1116 | } | ||
1117 | |||
1102 | /** | 1118 | /** |
1103 | * mmc_vdd_to_ocrbitnum - Convert a voltage to the OCR bit number | 1119 | * mmc_vdd_to_ocrbitnum - Convert a voltage to the OCR bit number |
1104 | * @vdd: voltage (mV) | 1120 | * @vdd: voltage (mV) |
@@ -1537,15 +1553,9 @@ void mmc_power_up(struct mmc_host *host, u32 ocr) | |||
1537 | mmc_host_clk_hold(host); | 1553 | mmc_host_clk_hold(host); |
1538 | 1554 | ||
1539 | host->ios.vdd = fls(ocr) - 1; | 1555 | host->ios.vdd = fls(ocr) - 1; |
1540 | if (mmc_host_is_spi(host)) | ||
1541 | host->ios.chip_select = MMC_CS_HIGH; | ||
1542 | else | ||
1543 | host->ios.chip_select = MMC_CS_DONTCARE; | ||
1544 | host->ios.bus_mode = MMC_BUSMODE_PUSHPULL; | ||
1545 | host->ios.power_mode = MMC_POWER_UP; | 1556 | host->ios.power_mode = MMC_POWER_UP; |
1546 | host->ios.bus_width = MMC_BUS_WIDTH_1; | 1557 | /* Set initial state and call mmc_set_ios */ |
1547 | host->ios.timing = MMC_TIMING_LEGACY; | 1558 | mmc_set_initial_state(host); |
1548 | mmc_set_ios(host); | ||
1549 | 1559 | ||
1550 | /* Try to set signal voltage to 3.3V but fall back to 1.8v or 1.2v */ | 1560 | /* Try to set signal voltage to 3.3V but fall back to 1.8v or 1.2v */ |
1551 | if (__mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_330) == 0) | 1561 | if (__mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_330) == 0) |
@@ -1585,14 +1595,9 @@ void mmc_power_off(struct mmc_host *host) | |||
1585 | host->ios.clock = 0; | 1595 | host->ios.clock = 0; |
1586 | host->ios.vdd = 0; | 1596 | host->ios.vdd = 0; |
1587 | 1597 | ||
1588 | if (!mmc_host_is_spi(host)) { | ||
1589 | host->ios.bus_mode = MMC_BUSMODE_OPENDRAIN; | ||
1590 | host->ios.chip_select = MMC_CS_DONTCARE; | ||
1591 | } | ||
1592 | host->ios.power_mode = MMC_POWER_OFF; | 1598 | host->ios.power_mode = MMC_POWER_OFF; |
1593 | host->ios.bus_width = MMC_BUS_WIDTH_1; | 1599 | /* Set initial state and call mmc_set_ios */ |
1594 | host->ios.timing = MMC_TIMING_LEGACY; | 1600 | mmc_set_initial_state(host); |
1595 | mmc_set_ios(host); | ||
1596 | 1601 | ||
1597 | /* | 1602 | /* |
1598 | * Some configurations, such as the 802.11 SDIO card in the OLPC | 1603 | * Some configurations, such as the 802.11 SDIO card in the OLPC |
@@ -2278,16 +2283,8 @@ static int mmc_do_hw_reset(struct mmc_host *host, int check) | |||
2278 | } | 2283 | } |
2279 | } | 2284 | } |
2280 | 2285 | ||
2281 | if (mmc_host_is_spi(host)) { | 2286 | /* Set initial state and call mmc_set_ios */ |
2282 | host->ios.chip_select = MMC_CS_HIGH; | 2287 | mmc_set_initial_state(host); |
2283 | host->ios.bus_mode = MMC_BUSMODE_PUSHPULL; | ||
2284 | } else { | ||
2285 | host->ios.chip_select = MMC_CS_DONTCARE; | ||
2286 | host->ios.bus_mode = MMC_BUSMODE_OPENDRAIN; | ||
2287 | } | ||
2288 | host->ios.bus_width = MMC_BUS_WIDTH_1; | ||
2289 | host->ios.timing = MMC_TIMING_LEGACY; | ||
2290 | mmc_set_ios(host); | ||
2291 | 2288 | ||
2292 | mmc_host_clk_release(host); | 2289 | mmc_host_clk_release(host); |
2293 | 2290 | ||
diff --git a/drivers/mmc/core/core.h b/drivers/mmc/core/core.h index 443a584660f0..d76597c65e3a 100644 --- a/drivers/mmc/core/core.h +++ b/drivers/mmc/core/core.h | |||
@@ -49,6 +49,7 @@ void mmc_set_driver_type(struct mmc_host *host, unsigned int drv_type); | |||
49 | void mmc_power_up(struct mmc_host *host, u32 ocr); | 49 | void mmc_power_up(struct mmc_host *host, u32 ocr); |
50 | void mmc_power_off(struct mmc_host *host); | 50 | void mmc_power_off(struct mmc_host *host); |
51 | void mmc_power_cycle(struct mmc_host *host, u32 ocr); | 51 | void mmc_power_cycle(struct mmc_host *host, u32 ocr); |
52 | void mmc_set_initial_state(struct mmc_host *host); | ||
52 | 53 | ||
53 | static inline void mmc_delay(unsigned int ms) | 54 | static inline void mmc_delay(unsigned int ms) |
54 | { | 55 | { |