summaryrefslogtreecommitdiffstats
path: root/drivers/mci/mci-core.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2023-01-10 16:50:38 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2023-01-11 08:41:17 +0100
commit4ead6e90a9cb8734db3efcc3e3794b3356d2a451 (patch)
tree657eb45048e43634ae13c6224d3fee22ea86d5f3 /drivers/mci/mci-core.c
parentd415e746c9c33d576e94c59d55873d65ad9b4e4d (diff)
downloadbarebox-4ead6e90a9cb8734db3efcc3e3794b3356d2a451.tar.gz
barebox-4ead6e90a9cb8734db3efcc3e3794b3356d2a451.tar.xz
mci: handle SDIO cards gracefully
Detect SDIO cards properly to be able to return from card detection without errors. So far a SDIO card reports several errors during detection: ERROR: bcm2835_mci 3f300000.mmc@7e300000.of: Error while executing command 8 ERROR: bcm2835_mci 3f300000.mmc@7e300000.of: Status: 0x1FF0001, Interrupt: 0x18000 ERROR: bcm2835_mci 3f300000.mmc@7e300000.of: Error while executing command 55 ERROR: bcm2835_mci 3f300000.mmc@7e300000.of: Status: 0x1FF0001, Interrupt: 0x18000 ERROR: bcm2835_mci 3f300000.mmc@7e300000.of: Error while executing command 1 ERROR: bcm2835_mci 3f300000.mmc@7e300000.of: Status: 0x1FF0001, Interrupt: 0x18000 With this we can now detect SDIO cards without reporting errors, or to put it differently: barebox now has SDIO support ;) Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.barebox.org/20230110155039.2039341-2-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/mci/mci-core.c')
-rw-r--r--drivers/mci/mci-core.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
index 6c7293a21e..7fb13e7e5a 100644
--- a/drivers/mci/mci-core.c
+++ b/drivers/mci/mci-core.c
@@ -326,6 +326,15 @@ static int mci_go_idle(struct mci *mci)
return 0;
}
+static int sdio_send_op_cond(struct mci *mci)
+{
+ struct mci_cmd cmd;
+
+ mci_setup_cmd(&cmd, SD_IO_SEND_OP_COND, 0, MMC_RSP_SPI_R4 | MMC_RSP_R4 | MMC_CMD_BCR);
+
+ return mci_send_cmd(mci, &cmd, NULL);
+}
+
/**
* FIXME
* @param mci MCI instance
@@ -1690,7 +1699,9 @@ static void mci_info(struct device_d *dev)
mci_print_caps(host->host_caps);
printf("Card information:\n");
- printf(" Attached is a %s card\n", IS_SD(mci) ? "SD" : "MMC");
+ printf(" Card type: %s\n", mci->sdio ? "SDIO" : IS_SD(mci) ? "SD" : "MMC");
+ if (mci->sdio)
+ return;
printf(" Version: %s\n", mci_version_string(mci));
printf(" Capacity: %u MiB\n", (unsigned)(mci->capacity >> 20));
@@ -1903,6 +1914,16 @@ static int mci_card_probe(struct mci *mci)
goto on_error;
}
+ if (!host->no_sdio) {
+ rc = sdio_send_op_cond(mci);
+ if (!rc) {
+ mci->ready_for_use = true;
+ mci->sdio = true;
+ dev_info(&mci->dev, "SDIO card detected, ignoring\n");
+ return 0;
+ }
+ }
+
/* Check if this card can handle the "SD Card Physical Layer Specification 2.0" */
if (!host->no_sd) {
rc = sd_send_if_cond(mci);
@@ -2180,6 +2201,7 @@ void mci_of_parse_node(struct mci_host *host,
host->broken_cd = of_property_read_bool(np, "broken-cd");
host->non_removable = of_property_read_bool(np, "non-removable");
host->no_sd = of_property_read_bool(np, "no-sd");
+ host->no_sdio = of_property_read_bool(np, "no-sdio");
host->disable_wp = of_property_read_bool(np, "disable-wp");
}