@@ -48,7 +48,7 @@ struct rtsx_usb_sdmmc {
bool ddr_mode;
unsigned char power_mode;
-
+ unsigned char prev_power_mode;
#ifdef RTSX_USB_USE_LEDS_CLASS
struct led_classdev led;
char led_name[32];
@@ -952,6 +952,8 @@ static int sd_power_on(struct rtsx_usb_sdmmc *host)
struct rtsx_ucr *ucr = host->ucr;
int err;
+ msleep(100);
+
dev_dbg(sdmmc_dev(host), "%s\n", __func__);
rtsx_usb_init_cmd(ucr);
rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CARD_SELECT, 0x07, SD_MOD_SEL);
@@ -1014,6 +1016,16 @@ static int sd_set_power_mode(struct rtsx_usb_sdmmc *host,
unsigned char power_mode)
{
int err;
+ int power_mode_temp;
+ struct rtsx_ucr *ucr = host->ucr;
+
+ power_mode_temp = power_mode;
+
+ if ((power_mode == MMC_POWER_ON) && (host->power_mode == MMC_POWER_ON) &&
+ (host->prev_power_mode == MMC_POWER_UP)) {
+ host->prev_power_mode = MMC_POWER_ON;
+ rtsx_usb_write_register(ucr, SD_BUS_STAT, SD_CLK_TOGGLE_EN, 0x00);
+ }
if (power_mode != MMC_POWER_OFF)
power_mode = MMC_POWER_ON;
@@ -1029,9 +1041,18 @@ static int sd_set_power_mode(struct rtsx_usb_sdmmc *host,
err = sd_power_on(host);
}
- if (!err)
- host->power_mode = power_mode;
+ if (!err) {
+ if ((power_mode_temp == MMC_POWER_UP) && (host->power_mode == MMC_POWER_OFF)) {
+ host->prev_power_mode = MMC_POWER_UP;
+ rtsx_usb_write_register(ucr, SD_BUS_STAT, SD_CLK_TOGGLE_EN,
+ SD_CLK_TOGGLE_EN);
+ }
+
+ if ((power_mode_temp == MMC_POWER_OFF) && (host->power_mode == MMC_POWER_ON))
+ host->prev_power_mode = MMC_POWER_OFF;
+ host->power_mode = power_mode;
+ }
return err;
}
@@ -1316,6 +1337,7 @@ static void rtsx_usb_init_host(struct rtsx_usb_sdmmc *host)
mmc->max_req_size = 524288;
host->power_mode = MMC_POWER_OFF;
+ host->prev_power_mode = MMC_POWER_OFF;
}
static int rtsx_usb_sdmmc_drv_probe(struct platform_device *pdev)
SD spec definition: "Host provides at least 74 Clocks before issuing first command" After 1ms for the voltage stable then start issuing the Clock signals add if statement to issue/stop the clock signal to card: The power state from POWER_OFF to POWER_UP issue the signal to card, POWER_UP to POWER_ON stop the signal add 100ms delay in power_on to make sure the power cycle complete Signed-off-by: Ricky Wu <ricky_wu@realtek.com> --- drivers/mmc/host/rtsx_usb_sdmmc.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-)