diff options
Diffstat (limited to 'drivers/mci/mci-core.c')
-rw-r--r-- | drivers/mci/mci-core.c | 39 |
1 files changed, 25 insertions, 14 deletions
diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c index 414bcf6f06..f6565b2b64 100644 --- a/drivers/mci/mci-core.c +++ b/drivers/mci/mci-core.c @@ -545,12 +545,12 @@ u8 *mci_get_ext_csd(struct mci *mci) u8 *ext_csd; int ret; - ext_csd = xmalloc(512); + ext_csd = dma_alloc(512); ret = mci_send_ext_csd(mci, ext_csd); if (ret) { printf("Failure to read EXT_CSD register\n"); - free(ext_csd); + dma_free(ext_csd); return ERR_PTR(-EIO); } @@ -666,7 +666,7 @@ static int mmc_change_freq(struct mci *mci) char cardtype; int err; - mci->ext_csd = xmalloc(512); + mci->ext_csd = dma_alloc(512); mci->card_caps = 0; /* Only version 4 supports high-speed */ @@ -1124,7 +1124,7 @@ static int mmc_compare_ext_csds(struct mci *mci, enum mci_bus_width bus_width) if (bus_width == MMC_BUS_WIDTH_1) return 0; - bw_ext_csd = xmalloc(512); + bw_ext_csd = dma_alloc(512); err = mci_send_ext_csd(mci, bw_ext_csd); if (err) { dev_info(&mci->dev, "mci_send_ext_csd failed with %d\n", err); @@ -1173,7 +1173,7 @@ static int mmc_compare_ext_csds(struct mci *mci, enum mci_bus_width bus_width) 0 : -EINVAL; out: - free(bw_ext_csd); + dma_free(bw_ext_csd); return err; } @@ -1349,8 +1349,14 @@ int mci_execute_tuning(struct mci *mci) struct mci_host *host = mci->host; u32 opcode; - if (!host->execute_tuning) - return 0; + if (!host->execute_tuning) { + /* + * For us, implementing ->execute_tuning is mandatory to + * support higher speed modes + */ + dev_warn(&mci->dev, "tuning failed: no host diver support\n"); + return -EOPNOTSUPP; + } /* Tuning is only supported for MMC / HS200 */ if (mmc_card_hs200(mci)) @@ -1431,11 +1437,11 @@ static int mmc_select_hs200(struct mci *mci) /* find out maximum bus width and then try DDR if supported */ err = mci_mmc_select_bus_width(mci); if (err > 0) { - u32 status; - /* TODO actually set drive strength instead of 0. Currently unsupported. */ val = EXT_CSD_TIMING_HS200 | 0 << EXT_CSD_DRV_STR_SHIFT; err = mci_switch(mci, EXT_CSD_HS_TIMING, val); + if (err == -EIO) + return -EBADMSG; if (err) goto err; @@ -1452,7 +1458,7 @@ static int mmc_select_hs200(struct mci *mci) mci_set_ios(mci); mci_set_clock(mci, mci->host->hs_max_dtr); - err = mci_switch_status(mci, &status); + err = mci_switch_status(mci, true); /* * mmc_select_timing() assumes timing has not changed if @@ -1551,6 +1557,11 @@ static int mci_startup_mmc(struct mci *mci) if (mmc_card_hs200(mci)) ret = mmc_hs200_tuning(mci); + + if (ret) { + host->timing = MMC_TIMING_MMC_HS; + mci_switch(mci, EXT_CSD_HS_TIMING, EXT_CSD_TIMING_HS); + } } if (ret || !IS_ENABLED(CONFIG_MCI_TUNING)) { @@ -1566,7 +1577,7 @@ static int mci_startup_mmc(struct mci *mci) } } - return ret; + return ret >= MMC_BUS_WIDTH_1 ? 0 : ret; } /** @@ -2058,8 +2069,8 @@ static void mci_info(struct device *dev) mci->csd[2], mci->csd[3]); printf(" Max. transfer speed: %u Hz\n", mci->tran_speed); mci_print_caps(mci->card_caps); - printf(" Manufacturer ID: %02X\n", extract_mid(mci)); - printf(" OEM/Application ID: %04X\n", extract_oid(mci)); + printf(" Manufacturer ID: 0x%02X\n", extract_mid(mci)); + printf(" OEM/Application ID: 0x%04X\n", extract_oid(mci)); printf(" Product name: '%c%c%c%c%c'\n", mci->cid[0] & 0xff, (mci->cid[1] >> 24), (mci->cid[1] >> 16) & 0xff, (mci->cid[1] >> 8) & 0xff, mci->cid[1] & 0xff); @@ -2220,7 +2231,7 @@ static int mci_get_partition_setting_completed(struct mci *mci) ret = ext_csd[EXT_CSD_PARTITION_SETTING_COMPLETED]; - free(ext_csd); + dma_free(ext_csd); return ret; } |