]> git.baikalelectronics.ru Git - kernel.git/commitdiff
mmc: sdhci: imx: Use the slot GPIO descriptor
authorLinus Walleij <linus.walleij@linaro.org>
Mon, 12 Nov 2018 14:12:35 +0000 (15:12 +0100)
committerUlf Hansson <ulf.hansson@linaro.org>
Mon, 17 Dec 2018 07:26:24 +0000 (08:26 +0100)
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>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
arch/arm/mach-imx/mach-pcm043.c
drivers/mmc/host/sdhci-esdhc-imx.c
include/linux/platform_data/mmc-esdhc-imx.h

index e595e5368676de1f5f219c74ed8ea37cc217266b..46ba3348e8f0d1cbafa27a22c69b450bd8fae1b0 100644 (file)
@@ -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);
 }
 
index 3f62dae0afa5f70cdc493d4457ffcb7a86a5b472..d0d319398a547827a5a7a5053f3f12f802402f61 100644 (file)
@@ -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");
index 640dec8b5b0c7f0c1f96143e007b196c8513d777..b606ca4197dfdd71fb19e8a666c7f7392864fec4 100644 (file)
@@ -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;