From: Inochi Amaoto <inochiama@gmail.com>
To: Ulf Hansson <ulfh@kernel.org>,
Karol Gugala <kgugala@antmicro.com>,
Mateusz Holenko <mholenko@antmicro.com>,
Gabriel Somlo <gsomlo@gmail.com>, Joel Stanley <joel@jms.id.au>
Cc: Inochi Amaoto <inochiama@gmail.com>,
linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org,
Yixun Lan <dlan@gentoo.org>, Longbin Li <looong.bin@gmail.com>
Subject: [PATCH 2/2] mmc: litex_mmc: Remove unused logic for the fixed bus width
Date: Mon, 29 Jun 2026 15:25:08 +0800 [thread overview]
Message-ID: <20260629072510.1451480-3-inochiama@gmail.com> (raw)
In-Reply-To: <20260629072510.1451480-1-inochiama@gmail.com>
As the set_ios() function in litex_mmc driver does support
setting bus width, it is not necessary to leave the logic
for fixed bus width. Clean up these unneeded code.
Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
---
drivers/mmc/host/litex_mmc.c | 95 ++----------------------------------
1 file changed, 3 insertions(+), 92 deletions(-)
diff --git a/drivers/mmc/host/litex_mmc.c b/drivers/mmc/host/litex_mmc.c
index affdff8621bf..1b5ac4b38f4c 100644
--- a/drivers/mmc/host/litex_mmc.c
+++ b/drivers/mmc/host/litex_mmc.c
@@ -104,10 +104,6 @@ struct litex_mmc_host {
u8 width;
u32 resp[4];
- u16 rca;
-
- bool is_bus_width_set;
- bool app_cmd;
};
static int litex_mmc_sdcard_wait_done(void __iomem *reg, struct device *dev)
@@ -172,11 +168,6 @@ static int litex_mmc_send_cmd(struct litex_mmc_host *host,
host->sdcore + LITEX_CORE_CMDRSP, 0x10);
}
- if (!host->app_cmd && cmd == SD_SEND_RELATIVE_ADDR)
- host->rca = (host->resp[3] >> 16);
-
- host->app_cmd = (cmd == MMC_APP_CMD);
-
if (transfer == SD_CTL_DATA_XFER_NONE)
return ret; /* OK from prior litex_mmc_sdcard_wait_done() */
@@ -198,51 +189,6 @@ static int litex_mmc_send_cmd(struct litex_mmc_host *host,
return ret;
}
-static int litex_mmc_send_app_cmd(struct litex_mmc_host *host)
-{
- return litex_mmc_send_cmd(host, MMC_APP_CMD, host->rca << 16,
- SD_CTL_RESP_SHORT, SD_CTL_DATA_XFER_NONE);
-}
-
-static int litex_mmc_send_set_bus_w_cmd(struct litex_mmc_host *host, u32 width)
-{
- return litex_mmc_send_cmd(host, SD_APP_SET_BUS_WIDTH, width,
- SD_CTL_RESP_SHORT, SD_CTL_DATA_XFER_NONE);
-}
-
-static int litex_mmc_set_bus_width(struct litex_mmc_host *host)
-{
- bool app_cmd_sent;
- int ret;
-
- if (host->is_bus_width_set)
- return 0;
-
- /* Ensure 'app_cmd' precedes 'app_set_bus_width_cmd' */
- app_cmd_sent = host->app_cmd; /* was preceding command app_cmd? */
- if (!app_cmd_sent) {
- ret = litex_mmc_send_app_cmd(host);
- if (ret)
- return ret;
- }
-
- /* LiteSDCard only supports 4-bit bus width */
- ret = litex_mmc_send_set_bus_w_cmd(host, MMC_BUS_WIDTH_4);
- if (ret)
- return ret;
-
- /* Re-send 'app_cmd' if necessary */
- if (app_cmd_sent) {
- ret = litex_mmc_send_app_cmd(host);
- if (ret)
- return ret;
- }
-
- host->is_bus_width_set = true;
-
- return 0;
-}
-
static int litex_mmc_get_cd(struct mmc_host *mmc)
{
struct litex_mmc_host *host = mmc_priv(mmc);
@@ -255,9 +201,6 @@ static int litex_mmc_get_cd(struct mmc_host *mmc)
if (ret)
return ret;
- /* Ensure bus width will be set (again) upon card (re)insertion */
- host->is_bus_width_set = false;
-
return 0;
}
@@ -373,39 +316,19 @@ static void litex_mmc_request(struct mmc_host *mmc, struct mmc_request *mrq)
litex_mmc_response_len(sbc),
SD_CTL_DATA_XFER_NONE);
if (sbc->error) {
- host->is_bus_width_set = false;
mmc_request_done(mmc, mrq);
return;
}
}
- if (data) {
- /*
- * LiteSDCard only supports 4-bit bus width; therefore, we MUST
- * inject a SET_BUS_WIDTH (acmd6) before the very first data
- * transfer, earlier than when the mmc subsystem would normally
- * get around to it!
- */
- cmd->error = litex_mmc_set_bus_width(host);
- if (cmd->error) {
- dev_err(dev, "Can't set bus width!\n");
- mmc_request_done(mmc, mrq);
- return;
- }
-
+ if (data)
litex_mmc_do_dma(host, data, &len, &direct, &transfer);
- }
do {
cmd->error = litex_mmc_send_cmd(host, cmd->opcode, cmd->arg,
response_len, transfer);
} while (cmd->error && retries-- > 0);
- if (cmd->error) {
- /* Card may be gone; don't assume bus width is still set */
- host->is_bus_width_set = false;
- }
-
if (response_len == SD_CTL_RESP_SHORT) {
/* Pull short response fields from appropriate host registers */
cmd->resp[0] = host->resp[3];
@@ -418,13 +341,10 @@ static void litex_mmc_request(struct mmc_host *mmc, struct mmc_request *mrq)
}
/* Send stop-transmission command if required */
- if (stop && (cmd->error || !sbc)) {
+ if (stop && (cmd->error || !sbc))
stop->error = litex_mmc_send_cmd(host, stop->opcode, stop->arg,
litex_mmc_response_len(stop),
SD_CTL_DATA_XFER_NONE);
- if (stop->error)
- host->is_bus_width_set = false;
- }
if (data) {
dma_unmap_sg(dev, data->sg, data->sg_len,
@@ -565,14 +485,6 @@ static int litex_mmc_probe(struct platform_device *pdev)
return dev_err_probe(dev, PTR_ERR(clk), "can't get clock\n");
host->ref_clk = clk_get_rate(clk);
host->sd_clk = 0;
-
- /*
- * LiteSDCard only supports 4-bit bus width; therefore, we MUST inject
- * a SET_BUS_WIDTH (acmd6) before the very first data transfer, earlier
- * than when the mmc subsystem would normally get around to it!
- */
- host->is_bus_width_set = false;
- host->app_cmd = false;
host->width = MMC_BUS_WIDTH_1;
/* LiteSDCard can support 64-bit DMA addressing */
@@ -633,9 +545,8 @@ static int litex_mmc_probe(struct platform_device *pdev)
if (ret)
return ret;
- /* Force 4-bit bus_width (only width supported by hardware) */
+ /* Only drop 8-bit bus_width support */
mmc->caps &= ~MMC_CAP_8_BIT_DATA;
- mmc->caps |= MMC_CAP_4_BIT_DATA;
/* Set default capabilities */
mmc->caps |= MMC_CAP_WAIT_WHILE_BUSY |
--
2.54.0
prev parent reply other threads:[~2026-06-29 7:25 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-29 7:25 [PATCH 0/2] mmc: litex_mmc: Respect the bus width request from the core Inochi Amaoto
2026-06-29 7:25 ` [PATCH 1/2] mmc: litex_mmc: Set width from linux request Inochi Amaoto
2026-06-29 7:25 ` Inochi Amaoto [this message]
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=20260629072510.1451480-3-inochiama@gmail.com \
--to=inochiama@gmail.com \
--cc=dlan@gentoo.org \
--cc=gsomlo@gmail.com \
--cc=joel@jms.id.au \
--cc=kgugala@antmicro.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=looong.bin@gmail.com \
--cc=mholenko@antmicro.com \
--cc=ulfh@kernel.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