diff mbox series

[06/10] mmc: sdhci: imx: Use the slot GPIO descriptor

Message ID 20181112141239.19646-7-linus.walleij@linaro.org (mailing list archive)
State New, archived
Headers show
Series Convert MMC slot GPIO to descriptors | expand

Commit Message

Linus Walleij Nov. 12, 2018, 2:12 p.m. UTC
Simplify things by making the i.MX SDHCI driver just use
slot GPIO with descriptors instead of passing around the global
GPIO numbers that we want to get rid of.

As it turns out, just one single board is using the platform
data to pass in GPIOs numbers for CD and WP, so we augment this
to use a machine descriptor table instead.

Cc: Shawn Guo <shawnguo@kernel.org>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Pengutronix Kernel Team <kernel@pengutronix.de>
Cc: Fabio Estevam <fabio.estevam@nxp.com>
Cc: NXP Linux Team <linux-imx@nxp.com>
Cc: Bartosz Golaszewski <brgl@bgdev.pl>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
This very much needs to be tested on the PCM043.

If it works fine, it also opens the way for switching more i.MX
boardfiles to using machine GPIO descriptor tables.
---
 arch/arm/mach-imx/mach-pcm043.c             | 17 +++++++++++++----
 drivers/mmc/host/sdhci-esdhc-imx.c          | 14 ++++++++------
 include/linux/platform_data/mmc-esdhc-imx.h |  4 ----
 3 files changed, 21 insertions(+), 14 deletions(-)

Comments

Dong Aisheng Nov. 12, 2018, 4:09 p.m. UTC | #1
> -----Original Message-----
> From: Linus Walleij [mailto:linus.walleij@linaro.org]
> Sent: Monday, November 12, 2018 10:13 PM
> To: linux-mmc@vger.kernel.org; Ulf Hansson <ulf.hansson@linaro.org>
> Cc: Linus Walleij <linus.walleij@linaro.org>; Shawn Guo
> <shawnguo@kernel.org>; Sascha Hauer <s.hauer@pengutronix.de>;
> Pengutronix Kernel Team <kernel@pengutronix.de>; Fabio Estevam
> <fabio.estevam@nxp.com>; dl-linux-imx <linux-imx@nxp.com>; Bartosz
> Golaszewski <brgl@bgdev.pl>
> Subject: [PATCH 06/10] mmc: sdhci: imx: Use the slot GPIO descriptor
> 
> Simplify things by making the i.MX SDHCI driver just use slot GPIO with
> descriptors instead of passing around the global GPIO numbers that we want
> to get rid of.
> 
> As it turns out, just one single board is using the platform data to pass in GPIOs
> numbers for CD and WP, so we augment this to use a machine descriptor table
> instead.
> 
> Cc: Shawn Guo <shawnguo@kernel.org>
> Cc: Sascha Hauer <s.hauer@pengutronix.de>
> Cc: Pengutronix Kernel Team <kernel@pengutronix.de>
> Cc: Fabio Estevam <fabio.estevam@nxp.com>
> Cc: NXP Linux Team <linux-imx@nxp.com>
> Cc: Bartosz Golaszewski <brgl@bgdev.pl>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

Reviewed-by: Dong Aisheng <aisheng.dong@nxp.com>

> ---
> This very much needs to be tested on the PCM043.
> 
> If it works fine, it also opens the way for switching more i.MX boardfiles to
> using machine GPIO descriptor tables.

It's almost a 10 years old board and not sure if it's still maintained by Pengutronix.

Sascha,
Any comments?

Regards
Dong Aisheng

> ---
>  arch/arm/mach-imx/mach-pcm043.c             | 17 +++++++++++++----
>  drivers/mmc/host/sdhci-esdhc-imx.c          | 14 ++++++++------
>  include/linux/platform_data/mmc-esdhc-imx.h |  4 ----
>  3 files changed, 21 insertions(+), 14 deletions(-)
> 
> diff --git a/arch/arm/mach-imx/mach-pcm043.c
> b/arch/arm/mach-imx/mach-pcm043.c index e595e5368676..46ba3348e8f0
> 100644
> --- a/arch/arm/mach-imx/mach-pcm043.c
> +++ b/arch/arm/mach-imx/mach-pcm043.c
> @@ -20,6 +20,7 @@
>  #include <linux/mtd/plat-ram.h>
>  #include <linux/memory.h>
>  #include <linux/gpio.h>
> +#include <linux/gpio/machine.h>
>  #include <linux/smc911x.h>
>  #include <linux/interrupt.h>
>  #include <linux/delay.h>
> @@ -214,8 +215,6 @@ static const iomux_v3_cfg_t pcm043_pads[]
> __initconst = {
>  #define AC97_GPIO_TXFS	IMX_GPIO_NR(2, 31)
>  #define AC97_GPIO_TXD	IMX_GPIO_NR(2, 28)
>  #define AC97_GPIO_RESET	IMX_GPIO_NR(2, 0)
> -#define SD1_GPIO_WP	IMX_GPIO_NR(2, 23)
> -#define SD1_GPIO_CD	IMX_GPIO_NR(2, 24)
> 
>  static void pcm043_ac97_warm_reset(struct snd_ac97 *ac97)  { @@
> -341,12 +340,21 @@ static int __init pcm043_otg_mode(char *options)
> __setup("otg_mode=", pcm043_otg_mode);
> 
>  static struct esdhc_platform_data sd1_pdata = {
> -	.wp_gpio = SD1_GPIO_WP,
> -	.cd_gpio = SD1_GPIO_CD,
>  	.wp_type = ESDHC_WP_GPIO,
>  	.cd_type = ESDHC_CD_GPIO,
>  };
> 
> +static struct gpiod_lookup_table sd1_gpio_table = {
> +	.dev_id = "sdhci-esdhc-imx35.0",
> +	.table = {
> +		/* Card detect: bank 2 offset 24 */
> +		GPIO_LOOKUP("imx35-gpio.2", 24, "cd", GPIO_ACTIVE_LOW),
> +		/* Write protect: bank 2 offset 23 */
> +		GPIO_LOOKUP("imx35-gpio.2", 23, "wp", GPIO_ACTIVE_LOW),
> +		{ },
> +	},
> +};
> +
>  /*
>   * Board specific initialization.
>   */
> @@ -391,6 +399,7 @@ static void __init pcm043_late_init(void)  {
>  	imx35_add_imx_ssi(0, &pcm043_ssi_pdata);
> 
> +	gpiod_add_lookup_table(&sd1_gpio_table);
>  	imx35_add_sdhci_esdhc_imx(0, &sd1_pdata);  }
> 
> diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c
> b/drivers/mmc/host/sdhci-esdhc-imx.c
> index f44e49014a44..982d2a9866dc 100644
> --- a/drivers/mmc/host/sdhci-esdhc-imx.c
> +++ b/drivers/mmc/host/sdhci-esdhc-imx.c
> @@ -12,7 +12,6 @@
>  #include <linux/delay.h>
>  #include <linux/err.h>
>  #include <linux/clk.h>
> -#include <linux/gpio.h>
>  #include <linux/module.h>
>  #include <linux/slab.h>
>  #include <linux/mmc/host.h>
> @@ -21,7 +20,6 @@
>  #include <linux/mmc/slot-gpio.h>
>  #include <linux/of.h>
>  #include <linux/of_device.h>
> -#include <linux/of_gpio.h>
>  #include <linux/pinctrl/consumer.h>
>  #include <linux/platform_data/mmc-esdhc-imx.h>
>  #include <linux/pm_runtime.h>
> @@ -1139,8 +1137,12 @@ sdhci_esdhc_imx_probe_dt(struct platform_device
> *pdev,
>  	if (of_get_property(np, "fsl,wp-controller", NULL))
>  		boarddata->wp_type = ESDHC_WP_CONTROLLER;
> 
> -	boarddata->wp_gpio = of_get_named_gpio(np, "wp-gpios", 0);
> -	if (gpio_is_valid(boarddata->wp_gpio))
> +	/*
> +	 * If we have this property, then activate WP check.
> +	 * Retrieveing and requesting the actual WP GPIO will happen
> +	 * in the call to mmc_of_parse().
> +	 */
> +	if (of_property_read_bool(np, "wp-gpios"))
>  		boarddata->wp_type = ESDHC_WP_GPIO;
> 
>  	of_property_read_u32(np, "fsl,tuning-step", &boarddata->tuning_step);
> @@ -1198,7 +1200,7 @@ static int sdhci_esdhc_imx_probe_nondt(struct
> platform_device *pdev,
>  				host->mmc->parent->platform_data);
>  	/* write_protect */
>  	if (boarddata->wp_type == ESDHC_WP_GPIO) {
> -		err = mmc_gpio_request_ro(host->mmc, boarddata->wp_gpio);
> +		err = mmc_gpiod_request_ro(host->mmc, "wp", 0, false, 0, NULL);
>  		if (err) {
>  			dev_err(mmc_dev(host->mmc),
>  				"failed to request write-protect gpio!\n"); @@ -1210,7
> +1212,7 @@ static int sdhci_esdhc_imx_probe_nondt(struct platform_device
> *pdev,
>  	/* card_detect */
>  	switch (boarddata->cd_type) {
>  	case ESDHC_CD_GPIO:
> -		err = mmc_gpio_request_cd(host->mmc, boarddata->cd_gpio, 0);
> +		err = mmc_gpiod_request_cd(host->mmc, "cd", 0, false, 0, NULL);
>  		if (err) {
>  			dev_err(mmc_dev(host->mmc),
>  				"failed to request card-detect gpio!\n"); diff --git
> a/include/linux/platform_data/mmc-esdhc-imx.h
> b/include/linux/platform_data/mmc-esdhc-imx.h
> index 640dec8b5b0c..b606ca4197df 100644
> --- a/include/linux/platform_data/mmc-esdhc-imx.h
> +++ b/include/linux/platform_data/mmc-esdhc-imx.h
> @@ -30,15 +30,11 @@ enum cd_types {
>   *
>   * ESDHC_WP(CD)_CONTROLLER type is not available on i.MX25/35.
>   *
> - * @wp_gpio:	gpio for write_protect
> - * @cd_gpio:	gpio for card_detect interrupt
>   * @wp_type:	type of write_protect method (see wp_types enum above)
>   * @cd_type:	type of card_detect method (see cd_types enum above)
>   */
> 
>  struct esdhc_platform_data {
> -	unsigned int wp_gpio;
> -	unsigned int cd_gpio;
>  	enum wp_types wp_type;
>  	enum cd_types cd_type;
>  	int max_bus_width;
> --
> 2.17.2
Sascha Hauer Nov. 13, 2018, 7:11 a.m. UTC | #2
On Mon, Nov 12, 2018 at 04:09:06PM +0000, A.s. Dong wrote:
> > -----Original Message-----
> > From: Linus Walleij [mailto:linus.walleij@linaro.org]
> > Sent: Monday, November 12, 2018 10:13 PM
> > To: linux-mmc@vger.kernel.org; Ulf Hansson <ulf.hansson@linaro.org>
> > Cc: Linus Walleij <linus.walleij@linaro.org>; Shawn Guo
> > <shawnguo@kernel.org>; Sascha Hauer <s.hauer@pengutronix.de>;
> > Pengutronix Kernel Team <kernel@pengutronix.de>; Fabio Estevam
> > <fabio.estevam@nxp.com>; dl-linux-imx <linux-imx@nxp.com>; Bartosz
> > Golaszewski <brgl@bgdev.pl>
> > Subject: [PATCH 06/10] mmc: sdhci: imx: Use the slot GPIO descriptor
> > 
> > Simplify things by making the i.MX SDHCI driver just use slot GPIO with
> > descriptors instead of passing around the global GPIO numbers that we want
> > to get rid of.
> > 
> > As it turns out, just one single board is using the platform data to pass in GPIOs
> > numbers for CD and WP, so we augment this to use a machine descriptor table
> > instead.
> > 
> > Cc: Shawn Guo <shawnguo@kernel.org>
> > Cc: Sascha Hauer <s.hauer@pengutronix.de>
> > Cc: Pengutronix Kernel Team <kernel@pengutronix.de>
> > Cc: Fabio Estevam <fabio.estevam@nxp.com>
> > Cc: NXP Linux Team <linux-imx@nxp.com>
> > Cc: Bartosz Golaszewski <brgl@bgdev.pl>
> > Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> 
> Reviewed-by: Dong Aisheng <aisheng.dong@nxp.com>
> 
> > ---
> > This very much needs to be tested on the PCM043.
> > 
> > If it works fine, it also opens the way for switching more i.MX boardfiles to
> > using machine GPIO descriptor tables.
> 
> It's almost a 10 years old board and not sure if it's still maintained by Pengutronix.

I think if someone had real intereset in that board he should first port
it over to device tree, so no objections from me here.

Sascha
Ulf Hansson Nov. 20, 2018, 9:30 a.m. UTC | #3
On 12 November 2018 at 15:12, Linus Walleij <linus.walleij@linaro.org> wrote:
> Simplify things by making the i.MX SDHCI driver just use
> slot GPIO with descriptors instead of passing around the global
> GPIO numbers that we want to get rid of.
>
> As it turns out, just one single board is using the platform
> data to pass in GPIOs numbers for CD and WP, so we augment this
> to use a machine descriptor table instead.
>
> Cc: Shawn Guo <shawnguo@kernel.org>
> Cc: Sascha Hauer <s.hauer@pengutronix.de>
> Cc: Pengutronix Kernel Team <kernel@pengutronix.de>
> Cc: Fabio Estevam <fabio.estevam@nxp.com>
> Cc: NXP Linux Team <linux-imx@nxp.com>
> Cc: Bartosz Golaszewski <brgl@bgdev.pl>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

Applied for next, thanks!

Kind regards
Uffe

> ---
> This very much needs to be tested on the PCM043.
>
> If it works fine, it also opens the way for switching more i.MX
> boardfiles to using machine GPIO descriptor tables.
> ---
>  arch/arm/mach-imx/mach-pcm043.c             | 17 +++++++++++++----
>  drivers/mmc/host/sdhci-esdhc-imx.c          | 14 ++++++++------
>  include/linux/platform_data/mmc-esdhc-imx.h |  4 ----
>  3 files changed, 21 insertions(+), 14 deletions(-)
>
> diff --git a/arch/arm/mach-imx/mach-pcm043.c b/arch/arm/mach-imx/mach-pcm043.c
> index e595e5368676..46ba3348e8f0 100644
> --- a/arch/arm/mach-imx/mach-pcm043.c
> +++ b/arch/arm/mach-imx/mach-pcm043.c
> @@ -20,6 +20,7 @@
>  #include <linux/mtd/plat-ram.h>
>  #include <linux/memory.h>
>  #include <linux/gpio.h>
> +#include <linux/gpio/machine.h>
>  #include <linux/smc911x.h>
>  #include <linux/interrupt.h>
>  #include <linux/delay.h>
> @@ -214,8 +215,6 @@ static const iomux_v3_cfg_t pcm043_pads[] __initconst = {
>  #define AC97_GPIO_TXFS IMX_GPIO_NR(2, 31)
>  #define AC97_GPIO_TXD  IMX_GPIO_NR(2, 28)
>  #define AC97_GPIO_RESET        IMX_GPIO_NR(2, 0)
> -#define SD1_GPIO_WP    IMX_GPIO_NR(2, 23)
> -#define SD1_GPIO_CD    IMX_GPIO_NR(2, 24)
>
>  static void pcm043_ac97_warm_reset(struct snd_ac97 *ac97)
>  {
> @@ -341,12 +340,21 @@ static int __init pcm043_otg_mode(char *options)
>  __setup("otg_mode=", pcm043_otg_mode);
>
>  static struct esdhc_platform_data sd1_pdata = {
> -       .wp_gpio = SD1_GPIO_WP,
> -       .cd_gpio = SD1_GPIO_CD,
>         .wp_type = ESDHC_WP_GPIO,
>         .cd_type = ESDHC_CD_GPIO,
>  };
>
> +static struct gpiod_lookup_table sd1_gpio_table = {
> +       .dev_id = "sdhci-esdhc-imx35.0",
> +       .table = {
> +               /* Card detect: bank 2 offset 24 */
> +               GPIO_LOOKUP("imx35-gpio.2", 24, "cd", GPIO_ACTIVE_LOW),
> +               /* Write protect: bank 2 offset 23 */
> +               GPIO_LOOKUP("imx35-gpio.2", 23, "wp", GPIO_ACTIVE_LOW),
> +               { },
> +       },
> +};
> +
>  /*
>   * Board specific initialization.
>   */
> @@ -391,6 +399,7 @@ static void __init pcm043_late_init(void)
>  {
>         imx35_add_imx_ssi(0, &pcm043_ssi_pdata);
>
> +       gpiod_add_lookup_table(&sd1_gpio_table);
>         imx35_add_sdhci_esdhc_imx(0, &sd1_pdata);
>  }
>
> diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
> index f44e49014a44..982d2a9866dc 100644
> --- a/drivers/mmc/host/sdhci-esdhc-imx.c
> +++ b/drivers/mmc/host/sdhci-esdhc-imx.c
> @@ -12,7 +12,6 @@
>  #include <linux/delay.h>
>  #include <linux/err.h>
>  #include <linux/clk.h>
> -#include <linux/gpio.h>
>  #include <linux/module.h>
>  #include <linux/slab.h>
>  #include <linux/mmc/host.h>
> @@ -21,7 +20,6 @@
>  #include <linux/mmc/slot-gpio.h>
>  #include <linux/of.h>
>  #include <linux/of_device.h>
> -#include <linux/of_gpio.h>
>  #include <linux/pinctrl/consumer.h>
>  #include <linux/platform_data/mmc-esdhc-imx.h>
>  #include <linux/pm_runtime.h>
> @@ -1139,8 +1137,12 @@ sdhci_esdhc_imx_probe_dt(struct platform_device *pdev,
>         if (of_get_property(np, "fsl,wp-controller", NULL))
>                 boarddata->wp_type = ESDHC_WP_CONTROLLER;
>
> -       boarddata->wp_gpio = of_get_named_gpio(np, "wp-gpios", 0);
> -       if (gpio_is_valid(boarddata->wp_gpio))
> +       /*
> +        * If we have this property, then activate WP check.
> +        * Retrieveing and requesting the actual WP GPIO will happen
> +        * in the call to mmc_of_parse().
> +        */
> +       if (of_property_read_bool(np, "wp-gpios"))
>                 boarddata->wp_type = ESDHC_WP_GPIO;
>
>         of_property_read_u32(np, "fsl,tuning-step", &boarddata->tuning_step);
> @@ -1198,7 +1200,7 @@ static int sdhci_esdhc_imx_probe_nondt(struct platform_device *pdev,
>                                 host->mmc->parent->platform_data);
>         /* write_protect */
>         if (boarddata->wp_type == ESDHC_WP_GPIO) {
> -               err = mmc_gpio_request_ro(host->mmc, boarddata->wp_gpio);
> +               err = mmc_gpiod_request_ro(host->mmc, "wp", 0, false, 0, NULL);
>                 if (err) {
>                         dev_err(mmc_dev(host->mmc),
>                                 "failed to request write-protect gpio!\n");
> @@ -1210,7 +1212,7 @@ static int sdhci_esdhc_imx_probe_nondt(struct platform_device *pdev,
>         /* card_detect */
>         switch (boarddata->cd_type) {
>         case ESDHC_CD_GPIO:
> -               err = mmc_gpio_request_cd(host->mmc, boarddata->cd_gpio, 0);
> +               err = mmc_gpiod_request_cd(host->mmc, "cd", 0, false, 0, NULL);
>                 if (err) {
>                         dev_err(mmc_dev(host->mmc),
>                                 "failed to request card-detect gpio!\n");
> diff --git a/include/linux/platform_data/mmc-esdhc-imx.h b/include/linux/platform_data/mmc-esdhc-imx.h
> index 640dec8b5b0c..b606ca4197df 100644
> --- a/include/linux/platform_data/mmc-esdhc-imx.h
> +++ b/include/linux/platform_data/mmc-esdhc-imx.h
> @@ -30,15 +30,11 @@ enum cd_types {
>   *
>   * ESDHC_WP(CD)_CONTROLLER type is not available on i.MX25/35.
>   *
> - * @wp_gpio:   gpio for write_protect
> - * @cd_gpio:   gpio for card_detect interrupt
>   * @wp_type:   type of write_protect method (see wp_types enum above)
>   * @cd_type:   type of card_detect method (see cd_types enum above)
>   */
>
>  struct esdhc_platform_data {
> -       unsigned int wp_gpio;
> -       unsigned int cd_gpio;
>         enum wp_types wp_type;
>         enum cd_types cd_type;
>         int max_bus_width;
> --
> 2.17.2
>
diff mbox series

Patch

diff --git a/arch/arm/mach-imx/mach-pcm043.c b/arch/arm/mach-imx/mach-pcm043.c
index e595e5368676..46ba3348e8f0 100644
--- a/arch/arm/mach-imx/mach-pcm043.c
+++ b/arch/arm/mach-imx/mach-pcm043.c
@@ -20,6 +20,7 @@ 
 #include <linux/mtd/plat-ram.h>
 #include <linux/memory.h>
 #include <linux/gpio.h>
+#include <linux/gpio/machine.h>
 #include <linux/smc911x.h>
 #include <linux/interrupt.h>
 #include <linux/delay.h>
@@ -214,8 +215,6 @@  static const iomux_v3_cfg_t pcm043_pads[] __initconst = {
 #define AC97_GPIO_TXFS	IMX_GPIO_NR(2, 31)
 #define AC97_GPIO_TXD	IMX_GPIO_NR(2, 28)
 #define AC97_GPIO_RESET	IMX_GPIO_NR(2, 0)
-#define SD1_GPIO_WP	IMX_GPIO_NR(2, 23)
-#define SD1_GPIO_CD	IMX_GPIO_NR(2, 24)
 
 static void pcm043_ac97_warm_reset(struct snd_ac97 *ac97)
 {
@@ -341,12 +340,21 @@  static int __init pcm043_otg_mode(char *options)
 __setup("otg_mode=", pcm043_otg_mode);
 
 static struct esdhc_platform_data sd1_pdata = {
-	.wp_gpio = SD1_GPIO_WP,
-	.cd_gpio = SD1_GPIO_CD,
 	.wp_type = ESDHC_WP_GPIO,
 	.cd_type = ESDHC_CD_GPIO,
 };
 
+static struct gpiod_lookup_table sd1_gpio_table = {
+	.dev_id = "sdhci-esdhc-imx35.0",
+	.table = {
+		/* Card detect: bank 2 offset 24 */
+		GPIO_LOOKUP("imx35-gpio.2", 24, "cd", GPIO_ACTIVE_LOW),
+		/* Write protect: bank 2 offset 23 */
+		GPIO_LOOKUP("imx35-gpio.2", 23, "wp", GPIO_ACTIVE_LOW),
+		{ },
+	},
+};
+
 /*
  * Board specific initialization.
  */
@@ -391,6 +399,7 @@  static void __init pcm043_late_init(void)
 {
 	imx35_add_imx_ssi(0, &pcm043_ssi_pdata);
 
+	gpiod_add_lookup_table(&sd1_gpio_table);
 	imx35_add_sdhci_esdhc_imx(0, &sd1_pdata);
 }
 
diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
index f44e49014a44..982d2a9866dc 100644
--- a/drivers/mmc/host/sdhci-esdhc-imx.c
+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
@@ -12,7 +12,6 @@ 
 #include <linux/delay.h>
 #include <linux/err.h>
 #include <linux/clk.h>
-#include <linux/gpio.h>
 #include <linux/module.h>
 #include <linux/slab.h>
 #include <linux/mmc/host.h>
@@ -21,7 +20,6 @@ 
 #include <linux/mmc/slot-gpio.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
-#include <linux/of_gpio.h>
 #include <linux/pinctrl/consumer.h>
 #include <linux/platform_data/mmc-esdhc-imx.h>
 #include <linux/pm_runtime.h>
@@ -1139,8 +1137,12 @@  sdhci_esdhc_imx_probe_dt(struct platform_device *pdev,
 	if (of_get_property(np, "fsl,wp-controller", NULL))
 		boarddata->wp_type = ESDHC_WP_CONTROLLER;
 
-	boarddata->wp_gpio = of_get_named_gpio(np, "wp-gpios", 0);
-	if (gpio_is_valid(boarddata->wp_gpio))
+	/*
+	 * If we have this property, then activate WP check.
+	 * Retrieveing and requesting the actual WP GPIO will happen
+	 * in the call to mmc_of_parse().
+	 */
+	if (of_property_read_bool(np, "wp-gpios"))
 		boarddata->wp_type = ESDHC_WP_GPIO;
 
 	of_property_read_u32(np, "fsl,tuning-step", &boarddata->tuning_step);
@@ -1198,7 +1200,7 @@  static int sdhci_esdhc_imx_probe_nondt(struct platform_device *pdev,
 				host->mmc->parent->platform_data);
 	/* write_protect */
 	if (boarddata->wp_type == ESDHC_WP_GPIO) {
-		err = mmc_gpio_request_ro(host->mmc, boarddata->wp_gpio);
+		err = mmc_gpiod_request_ro(host->mmc, "wp", 0, false, 0, NULL);
 		if (err) {
 			dev_err(mmc_dev(host->mmc),
 				"failed to request write-protect gpio!\n");
@@ -1210,7 +1212,7 @@  static int sdhci_esdhc_imx_probe_nondt(struct platform_device *pdev,
 	/* card_detect */
 	switch (boarddata->cd_type) {
 	case ESDHC_CD_GPIO:
-		err = mmc_gpio_request_cd(host->mmc, boarddata->cd_gpio, 0);
+		err = mmc_gpiod_request_cd(host->mmc, "cd", 0, false, 0, NULL);
 		if (err) {
 			dev_err(mmc_dev(host->mmc),
 				"failed to request card-detect gpio!\n");
diff --git a/include/linux/platform_data/mmc-esdhc-imx.h b/include/linux/platform_data/mmc-esdhc-imx.h
index 640dec8b5b0c..b606ca4197df 100644
--- a/include/linux/platform_data/mmc-esdhc-imx.h
+++ b/include/linux/platform_data/mmc-esdhc-imx.h
@@ -30,15 +30,11 @@  enum cd_types {
  *
  * ESDHC_WP(CD)_CONTROLLER type is not available on i.MX25/35.
  *
- * @wp_gpio:	gpio for write_protect
- * @cd_gpio:	gpio for card_detect interrupt
  * @wp_type:	type of write_protect method (see wp_types enum above)
  * @cd_type:	type of card_detect method (see cd_types enum above)
  */
 
 struct esdhc_platform_data {
-	unsigned int wp_gpio;
-	unsigned int cd_gpio;
 	enum wp_types wp_type;
 	enum cd_types cd_type;
 	int max_bus_width;