mirror of
https://github.com/u-boot/u-boot.git
synced 2024-11-24 12:44:23 +08:00
dm: mmc: dwmmc: Support CONFIG_BLK
Add support for using driver model for block devices in this driver. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
ef5609c33f
commit
5e6ff810c3
@ -454,27 +454,40 @@ static const struct mmc_ops dwmci_ops = {
|
||||
.init = dwmci_init,
|
||||
};
|
||||
|
||||
void dwmci_setup_cfg(struct mmc_config *cfg, const char *name, int buswidth,
|
||||
uint caps, u32 max_clk, u32 min_clk)
|
||||
{
|
||||
cfg->name = name;
|
||||
cfg->ops = &dwmci_ops;
|
||||
cfg->f_min = min_clk;
|
||||
cfg->f_max = max_clk;
|
||||
|
||||
cfg->voltages = MMC_VDD_32_33 | MMC_VDD_33_34 | MMC_VDD_165_195;
|
||||
|
||||
cfg->host_caps = caps;
|
||||
|
||||
if (buswidth == 8) {
|
||||
cfg->host_caps |= MMC_MODE_8BIT;
|
||||
cfg->host_caps &= ~MMC_MODE_4BIT;
|
||||
} else {
|
||||
cfg->host_caps |= MMC_MODE_4BIT;
|
||||
cfg->host_caps &= ~MMC_MODE_8BIT;
|
||||
}
|
||||
cfg->host_caps |= MMC_MODE_HS | MMC_MODE_HS_52MHz;
|
||||
|
||||
cfg->b_max = CONFIG_SYS_MMC_MAX_BLK_COUNT;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_BLK
|
||||
int dwmci_bind(struct udevice *dev, struct mmc *mmc, struct mmc_config *cfg)
|
||||
{
|
||||
return mmc_bind(dev, mmc, cfg);
|
||||
}
|
||||
#else
|
||||
int add_dwmci(struct dwmci_host *host, u32 max_clk, u32 min_clk)
|
||||
{
|
||||
host->cfg.name = host->name;
|
||||
host->cfg.ops = &dwmci_ops;
|
||||
host->cfg.f_min = min_clk;
|
||||
host->cfg.f_max = max_clk;
|
||||
|
||||
host->cfg.voltages = MMC_VDD_32_33 | MMC_VDD_33_34 | MMC_VDD_165_195;
|
||||
|
||||
host->cfg.host_caps = host->caps;
|
||||
|
||||
if (host->buswidth == 8) {
|
||||
host->cfg.host_caps |= MMC_MODE_8BIT;
|
||||
host->cfg.host_caps &= ~MMC_MODE_4BIT;
|
||||
} else {
|
||||
host->cfg.host_caps |= MMC_MODE_4BIT;
|
||||
host->cfg.host_caps &= ~MMC_MODE_8BIT;
|
||||
}
|
||||
host->cfg.host_caps |= MMC_MODE_HS | MMC_MODE_HS_52MHz;
|
||||
|
||||
host->cfg.b_max = CONFIG_SYS_MMC_MAX_BLK_COUNT;
|
||||
dwmci_setup_cfg(&host->cfg, host->name, host->buswidth, host->caps,
|
||||
max_clk, min_clk);
|
||||
|
||||
host->mmc = mmc_create(&host->cfg, host);
|
||||
if (host->mmc == NULL)
|
||||
@ -482,3 +495,4 @@ int add_dwmci(struct dwmci_host *host, u32 max_clk, u32 min_clk)
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
@ -180,8 +180,9 @@ struct dwmci_host {
|
||||
* @freq: Frequency the host is trying to achieve
|
||||
*/
|
||||
unsigned int (*get_mmc_clk)(struct dwmci_host *host, uint freq);
|
||||
|
||||
#ifndef CONFIG_BLK
|
||||
struct mmc_config cfg;
|
||||
#endif
|
||||
|
||||
/* use fifo mode to read and write data */
|
||||
bool fifo_mode;
|
||||
@ -223,5 +224,9 @@ static inline u8 dwmci_readb(struct dwmci_host *host, int reg)
|
||||
return readb(host->ioaddr + reg);
|
||||
}
|
||||
|
||||
void dwmci_setup_cfg(struct mmc_config *cfg, const char *name, int buswidth,
|
||||
uint caps, u32 max_clk, u32 min_clk);
|
||||
int dwmci_bind(struct udevice *dev, struct mmc *mmc, struct mmc_config *cfg);
|
||||
|
||||
int add_dwmci(struct dwmci_host *host, u32 max_clk, u32 min_clk);
|
||||
#endif /* __DWMMC_HW_H */
|
||||
|
Loading…
Reference in New Issue
Block a user