mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-04-02 04:21:32 +00:00
rockchip: sdhci: rk3399: update driver to support of-platdata
Change some API in order to enable of-platdata. Signed-off-by: Kever Yang <kever.yang@rock-chips.com> Reviewed-by: Simon Glass <sjg@chromium.org> Added rockchip tag: Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
5ae2fd9724
commit
c2868212bb
1 changed files with 16 additions and 1 deletions
|
@ -8,9 +8,11 @@
|
||||||
|
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
#include <dm.h>
|
#include <dm.h>
|
||||||
|
#include <dt-structs.h>
|
||||||
#include <fdtdec.h>
|
#include <fdtdec.h>
|
||||||
#include <libfdt.h>
|
#include <libfdt.h>
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
|
#include <mapmem.h>
|
||||||
#include <sdhci.h>
|
#include <sdhci.h>
|
||||||
#include <clk.h>
|
#include <clk.h>
|
||||||
|
|
||||||
|
@ -19,6 +21,9 @@ DECLARE_GLOBAL_DATA_PTR;
|
||||||
#define EMMC_MIN_FREQ 400000
|
#define EMMC_MIN_FREQ 400000
|
||||||
|
|
||||||
struct rockchip_sdhc_plat {
|
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_config cfg;
|
||||||
struct mmc mmc;
|
struct mmc mmc;
|
||||||
};
|
};
|
||||||
|
@ -37,10 +42,18 @@ static int arasan_sdhci_probe(struct udevice *dev)
|
||||||
int max_frequency, ret;
|
int max_frequency, ret;
|
||||||
struct clk clk;
|
struct clk clk;
|
||||||
|
|
||||||
|
#if CONFIG_IS_ENABLED(OF_PLATDATA)
|
||||||
|
struct dtd_rockchip_rk3399_sdhci_5_1 *dtplat = &plat->dtplat;
|
||||||
|
|
||||||
|
host->name = dev->name;
|
||||||
|
host->ioaddr = map_sysmem(dtplat->reg[1], dtplat->reg[3]);
|
||||||
|
max_frequency = dtplat->max_frequency;
|
||||||
|
ret = clk_get_by_index_platdata(dev, 0, dtplat->clocks, &clk);
|
||||||
|
#else
|
||||||
max_frequency = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
|
max_frequency = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
|
||||||
"max-frequency", 0);
|
"max-frequency", 0);
|
||||||
ret = clk_get_by_index(dev, 0, &clk);
|
ret = clk_get_by_index(dev, 0, &clk);
|
||||||
|
#endif
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
ret = clk_set_rate(&clk, max_frequency);
|
ret = clk_set_rate(&clk, max_frequency);
|
||||||
if (IS_ERR_VALUE(ret))
|
if (IS_ERR_VALUE(ret))
|
||||||
|
@ -66,10 +79,12 @@ static int arasan_sdhci_probe(struct udevice *dev)
|
||||||
|
|
||||||
static int arasan_sdhci_ofdata_to_platdata(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);
|
struct sdhci_host *host = dev_get_priv(dev);
|
||||||
|
|
||||||
host->name = dev->name;
|
host->name = dev->name;
|
||||||
host->ioaddr = dev_get_addr_ptr(dev);
|
host->ioaddr = dev_get_addr_ptr(dev);
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -87,7 +102,7 @@ static const struct udevice_id arasan_sdhci_ids[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
U_BOOT_DRIVER(arasan_sdhci_drv) = {
|
U_BOOT_DRIVER(arasan_sdhci_drv) = {
|
||||||
.name = "arasan_sdhci",
|
.name = "rockchip_rk3399_sdhci_5_1",
|
||||||
.id = UCLASS_MMC,
|
.id = UCLASS_MMC,
|
||||||
.of_match = arasan_sdhci_ids,
|
.of_match = arasan_sdhci_ids,
|
||||||
.ofdata_to_platdata = arasan_sdhci_ofdata_to_platdata,
|
.ofdata_to_platdata = arasan_sdhci_ofdata_to_platdata,
|
||||||
|
|
Loading…
Add table
Reference in a new issue