All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] Fix/improve hotplug for sh_mobile_sdhi/tmio_mmc/sh_mmcif
@ 2010-08-24 15:26 ` Arnd Hannemann
  0 siblings, 0 replies; 18+ messages in thread
From: Arnd Hannemann @ 2010-08-24 15:26 UTC (permalink / raw)
  To: ian; +Cc: sameo, linux-mmc, linux-sh, yusuke.goda.sx

This patch series attempts to fix hotplug (for sh_mobile_sdhi/tmio_mmc) and 
improve hotplug (for sh_mmcif) on the AP4EVB (shmobile) board, by handling the 
card detect in platform code.

Best regards,
Arnd


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

* [PATCH 0/4] Fix/improve hotplug for sh_mobile_sdhi/tmio_mmc/sh_mmcif
@ 2010-08-24 15:26 ` Arnd Hannemann
  0 siblings, 0 replies; 18+ messages in thread
From: Arnd Hannemann @ 2010-08-24 15:26 UTC (permalink / raw)
  To: ian; +Cc: sameo, linux-mmc, linux-sh, yusuke.goda.sx

This patch series attempts to fix hotplug (for sh_mobile_sdhi/tmio_mmc) and 
improve hotplug (for sh_mmcif) on the AP4EVB (shmobile) board, by handling the 
card detect in platform code.

Best regards,
Arnd


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

* [PATCH 1/4] tmio_mmc: Allow the mfd driver to specify get_cd handler
  2010-08-24 15:26 ` Arnd Hannemann
@ 2010-08-24 15:26   ` Arnd Hannemann
  -1 siblings, 0 replies; 18+ messages in thread
From: Arnd Hannemann @ 2010-08-24 15:26 UTC (permalink / raw)
  To: ian; +Cc: sameo, linux-mmc, linux-sh, yusuke.goda.sx, Arnd Hannemann

Some controllers, supported by the tmio_mmc driver do not have the card detect
pin of a slot connected, so that polling needs to be used and card detection is
handled by other means.
This patch exposes a get_cd hook for that purpose.

Signed-off-by: Arnd Hannemann <arnd@arndnet.de>
---
 drivers/mmc/host/tmio_mmc.c |   13 +++++++++++++
 include/linux/mfd/tmio.h    |    1 +
 2 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/drivers/mmc/host/tmio_mmc.c b/drivers/mmc/host/tmio_mmc.c
index ee7d0a5..fe2ebf6 100644
--- a/drivers/mmc/host/tmio_mmc.c
+++ b/drivers/mmc/host/tmio_mmc.c
@@ -755,10 +755,23 @@ static int tmio_mmc_get_ro(struct mmc_host *mmc)
 		(sd_ctrl_read32(host, CTL_STATUS) & TMIO_STAT_WRPROTECT)) ? 0 : 1;
 }
 
+static int tmio_mmc_get_cd(struct mmc_host *mmc)
+{
+	struct tmio_mmc_host *host = mmc_priv(mmc);
+	struct mfd_cell	*cell = host->pdev->dev.platform_data;
+	struct tmio_mmc_data *pdata = cell->driver_data;
+
+	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,
 };
 
 #ifdef CONFIG_PM
diff --git a/include/linux/mfd/tmio.h b/include/linux/mfd/tmio.h
index f07425b..24c43bb 100644
--- a/include/linux/mfd/tmio.h
+++ b/include/linux/mfd/tmio.h
@@ -74,6 +74,7 @@ struct tmio_mmc_data {
 	struct tmio_mmc_dma		*dma;
 	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);
 };
 
 /*
-- 
1.7.0.4


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

* [PATCH 1/4] tmio_mmc: Allow the mfd driver to specify get_cd handler
@ 2010-08-24 15:26   ` Arnd Hannemann
  0 siblings, 0 replies; 18+ messages in thread
From: Arnd Hannemann @ 2010-08-24 15:26 UTC (permalink / raw)
  To: ian; +Cc: sameo, linux-mmc, linux-sh, yusuke.goda.sx, Arnd Hannemann

Some controllers, supported by the tmio_mmc driver do not have the card detect
pin of a slot connected, so that polling needs to be used and card detection is
handled by other means.
This patch exposes a get_cd hook for that purpose.

Signed-off-by: Arnd Hannemann <arnd@arndnet.de>
---
 drivers/mmc/host/tmio_mmc.c |   13 +++++++++++++
 include/linux/mfd/tmio.h    |    1 +
 2 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/drivers/mmc/host/tmio_mmc.c b/drivers/mmc/host/tmio_mmc.c
index ee7d0a5..fe2ebf6 100644
--- a/drivers/mmc/host/tmio_mmc.c
+++ b/drivers/mmc/host/tmio_mmc.c
@@ -755,10 +755,23 @@ static int tmio_mmc_get_ro(struct mmc_host *mmc)
 		(sd_ctrl_read32(host, CTL_STATUS) & TMIO_STAT_WRPROTECT)) ? 0 : 1;
 }
 
+static int tmio_mmc_get_cd(struct mmc_host *mmc)
+{
+	struct tmio_mmc_host *host = mmc_priv(mmc);
+	struct mfd_cell	*cell = host->pdev->dev.platform_data;
+	struct tmio_mmc_data *pdata = cell->driver_data;
+
+	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,
 };
 
 #ifdef CONFIG_PM
diff --git a/include/linux/mfd/tmio.h b/include/linux/mfd/tmio.h
index f07425b..24c43bb 100644
--- a/include/linux/mfd/tmio.h
+++ b/include/linux/mfd/tmio.h
@@ -74,6 +74,7 @@ struct tmio_mmc_data {
 	struct tmio_mmc_dma		*dma;
 	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);
 };
 
 /*
-- 
1.7.0.4


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

* [PATCH 2/4] sh_mobile_sdhi: Allow the platform to specify get_cd
  2010-08-24 15:26 ` Arnd Hannemann
@ 2010-08-24 15:27   ` Arnd Hannemann
  -1 siblings, 0 replies; 18+ messages in thread
From: Arnd Hannemann @ 2010-08-24 15:27 UTC (permalink / raw)
  To: ian; +Cc: sameo, linux-mmc, linux-sh, yusuke.goda.sx, Arnd Hannemann

On some platforms (e.g. AP4EVB) the card detect pin of a slot is not directly
connected to the sdhi hardware, so that polling needs to be used with tmio_mmc
and card detection is handled in the platform code.
This patch allows to set tmio_mmc capabilities (to pass the MMC_CAP_NEEDS_POLL
flag) and exposes a get_cd hook for that purpose.

Signed-off-by: Arnd Hannemann <arnd@arndnet.de>
---
 drivers/mfd/sh_mobile_sdhi.c       |   13 +++++++++++++
 include/linux/mfd/sh_mobile_sdhi.h |    2 ++
 2 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/drivers/mfd/sh_mobile_sdhi.c b/drivers/mfd/sh_mobile_sdhi.c
index cd16459..7c23630 100644
--- a/drivers/mfd/sh_mobile_sdhi.c
+++ b/drivers/mfd/sh_mobile_sdhi.c
@@ -65,6 +65,17 @@ static void sh_mobile_sdhi_set_pwr(struct platform_device *tmio, int state)
 		p->set_pwr(pdev, state);
 }
 
+static int sh_mobile_sdhi_get_cd(struct platform_device *tmio)
+{
+	struct platform_device *pdev = to_platform_device(tmio->dev.parent);
+	struct sh_mobile_sdhi_info *p = pdev->dev.platform_data;
+
+	if (p && p->get_cd)
+		return p->get_cd(pdev);
+	else
+		return -ENOSYS;
+}
+
 static int __init sh_mobile_sdhi_probe(struct platform_device *pdev)
 {
 	struct sh_mobile_sdhi *priv;
@@ -106,10 +117,12 @@ static int __init sh_mobile_sdhi_probe(struct platform_device *pdev)
 
 	mmc_data->hclk = clk_get_rate(priv->clk);
 	mmc_data->set_pwr = sh_mobile_sdhi_set_pwr;
+	mmc_data->get_cd = sh_mobile_sdhi_get_cd;
 	mmc_data->capabilities = MMC_CAP_MMC_HIGHSPEED;
 	if (p) {
 		mmc_data->flags = p->tmio_flags;
 		mmc_data->ocr_mask = p->tmio_ocr_mask;
+		mmc_data->capabilities |= p->tmio_caps;
 	}
 
 	if (p && p->dma_slave_tx >= 0 && p->dma_slave_rx >= 0) {
diff --git a/include/linux/mfd/sh_mobile_sdhi.h b/include/linux/mfd/sh_mobile_sdhi.h
index 4906780..c981b95 100644
--- a/include/linux/mfd/sh_mobile_sdhi.h
+++ b/include/linux/mfd/sh_mobile_sdhi.h
@@ -7,8 +7,10 @@ struct sh_mobile_sdhi_info {
 	int dma_slave_tx;
 	int dma_slave_rx;
 	unsigned long tmio_flags;
+	unsigned long tmio_caps;
 	u32 tmio_ocr_mask;	/* available MMC voltages */
 	void (*set_pwr)(struct platform_device *pdev, int state);
+	int (*get_cd)(struct platform_device *pdev);
 };
 
 #endif /* __SH_MOBILE_SDHI_H__ */
-- 
1.7.0.4


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

* [PATCH 2/4] sh_mobile_sdhi: Allow the platform to specify get_cd handler
@ 2010-08-24 15:27   ` Arnd Hannemann
  0 siblings, 0 replies; 18+ messages in thread
From: Arnd Hannemann @ 2010-08-24 15:27 UTC (permalink / raw)
  To: ian; +Cc: sameo, linux-mmc, linux-sh, yusuke.goda.sx, Arnd Hannemann

On some platforms (e.g. AP4EVB) the card detect pin of a slot is not directly
connected to the sdhi hardware, so that polling needs to be used with tmio_mmc
and card detection is handled in the platform code.
This patch allows to set tmio_mmc capabilities (to pass the MMC_CAP_NEEDS_POLL
flag) and exposes a get_cd hook for that purpose.

Signed-off-by: Arnd Hannemann <arnd@arndnet.de>
---
 drivers/mfd/sh_mobile_sdhi.c       |   13 +++++++++++++
 include/linux/mfd/sh_mobile_sdhi.h |    2 ++
 2 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/drivers/mfd/sh_mobile_sdhi.c b/drivers/mfd/sh_mobile_sdhi.c
index cd16459..7c23630 100644
--- a/drivers/mfd/sh_mobile_sdhi.c
+++ b/drivers/mfd/sh_mobile_sdhi.c
@@ -65,6 +65,17 @@ static void sh_mobile_sdhi_set_pwr(struct platform_device *tmio, int state)
 		p->set_pwr(pdev, state);
 }
 
+static int sh_mobile_sdhi_get_cd(struct platform_device *tmio)
+{
+	struct platform_device *pdev = to_platform_device(tmio->dev.parent);
+	struct sh_mobile_sdhi_info *p = pdev->dev.platform_data;
+
+	if (p && p->get_cd)
+		return p->get_cd(pdev);
+	else
+		return -ENOSYS;
+}
+
 static int __init sh_mobile_sdhi_probe(struct platform_device *pdev)
 {
 	struct sh_mobile_sdhi *priv;
@@ -106,10 +117,12 @@ static int __init sh_mobile_sdhi_probe(struct platform_device *pdev)
 
 	mmc_data->hclk = clk_get_rate(priv->clk);
 	mmc_data->set_pwr = sh_mobile_sdhi_set_pwr;
+	mmc_data->get_cd = sh_mobile_sdhi_get_cd;
 	mmc_data->capabilities = MMC_CAP_MMC_HIGHSPEED;
 	if (p) {
 		mmc_data->flags = p->tmio_flags;
 		mmc_data->ocr_mask = p->tmio_ocr_mask;
+		mmc_data->capabilities |= p->tmio_caps;
 	}
 
 	if (p && p->dma_slave_tx >= 0 && p->dma_slave_rx >= 0) {
diff --git a/include/linux/mfd/sh_mobile_sdhi.h b/include/linux/mfd/sh_mobile_sdhi.h
index 4906780..c981b95 100644
--- a/include/linux/mfd/sh_mobile_sdhi.h
+++ b/include/linux/mfd/sh_mobile_sdhi.h
@@ -7,8 +7,10 @@ struct sh_mobile_sdhi_info {
 	int dma_slave_tx;
 	int dma_slave_rx;
 	unsigned long tmio_flags;
+	unsigned long tmio_caps;
 	u32 tmio_ocr_mask;	/* available MMC voltages */
 	void (*set_pwr)(struct platform_device *pdev, int state);
+	int (*get_cd)(struct platform_device *pdev);
 };
 
 #endif /* __SH_MOBILE_SDHI_H__ */
-- 
1.7.0.4


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

* [PATCH 3/4] sh_mmcif: Allow the platform to specify own get_cd handler
  2010-08-24 15:26 ` Arnd Hannemann
@ 2010-08-24 15:27   ` Arnd Hannemann
  -1 siblings, 0 replies; 18+ messages in thread
From: Arnd Hannemann @ 2010-08-24 15:27 UTC (permalink / raw)
  To: ian; +Cc: sameo, linux-mmc, linux-sh, yusuke.goda.sx, Arnd Hannemann

In some platforms (e.g. AP4EVB) the card detect pin of a slot is not directly
connected to the sh_mmcif controller, so that polling needs to be used. To
overcome the overhead induced by querying the controller on each poll cycle,
card detection can be handled in the platform code more efficiently.
This patch exposes a get_cd hook for that purpose.

Signed-off-by: Arnd Hannemann <arnd@arndnet.de>
---
 drivers/mmc/host/sh_mmcif.c  |   12 ++++++++++++
 include/linux/mmc/sh_mmcif.h |    1 +
 2 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/drivers/mmc/host/sh_mmcif.c b/drivers/mmc/host/sh_mmcif.c
index 5d3f824..25eebbb 100644
--- a/drivers/mmc/host/sh_mmcif.c
+++ b/drivers/mmc/host/sh_mmcif.c
@@ -710,9 +710,21 @@ static void sh_mmcif_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 	host->bus_width = ios->bus_width;
 }
 
+static int sh_mmcif_get_cd(struct mmc_host *mmc)
+{
+	struct sh_mmcif_host *host = mmc_priv(mmc);
+	struct sh_mmcif_plat_data *p = host->pd->dev.platform_data;
+
+	if (!p->get_cd)
+		return -ENOSYS;
+	else
+		return p->get_cd(host->pd);
+}
+
 static struct mmc_host_ops sh_mmcif_ops = {
 	.request	= sh_mmcif_request,
 	.set_ios	= sh_mmcif_set_ios,
+	.get_cd		= sh_mmcif_get_cd,
 };
 
 static void sh_mmcif_detect(struct mmc_host *mmc)
diff --git a/include/linux/mmc/sh_mmcif.h b/include/linux/mmc/sh_mmcif.h
index d4a2ebb..d19e211 100644
--- a/include/linux/mmc/sh_mmcif.h
+++ b/include/linux/mmc/sh_mmcif.h
@@ -34,6 +34,7 @@
 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);
 	u8	sup_pclk;	/* 1 :SH7757, 0: SH7724/SH7372 */
 	unsigned long caps;
 	u32	ocr;
-- 
1.7.0.4


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

* [PATCH 3/4] sh_mmcif: Allow the platform to specify own get_cd handler
@ 2010-08-24 15:27   ` Arnd Hannemann
  0 siblings, 0 replies; 18+ messages in thread
From: Arnd Hannemann @ 2010-08-24 15:27 UTC (permalink / raw)
  To: ian; +Cc: sameo, linux-mmc, linux-sh, yusuke.goda.sx, Arnd Hannemann

In some platforms (e.g. AP4EVB) the card detect pin of a slot is not directly
connected to the sh_mmcif controller, so that polling needs to be used. To
overcome the overhead induced by querying the controller on each poll cycle,
card detection can be handled in the platform code more efficiently.
This patch exposes a get_cd hook for that purpose.

Signed-off-by: Arnd Hannemann <arnd@arndnet.de>
---
 drivers/mmc/host/sh_mmcif.c  |   12 ++++++++++++
 include/linux/mmc/sh_mmcif.h |    1 +
 2 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/drivers/mmc/host/sh_mmcif.c b/drivers/mmc/host/sh_mmcif.c
index 5d3f824..25eebbb 100644
--- a/drivers/mmc/host/sh_mmcif.c
+++ b/drivers/mmc/host/sh_mmcif.c
@@ -710,9 +710,21 @@ static void sh_mmcif_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 	host->bus_width = ios->bus_width;
 }
 
+static int sh_mmcif_get_cd(struct mmc_host *mmc)
+{
+	struct sh_mmcif_host *host = mmc_priv(mmc);
+	struct sh_mmcif_plat_data *p = host->pd->dev.platform_data;
+
+	if (!p->get_cd)
+		return -ENOSYS;
+	else
+		return p->get_cd(host->pd);
+}
+
 static struct mmc_host_ops sh_mmcif_ops = {
 	.request	= sh_mmcif_request,
 	.set_ios	= sh_mmcif_set_ios,
+	.get_cd		= sh_mmcif_get_cd,
 };
 
 static void sh_mmcif_detect(struct mmc_host *mmc)
diff --git a/include/linux/mmc/sh_mmcif.h b/include/linux/mmc/sh_mmcif.h
index d4a2ebb..d19e211 100644
--- a/include/linux/mmc/sh_mmcif.h
+++ b/include/linux/mmc/sh_mmcif.h
@@ -34,6 +34,7 @@
 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);
 	u8	sup_pclk;	/* 1 :SH7757, 0: SH7724/SH7372 */
 	unsigned long caps;
 	u32	ocr;
-- 
1.7.0.4


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

* [PATCH 4/4] ARM: mach-shmobile: ap4evb: Fix hotplug for SDHI1
  2010-08-24 15:26 ` Arnd Hannemann
@ 2010-08-24 15:27   ` Arnd Hannemann
  -1 siblings, 0 replies; 18+ messages in thread
From: Arnd Hannemann @ 2010-08-24 15:27 UTC (permalink / raw)
  To: ian; +Cc: sameo, linux-mmc, linux-sh, yusuke.goda.sx, Arnd Hannemann

On AP4EVB the card detect pin of the top SD/MMC slot is not directly connected
to the tmio/mmcif controller but to a GPIO pin, so polling needs to be done for
SDHI1 and MMCIF in order to support hotplug for that slot. SHDI1 and MMCIF
share that slot, and the used controller is selected by a DIP switch.
This patch adds a helper function to check if a card is present in that
particular slot, registers this function with SDHI1 and MMCIF and enables
polling for SDHI1.

Signed-off-by: Arnd Hannemann <arnd@arndnet.de>
---
 arch/arm/mach-shmobile/board-ap4evb.c |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-shmobile/board-ap4evb.c b/arch/arm/mach-shmobile/board-ap4evb.c
index 95935c8..2e90ce4 100644
--- a/arch/arm/mach-shmobile/board-ap4evb.c
+++ b/arch/arm/mach-shmobile/board-ap4evb.c
@@ -235,6 +235,18 @@ static struct platform_device smc911x_device = {
 	},
 };
 
+/*
+ * The card detect pin of the top SD/MMC slot (CN7) is active low and is
+ * connected to GPIO A22 of SH7372 (GPIO_PORT41).
+ */
+static int slot_cn7_get_cd(struct platform_device *pdev)
+{
+	if (gpio_is_valid(GPIO_PORT41))
+		return !gpio_get_value(GPIO_PORT41);
+	else
+		return -ENXIO;
+}
+
 /* SH_MMCIF */
 static struct resource sh_mmcif_resources[] = {
 	[0] = {
@@ -261,6 +273,7 @@ static struct sh_mmcif_plat_data sh_mmcif_plat = {
 	.caps		= MMC_CAP_4_BIT_DATA |
 			  MMC_CAP_8_BIT_DATA |
 			  MMC_CAP_NEEDS_POLL,
+	.get_cd		= slot_cn7_get_cd,
 };
 
 static struct platform_device sh_mmcif_device = {
@@ -310,6 +323,8 @@ static struct sh_mobile_sdhi_info sdhi1_info = {
 	.dma_slave_rx	= SHDMA_SLAVE_SDHI1_RX,
 	.tmio_ocr_mask	= MMC_VDD_165_195,
 	.tmio_flags	= TMIO_MMC_WRPROTECT_DISABLE,
+	.tmio_caps	= MMC_CAP_NEEDS_POLL,
+	.get_cd		= slot_cn7_get_cd,
 };
 
 static struct resource sdhi1_resources[] = {
@@ -948,6 +963,10 @@ static void __init ap4evb_init(void)
 	gpio_no_direction(GPIO_PORT9CR);  /* FSIAOBT needs no direction */
 	gpio_no_direction(GPIO_PORT10CR); /* FSIAOLR needs no direction */
 
+	/* card detect pin for MMC slot (CN7) */
+	gpio_request(GPIO_PORT41, NULL);
+	gpio_direction_input(GPIO_PORT41);
+
 	/* set SPU2 clock to 119.6 MHz */
 	clk = clk_get(NULL, "spu_clk");
 	if (!IS_ERR(clk)) {
-- 
1.7.0.4


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

* [PATCH 4/4] ARM: mach-shmobile: ap4evb: Fix hotplug for SDHI1
@ 2010-08-24 15:27   ` Arnd Hannemann
  0 siblings, 0 replies; 18+ messages in thread
From: Arnd Hannemann @ 2010-08-24 15:27 UTC (permalink / raw)
  To: ian; +Cc: sameo, linux-mmc, linux-sh, yusuke.goda.sx, Arnd Hannemann

On AP4EVB the card detect pin of the top SD/MMC slot is not directly connected
to the tmio/mmcif controller but to a GPIO pin, so polling needs to be done for
SDHI1 and MMCIF in order to support hotplug for that slot. SHDI1 and MMCIF
share that slot, and the used controller is selected by a DIP switch.
This patch adds a helper function to check if a card is present in that
particular slot, registers this function with SDHI1 and MMCIF and enables
polling for SDHI1.

Signed-off-by: Arnd Hannemann <arnd@arndnet.de>
---
 arch/arm/mach-shmobile/board-ap4evb.c |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-shmobile/board-ap4evb.c b/arch/arm/mach-shmobile/board-ap4evb.c
index 95935c8..2e90ce4 100644
--- a/arch/arm/mach-shmobile/board-ap4evb.c
+++ b/arch/arm/mach-shmobile/board-ap4evb.c
@@ -235,6 +235,18 @@ static struct platform_device smc911x_device = {
 	},
 };
 
+/*
+ * The card detect pin of the top SD/MMC slot (CN7) is active low and is
+ * connected to GPIO A22 of SH7372 (GPIO_PORT41).
+ */
+static int slot_cn7_get_cd(struct platform_device *pdev)
+{
+	if (gpio_is_valid(GPIO_PORT41))
+		return !gpio_get_value(GPIO_PORT41);
+	else
+		return -ENXIO;
+}
+
 /* SH_MMCIF */
 static struct resource sh_mmcif_resources[] = {
 	[0] = {
@@ -261,6 +273,7 @@ static struct sh_mmcif_plat_data sh_mmcif_plat = {
 	.caps		= MMC_CAP_4_BIT_DATA |
 			  MMC_CAP_8_BIT_DATA |
 			  MMC_CAP_NEEDS_POLL,
+	.get_cd		= slot_cn7_get_cd,
 };
 
 static struct platform_device sh_mmcif_device = {
@@ -310,6 +323,8 @@ static struct sh_mobile_sdhi_info sdhi1_info = {
 	.dma_slave_rx	= SHDMA_SLAVE_SDHI1_RX,
 	.tmio_ocr_mask	= MMC_VDD_165_195,
 	.tmio_flags	= TMIO_MMC_WRPROTECT_DISABLE,
+	.tmio_caps	= MMC_CAP_NEEDS_POLL,
+	.get_cd		= slot_cn7_get_cd,
 };
 
 static struct resource sdhi1_resources[] = {
@@ -948,6 +963,10 @@ static void __init ap4evb_init(void)
 	gpio_no_direction(GPIO_PORT9CR);  /* FSIAOBT needs no direction */
 	gpio_no_direction(GPIO_PORT10CR); /* FSIAOLR needs no direction */
 
+	/* card detect pin for MMC slot (CN7) */
+	gpio_request(GPIO_PORT41, NULL);
+	gpio_direction_input(GPIO_PORT41);
+
 	/* set SPU2 clock to 119.6 MHz */
 	clk = clk_get(NULL, "spu_clk");
 	if (!IS_ERR(clk)) {
-- 
1.7.0.4


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

* Re: [PATCH 3/4] sh_mmcif: Allow the platform to specify own get_cd
  2010-08-24 15:27   ` Arnd Hannemann
@ 2010-08-26  4:59     ` Yusuke Goda
  -1 siblings, 0 replies; 18+ messages in thread
From: Yusuke Goda @ 2010-08-26  4:59 UTC (permalink / raw)
  To: Arnd Hannemann; +Cc: ian, sameo, linux-mmc, linux-sh

Hi Arnd

Thanks, your patches!

Arnd Hannemann wrote:
> In some platforms (e.g. AP4EVB) the card detect pin of a slot is not directly
> connected to the sh_mmcif controller, so that polling needs to be used. To
> overcome the overhead induced by querying the controller on each poll cycle,
> card detection can be handled in the platform code more efficiently.
> This patch exposes a get_cd hook for that purpose.
> 
> Signed-off-by: Arnd Hannemann <arnd@arndnet.de>

I confirmed normal operation in the following environment.
 - AP4EVB board
 - CN7 (MMCIF)

Tested-by: Yusuke Goda <yusuke.goda.sx@renesas.com>


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

* Re: [PATCH 3/4] sh_mmcif: Allow the platform to specify own get_cd handler
@ 2010-08-26  4:59     ` Yusuke Goda
  0 siblings, 0 replies; 18+ messages in thread
From: Yusuke Goda @ 2010-08-26  4:59 UTC (permalink / raw)
  To: Arnd Hannemann; +Cc: ian, sameo, linux-mmc, linux-sh

Hi Arnd

Thanks, your patches!

Arnd Hannemann wrote:
> In some platforms (e.g. AP4EVB) the card detect pin of a slot is not directly
> connected to the sh_mmcif controller, so that polling needs to be used. To
> overcome the overhead induced by querying the controller on each poll cycle,
> card detection can be handled in the platform code more efficiently.
> This patch exposes a get_cd hook for that purpose.
> 
> Signed-off-by: Arnd Hannemann <arnd@arndnet.de>

I confirmed normal operation in the following environment.
 - AP4EVB board
 - CN7 (MMCIF)

Tested-by: Yusuke Goda <yusuke.goda.sx@renesas.com>


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

* Re: [PATCH 4/4] ARM: mach-shmobile: ap4evb: Fix hotplug for SDHI1
  2010-08-24 15:27   ` Arnd Hannemann
@ 2010-08-26  5:00     ` Yusuke Goda
  -1 siblings, 0 replies; 18+ messages in thread
From: Yusuke Goda @ 2010-08-26  5:00 UTC (permalink / raw)
  To: Arnd Hannemann; +Cc: ian, sameo, linux-mmc, linux-sh


Arnd Hannemann wrote:
> On AP4EVB the card detect pin of the top SD/MMC slot is not directly connected
> to the tmio/mmcif controller but to a GPIO pin, so polling needs to be done for
> SDHI1 and MMCIF in order to support hotplug for that slot. SHDI1 and MMCIF
> share that slot, and the used controller is selected by a DIP switch.
> This patch adds a helper function to check if a card is present in that
> particular slot, registers this function with SDHI1 and MMCIF and enables
> polling for SDHI1.
> 
> Signed-off-by: Arnd Hannemann <arnd@arndnet.de>

I confirmed normal operation in the following environment.
 - AP4EVB board
 - CN7 (MMCIF)

Tested-by: Yusuke Goda <yusuke.goda.sx@renesas.com>


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

* Re: [PATCH 4/4] ARM: mach-shmobile: ap4evb: Fix hotplug for SDHI1
@ 2010-08-26  5:00     ` Yusuke Goda
  0 siblings, 0 replies; 18+ messages in thread
From: Yusuke Goda @ 2010-08-26  5:00 UTC (permalink / raw)
  To: Arnd Hannemann; +Cc: ian, sameo, linux-mmc, linux-sh


Arnd Hannemann wrote:
> On AP4EVB the card detect pin of the top SD/MMC slot is not directly connected
> to the tmio/mmcif controller but to a GPIO pin, so polling needs to be done for
> SDHI1 and MMCIF in order to support hotplug for that slot. SHDI1 and MMCIF
> share that slot, and the used controller is selected by a DIP switch.
> This patch adds a helper function to check if a card is present in that
> particular slot, registers this function with SDHI1 and MMCIF and enables
> polling for SDHI1.
> 
> Signed-off-by: Arnd Hannemann <arnd@arndnet.de>

I confirmed normal operation in the following environment.
 - AP4EVB board
 - CN7 (MMCIF)

Tested-by: Yusuke Goda <yusuke.goda.sx@renesas.com>


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

* Re: [PATCH 1/4] tmio_mmc: Allow the mfd driver to specify get_cd
  2010-08-24 15:26   ` Arnd Hannemann
@ 2010-09-10 16:10     ` Samuel Ortiz
  -1 siblings, 0 replies; 18+ messages in thread
From: Samuel Ortiz @ 2010-09-10 16:10 UTC (permalink / raw)
  To: Arnd Hannemann; +Cc: ian, linux-mmc, linux-sh, yusuke.goda.sx

On Tue, Aug 24, 2010 at 05:26:59PM +0200, Arnd Hannemann wrote:
> Some controllers, supported by the tmio_mmc driver do not have the card detect
> pin of a slot connected, so that polling needs to be used and card detection is
> handled by other means.
> This patch exposes a get_cd hook for that purpose.
The patchset looks fine to me. I guess it makes sense to push it through the
MFD tree. Are you ok with that ?

Cheers,
Samuel.

 
> Signed-off-by: Arnd Hannemann <arnd@arndnet.de>
> ---
>  drivers/mmc/host/tmio_mmc.c |   13 +++++++++++++
>  include/linux/mfd/tmio.h    |    1 +
>  2 files changed, 14 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/mmc/host/tmio_mmc.c b/drivers/mmc/host/tmio_mmc.c
> index ee7d0a5..fe2ebf6 100644
> --- a/drivers/mmc/host/tmio_mmc.c
> +++ b/drivers/mmc/host/tmio_mmc.c
> @@ -755,10 +755,23 @@ static int tmio_mmc_get_ro(struct mmc_host *mmc)
>  		(sd_ctrl_read32(host, CTL_STATUS) & TMIO_STAT_WRPROTECT)) ? 0 : 1;
>  }
>  
> +static int tmio_mmc_get_cd(struct mmc_host *mmc)
> +{
> +	struct tmio_mmc_host *host = mmc_priv(mmc);
> +	struct mfd_cell	*cell = host->pdev->dev.platform_data;
> +	struct tmio_mmc_data *pdata = cell->driver_data;
> +
> +	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,
>  };
>  
>  #ifdef CONFIG_PM
> diff --git a/include/linux/mfd/tmio.h b/include/linux/mfd/tmio.h
> index f07425b..24c43bb 100644
> --- a/include/linux/mfd/tmio.h
> +++ b/include/linux/mfd/tmio.h
> @@ -74,6 +74,7 @@ struct tmio_mmc_data {
>  	struct tmio_mmc_dma		*dma;
>  	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);
>  };
>  
>  /*
> -- 
> 1.7.0.4
> 

-- 
Intel Open Source Technology Centre
http://oss.intel.com/

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

* Re: [PATCH 1/4] tmio_mmc: Allow the mfd driver to specify get_cd handler
@ 2010-09-10 16:10     ` Samuel Ortiz
  0 siblings, 0 replies; 18+ messages in thread
From: Samuel Ortiz @ 2010-09-10 16:10 UTC (permalink / raw)
  To: Arnd Hannemann; +Cc: ian, linux-mmc, linux-sh, yusuke.goda.sx

On Tue, Aug 24, 2010 at 05:26:59PM +0200, Arnd Hannemann wrote:
> Some controllers, supported by the tmio_mmc driver do not have the card detect
> pin of a slot connected, so that polling needs to be used and card detection is
> handled by other means.
> This patch exposes a get_cd hook for that purpose.
The patchset looks fine to me. I guess it makes sense to push it through the
MFD tree. Are you ok with that ?

Cheers,
Samuel.

 
> Signed-off-by: Arnd Hannemann <arnd@arndnet.de>
> ---
>  drivers/mmc/host/tmio_mmc.c |   13 +++++++++++++
>  include/linux/mfd/tmio.h    |    1 +
>  2 files changed, 14 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/mmc/host/tmio_mmc.c b/drivers/mmc/host/tmio_mmc.c
> index ee7d0a5..fe2ebf6 100644
> --- a/drivers/mmc/host/tmio_mmc.c
> +++ b/drivers/mmc/host/tmio_mmc.c
> @@ -755,10 +755,23 @@ static int tmio_mmc_get_ro(struct mmc_host *mmc)
>  		(sd_ctrl_read32(host, CTL_STATUS) & TMIO_STAT_WRPROTECT)) ? 0 : 1;
>  }
>  
> +static int tmio_mmc_get_cd(struct mmc_host *mmc)
> +{
> +	struct tmio_mmc_host *host = mmc_priv(mmc);
> +	struct mfd_cell	*cell = host->pdev->dev.platform_data;
> +	struct tmio_mmc_data *pdata = cell->driver_data;
> +
> +	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,
>  };
>  
>  #ifdef CONFIG_PM
> diff --git a/include/linux/mfd/tmio.h b/include/linux/mfd/tmio.h
> index f07425b..24c43bb 100644
> --- a/include/linux/mfd/tmio.h
> +++ b/include/linux/mfd/tmio.h
> @@ -74,6 +74,7 @@ struct tmio_mmc_data {
>  	struct tmio_mmc_dma		*dma;
>  	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);
>  };
>  
>  /*
> -- 
> 1.7.0.4
> 

-- 
Intel Open Source Technology Centre
http://oss.intel.com/

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

* Re: [PATCH 1/4] tmio_mmc: Allow the mfd driver to specify get_cd
  2010-09-10 16:10     ` [PATCH 1/4] tmio_mmc: Allow the mfd driver to specify get_cd handler Samuel Ortiz
@ 2010-09-12 12:51       ` Arnd Hannemann
  -1 siblings, 0 replies; 18+ messages in thread
From: Arnd Hannemann @ 2010-09-12 12:51 UTC (permalink / raw)
  To: Samuel Ortiz; +Cc: ian, linux-mmc, linux-sh, yusuke.goda.sx

AM 10.09.2010 18:10, schrieb Samuel Ortiz:
> On Tue, Aug 24, 2010 at 05:26:59PM +0200, Arnd Hannemann wrote:
>> Some controllers, supported by the tmio_mmc driver do not have the
>> card detect pin of a slot connected, so that polling needs to be
>> used and card detection is handled by other means. This patch
>> exposes a get_cd hook for that purpose.
> The patchset looks fine to me. I guess it makes sense to push it
> through the MFD tree. Are you ok with that ?

Thats fine with me.

Thanks,
Arnd

>
>> Signed-off-by: Arnd Hannemann <arnd@arndnet.de> ---
>> drivers/mmc/host/tmio_mmc.c |   13 +++++++++++++
>> include/linux/mfd/tmio.h    |    1 + 2 files changed, 14
>> insertions(+), 0 deletions(-)
>>
>> diff --git a/drivers/mmc/host/tmio_mmc.c
>> b/drivers/mmc/host/tmio_mmc.c index ee7d0a5..fe2ebf6 100644 ---
>> a/drivers/mmc/host/tmio_mmc.c +++ b/drivers/mmc/host/tmio_mmc.c @@
>> -755,10 +755,23 @@ static int tmio_mmc_get_ro(struct mmc_host
>> *mmc) (sd_ctrl_read32(host, CTL_STATUS) & TMIO_STAT_WRPROTECT)) ? 0
>> : 1; }
>>
>> +static int tmio_mmc_get_cd(struct mmc_host *mmc) +{ +    struct
>> tmio_mmc_host *host = mmc_priv(mmc); +    struct mfd_cell    *cell >> host->pdev->dev.platform_data; +    struct tmio_mmc_data *pdata >> cell->driver_data; + +    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, };
>>
>> #ifdef CONFIG_PM diff --git a/include/linux/mfd/tmio.h
>> b/include/linux/mfd/tmio.h index f07425b..24c43bb 100644 ---
>> a/include/linux/mfd/tmio.h +++ b/include/linux/mfd/tmio.h @@ -74,6
>> +74,7 @@ struct tmio_mmc_data { struct tmio_mmc_dma        *dma; 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); };
>>
>> /* -- 1.7.0.4
>>
>



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

* Re: [PATCH 1/4] tmio_mmc: Allow the mfd driver to specify get_cd handler
@ 2010-09-12 12:51       ` Arnd Hannemann
  0 siblings, 0 replies; 18+ messages in thread
From: Arnd Hannemann @ 2010-09-12 12:51 UTC (permalink / raw)
  To: Samuel Ortiz; +Cc: ian, linux-mmc, linux-sh, yusuke.goda.sx

AM 10.09.2010 18:10, schrieb Samuel Ortiz:
> On Tue, Aug 24, 2010 at 05:26:59PM +0200, Arnd Hannemann wrote:
>> Some controllers, supported by the tmio_mmc driver do not have the
>> card detect pin of a slot connected, so that polling needs to be
>> used and card detection is handled by other means. This patch
>> exposes a get_cd hook for that purpose.
> The patchset looks fine to me. I guess it makes sense to push it
> through the MFD tree. Are you ok with that ?

Thats fine with me.

Thanks,
Arnd

>
>> Signed-off-by: Arnd Hannemann <arnd@arndnet.de> ---
>> drivers/mmc/host/tmio_mmc.c |   13 +++++++++++++
>> include/linux/mfd/tmio.h    |    1 + 2 files changed, 14
>> insertions(+), 0 deletions(-)
>>
>> diff --git a/drivers/mmc/host/tmio_mmc.c
>> b/drivers/mmc/host/tmio_mmc.c index ee7d0a5..fe2ebf6 100644 ---
>> a/drivers/mmc/host/tmio_mmc.c +++ b/drivers/mmc/host/tmio_mmc.c @@
>> -755,10 +755,23 @@ static int tmio_mmc_get_ro(struct mmc_host
>> *mmc) (sd_ctrl_read32(host, CTL_STATUS) & TMIO_STAT_WRPROTECT)) ? 0
>> : 1; }
>>
>> +static int tmio_mmc_get_cd(struct mmc_host *mmc) +{ +    struct
>> tmio_mmc_host *host = mmc_priv(mmc); +    struct mfd_cell    *cell =
>> host->pdev->dev.platform_data; +    struct tmio_mmc_data *pdata =
>> cell->driver_data; + +    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, };
>>
>> #ifdef CONFIG_PM diff --git a/include/linux/mfd/tmio.h
>> b/include/linux/mfd/tmio.h index f07425b..24c43bb 100644 ---
>> a/include/linux/mfd/tmio.h +++ b/include/linux/mfd/tmio.h @@ -74,6
>> +74,7 @@ struct tmio_mmc_data { struct tmio_mmc_dma        *dma; 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); };
>>
>> /* -- 1.7.0.4
>>
>



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

end of thread, other threads:[~2010-09-12 12:51 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-24 15:26 [PATCH 0/4] Fix/improve hotplug for sh_mobile_sdhi/tmio_mmc/sh_mmcif Arnd Hannemann
2010-08-24 15:26 ` Arnd Hannemann
2010-08-24 15:26 ` [PATCH 1/4] tmio_mmc: Allow the mfd driver to specify get_cd handler Arnd Hannemann
2010-08-24 15:26   ` Arnd Hannemann
2010-09-10 16:10   ` [PATCH 1/4] tmio_mmc: Allow the mfd driver to specify get_cd Samuel Ortiz
2010-09-10 16:10     ` [PATCH 1/4] tmio_mmc: Allow the mfd driver to specify get_cd handler Samuel Ortiz
2010-09-12 12:51     ` [PATCH 1/4] tmio_mmc: Allow the mfd driver to specify get_cd Arnd Hannemann
2010-09-12 12:51       ` [PATCH 1/4] tmio_mmc: Allow the mfd driver to specify get_cd handler Arnd Hannemann
2010-08-24 15:27 ` [PATCH 2/4] sh_mobile_sdhi: Allow the platform to specify get_cd Arnd Hannemann
2010-08-24 15:27   ` [PATCH 2/4] sh_mobile_sdhi: Allow the platform to specify get_cd handler Arnd Hannemann
2010-08-24 15:27 ` [PATCH 3/4] sh_mmcif: Allow the platform to specify own " Arnd Hannemann
2010-08-24 15:27   ` Arnd Hannemann
2010-08-26  4:59   ` [PATCH 3/4] sh_mmcif: Allow the platform to specify own get_cd Yusuke Goda
2010-08-26  4:59     ` [PATCH 3/4] sh_mmcif: Allow the platform to specify own get_cd handler Yusuke Goda
2010-08-24 15:27 ` [PATCH 4/4] ARM: mach-shmobile: ap4evb: Fix hotplug for SDHI1 Arnd Hannemann
2010-08-24 15:27   ` Arnd Hannemann
2010-08-26  5:00   ` Yusuke Goda
2010-08-26  5:00     ` Yusuke Goda

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.