dm: mmc: Remove use of fdtdec GPIO support
authorSimon Glass <sjg@chromium.org>
Tue, 6 Jan 2015 03:05:38 +0000 (20:05 -0700)
committerSimon Glass <sjg@chromium.org>
Fri, 30 Jan 2015 00:09:52 +0000 (17:09 -0700)
These functions are going away, so use the new uclass support instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
arch/arm/include/asm/arch-pantheon/gpio.h [new file with mode: 0644]
arch/arm/include/asm/arch-tegra/tegra_mmc.h
drivers/mmc/s5p_sdhci.c
drivers/mmc/tegra_mmc.c
include/sdhci.h

diff --git a/arch/arm/include/asm/arch-pantheon/gpio.h b/arch/arm/include/asm/arch-pantheon/gpio.h
new file mode 100644 (file)
index 0000000..e69de29
index 84e7b5553de16cb5ea8f5965079ec169d2459022..a20bdaa6187257a8fdd912d8e509e68ba27aac93 100644 (file)
@@ -10,6 +10,7 @@
 #define __TEGRA_MMC_H_
 
 #include <fdtdec.h>
+#include <asm/gpio.h>
 
 /* for mmc_config definition */
 #include <mmc.h>
@@ -134,9 +135,9 @@ struct mmc_host {
        int enabled;            /* 1 to enable, 0 to disable */
        int width;              /* Bus Width, 1, 4 or 8 */
        enum periph_id mmc_id;  /* Peripheral ID: PERIPH_ID_... */
-       struct fdt_gpio_state cd_gpio;          /* Change Detect GPIO */
-       struct fdt_gpio_state pwr_gpio;         /* Power GPIO */
-       struct fdt_gpio_state wp_gpio;          /* Write Protect GPIO */
+       struct gpio_desc cd_gpio;       /* Change Detect GPIO */
+       struct gpio_desc pwr_gpio;      /* Power GPIO */
+       struct gpio_desc wp_gpio;       /* Write Protect GPIO */
        unsigned int version;   /* SDHCI spec. version */
        unsigned int clock;     /* Current clock (MHz) */
        struct mmc_config cfg;  /* mmc configuration */
index a5d34876bbb6d7633f4a8f3dac3c9f21a6b82753..3899372e0e44a82ab9df970fb95e0292fbc19d29 100644 (file)
@@ -102,17 +102,14 @@ 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;
 
        flag = host->bus_width == 8 ? PINMUX_FLAG_8BIT_MODE : PINMUX_FLAG_NONE;
        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);
+       if (dm_gpio_is_valid(&host->pwr_gpio)) {
+               dm_gpio_set_value(&host->pwr_gpio, 1);
                err = exynos_pinmux_config(dev_id, flag);
                if (err) {
                        debug("MMC not configured\n");
@@ -120,11 +117,8 @@ static int do_sdhci_init(struct sdhci_host *host)
                }
        }
 
-       if (fdt_gpio_isvalid(&host->cd_gpio)) {
-               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))
+       if (dm_gpio_is_valid(&host->cd_gpio)) {
+               if (dm_gpio_get_value(&host->cd_gpio))
                        return -ENODEV;
 
                err = exynos_pinmux_config(dev_id, flag);
@@ -166,8 +160,10 @@ static int sdhci_get_config(const void *blob, int node, struct sdhci_host *host)
        }
        host->ioaddr = (void *)base;
 
-       fdtdec_decode_gpio(blob, node, "pwr-gpios", &host->pwr_gpio);
-       fdtdec_decode_gpio(blob, node, "cd-gpios", &host->cd_gpio);
+       gpio_request_by_name_nodev(blob, node, "pwr-gpios", 0, &host->pwr_gpio,
+                                  GPIOD_IS_OUT);
+       gpio_request_by_name_nodev(blob, node, "cd-gpios", 0, &host->cd_gpio,
+                                  GPIOD_IS_IN);
 
        return 0;
 }
index 2bd36b0ee704a86308bfa0d3c7faa68cc506249a..2cd8cf10aec557cc3a3579f3e292d9ee3f686e90 100644 (file)
@@ -515,8 +515,8 @@ static int tegra_mmc_getcd(struct mmc *mmc)
 
        debug("tegra_mmc_getcd called\n");
 
-       if (fdt_gpio_isvalid(&host->cd_gpio))
-               return fdtdec_get_gpio(&host->cd_gpio);
+       if (dm_gpio_is_valid(&host->cd_gpio))
+               return dm_gpio_get_value(&host->cd_gpio);
 
        return 1;
 }
@@ -531,7 +531,6 @@ static const struct mmc_ops tegra_mmc_ops = {
 static int do_mmc_init(int dev_index)
 {
        struct mmc_host *host;
-       char gpusage[12]; /* "SD/MMCn PWR" or "SD/MMCn CD" */
        struct mmc *mmc;
 
        /* DT should have been read & host config filled in */
@@ -539,27 +538,15 @@ static int do_mmc_init(int dev_index)
        if (!host->enabled)
                return -1;
 
-       debug(" do_mmc_init: index %d, bus width %d "
-               "pwr_gpio %d cd_gpio %d\n",
-               dev_index, host->width,
-               host->pwr_gpio.gpio, host->cd_gpio.gpio);
+       debug(" do_mmc_init: index %d, bus width %d pwr_gpio %d cd_gpio %d\n",
+             dev_index, host->width, gpio_get_number(&host->pwr_gpio),
+             gpio_get_number(&host->cd_gpio));
 
        host->clock = 0;
        clock_start_periph_pll(host->mmc_id, CLOCK_ID_PERIPH, 20000000);
 
-       if (fdt_gpio_isvalid(&host->pwr_gpio)) {
-               sprintf(gpusage, "SD/MMC%d PWR", dev_index);
-               gpio_request(host->pwr_gpio.gpio, gpusage);
-               gpio_direction_output(host->pwr_gpio.gpio, 1);
-               debug(" Power GPIO name = %s\n", host->pwr_gpio.name);
-       }
-
-       if (fdt_gpio_isvalid(&host->cd_gpio)) {
-               sprintf(gpusage, "SD/MMC%d CD", dev_index);
-               gpio_request(host->cd_gpio.gpio, gpusage);
-               gpio_direction_input(host->cd_gpio.gpio);
-               debug(" CD GPIO name = %s\n", host->cd_gpio.name);
-       }
+       if (dm_gpio_is_valid(&host->pwr_gpio))
+               dm_gpio_set_value(&host->pwr_gpio, 1);
 
        memset(&host->cfg, 0, sizeof(host->cfg));
 
@@ -626,9 +613,12 @@ static int mmc_get_config(const void *blob, int node, struct mmc_host *host)
                debug("%s: no sdmmc width found\n", __func__);
 
        /* These GPIOs are optional */
-       fdtdec_decode_gpio(blob, node, "cd-gpios", &host->cd_gpio);
-       fdtdec_decode_gpio(blob, node, "wp-gpios", &host->wp_gpio);
-       fdtdec_decode_gpio(blob, node, "power-gpios", &host->pwr_gpio);
+       gpio_request_by_name_nodev(blob, node, "cd-gpios", 0, &host->cd_gpio,
+                                  GPIOD_IS_IN);
+       gpio_request_by_name_nodev(blob, node, "wp-gpios", 0, &host->wp_gpio,
+                                  GPIOD_IS_IN);
+       gpio_request_by_name_nodev(blob, node, "power-gpios", 0,
+                                  &host->pwr_gpio, GPIOD_IS_OUT);
 
        debug("%s: found controller at %p, width = %d, periph_id = %d\n",
                __func__, host->reg, host->width, host->mmc_id);
index aa4a0e9654dd6262839aec65df1d8fab08e16076..23893b57408056ea3cd077af2923a300e53c36fb 100644 (file)
@@ -12,7 +12,7 @@
 
 #include <asm/io.h>
 #include <mmc.h>
-#include <fdtdec.h>
+#include <asm/gpio.h>
 
 /*
  * Controller registers
@@ -246,8 +246,8 @@ struct sdhci_host {
        int index;
 
        int bus_width;
-       struct fdt_gpio_state pwr_gpio; /* Power GPIO */
-       struct fdt_gpio_state cd_gpio;          /* Card Detect GPIO */
+       struct gpio_desc pwr_gpio;      /* Power GPIO */
+       struct gpio_desc cd_gpio;               /* Card Detect GPIO */
 
        void (*set_control_reg)(struct sdhci_host *host);
        void (*set_clock)(int dev_index, unsigned int div);