Skip to content

Commit

Permalink
mmc: rtsx: Clear SD_CLK toggle enable bit if switching voltage fail
Browse files Browse the repository at this point in the history
If switching voltage fails, SD_CLK toggle enable bit should been cleared
so that SD host can control SD clock automatically.

Signed-off-by: Wei WANG <wei_wang@realsil.com.cn>
Acked-by: Chris Ball <cjb@laptop.org>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
  • Loading branch information
Wei WANG authored and Samuel Ortiz committed Aug 30, 2013
1 parent 84d72f9 commit 1b8055b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion drivers/mmc/host/rtsx_pci_sdmmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ static void sd_send_cmd_get_rsp(struct realtek_pci_sdmmc *host,
int stat_idx = 0;
u8 rsp_type;
int rsp_len = 5;
bool clock_toggled = false;

dev_dbg(sdmmc_dev(host), "%s: SD/MMC CMD %d, arg = 0x%08x\n",
__func__, cmd_idx, arg);
Expand Down Expand Up @@ -270,6 +271,8 @@ static void sd_send_cmd_get_rsp(struct realtek_pci_sdmmc *host,
0xFF, SD_CLK_TOGGLE_EN);
if (err < 0)
goto out;

clock_toggled = true;
}

rtsx_pci_init_cmd(pcr);
Expand Down Expand Up @@ -350,6 +353,10 @@ static void sd_send_cmd_get_rsp(struct realtek_pci_sdmmc *host,

out:
cmd->error = err;

if (err && clock_toggled)
rtsx_pci_write_register(pcr, SD_BUS_STAT,
SD_CLK_TOGGLE_EN | SD_CLK_FORCE_STOP, 0);
}

static int sd_rw_multi(struct realtek_pci_sdmmc *host, struct mmc_request *mrq)
Expand Down Expand Up @@ -1121,11 +1128,11 @@ static int sdmmc_switch_voltage(struct mmc_host *mmc, struct mmc_ios *ios)
goto out;
}

out:
/* Stop toggle SD clock in idle */
err = rtsx_pci_write_register(pcr, SD_BUS_STAT,
SD_CLK_TOGGLE_EN | SD_CLK_FORCE_STOP, 0);

out:
mutex_unlock(&pcr->pcr_mutex);

return err;
Expand Down

0 comments on commit 1b8055b

Please sign in to comment.