summaryrefslogtreecommitdiff
path: root/drivers/mmc
diff options
context:
space:
mode:
authorTien Hock, Loh <tien.hock.loh@intel.com>2019-03-07 11:34:20 +0800
committerTien Hock, Loh <tien.hock.loh@intel.com>2019-03-07 11:34:20 +0800
commita468e756377ebe73920eb83f4a4425cabab66ebc (patch)
tree76ac6077eda8b433325e3c034b44d0d55812bcc9 /drivers/mmc
parent1cf55aba4902d43c95e5a24acf6d85de96923dc0 (diff)
drivers: mmc: Fix some issues with MMC stack
Some bugs in MMC stack needs to be fixed: - scr cannot be local as this will cause cache issue when invalidating after the read DMA transfer is completed - ACMD41 needs to send voltage information in initialization, otherwise the command is a query, thus will not initialize the controller - when checking device state, retry until the retries counter goes to zero before failing Signed-off-by: Tien Hock, Loh <tien.hock.loh@intel.com>
Diffstat (limited to 'drivers/mmc')
-rw-r--r--drivers/mmc/mmc.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 77d683c4..db6f3f9e 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -29,6 +29,7 @@ static unsigned char mmc_ext_csd[512] __aligned(16);
static unsigned int mmc_flags;
static struct mmc_device_info *mmc_dev_info;
static unsigned int rca;
+static unsigned int scr[2]__aligned(16) = { 0 };
static const unsigned char tran_speed_base[16] = {
0, 10, 12, 13, 15, 20, 26, 30, 35, 40, 45, 52, 55, 60, 70, 80
@@ -90,7 +91,8 @@ static int mmc_device_state(void)
ret = mmc_send_cmd(MMC_CMD(13), rca << RCA_SHIFT_OFFSET,
MMC_RESPONSE_R1, &resp_data[0]);
if (ret != 0) {
- return ret;
+ retries--;
+ continue;
}
if ((resp_data[0] & STATUS_SWITCH_ERROR) != 0U) {
@@ -129,7 +131,6 @@ static int mmc_sd_switch(unsigned int bus_width)
{
int ret;
int retries = MMC_DEFAULT_MAX_RETRIES;
- unsigned int scr[2] = { 0 };
unsigned int bus_width_arg = 0;
ret = ops->prepare(0, (uintptr_t)&scr, sizeof(scr));
@@ -341,8 +342,9 @@ static int sd_send_op_cond(void)
}
/* ACMD41: SD_SEND_OP_COND */
- ret = mmc_send_cmd(MMC_ACMD(41), OCR_HCS, MMC_RESPONSE_R3,
- &resp_data[0]);
+ ret = mmc_send_cmd(MMC_ACMD(41), OCR_HCS |
+ mmc_dev_info->ocr_voltage, MMC_RESPONSE_R3,
+ &resp_data[0]);
if (ret != 0) {
return ret;
}