diff mbox series

[v2,4/6] mmc: fsl_esdhc_imx: add CD support when OF_PLATDATA is enabled

Message ID 20200722131438.12215-5-walter.lozano@collabora.com
State Superseded
Delegated to: Stefano Babic
Headers show
Series mx6cuboxi: enable OF_PLATDATA with MMC support | expand

Commit Message

Walter Lozano July 22, 2020, 1:14 p.m. UTC
After enabling OF_PLATDATA support to both MMC and GPIO drivers add the
support for card detection.

Signed-off-by: Walter Lozano <walter.lozano@collabora.com>
---

(no changes since v1)

 drivers/mmc/fsl_esdhc_imx.c | 27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

Comments

Simon Glass July 26, 2020, 2:54 p.m. UTC | #1
On Wed, 22 Jul 2020 at 07:15, Walter Lozano <walter.lozano@collabora.com> wrote:
>
> After enabling OF_PLATDATA support to both MMC and GPIO drivers add the
> support for card detection.
>
> Signed-off-by: Walter Lozano <walter.lozano@collabora.com>
> ---
>
> (no changes since v1)
>
>  drivers/mmc/fsl_esdhc_imx.c | 27 ++++++++++++++++++++++++++-
>  1 file changed, 26 insertions(+), 1 deletion(-)

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

See below

>
> diff --git a/drivers/mmc/fsl_esdhc_imx.c b/drivers/mmc/fsl_esdhc_imx.c
> index f2509b5cc9..4448565b5a 100644
> --- a/drivers/mmc/fsl_esdhc_imx.c
> +++ b/drivers/mmc/fsl_esdhc_imx.c
> @@ -1498,7 +1498,32 @@ static int fsl_esdhc_probe(struct udevice *dev)
>                 priv->bus_width = 4;
>         else
>                 priv->bus_width = 1;
> -       priv->non_removable = 1;
> +
> +       if (dtplat->non_removable)
> +               priv->non_removable = 1;
> +       else
> +               priv->non_removable = 0;
> +
> +#if CONFIG_IS_ENABLED(DM_GPIO)

Can this use if() ?


> +       if (!priv->non_removable) {
> +               struct udevice *gpiodev;
> +               struct driver_info *info;
> +
> +               info = (struct driver_info *)dtplat->cd_gpios->node;
> +
> +               ret = device_get_by_driver_info(info, &gpiodev);
> +
> +               if (ret)
> +                       return ret;
> +
> +               ret = gpio_dev_request_index(gpiodev, gpiodev->name, "cd-gpios",
> +                                            dtplat->cd_gpios->arg[0], GPIOD_IS_IN,
> +                                            dtplat->cd_gpios->arg[1], &priv->cd_gpio);
> +
> +               if (ret)
> +                       return ret;
> +       }
> +#endif
>  #endif
>
>         if (data)
> --
> 2.20.1
>
diff mbox series

Patch

diff --git a/drivers/mmc/fsl_esdhc_imx.c b/drivers/mmc/fsl_esdhc_imx.c
index f2509b5cc9..4448565b5a 100644
--- a/drivers/mmc/fsl_esdhc_imx.c
+++ b/drivers/mmc/fsl_esdhc_imx.c
@@ -1498,7 +1498,32 @@  static int fsl_esdhc_probe(struct udevice *dev)
 		priv->bus_width = 4;
 	else
 		priv->bus_width = 1;
-	priv->non_removable = 1;
+
+	if (dtplat->non_removable)
+		priv->non_removable = 1;
+	else
+		priv->non_removable = 0;
+
+#if CONFIG_IS_ENABLED(DM_GPIO)
+	if (!priv->non_removable) {
+		struct udevice *gpiodev;
+		struct driver_info *info;
+
+		info = (struct driver_info *)dtplat->cd_gpios->node;
+
+		ret = device_get_by_driver_info(info, &gpiodev);
+
+		if (ret)
+			return ret;
+
+		ret = gpio_dev_request_index(gpiodev, gpiodev->name, "cd-gpios",
+					     dtplat->cd_gpios->arg[0], GPIOD_IS_IN,
+					     dtplat->cd_gpios->arg[1], &priv->cd_gpio);
+
+		if (ret)
+			return ret;
+	}
+#endif
 #endif
 
 	if (data)