linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] mmc: add a card-event host call-back
@ 2012-12-04 15:51 Guennadi Liakhovetski
  2012-12-04 15:51 ` [PATCH 1/3] mmc: add a card-event host operation Guennadi Liakhovetski
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Guennadi Liakhovetski @ 2012-12-04 15:51 UTC (permalink / raw)
  To: linux-arm-kernel

In a recent thread [1] an extension to the slot-gpio MMC API, adding a 
host call-back for card detection events, has been proposed. This 
extension shall be used by the SDHCI driver to reset the host if the card 
is ejected during a running request. These patches add such a call-back.


Thanks
Guennadi

[1] http://thread.gmane.org/gmane.linux.kernel.mmc/17924/focus=17927

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

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

* [PATCH 1/3] mmc: add a card-event host operation
  2012-12-04 15:51 [PATCH 0/3] mmc: add a card-event host call-back Guennadi Liakhovetski
@ 2012-12-04 15:51 ` Guennadi Liakhovetski
  2012-12-04 15:51 ` [PATCH 2/3] mmc: extend the slot-gpio card-detection to use host's .card_event() method Guennadi Liakhovetski
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Guennadi Liakhovetski @ 2012-12-04 15:51 UTC (permalink / raw)
  To: linux-arm-kernel

Some hosts need to perform additional actions upon card insertion or
ejection. Add a host operation to be called from card detection handlers.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
---
 include/linux/mmc/host.h |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
index 7abb0e1..79ead24 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -136,6 +136,7 @@ struct mmc_host_ops {
 	void	(*enable_preset_value)(struct mmc_host *host, bool enable);
 	int	(*select_drive_strength)(unsigned int max_dtr, int host_drv, int card_drv);
 	void	(*hw_reset)(struct mmc_host *host);
+	void	(*card_event)(struct mmc_host *host);
 };
 
 struct mmc_card;
-- 
1.7.2.5

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

* [PATCH 2/3] mmc: extend the slot-gpio card-detection to use host's .card_event() method
  2012-12-04 15:51 [PATCH 0/3] mmc: add a card-event host call-back Guennadi Liakhovetski
  2012-12-04 15:51 ` [PATCH 1/3] mmc: add a card-event host operation Guennadi Liakhovetski
@ 2012-12-04 15:51 ` Guennadi Liakhovetski
  2012-12-04 15:51 ` [PATCH 3/3] mmc: sdhci: implement the " Guennadi Liakhovetski
  2012-12-07 13:42 ` [PATCH 0/3] mmc: add a card-event host call-back Shawn Guo
  3 siblings, 0 replies; 6+ messages in thread
From: Guennadi Liakhovetski @ 2012-12-04 15:51 UTC (permalink / raw)
  To: linux-arm-kernel

The slot-gpio API provides a generic card-detection handler. To support a
wider range of hosts it has to call the host's card-event callback, if
implemented. Also increase the debounce interval to 200ms to match the 
SDHCI driver.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
---
 drivers/mmc/core/slot-gpio.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/drivers/mmc/core/slot-gpio.c b/drivers/mmc/core/slot-gpio.c
index 08c6b3d..16a1c0b 100644
--- a/drivers/mmc/core/slot-gpio.c
+++ b/drivers/mmc/core/slot-gpio.c
@@ -27,7 +27,13 @@ struct mmc_gpio {
 static irqreturn_t mmc_gpio_cd_irqt(int irq, void *dev_id)
 {
 	/* Schedule a card detection after a debounce timeout */
-	mmc_detect_change(dev_id, msecs_to_jiffies(100));
+	struct mmc_host *host = dev_id;
+
+	if (host->ops->card_event)
+		host->ops->card_event(host);
+
+	mmc_detect_change(host, msecs_to_jiffies(200));
+
 	return IRQ_HANDLED;
 }
 
-- 
1.7.2.5

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

* [PATCH 3/3] mmc: sdhci: implement the .card_event() method
  2012-12-04 15:51 [PATCH 0/3] mmc: add a card-event host call-back Guennadi Liakhovetski
  2012-12-04 15:51 ` [PATCH 1/3] mmc: add a card-event host operation Guennadi Liakhovetski
  2012-12-04 15:51 ` [PATCH 2/3] mmc: extend the slot-gpio card-detection to use host's .card_event() method Guennadi Liakhovetski
@ 2012-12-04 15:51 ` Guennadi Liakhovetski
  2012-12-07 13:42 ` [PATCH 0/3] mmc: add a card-event host call-back Shawn Guo
  3 siblings, 0 replies; 6+ messages in thread
From: Guennadi Liakhovetski @ 2012-12-04 15:51 UTC (permalink / raw)
  To: linux-arm-kernel

Extracting a part of the SDHCI card tasklet into a .card_event()
implementation allows SDHCI hosts to use generic card-detection
services, e.g. the GPIO slot function.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
---
 drivers/mmc/host/sdhci.c |   48 +++++++++++++++++++++++++--------------------
 1 files changed, 27 insertions(+), 21 deletions(-)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index c7851c0..2323553 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -1994,30 +1994,11 @@ static void sdhci_enable_preset_value(struct mmc_host *mmc, bool enable)
 	sdhci_runtime_pm_put(host);
 }
 
-static const struct mmc_host_ops sdhci_ops = {
-	.request	= sdhci_request,
-	.set_ios	= sdhci_set_ios,
-	.get_ro		= sdhci_get_ro,
-	.hw_reset	= sdhci_hw_reset,
-	.enable_sdio_irq = sdhci_enable_sdio_irq,
-	.start_signal_voltage_switch	= sdhci_start_signal_voltage_switch,
-	.execute_tuning			= sdhci_execute_tuning,
-	.enable_preset_value		= sdhci_enable_preset_value,
-};
-
-/*****************************************************************************\
- *                                                                           *
- * Tasklets                                                                  *
- *                                                                           *
-\*****************************************************************************/
-
-static void sdhci_tasklet_card(unsigned long param)
+static void sdhci_card_event(struct mmc_host *mmc)
 {
-	struct sdhci_host *host;
+	struct sdhci_host *host = mmc_priv(mmc);
 	unsigned long flags;
 
-	host = (struct sdhci_host*)param;
-
 	spin_lock_irqsave(&host->lock, flags);
 
 	/* Check host->mrq first in case we are runtime suspended */
@@ -2036,6 +2017,31 @@ static void sdhci_tasklet_card(unsigned long param)
 	}
 
 	spin_unlock_irqrestore(&host->lock, flags);
+}
+
+static const struct mmc_host_ops sdhci_ops = {
+	.request	= sdhci_request,
+	.set_ios	= sdhci_set_ios,
+	.get_ro		= sdhci_get_ro,
+	.hw_reset	= sdhci_hw_reset,
+	.enable_sdio_irq = sdhci_enable_sdio_irq,
+	.start_signal_voltage_switch	= sdhci_start_signal_voltage_switch,
+	.execute_tuning			= sdhci_execute_tuning,
+	.enable_preset_value		= sdhci_enable_preset_value,
+	.card_event			= sdhci_card_event,
+};
+
+/*****************************************************************************\
+ *                                                                           *
+ * Tasklets                                                                  *
+ *                                                                           *
+\*****************************************************************************/
+
+static void sdhci_tasklet_card(unsigned long param)
+{
+	struct sdhci_host *host = (struct sdhci_host*)param;
+
+	sdhci_card_event(host->mmc);
 
 	mmc_detect_change(host->mmc, msecs_to_jiffies(200));
 }
-- 
1.7.2.5

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

* [PATCH 0/3] mmc: add a card-event host call-back
  2012-12-04 15:51 [PATCH 0/3] mmc: add a card-event host call-back Guennadi Liakhovetski
                   ` (2 preceding siblings ...)
  2012-12-04 15:51 ` [PATCH 3/3] mmc: sdhci: implement the " Guennadi Liakhovetski
@ 2012-12-07 13:42 ` Shawn Guo
  2012-12-07 18:56   ` Chris Ball
  3 siblings, 1 reply; 6+ messages in thread
From: Shawn Guo @ 2012-12-07 13:42 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Dec 04, 2012 at 04:51:28PM +0100, Guennadi Liakhovetski wrote:
> In a recent thread [1] an extension to the slot-gpio MMC API, adding a 
> host call-back for card detection events, has been proposed. This 
> extension shall be used by the SDHCI driver to reset the host if the card 
> is ejected during a running request. These patches add such a call-back.
> 
For the series,

Reviewed-by: Shawn Guo <shawn.guo@linaro.org>

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

* [PATCH 0/3] mmc: add a card-event host call-back
  2012-12-07 13:42 ` [PATCH 0/3] mmc: add a card-event host call-back Shawn Guo
@ 2012-12-07 18:56   ` Chris Ball
  0 siblings, 0 replies; 6+ messages in thread
From: Chris Ball @ 2012-12-07 18:56 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

On Fri, Dec 07 2012, Shawn Guo wrote:
> On Tue, Dec 04, 2012 at 04:51:28PM +0100, Guennadi Liakhovetski wrote:
>> In a recent thread [1] an extension to the slot-gpio MMC API, adding a 
>> host call-back for card detection events, has been proposed. This 
>> extension shall be used by the SDHCI driver to reset the host if the card 
>> is ejected during a running request. These patches add such a call-back.
>> 
> For the series,
>
> Reviewed-by: Shawn Guo <shawn.guo@linaro.org>

Thanks, pushed to mmc-next for 3.8.

- Chris.
-- 
Chris Ball   <cjb@laptop.org>   <http://printf.net/>
One Laptop Per Child

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

end of thread, other threads:[~2012-12-07 18:56 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-04 15:51 [PATCH 0/3] mmc: add a card-event host call-back Guennadi Liakhovetski
2012-12-04 15:51 ` [PATCH 1/3] mmc: add a card-event host operation Guennadi Liakhovetski
2012-12-04 15:51 ` [PATCH 2/3] mmc: extend the slot-gpio card-detection to use host's .card_event() method Guennadi Liakhovetski
2012-12-04 15:51 ` [PATCH 3/3] mmc: sdhci: implement the " Guennadi Liakhovetski
2012-12-07 13:42 ` [PATCH 0/3] mmc: add a card-event host call-back Shawn Guo
2012-12-07 18:56   ` Chris Ball

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