mci: Fix version handling
Currently the version defines reflect the digits in the version number. MMC_VERSION_4_41 is defined as 0x441 and MMC_VERSION_4_5 is defined as 0x405. This results in MMC_VERSION_4_5 < MMC_VERSION_4_41 becoming true which was surely not intended. Fix this by redefining the versions as 0x<major><minor><micro>. This makes the string generation more complicated but makes versions comparable again. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
parent
403fbbbc34
commit
9bdef9e7f2
|
@ -939,6 +939,21 @@ out:
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char *mci_version_string(struct mci *mci)
|
||||||
|
{
|
||||||
|
static char version[sizeof("x.xx")];
|
||||||
|
unsigned major, minor, micro;
|
||||||
|
|
||||||
|
major = (mci->version >> 8) & 0xf;
|
||||||
|
minor = (mci->version >> 4) & 0xf;
|
||||||
|
micro = mci->version & 0xf;
|
||||||
|
|
||||||
|
sprintf(version, "%u.%u", major,
|
||||||
|
micro ? (minor << 4) | micro : minor);
|
||||||
|
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
static int mci_startup_sd(struct mci *mci)
|
static int mci_startup_sd(struct mci *mci)
|
||||||
{
|
{
|
||||||
struct mci_cmd cmd;
|
struct mci_cmd cmd;
|
||||||
|
@ -1140,8 +1155,8 @@ static int mci_startup(struct mci *mci)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
mci_correct_version_from_ext_csd(mci);
|
mci_correct_version_from_ext_csd(mci);
|
||||||
printf("detected %s card version %d.%d\n", IS_SD(mci) ? "SD" : "MMC",
|
dev_info(&mci->dev, "detected %s card version %s\n", IS_SD(mci) ? "SD" : "MMC",
|
||||||
(mci->version >> 8) & 0xf, mci->version & 0xff);
|
mci_version_string(mci));
|
||||||
mci_extract_card_capacity_from_csd(mci);
|
mci_extract_card_capacity_from_csd(mci);
|
||||||
|
|
||||||
if (IS_SD(mci))
|
if (IS_SD(mci))
|
||||||
|
@ -1477,13 +1492,8 @@ static void mci_info(struct device_d *dev)
|
||||||
mci_print_caps(host->host_caps);
|
mci_print_caps(host->host_caps);
|
||||||
|
|
||||||
printf("Card information:\n");
|
printf("Card information:\n");
|
||||||
if (mci->version < SD_VERSION_SD) {
|
printf(" Attached is a %s card\n", IS_SD(mci) ? "SD" : "MMC");
|
||||||
printf(" Attached is a MultiMediaCard (Version: %u.%u)\n",
|
printf(" Version: %s\n", mci_version_string(mci));
|
||||||
(mci->version >> 4) & 0xf, mci->version & 0xf);
|
|
||||||
} else {
|
|
||||||
printf(" Attached is an SD Card (Version: %u.%u)\n",
|
|
||||||
(mci->version >> 8) & 0xf, mci->version & 0xff);
|
|
||||||
}
|
|
||||||
printf(" Capacity: %u MiB\n", (unsigned)(mci->capacity >> 20));
|
printf(" Capacity: %u MiB\n", (unsigned)(mci->capacity >> 20));
|
||||||
|
|
||||||
if (mci->high_capacity)
|
if (mci->high_capacity)
|
||||||
|
|
|
@ -33,21 +33,21 @@
|
||||||
#define SD_VERSION_SD 0x20000
|
#define SD_VERSION_SD 0x20000
|
||||||
#define SD_VERSION_2 (SD_VERSION_SD | 0x200)
|
#define SD_VERSION_2 (SD_VERSION_SD | 0x200)
|
||||||
#define SD_VERSION_1_0 (SD_VERSION_SD | 0x100)
|
#define SD_VERSION_1_0 (SD_VERSION_SD | 0x100)
|
||||||
#define SD_VERSION_1_10 (SD_VERSION_SD | 0x10a)
|
#define SD_VERSION_1_10 (SD_VERSION_SD | 0x1a0)
|
||||||
|
|
||||||
/* Firmware revisions for MMC cards */
|
/* Firmware revisions for MMC cards */
|
||||||
#define MMC_VERSION_MMC 0x10000
|
#define MMC_VERSION_MMC 0x10000
|
||||||
#define MMC_VERSION_UNKNOWN (MMC_VERSION_MMC)
|
#define MMC_VERSION_UNKNOWN (MMC_VERSION_MMC)
|
||||||
#define MMC_VERSION_1_2 (MMC_VERSION_MMC | 0x102)
|
#define MMC_VERSION_1_2 (MMC_VERSION_MMC | 0x120)
|
||||||
#define MMC_VERSION_1_4 (MMC_VERSION_MMC | 0x104)
|
#define MMC_VERSION_1_4 (MMC_VERSION_MMC | 0x140)
|
||||||
#define MMC_VERSION_2_2 (MMC_VERSION_MMC | 0x202)
|
#define MMC_VERSION_2_2 (MMC_VERSION_MMC | 0x220)
|
||||||
#define MMC_VERSION_3 (MMC_VERSION_MMC | 0x300)
|
#define MMC_VERSION_3 (MMC_VERSION_MMC | 0x300)
|
||||||
#define MMC_VERSION_4 (MMC_VERSION_MMC | 0x400)
|
#define MMC_VERSION_4 (MMC_VERSION_MMC | 0x400)
|
||||||
#define MMC_VERSION_4_1 (MMC_VERSION_MMC | 0x401)
|
#define MMC_VERSION_4_1 (MMC_VERSION_MMC | 0x410)
|
||||||
#define MMC_VERSION_4_2 (MMC_VERSION_MMC | 0x402)
|
#define MMC_VERSION_4_2 (MMC_VERSION_MMC | 0x420)
|
||||||
#define MMC_VERSION_4_3 (MMC_VERSION_MMC | 0x403)
|
#define MMC_VERSION_4_3 (MMC_VERSION_MMC | 0x430)
|
||||||
#define MMC_VERSION_4_41 (MMC_VERSION_MMC | 0x429)
|
#define MMC_VERSION_4_41 (MMC_VERSION_MMC | 0x441)
|
||||||
#define MMC_VERSION_4_5 (MMC_VERSION_MMC | 0x405)
|
#define MMC_VERSION_4_5 (MMC_VERSION_MMC | 0x450)
|
||||||
|
|
||||||
#define MMC_CAP_SPI (1 << 0)
|
#define MMC_CAP_SPI (1 << 0)
|
||||||
#define MMC_CAP_4_BIT_DATA (1 << 1)
|
#define MMC_CAP_4_BIT_DATA (1 << 1)
|
||||||
|
|
Loading…
Reference in New Issue