Commit 0347960b8732b8d8506c9123c217b503666a4ad8

Authored by Simon Glass
1 parent 9762a415c8

dm: mmc: Remove use of fdtdec GPIO support

These functions are going away, so use the new uclass support instead.

Signed-off-by: Simon Glass <sjg@chromium.org>

Showing 4 changed files with 28 additions and 41 deletions Side-by-side Diff

arch/arm/include/asm/arch-tegra/tegra_mmc.h
... ... @@ -10,6 +10,7 @@
10 10 #define __TEGRA_MMC_H_
11 11  
12 12 #include <fdtdec.h>
  13 +#include <asm/gpio.h>
13 14  
14 15 /* for mmc_config definition */
15 16 #include <mmc.h>
... ... @@ -134,9 +135,9 @@
134 135 int enabled; /* 1 to enable, 0 to disable */
135 136 int width; /* Bus Width, 1, 4 or 8 */
136 137 enum periph_id mmc_id; /* Peripheral ID: PERIPH_ID_... */
137   - struct fdt_gpio_state cd_gpio; /* Change Detect GPIO */
138   - struct fdt_gpio_state pwr_gpio; /* Power GPIO */
139   - struct fdt_gpio_state wp_gpio; /* Write Protect GPIO */
  138 + struct gpio_desc cd_gpio; /* Change Detect GPIO */
  139 + struct gpio_desc pwr_gpio; /* Power GPIO */
  140 + struct gpio_desc wp_gpio; /* Write Protect GPIO */
140 141 unsigned int version; /* SDHCI spec. version */
141 142 unsigned int clock; /* Current clock (MHz) */
142 143 struct mmc_config cfg; /* mmc configuration */
drivers/mmc/s5p_sdhci.c
... ... @@ -102,17 +102,14 @@
102 102  
103 103 static int do_sdhci_init(struct sdhci_host *host)
104 104 {
105   - char str[20];
106 105 int dev_id, flag;
107 106 int err = 0;
108 107  
109 108 flag = host->bus_width == 8 ? PINMUX_FLAG_8BIT_MODE : PINMUX_FLAG_NONE;
110 109 dev_id = host->index + PERIPH_ID_SDMMC0;
111 110  
112   - if (fdt_gpio_isvalid(&host->pwr_gpio)) {
113   - sprintf(str, "sdhci%d_power", host->index & 0xf);
114   - gpio_request(host->pwr_gpio.gpio, str);
115   - gpio_direction_output(host->pwr_gpio.gpio, 1);
  111 + if (dm_gpio_is_valid(&host->pwr_gpio)) {
  112 + dm_gpio_set_value(&host->pwr_gpio, 1);
116 113 err = exynos_pinmux_config(dev_id, flag);
117 114 if (err) {
118 115 debug("MMC not configured\n");
... ... @@ -120,11 +117,8 @@
120 117 }
121 118 }
122 119  
123   - if (fdt_gpio_isvalid(&host->cd_gpio)) {
124   - sprintf(str, "sdhci%d_cd", host->index & 0xf);
125   - gpio_request(host->cd_gpio.gpio, str);
126   - gpio_direction_input(host->cd_gpio.gpio);
127   - if (gpio_get_value(host->cd_gpio.gpio))
  120 + if (dm_gpio_is_valid(&host->cd_gpio)) {
  121 + if (dm_gpio_get_value(&host->cd_gpio))
128 122 return -ENODEV;
129 123  
130 124 err = exynos_pinmux_config(dev_id, flag);
... ... @@ -166,8 +160,10 @@
166 160 }
167 161 host->ioaddr = (void *)base;
168 162  
169   - fdtdec_decode_gpio(blob, node, "pwr-gpios", &host->pwr_gpio);
170   - fdtdec_decode_gpio(blob, node, "cd-gpios", &host->cd_gpio);
  163 + gpio_request_by_name_nodev(blob, node, "pwr-gpios", 0, &host->pwr_gpio,
  164 + GPIOD_IS_OUT);
  165 + gpio_request_by_name_nodev(blob, node, "cd-gpios", 0, &host->cd_gpio,
  166 + GPIOD_IS_IN);
171 167  
172 168 return 0;
173 169 }
drivers/mmc/tegra_mmc.c
... ... @@ -515,8 +515,8 @@
515 515  
516 516 debug("tegra_mmc_getcd called\n");
517 517  
518   - if (fdt_gpio_isvalid(&host->cd_gpio))
519   - return fdtdec_get_gpio(&host->cd_gpio);
  518 + if (dm_gpio_is_valid(&host->cd_gpio))
  519 + return dm_gpio_get_value(&host->cd_gpio);
520 520  
521 521 return 1;
522 522 }
... ... @@ -531,7 +531,6 @@
531 531 static int do_mmc_init(int dev_index)
532 532 {
533 533 struct mmc_host *host;
534   - char gpusage[12]; /* "SD/MMCn PWR" or "SD/MMCn CD" */
535 534 struct mmc *mmc;
536 535  
537 536 /* DT should have been read & host config filled in */
538 537  
539 538  
... ... @@ -539,28 +538,16 @@
539 538 if (!host->enabled)
540 539 return -1;
541 540  
542   - debug(" do_mmc_init: index %d, bus width %d "
543   - "pwr_gpio %d cd_gpio %d\n",
544   - dev_index, host->width,
545   - host->pwr_gpio.gpio, host->cd_gpio.gpio);
  541 + debug(" do_mmc_init: index %d, bus width %d pwr_gpio %d cd_gpio %d\n",
  542 + dev_index, host->width, gpio_get_number(&host->pwr_gpio),
  543 + gpio_get_number(&host->cd_gpio));
546 544  
547 545 host->clock = 0;
548 546 clock_start_periph_pll(host->mmc_id, CLOCK_ID_PERIPH, 20000000);
549 547  
550   - if (fdt_gpio_isvalid(&host->pwr_gpio)) {
551   - sprintf(gpusage, "SD/MMC%d PWR", dev_index);
552   - gpio_request(host->pwr_gpio.gpio, gpusage);
553   - gpio_direction_output(host->pwr_gpio.gpio, 1);
554   - debug(" Power GPIO name = %s\n", host->pwr_gpio.name);
555   - }
  548 + if (dm_gpio_is_valid(&host->pwr_gpio))
  549 + dm_gpio_set_value(&host->pwr_gpio, 1);
556 550  
557   - if (fdt_gpio_isvalid(&host->cd_gpio)) {
558   - sprintf(gpusage, "SD/MMC%d CD", dev_index);
559   - gpio_request(host->cd_gpio.gpio, gpusage);
560   - gpio_direction_input(host->cd_gpio.gpio);
561   - debug(" CD GPIO name = %s\n", host->cd_gpio.name);
562   - }
563   -
564 551 memset(&host->cfg, 0, sizeof(host->cfg));
565 552  
566 553 host->cfg.name = "Tegra SD/MMC";
... ... @@ -626,9 +613,12 @@
626 613 debug("%s: no sdmmc width found\n", __func__);
627 614  
628 615 /* These GPIOs are optional */
629   - fdtdec_decode_gpio(blob, node, "cd-gpios", &host->cd_gpio);
630   - fdtdec_decode_gpio(blob, node, "wp-gpios", &host->wp_gpio);
631   - fdtdec_decode_gpio(blob, node, "power-gpios", &host->pwr_gpio);
  616 + gpio_request_by_name_nodev(blob, node, "cd-gpios", 0, &host->cd_gpio,
  617 + GPIOD_IS_IN);
  618 + gpio_request_by_name_nodev(blob, node, "wp-gpios", 0, &host->wp_gpio,
  619 + GPIOD_IS_IN);
  620 + gpio_request_by_name_nodev(blob, node, "power-gpios", 0,
  621 + &host->pwr_gpio, GPIOD_IS_OUT);
632 622  
633 623 debug("%s: found controller at %p, width = %d, periph_id = %d\n",
634 624 __func__, host->reg, host->width, host->mmc_id);
... ... @@ -12,7 +12,7 @@
12 12  
13 13 #include <asm/io.h>
14 14 #include <mmc.h>
15   -#include <fdtdec.h>
  15 +#include <asm/gpio.h>
16 16  
17 17 /*
18 18 * Controller registers
... ... @@ -246,8 +246,8 @@
246 246 int index;
247 247  
248 248 int bus_width;
249   - struct fdt_gpio_state pwr_gpio; /* Power GPIO */
250   - struct fdt_gpio_state cd_gpio; /* Card Detect GPIO */
  249 + struct gpio_desc pwr_gpio; /* Power GPIO */
  250 + struct gpio_desc cd_gpio; /* Card Detect GPIO */
251 251  
252 252 void (*set_control_reg)(struct sdhci_host *host);
253 253 void (*set_clock)(int dev_index, unsigned int div);