]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - drivers/mmc/s5p_sdhci.c
Merge branch 'zynq' of git://www.denx.de/git/u-boot-microblaze
[karo-tx-uboot.git] / drivers / mmc / s5p_sdhci.c
index ccae4ccae15638410eb73c9766ee07467164f0a4..a5d34876bbb6d7633f4a8f3dac3c9f21a6b82753 100644 (file)
@@ -14,9 +14,7 @@
 #include <asm/arch/mmc.h>
 #include <asm/arch/clk.h>
 #include <errno.h>
-#ifdef CONFIG_OF_CONTROL
 #include <asm/arch/pinmux.h>
-#endif
 
 static char *S5P_NAME = "SAMSUNG SDHCI";
 static void s5p_sdhci_set_control_reg(struct sdhci_host *host)
@@ -65,17 +63,9 @@ static void s5p_sdhci_set_control_reg(struct sdhci_host *host)
        sdhci_writel(host, ctrl, SDHCI_CONTROL2);
 }
 
-int s5p_sdhci_init(u32 regbase, int index, int bus_width)
+static int s5p_sdhci_core_init(struct sdhci_host *host)
 {
-       struct sdhci_host *host = NULL;
-       host = (struct sdhci_host *)malloc(sizeof(struct sdhci_host));
-       if (!host) {
-               printf("sdhci__host malloc fail!\n");
-               return 1;
-       }
-
        host->name = S5P_NAME;
-       host->ioaddr = (void *)regbase;
 
        host->quirks = SDHCI_QUIRK_NO_HISPD_BIT | SDHCI_QUIRK_BROKEN_VOLTAGE |
                SDHCI_QUIRK_BROKEN_R1B | SDHCI_QUIRK_32BIT_DMA_ADDR |
@@ -85,20 +75,34 @@ int s5p_sdhci_init(u32 regbase, int index, int bus_width)
 
        host->set_control_reg = &s5p_sdhci_set_control_reg;
        host->set_clock = set_mmc_clk;
-       host->index = index;
 
        host->host_caps = MMC_MODE_HC;
-       if (bus_width == 8)
+       if (host->bus_width == 8)
                host->host_caps |= MMC_MODE_8BIT;
 
        return add_sdhci(host, 52000000, 400000);
 }
 
+int s5p_sdhci_init(u32 regbase, int index, int bus_width)
+{
+       struct sdhci_host *host = malloc(sizeof(struct sdhci_host));
+       if (!host) {
+               printf("sdhci__host malloc fail!\n");
+               return 1;
+       }
+       host->ioaddr = (void *)regbase;
+       host->index = index;
+       host->bus_width = bus_width;
+
+       return s5p_sdhci_core_init(host);
+}
+
 #ifdef CONFIG_OF_CONTROL
 struct sdhci_host sdhci_host[SDHCI_MAX_HOSTS];
 
 static int do_sdhci_init(struct sdhci_host *host)
 {
+       char str[20];
        int dev_id, flag;
        int err = 0;
 
@@ -106,6 +110,8 @@ static int do_sdhci_init(struct sdhci_host *host)
        dev_id = host->index + PERIPH_ID_SDMMC0;
 
        if (fdt_gpio_isvalid(&host->pwr_gpio)) {
+               sprintf(str, "sdhci%d_power", host->index & 0xf);
+               gpio_request(host->pwr_gpio.gpio, str);
                gpio_direction_output(host->pwr_gpio.gpio, 1);
                err = exynos_pinmux_config(dev_id, flag);
                if (err) {
@@ -115,7 +121,9 @@ static int do_sdhci_init(struct sdhci_host *host)
        }
 
        if (fdt_gpio_isvalid(&host->cd_gpio)) {
-               gpio_direction_output(host->cd_gpio.gpio, 0xf);
+               sprintf(str, "sdhci%d_cd", host->index & 0xf);
+               gpio_request(host->cd_gpio.gpio, str);
+               gpio_direction_input(host->cd_gpio.gpio);
                if (gpio_get_value(host->cd_gpio.gpio))
                        return -ENODEV;
 
@@ -126,20 +134,7 @@ static int do_sdhci_init(struct sdhci_host *host)
                }
        }
 
-       host->name = S5P_NAME;
-
-       host->quirks = SDHCI_QUIRK_NO_HISPD_BIT | SDHCI_QUIRK_BROKEN_VOLTAGE |
-               SDHCI_QUIRK_BROKEN_R1B | SDHCI_QUIRK_32BIT_DMA_ADDR |
-               SDHCI_QUIRK_WAIT_SEND_CMD;
-       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;
-
-       host->host_caps = MMC_MODE_HC;
-
-       return add_sdhci(host, 52000000, 400000);
+       return s5p_sdhci_core_init(host);
 }
 
 static int sdhci_get_config(const void *blob, int node, struct sdhci_host *host)