diff options
author | Rabin Vincent <rabin@rab.in> | 2009-04-05 13:30:55 +0530 |
---|---|---|
committer | Andy Fleming <afleming@freescale.com> | 2009-06-02 17:18:57 -0500 |
commit | 0b453ffe28bb9227d86ddbe0893bd19c93f04ed7 (patch) | |
tree | 30ca9a03cccd70c552d211512430fa3431b97c35 /drivers/mmc | |
parent | 9b1f942c09dd942e6de3185caa81c111b14de567 (diff) | |
download | u-boot-imx-0b453ffe28bb9227d86ddbe0893bd19c93f04ed7.zip u-boot-imx-0b453ffe28bb9227d86ddbe0893bd19c93f04ed7.tar.gz u-boot-imx-0b453ffe28bb9227d86ddbe0893bd19c93f04ed7.tar.bz2 |
mmc: fix response decoding on little endian
The mmc code defines the response as an array of chars. However, it
access the response bytes both as (i) an array of four uints (with
casts) and (ii) as individual chars. The former case is used more
often, including by the driver when it assigns the response.
The char-wise accesses are broken on little endian systems because they
assume that the bytes in the uints are in big endian byte order.
This patch fixes this by changing the response to be an array of four
uints and replacing the char-wise accesses with equivalent uint-wise
accesses.
Signed-off-by: Rabin Vincent <rabin@rab.in>
Diffstat (limited to 'drivers/mmc')
-rw-r--r-- | drivers/mmc/mmc.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index 95ed21e..1c89e31 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -651,7 +651,7 @@ int mmc_startup(struct mmc *mmc) mmc->csd[3] = ((uint *)(cmd.response))[3]; if (mmc->version == MMC_VERSION_UNKNOWN) { - int version = (cmd.response[0] >> 2) & 0xf; + int version = (cmd.response[0] >> 26) & 0xf; switch (version) { case 0: @@ -676,8 +676,8 @@ int mmc_startup(struct mmc *mmc) } /* divide frequency by 10, since the mults are 10x bigger */ - freq = fbase[(cmd.response[3] & 0x7)]; - mult = multipliers[((cmd.response[3] >> 3) & 0xf)]; + freq = fbase[(cmd.response[0] & 0x7)]; + mult = multipliers[((cmd.response[0] >> 3) & 0xf)]; mmc->tran_speed = freq * mult; @@ -791,13 +791,13 @@ int mmc_startup(struct mmc *mmc) mmc->block_dev.type = 0; mmc->block_dev.blksz = mmc->read_bl_len; mmc->block_dev.lba = lldiv(mmc->capacity, mmc->read_bl_len); - sprintf(mmc->block_dev.vendor,"Man %02x%02x%02x Snr %02x%02x%02x%02x", - mmc->cid[0], mmc->cid[1], mmc->cid[2], - mmc->cid[9], mmc->cid[10], mmc->cid[11], mmc->cid[12]); - sprintf(mmc->block_dev.product,"%c%c%c%c%c", mmc->cid[3], - mmc->cid[4], mmc->cid[5], mmc->cid[6], mmc->cid[7]); - sprintf(mmc->block_dev.revision,"%d.%d", mmc->cid[8] >> 4, - mmc->cid[8] & 0xf); + sprintf(mmc->block_dev.vendor, "Man %06x Snr %08x", mmc->cid[0] >> 8, + (mmc->cid[2] << 8) | (mmc->cid[3] >> 24)); + sprintf(mmc->block_dev.product, "%c%c%c%c%c", mmc->cid[0] & 0xff, + (mmc->cid[1] >> 24), (mmc->cid[1] >> 16) & 0xff, + (mmc->cid[1] >> 8) & 0xff, mmc->cid[1] & 0xff); + sprintf(mmc->block_dev.revision, "%d.%d", mmc->cid[2] >> 28, + (mmc->cid[2] >> 24) & 0xf); init_part(&mmc->block_dev); return 0; |