dm: core: Update lists_bind_fdt() to use ofnode
[oweals/u-boot.git] / drivers / mmc / s5p_sdhci.c
index d7cfa3e2e9e9769297a15132186aa66e292e6d32..640ea0261eb50e24c586de49d0928dffefec90fd 100644 (file)
@@ -73,6 +73,17 @@ static void s5p_sdhci_set_control_reg(struct sdhci_host *host)
        sdhci_writel(host, ctrl, SDHCI_CONTROL2);
 }
 
+static void s5p_set_clock(struct sdhci_host *host, u32 div)
+{
+       /* ToDo : Use the Clock Framework */
+       set_mmc_clk(host->index, div);
+}
+
+static const struct sdhci_ops s5p_sdhci_ops = {
+       .set_clock      = &s5p_set_clock,
+       .set_control_reg = &s5p_sdhci_set_control_reg,
+};
+
 static int s5p_sdhci_core_init(struct sdhci_host *host)
 {
        host->name = S5P_NAME;
@@ -80,16 +91,15 @@ static int s5p_sdhci_core_init(struct sdhci_host *host)
        host->quirks = SDHCI_QUIRK_NO_HISPD_BIT | SDHCI_QUIRK_BROKEN_VOLTAGE |
                SDHCI_QUIRK_32BIT_DMA_ADDR |
                SDHCI_QUIRK_WAIT_SEND_CMD | SDHCI_QUIRK_USE_WIDE8;
+       host->max_clk = 52000000;
        host->voltages = MMC_VDD_32_33 | MMC_VDD_33_34 | MMC_VDD_165_195;
-
-       host->set_control_reg = &s5p_sdhci_set_control_reg;
-       host->set_clock = set_mmc_clk;
+       host->ops = &s5p_sdhci_ops;
 
        if (host->bus_width == 8)
                host->host_caps |= MMC_MODE_8BIT;
 
 #ifndef CONFIG_BLK
-       return add_sdhci(host, 52000000, 400000);
+       return add_sdhci(host, 0, 400000);
 #else
        return 0;
 #endif
@@ -100,7 +110,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;
@@ -152,9 +162,9 @@ static int sdhci_get_config(const void *blob, int node, struct sdhci_host *host)
 
        /* Get device id */
        dev_id = pinmux_decode_periph_id(blob, node);
-       if (dev_id < PERIPH_ID_SDMMC0 && dev_id > PERIPH_ID_SDMMC3) {
+       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;
 
@@ -162,7 +172,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;
 
@@ -170,7 +180,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;
 
@@ -237,7 +247,7 @@ static int s5p_sdhci_probe(struct udevice *dev)
        struct sdhci_host *host = dev_get_priv(dev);
        int ret;
 
-       ret = sdhci_get_config(gd->fdt_blob, dev->of_offset, host);
+       ret = sdhci_get_config(gd->fdt_blob, dev_of_offset(dev), host);
        if (ret)
                return ret;
 
@@ -245,7 +255,7 @@ static int s5p_sdhci_probe(struct udevice *dev)
        if (ret)
                return ret;
 
-       ret = sdhci_setup_cfg(&plat->cfg, host, 52000000, 400000);
+       ret = sdhci_setup_cfg(&plat->cfg, host, 0, 400000);
        if (ret)
                return ret;