From: Shawn Lin <shawn.lin@rock-chips.com>
To: Ulf Hansson <ulf.hansson@linaro.org>
Cc: linux-mmc@vger.kernel.org, Jaehoon Chung <jh80.chung@samsung.com>,
Shawn Lin <shawn.lin@rock-chips.com>
Subject: [PATCH 08/13] mmc: dw_mmc: Remove id from dw_mci_slot
Date: Thu, 20 Nov 2025 18:29:20 +0800 [thread overview]
Message-ID: <1763634565-183891-9-git-send-email-shawn.lin@rock-chips.com> (raw)
In-Reply-To: <1763634565-183891-1-git-send-email-shawn.lin@rock-chips.com>
There is only one slot support, id should be zero. So no need
to keep it in track.
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---
drivers/mmc/host/dw_mmc.c | 41 ++++++++++++++++++++---------------------
drivers/mmc/host/dw_mmc.h | 7 ++-----
2 files changed, 22 insertions(+), 26 deletions(-)
diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
index 3dc816e..83f213c 100644
--- a/drivers/mmc/host/dw_mmc.c
+++ b/drivers/mmc/host/dw_mmc.c
@@ -282,7 +282,7 @@ static u32 dw_mci_prepare_command(struct mmc_host *mmc, struct mmc_command *cmd)
* until the voltage change is all done.
*/
clk_en_a = mci_readl(host, CLKENA);
- clk_en_a &= ~(SDMMC_CLKEN_LOW_PWR << slot->id);
+ clk_en_a &= ~SDMMC_CLKEN_LOW_PWR;
mci_writel(host, CLKENA, clk_en_a);
mci_send_cmd(slot, SDMMC_CMD_UPD_CLK |
SDMMC_CMD_PRV_DAT_WAIT, 0);
@@ -904,7 +904,7 @@ static int dw_mci_get_cd(struct mmc_host *mmc)
} else if (gpio_cd >= 0)
present = gpio_cd;
else
- present = (mci_readl(slot->host, CDETECT) & (1 << slot->id))
+ present = (mci_readl(slot->host, CDETECT) & BIT(0))
== 0 ? 1 : 0;
spin_lock_bh(&host->lock);
@@ -1166,8 +1166,8 @@ static void dw_mci_setup_bus(struct dw_mci_slot *slot, bool force_clkinit)
/* Silent the verbose log if calling from PM context */
if (!force_clkinit)
dev_info(&host->mmc->class_dev,
- "Bus speed (slot %d) = %dHz (slot req %dHz, actual %dHZ div = %d)\n",
- slot->id, host->bus_hz, clock,
+ "Bus speed = %dHz (slot req %dHz, actual %dHZ div = %d)\n",
+ host->bus_hz, clock,
div ? ((host->bus_hz / div) >> 1) :
host->bus_hz, div);
@@ -1194,9 +1194,9 @@ static void dw_mci_setup_bus(struct dw_mci_slot *slot, bool force_clkinit)
mci_send_cmd(slot, sdmmc_cmd_bits, 0);
/* enable clock; only low power if no SDIO */
- clk_en_a = SDMMC_CLKEN_ENABLE << slot->id;
+ clk_en_a = SDMMC_CLKEN_ENABLE;
if (!test_bit(DW_MMC_CARD_NO_LOW_PWR, &host->flags))
- clk_en_a |= SDMMC_CLKEN_LOW_PWR << slot->id;
+ clk_en_a |= SDMMC_CLKEN_LOW_PWR;
mci_writel(host, CLKENA, clk_en_a);
/* inform CIU */
@@ -1211,7 +1211,7 @@ static void dw_mci_setup_bus(struct dw_mci_slot *slot, bool force_clkinit)
host->current_speed = clock;
/* Set the current slot bus width */
- mci_writel(host, CTYPE, (slot->ctype << slot->id));
+ mci_writel(host, CTYPE, host->ctype);
}
static void dw_mci_set_data_timeout(struct dw_mci *host,
@@ -1379,14 +1379,14 @@ static void dw_mci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
switch (ios->bus_width) {
case MMC_BUS_WIDTH_4:
- slot->ctype = SDMMC_CTYPE_4BIT;
+ slot->host->ctype = SDMMC_CTYPE_4BIT;
break;
case MMC_BUS_WIDTH_8:
- slot->ctype = SDMMC_CTYPE_8BIT;
+ slot->host->ctype = SDMMC_CTYPE_8BIT;
break;
default:
/* set default 1 bit mode */
- slot->ctype = SDMMC_CTYPE_1BIT;
+ slot->host->ctype = SDMMC_CTYPE_1BIT;
}
regs = mci_readl(slot->host, UHS_REG);
@@ -1395,9 +1395,9 @@ static void dw_mci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
if (ios->timing == MMC_TIMING_MMC_DDR52 ||
ios->timing == MMC_TIMING_UHS_DDR50 ||
ios->timing == MMC_TIMING_MMC_HS400)
- regs |= ((0x1 << slot->id) << 16);
+ regs |= BIT(16);
else
- regs &= ~((0x1 << slot->id) << 16);
+ regs &= ~BIT(16);
mci_writel(slot->host, UHS_REG, regs);
slot->host->timing = ios->timing;
@@ -1425,7 +1425,7 @@ static void dw_mci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
}
set_bit(DW_MMC_CARD_NEED_INIT, &slot->host->flags);
regs = mci_readl(slot->host, PWREN);
- regs |= (1 << slot->id);
+ regs |= BIT(0);
mci_writel(slot->host, PWREN, regs);
break;
case MMC_POWER_ON:
@@ -1450,7 +1450,7 @@ static void dw_mci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
regulator_disable(mmc->supply.vqmmc);
regs = mci_readl(slot->host, PWREN);
- regs &= ~(1 << slot->id);
+ regs &= ~BIT(0);
mci_writel(slot->host, PWREN, regs);
/* Reset our state machine after powering off */
dw_mci_ctrl_reset(slot->host, SDMMC_CTRL_ALL_RESET_FLAGS);
@@ -1483,7 +1483,7 @@ static int dw_mci_switch_voltage(struct mmc_host *mmc, struct mmc_ios *ios)
struct dw_mci *host = slot->host;
const struct dw_mci_drv_data *drv_data = host->drv_data;
u32 uhs;
- u32 v18 = SDMMC_UHS_18V << slot->id;
+ u32 v18 = SDMMC_UHS_18V;
int ret;
if (drv_data && drv_data->switch_voltage)
@@ -1525,7 +1525,7 @@ static int dw_mci_get_ro(struct mmc_host *mmc)
read_only = gpio_ro;
else
read_only =
- mci_readl(slot->host, WRTPRT) & (1 << slot->id) ? 1 : 0;
+ mci_readl(slot->host, WRTPRT) & BIT(0) ? 1 : 0;
dev_dbg(&mmc->class_dev, "card is %s\n",
read_only ? "read-only" : "read-write");
@@ -1559,10 +1559,10 @@ static void dw_mci_hw_reset(struct mmc_host *mmc)
* tRSTH >= 1us: RST_n high period
*/
reset = mci_readl(host, RST_N);
- reset &= ~(SDMMC_RST_HWACTIVE << slot->id);
+ reset &= ~SDMMC_RST_HWACTIVE;
mci_writel(host, RST_N, reset);
usleep_range(1, 2);
- reset |= SDMMC_RST_HWACTIVE << slot->id;
+ reset |= SDMMC_RST_HWACTIVE;
mci_writel(host, RST_N, reset);
usleep_range(200, 300);
}
@@ -1570,7 +1570,7 @@ static void dw_mci_hw_reset(struct mmc_host *mmc)
static void dw_mci_prepare_sdio_irq(struct dw_mci_slot *slot, bool prepare)
{
struct dw_mci *host = slot->host;
- const u32 clken_low_pwr = SDMMC_CLKEN_LOW_PWR << slot->id;
+ const u32 clken_low_pwr = SDMMC_CLKEN_LOW_PWR;
u32 clk_en_a_old;
u32 clk_en_a;
@@ -2931,8 +2931,7 @@ static int dw_mci_init_slot(struct dw_mci *host)
return -ENOMEM;
slot = mmc_priv(mmc);
- slot->id = 0;
- slot->sdio_id = host->sdio_id0 + slot->id;
+ slot->sdio_id = host->sdio_id0;
host->mmc = mmc;
slot->host = host;
host->slot = slot;
diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h
index 933d0a37..7f6efb6 100644
--- a/drivers/mmc/host/dw_mmc.h
+++ b/drivers/mmc/host/dw_mmc.h
@@ -129,6 +129,7 @@ struct dw_mci_dma_slave {
* @dto_timer: Timer for broken data transfer over scheme.
* @mmc: The mmc_host representing this dw_mci.
* @flags: Random state bits associated with the host.
+ * @ctype: Card type for this host.
*
* Locking
* =======
@@ -249,6 +250,7 @@ struct dw_mci {
#define DW_MMC_CARD_NO_LOW_PWR 2
#define DW_MMC_CARD_NO_USE_HOLD 3
#define DW_MMC_CARD_NEEDS_POLL 4
+ u32 ctype;
};
/* DMA ops for Internal/External DMAC interface */
@@ -553,7 +555,6 @@ static inline int dw_mci_runtime_resume(struct device *device) { return -EOPNOTS
/**
* struct dw_mci_slot - MMC slot state
* @host: The MMC controller this slot is using.
- * @ctype: Card type for this slot.
* @mrq: mmc_request currently being processed or waiting to be
* processed, or NULL when the slot is idle.
* @queue_node: List node for placing this node in the @queue list of
@@ -561,21 +562,17 @@ static inline int dw_mci_runtime_resume(struct device *device) { return -EOPNOTS
* @clock: Clock rate configured by set_ios(). Protected by host->lock.
* @__clk_old: The last clock value that was requested from core.
* Keeping track of this helps us to avoid spamming the console.
- * @id: Number of this slot.
* @sdio_id: Number of this slot in the SDIO interrupt registers.
*/
struct dw_mci_slot {
struct dw_mci *host;
- u32 ctype;
-
struct mmc_request *mrq;
struct list_head queue_node;
unsigned int clock;
unsigned int __clk_old;
- int id;
int sdio_id;
};
--
2.7.4
next prev parent reply other threads:[~2025-11-20 10:37 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-20 10:29 [PATCH 0/13] dw_mmc cleanup Shawn Lin
2025-11-20 10:29 ` [PATCH 01/13] mmc: dw_mmc: Remove unused struct dma_pdata Shawn Lin
2025-11-20 10:29 ` [PATCH 02/13] mmc: dw_mmc: add dw_mci_prepare_desc() for both of 32bit and 64bit DMA Shawn Lin
2025-11-20 10:29 ` [PATCH 03/13] mmc: dw_mmc: Remove vqmmc_enabled from struct dw_mci Shawn Lin
2025-11-25 12:23 ` Ulf Hansson
2025-11-20 10:29 ` [PATCH 04/13] mmc: dw_mmc: Remove unused header files and keep alphabetical order Shawn Lin
2025-11-20 10:29 ` [PATCH 05/13] mmc: dw_mmc: Move struct mmc_host from struct dw_mci_slot to struct dw_mci Shawn Lin
2025-11-20 10:29 ` [PATCH 06/13] mmc: dw_mmc: Let glue drivers to use struct dw_mci as possible Shawn Lin
2025-11-20 10:29 ` [PATCH 07/13] mmc: dw_mmc: Move flags from struct dw_mci_slot to struct dw_mci Shawn Lin
2025-11-20 10:29 ` Shawn Lin [this message]
2025-11-20 10:29 ` [PATCH 09/13] mmc: dw_mmc: Remove sdio_id from struct dw_mci_slot Shawn Lin
2025-11-20 10:29 ` [PATCH 10/13] mmc: dw_mmc: Move clock rate stuff from struct dw_mci_slot to struct dw_mci Shawn Lin
2025-11-20 10:29 ` [PATCH 11/13] mmc: dw_mmc: Remove mrq from struct dw_mci_slot Shawn Lin
2025-11-20 10:29 ` [PATCH 12/13] mmc: dw_mmc: Remove queue from dw_mci Shawn Lin
2025-11-20 10:29 ` [PATCH 13/13] mmc: dw_mmc: Remove struct dw_mci_slot Shawn Lin
2025-11-22 18:40 ` kernel test robot
2025-11-22 19:54 ` kernel test robot
2025-11-20 11:10 ` [PATCH 0/13] dw_mmc cleanup Ulf Hansson
2025-11-20 12:51 ` Shawn Lin
2025-11-25 12:33 ` Ulf Hansson
2025-11-25 14:00 ` Shawn Lin
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=1763634565-183891-9-git-send-email-shawn.lin@rock-chips.com \
--to=shawn.lin@rock-chips.com \
--cc=jh80.chung@samsung.com \
--cc=linux-mmc@vger.kernel.org \
--cc=ulf.hansson@linaro.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