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@xxxxxxxxxxx: Error while executing command 8 ERROR: bcm2835_mci 3f300000.mmc@xxxxxxxxxxx: Status: 0x1FF0001, Interrupt: 0x18000 ERROR: bcm2835_mci 3f300000.mmc@xxxxxxxxxxx: Error while executing command 55 ERROR: bcm2835_mci 3f300000.mmc@xxxxxxxxxxx: Status: 0x1FF0001, Interrupt: 0x18000 ERROR: bcm2835_mci 3f300000.mmc@xxxxxxxxxxx: Error while executing command 1 ERROR: bcm2835_mci 3f300000.mmc@xxxxxxxxxxx: 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@xxxxxxxxxxxxxx> --- drivers/mci/mci-core.c | 24 +++++++++++++++++++++++- include/mci.h | 4 ++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c index 8cda07e711..44a577e8c3 100644 --- a/drivers/mci/mci-core.c +++ b/drivers/mci/mci-core.c @@ -232,6 +232,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 @@ -1596,7 +1605,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)); @@ -1809,6 +1820,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); @@ -2086,6 +2107,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"); } diff --git a/include/mci.h b/include/mci.h index d3201e17e6..56a5659e50 100644 --- a/include/mci.h +++ b/include/mci.h @@ -91,6 +91,8 @@ #define SD_CMD_APP_SEND_OP_COND 41 #define SD_CMD_APP_SEND_SCR 51 +#define SD_IO_SEND_OP_COND 5 /* bcr [23:0] OCR R4 */ + /* SCR definitions in different words */ #define SD_HIGHSPEED_BUSY 0x00020000 #define SD_HIGHSPEED_SUPPORTED 0x00020000 @@ -431,6 +433,7 @@ struct mci_host { int broken_cd; /**< card detect is broken */ bool non_removable; /**< device is non removable */ bool no_sd; /**< do not send SD commands during initialization */ + bool no_sdio; /**< do not send SDIO commands during initialization */ bool disable_wp; /**< ignore write-protect detection logic */ struct regulator *supply; @@ -469,6 +472,7 @@ struct mci { struct mci_host *host; /**< the host for this card */ struct device_d dev; /**< the device for our disk (mcix) */ unsigned version; + bool sdio; /**< card is a SDIO card */ /** != 0 when a high capacity card is connected (OCR -> OCR_HCS) */ int high_capacity; unsigned card_caps; /**< Card's capabilities */ -- 2.30.2