linux-mips.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] mmc: jz4740: Remove platform data and use standard APIs
@ 2019-01-25 20:09 Paul Cercueil
  2019-01-25 20:09 ` [PATCH 2/3] MIPS: DTS: jz4740: Add node for the MMC driver Paul Cercueil
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Paul Cercueil @ 2019-01-25 20:09 UTC (permalink / raw)
  To: Rob Herring, Mark Rutland, Ralf Baechle, Paul Burton,
	James Hogan, Ulf Hansson, Linus Walleij
  Cc: devicetree, linux-mips, linux-kernel, linux-mmc, Paul Cercueil

Drop the custom code to get the 'cd' and 'wp' GPIOs. The driver now
calls mmc_of_parse() which will init these from devicetree or
device properties.

Also drop the custom code to get the 'power' GPIO. The MMC core
provides us with the means to power the MMC card through an external
regulator.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
 drivers/mmc/host/jz4740_mmc.c | 71 +++++++++----------------------------------
 1 file changed, 14 insertions(+), 57 deletions(-)

diff --git a/drivers/mmc/host/jz4740_mmc.c b/drivers/mmc/host/jz4740_mmc.c
index 33215d66afa2..e41c7230815f 100644
--- a/drivers/mmc/host/jz4740_mmc.c
+++ b/drivers/mmc/host/jz4740_mmc.c
@@ -21,7 +21,6 @@
 #include <linux/dmaengine.h>
 #include <linux/dma-mapping.h>
 #include <linux/err.h>
-#include <linux/gpio/consumer.h>
 #include <linux/interrupt.h>
 #include <linux/io.h>
 #include <linux/irq.h>
@@ -36,7 +35,6 @@
 #include <asm/cacheflush.h>
 
 #include <asm/mach-jz4740/dma.h>
-#include <asm/mach-jz4740/jz4740_mmc.h>
 
 #define JZ_REG_MMC_STRPCL	0x00
 #define JZ_REG_MMC_STATUS	0x04
@@ -148,9 +146,7 @@ enum jz4780_cookie {
 struct jz4740_mmc_host {
 	struct mmc_host *mmc;
 	struct platform_device *pdev;
-	struct jz4740_mmc_platform_data *pdata;
 	struct clk *clk;
-	struct gpio_desc *power;
 
 	enum jz4740_mmc_version version;
 
@@ -894,16 +890,16 @@ static void jz4740_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 	switch (ios->power_mode) {
 	case MMC_POWER_UP:
 		jz4740_mmc_reset(host);
-		if (host->power)
-			gpiod_set_value(host->power, 1);
+		if (!IS_ERR(mmc->supply.vmmc))
+			mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, ios->vdd);
 		host->cmdat |= JZ_MMC_CMDAT_INIT;
 		clk_prepare_enable(host->clk);
 		break;
 	case MMC_POWER_ON:
 		break;
 	default:
-		if (host->power)
-			gpiod_set_value(host->power, 0);
+		if (!IS_ERR(mmc->supply.vmmc))
+			mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, 0);
 		clk_disable_unprepare(host->clk);
 		break;
 	}
@@ -936,38 +932,6 @@ static const struct mmc_host_ops jz4740_mmc_ops = {
 	.enable_sdio_irq = jz4740_mmc_enable_sdio_irq,
 };
 
-static int jz4740_mmc_request_gpios(struct jz4740_mmc_host *host,
-				    struct mmc_host *mmc,
-				    struct platform_device *pdev)
-{
-	struct jz4740_mmc_platform_data *pdata = dev_get_platdata(&pdev->dev);
-	int ret = 0;
-
-	if (!pdata)
-		return 0;
-
-	if (!pdata->card_detect_active_low)
-		mmc->caps2 |= MMC_CAP2_CD_ACTIVE_HIGH;
-	if (!pdata->read_only_active_low)
-		mmc->caps2 |= MMC_CAP2_RO_ACTIVE_HIGH;
-
-	/*
-	 * Get optional card detect and write protect GPIOs,
-	 * only back out on probe deferral.
-	 */
-	ret = mmc_gpiod_request_cd(mmc, "cd", 0, false, 0, NULL);
-	if (ret == -EPROBE_DEFER)
-		return ret;
-
-	ret = mmc_gpiod_request_ro(mmc, "wp", 0, false, 0, NULL);
-	if (ret == -EPROBE_DEFER)
-		return ret;
-
-	host->power = devm_gpiod_get_optional(&pdev->dev, "power",
-					      GPIOD_OUT_HIGH);
-	return PTR_ERR_OR_ZERO(host->power);
-}
-
 static const struct of_device_id jz4740_mmc_of_match[] = {
 	{ .compatible = "ingenic,jz4740-mmc", .data = (void *) JZ_MMC_JZ4740 },
 	{ .compatible = "ingenic,jz4725b-mmc", .data = (void *)JZ_MMC_JZ4725B },
@@ -982,9 +946,6 @@ static int jz4740_mmc_probe(struct platform_device* pdev)
 	struct mmc_host *mmc;
 	struct jz4740_mmc_host *host;
 	const struct of_device_id *match;
-	struct jz4740_mmc_platform_data *pdata;
-
-	pdata = dev_get_platdata(&pdev->dev);
 
 	mmc = mmc_alloc_host(sizeof(struct jz4740_mmc_host), &pdev->dev);
 	if (!mmc) {
@@ -993,29 +954,25 @@ static int jz4740_mmc_probe(struct platform_device* pdev)
 	}
 
 	host = mmc_priv(mmc);
-	host->pdata = pdata;
 
 	match = of_match_device(jz4740_mmc_of_match, &pdev->dev);
 	if (match) {
 		host->version = (enum jz4740_mmc_version)match->data;
-		ret = mmc_of_parse(mmc);
-		if (ret) {
-			if (ret != -EPROBE_DEFER)
-				dev_err(&pdev->dev,
-					"could not parse of data: %d\n", ret);
-			goto err_free_host;
-		}
 	} else {
 		/* JZ4740 should be the only one using legacy probe */
 		host->version = JZ_MMC_JZ4740;
-		mmc->caps |= MMC_CAP_SDIO_IRQ;
-		if (!(pdata && pdata->data_1bit))
-			mmc->caps |= MMC_CAP_4_BIT_DATA;
-		ret = jz4740_mmc_request_gpios(host, mmc, pdev);
-		if (ret)
-			goto err_free_host;
 	}
 
+	ret = mmc_of_parse(mmc);
+	if (ret) {
+		if (ret != -EPROBE_DEFER)
+			dev_err(&pdev->dev,
+				"could not parse device properties: %d\n", ret);
+		goto err_free_host;
+	}
+
+	mmc_regulator_get_supply(mmc);
+
 	host->irq = platform_get_irq(pdev, 0);
 	if (host->irq < 0) {
 		ret = host->irq;
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/3] MIPS: DTS: jz4740: Add node for the MMC driver
  2019-01-25 20:09 [PATCH 1/3] mmc: jz4740: Remove platform data and use standard APIs Paul Cercueil
@ 2019-01-25 20:09 ` Paul Cercueil
  2019-07-22 21:22   ` Paul Burton
  2019-01-25 20:09 ` [PATCH 3/3] MIPS: qi_lb60: Move MMC configuration to devicetree Paul Cercueil
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Paul Cercueil @ 2019-01-25 20:09 UTC (permalink / raw)
  To: Rob Herring, Mark Rutland, Ralf Baechle, Paul Burton,
	James Hogan, Ulf Hansson, Linus Walleij
  Cc: devicetree, linux-mips, linux-kernel, linux-mmc, Paul Cercueil

Add a devicetree node for the jz4740-mmc driver.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
 arch/mips/boot/dts/ingenic/jz4740.dtsi | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/arch/mips/boot/dts/ingenic/jz4740.dtsi b/arch/mips/boot/dts/ingenic/jz4740.dtsi
index 6fb16fd24035..35c48e1e853f 100644
--- a/arch/mips/boot/dts/ingenic/jz4740.dtsi
+++ b/arch/mips/boot/dts/ingenic/jz4740.dtsi
@@ -132,6 +132,24 @@
 		};
 	};
 
+	mmc: mmc@10021000 {
+		compatible = "ingenic,jz4740-mmc";
+		reg = <0x10021000 0x1000>;
+
+		clocks = <&cgu JZ4740_CLK_MMC>;
+		clock-names = "mmc";
+
+		interrupt-parent = <&intc>;
+		interrupts = <14>;
+
+		dmas = <&dmac 27 0xffffffff>, <&dmac 26 0xffffffff>;
+		dma-names = "rx", "tx";
+
+		cap-sd-highspeed;
+		cap-mmc-highspeed;
+		cap-sdio-irq;
+	};
+
 	uart0: serial@10030000 {
 		compatible = "ingenic,jz4740-uart";
 		reg = <0x10030000 0x100>;
@@ -164,9 +182,6 @@
 		interrupts = <29>;
 
 		clocks = <&cgu JZ4740_CLK_DMA>;
-
-		/* Disable dmac until we have something that uses it */
-		status = "disabled";
 	};
 
 	uhc: uhc@13030000 {
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/3] MIPS: qi_lb60: Move MMC configuration to devicetree
  2019-01-25 20:09 [PATCH 1/3] mmc: jz4740: Remove platform data and use standard APIs Paul Cercueil
  2019-01-25 20:09 ` [PATCH 2/3] MIPS: DTS: jz4740: Add node for the MMC driver Paul Cercueil
@ 2019-01-25 20:09 ` Paul Cercueil
  2019-07-22 22:30   ` Paul Burton
  2019-01-26 12:10 ` [PATCH 1/3] mmc: jz4740: Remove platform data and use standard APIs Linus Walleij
  2019-01-28 12:02 ` Ulf Hansson
  3 siblings, 1 reply; 8+ messages in thread
From: Paul Cercueil @ 2019-01-25 20:09 UTC (permalink / raw)
  To: Rob Herring, Mark Rutland, Ralf Baechle, Paul Burton,
	James Hogan, Ulf Hansson, Linus Walleij
  Cc: devicetree, linux-mips, linux-kernel, linux-mmc, Paul Cercueil

Move the MMC configuration from the board C file to devicetree.

The 'power' GPIO was removed and instead the vmmc regulator is used,
to follow the changes introduced in the jz4740-mmc driver.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
 arch/mips/boot/dts/ingenic/qi_lb60.dts | 33 +++++++++++++++++++++++++++++++++
 arch/mips/jz4740/board-qi_lb60.c       | 32 --------------------------------
 2 files changed, 33 insertions(+), 32 deletions(-)

diff --git a/arch/mips/boot/dts/ingenic/qi_lb60.dts b/arch/mips/boot/dts/ingenic/qi_lb60.dts
index 76aaf8982554..cc26650562c2 100644
--- a/arch/mips/boot/dts/ingenic/qi_lb60.dts
+++ b/arch/mips/boot/dts/ingenic/qi_lb60.dts
@@ -2,6 +2,7 @@
 /dts-v1/;
 
 #include "jz4740.dtsi"
+#include <dt-bindings/gpio/gpio.h>
 
 / {
 	compatible = "qi,lb60", "ingenic,jz4740";
@@ -9,6 +10,15 @@
 	chosen {
 		stdout-path = &uart0;
 	};
+
+	mmc_power: fixedregulator {
+		compatible = "regulator-fixed";
+		regulator-name = "mmc_vcc";
+		gpio = <&gpd 2 0>;
+
+		regulator-min-microvolt = <3300000>;
+		regulator-max-microvolt = <3300000>;
+	};
 };
 
 &ext {
@@ -30,4 +40,27 @@
 		groups = "uart0-data";
 		bias-disable;
 	};
+
+	pins_mmc: mmc {
+		mmc {
+			function = "mmc";
+			groups = "mmc-1bit", "mmc-4bit";
+			bias-disable;
+		};
+
+		mmc-gpios {
+			pins = "PD0", "PD2";
+			bias-disable;
+		};
+	};
+};
+
+&mmc {
+	bus-width = <4>;
+	max-frequency = <24000000>;
+	cd-gpios = <&gpd 0 GPIO_ACTIVE_HIGH>;
+	vmmc-supply = <&mmc_power>;
+
+	pinctrl-names = "default";
+	pinctrl-0 = <&pins_mmc>;
 };
diff --git a/arch/mips/jz4740/board-qi_lb60.c b/arch/mips/jz4740/board-qi_lb60.c
index 6718efb400f4..8e4c7ac6ac02 100644
--- a/arch/mips/jz4740/board-qi_lb60.c
+++ b/arch/mips/jz4740/board-qi_lb60.c
@@ -33,7 +33,6 @@
 
 #include <asm/mach-jz4740/gpio.h>
 #include <asm/mach-jz4740/jz4740_fb.h>
-#include <asm/mach-jz4740/jz4740_mmc.h>
 
 #include <linux/regulator/fixed.h>
 #include <linux/regulator/machine.h>
@@ -382,19 +381,6 @@ static struct platform_device qi_lb60_gpio_keys = {
 	}
 };
 
-static struct jz4740_mmc_platform_data qi_lb60_mmc_pdata = {
-	/* Intentionally left blank */
-};
-
-static struct gpiod_lookup_table qi_lb60_mmc_gpio_table = {
-	.dev_id = "jz4740-mmc.0",
-	.table = {
-		GPIO_LOOKUP("GPIOD", 0, "cd", GPIO_ACTIVE_HIGH),
-		GPIO_LOOKUP("GPIOD", 2, "power", GPIO_ACTIVE_LOW),
-		{ },
-	},
-};
-
 /* beeper */
 static struct pwm_lookup qi_lb60_pwm_lookup[] = {
 	PWM_LOOKUP("jz4740-pwm", 4, "pwm-beeper", NULL, 0,
@@ -445,7 +431,6 @@ static struct gpiod_lookup_table qi_lb60_audio_gpio_table = {
 static struct platform_device *jz_platform_devices[] __initdata = {
 	&jz4740_udc_device,
 	&jz4740_udc_xceiv_device,
-	&jz4740_mmc_device,
 	&jz4740_nand_device,
 	&qi_lb60_keypad,
 	&qi_lb60_spigpio_device,
@@ -455,17 +440,12 @@ static struct platform_device *jz_platform_devices[] __initdata = {
 	&jz4740_codec_device,
 	&jz4740_adc_device,
 	&jz4740_pwm_device,
-	&jz4740_dma_device,
 	&qi_lb60_gpio_keys,
 	&qi_lb60_pwm_beeper,
 	&qi_lb60_charger_device,
 	&qi_lb60_audio_device,
 };
 
-static unsigned long pin_cfg_bias_disable[] = {
-	    PIN_CONFIG_BIAS_DISABLE,
-};
-
 static struct pinctrl_map pin_map[] __initdata = {
 	/* NAND pin configuration */
 	PIN_MAP_MUX_GROUP_DEFAULT("jz4740-nand",
@@ -477,16 +457,6 @@ static struct pinctrl_map pin_map[] __initdata = {
 	PIN_MAP_MUX_GROUP("jz4740-fb", PINCTRL_STATE_SLEEP,
 			"10010000.jz4740-pinctrl", "lcd", "lcd-no-pins"),
 
-	/* MMC pin configuration */
-	PIN_MAP_MUX_GROUP_DEFAULT("jz4740-mmc.0",
-			"10010000.jz4740-pinctrl", "mmc", "mmc-1bit"),
-	PIN_MAP_MUX_GROUP_DEFAULT("jz4740-mmc.0",
-			"10010000.jz4740-pinctrl", "mmc", "mmc-4bit"),
-	PIN_MAP_CONFIGS_PIN_DEFAULT("jz4740-mmc.0",
-			"10010000.jz4740-pinctrl", "PD0", pin_cfg_bias_disable),
-	PIN_MAP_CONFIGS_PIN_DEFAULT("jz4740-mmc.0",
-			"10010000.jz4740-pinctrl", "PD2", pin_cfg_bias_disable),
-
 	/* PWM pin configuration */
 	PIN_MAP_MUX_GROUP_DEFAULT("jz4740-pwm",
 			"10010000.jz4740-pinctrl", "pwm4", "pwm4"),
@@ -498,12 +468,10 @@ static int __init qi_lb60_init_platform_devices(void)
 	jz4740_framebuffer_device.dev.platform_data = &qi_lb60_fb_pdata;
 	jz4740_nand_device.dev.platform_data = &qi_lb60_nand_pdata;
 	jz4740_adc_device.dev.platform_data = &qi_lb60_battery_pdata;
-	jz4740_mmc_device.dev.platform_data = &qi_lb60_mmc_pdata;
 
 	gpiod_add_lookup_table(&qi_lb60_audio_gpio_table);
 	gpiod_add_lookup_table(&qi_lb60_nand_gpio_table);
 	gpiod_add_lookup_table(&qi_lb60_spigpio_gpio_table);
-	gpiod_add_lookup_table(&qi_lb60_mmc_gpio_table);
 
 	spi_register_board_info(qi_lb60_spi_board_info,
 				ARRAY_SIZE(qi_lb60_spi_board_info));
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/3] mmc: jz4740: Remove platform data and use standard APIs
  2019-01-25 20:09 [PATCH 1/3] mmc: jz4740: Remove platform data and use standard APIs Paul Cercueil
  2019-01-25 20:09 ` [PATCH 2/3] MIPS: DTS: jz4740: Add node for the MMC driver Paul Cercueil
  2019-01-25 20:09 ` [PATCH 3/3] MIPS: qi_lb60: Move MMC configuration to devicetree Paul Cercueil
@ 2019-01-26 12:10 ` Linus Walleij
  2019-01-28 12:02 ` Ulf Hansson
  3 siblings, 0 replies; 8+ messages in thread
From: Linus Walleij @ 2019-01-26 12:10 UTC (permalink / raw)
  To: Paul Cercueil
  Cc: Rob Herring, Mark Rutland, Ralf Baechle, Paul Burton,
	James Hogan, Ulf Hansson,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	linux-mips, linux-kernel, linux-mmc

On Fri, Jan 25, 2019 at 9:09 PM Paul Cercueil <paul@crapouillou.net> wrote:

> Drop the custom code to get the 'cd' and 'wp' GPIOs. The driver now
> calls mmc_of_parse() which will init these from devicetree or
> device properties.
>
> Also drop the custom code to get the 'power' GPIO. The MMC core
> provides us with the means to power the MMC card through an external
> regulator.
>
> Signed-off-by: Paul Cercueil <paul@crapouillou.net>

Execellent patching!
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

For all three patches.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/3] mmc: jz4740: Remove platform data and use standard APIs
  2019-01-25 20:09 [PATCH 1/3] mmc: jz4740: Remove platform data and use standard APIs Paul Cercueil
                   ` (2 preceding siblings ...)
  2019-01-26 12:10 ` [PATCH 1/3] mmc: jz4740: Remove platform data and use standard APIs Linus Walleij
@ 2019-01-28 12:02 ` Ulf Hansson
  2019-01-28 12:58   ` Paul Cercueil
  3 siblings, 1 reply; 8+ messages in thread
From: Ulf Hansson @ 2019-01-28 12:02 UTC (permalink / raw)
  To: Paul Cercueil
  Cc: Rob Herring, Mark Rutland, Ralf Baechle, Paul Burton,
	James Hogan, Linus Walleij, DTML, linux-mips,
	Linux Kernel Mailing List, linux-mmc

On Fri, 25 Jan 2019 at 21:09, Paul Cercueil <paul@crapouillou.net> wrote:
>
> Drop the custom code to get the 'cd' and 'wp' GPIOs. The driver now
> calls mmc_of_parse() which will init these from devicetree or
> device properties.
>
> Also drop the custom code to get the 'power' GPIO. The MMC core
> provides us with the means to power the MMC card through an external
> regulator.
>
> Signed-off-by: Paul Cercueil <paul@crapouillou.net>

Applied for next, thanks!

Should I also pick up the other two MIPS patches or you want to funnel
those through the MIPS soc tree?

Kind regards
Uffe

> ---
>  drivers/mmc/host/jz4740_mmc.c | 71 +++++++++----------------------------------
>  1 file changed, 14 insertions(+), 57 deletions(-)
>
> diff --git a/drivers/mmc/host/jz4740_mmc.c b/drivers/mmc/host/jz4740_mmc.c
> index 33215d66afa2..e41c7230815f 100644
> --- a/drivers/mmc/host/jz4740_mmc.c
> +++ b/drivers/mmc/host/jz4740_mmc.c
> @@ -21,7 +21,6 @@
>  #include <linux/dmaengine.h>
>  #include <linux/dma-mapping.h>
>  #include <linux/err.h>
> -#include <linux/gpio/consumer.h>
>  #include <linux/interrupt.h>
>  #include <linux/io.h>
>  #include <linux/irq.h>
> @@ -36,7 +35,6 @@
>  #include <asm/cacheflush.h>
>
>  #include <asm/mach-jz4740/dma.h>
> -#include <asm/mach-jz4740/jz4740_mmc.h>
>
>  #define JZ_REG_MMC_STRPCL      0x00
>  #define JZ_REG_MMC_STATUS      0x04
> @@ -148,9 +146,7 @@ enum jz4780_cookie {
>  struct jz4740_mmc_host {
>         struct mmc_host *mmc;
>         struct platform_device *pdev;
> -       struct jz4740_mmc_platform_data *pdata;
>         struct clk *clk;
> -       struct gpio_desc *power;
>
>         enum jz4740_mmc_version version;
>
> @@ -894,16 +890,16 @@ static void jz4740_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
>         switch (ios->power_mode) {
>         case MMC_POWER_UP:
>                 jz4740_mmc_reset(host);
> -               if (host->power)
> -                       gpiod_set_value(host->power, 1);
> +               if (!IS_ERR(mmc->supply.vmmc))
> +                       mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, ios->vdd);
>                 host->cmdat |= JZ_MMC_CMDAT_INIT;
>                 clk_prepare_enable(host->clk);
>                 break;
>         case MMC_POWER_ON:
>                 break;
>         default:
> -               if (host->power)
> -                       gpiod_set_value(host->power, 0);
> +               if (!IS_ERR(mmc->supply.vmmc))
> +                       mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, 0);
>                 clk_disable_unprepare(host->clk);
>                 break;
>         }
> @@ -936,38 +932,6 @@ static const struct mmc_host_ops jz4740_mmc_ops = {
>         .enable_sdio_irq = jz4740_mmc_enable_sdio_irq,
>  };
>
> -static int jz4740_mmc_request_gpios(struct jz4740_mmc_host *host,
> -                                   struct mmc_host *mmc,
> -                                   struct platform_device *pdev)
> -{
> -       struct jz4740_mmc_platform_data *pdata = dev_get_platdata(&pdev->dev);
> -       int ret = 0;
> -
> -       if (!pdata)
> -               return 0;
> -
> -       if (!pdata->card_detect_active_low)
> -               mmc->caps2 |= MMC_CAP2_CD_ACTIVE_HIGH;
> -       if (!pdata->read_only_active_low)
> -               mmc->caps2 |= MMC_CAP2_RO_ACTIVE_HIGH;
> -
> -       /*
> -        * Get optional card detect and write protect GPIOs,
> -        * only back out on probe deferral.
> -        */
> -       ret = mmc_gpiod_request_cd(mmc, "cd", 0, false, 0, NULL);
> -       if (ret == -EPROBE_DEFER)
> -               return ret;
> -
> -       ret = mmc_gpiod_request_ro(mmc, "wp", 0, false, 0, NULL);
> -       if (ret == -EPROBE_DEFER)
> -               return ret;
> -
> -       host->power = devm_gpiod_get_optional(&pdev->dev, "power",
> -                                             GPIOD_OUT_HIGH);
> -       return PTR_ERR_OR_ZERO(host->power);
> -}
> -
>  static const struct of_device_id jz4740_mmc_of_match[] = {
>         { .compatible = "ingenic,jz4740-mmc", .data = (void *) JZ_MMC_JZ4740 },
>         { .compatible = "ingenic,jz4725b-mmc", .data = (void *)JZ_MMC_JZ4725B },
> @@ -982,9 +946,6 @@ static int jz4740_mmc_probe(struct platform_device* pdev)
>         struct mmc_host *mmc;
>         struct jz4740_mmc_host *host;
>         const struct of_device_id *match;
> -       struct jz4740_mmc_platform_data *pdata;
> -
> -       pdata = dev_get_platdata(&pdev->dev);
>
>         mmc = mmc_alloc_host(sizeof(struct jz4740_mmc_host), &pdev->dev);
>         if (!mmc) {
> @@ -993,29 +954,25 @@ static int jz4740_mmc_probe(struct platform_device* pdev)
>         }
>
>         host = mmc_priv(mmc);
> -       host->pdata = pdata;
>
>         match = of_match_device(jz4740_mmc_of_match, &pdev->dev);
>         if (match) {
>                 host->version = (enum jz4740_mmc_version)match->data;
> -               ret = mmc_of_parse(mmc);
> -               if (ret) {
> -                       if (ret != -EPROBE_DEFER)
> -                               dev_err(&pdev->dev,
> -                                       "could not parse of data: %d\n", ret);
> -                       goto err_free_host;
> -               }
>         } else {
>                 /* JZ4740 should be the only one using legacy probe */
>                 host->version = JZ_MMC_JZ4740;
> -               mmc->caps |= MMC_CAP_SDIO_IRQ;
> -               if (!(pdata && pdata->data_1bit))
> -                       mmc->caps |= MMC_CAP_4_BIT_DATA;
> -               ret = jz4740_mmc_request_gpios(host, mmc, pdev);
> -               if (ret)
> -                       goto err_free_host;
>         }
>
> +       ret = mmc_of_parse(mmc);
> +       if (ret) {
> +               if (ret != -EPROBE_DEFER)
> +                       dev_err(&pdev->dev,
> +                               "could not parse device properties: %d\n", ret);
> +               goto err_free_host;
> +       }
> +
> +       mmc_regulator_get_supply(mmc);
> +
>         host->irq = platform_get_irq(pdev, 0);
>         if (host->irq < 0) {
>                 ret = host->irq;
> --
> 2.11.0
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/3] mmc: jz4740: Remove platform data and use standard APIs
  2019-01-28 12:02 ` Ulf Hansson
@ 2019-01-28 12:58   ` Paul Cercueil
  0 siblings, 0 replies; 8+ messages in thread
From: Paul Cercueil @ 2019-01-28 12:58 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Rob Herring, Mark Rutland, Ralf Baechle, Paul Burton,
	James Hogan, Linus Walleij, DTML, linux-mips,
	Linux Kernel Mailing List, linux-mmc

Hi,

Le lun. 28 janv. 2019 à 9:02, Ulf Hansson <ulf.hansson@linaro.org> a 
écrit :
> On Fri, 25 Jan 2019 at 21:09, Paul Cercueil <paul@crapouillou.net> 
> wrote:
>> 
>>  Drop the custom code to get the 'cd' and 'wp' GPIOs. The driver now
>>  calls mmc_of_parse() which will init these from devicetree or
>>  device properties.
>> 
>>  Also drop the custom code to get the 'power' GPIO. The MMC core
>>  provides us with the means to power the MMC card through an external
>>  regulator.
>> 
>>  Signed-off-by: Paul Cercueil <paul@crapouillou.net>
> 
> Applied for next, thanks!
> 
> Should I also pick up the other two MIPS patches or you want to funnel
> those through the MIPS soc tree?

I'd prefer through the MIPS tree, then I can still push some other 
patches
on top of these in the 5.1 dev window.

>>  ---
>>   drivers/mmc/host/jz4740_mmc.c | 71 
>> +++++++++----------------------------------
>>   1 file changed, 14 insertions(+), 57 deletions(-)
>> 
>>  diff --git a/drivers/mmc/host/jz4740_mmc.c 
>> b/drivers/mmc/host/jz4740_mmc.c
>>  index 33215d66afa2..e41c7230815f 100644
>>  --- a/drivers/mmc/host/jz4740_mmc.c
>>  +++ b/drivers/mmc/host/jz4740_mmc.c
>>  @@ -21,7 +21,6 @@
>>   #include <linux/dmaengine.h>
>>   #include <linux/dma-mapping.h>
>>   #include <linux/err.h>
>>  -#include <linux/gpio/consumer.h>
>>   #include <linux/interrupt.h>
>>   #include <linux/io.h>
>>   #include <linux/irq.h>
>>  @@ -36,7 +35,6 @@
>>   #include <asm/cacheflush.h>
>> 
>>   #include <asm/mach-jz4740/dma.h>
>>  -#include <asm/mach-jz4740/jz4740_mmc.h>
>> 
>>   #define JZ_REG_MMC_STRPCL      0x00
>>   #define JZ_REG_MMC_STATUS      0x04
>>  @@ -148,9 +146,7 @@ enum jz4780_cookie {
>>   struct jz4740_mmc_host {
>>          struct mmc_host *mmc;
>>          struct platform_device *pdev;
>>  -       struct jz4740_mmc_platform_data *pdata;
>>          struct clk *clk;
>>  -       struct gpio_desc *power;
>> 
>>          enum jz4740_mmc_version version;
>> 
>>  @@ -894,16 +890,16 @@ static void jz4740_mmc_set_ios(struct 
>> mmc_host *mmc, struct mmc_ios *ios)
>>          switch (ios->power_mode) {
>>          case MMC_POWER_UP:
>>                  jz4740_mmc_reset(host);
>>  -               if (host->power)
>>  -                       gpiod_set_value(host->power, 1);
>>  +               if (!IS_ERR(mmc->supply.vmmc))
>>  +                       mmc_regulator_set_ocr(mmc, 
>> mmc->supply.vmmc, ios->vdd);
>>                  host->cmdat |= JZ_MMC_CMDAT_INIT;
>>                  clk_prepare_enable(host->clk);
>>                  break;
>>          case MMC_POWER_ON:
>>                  break;
>>          default:
>>  -               if (host->power)
>>  -                       gpiod_set_value(host->power, 0);
>>  +               if (!IS_ERR(mmc->supply.vmmc))
>>  +                       mmc_regulator_set_ocr(mmc, 
>> mmc->supply.vmmc, 0);
>>                  clk_disable_unprepare(host->clk);
>>                  break;
>>          }
>>  @@ -936,38 +932,6 @@ static const struct mmc_host_ops 
>> jz4740_mmc_ops = {
>>          .enable_sdio_irq = jz4740_mmc_enable_sdio_irq,
>>   };
>> 
>>  -static int jz4740_mmc_request_gpios(struct jz4740_mmc_host *host,
>>  -                                   struct mmc_host *mmc,
>>  -                                   struct platform_device *pdev)
>>  -{
>>  -       struct jz4740_mmc_platform_data *pdata = 
>> dev_get_platdata(&pdev->dev);
>>  -       int ret = 0;
>>  -
>>  -       if (!pdata)
>>  -               return 0;
>>  -
>>  -       if (!pdata->card_detect_active_low)
>>  -               mmc->caps2 |= MMC_CAP2_CD_ACTIVE_HIGH;
>>  -       if (!pdata->read_only_active_low)
>>  -               mmc->caps2 |= MMC_CAP2_RO_ACTIVE_HIGH;
>>  -
>>  -       /*
>>  -        * Get optional card detect and write protect GPIOs,
>>  -        * only back out on probe deferral.
>>  -        */
>>  -       ret = mmc_gpiod_request_cd(mmc, "cd", 0, false, 0, NULL);
>>  -       if (ret == -EPROBE_DEFER)
>>  -               return ret;
>>  -
>>  -       ret = mmc_gpiod_request_ro(mmc, "wp", 0, false, 0, NULL);
>>  -       if (ret == -EPROBE_DEFER)
>>  -               return ret;
>>  -
>>  -       host->power = devm_gpiod_get_optional(&pdev->dev, "power",
>>  -                                             GPIOD_OUT_HIGH);
>>  -       return PTR_ERR_OR_ZERO(host->power);
>>  -}
>>  -
>>   static const struct of_device_id jz4740_mmc_of_match[] = {
>>          { .compatible = "ingenic,jz4740-mmc", .data = (void *) 
>> JZ_MMC_JZ4740 },
>>          { .compatible = "ingenic,jz4725b-mmc", .data = (void 
>> *)JZ_MMC_JZ4725B },
>>  @@ -982,9 +946,6 @@ static int jz4740_mmc_probe(struct 
>> platform_device* pdev)
>>          struct mmc_host *mmc;
>>          struct jz4740_mmc_host *host;
>>          const struct of_device_id *match;
>>  -       struct jz4740_mmc_platform_data *pdata;
>>  -
>>  -       pdata = dev_get_platdata(&pdev->dev);
>> 
>>          mmc = mmc_alloc_host(sizeof(struct jz4740_mmc_host), 
>> &pdev->dev);
>>          if (!mmc) {
>>  @@ -993,29 +954,25 @@ static int jz4740_mmc_probe(struct 
>> platform_device* pdev)
>>          }
>> 
>>          host = mmc_priv(mmc);
>>  -       host->pdata = pdata;
>> 
>>          match = of_match_device(jz4740_mmc_of_match, &pdev->dev);
>>          if (match) {
>>                  host->version = (enum 
>> jz4740_mmc_version)match->data;
>>  -               ret = mmc_of_parse(mmc);
>>  -               if (ret) {
>>  -                       if (ret != -EPROBE_DEFER)
>>  -                               dev_err(&pdev->dev,
>>  -                                       "could not parse of data: 
>> %d\n", ret);
>>  -                       goto err_free_host;
>>  -               }
>>          } else {
>>                  /* JZ4740 should be the only one using legacy probe 
>> */
>>                  host->version = JZ_MMC_JZ4740;
>>  -               mmc->caps |= MMC_CAP_SDIO_IRQ;
>>  -               if (!(pdata && pdata->data_1bit))
>>  -                       mmc->caps |= MMC_CAP_4_BIT_DATA;
>>  -               ret = jz4740_mmc_request_gpios(host, mmc, pdev);
>>  -               if (ret)
>>  -                       goto err_free_host;
>>          }
>> 
>>  +       ret = mmc_of_parse(mmc);
>>  +       if (ret) {
>>  +               if (ret != -EPROBE_DEFER)
>>  +                       dev_err(&pdev->dev,
>>  +                               "could not parse device properties: 
>> %d\n", ret);
>>  +               goto err_free_host;
>>  +       }
>>  +
>>  +       mmc_regulator_get_supply(mmc);
>>  +
>>          host->irq = platform_get_irq(pdev, 0);
>>          if (host->irq < 0) {
>>                  ret = host->irq;
>>  --
>>  2.11.0
>> 


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/3] MIPS: DTS: jz4740: Add node for the MMC driver
  2019-01-25 20:09 ` [PATCH 2/3] MIPS: DTS: jz4740: Add node for the MMC driver Paul Cercueil
@ 2019-07-22 21:22   ` Paul Burton
  0 siblings, 0 replies; 8+ messages in thread
From: Paul Burton @ 2019-07-22 21:22 UTC (permalink / raw)
  To: Paul Cercueil
  Cc: Rob Herring, Mark Rutland, Ralf Baechle, Paul Burton,
	James Hogan, Ulf Hansson, Linus Walleij, devicetree, linux-mips,
	linux-kernel, linux-mmc, Paul Cercueil, linux-mips

Hello,

Paul Cercueil wrote:
> Add a devicetree node for the jz4740-mmc driver.
> 
> Signed-off-by: Paul Cercueil <paul@crapouillou.net>

Applied to mips-next.

Thanks,
    Paul

[ This message was auto-generated; if you believe anything is incorrect
  then please email paul.burton@mips.com to report it. ]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 3/3] MIPS: qi_lb60: Move MMC configuration to devicetree
  2019-01-25 20:09 ` [PATCH 3/3] MIPS: qi_lb60: Move MMC configuration to devicetree Paul Cercueil
@ 2019-07-22 22:30   ` Paul Burton
  0 siblings, 0 replies; 8+ messages in thread
From: Paul Burton @ 2019-07-22 22:30 UTC (permalink / raw)
  To: Paul Cercueil
  Cc: Rob Herring, Mark Rutland, Ralf Baechle, Paul Burton,
	James Hogan, Ulf Hansson, Linus Walleij, devicetree, linux-mips,
	linux-kernel, linux-mmc, Paul Cercueil, linux-mips

Hello,

Paul Cercueil wrote:
> Move the MMC configuration from the board C file to devicetree.
> 
> The 'power' GPIO was removed and instead the vmmc regulator is used,
> to follow the changes introduced in the jz4740-mmc driver.
> 
> Signed-off-by: Paul Cercueil <paul@crapouillou.net>

Applied to mips-next.

Thanks,
    Paul

[ This message was auto-generated; if you believe anything is incorrect
  then please email paul.burton@mips.com to report it. ]

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2019-07-22 22:30 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-25 20:09 [PATCH 1/3] mmc: jz4740: Remove platform data and use standard APIs Paul Cercueil
2019-01-25 20:09 ` [PATCH 2/3] MIPS: DTS: jz4740: Add node for the MMC driver Paul Cercueil
2019-07-22 21:22   ` Paul Burton
2019-01-25 20:09 ` [PATCH 3/3] MIPS: qi_lb60: Move MMC configuration to devicetree Paul Cercueil
2019-07-22 22:30   ` Paul Burton
2019-01-26 12:10 ` [PATCH 1/3] mmc: jz4740: Remove platform data and use standard APIs Linus Walleij
2019-01-28 12:02 ` Ulf Hansson
2019-01-28 12:58   ` Paul Cercueil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).