mmc: fsl_esdhc: make GPIO support optional
authorYangbo Lu <yangbo.lu@nxp.com>
Wed, 7 Dec 2016 03:54:30 +0000 (11:54 +0800)
committerYork Sun <york.sun@nxp.com>
Wed, 18 Jan 2017 17:28:14 +0000 (09:28 -0800)
There would be compiling error as below when enable driver model for esdhc.
undefined reference to `dm_gpio_get_value'
undefined reference to `gpio_request_by_name_nodev'
This patch is to make GPIO support optional with CONFIG_DM_GPIO. Because
all boards of QorIQ platform don't need it and they just check register for
CD/WP status, only some boards of i.MX platform require this.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
Acked-by: Jaehoon Chung <jh80.chung@samsung.com>
Reviewed-by: York Sun <york.sun@nxp.com>
drivers/mmc/fsl_esdhc.c

index 9796d39c65bd00a2cd21b4495815d3c45f20a5e7..da3a1514a4a163c49f28c150e5c9080a97a19a29 100644 (file)
@@ -104,8 +104,10 @@ struct fsl_esdhc_priv {
        struct udevice *dev;
        int non_removable;
        int wp_enable;
+#ifdef CONFIG_DM_GPIO
        struct gpio_desc cd_gpio;
        struct gpio_desc wp_gpio;
+#endif
 };
 
 /* Return the XFERTYP flags for a given command and data packet */
@@ -687,9 +689,10 @@ static int esdhc_getcd(struct mmc *mmc)
 #ifdef CONFIG_DM_MMC
        if (priv->non_removable)
                return 1;
-
+#ifdef CONFIG_DM_GPIO
        if (dm_gpio_is_valid(&priv->cd_gpio))
                return dm_gpio_get_value(&priv->cd_gpio);
+#endif
 #endif
 
        while (!(esdhc_read32(&regs->prsstat) & PRSSTAT_CINS) && --timeout)
@@ -967,17 +970,20 @@ static int fsl_esdhc_probe(struct udevice *dev)
                priv->non_removable = 1;
         } else {
                priv->non_removable = 0;
+#ifdef CONFIG_DM_GPIO
                gpio_request_by_name_nodev(fdt, node, "cd-gpios", 0,
                                           &priv->cd_gpio, GPIOD_IS_IN);
+#endif
        }
 
        priv->wp_enable = 1;
 
+#ifdef CONFIG_DM_GPIO
        ret = gpio_request_by_name_nodev(fdt, node, "wp-gpios", 0,
                                         &priv->wp_gpio, GPIOD_IS_IN);
        if (ret)
                priv->wp_enable = 0;
-
+#endif
        /*
         * TODO:
         * Because lack of clk driver, if SDHC clk is not enabled,