mmc: dw_mmc: Remove struct dw_mci_board

The only user of dw_mci_board is dw_pci-pci, now we can provide
the caps from dw_mci_drv_data, so we could let dw_pci-pci use
dw_mci_drv_data and remove caps from struct dw_mci_board.

With that, struct dw_mci_board is no longer needed, we can remove
it. Then we should check all settings in dw_mci_parse_dt in order
not to overwrite them if provided from variant drivers.

Also, without CONFIG_OF support, dw_mmc doesn' work as host->pdata
is always ERR_PTR(-EINVAL), we could remove it together.

Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
This commit is contained in:
Shawn Lin 2026-01-06 10:17:01 +08:00 committed by Ulf Hansson
parent ec6d8bb39d
commit 792bd24b6e
3 changed files with 17 additions and 41 deletions

View File

@ -24,8 +24,8 @@
MMC_CAP_SD_HIGHSPEED | MMC_CAP_8_BIT_DATA |\
MMC_CAP_SDIO_IRQ)
static struct dw_mci_board pci_board_data = {
.caps = DW_MCI_CAPABILITIES,
static const struct dw_mci_drv_data pci_drv_data = {
.common_caps = DW_MCI_CAPABILITIES,
};
static int dw_mci_pci_probe(struct pci_dev *pdev,
@ -44,10 +44,10 @@ static int dw_mci_pci_probe(struct pci_dev *pdev,
host->irq = pdev->irq;
host->irq_flags = IRQF_SHARED;
host->pdata = &pci_board_data;
host->fifo_depth = 32;
host->detect_delay_ms = 200;
host->bus_hz = 33 * 1000 * 1000;
host->drv_data = &pci_drv_data;
ret = pcim_iomap_regions(pdev, 1 << PCI_BAR_NO, pci_name(pdev));
if (ret)

View File

@ -2837,9 +2837,6 @@ static int dw_mci_init_host_caps(struct dw_mci *host)
struct mmc_host *mmc = host->mmc;
int ctrl_id;
if (host->pdata->caps)
mmc->caps = host->pdata->caps;
if (drv_data)
mmc->caps |= drv_data->common_caps;
@ -3152,55 +3149,44 @@ static void dw_mci_dto_timer(struct timer_list *t)
spin_unlock_irqrestore(&host->irq_lock, irqflags);
}
#ifdef CONFIG_OF
static struct dw_mci_board *dw_mci_parse_dt(struct dw_mci *host)
static int dw_mci_parse_dt(struct dw_mci *host)
{
struct dw_mci_board *pdata;
struct device *dev = host->dev;
const struct dw_mci_drv_data *drv_data = host->drv_data;
int ret;
u32 clock_frequency;
pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
if (!pdata)
return ERR_PTR(-ENOMEM);
/* find reset controller when exist */
host->rstc = devm_reset_control_get_optional_exclusive(dev, "reset");
if (IS_ERR(host->rstc))
return ERR_CAST(host->rstc);
return PTR_ERR(host->rstc);
if (device_property_read_u32(dev, "fifo-depth", &host->fifo_depth))
if (!host->fifo_depth && device_property_read_u32(dev, "fifo-depth", &host->fifo_depth))
dev_info(dev,
"fifo-depth property not found, using value of FIFOTH register as default\n");
device_property_read_u32(dev, "card-detect-delay",
&host->detect_delay_ms);
if (!host->detect_delay_ms)
device_property_read_u32(dev, "card-detect-delay",
&host->detect_delay_ms);
device_property_read_u32(dev, "data-addr", &host->data_addr_override);
if (!host->data_addr_override)
device_property_read_u32(dev, "data-addr", &host->data_addr_override);
if (device_property_present(dev, "fifo-watermark-aligned"))
host->wm_aligned = true;
if (!device_property_read_u32(dev, "clock-frequency", &clock_frequency))
if (!host->bus_hz && !device_property_read_u32(dev, "clock-frequency", &clock_frequency))
host->bus_hz = clock_frequency;
if (drv_data && drv_data->parse_dt) {
ret = drv_data->parse_dt(host);
if (ret)
return ERR_PTR(ret);
return ret;
}
return pdata;
return 0;
}
#else /* CONFIG_OF */
static struct dw_mci_board *dw_mci_parse_dt(struct dw_mci *host)
{
return ERR_PTR(-EINVAL);
}
#endif /* CONFIG_OF */
static void dw_mci_enable_cd(struct dw_mci *host)
{
unsigned long irqflags;
@ -3245,12 +3231,9 @@ int dw_mci_probe(struct dw_mci *host)
int width, i, ret = 0;
u32 fifo_size;
if (!host->pdata) {
host->pdata = dw_mci_parse_dt(host);
if (IS_ERR(host->pdata))
return dev_err_probe(host->dev, PTR_ERR(host->pdata),
"platform data not available\n");
}
ret = dw_mci_parse_dt(host);
if (ret)
return dev_err_probe(host->dev, ret, "parse dt failed\n");
host->biu_clk = devm_clk_get(host->dev, "biu");
if (IS_ERR(host->biu_clk)) {

View File

@ -103,7 +103,6 @@ struct dw_mci_dma_slave {
* @fifoth_val: The value of FIFOTH register.
* @verid: Denote Version ID.
* @dev: Device associated with the MMC controller.
* @pdata: Platform data associated with the MMC controller.
* @drv_data: Driver specific data for identified variant of the controller
* @priv: Implementation defined private data.
* @biu_clk: Pointer to bus interface unit clock instance.
@ -208,7 +207,6 @@ struct dw_mci {
u32 fifoth_val;
u16 verid;
struct device *dev;
struct dw_mci_board *pdata;
const struct dw_mci_drv_data *drv_data;
void *priv;
struct clk *biu_clk;
@ -268,11 +266,6 @@ struct dw_mci_dma_ops {
void (*exit)(struct dw_mci *host);
};
/* Board platform data */
struct dw_mci_board {
u32 caps; /* Capabilities */
};
/* Support for longer data read timeout */
#define DW_MMC_QUIRK_EXTENDED_TMOUT BIT(0)
/* Force 32-bit access to the FIFO */