From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 2/3] mci: handle SDIO cards gracefully
Date: Tue, 10 Jan 2023 16:50:38 +0100 [thread overview]
Message-ID: <20230110155039.2039341-2-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20230110155039.2039341-1-s.hauer@pengutronix.de>
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>
---
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
next prev parent reply other threads:[~2023-01-10 15:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-10 15:50 [PATCH 1/3] mci: Add more respone types Sascha Hauer
2023-01-10 15:50 ` Sascha Hauer [this message]
2023-01-10 15:50 ` [PATCH 3/3] ARM: dts: rpi3: Enable sdhci controller Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230110155039.2039341-2-s.hauer@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox