X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=drivers%2Fmmc%2Frockchip_sdhci.c;h=ab89be47644e9dc3359255ce0a4be7a4d42b7ddb;hb=80a66a55fa46960e0c8c527503e76adc18bfe904;hp=e33e35e4fa560f9785bb50f0bd75e95916c2ab5c;hpb=f253f2933b7373556329c0174dd5b101039a4056;p=oweals%2Fu-boot.git diff --git a/drivers/mmc/rockchip_sdhci.c b/drivers/mmc/rockchip_sdhci.c index e33e35e4fa..ab89be4764 100644 --- a/drivers/mmc/rockchip_sdhci.c +++ b/drivers/mmc/rockchip_sdhci.c @@ -8,9 +8,10 @@ #include #include -#include -#include +#include +#include #include +#include #include #include @@ -19,6 +20,9 @@ DECLARE_GLOBAL_DATA_PTR; #define EMMC_MIN_FREQ 400000 struct rockchip_sdhc_plat { +#if CONFIG_IS_ENABLED(OF_PLATDATA) + struct dtd_rockchip_rk3399_sdhci_5_1 dtplat; +#endif struct mmc_config cfg; struct mmc mmc; }; @@ -37,10 +41,17 @@ static int arasan_sdhci_probe(struct udevice *dev) int max_frequency, ret; struct clk clk; +#if CONFIG_IS_ENABLED(OF_PLATDATA) + struct dtd_rockchip_rk3399_sdhci_5_1 *dtplat = &plat->dtplat; - max_frequency = fdtdec_get_int(gd->fdt_blob, dev->of_offset, - "max-frequency", 0); + host->name = dev->name; + host->ioaddr = map_sysmem(dtplat->reg[0], dtplat->reg[1]); + max_frequency = dtplat->max_frequency; + ret = clk_get_by_index_platdata(dev, 0, dtplat->clocks, &clk); +#else + max_frequency = dev_read_u32_default(dev, "max-frequency", 0); ret = clk_get_by_index(dev, 0, &clk); +#endif if (!ret) { ret = clk_set_rate(&clk, max_frequency); if (IS_ERR_VALUE(ret)) @@ -50,9 +61,16 @@ static int arasan_sdhci_probe(struct udevice *dev) } host->quirks = SDHCI_QUIRK_WAIT_SEND_CMD; + host->max_clk = max_frequency; + /* + * The sdhci-driver only supports 4bit and 8bit, as sdhci_setup_cfg + * doesn't allow us to clear MMC_MODE_4BIT. Consequently, we don't + * check for other bus-width values. + */ + if (host->bus_width == 8) + host->host_caps |= MMC_MODE_8BIT; - ret = sdhci_setup_cfg(&plat->cfg, host, max_frequency, - EMMC_MIN_FREQ); + ret = sdhci_setup_cfg(&plat->cfg, host, 0, EMMC_MIN_FREQ); host->mmc = &plat->mmc; if (ret) @@ -66,10 +84,13 @@ static int arasan_sdhci_probe(struct udevice *dev) static int arasan_sdhci_ofdata_to_platdata(struct udevice *dev) { +#if !CONFIG_IS_ENABLED(OF_PLATDATA) struct sdhci_host *host = dev_get_priv(dev); host->name = dev->name; - host->ioaddr = dev_get_addr_ptr(dev); + host->ioaddr = dev_read_addr_ptr(dev); + host->bus_width = dev_read_u32_default(dev, "bus-width", 4); +#endif return 0; } @@ -87,7 +108,7 @@ static const struct udevice_id arasan_sdhci_ids[] = { }; U_BOOT_DRIVER(arasan_sdhci_drv) = { - .name = "arasan_sdhci", + .name = "rockchip_rk3399_sdhci_5_1", .id = UCLASS_MMC, .of_match = arasan_sdhci_ids, .ofdata_to_platdata = arasan_sdhci_ofdata_to_platdata,