mirror of
https://github.com/AsahiLinux/u-boot
synced 2025-02-26 12:27:12 +00:00
mmc: add a function to read and test the ext csd (mmc >= 4)
This will be reused later in the selection of high speed and ddr modes. Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com> Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
dfda9d88e5
commit
7382e691ca
1 changed files with 33 additions and 20 deletions
|
@ -1146,10 +1146,39 @@ static int sd_select_bus_freq_width(struct mmc *mmc)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* read the compare the part of ext csd that is constant.
|
||||||
|
* This can be used to check that the transfer is working
|
||||||
|
* as expected.
|
||||||
|
*/
|
||||||
|
static int mmc_read_and_compare_ext_csd(struct mmc *mmc)
|
||||||
|
{
|
||||||
|
int err;
|
||||||
|
const u8 *ext_csd = mmc->ext_csd;
|
||||||
|
ALLOC_CACHE_ALIGN_BUFFER(u8, test_csd, MMC_MAX_BLOCK_LEN);
|
||||||
|
|
||||||
|
err = mmc_send_ext_csd(mmc, test_csd);
|
||||||
|
if (err)
|
||||||
|
return err;
|
||||||
|
|
||||||
|
/* Only compare read only fields */
|
||||||
|
if (ext_csd[EXT_CSD_PARTITIONING_SUPPORT]
|
||||||
|
== test_csd[EXT_CSD_PARTITIONING_SUPPORT] &&
|
||||||
|
ext_csd[EXT_CSD_HC_WP_GRP_SIZE]
|
||||||
|
== test_csd[EXT_CSD_HC_WP_GRP_SIZE] &&
|
||||||
|
ext_csd[EXT_CSD_REV]
|
||||||
|
== test_csd[EXT_CSD_REV] &&
|
||||||
|
ext_csd[EXT_CSD_HC_ERASE_GRP_SIZE]
|
||||||
|
== test_csd[EXT_CSD_HC_ERASE_GRP_SIZE] &&
|
||||||
|
memcmp(&ext_csd[EXT_CSD_SEC_CNT],
|
||||||
|
&test_csd[EXT_CSD_SEC_CNT], 4) == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return -EBADMSG;
|
||||||
|
}
|
||||||
|
|
||||||
static int mmc_select_bus_freq_width(struct mmc *mmc)
|
static int mmc_select_bus_freq_width(struct mmc *mmc)
|
||||||
{
|
{
|
||||||
ALLOC_CACHE_ALIGN_BUFFER(u8, test_csd, MMC_MAX_BLOCK_LEN);
|
|
||||||
const u8 *ext_csd = mmc->ext_csd;
|
|
||||||
/* An array of possible bus widths in order of preference */
|
/* An array of possible bus widths in order of preference */
|
||||||
static const unsigned int ext_csd_bits[] = {
|
static const unsigned int ext_csd_bits[] = {
|
||||||
EXT_CSD_DDR_BUS_WIDTH_8,
|
EXT_CSD_DDR_BUS_WIDTH_8,
|
||||||
|
@ -1221,25 +1250,9 @@ static int mmc_select_bus_freq_width(struct mmc *mmc)
|
||||||
mmc->ddr_mode = (caps & MMC_MODE_DDR_52MHz) ? 1 : 0;
|
mmc->ddr_mode = (caps & MMC_MODE_DDR_52MHz) ? 1 : 0;
|
||||||
mmc_set_bus_width(mmc, widths[idx]);
|
mmc_set_bus_width(mmc, widths[idx]);
|
||||||
|
|
||||||
err = mmc_send_ext_csd(mmc, test_csd);
|
err = mmc_read_and_compare_ext_csd(mmc);
|
||||||
|
if (!err)
|
||||||
if (err)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
/* Only compare read only fields */
|
|
||||||
if (ext_csd[EXT_CSD_PARTITIONING_SUPPORT]
|
|
||||||
== test_csd[EXT_CSD_PARTITIONING_SUPPORT] &&
|
|
||||||
ext_csd[EXT_CSD_HC_WP_GRP_SIZE]
|
|
||||||
== test_csd[EXT_CSD_HC_WP_GRP_SIZE] &&
|
|
||||||
ext_csd[EXT_CSD_REV]
|
|
||||||
== test_csd[EXT_CSD_REV] &&
|
|
||||||
ext_csd[EXT_CSD_HC_ERASE_GRP_SIZE]
|
|
||||||
== test_csd[EXT_CSD_HC_ERASE_GRP_SIZE] &&
|
|
||||||
memcmp(&ext_csd[EXT_CSD_SEC_CNT],
|
|
||||||
&test_csd[EXT_CSD_SEC_CNT], 4) == 0)
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
err = -EBADMSG;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (err)
|
if (err)
|
||||||
|
|
Loading…
Add table
Reference in a new issue