linux-mmc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] mmc:sd hotplug fixes for omap
@ 2012-05-24 20:14 Viswanath Puttagunta
  2012-05-24 20:14 ` [PATCH 1/3] mmc: omap_hsmmc: Errata i705: SD hot unplug Viswanath Puttagunta
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Viswanath Puttagunta @ 2012-05-24 20:14 UTC (permalink / raw)
  To: Linux-mmc
  Cc: T Krishnamoorthy Balaji, Venkatraman S, Semen Protsenko,
	Volodymyr Riazantsev, Viswanath Puttagunta

This patch set has fixes for SD card hotplug for OMAP SOCs.

Viswanath Puttagunta (3):
  mmc: omap_hsmmc: Errata i705: SD hot unplug
  mmc: omap_hsmmc: Errata: Fix SD card removal detection
  mfd: Enable Debounce logic for SD hotplug detection

 drivers/mfd/twl6030-irq.c     |    8 ++++++++
 drivers/mmc/host/omap_hsmmc.c |   41 ++++++++++++++++++++++++++++++++++++++---
 include/linux/i2c/twl.h       |    5 +++++
 3 files changed, 51 insertions(+), 3 deletions(-)

-- 
1.7.4.1


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

* [PATCH 1/3] mmc: omap_hsmmc: Errata i705: SD hot unplug
  2012-05-24 20:14 [PATCH 0/3] mmc:sd hotplug fixes for omap Viswanath Puttagunta
@ 2012-05-24 20:14 ` Viswanath Puttagunta
  2012-05-25  8:37   ` S, Venkatraman
  2012-05-24 20:14 ` [PATCH 2/3] mmc: omap_hsmmc: Errata: Fix SD card removal detection Viswanath Puttagunta
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Viswanath Puttagunta @ 2012-05-24 20:14 UTC (permalink / raw)
  To: Linux-mmc
  Cc: T Krishnamoorthy Balaji, Venkatraman S, Semen Protsenko,
	Volodymyr Riazantsev, Viswanath Puttagunta

Turn off IO & PBIAS cells and then SD card VMMC as soon
as we get disconnect interrupt. Failure to do so might
cause current spikes (latch-up issue) which can potentially
burn the IO cells.

Signed-off-by: Viswanath Puttagunta <vishp@ti.com>
---
 drivers/mmc/host/omap_hsmmc.c |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 56d4499..61d830f 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -1177,10 +1177,17 @@ static irqreturn_t omap_hsmmc_detect(int irq, void *dev_id)
 		carddetect = -ENOSYS;
 	}
 
-	if (carddetect)
+	if (carddetect) {
 		mmc_detect_change(host->mmc, (HZ * 200) / 1000);
-	else
-		mmc_detect_change(host->mmc, (HZ * 50) / 1000);
+	} else {
+		if ((MMC_POWER_OFF != host->power_mode) &&
+				(mmc_slot(host).set_power != NULL)) {
+			mmc_slot(host).set_power(host->dev, host->slot_id,
+						0, 0);
+			host->power_mode = MMC_POWER_OFF;
+		}
+		mmc_detect_change(host->mmc, 0);
+	}
 	return IRQ_HANDLED;
 }
 
-- 
1.7.4.1


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

* [PATCH 2/3] mmc: omap_hsmmc: Errata: Fix SD card removal detection
  2012-05-24 20:14 [PATCH 0/3] mmc:sd hotplug fixes for omap Viswanath Puttagunta
  2012-05-24 20:14 ` [PATCH 1/3] mmc: omap_hsmmc: Errata i705: SD hot unplug Viswanath Puttagunta
@ 2012-05-24 20:14 ` Viswanath Puttagunta
  2012-05-24 20:14 ` [PATCH 3/3] mfd: Enable Debounce logic for SD hotplug detection Viswanath Puttagunta
  2012-05-25  7:20 ` [PATCH 0/3] mmc:sd hotplug fixes for omap S, Venkatraman
  3 siblings, 0 replies; 8+ messages in thread
From: Viswanath Puttagunta @ 2012-05-24 20:14 UTC (permalink / raw)
  To: Linux-mmc
  Cc: T Krishnamoorthy Balaji, Venkatraman S, Semen Protsenko,
	Volodymyr Riazantsev, Viswanath Puttagunta

Because of OMAP4 Silicon errata (i705), we have to turn off the
PBIAS and VMMC for SD card as soon as we get card disconnect
interrupt. Because of this, we don't wait for all higher layer
structures to be dismantled before turning off power. As a side
effect of this, we might end up getting a mmc_request
even after SD is removed and VMMC and PBIAS are turned off.
In that case, just fail the mmc_request and return immediately

Signed-off-by: Viswanath Puttagunta <vishp@ti.com>
Signed-off-by: Semen Protsenko <semen.protsenko@ti.com>
---
 drivers/mmc/host/omap_hsmmc.c |   28 ++++++++++++++++++++++++++++
 1 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 61d830f..49a1a03 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -1180,12 +1180,20 @@ static irqreturn_t omap_hsmmc_detect(int irq, void *dev_id)
 	if (carddetect) {
 		mmc_detect_change(host->mmc, (HZ * 200) / 1000);
 	} else {
+	/*
+	 * Because of OMAP4 Silicon errata (i705), we have to turn off the
+	 * PBIAS and VMMC for SD card as soon as we get card disconnect
+	 * interrupt. Because of this, we don't wait for all higher layer
+	 * structures to be dismantled before turning off power
+	 */
+		mmc_claim_host(host->mmc);
 		if ((MMC_POWER_OFF != host->power_mode) &&
 				(mmc_slot(host).set_power != NULL)) {
 			mmc_slot(host).set_power(host->dev, host->slot_id,
 						0, 0);
 			host->power_mode = MMC_POWER_OFF;
 		}
+		mmc_release_host(host->mmc);
 		mmc_detect_change(host->mmc, 0);
 	}
 	return IRQ_HANDLED;
@@ -1500,6 +1508,26 @@ static void omap_hsmmc_request(struct mmc_host *mmc, struct mmc_request *req)
 	} else if (host->reqs_blocked)
 		host->reqs_blocked = 0;
 	WARN_ON(host->mrq != NULL);
+
+	/*
+	 * Because of OMAP4 Silicon errata (i705), we have to turn off the
+	 * PBIAS and VMMC for SD card as soon as we get card disconnect
+	 * interrupt. Because of this, we don't wait for all higher layer
+	 * structures to be dismantled before turning off power. Because
+	 * of this, we might end up here even after SD card is removed
+	 * and VMMC and PBIAS are turned off. In that case, just fail
+	 * the commands immediately
+	 */
+	if (host->power_mode == MMC_POWER_OFF) {
+		req->cmd->error = EIO;
+		if (req->data)
+			req->data->error = -EIO;
+		dev_warn(mmc_dev(host->mmc),
+			"Card is no longer present\n");
+		mmc_request_done(mmc, req);
+		return;
+	}
+
 	host->mrq = req;
 	err = omap_hsmmc_prepare_data(host, req);
 	if (err) {
-- 
1.7.4.1


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

* [PATCH 3/3] mfd: Enable Debounce logic for SD hotplug detection
  2012-05-24 20:14 [PATCH 0/3] mmc:sd hotplug fixes for omap Viswanath Puttagunta
  2012-05-24 20:14 ` [PATCH 1/3] mmc: omap_hsmmc: Errata i705: SD hot unplug Viswanath Puttagunta
  2012-05-24 20:14 ` [PATCH 2/3] mmc: omap_hsmmc: Errata: Fix SD card removal detection Viswanath Puttagunta
@ 2012-05-24 20:14 ` Viswanath Puttagunta
  2012-05-25  8:22   ` S, Venkatraman
  2012-05-25  7:20 ` [PATCH 0/3] mmc:sd hotplug fixes for omap S, Venkatraman
  3 siblings, 1 reply; 8+ messages in thread
From: Viswanath Puttagunta @ 2012-05-24 20:14 UTC (permalink / raw)
  To: Linux-mmc
  Cc: T Krishnamoorthy Balaji, Venkatraman S, Semen Protsenko,
	Volodymyr Riazantsev, Viswanath Puttagunta

Enable debounce logic in TWL6030 so that erroneous
disconnect/connect interrupts will be suppressed.

This will fix issue where SD card is either plugged
or unplugged very slowly.

Change-Id: Icc3afa4c66b3bc7920f27ff9c9a3f32e67d5833c
Signed-off-by: Viswanath Puttagunta <vishp@ti.com>
---
 drivers/mfd/twl6030-irq.c |    8 ++++++++
 include/linux/i2c/twl.h   |    5 +++++
 2 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/drivers/mfd/twl6030-irq.c b/drivers/mfd/twl6030-irq.c
index b76902f..05bb6e1 100644
--- a/drivers/mfd/twl6030-irq.c
+++ b/drivers/mfd/twl6030-irq.c
@@ -317,6 +317,14 @@ int twl6030_mmc_card_detect_config(void)
 									ret);
 		return ret;
 	}
+	ret = twl_i2c_write_u8(TWL6030_MODULE_ID0,
+				(MMC_MINS_DEB_MASK | MMC_MEXT_DEB_MASK),
+				TWL6030_MMCDEBOUNCING);
+	if (ret < 0) {
+		pr_err("twl6030: Failed to write MMC_MEXT_DEB_MASK %d\n",
+								ret);
+		return ret;
+	}
 
 	return twl6030_irq_base + MMCDETECT_INTR_OFFSET;
 }
diff --git a/include/linux/i2c/twl.h b/include/linux/i2c/twl.h
index 1f90de0..672dcfb 100644
--- a/include/linux/i2c/twl.h
+++ b/include/linux/i2c/twl.h
@@ -147,6 +147,11 @@
 #define SW_FC				(0x1 << 2)
 #define STS_MMC			0x1
 
+#define TWL6030_MMCDEBOUNCING		0xED
+#define MMC_DEB_BYPASS			(0x1 << 7)
+#define MMC_MINS_DEB_MASK		(0xF << 3)
+#define MMC_MEXT_DEB_MASK		(0x7 << 0)
+
 #define TWL6030_CFG_INPUT_PUPD3	0xF2
 #define MMC_PU				(0x1 << 3)
 #define MMC_PD				(0x1 << 2)
-- 
1.7.4.1


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

* Re: [PATCH 0/3] mmc:sd hotplug fixes for omap
  2012-05-24 20:14 [PATCH 0/3] mmc:sd hotplug fixes for omap Viswanath Puttagunta
                   ` (2 preceding siblings ...)
  2012-05-24 20:14 ` [PATCH 3/3] mfd: Enable Debounce logic for SD hotplug detection Viswanath Puttagunta
@ 2012-05-25  7:20 ` S, Venkatraman
  3 siblings, 0 replies; 8+ messages in thread
From: S, Venkatraman @ 2012-05-25  7:20 UTC (permalink / raw)
  To: Viswanath Puttagunta
  Cc: Linux-mmc, T Krishnamoorthy Balaji, Semen Protsenko,
	Volodymyr Riazantsev

On Fri, May 25, 2012 at 1:44 AM, Viswanath Puttagunta <vishp@ti.com> wrote:
> This patch set has fixes for SD card hotplug for OMAP SOCs.
>
> Viswanath Puttagunta (3):
>  mmc: omap_hsmmc: Errata i705: SD hot unplug
>  mmc: omap_hsmmc: Errata: Fix SD card removal detection
>  mfd: Enable Debounce logic for SD hotplug detection

Please copy linux-omap@vger.kernel.org as well, for these patches.
>
>  drivers/mfd/twl6030-irq.c     |    8 ++++++++
>  drivers/mmc/host/omap_hsmmc.c |   41 ++++++++++++++++++++++++++++++++++++++---
>  include/linux/i2c/twl.h       |    5 +++++
>  3 files changed, 51 insertions(+), 3 deletions(-)
>
> --
> 1.7.4.1
>

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

* Re: [PATCH 3/3] mfd: Enable Debounce logic for SD hotplug detection
  2012-05-24 20:14 ` [PATCH 3/3] mfd: Enable Debounce logic for SD hotplug detection Viswanath Puttagunta
@ 2012-05-25  8:22   ` S, Venkatraman
  0 siblings, 0 replies; 8+ messages in thread
From: S, Venkatraman @ 2012-05-25  8:22 UTC (permalink / raw)
  To: Viswanath Puttagunta
  Cc: Linux-mmc, T Krishnamoorthy Balaji, Semen Protsenko,
	Volodymyr Riazantsev

On Fri, May 25, 2012 at 1:44 AM, Viswanath Puttagunta <vishp@ti.com> wrote:
>
> Enable debounce logic in TWL6030 so that erroneous
> disconnect/connect interrupts will be suppressed.
>
> This will fix issue where SD card is either plugged
> or unplugged very slowly.
>
> Change-Id: Icc3afa4c66b3bc7920f27ff9c9a3f32e67d5833c
> Signed-off-by: Viswanath Puttagunta <vishp@ti.com>

Would be better without the Change-Id.
Also, this needs to be posted to linux-omap and linux-mfd, apart from linux-mmc.

> ---
>  drivers/mfd/twl6030-irq.c |    8 ++++++++
>  include/linux/i2c/twl.h   |    5 +++++
>  2 files changed, 13 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/mfd/twl6030-irq.c b/drivers/mfd/twl6030-irq.c
> index b76902f..05bb6e1 100644
> --- a/drivers/mfd/twl6030-irq.c
> +++ b/drivers/mfd/twl6030-irq.c
> @@ -317,6 +317,14 @@ int twl6030_mmc_card_detect_config(void)
>
>  ret);
>                return ret;
>        }
> +       ret = twl_i2c_write_u8(TWL6030_MODULE_ID0,
> +                               (MMC_MINS_DEB_MASK | MMC_MEXT_DEB_MASK),
> +                               TWL6030_MMCDEBOUNCING);
> +       if (ret < 0) {
> +               pr_err("twl6030: Failed to write MMC_MEXT_DEB_MASK %d\n",
> +                                                               ret);
> +               return ret;
> +       }
>
>        return twl6030_irq_base + MMCDETECT_INTR_OFFSET;
>  }
> diff --git a/include/linux/i2c/twl.h b/include/linux/i2c/twl.h
> index 1f90de0..672dcfb 100644
> --- a/include/linux/i2c/twl.h
> +++ b/include/linux/i2c/twl.h
> @@ -147,6 +147,11 @@
>  #define SW_FC                          (0x1 << 2)
>  #define STS_MMC                        0x1
>
> +#define TWL6030_MMCDEBOUNCING          0xED
> +#define MMC_DEB_BYPASS                 (0x1 << 7)
> +#define MMC_MINS_DEB_MASK              (0xF << 3)
> +#define MMC_MEXT_DEB_MASK              (0x7 << 0)

Some description about what these values mean (timing etc) would be helpful.

> +
>  #define TWL6030_CFG_INPUT_PUPD3        0xF2
>  #define MMC_PU                         (0x1 << 3)
>  #define MMC_PD                         (0x1 << 2)
> --
> 1.7.4.1
>

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

* Re: [PATCH 1/3] mmc: omap_hsmmc: Errata i705: SD hot unplug
  2012-05-24 20:14 ` [PATCH 1/3] mmc: omap_hsmmc: Errata i705: SD hot unplug Viswanath Puttagunta
@ 2012-05-25  8:37   ` S, Venkatraman
  2012-05-31 16:39     ` Puttagunta, Viswanath
  0 siblings, 1 reply; 8+ messages in thread
From: S, Venkatraman @ 2012-05-25  8:37 UTC (permalink / raw)
  To: Viswanath Puttagunta
  Cc: Linux-mmc, T Krishnamoorthy Balaji, Semen Protsenko,
	Volodymyr Riazantsev

On Fri, May 25, 2012 at 1:44 AM, Viswanath Puttagunta <vishp@ti.com> wrote:
> Turn off IO & PBIAS cells and then SD card VMMC as soon
> as we get disconnect interrupt. Failure to do so might
> cause current spikes (latch-up issue) which can potentially
> burn the IO cells.
>
> Signed-off-by: Viswanath Puttagunta <vishp@ti.com>
> ---
>  drivers/mmc/host/omap_hsmmc.c |   13 ++++++++++---
>  1 files changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
> index 56d4499..61d830f 100644
> --- a/drivers/mmc/host/omap_hsmmc.c
> +++ b/drivers/mmc/host/omap_hsmmc.c
> @@ -1177,10 +1177,17 @@ static irqreturn_t omap_hsmmc_detect(int irq, void *dev_id)
>                carddetect = -ENOSYS;
>        }
>
> -       if (carddetect)
> +       if (carddetect) {
>                mmc_detect_change(host->mmc, (HZ * 200) / 1000);
> -       else
> -               mmc_detect_change(host->mmc, (HZ * 50) / 1000);
> +       } else {
> +               if ((MMC_POWER_OFF != host->power_mode) &&

Should be if((host->power_mode != MMC_POWER_OFF)

> +                               (mmc_slot(host).set_power != NULL)) {
> +                       mmc_slot(host).set_power(host->dev, host->slot_id,
> +                                               0, 0);
> +                       host->power_mode = MMC_POWER_OFF;

This is just changing the default behaviour, irrespective of whether
the errata is applicable.
What is the effect of this change for other boards / platforms ?

> +               }
> +               mmc_detect_change(host->mmc, 0);
> +       }
>        return IRQ_HANDLED;
>  }
>
> --
> 1.7.4.1
>

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

* Re: [PATCH 1/3] mmc: omap_hsmmc: Errata i705: SD hot unplug
  2012-05-25  8:37   ` S, Venkatraman
@ 2012-05-31 16:39     ` Puttagunta, Viswanath
  0 siblings, 0 replies; 8+ messages in thread
From: Puttagunta, Viswanath @ 2012-05-31 16:39 UTC (permalink / raw)
  To: S, Venkatraman
  Cc: Linux-mmc, T Krishnamoorthy Balaji, Semen Protsenko,
	Volodymyr Riazantsev

On Fri, May 25, 2012 at 1:37 AM, S, Venkatraman <svenkatr@ti.com> wrote:
>
> On Fri, May 25, 2012 at 1:44 AM, Viswanath Puttagunta <vishp@ti.com>
> wrote:
> > Turn off IO & PBIAS cells and then SD card VMMC as soon
> > as we get disconnect interrupt. Failure to do so might
> > cause current spikes (latch-up issue) which can potentially
> > burn the IO cells.
> >
> > Signed-off-by: Viswanath Puttagunta <vishp@ti.com>
> > ---
> >  drivers/mmc/host/omap_hsmmc.c |   13 ++++++++++---
> >  1 files changed, 10 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/mmc/host/omap_hsmmc.c
> > b/drivers/mmc/host/omap_hsmmc.c
> > index 56d4499..61d830f 100644
> > --- a/drivers/mmc/host/omap_hsmmc.c
> > +++ b/drivers/mmc/host/omap_hsmmc.c
> > @@ -1177,10 +1177,17 @@ static irqreturn_t omap_hsmmc_detect(int irq,
> > void *dev_id)
> >                carddetect = -ENOSYS;
> >        }
> >
> > -       if (carddetect)
> > +       if (carddetect) {
> >                mmc_detect_change(host->mmc, (HZ * 200) / 1000);
> > -       else
> > -               mmc_detect_change(host->mmc, (HZ * 50) / 1000);
> > +       } else {
> > +               if ((MMC_POWER_OFF != host->power_mode) &&
>
> Should be if((host->power_mode != MMC_POWER_OFF)
>
> > +                               (mmc_slot(host).set_power != NULL)) {
> > +                       mmc_slot(host).set_power(host->dev,
> > host->slot_id,
> > +                                               0, 0);
> > +                       host->power_mode = MMC_POWER_OFF;
>
> This is just changing the default behaviour, irrespective of whether
> the errata is applicable.
> What is the effect of this change for other boards / platforms ?
>
> > +               }
> > +               mmc_detect_change(host->mmc, 0);
> > +       }
> >        return IRQ_HANDLED;
> >  }
> >
> > --
> > 1.7.4.1
> >

Resending as plain text without any html content/formatting.

I did not see any -ve effects of turning off the power cell as soon as
possible when the SD card is turned off. This is why I did not
differentiate.

- Vish

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

end of thread, other threads:[~2012-05-31 16:39 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-24 20:14 [PATCH 0/3] mmc:sd hotplug fixes for omap Viswanath Puttagunta
2012-05-24 20:14 ` [PATCH 1/3] mmc: omap_hsmmc: Errata i705: SD hot unplug Viswanath Puttagunta
2012-05-25  8:37   ` S, Venkatraman
2012-05-31 16:39     ` Puttagunta, Viswanath
2012-05-24 20:14 ` [PATCH 2/3] mmc: omap_hsmmc: Errata: Fix SD card removal detection Viswanath Puttagunta
2012-05-24 20:14 ` [PATCH 3/3] mfd: Enable Debounce logic for SD hotplug detection Viswanath Puttagunta
2012-05-25  8:22   ` S, Venkatraman
2012-05-25  7:20 ` [PATCH 0/3] mmc:sd hotplug fixes for omap S, Venkatraman

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