linux-mmc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/12] Remove platform callbacks from mmc_spi, sh_mmcif and sh_mobile_sdhi drivers
@ 2013-07-25 23:26 Laurent Pinchart
  2013-07-25 23:26 ` [PATCH 01/12] mmc: mmc_spi: Support CD/RO GPIOs Laurent Pinchart
                   ` (13 more replies)
  0 siblings, 14 replies; 23+ messages in thread
From: Laurent Pinchart @ 2013-07-25 23:26 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: linux-sh, linux-mmc, linux-spi, Hartley Sweeten, Ryan Mallon,
	Chris Ball, Guennadi Liakhovetski, Ian Molton

Hello,

This patch set replaces callbacks to board code with regulators and GPIOs in
the mmc_spi, sh_mmcif and sh_mobile_sdhi MMC drivers.

Most of the required infrastructure is in place already on the drivers side,
except for CD/RO GPIOs support in the mmc_spi driver. The series thus starts
with patch 01/12 that adds this feature to the mmc_spi driver.

Patches 02/12 to 05/12 remove the board callbacks from the ecovec24 and
vision_ep9307 boards. The code has been compile-tested only as I don't have
access to those boards.

Patches 06/12 to 07/12 then proceed to remove the callbacks from the drivers
themselves and from the platform data structures.

This will be a bit messy to merge, as the series interleaves patches for
drivers and board files. Given that the mmc_spi driver is marked as orphan in
MAINTAINERS and that the vision_ep9307 hasn't seen any board-specific
modification in the last couple of kernel versions one option would be to
merge all patches (or at least patches 01/12 to 06/12) through Simon's tree if
all involved maintainers agree.

The series is based on tag renesas-devel-20130725 from
git://git.kernel.org/pub/scm/linux/kernel/git/horms/renesas.git

Laurent Pinchart (12):
  mmc: mmc_spi: Support CD/RO GPIOs
  ARM: ep93xx: vision_ep9307: Use MMC CD and RO GPIO
  sh: ecovec24: Use MMC/SDHI CD and RO GPIO
  sh: ecovec24: Remove mmcif .down_pwr() callback
  sh: ecovec24: Remove MMCIF and SDHI .set_pwr() callbacks
  mmc: mmc_spi: Remove platform data .get_cd() and .get_ro() callbacks
  mmc: sh_mmcif: Remove .down_pwr() callback from platform data
  mmc: sh_mmcif: Remove .set_pwr() callback from platform data
  mmc: sh_mobile_sdhi: Remove .get_cd() callback from platform data
  mmc: sh_mobile_sdhi: Remove .set_pwr() callback from platform data
  mmc: tmio-mmc: Remove .get_cd() callback from platform data
  mmc: tmio-mmc: Remove .set_pwr() callback from platform data

 arch/arm/mach-ep93xx/vision_ep9307.c | 56 ++---------------------
 arch/sh/boards/mach-ecovec24/setup.c | 89 ++++--------------------------------
 drivers/mmc/host/mmc_spi.c           | 48 +++++++++----------
 drivers/mmc/host/of_mmc_spi.c        | 46 +++++--------------
 drivers/mmc/host/sh_mmcif.c          |  3 --
 drivers/mmc/host/sh_mobile_sdhi.c    | 18 --------
 drivers/mmc/host/tmio_mmc.h          |  1 -
 drivers/mmc/host/tmio_mmc_pio.c      | 23 +---------
 include/linux/mfd/tmio.h             |  2 -
 include/linux/mmc/sh_mmcif.h         |  2 -
 include/linux/mmc/sh_mobile_sdhi.h   |  2 -
 include/linux/spi/mmc_spi.h          | 18 ++++----
 12 files changed, 56 insertions(+), 252 deletions(-)

-- 
Regards,

Laurent Pinchart


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

* [PATCH 01/12] mmc: mmc_spi: Support CD/RO GPIOs
  2013-07-25 23:26 [PATCH 00/12] Remove platform callbacks from mmc_spi, sh_mmcif and sh_mobile_sdhi drivers Laurent Pinchart
@ 2013-07-25 23:26 ` Laurent Pinchart
  2013-07-25 23:45   ` Ryan Mallon
  2013-07-25 23:26 ` [PATCH 02/12] ARM: ep93xx: vision_ep9307: Use MMC CD and RO GPIO Laurent Pinchart
                   ` (12 subsequent siblings)
  13 siblings, 1 reply; 23+ messages in thread
From: Laurent Pinchart @ 2013-07-25 23:26 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: linux-sh, linux-mmc, linux-spi, Hartley Sweeten, Ryan Mallon,
	Chris Ball, Guennadi Liakhovetski, Ian Molton

Add support for passing CD/RO GPIO numbers directly to the mmc_spi
driver instead of relying solely on board code callbacks to retrieve the
CD/RO signals values.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 drivers/mmc/host/mmc_spi.c    | 32 +++++++++++++++++++++---------
 drivers/mmc/host/of_mmc_spi.c | 46 +++++++++++--------------------------------
 include/linux/spi/mmc_spi.h   | 11 +++++++++++
 3 files changed, 46 insertions(+), 43 deletions(-)

diff --git a/drivers/mmc/host/mmc_spi.c b/drivers/mmc/host/mmc_spi.c
index 74145d1..4e83908 100644
--- a/drivers/mmc/host/mmc_spi.c
+++ b/drivers/mmc/host/mmc_spi.c
@@ -36,6 +36,7 @@
 
 #include <linux/mmc/host.h>
 #include <linux/mmc/mmc.h>		/* for R1_SPI_* bit values */
+#include <linux/mmc/slot-gpio.h>
 
 #include <linux/spi/spi.h>
 #include <linux/spi/mmc_spi.h>
@@ -1278,11 +1279,8 @@ static int mmc_spi_get_ro(struct mmc_host *mmc)
 
 	if (host->pdata && host->pdata->get_ro)
 		return !!host->pdata->get_ro(mmc->parent);
-	/*
-	 * Board doesn't support read only detection; let the mmc core
-	 * decide what to do.
-	 */
-	return -ENOSYS;
+	else
+		return mmc_gpio_get_ro(mmc);
 }
 
 static int mmc_spi_get_cd(struct mmc_host *mmc)
@@ -1291,7 +1289,8 @@ static int mmc_spi_get_cd(struct mmc_host *mmc)
 
 	if (host->pdata && host->pdata->get_cd)
 		return !!host->pdata->get_cd(mmc->parent);
-	return -ENOSYS;
+	else
+		return mmc_gpio_get_cd(mmc);
 }
 
 static const struct mmc_host_ops mmc_spi_ops = {
@@ -1324,6 +1323,7 @@ static int mmc_spi_probe(struct spi_device *spi)
 	struct mmc_host		*mmc;
 	struct mmc_spi_host	*host;
 	int			status;
+	bool			has_ro = false;
 
 	/* We rely on full duplex transfers, mostly to reduce
 	 * per-transfer overheads (by making fewer transfers).
@@ -1448,18 +1448,32 @@ static int mmc_spi_probe(struct spi_device *spi)
 	}
 
 	/* pass platform capabilities, if any */
-	if (host->pdata)
+	if (host->pdata) {
 		mmc->caps |= host->pdata->caps;
+		mmc->caps2 |= host->pdata->caps2;
+	}
 
 	status = mmc_add_host(mmc);
 	if (status != 0)
 		goto fail_add_host;
 
+	if (host->pdata && host->pdata->flags & MMC_SPI_USE_CD_GPIO) {
+		status = mmc_gpio_request_cd(mmc, host->pdata->cd_gpio);
+		if (status != 0)
+			goto fail_add_host;
+	}
+
+	if (host->pdata && host->pdata->flags & MMC_SPI_USE_RO_GPIO) {
+		has_ro = true;
+		status = mmc_gpio_request_ro(mmc, host->pdata->ro_gpio);
+		if (status != 0)
+			goto fail_add_host;
+	}
+
 	dev_info(&spi->dev, "SD/MMC host %s%s%s%s%s\n",
 			dev_name(&mmc->class_dev),
 			host->dma_dev ? "" : ", no DMA",
-			(host->pdata && host->pdata->get_ro)
-				? "" : ", no WP",
+			has_ro ? "" : ", no WP",
 			(host->pdata && host->pdata->setpower)
 				? "" : ", no poweroff",
 			(mmc->caps & MMC_CAP_NEEDS_POLL)
diff --git a/drivers/mmc/host/of_mmc_spi.c b/drivers/mmc/host/of_mmc_spi.c
index d720b5e..6e218fb 100644
--- a/drivers/mmc/host/of_mmc_spi.c
+++ b/drivers/mmc/host/of_mmc_spi.c
@@ -50,25 +50,6 @@ static struct of_mmc_spi *to_of_mmc_spi(struct device *dev)
 	return container_of(dev->platform_data, struct of_mmc_spi, pdata);
 }
 
-static int of_mmc_spi_read_gpio(struct device *dev, int gpio_num)
-{
-	struct of_mmc_spi *oms = to_of_mmc_spi(dev);
-	bool active_low = oms->alow_gpios[gpio_num];
-	bool value = gpio_get_value(oms->gpios[gpio_num]);
-
-	return active_low ^ value;
-}
-
-static int of_mmc_spi_get_cd(struct device *dev)
-{
-	return of_mmc_spi_read_gpio(dev, CD_GPIO);
-}
-
-static int of_mmc_spi_get_ro(struct device *dev)
-{
-	return of_mmc_spi_read_gpio(dev, WP_GPIO);
-}
-
 static int of_mmc_spi_init(struct device *dev,
 			   irqreturn_t (*irqhandler)(int, void *), void *mmc)
 {
@@ -130,20 +111,22 @@ struct mmc_spi_platform_data *mmc_spi_get_pdata(struct spi_device *spi)
 		if (!gpio_is_valid(oms->gpios[i]))
 			continue;
 
-		ret = gpio_request(oms->gpios[i], dev_name(dev));
-		if (ret < 0) {
-			oms->gpios[i] = -EINVAL;
-			continue;
-		}
-
 		if (gpio_flags & OF_GPIO_ACTIVE_LOW)
 			oms->alow_gpios[i] = true;
 	}
 
-	if (gpio_is_valid(oms->gpios[CD_GPIO]))
-		oms->pdata.get_cd = of_mmc_spi_get_cd;
-	if (gpio_is_valid(oms->gpios[WP_GPIO]))
-		oms->pdata.get_ro = of_mmc_spi_get_ro;
+	if (gpio_is_valid(oms->gpios[CD_GPIO])) {
+		oms->pdata.cd_gpio = oms->gpios[CD_GPIO];
+		oms->pdata.flags |= MMC_SPI_USE_CD_GPIO;
+		if (!oms->alow_gpios[CD_GPIO])
+			oms->pdata.caps2 |= MMC_CAP2_CD_ACTIVE_HIGH;
+	}
+	if (gpio_is_valid(oms->gpios[WP_GPIO])) {
+		oms->pdata.ro_gpio = oms->gpios[WP_GPIO];
+		oms->pdata.flags |= MMC_SPI_USE_RO_GPIO;
+		if (!oms->alow_gpios[WP_GPIO])
+			oms->pdata.caps2 |= MMC_CAP2_RO_ACTIVE_HIGH;
+	}
 
 	oms->detect_irq = irq_of_parse_and_map(np, 0);
 	if (oms->detect_irq != 0) {
@@ -166,15 +149,10 @@ void mmc_spi_put_pdata(struct spi_device *spi)
 	struct device *dev = &spi->dev;
 	struct device_node *np = dev->of_node;
 	struct of_mmc_spi *oms = to_of_mmc_spi(dev);
-	int i;
 
 	if (!dev->platform_data || !np)
 		return;
 
-	for (i = 0; i < ARRAY_SIZE(oms->gpios); i++) {
-		if (gpio_is_valid(oms->gpios[i]))
-			gpio_free(oms->gpios[i]);
-	}
 	kfree(oms);
 	dev->platform_data = NULL;
 }
diff --git a/include/linux/spi/mmc_spi.h b/include/linux/spi/mmc_spi.h
index 32be8db..a54da4a 100644
--- a/include/linux/spi/mmc_spi.h
+++ b/include/linux/spi/mmc_spi.h
@@ -7,6 +7,11 @@
 struct device;
 struct mmc_host;
 
+#define MMC_SPI_USE_CD_GPIO			(1 << 0)
+#define MMC_SPI_USE_RO_GPIO			(1 << 1)
+#define MMC_SPI_CD_GPIO_ACTIVE_LOW		(1 << 2)
+#define MMC_SPI_RO_GPIO_ACTIVE_LOW		(1 << 3)
+
 /* Put this in platform_data of a device being used to manage an MMC/SD
  * card slot.  (Modeled after PXA mmc glue; see that for usage examples.)
  *
@@ -30,8 +35,14 @@ struct mmc_spi_platform_data {
 	 */
 	int (*get_cd)(struct device *);
 
+	/* Card Detect and Read Only GPIOs */
+	unsigned int flags;
+	unsigned int cd_gpio;
+	unsigned int ro_gpio;
+
 	/* Capabilities to pass into mmc core (e.g. MMC_CAP_NEEDS_POLL). */
 	unsigned long caps;
+	unsigned long caps2;
 
 	/* how long to debounce card detect, in msecs */
 	u16 detect_delay;
-- 
1.8.1.5


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

* [PATCH 02/12] ARM: ep93xx: vision_ep9307: Use MMC CD and RO GPIO
  2013-07-25 23:26 [PATCH 00/12] Remove platform callbacks from mmc_spi, sh_mmcif and sh_mobile_sdhi drivers Laurent Pinchart
  2013-07-25 23:26 ` [PATCH 01/12] mmc: mmc_spi: Support CD/RO GPIOs Laurent Pinchart
@ 2013-07-25 23:26 ` Laurent Pinchart
  2013-07-25 23:33   ` H Hartley Sweeten
  2013-07-26  0:19   ` H Hartley Sweeten
  2013-07-25 23:26 ` [PATCH 03/12] sh: ecovec24: Use MMC/SDHI " Laurent Pinchart
                   ` (11 subsequent siblings)
  13 siblings, 2 replies; 23+ messages in thread
From: Laurent Pinchart @ 2013-07-25 23:26 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: linux-sh, linux-mmc, linux-spi, Hartley Sweeten, Ryan Mallon,
	Chris Ball, Guennadi Liakhovetski, Ian Molton

Pass the CD and RO GPIO numbers to the MMC SPI driver and remove the
custom .get_cd() and .get_ro() callback functions.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 arch/arm/mach-ep93xx/vision_ep9307.c | 56 +++---------------------------------
 1 file changed, 4 insertions(+), 52 deletions(-)

diff --git a/arch/arm/mach-ep93xx/vision_ep9307.c b/arch/arm/mach-ep93xx/vision_ep9307.c
index 605956f..ab94dc5 100644
--- a/arch/arm/mach-ep93xx/vision_ep9307.c
+++ b/arch/arm/mach-ep93xx/vision_ep9307.c
@@ -224,62 +224,14 @@ static struct ep93xx_spi_chip_ops vision_spi_flash_hw = {
 #define VISION_SPI_MMC_WP	EP93XX_GPIO_LINE_F(0)
 #define VISION_SPI_MMC_CD	EP93XX_GPIO_LINE_EGPIO15
 
-static struct gpio vision_spi_mmc_gpios[] = {
-	{ VISION_SPI_MMC_WP, GPIOF_DIR_IN, "mmc_spi:wp" },
-	{ VISION_SPI_MMC_CD, GPIOF_DIR_IN, "mmc_spi:cd" },
-};
-
-static int vision_spi_mmc_init(struct device *pdev,
-			irqreturn_t (*func)(int, void *), void *pdata)
-{
-	int err;
-
-	err = gpio_request_array(vision_spi_mmc_gpios,
-				 ARRAY_SIZE(vision_spi_mmc_gpios));
-	if (err)
-		return err;
-
-	err = gpio_set_debounce(VISION_SPI_MMC_CD, 1);
-	if (err)
-		goto exit_err;
-
-	err = request_irq(gpio_to_irq(VISION_SPI_MMC_CD), func,
-			IRQ_TYPE_EDGE_BOTH, "mmc_spi:cd", pdata);
-	if (err)
-		goto exit_err;
-
-	return 0;
-
-exit_err:
-	gpio_free_array(vision_spi_mmc_gpios, ARRAY_SIZE(vision_spi_mmc_gpios));
-	return err;
-
-}
-
-static void vision_spi_mmc_exit(struct device *pdev, void *pdata)
-{
-	free_irq(gpio_to_irq(VISION_SPI_MMC_CD), pdata);
-	gpio_free_array(vision_spi_mmc_gpios, ARRAY_SIZE(vision_spi_mmc_gpios));
-}
-
-static int vision_spi_mmc_get_ro(struct device *pdev)
-{
-	return !!gpio_get_value(VISION_SPI_MMC_WP);
-}
-
-static int vision_spi_mmc_get_cd(struct device *pdev)
-{
-	return !gpio_get_value(VISION_SPI_MMC_CD);
-}
-
 static struct mmc_spi_platform_data vision_spi_mmc_data = {
-	.init		= vision_spi_mmc_init,
-	.exit		= vision_spi_mmc_exit,
-	.get_ro		= vision_spi_mmc_get_ro,
-	.get_cd		= vision_spi_mmc_get_cd,
 	.detect_delay	= 100,
 	.powerup_msecs	= 100,
 	.ocr_mask	= MMC_VDD_32_33 | MMC_VDD_33_34,
+	.flags		= MMC_SPI_USE_CD_GPIO | MMC_SPI_USE_RO_GPIO,
+	.cd_gpio	= VISION_SPI_MMC_CD,
+	.ro_gpio	= VISION_SPI_MMC_WP,
+	.caps2		= MMC_CAP2_RO_ACTIVE_HIGH,
 };
 
 static int vision_spi_mmc_hw_setup(struct spi_device *spi)
-- 
1.8.1.5


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

* [PATCH 03/12] sh: ecovec24: Use MMC/SDHI CD and RO GPIO
  2013-07-25 23:26 [PATCH 00/12] Remove platform callbacks from mmc_spi, sh_mmcif and sh_mobile_sdhi drivers Laurent Pinchart
  2013-07-25 23:26 ` [PATCH 01/12] mmc: mmc_spi: Support CD/RO GPIOs Laurent Pinchart
  2013-07-25 23:26 ` [PATCH 02/12] ARM: ep93xx: vision_ep9307: Use MMC CD and RO GPIO Laurent Pinchart
@ 2013-07-25 23:26 ` Laurent Pinchart
  2013-07-25 23:26 ` [PATCH 04/12] sh: ecovec24: Remove mmcif .down_pwr() callback Laurent Pinchart
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 23+ messages in thread
From: Laurent Pinchart @ 2013-07-25 23:26 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: linux-sh, linux-mmc, linux-spi, Hartley Sweeten, Ryan Mallon,
	Chris Ball, Guennadi Liakhovetski, Ian Molton

Pass the CD and RO GPIO numbers to the MMC SPI and SDHI drivers and
remove the custom .get_cd() and .get_ro() callback functions.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 arch/sh/boards/mach-ecovec24/setup.c | 42 +++++++-----------------------------
 1 file changed, 8 insertions(+), 34 deletions(-)

diff --git a/arch/sh/boards/mach-ecovec24/setup.c b/arch/sh/boards/mach-ecovec24/setup.c
index bcbb86b..4d46700 100644
--- a/arch/sh/boards/mach-ecovec24/setup.c
+++ b/arch/sh/boards/mach-ecovec24/setup.c
@@ -620,18 +620,14 @@ static void sdhi0_set_pwr(struct platform_device *pdev, int state)
 	gpio_set_value(GPIO_PTB6, state);
 }
 
-static int sdhi0_get_cd(struct platform_device *pdev)
-{
-	return !gpio_get_value(GPIO_PTY7);
-}
-
 static struct sh_mobile_sdhi_info sdhi0_info = {
 	.dma_slave_tx	= SHDMA_SLAVE_SDHI0_TX,
 	.dma_slave_rx	= SHDMA_SLAVE_SDHI0_RX,
 	.set_pwr	= sdhi0_set_pwr,
 	.tmio_caps      = MMC_CAP_SDIO_IRQ | MMC_CAP_POWER_OFF_CARD |
 			  MMC_CAP_NEEDS_POLL,
-	.get_cd		= sdhi0_get_cd,
+	.tmio_flags	= TMIO_MMC_USE_GPIO_CD,
+	.cd_gpio	= GPIO_PTY7,
 };
 
 static struct resource sdhi0_resources[] = {
@@ -678,18 +674,14 @@ static void cn12_set_pwr(struct platform_device *pdev, int state)
 
 #if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE)
 /* SDHI1 */
-static int sdhi1_get_cd(struct platform_device *pdev)
-{
-	return !gpio_get_value(GPIO_PTW7);
-}
-
 static struct sh_mobile_sdhi_info sdhi1_info = {
 	.dma_slave_tx	= SHDMA_SLAVE_SDHI1_TX,
 	.dma_slave_rx	= SHDMA_SLAVE_SDHI1_RX,
 	.tmio_caps      = MMC_CAP_SDIO_IRQ | MMC_CAP_POWER_OFF_CARD |
 			  MMC_CAP_NEEDS_POLL,
+	.tmio_flags	= TMIO_MMC_USE_GPIO_CD,
+	.cd_gpio	= GPIO_PTW7,
 	.set_pwr	= cn12_set_pwr,
-	.get_cd		= sdhi1_get_cd,
 };
 
 static struct resource sdhi1_resources[] = {
@@ -719,27 +711,19 @@ static struct platform_device sdhi1_device = {
 #else
 
 /* MMC SPI */
-static int mmc_spi_get_ro(struct device *dev)
-{
-	return gpio_get_value(GPIO_PTY6);
-}
-
-static int mmc_spi_get_cd(struct device *dev)
-{
-	return !gpio_get_value(GPIO_PTY7);
-}
-
 static void mmc_spi_setpower(struct device *dev, unsigned int maskval)
 {
 	gpio_set_value(GPIO_PTB6, maskval ? 1 : 0);
 }
 
 static struct mmc_spi_platform_data mmc_spi_info = {
-	.get_ro = mmc_spi_get_ro,
-	.get_cd = mmc_spi_get_cd,
 	.caps = MMC_CAP_NEEDS_POLL,
+	.caps2 = MMC_CAP2_RO_ACTIVE_HIGH,
 	.ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, /* 3.3V only */
 	.setpower = mmc_spi_setpower,
+	.flags = MMC_SPI_USE_CD_GPIO | MMC_SPI_USE_RO_GPIO,
+	.cd_gpio = GPIO_PTY7,
+	.ro_gpio = GPIO_PTY6,
 };
 
 static struct spi_board_info spi_bus[] = {
@@ -1342,10 +1326,6 @@ static int __init arch_setup(void)
 	gpio_direction_input(GPIO_PTR6);
 
 	/* SD-card slot CN11 */
-	/* Card-detect, used on CN11, either with SDHI0 or with SPI */
-	gpio_request(GPIO_PTY7, NULL);
-	gpio_direction_input(GPIO_PTY7);
-
 #if defined(CONFIG_MMC_SDHI) || defined(CONFIG_MMC_SDHI_MODULE)
 	/* enable SDHI0 on CN11 (needs DS2.4 set to ON) */
 	gpio_request(GPIO_FN_SDHI0WP,  NULL);
@@ -1364,8 +1344,6 @@ static int __init arch_setup(void)
 	gpio_direction_output(GPIO_PTM4, 1); /* active low CS */
 	gpio_request(GPIO_PTB6, NULL); /* 3.3V power control */
 	gpio_direction_output(GPIO_PTB6, 0); /* disable power by default */
-	gpio_request(GPIO_PTY6, NULL); /* write protect */
-	gpio_direction_input(GPIO_PTY6);
 
 	spi_register_board_info(spi_bus, ARRAY_SIZE(spi_bus));
 #endif
@@ -1395,10 +1373,6 @@ static int __init arch_setup(void)
 	gpio_request(GPIO_FN_SDHI1D1,  NULL);
 	gpio_request(GPIO_FN_SDHI1D0,  NULL);
 
-	/* Card-detect, used on CN12 with SDHI1 */
-	gpio_request(GPIO_PTW7, NULL);
-	gpio_direction_input(GPIO_PTW7);
-
 	cn12_enabled = true;
 #endif
 
-- 
1.8.1.5


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

* [PATCH 04/12] sh: ecovec24: Remove mmcif .down_pwr() callback
  2013-07-25 23:26 [PATCH 00/12] Remove platform callbacks from mmc_spi, sh_mmcif and sh_mobile_sdhi drivers Laurent Pinchart
                   ` (2 preceding siblings ...)
  2013-07-25 23:26 ` [PATCH 03/12] sh: ecovec24: Use MMC/SDHI " Laurent Pinchart
@ 2013-07-25 23:26 ` Laurent Pinchart
  2013-07-25 23:26 ` [PATCH 05/12] sh: ecovec24: Remove MMCIF and SDHI .set_pwr() callbacks Laurent Pinchart
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 23+ messages in thread
From: Laurent Pinchart @ 2013-07-25 23:26 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: linux-sh, linux-mmc, linux-spi, Hartley Sweeten, Ryan Mallon,
	Chris Ball, Guennadi Liakhovetski, Ian Molton

The callback isn't used by the mmcif driver, don't initialize it in
board code.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 arch/sh/boards/mach-ecovec24/setup.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/arch/sh/boards/mach-ecovec24/setup.c b/arch/sh/boards/mach-ecovec24/setup.c
index 4d46700..e1b6aa3 100644
--- a/arch/sh/boards/mach-ecovec24/setup.c
+++ b/arch/sh/boards/mach-ecovec24/setup.c
@@ -983,11 +983,6 @@ static struct platform_device vou_device = {
 
 #if defined(CONFIG_MMC_SH_MMCIF) || defined(CONFIG_MMC_SH_MMCIF_MODULE)
 /* SH_MMCIF */
-static void mmcif_down_pwr(struct platform_device *pdev)
-{
-	cn12_set_pwr(pdev, 0);
-}
-
 static struct resource sh_mmcif_resources[] = {
 	[0] = {
 		.name	= "SH_MMCIF",
@@ -1009,7 +1004,6 @@ static struct resource sh_mmcif_resources[] = {
 
 static struct sh_mmcif_plat_data sh_mmcif_plat = {
 	.set_pwr	= cn12_set_pwr,
-	.down_pwr	= mmcif_down_pwr,
 	.sup_pclk	= 0, /* SH7724: Max Pclk/2 */
 	.caps		= MMC_CAP_4_BIT_DATA |
 			  MMC_CAP_8_BIT_DATA |
-- 
1.8.1.5


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

* [PATCH 05/12] sh: ecovec24: Remove MMCIF and SDHI .set_pwr() callbacks
  2013-07-25 23:26 [PATCH 00/12] Remove platform callbacks from mmc_spi, sh_mmcif and sh_mobile_sdhi drivers Laurent Pinchart
                   ` (3 preceding siblings ...)
  2013-07-25 23:26 ` [PATCH 04/12] sh: ecovec24: Remove mmcif .down_pwr() callback Laurent Pinchart
@ 2013-07-25 23:26 ` Laurent Pinchart
  2013-07-25 23:26 ` [PATCH 06/12] mmc: mmc_spi: Remove platform data .get_cd() and .get_ro() callbacks Laurent Pinchart
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 23+ messages in thread
From: Laurent Pinchart @ 2013-07-25 23:26 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: linux-sh, linux-mmc, linux-spi, Hartley Sweeten, Ryan Mallon,
	Chris Ball, Guennadi Liakhovetski, Ian Molton

The MMCIF and SHDI platform data .set_pwr() callbacks are used to
control the vmmc/vqmmc power supplies. As the power supplies already
register control GPIOs there's no need to perform the operation
manually. Remove the callback functions.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 arch/sh/boards/mach-ecovec24/setup.c | 41 ------------------------------------
 1 file changed, 41 deletions(-)

diff --git a/arch/sh/boards/mach-ecovec24/setup.c b/arch/sh/boards/mach-ecovec24/setup.c
index e1b6aa3..60bf82c 100644
--- a/arch/sh/boards/mach-ecovec24/setup.c
+++ b/arch/sh/boards/mach-ecovec24/setup.c
@@ -601,29 +601,9 @@ static struct platform_device sdhi0_power = {
 	},
 };
 
-static void sdhi0_set_pwr(struct platform_device *pdev, int state)
-{
-	static int power_gpio = -EINVAL;
-
-	if (power_gpio < 0) {
-		int ret = gpio_request(GPIO_PTB6, NULL);
-		if (!ret) {
-			power_gpio = GPIO_PTB6;
-			gpio_direction_output(power_gpio, 0);
-		}
-	}
-
-	/*
-	 * Toggle the GPIO regardless, whether we managed to grab it above or
-	 * the fixed regulator driver did.
-	 */
-	gpio_set_value(GPIO_PTB6, state);
-}
-
 static struct sh_mobile_sdhi_info sdhi0_info = {
 	.dma_slave_tx	= SHDMA_SLAVE_SDHI0_TX,
 	.dma_slave_rx	= SHDMA_SLAVE_SDHI0_RX,
-	.set_pwr	= sdhi0_set_pwr,
 	.tmio_caps      = MMC_CAP_SDIO_IRQ | MMC_CAP_POWER_OFF_CARD |
 			  MMC_CAP_NEEDS_POLL,
 	.tmio_flags	= TMIO_MMC_USE_GPIO_CD,
@@ -653,25 +633,6 @@ static struct platform_device sdhi0_device = {
 	},
 };
 
-static void cn12_set_pwr(struct platform_device *pdev, int state)
-{
-	static int power_gpio = -EINVAL;
-
-	if (power_gpio < 0) {
-		int ret = gpio_request(GPIO_PTB7, NULL);
-		if (!ret) {
-			power_gpio = GPIO_PTB7;
-			gpio_direction_output(power_gpio, 0);
-		}
-	}
-
-	/*
-	 * Toggle the GPIO regardless, whether we managed to grab it above or
-	 * the fixed regulator driver did.
-	 */
-	gpio_set_value(GPIO_PTB7, state);
-}
-
 #if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE)
 /* SDHI1 */
 static struct sh_mobile_sdhi_info sdhi1_info = {
@@ -681,7 +642,6 @@ static struct sh_mobile_sdhi_info sdhi1_info = {
 			  MMC_CAP_NEEDS_POLL,
 	.tmio_flags	= TMIO_MMC_USE_GPIO_CD,
 	.cd_gpio	= GPIO_PTW7,
-	.set_pwr	= cn12_set_pwr,
 };
 
 static struct resource sdhi1_resources[] = {
@@ -1003,7 +963,6 @@ static struct resource sh_mmcif_resources[] = {
 };
 
 static struct sh_mmcif_plat_data sh_mmcif_plat = {
-	.set_pwr	= cn12_set_pwr,
 	.sup_pclk	= 0, /* SH7724: Max Pclk/2 */
 	.caps		= MMC_CAP_4_BIT_DATA |
 			  MMC_CAP_8_BIT_DATA |
-- 
1.8.1.5


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

* [PATCH 06/12] mmc: mmc_spi: Remove platform data .get_cd() and .get_ro() callbacks
  2013-07-25 23:26 [PATCH 00/12] Remove platform callbacks from mmc_spi, sh_mmcif and sh_mobile_sdhi drivers Laurent Pinchart
                   ` (4 preceding siblings ...)
  2013-07-25 23:26 ` [PATCH 05/12] sh: ecovec24: Remove MMCIF and SDHI .set_pwr() callbacks Laurent Pinchart
@ 2013-07-25 23:26 ` Laurent Pinchart
  2013-07-25 23:26 ` [PATCH 07/12] mmc: sh_mmcif: Remove .down_pwr() callback from platform data Laurent Pinchart
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 23+ messages in thread
From: Laurent Pinchart @ 2013-07-25 23:26 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: linux-sh, linux-mmc, linux-spi, Hartley Sweeten, Ryan Mallon,
	Chris Ball, Guennadi Liakhovetski, Ian Molton

All platforms now pass the CD and RO GPIOs to the MMC SPI driver, those
callbacks are not used anymore. Remove them.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 drivers/mmc/host/mmc_spi.c  | 24 ++----------------------
 include/linux/spi/mmc_spi.h |  9 ---------
 2 files changed, 2 insertions(+), 31 deletions(-)

diff --git a/drivers/mmc/host/mmc_spi.c b/drivers/mmc/host/mmc_spi.c
index 4e83908..19aa660 100644
--- a/drivers/mmc/host/mmc_spi.c
+++ b/drivers/mmc/host/mmc_spi.c
@@ -1273,31 +1273,11 @@ static void mmc_spi_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 	}
 }
 
-static int mmc_spi_get_ro(struct mmc_host *mmc)
-{
-	struct mmc_spi_host *host = mmc_priv(mmc);
-
-	if (host->pdata && host->pdata->get_ro)
-		return !!host->pdata->get_ro(mmc->parent);
-	else
-		return mmc_gpio_get_ro(mmc);
-}
-
-static int mmc_spi_get_cd(struct mmc_host *mmc)
-{
-	struct mmc_spi_host *host = mmc_priv(mmc);
-
-	if (host->pdata && host->pdata->get_cd)
-		return !!host->pdata->get_cd(mmc->parent);
-	else
-		return mmc_gpio_get_cd(mmc);
-}
-
 static const struct mmc_host_ops mmc_spi_ops = {
 	.request	= mmc_spi_request,
 	.set_ios	= mmc_spi_set_ios,
-	.get_ro		= mmc_spi_get_ro,
-	.get_cd		= mmc_spi_get_cd,
+	.get_ro		= mmc_gpio_get_ro,
+	.get_cd		= mmc_gpio_get_cd,
 };
 
 
diff --git a/include/linux/spi/mmc_spi.h b/include/linux/spi/mmc_spi.h
index a54da4a..46cc2f8 100644
--- a/include/linux/spi/mmc_spi.h
+++ b/include/linux/spi/mmc_spi.h
@@ -26,15 +26,6 @@ struct mmc_spi_platform_data {
 		void *);
 	void (*exit)(struct device *, void *);
 
-	/* sense switch on sd cards */
-	int (*get_ro)(struct device *);
-
-	/*
-	 * If board does not use CD interrupts, driver can optimize polling
-	 * using this function.
-	 */
-	int (*get_cd)(struct device *);
-
 	/* Card Detect and Read Only GPIOs */
 	unsigned int flags;
 	unsigned int cd_gpio;
-- 
1.8.1.5


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

* [PATCH 07/12] mmc: sh_mmcif: Remove .down_pwr() callback from platform data
  2013-07-25 23:26 [PATCH 00/12] Remove platform callbacks from mmc_spi, sh_mmcif and sh_mobile_sdhi drivers Laurent Pinchart
                   ` (5 preceding siblings ...)
  2013-07-25 23:26 ` [PATCH 06/12] mmc: mmc_spi: Remove platform data .get_cd() and .get_ro() callbacks Laurent Pinchart
@ 2013-07-25 23:26 ` Laurent Pinchart
  2013-07-25 23:26 ` [PATCH 08/12] mmc: sh_mmcif: Remove .set_pwr() " Laurent Pinchart
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 23+ messages in thread
From: Laurent Pinchart @ 2013-07-25 23:26 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: linux-sh, linux-mmc, linux-spi, Hartley Sweeten, Ryan Mallon,
	Chris Ball, Guennadi Liakhovetski, Ian Molton

The callback isn't used by the driver and isn't initialized by board
code. Remove it.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 include/linux/mmc/sh_mmcif.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/include/linux/mmc/sh_mmcif.h b/include/linux/mmc/sh_mmcif.h
index e7d5dd6..39011eb 100644
--- a/include/linux/mmc/sh_mmcif.h
+++ b/include/linux/mmc/sh_mmcif.h
@@ -34,7 +34,6 @@
 
 struct sh_mmcif_plat_data {
 	void (*set_pwr)(struct platform_device *pdev, int state);
-	void (*down_pwr)(struct platform_device *pdev);
 	int (*get_cd)(struct platform_device *pdef);
 	unsigned int		slave_id_tx;	/* embedded slave_id_[tr]x */
 	unsigned int		slave_id_rx;
-- 
1.8.1.5


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

* [PATCH 08/12] mmc: sh_mmcif: Remove .set_pwr() callback from platform data
  2013-07-25 23:26 [PATCH 00/12] Remove platform callbacks from mmc_spi, sh_mmcif and sh_mobile_sdhi drivers Laurent Pinchart
                   ` (6 preceding siblings ...)
  2013-07-25 23:26 ` [PATCH 07/12] mmc: sh_mmcif: Remove .down_pwr() callback from platform data Laurent Pinchart
@ 2013-07-25 23:26 ` Laurent Pinchart
  2013-07-25 23:26 ` [PATCH 09/12] mmc: sh_mobile_sdhi: Remove .get_cd() " Laurent Pinchart
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 23+ messages in thread
From: Laurent Pinchart @ 2013-07-25 23:26 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: linux-sh, linux-mmc, linux-spi, Hartley Sweeten, Ryan Mallon,
	Chris Ball, Guennadi Liakhovetski, Ian Molton

The .set_pwr() callback isn't used anymore as all platforms register
GPIO-controlled regulators. Remove it.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 drivers/mmc/host/sh_mmcif.c  | 3 ---
 include/linux/mmc/sh_mmcif.h | 1 -
 2 files changed, 4 deletions(-)

diff --git a/drivers/mmc/host/sh_mmcif.c b/drivers/mmc/host/sh_mmcif.c
index 6706b5e..b827c58 100644
--- a/drivers/mmc/host/sh_mmcif.c
+++ b/drivers/mmc/host/sh_mmcif.c
@@ -956,11 +956,8 @@ static int sh_mmcif_clk_update(struct sh_mmcif_host *host)
 
 static void sh_mmcif_set_power(struct sh_mmcif_host *host, struct mmc_ios *ios)
 {
-	struct sh_mmcif_plat_data *pd = host->pd->dev.platform_data;
 	struct mmc_host *mmc = host->mmc;
 
-	if (pd && pd->set_pwr)
-		pd->set_pwr(host->pd, ios->power_mode != MMC_POWER_OFF);
 	if (!IS_ERR(mmc->supply.vmmc))
 		/* Errors ignored... */
 		mmc_regulator_set_ocr(mmc, mmc->supply.vmmc,
diff --git a/include/linux/mmc/sh_mmcif.h b/include/linux/mmc/sh_mmcif.h
index 39011eb..767fac5 100644
--- a/include/linux/mmc/sh_mmcif.h
+++ b/include/linux/mmc/sh_mmcif.h
@@ -33,7 +33,6 @@
  */
 
 struct sh_mmcif_plat_data {
-	void (*set_pwr)(struct platform_device *pdev, int state);
 	int (*get_cd)(struct platform_device *pdef);
 	unsigned int		slave_id_tx;	/* embedded slave_id_[tr]x */
 	unsigned int		slave_id_rx;
-- 
1.8.1.5


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

* [PATCH 09/12] mmc: sh_mobile_sdhi: Remove .get_cd() callback from platform data
  2013-07-25 23:26 [PATCH 00/12] Remove platform callbacks from mmc_spi, sh_mmcif and sh_mobile_sdhi drivers Laurent Pinchart
                   ` (7 preceding siblings ...)
  2013-07-25 23:26 ` [PATCH 08/12] mmc: sh_mmcif: Remove .set_pwr() " Laurent Pinchart
@ 2013-07-25 23:26 ` Laurent Pinchart
  2013-07-25 23:26 ` [PATCH 10/12] mmc: sh_mobile_sdhi: Remove .set_pwr() " Laurent Pinchart
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 23+ messages in thread
From: Laurent Pinchart @ 2013-07-25 23:26 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: linux-sh, linux-mmc, linux-spi, Hartley Sweeten, Ryan Mallon,
	Chris Ball, Guennadi Liakhovetski, Ian Molton

All platforms pass the CD GPIO number to the driver in the .cd_gpio
field. The .get_cd() callback isn't used anymore, remove it.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 drivers/mmc/host/sh_mobile_sdhi.c  | 9 ---------
 include/linux/mmc/sh_mobile_sdhi.h | 1 -
 2 files changed, 10 deletions(-)

diff --git a/drivers/mmc/host/sh_mobile_sdhi.c b/drivers/mmc/host/sh_mobile_sdhi.c
index ebea749..663a672 100644
--- a/drivers/mmc/host/sh_mobile_sdhi.c
+++ b/drivers/mmc/host/sh_mobile_sdhi.c
@@ -77,13 +77,6 @@ static void sh_mobile_sdhi_set_pwr(struct platform_device *pdev, int state)
 	p->set_pwr(pdev, state);
 }
 
-static int sh_mobile_sdhi_get_cd(struct platform_device *pdev)
-{
-	struct sh_mobile_sdhi_info *p = pdev->dev.platform_data;
-
-	return p->get_cd(pdev);
-}
-
 static int sh_mobile_sdhi_wait_idle(struct tmio_mmc_host *host)
 {
 	int timeout = 1000;
@@ -182,8 +175,6 @@ static int sh_mobile_sdhi_probe(struct platform_device *pdev)
 		mmc_data->cd_gpio = p->cd_gpio;
 		if (p->set_pwr)
 			mmc_data->set_pwr = sh_mobile_sdhi_set_pwr;
-		if (p->get_cd)
-			mmc_data->get_cd = sh_mobile_sdhi_get_cd;
 
 		if (p->dma_slave_tx > 0 && p->dma_slave_rx > 0) {
 			/*
diff --git a/include/linux/mmc/sh_mobile_sdhi.h b/include/linux/mmc/sh_mobile_sdhi.h
index b76bcf0..f31c692 100644
--- a/include/linux/mmc/sh_mobile_sdhi.h
+++ b/include/linux/mmc/sh_mobile_sdhi.h
@@ -26,7 +26,6 @@ struct sh_mobile_sdhi_info {
 	u32 tmio_ocr_mask;	/* available MMC voltages */
 	unsigned int cd_gpio;
 	void (*set_pwr)(struct platform_device *pdev, int state);
-	int (*get_cd)(struct platform_device *pdev);
 
 	/* callbacks for board specific setup code */
 	int (*init)(struct platform_device *pdev,
-- 
1.8.1.5


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

* [PATCH 10/12] mmc: sh_mobile_sdhi: Remove .set_pwr() callback from platform data
  2013-07-25 23:26 [PATCH 00/12] Remove platform callbacks from mmc_spi, sh_mmcif and sh_mobile_sdhi drivers Laurent Pinchart
                   ` (8 preceding siblings ...)
  2013-07-25 23:26 ` [PATCH 09/12] mmc: sh_mobile_sdhi: Remove .get_cd() " Laurent Pinchart
@ 2013-07-25 23:26 ` Laurent Pinchart
  2013-07-25 23:26 ` [PATCH 11/12] mmc: tmio-mmc: Remove .get_cd() " Laurent Pinchart
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 23+ messages in thread
From: Laurent Pinchart @ 2013-07-25 23:26 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: linux-sh, linux-mmc, linux-spi, Hartley Sweeten, Ryan Mallon,
	Chris Ball, Guennadi Liakhovetski, Ian Molton

The .set_pwr() callback isn't used anymore as all platforms register
GPIO-controlled regulators. Remove it.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 drivers/mmc/host/sh_mobile_sdhi.c  | 9 ---------
 include/linux/mmc/sh_mobile_sdhi.h | 1 -
 2 files changed, 10 deletions(-)

diff --git a/drivers/mmc/host/sh_mobile_sdhi.c b/drivers/mmc/host/sh_mobile_sdhi.c
index 663a672..b3fd2c3 100644
--- a/drivers/mmc/host/sh_mobile_sdhi.c
+++ b/drivers/mmc/host/sh_mobile_sdhi.c
@@ -70,13 +70,6 @@ static void sh_mobile_sdhi_clk_disable(struct platform_device *pdev)
 	clk_disable(priv->clk);
 }
 
-static void sh_mobile_sdhi_set_pwr(struct platform_device *pdev, int state)
-{
-	struct sh_mobile_sdhi_info *p = pdev->dev.platform_data;
-
-	p->set_pwr(pdev, state);
-}
-
 static int sh_mobile_sdhi_wait_idle(struct tmio_mmc_host *host)
 {
 	int timeout = 1000;
@@ -173,8 +166,6 @@ static int sh_mobile_sdhi_probe(struct platform_device *pdev)
 		mmc_data->capabilities |= p->tmio_caps;
 		mmc_data->capabilities2 |= p->tmio_caps2;
 		mmc_data->cd_gpio = p->cd_gpio;
-		if (p->set_pwr)
-			mmc_data->set_pwr = sh_mobile_sdhi_set_pwr;
 
 		if (p->dma_slave_tx > 0 && p->dma_slave_rx > 0) {
 			/*
diff --git a/include/linux/mmc/sh_mobile_sdhi.h b/include/linux/mmc/sh_mobile_sdhi.h
index f31c692..68927ae 100644
--- a/include/linux/mmc/sh_mobile_sdhi.h
+++ b/include/linux/mmc/sh_mobile_sdhi.h
@@ -25,7 +25,6 @@ struct sh_mobile_sdhi_info {
 	unsigned long tmio_caps2;
 	u32 tmio_ocr_mask;	/* available MMC voltages */
 	unsigned int cd_gpio;
-	void (*set_pwr)(struct platform_device *pdev, int state);
 
 	/* callbacks for board specific setup code */
 	int (*init)(struct platform_device *pdev,
-- 
1.8.1.5


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

* [PATCH 11/12] mmc: tmio-mmc: Remove .get_cd() callback from platform data
  2013-07-25 23:26 [PATCH 00/12] Remove platform callbacks from mmc_spi, sh_mmcif and sh_mobile_sdhi drivers Laurent Pinchart
                   ` (9 preceding siblings ...)
  2013-07-25 23:26 ` [PATCH 10/12] mmc: sh_mobile_sdhi: Remove .set_pwr() " Laurent Pinchart
@ 2013-07-25 23:26 ` Laurent Pinchart
  2013-07-25 23:26 ` [PATCH 12/12] mmc: tmio-mmc: Remove .set_pwr() " Laurent Pinchart
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 23+ messages in thread
From: Laurent Pinchart @ 2013-07-25 23:26 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: linux-sh, linux-mmc, linux-spi, Hartley Sweeten, Ryan Mallon,
	Chris Ball, Guennadi Liakhovetski, Ian Molton

All platforms pass the CD GPIO number to the driver in the .cd_gpio
field. The .get_cd() callback isn't used anymore, remove it

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 drivers/mmc/host/tmio_mmc_pio.c | 16 +---------------
 include/linux/mfd/tmio.h        |  1 -
 2 files changed, 1 insertion(+), 16 deletions(-)

diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c
index b72edb7..a335fb8 100644
--- a/drivers/mmc/host/tmio_mmc_pio.c
+++ b/drivers/mmc/host/tmio_mmc_pio.c
@@ -932,25 +932,11 @@ static int tmio_mmc_get_ro(struct mmc_host *mmc)
 		 (sd_ctrl_read32(host, CTL_STATUS) & TMIO_STAT_WRPROTECT));
 }
 
-static int tmio_mmc_get_cd(struct mmc_host *mmc)
-{
-	struct tmio_mmc_host *host = mmc_priv(mmc);
-	struct tmio_mmc_data *pdata = host->pdata;
-	int ret = mmc_gpio_get_cd(mmc);
-	if (ret >= 0)
-		return ret;
-
-	if (!pdata->get_cd)
-		return -ENOSYS;
-	else
-		return pdata->get_cd(host->pdev);
-}
-
 static const struct mmc_host_ops tmio_mmc_ops = {
 	.request	= tmio_mmc_request,
 	.set_ios	= tmio_mmc_set_ios,
 	.get_ro         = tmio_mmc_get_ro,
-	.get_cd		= tmio_mmc_get_cd,
+	.get_cd		= mmc_gpio_get_cd,
 	.enable_sdio_irq = tmio_mmc_enable_sdio_irq,
 };
 
diff --git a/include/linux/mfd/tmio.h b/include/linux/mfd/tmio.h
index ce35113..b22883d 100644
--- a/include/linux/mfd/tmio.h
+++ b/include/linux/mfd/tmio.h
@@ -108,7 +108,6 @@ struct tmio_mmc_data {
 	unsigned int			cd_gpio;
 	void (*set_pwr)(struct platform_device *host, int state);
 	void (*set_clk_div)(struct platform_device *host, int state);
-	int (*get_cd)(struct platform_device *host);
 	int (*write16_hook)(struct tmio_mmc_host *host, int addr);
 	/* clock management callbacks */
 	int (*clk_enable)(struct platform_device *pdev, unsigned int *f);
-- 
1.8.1.5


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

* [PATCH 12/12] mmc: tmio-mmc: Remove .set_pwr() callback from platform data
  2013-07-25 23:26 [PATCH 00/12] Remove platform callbacks from mmc_spi, sh_mmcif and sh_mobile_sdhi drivers Laurent Pinchart
                   ` (10 preceding siblings ...)
  2013-07-25 23:26 ` [PATCH 11/12] mmc: tmio-mmc: Remove .get_cd() " Laurent Pinchart
@ 2013-07-25 23:26 ` Laurent Pinchart
  2013-07-25 23:37 ` [PATCH 00/12] Remove platform callbacks from mmc_spi, sh_mmcif and sh_mobile_sdhi drivers Ryan Mallon
  2013-07-26  7:01 ` Guennadi Liakhovetski
  13 siblings, 0 replies; 23+ messages in thread
From: Laurent Pinchart @ 2013-07-25 23:26 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: linux-sh, linux-mmc, linux-spi, Hartley Sweeten, Ryan Mallon,
	Chris Ball, Guennadi Liakhovetski, Ian Molton

The .set_pwr() callback isn't used anymore as all platforms register
GPIO-controlled regulators. Remove it.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 drivers/mmc/host/tmio_mmc.h     | 1 -
 drivers/mmc/host/tmio_mmc_pio.c | 7 -------
 include/linux/mfd/tmio.h        | 1 -
 3 files changed, 9 deletions(-)

diff --git a/drivers/mmc/host/tmio_mmc.h b/drivers/mmc/host/tmio_mmc.h
index 86fd21e..39c2f45 100644
--- a/drivers/mmc/host/tmio_mmc.h
+++ b/drivers/mmc/host/tmio_mmc.h
@@ -68,7 +68,6 @@ struct tmio_mmc_host {
 	enum tmio_mmc_power	power;
 
 	/* Callbacks for clock / power control */
-	void (*set_pwr)(struct platform_device *host, int state);
 	void (*set_clk_div)(struct platform_device *host, int state);
 
 	/* pio related stuff */
diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c
index a335fb8..0cd37e2 100644
--- a/drivers/mmc/host/tmio_mmc_pio.c
+++ b/drivers/mmc/host/tmio_mmc_pio.c
@@ -777,9 +777,6 @@ static void tmio_mmc_power_on(struct tmio_mmc_host *host, unsigned short vdd)
 
 	/* .set_ios() is returning void, so, no chance to report an error */
 
-	if (host->set_pwr)
-		host->set_pwr(host->pdev, 1);
-
 	if (!IS_ERR(mmc->supply.vmmc)) {
 		ret = mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, vdd);
 		/*
@@ -809,9 +806,6 @@ static void tmio_mmc_power_off(struct tmio_mmc_host *host)
 
 	if (!IS_ERR(mmc->supply.vmmc))
 		mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, 0);
-
-	if (host->set_pwr)
-		host->set_pwr(host->pdev, 0);
 }
 
 /* Set MMC clock / power.
@@ -998,7 +992,6 @@ int tmio_mmc_host_probe(struct tmio_mmc_host **host,
 	_host->pdev = pdev;
 	platform_set_drvdata(pdev, mmc);
 
-	_host->set_pwr = pdata->set_pwr;
 	_host->set_clk_div = pdata->set_clk_div;
 
 	/* SD control register space size is 0x200, 0x400 for bus_shift=1 */
diff --git a/include/linux/mfd/tmio.h b/include/linux/mfd/tmio.h
index b22883d..baa2346 100644
--- a/include/linux/mfd/tmio.h
+++ b/include/linux/mfd/tmio.h
@@ -106,7 +106,6 @@ struct tmio_mmc_data {
 	struct tmio_mmc_dma		*dma;
 	struct device			*dev;
 	unsigned int			cd_gpio;
-	void (*set_pwr)(struct platform_device *host, int state);
 	void (*set_clk_div)(struct platform_device *host, int state);
 	int (*write16_hook)(struct tmio_mmc_host *host, int addr);
 	/* clock management callbacks */
-- 
1.8.1.5


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

* RE: [PATCH 02/12] ARM: ep93xx: vision_ep9307: Use MMC CD and RO GPIO
  2013-07-25 23:26 ` [PATCH 02/12] ARM: ep93xx: vision_ep9307: Use MMC CD and RO GPIO Laurent Pinchart
@ 2013-07-25 23:33   ` H Hartley Sweeten
  2013-07-26  0:19   ` H Hartley Sweeten
  1 sibling, 0 replies; 23+ messages in thread
From: H Hartley Sweeten @ 2013-07-25 23:33 UTC (permalink / raw)
  To: Laurent Pinchart, linux-arm-kernel
  Cc: Ryan Mallon, linux-sh, linux-mmc, linux-spi, Ian Molton,
	Chris Ball, Guennadi Liakhovetski

On Thursday, July 25, 2013 4:27 PM, Laurent Pinchart wrote:
>
> Pass the CD and RO GPIO numbers to the MMC SPI driver and remove the
> custom .get_cd() and .get_ro() callback functions.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> ---
>  arch/arm/mach-ep93xx/vision_ep9307.c | 56 +++---------------------------------
>  1 file changed, 4 insertions(+), 52 deletions(-)

I'll try testing this tomorrow.

Thanks,
Hartley

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

* Re: [PATCH 00/12] Remove platform callbacks from mmc_spi, sh_mmcif and sh_mobile_sdhi drivers
  2013-07-25 23:26 [PATCH 00/12] Remove platform callbacks from mmc_spi, sh_mmcif and sh_mobile_sdhi drivers Laurent Pinchart
                   ` (11 preceding siblings ...)
  2013-07-25 23:26 ` [PATCH 12/12] mmc: tmio-mmc: Remove .set_pwr() " Laurent Pinchart
@ 2013-07-25 23:37 ` Ryan Mallon
  2013-07-26  7:01 ` Guennadi Liakhovetski
  13 siblings, 0 replies; 23+ messages in thread
From: Ryan Mallon @ 2013-07-25 23:37 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: linux-arm-kernel, linux-sh, linux-mmc, linux-spi,
	Hartley Sweeten, Chris Ball, Guennadi Liakhovetski, Ian Molton,
	Arnd Bergmann, Olof Johansson

On 26/07/13 09:26, Laurent Pinchart wrote:
> Hello,
> 
> This patch set replaces callbacks to board code with regulators and GPIOs in
> the mmc_spi, sh_mmcif and sh_mobile_sdhi MMC drivers.
> 
> Most of the required infrastructure is in place already on the drivers side,
> except for CD/RO GPIOs support in the mmc_spi driver. The series thus starts
> with patch 01/12 that adds this feature to the mmc_spi driver.
> 
> Patches 02/12 to 05/12 remove the board callbacks from the ecovec24 and
> vision_ep9307 boards. The code has been compile-tested only as I don't have
> access to those boards.
> 
> Patches 06/12 to 07/12 then proceed to remove the callbacks from the drivers
> themselves and from the platform data structures.
> 
> This will be a bit messy to merge, as the series interleaves patches for
> drivers and board files. Given that the mmc_spi driver is marked as orphan in
> MAINTAINERS and that the vision_ep9307 hasn't seen any board-specific
> modification in the last couple of kernel versions one option would be to
> merge all patches (or at least patches 01/12 to 06/12) through Simon's tree if
> all involved maintainers agree.

I'm fine with this. The ep93xx tree sees very few patches, so it would
be easier. As long as you get Ack's from Hartley, and please also check
with the arm-soc team (Arnd and Olof, Cc'ed) so that they are aware of
the patches.

> 
> The series is based on tag renesas-devel-20130725 from
> git://git.kernel.org/pub/scm/linux/kernel/git/horms/renesas.git
> 
> Laurent Pinchart (12):
>   mmc: mmc_spi: Support CD/RO GPIOs
>   ARM: ep93xx: vision_ep9307: Use MMC CD and RO GPIO
>   sh: ecovec24: Use MMC/SDHI CD and RO GPIO
>   sh: ecovec24: Remove mmcif .down_pwr() callback
>   sh: ecovec24: Remove MMCIF and SDHI .set_pwr() callbacks
>   mmc: mmc_spi: Remove platform data .get_cd() and .get_ro() callbacks
>   mmc: sh_mmcif: Remove .down_pwr() callback from platform data
>   mmc: sh_mmcif: Remove .set_pwr() callback from platform data
>   mmc: sh_mobile_sdhi: Remove .get_cd() callback from platform data
>   mmc: sh_mobile_sdhi: Remove .set_pwr() callback from platform data
>   mmc: tmio-mmc: Remove .get_cd() callback from platform data
>   mmc: tmio-mmc: Remove .set_pwr() callback from platform data
> 
>  arch/arm/mach-ep93xx/vision_ep9307.c | 56 ++---------------------
>  arch/sh/boards/mach-ecovec24/setup.c | 89 ++++--------------------------------
>  drivers/mmc/host/mmc_spi.c           | 48 +++++++++----------
>  drivers/mmc/host/of_mmc_spi.c        | 46 +++++--------------
>  drivers/mmc/host/sh_mmcif.c          |  3 --
>  drivers/mmc/host/sh_mobile_sdhi.c    | 18 --------
>  drivers/mmc/host/tmio_mmc.h          |  1 -
>  drivers/mmc/host/tmio_mmc_pio.c      | 23 +---------
>  include/linux/mfd/tmio.h             |  2 -
>  include/linux/mmc/sh_mmcif.h         |  2 -
>  include/linux/mmc/sh_mobile_sdhi.h   |  2 -
>  include/linux/spi/mmc_spi.h          | 18 ++++----
>  12 files changed, 56 insertions(+), 252 deletions(-)
> 


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

* Re: [PATCH 01/12] mmc: mmc_spi: Support CD/RO GPIOs
  2013-07-25 23:26 ` [PATCH 01/12] mmc: mmc_spi: Support CD/RO GPIOs Laurent Pinchart
@ 2013-07-25 23:45   ` Ryan Mallon
  2013-07-26  0:04     ` Laurent Pinchart
  0 siblings, 1 reply; 23+ messages in thread
From: Ryan Mallon @ 2013-07-25 23:45 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: linux-arm-kernel, linux-sh, linux-mmc, linux-spi,
	Hartley Sweeten, Chris Ball, Guennadi Liakhovetski, Ian Molton

On 26/07/13 09:26, Laurent Pinchart wrote:
> Add support for passing CD/RO GPIO numbers directly to the mmc_spi
> driver instead of relying solely on board code callbacks to retrieve the
> CD/RO signals values.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> ---
>  drivers/mmc/host/mmc_spi.c    | 32 +++++++++++++++++++++---------
>  drivers/mmc/host/of_mmc_spi.c | 46 +++++++++++--------------------------------
>  include/linux/spi/mmc_spi.h   | 11 +++++++++++
>  3 files changed, 46 insertions(+), 43 deletions(-)
> 
> diff --git a/drivers/mmc/host/mmc_spi.c b/drivers/mmc/host/mmc_spi.c
> index 74145d1..4e83908 100644
> --- a/drivers/mmc/host/mmc_spi.c
> +++ b/drivers/mmc/host/mmc_spi.c
> @@ -36,6 +36,7 @@
>  
>  #include <linux/mmc/host.h>
>  #include <linux/mmc/mmc.h>		/* for R1_SPI_* bit values */
> +#include <linux/mmc/slot-gpio.h>
>  
>  #include <linux/spi/spi.h>
>  #include <linux/spi/mmc_spi.h>
> @@ -1278,11 +1279,8 @@ static int mmc_spi_get_ro(struct mmc_host *mmc)
>  
>  	if (host->pdata && host->pdata->get_ro)
>  		return !!host->pdata->get_ro(mmc->parent);
> -	/*
> -	 * Board doesn't support read only detection; let the mmc core
> -	 * decide what to do.
> -	 */
> -	return -ENOSYS;
> +	else
> +		return mmc_gpio_get_ro(mmc);

Why not just have the board file assign mmc_gpio_get_ro as
host->pdata->get_ro? This would eliminate the need for the
MMC_SPI_USE_RO_GPIO flag.

Also, if host->pdata->get_ro is not set then this will assume
mmc_gpio_get_ro is valid, even if MMC_SPI_USE_RO_GPIO is not set. I'm
guessing it will end up returning -ENOSYS, but they way the code reads
is that if the host doesn't have get_ro function set, then it is must be
a gpio.

Same applies for the other callbacks.

~Ryan


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

* Re: [PATCH 01/12] mmc: mmc_spi: Support CD/RO GPIOs
  2013-07-25 23:45   ` Ryan Mallon
@ 2013-07-26  0:04     ` Laurent Pinchart
  2013-07-26  0:23       ` Ryan Mallon
  0 siblings, 1 reply; 23+ messages in thread
From: Laurent Pinchart @ 2013-07-26  0:04 UTC (permalink / raw)
  To: Ryan Mallon
  Cc: Laurent Pinchart, linux-arm-kernel, linux-sh, linux-mmc,
	linux-spi, Hartley Sweeten, Chris Ball, Guennadi Liakhovetski,
	Ian Molton

Hi Ryan,

On Friday 26 July 2013 09:45:26 Ryan Mallon wrote:
> On 26/07/13 09:26, Laurent Pinchart wrote:
> > Add support for passing CD/RO GPIO numbers directly to the mmc_spi
> > driver instead of relying solely on board code callbacks to retrieve the
> > CD/RO signals values.
> > 
> > Signed-off-by: Laurent Pinchart
> > <laurent.pinchart+renesas@ideasonboard.com>
> > ---
> > 
> >  drivers/mmc/host/mmc_spi.c    | 32 +++++++++++++++++++++---------
> >  drivers/mmc/host/of_mmc_spi.c | 46 ++++++++++----------------------------
> >  include/linux/spi/mmc_spi.h   | 11 +++++++++++
> >  3 files changed, 46 insertions(+), 43 deletions(-)
> > 
> > diff --git a/drivers/mmc/host/mmc_spi.c b/drivers/mmc/host/mmc_spi.c
> > index 74145d1..4e83908 100644
> > --- a/drivers/mmc/host/mmc_spi.c
> > +++ b/drivers/mmc/host/mmc_spi.c
> > @@ -36,6 +36,7 @@
> > 
> >  #include <linux/mmc/host.h>
> >  #include <linux/mmc/mmc.h>		/* for R1_SPI_* bit values */
> > +#include <linux/mmc/slot-gpio.h>
> >  #include <linux/spi/spi.h>
> >  #include <linux/spi/mmc_spi.h>
> > 
> > @@ -1278,11 +1279,8 @@ static int mmc_spi_get_ro(struct mmc_host *mmc)
> >  	if (host->pdata && host->pdata->get_ro)
> >  		return !!host->pdata->get_ro(mmc->parent);
> > 
> > -	/*
> > -	 * Board doesn't support read only detection; let the mmc core
> > -	 * decide what to do.
> > -	 */
> > -	return -ENOSYS;
> > +	else
> > +		return mmc_gpio_get_ro(mmc);
> 
> Why not just have the board file assign mmc_gpio_get_ro as
> host->pdata->get_ro? This would eliminate the need for the
> MMC_SPI_USE_RO_GPIO flag.

Because the idea is to get rid of board callbacks and rely on proper kernel 
abstraction layers such as the GPIO subsystem. This will be especially 
important when adding device tree support to the mmc_spi driver.

> Also, if host->pdata->get_ro is not set then this will assume
> mmc_gpio_get_ro is valid, even if MMC_SPI_USE_RO_GPIO is not set. I'm
> guessing it will end up returning -ENOSYS, but they way the code reads is
> that if the host doesn't have get_ro function set, then it is must be a
> gpio.

mmc_gpio_get_ro() will indeed return -ENOSYS when the MMC_SPI_USE_RO_GPIO flag 
isn't set, as the mmc_spi driver will not call mmc_gpio_request_ro() in that 
case.

This patch hides the -ENOSYS value from the mmc_spi_get_ro() and 
mmc_spi_get_cd() functions, perhaps making them slightly confusing, but patch 
06/12 then gets rid of those functions, so I don't think it's a bit issue.

> Same applies for the other callbacks.

-- 
Regards,

Laurent Pinchart


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

* RE: [PATCH 02/12] ARM: ep93xx: vision_ep9307: Use MMC CD and RO GPIO
  2013-07-25 23:26 ` [PATCH 02/12] ARM: ep93xx: vision_ep9307: Use MMC CD and RO GPIO Laurent Pinchart
  2013-07-25 23:33   ` H Hartley Sweeten
@ 2013-07-26  0:19   ` H Hartley Sweeten
  2013-07-26  9:54     ` Laurent Pinchart
  1 sibling, 1 reply; 23+ messages in thread
From: H Hartley Sweeten @ 2013-07-26  0:19 UTC (permalink / raw)
  To: Laurent Pinchart, linux-arm-kernel
  Cc: linux-sh, linux-mmc, linux-spi, Ryan Mallon, Chris Ball,
	Guennadi Liakhovetski, Ian Molton

On Thursday, July 25, 2013 4:27 PM, Laurent Pinchart wrote:
>
> Pass the CD and RO GPIO numbers to the MMC SPI driver and remove the
> custom .get_cd() and .get_ro() callback functions.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> ---
>  arch/arm/mach-ep93xx/vision_ep9307.c | 56 +++---------------------------------
>  1 file changed, 4 insertions(+), 52 deletions(-)
>
> diff --git a/arch/arm/mach-ep93xx/vision_ep9307.c b/arch/arm/mach-ep93xx/vision_ep9307.c
> index 605956f..ab94dc5 100644
> --- a/arch/arm/mach-ep93xx/vision_ep9307.c
> +++ b/arch/arm/mach-ep93xx/vision_ep9307.c
> @@ -224,62 +224,14 @@ static struct ep93xx_spi_chip_ops vision_spi_flash_hw = {
>  #define VISION_SPI_MMC_WP	EP93XX_GPIO_LINE_F(0)
>  #define VISION_SPI_MMC_CD	EP93XX_GPIO_LINE_EGPIO15
>  
> -static struct gpio vision_spi_mmc_gpios[] = {
> -	{ VISION_SPI_MMC_WP, GPIOF_DIR_IN, "mmc_spi:wp" },
> -	{ VISION_SPI_MMC_CD, GPIOF_DIR_IN, "mmc_spi:cd" },
> -};
> -
> -static int vision_spi_mmc_init(struct device *pdev,
> -			irqreturn_t (*func)(int, void *), void *pdata)
> -{
> -	int err;
> -
> -	err = gpio_request_array(vision_spi_mmc_gpios,
> -				 ARRAY_SIZE(vision_spi_mmc_gpios));
> -	if (err)
> -		return err;
> -
> -	err = gpio_set_debounce(VISION_SPI_MMC_CD, 1);
> -	if (err)
> -		goto exit_err;

I tested this and it _kind_ of works.

The card detect is a bit flaky due to the gpio interrupt debounce not being enabled.

The only way I can see to fix this is add the following to this patch:

@@ -233,8 +233,31 @@ static struct mmc_spi_platform_data vision_spi_mmc_data = {
        .caps2          = MMC_CAP2_RO_ACTIVE_HIGH,
 };
 
+static int vision_spi_mmc_enable_cd_debounce(struct spi_device *spi)
+{
+       int ret;
+
+       ret = gpio_request_one(VISION_SPI_MMC_CD, GPIOF_DIR_IN, spi->modalias);
+       if (ret)
+               return ret;
+
+       ret = gpio_set_debounce(VISION_SPI_MMC_CD, 1);
+       if (ret)
+               return ret;
+
+       gpio_free(VISION_SPI_MMC_CD);
+
+       return 0;
+}
+
 static int vision_spi_mmc_hw_setup(struct spi_device *spi)
 {
+       int ret;
+
+       ret = vision_spi_mmc_enable_cd_debounce(spi);
+       if (ret)
+               return ret;
+
        return gpio_request_one(VISION_SPI_MMC_CS, GPIOF_INIT_HIGH,
                                spi->modalias);
 }

Regards,
Hartley


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

* Re: [PATCH 01/12] mmc: mmc_spi: Support CD/RO GPIOs
  2013-07-26  0:04     ` Laurent Pinchart
@ 2013-07-26  0:23       ` Ryan Mallon
  2013-07-26  9:51         ` Laurent Pinchart
  0 siblings, 1 reply; 23+ messages in thread
From: Ryan Mallon @ 2013-07-26  0:23 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: Laurent Pinchart, linux-arm-kernel, linux-sh, linux-mmc,
	linux-spi, Hartley Sweeten, Chris Ball, Guennadi Liakhovetski,
	Ian Molton

On 26/07/13 10:04, Laurent Pinchart wrote:
> Hi Ryan,
> 
> On Friday 26 July 2013 09:45:26 Ryan Mallon wrote:
>> On 26/07/13 09:26, Laurent Pinchart wrote:
>>> Add support for passing CD/RO GPIO numbers directly to the mmc_spi
>>> driver instead of relying solely on board code callbacks to retrieve the
>>> CD/RO signals values.
>>>
>>> Signed-off-by: Laurent Pinchart
>>> <laurent.pinchart+renesas@ideasonboard.com>
>>> ---
>>>
>>>  drivers/mmc/host/mmc_spi.c    | 32 +++++++++++++++++++++---------
>>>  drivers/mmc/host/of_mmc_spi.c | 46 ++++++++++----------------------------
>>>  include/linux/spi/mmc_spi.h   | 11 +++++++++++
>>>  3 files changed, 46 insertions(+), 43 deletions(-)
>>>
>>> diff --git a/drivers/mmc/host/mmc_spi.c b/drivers/mmc/host/mmc_spi.c
>>> index 74145d1..4e83908 100644
>>> --- a/drivers/mmc/host/mmc_spi.c
>>> +++ b/drivers/mmc/host/mmc_spi.c
>>> @@ -36,6 +36,7 @@
>>>
>>>  #include <linux/mmc/host.h>
>>>  #include <linux/mmc/mmc.h>		/* for R1_SPI_* bit values */
>>> +#include <linux/mmc/slot-gpio.h>
>>>  #include <linux/spi/spi.h>
>>>  #include <linux/spi/mmc_spi.h>
>>>
>>> @@ -1278,11 +1279,8 @@ static int mmc_spi_get_ro(struct mmc_host *mmc)
>>>  	if (host->pdata && host->pdata->get_ro)
>>>  		return !!host->pdata->get_ro(mmc->parent);
>>>
>>> -	/*
>>> -	 * Board doesn't support read only detection; let the mmc core
>>> -	 * decide what to do.
>>> -	 */
>>> -	return -ENOSYS;
>>> +	else
>>> +		return mmc_gpio_get_ro(mmc);
>>
>> Why not just have the board file assign mmc_gpio_get_ro as
>> host->pdata->get_ro? This would eliminate the need for the
>> MMC_SPI_USE_RO_GPIO flag.
> 
> Because the idea is to get rid of board callbacks and rely on proper kernel 
> abstraction layers such as the GPIO subsystem. This will be especially 
> important when adding device tree support to the mmc_spi driver.
> 
>> Also, if host->pdata->get_ro is not set then this will assume
>> mmc_gpio_get_ro is valid, even if MMC_SPI_USE_RO_GPIO is not set. I'm
>> guessing it will end up returning -ENOSYS, but they way the code reads is
>> that if the host doesn't have get_ro function set, then it is must be a
>> gpio.
> 
> mmc_gpio_get_ro() will indeed return -ENOSYS when the MMC_SPI_USE_RO_GPIO flag 
> isn't set, as the mmc_spi driver will not call mmc_gpio_request_ro() in that 
> case.
> 
> This patch hides the -ENOSYS value from the mmc_spi_get_ro() and 
> mmc_spi_get_cd() functions, perhaps making them slightly confusing, but patch 
> 06/12 then gets rid of those functions, so I don't think it's a bit issue.

Ah, I didn't read far enough along in the patch series :-). So all mmc
spi ro/cd controls are now assumed to be gpios?

~Ryan





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

* Re: [PATCH 00/12] Remove platform callbacks from mmc_spi, sh_mmcif and sh_mobile_sdhi drivers
  2013-07-25 23:26 [PATCH 00/12] Remove platform callbacks from mmc_spi, sh_mmcif and sh_mobile_sdhi drivers Laurent Pinchart
                   ` (12 preceding siblings ...)
  2013-07-25 23:37 ` [PATCH 00/12] Remove platform callbacks from mmc_spi, sh_mmcif and sh_mobile_sdhi drivers Ryan Mallon
@ 2013-07-26  7:01 ` Guennadi Liakhovetski
  13 siblings, 0 replies; 23+ messages in thread
From: Guennadi Liakhovetski @ 2013-07-26  7:01 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: linux-arm-kernel, linux-sh, linux-mmc, linux-spi,
	Hartley Sweeten, Ryan Mallon, Chris Ball, Ian Molton

Hi Laurent

On Fri, 26 Jul 2013, Laurent Pinchart wrote:

> Hello,
> 
> This patch set replaces callbacks to board code with regulators and GPIOs in
> the mmc_spi, sh_mmcif and sh_mobile_sdhi MMC drivers.
> 
> Most of the required infrastructure is in place already on the drivers side,
> except for CD/RO GPIOs support in the mmc_spi driver. The series thus starts
> with patch 01/12 that adds this feature to the mmc_spi driver.
> 
> Patches 02/12 to 05/12 remove the board callbacks from the ecovec24 and
> vision_ep9307 boards. The code has been compile-tested only as I don't have
> access to those boards.
> 
> Patches 06/12 to 07/12 then proceed to remove the callbacks from the drivers
> themselves and from the platform data structures.
> 
> This will be a bit messy to merge, as the series interleaves patches for
> drivers and board files. Given that the mmc_spi driver is marked as orphan in
> MAINTAINERS and that the vision_ep9307 hasn't seen any board-specific
> modification in the last couple of kernel versions one option would be to
> merge all patches (or at least patches 01/12 to 06/12) through Simon's tree if
> all involved maintainers agree.
> 
> The series is based on tag renesas-devel-20130725 from
> git://git.kernel.org/pub/scm/linux/kernel/git/horms/renesas.git
> 
> Laurent Pinchart (12):
>   mmc: mmc_spi: Support CD/RO GPIOs
>   ARM: ep93xx: vision_ep9307: Use MMC CD and RO GPIO
>   sh: ecovec24: Use MMC/SDHI CD and RO GPIO
>   sh: ecovec24: Remove mmcif .down_pwr() callback
>   sh: ecovec24: Remove MMCIF and SDHI .set_pwr() callbacks
>   mmc: mmc_spi: Remove platform data .get_cd() and .get_ro() callbacks
>   mmc: sh_mmcif: Remove .down_pwr() callback from platform data
>   mmc: sh_mmcif: Remove .set_pwr() callback from platform data
>   mmc: sh_mobile_sdhi: Remove .get_cd() callback from platform data
>   mmc: sh_mobile_sdhi: Remove .set_pwr() callback from platform data
>   mmc: tmio-mmc: Remove .get_cd() callback from platform data
>   mmc: tmio-mmc: Remove .set_pwr() callback from platform data

For #3-5, 7-12

Acked-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>

Thanks
Guennadi

>  arch/arm/mach-ep93xx/vision_ep9307.c | 56 ++---------------------
>  arch/sh/boards/mach-ecovec24/setup.c | 89 ++++--------------------------------
>  drivers/mmc/host/mmc_spi.c           | 48 +++++++++----------
>  drivers/mmc/host/of_mmc_spi.c        | 46 +++++--------------
>  drivers/mmc/host/sh_mmcif.c          |  3 --
>  drivers/mmc/host/sh_mobile_sdhi.c    | 18 --------
>  drivers/mmc/host/tmio_mmc.h          |  1 -
>  drivers/mmc/host/tmio_mmc_pio.c      | 23 +---------
>  include/linux/mfd/tmio.h             |  2 -
>  include/linux/mmc/sh_mmcif.h         |  2 -
>  include/linux/mmc/sh_mobile_sdhi.h   |  2 -
>  include/linux/spi/mmc_spi.h          | 18 ++++----
>  12 files changed, 56 insertions(+), 252 deletions(-)
> 
> -- 
> Regards,
> 
> Laurent Pinchart

---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/

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

* Re: [PATCH 01/12] mmc: mmc_spi: Support CD/RO GPIOs
  2013-07-26  0:23       ` Ryan Mallon
@ 2013-07-26  9:51         ` Laurent Pinchart
  0 siblings, 0 replies; 23+ messages in thread
From: Laurent Pinchart @ 2013-07-26  9:51 UTC (permalink / raw)
  To: Ryan Mallon
  Cc: Laurent Pinchart, linux-arm-kernel, linux-sh, linux-mmc,
	linux-spi, Hartley Sweeten, Chris Ball, Guennadi Liakhovetski,
	Ian Molton

Hi Ryan,

On Friday 26 July 2013 10:23:01 Ryan Mallon wrote:
> On 26/07/13 10:04, Laurent Pinchart wrote:
> > On Friday 26 July 2013 09:45:26 Ryan Mallon wrote:
> >> On 26/07/13 09:26, Laurent Pinchart wrote:
> >>> Add support for passing CD/RO GPIO numbers directly to the mmc_spi
> >>> driver instead of relying solely on board code callbacks to retrieve the
> >>> CD/RO signals values.
> >>> 
> >>> Signed-off-by: Laurent Pinchart
> >>> <laurent.pinchart+renesas@ideasonboard.com>
> >>> ---
> >>> 
> >>>  drivers/mmc/host/mmc_spi.c    | 32 +++++++++++++++++++++---------
> >>>  drivers/mmc/host/of_mmc_spi.c | 46 ++++++++++--------------------------
> >>>  include/linux/spi/mmc_spi.h   | 11 +++++++++++
> >>>  3 files changed, 46 insertions(+), 43 deletions(-)
> >>> 
> >>> diff --git a/drivers/mmc/host/mmc_spi.c b/drivers/mmc/host/mmc_spi.c
> >>> index 74145d1..4e83908 100644
> >>> --- a/drivers/mmc/host/mmc_spi.c
> >>> +++ b/drivers/mmc/host/mmc_spi.c
> >>> @@ -36,6 +36,7 @@
> >>> 
> >>>  #include <linux/mmc/host.h>
> >>>  #include <linux/mmc/mmc.h>		/* for R1_SPI_* bit values */
> >>> +#include <linux/mmc/slot-gpio.h>
> >>>  #include <linux/spi/spi.h>
> >>>  #include <linux/spi/mmc_spi.h>
> >>> 
> >>> @@ -1278,11 +1279,8 @@ static int mmc_spi_get_ro(struct mmc_host *mmc)
> >>>  	if (host->pdata && host->pdata->get_ro)
> >>>  		return !!host->pdata->get_ro(mmc->parent);
> >>> 
> >>> -	/*
> >>> -	 * Board doesn't support read only detection; let the mmc core
> >>> -	 * decide what to do.
> >>> -	 */
> >>> -	return -ENOSYS;
> >>> +	else
> >>> +		return mmc_gpio_get_ro(mmc);
> >> 
> >> Why not just have the board file assign mmc_gpio_get_ro as
> >> host->pdata->get_ro? This would eliminate the need for the
> >> MMC_SPI_USE_RO_GPIO flag.
> > 
> > Because the idea is to get rid of board callbacks and rely on proper
> > kernel abstraction layers such as the GPIO subsystem. This will be
> > especially important when adding device tree support to the mmc_spi
> > driver.
> > 
> >> Also, if host->pdata->get_ro is not set then this will assume
> >> mmc_gpio_get_ro is valid, even if MMC_SPI_USE_RO_GPIO is not set. I'm
> >> guessing it will end up returning -ENOSYS, but they way the code reads is
> >> that if the host doesn't have get_ro function set, then it is must be a
> >> gpio.
> > 
> > mmc_gpio_get_ro() will indeed return -ENOSYS when the MMC_SPI_USE_RO_GPIO
> > flag isn't set, as the mmc_spi driver will not call mmc_gpio_request_ro()
> > in that case.
> > 
> > This patch hides the -ENOSYS value from the mmc_spi_get_ro() and
> > mmc_spi_get_cd() functions, perhaps making them slightly confusing, but
> > patch 06/12 then gets rid of those functions, so I don't think it's a bit
> > issue.
>
> Ah, I didn't read far enough along in the patch series :-). So all mmc spi
> ro/cd controls are now assumed to be gpios?

That's correct. It's the case in practice for all the boards we support in 
mainline. If the situation changes in the future for a new board (hardware 
engineers tend to have strange design ideas sometimes) a custom GPIO driver 
might be needed (for FPGA/CPLD-controlled GPIOs for instance).

-- 
Regards,

Laurent Pinchart


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

* Re: [PATCH 02/12] ARM: ep93xx: vision_ep9307: Use MMC CD and RO GPIO
  2013-07-26  0:19   ` H Hartley Sweeten
@ 2013-07-26  9:54     ` Laurent Pinchart
  2013-07-26 16:26       ` H Hartley Sweeten
  0 siblings, 1 reply; 23+ messages in thread
From: Laurent Pinchart @ 2013-07-26  9:54 UTC (permalink / raw)
  To: H Hartley Sweeten
  Cc: Laurent Pinchart, linux-arm-kernel, linux-sh, linux-mmc,
	linux-spi, Ryan Mallon, Chris Ball, Guennadi Liakhovetski,
	Ian Molton

Hi Hartley,

On Thursday 25 July 2013 19:19:52 H Hartley Sweeten wrote:
> On Thursday, July 25, 2013 4:27 PM, Laurent Pinchart wrote:
> > Pass the CD and RO GPIO numbers to the MMC SPI driver and remove the
> > custom .get_cd() and .get_ro() callback functions.
> > 
> > Signed-off-by: Laurent Pinchart
> > <laurent.pinchart+renesas@ideasonboard.com>
> > ---
> > 
> >  arch/arm/mach-ep93xx/vision_ep9307.c | 56  +++---------------------------
> >  1 file changed, 4 insertions(+), 52 deletions(-)
> > 
> > diff --git a/arch/arm/mach-ep93xx/vision_ep9307.c
> > b/arch/arm/mach-ep93xx/vision_ep9307.c index 605956f..ab94dc5 100644
> > --- a/arch/arm/mach-ep93xx/vision_ep9307.c
> > +++ b/arch/arm/mach-ep93xx/vision_ep9307.c
> > @@ -224,62 +224,14 @@ static struct ep93xx_spi_chip_ops
> > vision_spi_flash_hw = {> 
> >  #define VISION_SPI_MMC_WP	EP93XX_GPIO_LINE_F(0)
> >  #define VISION_SPI_MMC_CD	EP93XX_GPIO_LINE_EGPIO15
> > 
> > -static struct gpio vision_spi_mmc_gpios[] = {
> > -	{ VISION_SPI_MMC_WP, GPIOF_DIR_IN, "mmc_spi:wp" },
> > -	{ VISION_SPI_MMC_CD, GPIOF_DIR_IN, "mmc_spi:cd" },
> > -};
> > -
> > -static int vision_spi_mmc_init(struct device *pdev,
> > -			irqreturn_t (*func)(int, void *), void *pdata)
> > -{
> > -	int err;
> > -
> > -	err = gpio_request_array(vision_spi_mmc_gpios,
> > -				 ARRAY_SIZE(vision_spi_mmc_gpios));
> > -	if (err)
> > -		return err;
> > -
> > -	err = gpio_set_debounce(VISION_SPI_MMC_CD, 1);
> > -	if (err)
> > -		goto exit_err;
> 
> I tested this and it _kind_ of works.
> 
> The card detect is a bit flaky due to the gpio interrupt debounce not being
> enabled.
> 
> The only way I can see to fix this is add the following to this patch:
> 
> @@ -233,8 +233,31 @@ static struct mmc_spi_platform_data vision_spi_mmc_data
> = { .caps2          = MMC_CAP2_RO_ACTIVE_HIGH,
>  };
> 
> +static int vision_spi_mmc_enable_cd_debounce(struct spi_device *spi)
> +{
> +       int ret;
> +
> +       ret = gpio_request_one(VISION_SPI_MMC_CD, GPIOF_DIR_IN,
> spi->modalias);
> +       if (ret)
> +               return ret;
> +
> +       ret = gpio_set_debounce(VISION_SPI_MMC_CD, 1);
> +       if (ret)
> +               return ret;
> +
> +       gpio_free(VISION_SPI_MMC_CD);
> +
> +       return 0;
> +}
> +
>  static int vision_spi_mmc_hw_setup(struct spi_device *spi)
>  {
> +       int ret;
> +
> +       ret = vision_spi_mmc_enable_cd_debounce(spi);
> +       if (ret)
> +               return ret;
> +
>         return gpio_request_one(VISION_SPI_MMC_CS, GPIOF_INIT_HIGH,
>                                 spi->modalias);
>  }

What about extending the mmc_spi and MMC core with GPIO debounce support ? The 
mmc_spi driver would get a new cd_gpio_debounce field, which would be passed 
to mmc_gpio_request_cd(). I can cook up a patch.

-- 
Regards,

Laurent Pinchart


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

* RE: [PATCH 02/12] ARM: ep93xx: vision_ep9307: Use MMC CD and RO GPIO
  2013-07-26  9:54     ` Laurent Pinchart
@ 2013-07-26 16:26       ` H Hartley Sweeten
  0 siblings, 0 replies; 23+ messages in thread
From: H Hartley Sweeten @ 2013-07-26 16:26 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: Laurent Pinchart, linux-arm-kernel, linux-sh, linux-mmc,
	linux-spi, Ryan Mallon, Chris Ball, Guennadi Liakhovetski,
	Ian Molton

On Friday, July 26, 2013 2:55 AM, Laurent Pinchart wrote:
> On Thursday 25 July 2013 19:19:52 H Hartley Sweeten wrote:
>> On Thursday, July 25, 2013 4:27 PM, Laurent Pinchart wrote:
>>> Pass the CD and RO GPIO numbers to the MMC SPI driver and remove the
>>> custom .get_cd() and .get_ro() callback functions.
>>> 
>>> Signed-off-by: Laurent Pinchart
>>> <laurent.pinchart+renesas@ideasonboard.com>
>>> ---
>>> 
>>>  arch/arm/mach-ep93xx/vision_ep9307.c | 56  +++---------------------------
>>>  1 file changed, 4 insertions(+), 52 deletions(-)

<snip>

>> I tested this and it _kind_ of works.
>> 
>> The card detect is a bit flaky due to the gpio interrupt debounce not being
>> enabled.
>> 
>> The only way I can see to fix this is add the following to this patch:

<snip>

> What about extending the mmc_spi and MMC core with GPIO debounce support ? The 
> mmc_spi driver would get a new cd_gpio_debounce field, which would be passed 
> to mmc_gpio_request_cd(). I can cook up a patch.

Works for me. That would also remove the need for the platform init to request then free
the GPIO just to set the debounce.

Make sure you do the gpiu_set_debounce() after the GPIO has been requested or you
trigger a WARN due to the auto-requested GPIO. Then, of course, the drivers gpio request
will fail...

I'll give it a test when you post it.

Thanks,
Hartley


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

end of thread, other threads:[~2013-07-26 16:26 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-25 23:26 [PATCH 00/12] Remove platform callbacks from mmc_spi, sh_mmcif and sh_mobile_sdhi drivers Laurent Pinchart
2013-07-25 23:26 ` [PATCH 01/12] mmc: mmc_spi: Support CD/RO GPIOs Laurent Pinchart
2013-07-25 23:45   ` Ryan Mallon
2013-07-26  0:04     ` Laurent Pinchart
2013-07-26  0:23       ` Ryan Mallon
2013-07-26  9:51         ` Laurent Pinchart
2013-07-25 23:26 ` [PATCH 02/12] ARM: ep93xx: vision_ep9307: Use MMC CD and RO GPIO Laurent Pinchart
2013-07-25 23:33   ` H Hartley Sweeten
2013-07-26  0:19   ` H Hartley Sweeten
2013-07-26  9:54     ` Laurent Pinchart
2013-07-26 16:26       ` H Hartley Sweeten
2013-07-25 23:26 ` [PATCH 03/12] sh: ecovec24: Use MMC/SDHI " Laurent Pinchart
2013-07-25 23:26 ` [PATCH 04/12] sh: ecovec24: Remove mmcif .down_pwr() callback Laurent Pinchart
2013-07-25 23:26 ` [PATCH 05/12] sh: ecovec24: Remove MMCIF and SDHI .set_pwr() callbacks Laurent Pinchart
2013-07-25 23:26 ` [PATCH 06/12] mmc: mmc_spi: Remove platform data .get_cd() and .get_ro() callbacks Laurent Pinchart
2013-07-25 23:26 ` [PATCH 07/12] mmc: sh_mmcif: Remove .down_pwr() callback from platform data Laurent Pinchart
2013-07-25 23:26 ` [PATCH 08/12] mmc: sh_mmcif: Remove .set_pwr() " Laurent Pinchart
2013-07-25 23:26 ` [PATCH 09/12] mmc: sh_mobile_sdhi: Remove .get_cd() " Laurent Pinchart
2013-07-25 23:26 ` [PATCH 10/12] mmc: sh_mobile_sdhi: Remove .set_pwr() " Laurent Pinchart
2013-07-25 23:26 ` [PATCH 11/12] mmc: tmio-mmc: Remove .get_cd() " Laurent Pinchart
2013-07-25 23:26 ` [PATCH 12/12] mmc: tmio-mmc: Remove .set_pwr() " Laurent Pinchart
2013-07-25 23:37 ` [PATCH 00/12] Remove platform callbacks from mmc_spi, sh_mmcif and sh_mobile_sdhi drivers Ryan Mallon
2013-07-26  7:01 ` Guennadi Liakhovetski

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).