|
|
|
@ -6,6 +6,7 @@ |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
#include <common.h> |
|
|
|
|
#include <dm.h> |
|
|
|
|
#include <malloc.h> |
|
|
|
|
#include <sdhci.h> |
|
|
|
|
#include <fdtdec.h> |
|
|
|
@ -16,6 +17,15 @@ |
|
|
|
|
#include <errno.h> |
|
|
|
|
#include <asm/arch/pinmux.h> |
|
|
|
|
|
|
|
|
|
#ifdef CONFIG_DM_MMC |
|
|
|
|
struct s5p_sdhci_plat { |
|
|
|
|
struct mmc_config cfg; |
|
|
|
|
struct mmc mmc; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
DECLARE_GLOBAL_DATA_PTR; |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
static char *S5P_NAME = "SAMSUNG SDHCI"; |
|
|
|
|
static void s5p_sdhci_set_control_reg(struct sdhci_host *host) |
|
|
|
|
{ |
|
|
|
@ -71,7 +81,6 @@ static int s5p_sdhci_core_init(struct sdhci_host *host) |
|
|
|
|
SDHCI_QUIRK_32BIT_DMA_ADDR | |
|
|
|
|
SDHCI_QUIRK_WAIT_SEND_CMD | SDHCI_QUIRK_USE_WIDE8; |
|
|
|
|
host->voltages = MMC_VDD_32_33 | MMC_VDD_33_34 | MMC_VDD_165_195; |
|
|
|
|
host->version = sdhci_readw(host, SDHCI_HOST_VERSION); |
|
|
|
|
|
|
|
|
|
host->set_control_reg = &s5p_sdhci_set_control_reg; |
|
|
|
|
host->set_clock = set_mmc_clk; |
|
|
|
@ -79,7 +88,11 @@ static int s5p_sdhci_core_init(struct sdhci_host *host) |
|
|
|
|
if (host->bus_width == 8) |
|
|
|
|
host->host_caps |= MMC_MODE_8BIT; |
|
|
|
|
|
|
|
|
|
#ifndef CONFIG_BLK |
|
|
|
|
return add_sdhci(host, 52000000, 400000); |
|
|
|
|
#else |
|
|
|
|
return 0; |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int s5p_sdhci_init(u32 regbase, int index, int bus_width) |
|
|
|
@ -87,7 +100,7 @@ int s5p_sdhci_init(u32 regbase, int index, int bus_width) |
|
|
|
|
struct sdhci_host *host = calloc(1, sizeof(struct sdhci_host)); |
|
|
|
|
if (!host) { |
|
|
|
|
printf("sdhci__host allocation fail!\n"); |
|
|
|
|
return 1; |
|
|
|
|
return -ENOMEM; |
|
|
|
|
} |
|
|
|
|
host->ioaddr = (void *)regbase; |
|
|
|
|
host->index = index; |
|
|
|
@ -141,7 +154,7 @@ static int sdhci_get_config(const void *blob, int node, struct sdhci_host *host) |
|
|
|
|
dev_id = pinmux_decode_periph_id(blob, node); |
|
|
|
|
if (dev_id < PERIPH_ID_SDMMC0 && dev_id > PERIPH_ID_SDMMC3) { |
|
|
|
|
debug("MMC: Can't get device id\n"); |
|
|
|
|
return -1; |
|
|
|
|
return -EINVAL; |
|
|
|
|
} |
|
|
|
|
host->index = dev_id - PERIPH_ID_SDMMC0; |
|
|
|
|
|
|
|
|
@ -149,7 +162,7 @@ static int sdhci_get_config(const void *blob, int node, struct sdhci_host *host) |
|
|
|
|
bus_width = fdtdec_get_int(blob, node, "samsung,bus-width", 0); |
|
|
|
|
if (bus_width <= 0) { |
|
|
|
|
debug("MMC: Can't get bus-width\n"); |
|
|
|
|
return -1; |
|
|
|
|
return -EINVAL; |
|
|
|
|
} |
|
|
|
|
host->bus_width = bus_width; |
|
|
|
|
|
|
|
|
@ -157,7 +170,7 @@ static int sdhci_get_config(const void *blob, int node, struct sdhci_host *host) |
|
|
|
|
base = fdtdec_get_addr(blob, node, "reg"); |
|
|
|
|
if (!base) { |
|
|
|
|
debug("MMC: Can't get base address\n"); |
|
|
|
|
return -1; |
|
|
|
|
return -EINVAL; |
|
|
|
|
} |
|
|
|
|
host->ioaddr = (void *)base; |
|
|
|
|
|
|
|
|
@ -215,3 +228,60 @@ int exynos_mmc_init(const void *blob) |
|
|
|
|
return process_nodes(blob, node_list, count); |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
#ifdef CONFIG_DM_MMC |
|
|
|
|
static int s5p_sdhci_probe(struct udevice *dev) |
|
|
|
|
{ |
|
|
|
|
struct s5p_sdhci_plat *plat = dev_get_platdata(dev); |
|
|
|
|
struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev); |
|
|
|
|
struct sdhci_host *host = dev_get_priv(dev); |
|
|
|
|
int ret; |
|
|
|
|
|
|
|
|
|
ret = sdhci_get_config(gd->fdt_blob, dev->of_offset, host); |
|
|
|
|
if (ret) |
|
|
|
|
return ret; |
|
|
|
|
|
|
|
|
|
ret = do_sdhci_init(host); |
|
|
|
|
if (ret) |
|
|
|
|
return ret; |
|
|
|
|
|
|
|
|
|
ret = sdhci_setup_cfg(&plat->cfg, host, 52000000, 400000); |
|
|
|
|
if (ret) |
|
|
|
|
return ret; |
|
|
|
|
|
|
|
|
|
host->mmc = &plat->mmc; |
|
|
|
|
host->mmc->priv = host; |
|
|
|
|
host->mmc->dev = dev; |
|
|
|
|
upriv->mmc = host->mmc; |
|
|
|
|
|
|
|
|
|
return sdhci_probe(dev); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static int s5p_sdhci_bind(struct udevice *dev) |
|
|
|
|
{ |
|
|
|
|
struct s5p_sdhci_plat *plat = dev_get_platdata(dev); |
|
|
|
|
int ret; |
|
|
|
|
|
|
|
|
|
ret = sdhci_bind(dev, &plat->mmc, &plat->cfg); |
|
|
|
|
if (ret) |
|
|
|
|
return ret; |
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static const struct udevice_id s5p_sdhci_ids[] = { |
|
|
|
|
{ .compatible = "samsung,exynos4412-sdhci"}, |
|
|
|
|
{ } |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
U_BOOT_DRIVER(s5p_sdhci_drv) = { |
|
|
|
|
.name = "s5p_sdhci", |
|
|
|
|
.id = UCLASS_MMC, |
|
|
|
|
.of_match = s5p_sdhci_ids, |
|
|
|
|
.bind = s5p_sdhci_bind, |
|
|
|
|
.ops = &sdhci_ops, |
|
|
|
|
.probe = s5p_sdhci_probe, |
|
|
|
|
.priv_auto_alloc_size = sizeof(struct sdhci_host), |
|
|
|
|
.platdata_auto_alloc_size = sizeof(struct s5p_sdhci_plat), |
|
|
|
|
}; |
|
|
|
|
#endif /* CONFIG_DM_MMC */ |
|
|
|
|