From: Sebastien Bourdelin <sebastien.bourdelin@gmail.com>
To: barebox@lists.infradead.org
Cc: Sebastien Bourdelin <sebastien.bourdelin@gmail.com>,
a.fatoum@pengutronix.de, sebastien.bourdelin@rtone.fr,
oss-contrib@rtone.fr
Subject: [PATCH v2 3/4] mci: sdhci: use the busy_timeout value in the sdhci_wait_idle functions
Date: Wed, 6 Nov 2024 16:25:24 +0100 [thread overview]
Message-ID: <20241106152525.856201-4-sebastien.bourdelin@gmail.com> (raw)
In-Reply-To: <20241106152525.856201-1-sebastien.bourdelin@gmail.com>
From: Sebastien Bourdelin <sebastien.bourdelin@rtone.fr>
The busy_timeout value is used by the sdhci_wait_idle and
sdhci_wait_idle_data functions to define the timeout to wait on when
send a command to the controller.
The default value remains unchanged and is set to 10ms.
Signed-off-by: Sebastien Bourdelin <sebastien.bourdelin@rtone.fr>
---
Changes v1 -> v2:
- rename SDHCI_CMD_DEFAULT_BUSY_TIMEOUT to SDHCI_CMD_DEFAULT_BUSY_TIMEOUT_MS (suggested by Ahmad Fatoum)
Signed-off-by: Sebastien Bourdelin <sebastien.bourdelin@gmail.com>
---
drivers/mci/sdhci.c | 14 ++++++++++++--
drivers/mci/sdhci.h | 2 ++
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/drivers/mci/sdhci.c b/drivers/mci/sdhci.c
index fe033583ad..9b04101c0f 100644
--- a/drivers/mci/sdhci.c
+++ b/drivers/mci/sdhci.c
@@ -796,9 +796,11 @@ void sdhci_enable_clk(struct sdhci *host, u16 clk)
int sdhci_wait_idle(struct sdhci *host, struct mci_cmd *cmd, struct mci_data *data)
{
u32 mask;
+ unsigned timeout_ms;
int ret;
mask = SDHCI_CMD_INHIBIT_CMD;
+ timeout_ms = SDHCI_CMD_DEFAULT_BUSY_TIMEOUT_MS;
if (data || (cmd && (cmd->resp_type & MMC_RSP_BUSY)))
mask |= SDHCI_CMD_INHIBIT_DATA;
@@ -806,7 +808,10 @@ int sdhci_wait_idle(struct sdhci *host, struct mci_cmd *cmd, struct mci_data *da
if (cmd && cmd->cmdidx == MMC_CMD_STOP_TRANSMISSION)
mask &= ~SDHCI_CMD_INHIBIT_DATA;
- ret = wait_on_timeout(10 * MSECOND,
+ if (cmd && cmd->busy_timeout != 0)
+ timeout_ms = cmd->busy_timeout;
+
+ ret = wait_on_timeout(timeout_ms * MSECOND,
!(sdhci_read32(host, SDHCI_PRESENT_STATE) & mask));
if (ret) {
@@ -821,14 +826,19 @@ int sdhci_wait_idle(struct sdhci *host, struct mci_cmd *cmd, struct mci_data *da
int sdhci_wait_idle_data(struct sdhci *host, struct mci_cmd *cmd)
{
u32 mask;
+ unsigned timeout_ms;
int ret;
mask = SDHCI_CMD_INHIBIT_CMD | SDHCI_CMD_INHIBIT_DATA;
+ timeout_ms = SDHCI_CMD_DEFAULT_BUSY_TIMEOUT_MS;
if (cmd && cmd->cmdidx == MMC_CMD_STOP_TRANSMISSION)
mask &= ~SDHCI_CMD_INHIBIT_DATA;
- ret = wait_on_timeout(10 * MSECOND,
+ if (cmd && cmd->busy_timeout != 0)
+ timeout_ms = cmd->busy_timeout;
+
+ ret = wait_on_timeout(timeout_ms * MSECOND,
!(sdhci_read32(host, SDHCI_PRESENT_STATE) & mask));
if (ret) {
diff --git a/drivers/mci/sdhci.h b/drivers/mci/sdhci.h
index 5de85239b1..2a8456545d 100644
--- a/drivers/mci/sdhci.h
+++ b/drivers/mci/sdhci.h
@@ -200,6 +200,8 @@
#define SDHCI_MAX_DIV_SPEC_200 256
#define SDHCI_MAX_DIV_SPEC_300 2046
+#define SDHCI_CMD_DEFAULT_BUSY_TIMEOUT_MS 10
+
struct sdhci {
u32 (*read32)(struct sdhci *host, int reg);
u16 (*read16)(struct sdhci *host, int reg);
--
2.47.0
next prev parent reply other threads:[~2024-11-06 15:26 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-06 15:25 [PATCH v2 0/4] Add a struct mci_cmd::busy_timeout member Sebastien Bourdelin
2024-11-06 15:25 ` [PATCH v2 1/4] mci: add a busy_timeout member to the struct mci_cmd Sebastien Bourdelin
2024-11-06 15:25 ` [PATCH v2 2/4] mci: zeroed all structs mci_cmd instances Sebastien Bourdelin
2024-11-06 15:25 ` Sebastien Bourdelin [this message]
2024-11-06 15:25 ` [PATCH v2 4/4] mci: bcm2835: set timeout value to 100ms Sebastien Bourdelin
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=20241106152525.856201-4-sebastien.bourdelin@gmail.com \
--to=sebastien.bourdelin@gmail.com \
--cc=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=oss-contrib@rtone.fr \
--cc=sebastien.bourdelin@rtone.fr \
/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