Re: [PATCH] mmc: block: add newline to sysfs display of force_ro

2014-09-22 Thread Baruch Siach
Hi Cris, Ulf,

On Mon, Sep 22, 2014 at 10:12:51AM +0300, Baruch Siach wrote:
 Make force_ro consistent with other sysfs entries.
 
 Fixes: 371a689f64b0d ('mmc: MMC boot partitions support')
 Cc: Andrei Warkentin andr...@motorola.com

Andrei's address is bouncing. Added his gmail address instead:

Cc: Andrei Warkentin andrey.warken...@gmail.com

baruch

 Signed-off-by: Baruch Siach bar...@tkos.co.il
 ---
  drivers/mmc/card/block.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
 index ede41f05c392..dad364b09952 100644
 --- a/drivers/mmc/card/block.c
 +++ b/drivers/mmc/card/block.c
 @@ -260,7 +260,7 @@ static ssize_t force_ro_show(struct device *dev, struct 
 device_attribute *attr,
   int ret;
   struct mmc_blk_data *md = mmc_blk_get(dev_to_disk(dev));
  
 - ret = snprintf(buf, PAGE_SIZE, %d,
 + ret = snprintf(buf, PAGE_SIZE, %d\n,
  get_disk_ro(dev_to_disk(dev)) ^
  md-read_only);
   mmc_blk_put(md);
 -- 
 2.1.0

-- 
 http://baruch.siach.name/blog/  ~. .~   Tk Open Systems
=}ooO--U--Ooo{=
   - bar...@tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -
--
To unsubscribe from this list: send the line unsubscribe linux-mmc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] mmc: block: add newline to sysfs display of force_ro

2014-09-22 Thread Baruch Siach
Make force_ro consistent with other sysfs entries.

Fixes: 371a689f64b0d ('mmc: MMC boot partitions support')
Cc: Andrei Warkentin andr...@motorola.com
Signed-off-by: Baruch Siach bar...@tkos.co.il
---
 drivers/mmc/card/block.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index ede41f05c392..dad364b09952 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -260,7 +260,7 @@ static ssize_t force_ro_show(struct device *dev, struct 
device_attribute *attr,
int ret;
struct mmc_blk_data *md = mmc_blk_get(dev_to_disk(dev));
 
-   ret = snprintf(buf, PAGE_SIZE, %d,
+   ret = snprintf(buf, PAGE_SIZE, %d\n,
   get_disk_ro(dev_to_disk(dev)) ^
   md-read_only);
mmc_blk_put(md);
-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-mmc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] mmc: Add delay between CMD6 and CMD13 for Sandisk eMMC cards

2014-09-22 Thread Jean-Michel Hautbois
2014-09-21 19:48 GMT+02:00 Pavel Machek pa...@ucw.cz:
 On Mon 2014-09-15 19:44:28, Jaehoon Chung wrote:
 On 09/15/2014 07:08 PM, Jean-Michel Hautbois wrote:
  Hi Jaehoon,
 
  On 09/09/2014 09:26 PM, Jean-Michel Hautbois wrote:
  Tested on a i.MX6 board, with Sandisk SDIN5D1-2G.
  Without this patch, I/O errors occur.
  This eMMC seems to have a different Manufacturer ID as it reads 0x45
  and not 0x2 as specified in datasheet.
 
  I think this patch don't merge into mainline.
  This is not solution for problem.
  you mentioned the below comment, this is workaround.
 
  Yes
 
 
  Signed-off-by: Jean-Michel Hautbois jean-michel.hautb...@vodalys.com
  ---
   drivers/mmc/core/mmc_ops.c | 9 +
   1 file changed, 9 insertions(+)
 
  diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
  index f51b5ba..91babaa 100644
  --- a/drivers/mmc/core/mmc_ops.c
  +++ b/drivers/mmc/core/mmc_ops.c
  @@ -458,6 +458,15 @@ int __mmc_switch(struct mmc_card *card, u8 set, u8 
  index, u8 value,
if (!use_busy_signal)
return 0;
 
  + /* WORKAROUND: for Sandisk eMMC cards, it might need certain delay
  +  * before sending CMD13 after CMD6
  +  * On SDIN5D1-2G MANFID is 0x45 and not 0x2 as specified in 
  datasheet
  +  */
  + if (card-cid.manfid == CID_MANFID_SANDISK ||
  + card-cid.manfid == 0x45) {
  + msleep(1);
  + }
 
  If it's a general problem of Sandisk SDIN5D1-2G,
  I think you need to verify this problem. And can you use the MMC_FIXUP() 
  and QUIRK?
 
  Well, this is difficult to verify, I know that on all my SDIN5D1-2G I
  have this MANFID different from what is defined by CID_MANFID_SANDISK.
  How should I use MMC_FIXUP ? Like this ?

 I think you need to explain why delay is need.
 i didn't have same card, but it might be your host controller or other 
 problem.

 Datasheet says it is needed, so we need to do the delay.

 Adding pointer to the datasheet (page, chapter) to the comment might be good 
 idea.

I can't find the page saying a delay must be added... Can you point me
to the correct line ?
BTW, the MANFID is 0x45 on SDIN*-L parts. I will add a comment for this too.

JM
--
To unsubscribe from this list: send the line unsubscribe linux-mmc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/4] mmc: slot-gpio: switch to use flags when getting GPIO

2014-09-22 Thread Adrian Hunter
On 08/29/2014 03:16 PM, Ulf Hansson wrote:
 On 27 August 2014 13:00, Linus Walleij linus.wall...@linaro.org wrote:
 When the slot GPIO driver gets the GPIO to be used for card
 detect, it is now possible to specify a flag to have the line
 set up as input. Get rid of the explicit setup call for input
 and use the flag.

 The extra argument works as there are transition varargs
 macros in place in the linux/gpio/consumer.h header, in
 the future we will make the flags argument compulsory.

 Reviewed-by: Alexandre Courbot acour...@nvidia.com
 Signed-off-by: Linus Walleij linus.wall...@linaro.org
 
 Thanks! Applied for next.

Unfortunately it doesn't seem to work.  I needed the patch
below.


From: Adrian Hunter adrian.hun...@intel.com
Date: Mon, 22 Sep 2014 11:01:16 +0300
Subject: [PATCH] gpio: Fix gpio direction flags not getting set

GPIO direction flags are not getting set because
an 'if' statement is the wrong way around.

Signed-off-by: Adrian Hunter adrian.hun...@intel.com
---
 drivers/gpio/gpiolib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 15cc0bb..3b54edf 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -1674,7 +1674,7 @@ struct gpio_desc *__must_check __gpiod_get_index(struct 
device *dev,
set_bit(FLAG_OPEN_SOURCE, desc-flags);
 
/* No particular flag request, return here... */
-   if (flags  GPIOD_FLAGS_BIT_DIR_SET)
+   if (!(flags  GPIOD_FLAGS_BIT_DIR_SET))
return desc;
 
/* Process flags */
-- 
1.8.3.2



 
 Kind regards
 Uffe
 
 ---
  drivers/mmc/core/slot-gpio.c | 6 +-
  1 file changed, 1 insertion(+), 5 deletions(-)

 diff --git a/drivers/mmc/core/slot-gpio.c b/drivers/mmc/core/slot-gpio.c
 index 5f89cb83d5f0..908c2b29e79f 100644
 --- a/drivers/mmc/core/slot-gpio.c
 +++ b/drivers/mmc/core/slot-gpio.c
 @@ -308,14 +308,10 @@ int mmc_gpiod_request_cd(struct mmc_host *host, const 
 char *con_id,
 if (!con_id)
 con_id = ctx-cd_label;

 -   desc = devm_gpiod_get_index(host-parent, con_id, idx);
 +   desc = devm_gpiod_get_index(host-parent, con_id, idx, GPIOD_IN);
 if (IS_ERR(desc))
 return PTR_ERR(desc);

 -   ret = gpiod_direction_input(desc);
 -   if (ret  0)
 -   return ret;
 -
 if (debounce) {
 ret = gpiod_set_debounce(desc, debounce);
 if (ret  0)
 --
 1.9.3

 --
 To unsubscribe from this list: send the line unsubscribe linux-gpio in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
 

--
To unsubscribe from this list: send the line unsubscribe linux-mmc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH V2] mmc: don't request CD IRQ until mmc_start_host()

2014-09-22 Thread Adrian Hunter
On 09/19/2014 06:56 PM, Stephen Warren wrote:
 From: Stephen Warren swar...@nvidia.com
 
 As soon as the CD IRQ is requested, it can trigger, since it's an
 externally controlled event. If it does, delayed_work host-detect will
 be scheduled.
 
 Many host controller probe()s are roughly structured as:
 
 *_probe() {
 host = sdhci_pltfm_init();
 mmc_of_parse(host-mmc);
 rc = sdhci_add_host(host);
 if (rc) {
 sdhci_pltfm_free();
 return rc;
 }
 
 In 3.17, CD IRQs can are enabled quite early via *_probe() -
 mmc_of_parse() - mmc_gpio_request_cd() - mmc_gpiod_request_cd_irq().
 
 Note that in linux-next, mmc_of_parse() calls mmc_gpio*d*_request_cd()
 rather than mmc_gpio_request_cd(), and mmc_gpio*d*_request_cd() doesn't
 call mmc_gpiod_request_cd_irq(). However, this issue still exists if
 mmc_gpio_request_cd() is called directly before mmc_start_host().
 
 sdhci_add_host() may fail part way through (e.g. due to deferred
 probe for a vmmc regulator), and sdhci_pltfm_free() does nothing to
 unrequest the CD IRQ nor cancel the delayed_work. sdhci_pltfm_free() is
 coded to assume that if sdhci_add_host() failed, then the delayed_work
 cannot (or should not) have been triggered.
 
 This can lead to the following with CONFIG_DEBUG_OBJECTS_* enabled, when
 kfree(host) is eventually called inside sdhci_pltfm_free():
 
 WARNING: CPU: 2 PID: 6 at lib/debugobjects.c:263 
 debug_print_object+0x8c/0xb4()
 ODEBUG: free active (active state 0) object type: timer_list hint: 
 delayed_work_timer_fn+0x0/0x18
 
 The object being complained about is host-detect.
 
 There's no need to request the CD IRQ so early; mmc_start_host() already
 requests it. For most SDHCI hosts at least, the typical call path that
 does this is: *_probe() - sdhci_add_host() - mmc_add_host() -
 mmc_start_host().
 
 Ideally, we would solve this by removing the call to
 mmc_gpiod_request_cd_irq() from mmc_gpio_request_cd(). This would match
 mmc_gpio*d*_request_cd(), which already doesn't call
 mmc_gpiod_request_cd_irq(). However, we need to keep the call and make it
 conditional; some host controller drivers call mmc_gpio_request_cd()
 after mmc_start_host() has already been called, and assume that this will
 also call mmc_gpiod_request_cd_irq(). Unfortunately, the only way I could
 find to differentiate the two cases was to add an extra parameter to
 mmc_gpio_request_cd() to provide this information.
 
 This solves the problem (eliminates the kernel error message above),
 since it guarantees that the IRQ can't trigger before mmc_start_host()
 is called.
 
 The critical point here is that once sdhci_add_host() calls
 mmc_add_host() - mmc_start_host(), sdhci_add_host() is coded not to
 fail. In other words, if there's a chance that mmc_start_host() may have
 been called, and CD IRQs triggered, and the delayed_work scheduled,
 sdhci_add_host() won't fail, and so cleanup is no longer via
 sdhci_pltfm_free() (which doesn't free the IRQ or cancel the work queue)
 but instead must be via sdhci_remove_host(), which calls mmc_remove_host()
 - mmc_stop_host(), which does free the IRQ and cancel the work queue.
 
 CC: Russell King li...@arm.linux.org.uk
 Cc: Adrian Hunter adrian.hun...@intel.com
 Cc: Alexandre Courbot acour...@nvidia.com
 Cc: Linus Walleij linus.wall...@linaro.org
 Signed-off-by: Stephen Warren swar...@nvidia.com
 ---
 Note: This is a patch for v3.17 (and perhaps earlier); linux-next doesn't
 have this problem due to other code re-structing. However, I think those
 patches are too large to backport.
 
 v2: Rather than completely removing mmc_gpio_request_cd()'s call to
 mmc_gpiod_request_cd_irq(), make the call conditional.

Drivers that call mmc_gpio_request_cd() after mmc_add_host() need
to be changed to call it before mmc_add_host().

However the interim fix is to put the call to mmc_gpiod_request_cd_irq()
into those drivers (mmc_spi.c, sdhci-sirf.c, tmio_mmc_pio.c) rather than
adding request_irq.  That touches far fewer lines and is much easier to
backport / apply to stable.


 ---
  drivers/mmc/core/host.c|  2 +-
  drivers/mmc/core/slot-gpio.c   | 13 +++--
  drivers/mmc/host/jz4740_mmc.c  |  3 ++-
  drivers/mmc/host/mmc_spi.c |  2 +-
  drivers/mmc/host/mmci.c|  2 +-
  drivers/mmc/host/mvsdio.c  |  2 +-
  drivers/mmc/host/sdhci-esdhc-imx.c |  3 ++-
  drivers/mmc/host/sdhci-pxav3.c |  2 +-
  drivers/mmc/host/sdhci-sirf.c  |  2 +-
  drivers/mmc/host/sdhci-spear.c |  3 ++-
  drivers/mmc/host/sh_mmcif.c|  2 +-
  drivers/mmc/host/tmio_mmc_pio.c|  2 +-
  include/linux/mmc/slot-gpio.h  |  2 +-
  13 files changed, 26 insertions(+), 14 deletions(-)
 
 diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
 index 95cceae96944..217d6c99c11d 100644
 --- a/drivers/mmc/core/host.c
 +++ b/drivers/mmc/core/host.c
 @@ -374,7 +374,7 @@ int mmc_of_parse(struct mmc_host *host)
   if (!(flags  OF_GPIO_ACTIVE_LOW))
   

[PATCH v2 8/8] mmc: sdhci-esdhc-imx: add quirk SDHCI_QUIRK2_BROKEN_HS200 for imx6qdl

2014-09-22 Thread Dong Aisheng
The iMX6Q/DL can not support HS200 mode while iMX6SL and iMX6SX can,
so introduce a new flag to distinguish them.

Signed-off-by: Dong Aisheng b29...@freescale.com
---
 drivers/mmc/host/sdhci-esdhc-imx.c |   10 --
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c 
b/drivers/mmc/host/sdhci-esdhc-imx.c
index 87179c4..16eff00 100644
--- a/drivers/mmc/host/sdhci-esdhc-imx.c
+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
@@ -120,6 +120,8 @@
  * when reading data from the card
  */
 #define ESDHC_FLAG_ERR004536   BIT(7)
+/* The IP supports HS200 mode */
+#define ESDHC_FLAG_HS200   BIT(8)
 
 struct esdhc_soc_data {
u32 flags;
@@ -147,12 +149,13 @@ static struct esdhc_soc_data usdhc_imx6q_data = {
 
 static struct esdhc_soc_data usdhc_imx6sl_data = {
.flags = ESDHC_FLAG_USDHC | ESDHC_FLAG_STD_TUNING
-   | ESDHC_FLAG_HAVE_CAP1 | ESDHC_FLAG_ERR004536,
+   | ESDHC_FLAG_HAVE_CAP1 | ESDHC_FLAG_ERR004536
+   | ESDHC_FLAG_HS200,
 };
 
 static struct esdhc_soc_data usdhc_imx6sx_data = {
.flags = ESDHC_FLAG_USDHC | ESDHC_FLAG_STD_TUNING
-   | ESDHC_FLAG_HAVE_CAP1,
+   | ESDHC_FLAG_HAVE_CAP1 | ESDHC_FLAG_HS200,
 };
 
 struct pltfm_imx_data {
@@ -1063,6 +1066,9 @@ static int sdhci_esdhc_imx_probe(struct platform_device 
*pdev)
host-quirks2 |= SDHCI_QUIRK2_PRESET_VALUE_BROKEN;
host-mmc-caps |= MMC_CAP_1_8V_DDR;
 
+   if (!(imx_data-socdata-flags  ESDHC_FLAG_HS200))
+   host-quirks2 |= SDHCI_QUIRK2_BROKEN_HS200;
+
/*
 * errata ESDHC_FLAG_ERR004536 fix for MX6Q TO1.2 and MX6DL
 * TO1.1, it's harmless for MX6SL
-- 
1.7.8

--
To unsubscribe from this list: send the line unsubscribe linux-mmc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 0/8] mmc: sdhci/imx: a few clean up and fixes

2014-09-22 Thread Dong Aisheng
Change since v1:
  Add patch 6 which resolves a checkpatch warning like below in v1:
0005-mmc-sdhci-do-not-enable-card-cd-wakeup-for-gpio-case.patch has no obvious 
style problems and is ready for submission.
WARNING: DT compatible string fsl,imx6sx-usdhc appears un-documented -- check 
./Documentation/devicetree/bindings/
+   { .compatible = fsl,imx6sx-usdhc, .data = usdhc_imx6sx_data, },

total: 0 errors, 1 warnings, 18 lines checked

Dong Aisheng (8):
  mmc: sdhci-esdhc-imx: remove duplicated lines
  mmc: sdhci-esdhc-imx: usdhc does not have missing card interrupt
issue
  mmc: sdhci-esdhc-imx: add ADMA Length Mismatch errata fix
  mmc: sdhci: do not enable card detect interrupt for gpio cd type
  mmc: sdhci: do not enable card cd wakeup for gpio case
  mmc: sdhci-esdhc-imx: using specific compatible string in binding doc
  mmc: sdhci-esdhc-imx: add imx6sx support
  mmc: sdhci-esdhc-imx: add quirk SDHCI_QUIRK2_BROKEN_HS200 for imx6qdl

 .../devicetree/bindings/mmc/fsl-imx-esdhc.txt  |9 -
 drivers/mmc/host/sdhci-esdhc-imx.c |   44 
 drivers/mmc/host/sdhci.c   |8 +++-
 3 files changed, 49 insertions(+), 12 deletions(-)

-- 
1.7.8

--
To unsubscribe from this list: send the line unsubscribe linux-mmc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 5/8] mmc: sdhci: do not enable card cd wakeup for gpio case

2014-09-22 Thread Dong Aisheng
Do not need to enable the controller card cd interrupt wakeup
if using GPIO as card detect since it's meaningless.

Signed-off-by: Dong Aisheng b29...@freescale.com
---
 drivers/mmc/host/sdhci.c |5 -
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 85cbf45..2b5bba1 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -2561,13 +2561,16 @@ static irqreturn_t sdhci_thread_irq(int irq, void 
*dev_id)
 void sdhci_enable_irq_wakeups(struct sdhci_host *host)
 {
u8 val;
+   int gpio_cd = mmc_gpio_get_cd(host-mmc);
+
u8 mask = SDHCI_WAKE_ON_INSERT | SDHCI_WAKE_ON_REMOVE
| SDHCI_WAKE_ON_INT;
 
val = sdhci_readb(host, SDHCI_WAKE_UP_CONTROL);
val |= mask ;
/* Avoid fake wake up */
-   if (host-quirks  SDHCI_QUIRK_BROKEN_CARD_DETECTION)
+   if (host-quirks  SDHCI_QUIRK_BROKEN_CARD_DETECTION ||
+   !IS_ERR_VALUE(gpio_cd))
val = ~(SDHCI_WAKE_ON_INSERT | SDHCI_WAKE_ON_REMOVE);
sdhci_writeb(host, val, SDHCI_WAKE_UP_CONTROL);
 }
-- 
1.7.8

--
To unsubscribe from this list: send the line unsubscribe linux-mmc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 3/8] mmc: sdhci-esdhc-imx: add ADMA Length Mismatch errata fix

2014-09-22 Thread Dong Aisheng
The uSDHC has an ADMA Length Mismatch errata ERR004536 which may
cause ADMA work abnormally. The errata has already been fixed for
i.MX6Q TO1.2 and i.MX6DL TO1.1 by enable the bit 7 in 0x6c register.
Unfortunately this fix is not included in i.MX6SL.
So we disable ADMA for i.MX6SL and use SDMA instead.

Signed-off-by: Dong Aisheng b29...@freescale.com
---
 drivers/mmc/host/sdhci-esdhc-imx.c |   18 +-
 1 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c 
b/drivers/mmc/host/sdhci-esdhc-imx.c
index 9594bf8..dc0e384 100644
--- a/drivers/mmc/host/sdhci-esdhc-imx.c
+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
@@ -114,6 +114,12 @@
 #define ESDHC_FLAG_STD_TUNING  BIT(5)
 /* The IP has SDHCI_CAPABILITIES_1 register */
 #define ESDHC_FLAG_HAVE_CAP1   BIT(6)
+/*
+ * The IP has errata ERR004536
+ * uSDHC: ADMA Length Mismatch Error occurs if the AHB read access is slow,
+ * when reading data from the card
+ */
+#define ESDHC_FLAG_ERR004536   BIT(7)
 
 struct esdhc_soc_data {
u32 flags;
@@ -141,7 +147,7 @@ static struct esdhc_soc_data usdhc_imx6q_data = {
 
 static struct esdhc_soc_data usdhc_imx6sl_data = {
.flags = ESDHC_FLAG_USDHC | ESDHC_FLAG_STD_TUNING
-   | ESDHC_FLAG_HAVE_CAP1,
+   | ESDHC_FLAG_HAVE_CAP1 | ESDHC_FLAG_ERR004536,
 };
 
 struct pltfm_imx_data {
@@ -1050,6 +1056,13 @@ static int sdhci_esdhc_imx_probe(struct platform_device 
*pdev)
writel(0x08100810, host-ioaddr + ESDHC_WTMK_LVL);
host-quirks2 |= SDHCI_QUIRK2_PRESET_VALUE_BROKEN;
host-mmc-caps |= MMC_CAP_1_8V_DDR;
+
+   /*
+* errata ESDHC_FLAG_ERR004536 fix for MX6Q TO1.2 and MX6DL
+* TO1.1, it's harmless for MX6SL
+*/
+   writel(readl(host-ioaddr + 0x6c) | BIT(7),
+   host-ioaddr + 0x6c);
}
 
if (imx_data-socdata-flags  ESDHC_FLAG_MAN_TUNING)
@@ -1061,6 +1074,9 @@ static int sdhci_esdhc_imx_probe(struct platform_device 
*pdev)
ESDHC_STD_TUNING_EN | ESDHC_TUNING_START_TAP,
host-ioaddr + ESDHC_TUNING_CTRL);
 
+   if (imx_data-socdata-flags  ESDHC_FLAG_ERR004536)
+   host-quirks |= SDHCI_QUIRK_BROKEN_ADMA;
+
boarddata = imx_data-boarddata;
if (sdhci_esdhc_imx_probe_dt(pdev, boarddata)  0) {
if (!host-mmc-parent-platform_data) {
-- 
1.7.8

--
To unsubscribe from this list: send the line unsubscribe linux-mmc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 7/8] mmc: sdhci-esdhc-imx: add imx6sx support

2014-09-22 Thread Dong Aisheng
The imx6sx usdhc is derived from imx6sl, the difference is minor.
imx6sx have the errata ESDHC_FLAG_ERR004536 fixed.
So introduce a new compatible string for imx6sx to distinguish them.

Signed-off-by: Dong Aisheng b29...@freescale.com
---
 drivers/mmc/host/sdhci-esdhc-imx.c |6 ++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c 
b/drivers/mmc/host/sdhci-esdhc-imx.c
index dc0e384..87179c4 100644
--- a/drivers/mmc/host/sdhci-esdhc-imx.c
+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
@@ -150,6 +150,11 @@ static struct esdhc_soc_data usdhc_imx6sl_data = {
| ESDHC_FLAG_HAVE_CAP1 | ESDHC_FLAG_ERR004536,
 };
 
+static struct esdhc_soc_data usdhc_imx6sx_data = {
+   .flags = ESDHC_FLAG_USDHC | ESDHC_FLAG_STD_TUNING
+   | ESDHC_FLAG_HAVE_CAP1,
+};
+
 struct pltfm_imx_data {
u32 scratchpad;
struct pinctrl *pinctrl;
@@ -190,6 +195,7 @@ static const struct of_device_id imx_esdhc_dt_ids[] = {
{ .compatible = fsl,imx35-esdhc, .data = esdhc_imx35_data, },
{ .compatible = fsl,imx51-esdhc, .data = esdhc_imx51_data, },
{ .compatible = fsl,imx53-esdhc, .data = esdhc_imx53_data, },
+   { .compatible = fsl,imx6sx-usdhc, .data = usdhc_imx6sx_data, },
{ .compatible = fsl,imx6sl-usdhc, .data = usdhc_imx6sl_data, },
{ .compatible = fsl,imx6q-usdhc, .data = usdhc_imx6q_data, },
{ /* sentinel */ }
-- 
1.7.8

--
To unsubscribe from this list: send the line unsubscribe linux-mmc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 4/8] mmc: sdhci: do not enable card detect interrupt for gpio cd type

2014-09-22 Thread Dong Aisheng
Except SDHCI_QUIRK_BROKEN_CARD_DETECTION and MMC_CAP_NONREMOVABLE,
we also do not need to handle controller native card detect interrupt
for gpio as card detect case.
If we wrong enabled the card detect interrupt for gpio case,
it will cause a lot of unexpected card detect interrupts during data transfer
which should not happen.

Signed-off-by: Dong Aisheng b29...@freescale.com
---
 drivers/mmc/host/sdhci.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 7481bd8..85cbf45 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -136,9 +136,10 @@ static void sdhci_dumpregs(struct sdhci_host *host)
 static void sdhci_set_card_detection(struct sdhci_host *host, bool enable)
 {
u32 present;
+   int gpio_cd = mmc_gpio_get_cd(host-mmc);
 
if ((host-quirks  SDHCI_QUIRK_BROKEN_CARD_DETECTION) ||
-   (host-mmc-caps  MMC_CAP_NONREMOVABLE))
+   (host-mmc-caps  MMC_CAP_NONREMOVABLE) || !IS_ERR_VALUE(gpio_cd))
return;
 
if (enable) {
-- 
1.7.8

--
To unsubscribe from this list: send the line unsubscribe linux-mmc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 6/8] mmc: sdhci-esdhc-imx: using specific compatible string in binding doc

2014-09-22 Thread Dong Aisheng
Using specific compatible string in binding doc to make the binding
more clear.
It's also used to avoid checkpatch warning in the future like follows:
0005-mmc-sdhci-do-not-enable-card-cd-wakeup-for-gpio-case.patch has no obvious 
style problems and is ready for submission.
WARNING: DT compatible string fsl,imx6sx-usdhc appears un-documented -- check 
./Documentation/devicetree/bindings/
+   { .compatible = fsl,imx6sx-usdhc, .data = usdhc_imx6sx_data, },

total: 0 errors, 1 warnings, 18 lines checked

Signed-off-by: Dong Aisheng b29...@freescale.com
---
 .../devicetree/bindings/mmc/fsl-imx-esdhc.txt  |9 -
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/Documentation/devicetree/bindings/mmc/fsl-imx-esdhc.txt 
b/Documentation/devicetree/bindings/mmc/fsl-imx-esdhc.txt
index 9046ba06..c415d34 100644
--- a/Documentation/devicetree/bindings/mmc/fsl-imx-esdhc.txt
+++ b/Documentation/devicetree/bindings/mmc/fsl-imx-esdhc.txt
@@ -7,7 +7,14 @@ This file documents differences between the core properties 
described
 by mmc.txt and the properties used by the sdhci-esdhc-imx driver.
 
 Required properties:
-- compatible : Should be fsl,chip-esdhc
+- compatible : Should be fsl,chip-esdhc, the supported chips include
+  fsl,imx25-esdhc
+  fsl,imx35-esdhc
+  fsl,imx51-esdhc
+  fsl,imx53-esdhc
+  fsl,imx6q-usdhc
+  fsl,imx6sl-usdhc
+  fsl,imx6sx-usdhc
 
 Optional properties:
 - fsl,cd-controller : Indicate to use controller internal card detection
-- 
1.7.8

--
To unsubscribe from this list: send the line unsubscribe linux-mmc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] mmc: rtsx: add card power off during probe

2014-09-22 Thread Roger Tseng
On Thu, 2014-09-18 at 23:14 +0200, Ulf Hansson wrote:
 [...]
 
 
  In that case, don't forget to enable MMC_CAP2_FULL_PWR_CYCLE.
 
  
   if MMC_CAP2_NO_PRESCAN_POWERUP enable, will call mmc_power_off() at 
   start,
   then it will check ios.power_mode, but the state is MMC_POWER_OFF and 
   just
   return.
 
  Uhh, that's right! So, I wonder why we invokes mmc_power_off() from
  that path at all.
 
  Hmm, I think we should change the behavior in mmc_start_host(), like below:
  1) Add a MMC_POWER_UNDEFINED state which is what the power state
  should be assigned to at allocation.
  2 ) From mmc_start_host(), invoke mmc_power_off() when
  MMC_CAP2_NO_PRESCAN_POWERUP and MMC_CAP2_FULL_PWR_CYCLE is set.
 
  Would that work?
  Yes. I have confirmed this by following changes. The MMC_POWER_UNDEFINED
  designation in mmc_start_host() will eventually cause a power-off
  operation.
 
  But I wonder if we need to additionally check MMC_CAP2_FULL_PWR_CYCLE
  before calling mmc_power_off()?
 
 The intent from my side was to keep the current behaviour for those
 that already used MMC_CAP2_NO_PRESCAN_POWERUP, but it's s not a big
 deal.
 

I checked the log and found the commit that invokes mmc_power_off():
a08b17be8b984a7c51cd5a480cd977363df353f9
0d3e3350d5871c53464be4c92d57198744247005
(https://www.mail-archive.com/linux-mmc@vger.kernel.org/msg19638.html )

The proposed change might bring back some delay since invoking
mmc_power_off() in mmc_start_host() is more than NOP now and triggers
real power-off and re-init in sdhci.

Will this be OK?

 So, let's try your proposal, thus don't check MMC_CAP2_FULL_PWR_CYCLE.
 
 Can you repost new version of your patches and please split them up on
 core and host separately.
 
 Kind regards
 Uffe
 
 --Please consider the environment before printing this e-mail.

-- 
Best regards,
Roger Tseng


[PATCH v2 1/8] mmc: sdhci-esdhc-imx: remove duplicated lines

2014-09-22 Thread Dong Aisheng
There is already the same register check above, no need the later one.
Move them into one place and delete the later one.

Signed-off-by: Dong Aisheng b29...@freescale.com
---
 drivers/mmc/host/sdhci-esdhc-imx.c |   12 +---
 1 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c 
b/drivers/mmc/host/sdhci-esdhc-imx.c
index 587ee0e..256c901 100644
--- a/drivers/mmc/host/sdhci-esdhc-imx.c
+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
@@ -315,6 +315,11 @@ static void esdhc_writel_le(struct sdhci_host *host, u32 
val, int reg)
data |= ESDHC_CTRL_D3CD;
writel(data, host-ioaddr + SDHCI_HOST_CONTROL);
}
+
+   if (val  SDHCI_INT_ADMA_ERROR) {
+   val = ~SDHCI_INT_ADMA_ERROR;
+   val |= ESDHC_INT_VENDOR_SPEC_DMA_ERR;
+   }
}
 
if (unlikely((imx_data-socdata-flags  ESDHC_FLAG_MULTIBLK_NO_INT)
@@ -335,13 +340,6 @@ static void esdhc_writel_le(struct sdhci_host *host, u32 
val, int reg)
}
}
 
-   if (unlikely(reg == SDHCI_INT_ENABLE || reg == SDHCI_SIGNAL_ENABLE)) {
-   if (val  SDHCI_INT_ADMA_ERROR) {
-   val = ~SDHCI_INT_ADMA_ERROR;
-   val |= ESDHC_INT_VENDOR_SPEC_DMA_ERR;
-   }
-   }
-
writel(val, host-ioaddr + reg);
 }
 
-- 
1.7.8

--
To unsubscribe from this list: send the line unsubscribe linux-mmc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 2/8] mmc: sdhci-esdhc-imx: usdhc does not have missing card interrupt issue

2014-09-22 Thread Dong Aisheng
The usdhc does not have missing card interrupt issue, so execute the
workaround conditionally.

Signed-off-by: Dong Aisheng b29...@freescale.com
---
 drivers/mmc/host/sdhci-esdhc-imx.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c 
b/drivers/mmc/host/sdhci-esdhc-imx.c
index 256c901..9594bf8 100644
--- a/drivers/mmc/host/sdhci-esdhc-imx.c
+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
@@ -300,7 +300,7 @@ static void esdhc_writel_le(struct sdhci_host *host, u32 
val, int reg)
u32 data;
 
if (unlikely(reg == SDHCI_INT_ENABLE || reg == SDHCI_SIGNAL_ENABLE)) {
-   if (val  SDHCI_INT_CARD_INT) {
+   if ((val  SDHCI_INT_CARD_INT)  !esdhc_is_usdhc(imx_data)) {
/*
 * Clear and then set D3CD bit to avoid missing the
 * card interrupt.  This is a eSDHC controller problem
-- 
1.7.8

--
To unsubscribe from this list: send the line unsubscribe linux-mmc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 06/13] mmc: sdhci: Add quirk for always getting TC with stop cmd

2014-09-22 Thread Adrian Hunter
Add a quirk for a host controller that always sets
a Transfer Complete interrupt status for the stop
command even when a busy response is not indicated.

Signed-off-by: Adrian Hunter adrian.hun...@intel.com
---
 drivers/mmc/host/sdhci.c  | 8 ++--
 include/linux/mmc/sdhci.h | 2 ++
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 7481bd8..d20d104 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -2224,7 +2224,7 @@ static void sdhci_tuning_timer(unsigned long data)
  *   *
 \*/
 
-static void sdhci_cmd_irq(struct sdhci_host *host, u32 intmask)
+static void sdhci_cmd_irq(struct sdhci_host *host, u32 intmask, u32 *mask)
 {
BUG_ON(intmask == 0);
 
@@ -2271,6 +2271,9 @@ static void sdhci_cmd_irq(struct sdhci_host *host, u32 
intmask)
 
/* The controller does not support the end-of-busy IRQ,
 * fall through and take the SDHCI_INT_RESPONSE */
+   } else if ((host-quirks2  SDHCI_QUIRK2_STOP_WITH_TC) 
+  host-cmd-opcode == MMC_STOP_TRANSMISSION  !host-data) {
+   *mask = ~SDHCI_INT_DATA_END;
}
 
if (intmask  SDHCI_INT_RESPONSE)
@@ -2480,7 +2483,8 @@ static irqreturn_t sdhci_irq(int irq, void *dev_id)
}
 
if (intmask  SDHCI_INT_CMD_MASK)
-   sdhci_cmd_irq(host, intmask  SDHCI_INT_CMD_MASK);
+   sdhci_cmd_irq(host, intmask  SDHCI_INT_CMD_MASK,
+ intmask);
 
if (intmask  SDHCI_INT_DATA_MASK)
sdhci_data_irq(host, intmask  SDHCI_INT_DATA_MASK);
diff --git a/include/linux/mmc/sdhci.h b/include/linux/mmc/sdhci.h
index 0aa85ca..dba793e 100644
--- a/include/linux/mmc/sdhci.h
+++ b/include/linux/mmc/sdhci.h
@@ -98,6 +98,8 @@ struct sdhci_host {
 #define SDHCI_QUIRK2_BROKEN_HS200  (16)
 /* Controller does not support DDR50 */
 #define SDHCI_QUIRK2_BROKEN_DDR50  (17)
+/* Stop command (CMD12) can set Transfer Complete when not using MMC_RSP_BUSY 
*/
+#define SDHCI_QUIRK2_STOP_WITH_TC  (18)
 
int irq;/* Device IRQ */
void __iomem *ioaddr;   /* Mapped address */
-- 
1.8.3.2

--
To unsubscribe from this list: send the line unsubscribe linux-mmc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 03/13] mmc: It is not an error for the card to be removed while suspended

2014-09-22 Thread Adrian Hunter
A removable card can be removed while it is runtime suspended.
Do not print an error message.

Signed-off-by: Adrian Hunter adrian.hun...@intel.com
---
 drivers/mmc/core/mmc.c | 2 +-
 drivers/mmc/core/sd.c  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index ce11d89..1d827eb 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -1804,7 +1804,7 @@ static int mmc_runtime_resume(struct mmc_host *host)
return 0;
 
err = _mmc_resume(host);
-   if (err)
+   if (err  (err != -ENOMEDIUM || (host-caps  MMC_CAP_NONREMOVABLE)))
pr_err(%s: error %d doing aggessive resume\n,
mmc_hostname(host), err);
 
diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
index 2591388..28089b3 100644
--- a/drivers/mmc/core/sd.c
+++ b/drivers/mmc/core/sd.c
@@ -1178,7 +1178,7 @@ static int mmc_sd_runtime_resume(struct mmc_host *host)
return 0;
 
err = _mmc_sd_resume(host);
-   if (err)
+   if (err  (err != -ENOMEDIUM || (host-caps  MMC_CAP_NONREMOVABLE)))
pr_err(%s: error %d doing aggessive resume\n,
mmc_hostname(host), err);
 
-- 
1.8.3.2

--
To unsubscribe from this list: send the line unsubscribe linux-mmc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 08/13] mmc: sdhci-acpi: Add a HID and UID for a SD Card host controller

2014-09-22 Thread Adrian Hunter
Add a HID (INT33BB) and UID (3) for a SD Card host controller.

Signed-off-by: Adrian Hunter adrian.hun...@intel.com
---
 drivers/mmc/host/sdhci-acpi.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mmc/host/sdhci-acpi.c b/drivers/mmc/host/sdhci-acpi.c
index 1bc92c6..c38f089 100644
--- a/drivers/mmc/host/sdhci-acpi.c
+++ b/drivers/mmc/host/sdhci-acpi.c
@@ -207,6 +207,7 @@ static const struct sdhci_acpi_uid_slot sdhci_acpi_uids[] = 
{
{ 80860F14 , 3 , sdhci_acpi_slot_int_sd   },
{ 80860F16 , NULL, sdhci_acpi_slot_int_sd   },
{ INT33BB  , 2 , sdhci_acpi_slot_int_sdio },
+   { INT33BB  , 3 , sdhci_acpi_slot_int_sd },
{ INT33C6  , NULL, sdhci_acpi_slot_int_sdio },
{ INT3436  , NULL, sdhci_acpi_slot_int_sdio },
{ PNP0D40  },
-- 
1.8.3.2

--
To unsubscribe from this list: send the line unsubscribe linux-mmc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 02/13] mmc: Fix incorrect warning when setting 0 Hz via debugfs

2014-09-22 Thread Adrian Hunter
It is possible to turn off the card clock by setting
the frequency to zero via debugfs e.g.

echo 0  /sys/kernel/debug/mmc0/clock

However that produces an incorrect warning that is
designed to warn if the frequency is below the minimum
operating frequency.  So correct the warning.

Signed-off-by: Adrian Hunter adrian.hun...@intel.com
---
 drivers/mmc/core/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index e2e1dd4..16aa7bd 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -995,7 +995,7 @@ void mmc_set_chip_select(struct mmc_host *host, int mode)
  */
 static void __mmc_set_clock(struct mmc_host *host, unsigned int hz)
 {
-   WARN_ON(hz  host-f_min);
+   WARN_ON(hz  hz  host-f_min);
 
if (hz  host-f_max)
hz = host-f_max;
-- 
1.8.3.2

--
To unsubscribe from this list: send the line unsubscribe linux-mmc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 01/13] mmc: Fix use of wrong device in mmc_gpiod_free_cd()

2014-09-22 Thread Adrian Hunter
mmc_gpiod_free_cd() is paired with mmc_gpiod_request_cd()
and both must reference the same device which is the
actual host controller device not the mmc_host class
device.

Signed-off-by: Adrian Hunter adrian.hun...@intel.com
---
 drivers/mmc/core/slot-gpio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mmc/core/slot-gpio.c b/drivers/mmc/core/slot-gpio.c
index e3fce44..06616cd 100644
--- a/drivers/mmc/core/slot-gpio.c
+++ b/drivers/mmc/core/slot-gpio.c
@@ -392,7 +392,7 @@ void mmc_gpiod_free_cd(struct mmc_host *host)
host-slot.cd_irq = -EINVAL;
}
 
-   devm_gpiod_put(host-class_dev, ctx-cd_gpio);
+   devm_gpiod_put(host-parent, ctx-cd_gpio);
 
ctx-cd_gpio = NULL;
 }
-- 
1.8.3.2

--
To unsubscribe from this list: send the line unsubscribe linux-mmc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 10/13] mmc: sdhci-pci: Add Bay Trail and Braswell SD card detect

2014-09-22 Thread Adrian Hunter
Add support for card detect for Bay Trail
and Braswell SD Card host controllers in PCI
mode.

This uses the gpio descriptor API which can find
gpio descriptors, for example, on an ACPI comapnion
device.

Signed-off-by: Adrian Hunter adrian.hun...@intel.com
---
 drivers/mmc/host/sdhci-pci.c | 20 +++-
 drivers/mmc/host/sdhci-pci.h |  4 
 2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/host/sdhci-pci.c b/drivers/mmc/host/sdhci-pci.c
index 31181d8..39499fb 100644
--- a/drivers/mmc/host/sdhci-pci.c
+++ b/drivers/mmc/host/sdhci-pci.c
@@ -24,6 +24,7 @@
 #include linux/io.h
 #include linux/gpio.h
 #include linux/pm_runtime.h
+#include linux/mmc/slot-gpio.h
 #include linux/mmc/sdhci-pci-data.h
 
 #include sdhci.h
@@ -280,6 +281,14 @@ static int byt_sdio_probe_slot(struct sdhci_pci_slot *slot)
return 0;
 }
 
+static int byt_sd_probe_slot(struct sdhci_pci_slot *slot)
+{
+   slot-cd_con_id = NULL;
+   slot-cd_idx = 0;
+   slot-cd_override_level = true;
+   return 0;
+}
+
 static const struct sdhci_pci_fixes sdhci_intel_byt_emmc = {
.allow_runtime_pm = true,
.probe_slot = byt_emmc_probe_slot,
@@ -300,6 +309,7 @@ static const struct sdhci_pci_fixes sdhci_intel_byt_sd = {
  SDHCI_QUIRK2_STOP_WITH_TC,
.allow_runtime_pm = true,
.own_cd_for_runtime_pm = true,
+   .probe_slot = byt_sd_probe_slot,
 };
 
 /* Define Host controllers for Intel Merrifield platform */
@@ -1354,6 +1364,7 @@ static struct sdhci_pci_slot *sdhci_pci_probe_slot(
slot-pci_bar = bar;
slot-rst_n_gpio = -EINVAL;
slot-cd_gpio = -EINVAL;
+   slot-cd_idx = -1;
 
/* Retrieve platform data if there is any */
if (*sdhci_pci_get_data)
@@ -1412,6 +1423,13 @@ static struct sdhci_pci_slot *sdhci_pci_probe_slot(
host-mmc-slotno = slotno;
host-mmc-caps2 |= MMC_CAP2_NO_PRESCAN_POWERUP;
 
+   if (slot-cd_idx = 0 
+   mmc_gpiod_request_cd(host-mmc, slot-cd_con_id, slot-cd_idx,
+slot-cd_override_level, 0)) {
+   dev_warn(pdev-dev, failed to setup card detect gpio\n);
+   slot-cd_idx = -1;
+   }
+
ret = sdhci_add_host(host);
if (ret)
goto remove;
@@ -1424,7 +1442,7 @@ static struct sdhci_pci_slot *sdhci_pci_probe_slot(
 * Note sdhci_pci_add_own_cd() sets slot-cd_gpio to -EINVAL on failure.
 */
if (chip-fixes  chip-fixes-own_cd_for_runtime_pm 
-   !gpio_is_valid(slot-cd_gpio))
+   !gpio_is_valid(slot-cd_gpio)  slot-cd_idx  0)
chip-allow_runtime_pm = false;
 
return slot;
diff --git a/drivers/mmc/host/sdhci-pci.h b/drivers/mmc/host/sdhci-pci.h
index 9c1909b..d57c3d1 100644
--- a/drivers/mmc/host/sdhci-pci.h
+++ b/drivers/mmc/host/sdhci-pci.h
@@ -64,6 +64,10 @@ struct sdhci_pci_slot {
int cd_gpio;
int cd_irq;
 
+   char*cd_con_id;
+   int cd_idx;
+   boolcd_override_level;
+
void (*hw_reset)(struct sdhci_host *host);
 };
 
-- 
1.8.3.2

--
To unsubscribe from this list: send the line unsubscribe linux-mmc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 00/13] mmc: Some Braswell and misc patches

2014-09-22 Thread Adrian Hunter
Hi

Here are some patches to further support for Intel Braswell
SoC plus some miscellaneous changes.

The patches needed for Braswell are:

  mmc: sdhci: Add quirk for always getting TC with stop cmd
  mmc: sdhci-acpi: Set SDHCI_QUIRK2_STOP_WITH_TC for Intel host controllers
  mmc: sdhci-acpi: Add a HID and UID for a SD Card host controller
  mmc: sdhci-pci: Set SDHCI_QUIRK2_STOP_WITH_TC for Intel BYT host 
controllers
  mmc: sdhci-pci: Add Bay Trail and Braswell SD card detect
  mmc: sdhci: Let a driver override timeout clock frequency
  mmc: sdhci-pci: Fix Braswell eMMC timeout clock frequency


Adrian Hunter (13):
  mmc: Fix use of wrong device in mmc_gpiod_free_cd()
  mmc: Fix incorrect warning when setting 0 Hz via debugfs
  mmc: It is not an error for the card to be removed while suspended
  mmc: block: Fix error recovery stop cmd timeout calculation
  mmc: block: Fix SD card stop cmd response type
  mmc: sdhci: Add quirk for always getting TC with stop cmd
  mmc: sdhci-acpi: Set SDHCI_QUIRK2_STOP_WITH_TC for Intel host controllers
  mmc: sdhci-acpi: Add a HID and UID for a SD Card host controller
  mmc: sdhci-pci: Set SDHCI_QUIRK2_STOP_WITH_TC for Intel BYT host 
controllers
  mmc: sdhci-pci: Add Bay Trail and Braswell SD card detect
  mmc: sdhci: Let a driver override timeout clock frequency
  mmc: sdhci-pci: Fix Braswell eMMC timeout clock frequency
  mmc: sdhci: Transfer Complete has higher priority than Data Timeout Error

 drivers/mmc/card/block.c  | 30 --
 drivers/mmc/core/core.c   |  2 +-
 drivers/mmc/core/mmc.c|  2 +-
 drivers/mmc/core/sd.c |  2 +-
 drivers/mmc/core/slot-gpio.c  |  2 +-
 drivers/mmc/host/sdhci-acpi.c |  6 --
 drivers/mmc/host/sdhci-pci.c  | 28 +---
 drivers/mmc/host/sdhci-pci.h  |  4 
 drivers/mmc/host/sdhci.c  | 27 +++
 include/linux/mmc/sdhci.h |  2 ++
 10 files changed, 82 insertions(+), 23 deletions(-)


Regards
Adrian
--
To unsubscribe from this list: send the line unsubscribe linux-mmc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 13/13] mmc: sdhci: Transfer Complete has higher priority than Data Timeout Error

2014-09-22 Thread Adrian Hunter
According to the SD Host Controller Standard Specification:

...Transfer Complete has higher priority than Data Timeout
Error. If both bits are set to 1, execution of a command
can be considered to be completed.

Adjust the checking of SDHCI_INT_DATA_TIMEOUT and
SDHCI_INT_DATA_END (Transfer Complete) accordingly.

Signed-off-by: Adrian Hunter adrian.hun...@intel.com
---
 drivers/mmc/host/sdhci.c | 13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 8588550..6ada726 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -2332,11 +2332,6 @@ static void sdhci_data_irq(struct sdhci_host *host, u32 
intmask)
 * above in sdhci_cmd_irq().
 */
if (host-cmd  (host-cmd-flags  MMC_RSP_BUSY)) {
-   if (intmask  SDHCI_INT_DATA_TIMEOUT) {
-   host-cmd-error = -ETIMEDOUT;
-   tasklet_schedule(host-finish_tasklet);
-   return;
-   }
if (intmask  SDHCI_INT_DATA_END) {
/*
 * Some cards handle busy-end interrupt
@@ -2349,6 +2344,11 @@ static void sdhci_data_irq(struct sdhci_host *host, u32 
intmask)
host-busy_handle = 1;
return;
}
+   if (intmask  SDHCI_INT_DATA_TIMEOUT) {
+   host-cmd-error = -ETIMEDOUT;
+   tasklet_schedule(host-finish_tasklet);
+   return;
+   }
}
 
pr_err(%s: Got data interrupt 0x%08x even 
@@ -2359,7 +2359,8 @@ static void sdhci_data_irq(struct sdhci_host *host, u32 
intmask)
return;
}
 
-   if (intmask  SDHCI_INT_DATA_TIMEOUT)
+   if ((intmask  SDHCI_INT_DATA_TIMEOUT) 
+   !(intmask  SDHCI_INT_DATA_END))
host-data-error = -ETIMEDOUT;
else if (intmask  SDHCI_INT_DATA_END_BIT)
host-data-error = -EILSEQ;
-- 
1.8.3.2

--
To unsubscribe from this list: send the line unsubscribe linux-mmc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 09/13] mmc: sdhci-pci: Set SDHCI_QUIRK2_STOP_WITH_TC for Intel BYT host controllers

2014-09-22 Thread Adrian Hunter
Add quirk SDHCI_QUIRK2_STOP_WITH_TC for Intel BYT host controllers.

Signed-off-by: Adrian Hunter adrian.hun...@intel.com
---
 drivers/mmc/host/sdhci-pci.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/sdhci-pci.c b/drivers/mmc/host/sdhci-pci.c
index 580073b..31181d8 100644
--- a/drivers/mmc/host/sdhci-pci.c
+++ b/drivers/mmc/host/sdhci-pci.c
@@ -283,7 +283,8 @@ static int byt_sdio_probe_slot(struct sdhci_pci_slot *slot)
 static const struct sdhci_pci_fixes sdhci_intel_byt_emmc = {
.allow_runtime_pm = true,
.probe_slot = byt_emmc_probe_slot,
-   .quirks2= SDHCI_QUIRK2_PRESET_VALUE_BROKEN,
+   .quirks2= SDHCI_QUIRK2_PRESET_VALUE_BROKEN |
+ SDHCI_QUIRK2_STOP_WITH_TC,
 };
 
 static const struct sdhci_pci_fixes sdhci_intel_byt_sdio = {
@@ -295,7 +296,8 @@ static const struct sdhci_pci_fixes sdhci_intel_byt_sdio = {
 
 static const struct sdhci_pci_fixes sdhci_intel_byt_sd = {
.quirks2= SDHCI_QUIRK2_CARD_ON_NEEDS_BUS_ON |
-   SDHCI_QUIRK2_PRESET_VALUE_BROKEN,
+ SDHCI_QUIRK2_PRESET_VALUE_BROKEN |
+ SDHCI_QUIRK2_STOP_WITH_TC,
.allow_runtime_pm = true,
.own_cd_for_runtime_pm = true,
 };
-- 
1.8.3.2

--
To unsubscribe from this list: send the line unsubscribe linux-mmc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 07/13] mmc: sdhci-acpi: Set SDHCI_QUIRK2_STOP_WITH_TC for Intel host controllers

2014-09-22 Thread Adrian Hunter
Add quirk SDHCI_QUIRK2_STOP_WITH_TC for Intel host controllers.

Signed-off-by: Adrian Hunter adrian.hun...@intel.com
---
 drivers/mmc/host/sdhci-acpi.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/sdhci-acpi.c b/drivers/mmc/host/sdhci-acpi.c
index 3483c08..1bc92c6 100644
--- a/drivers/mmc/host/sdhci-acpi.c
+++ b/drivers/mmc/host/sdhci-acpi.c
@@ -175,7 +175,7 @@ static const struct sdhci_acpi_slot 
sdhci_acpi_slot_int_emmc = {
   MMC_CAP_HW_RESET | MMC_CAP_1_8V_DDR,
.caps2   = MMC_CAP2_HC_ERASE_SZ,
.flags   = SDHCI_ACPI_RUNTIME_PM,
-   .quirks2 = SDHCI_QUIRK2_PRESET_VALUE_BROKEN,
+   .quirks2 = SDHCI_QUIRK2_PRESET_VALUE_BROKEN | SDHCI_QUIRK2_STOP_WITH_TC,
.probe_slot = sdhci_acpi_emmc_probe_slot,
 };
 
@@ -191,7 +191,8 @@ static const struct sdhci_acpi_slot 
sdhci_acpi_slot_int_sdio = {
 static const struct sdhci_acpi_slot sdhci_acpi_slot_int_sd = {
.flags   = SDHCI_ACPI_SD_CD | SDHCI_ACPI_SD_CD_OVERRIDE_LEVEL |
   SDHCI_ACPI_RUNTIME_PM,
-   .quirks2 = SDHCI_QUIRK2_CARD_ON_NEEDS_BUS_ON,
+   .quirks2 = SDHCI_QUIRK2_CARD_ON_NEEDS_BUS_ON |
+  SDHCI_QUIRK2_STOP_WITH_TC,
.probe_slot = sdhci_acpi_sd_probe_slot,
 };
 
-- 
1.8.3.2

--
To unsubscribe from this list: send the line unsubscribe linux-mmc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 05/13] mmc: block: Fix SD card stop cmd response type

2014-09-22 Thread Adrian Hunter
Nowhere in the SD Association Specifications does
it state that the stop command has an R1 response
type.  It is always R1B.  Change accordingly.

Note that, for SD cards, this puts the situation back
to what it was prior to commit
bcc3e1726d827c2d6f62f0e0e7bbc99eed7ad925.

Signed-off-by: Adrian Hunter adrian.hun...@intel.com
---
 drivers/mmc/card/block.c | 14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index c3770dd..0736efb 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -801,6 +801,9 @@ static int send_stop(struct mmc_card *card, unsigned int 
timeout_ms,
if (host-max_busy_timeout  (timeout_ms  host-max_busy_timeout))
use_r1b_resp = false;
 
+   if (!mmc_card_mmc(card))
+   use_r1b_resp = true;
+
cmd.opcode = MMC_STOP_TRANSMISSION;
if (use_r1b_resp) {
cmd.flags = MMC_RSP_SPI_R1B | MMC_RSP_R1B | MMC_CMD_AC;
@@ -1436,9 +1439,14 @@ static void mmc_blk_rw_rq_prep(struct mmc_queue_req 
*mqrq,
if (rq_data_dir(req) == READ) {
brq-cmd.opcode = readcmd;
brq-data.flags |= MMC_DATA_READ;
-   if (brq-mrq.stop)
-   brq-stop.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 |
-   MMC_CMD_AC;
+   if (brq-mrq.stop) {
+   if (mmc_card_mmc(card))
+   brq-stop.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 |
+ MMC_CMD_AC;
+   else
+   brq-stop.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1B |
+ MMC_CMD_AC;
+   }
} else {
brq-cmd.opcode = writecmd;
brq-data.flags |= MMC_DATA_WRITE;
-- 
1.8.3.2

--
To unsubscribe from this list: send the line unsubscribe linux-mmc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 04/13] mmc: block: Fix error recovery stop cmd timeout calculation

2014-09-22 Thread Adrian Hunter
Data timeout has two components: one in nanoseconds
and one in clock cycles.  Clock cycles were not being
added when using the data timeout for the error
recovery stop cmd timeout.

Signed-off-by: Adrian Hunter adrian.hun...@intel.com
---
 drivers/mmc/card/block.c | 16 +---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index 5d27997..c3770dd 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -945,9 +945,19 @@ static int mmc_blk_cmd_recovery(struct mmc_card *card, 
struct request *req,
 */
if (R1_CURRENT_STATE(status) == R1_STATE_DATA ||
R1_CURRENT_STATE(status) == R1_STATE_RCV) {
-   err = send_stop(card,
-   DIV_ROUND_UP(brq-data.timeout_ns, 100),
-   req, gen_err, stop_status);
+   unsigned int timeout_ms, clock;
+
+   timeout_ms = DIV_ROUND_UP(brq-data.timeout_ns, 100);
+   if (brq-data.timeout_clks) {
+   clock = card-host-actual_clock;
+   if (!clock)
+   clock = card-host-ios.clock;
+   if (clock) {
+   clock = DIV_ROUND_UP(clock, 1000);
+   timeout_ms += brq-data.timeout_clks / clock;
+   }
+   }
+   err = send_stop(card, timeout_ms, req, gen_err, stop_status);
if (err) {
pr_err(%s: error %d sending stop command\n,
   req-rq_disk-disk_name, err);
-- 
1.8.3.2

--
To unsubscribe from this list: send the line unsubscribe linux-mmc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 12/13] mmc: sdhci-pci: Fix Braswell eMMC timeout clock frequency

2014-09-22 Thread Adrian Hunter
Braswell eMMC host controller specifies an incorrect
timeout clock frequncy in the capabilities registers.
The correct value is 1 MHz.

Signed-off-by: Adrian Hunter adrian.hun...@intel.com
---
 drivers/mmc/host/sdhci-pci.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/mmc/host/sdhci-pci.c b/drivers/mmc/host/sdhci-pci.c
index 39499fb..9e791e9 100644
--- a/drivers/mmc/host/sdhci-pci.c
+++ b/drivers/mmc/host/sdhci-pci.c
@@ -272,6 +272,8 @@ static int byt_emmc_probe_slot(struct sdhci_pci_slot *slot)
 MMC_CAP_HW_RESET | MMC_CAP_1_8V_DDR;
slot-host-mmc-caps2 |= MMC_CAP2_HC_ERASE_SZ;
slot-hw_reset = sdhci_pci_int_hw_reset;
+   if (slot-chip-pdev-device == PCI_DEVICE_ID_INTEL_BSW_EMMC)
+   slot-host-timeout_clk = 1000; /* 1000 kHz i.e. 1 MHz */
return 0;
 }
 
-- 
1.8.3.2

--
To unsubscribe from this list: send the line unsubscribe linux-mmc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 11/13] mmc: sdhci: Let a driver override timeout clock frequency

2014-09-22 Thread Adrian Hunter
Let a driver override the timeout clock frequency by
populating it before calling sdhci_add_host().  Note
the value will otherwise be zero because sdhci_host is
zeroed when allocated.

Signed-off-by: Adrian Hunter adrian.hun...@intel.com
---
 drivers/mmc/host/sdhci.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index d20d104..8588550 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -2790,6 +2790,7 @@ int sdhci_add_host(struct sdhci_host *host)
u32 caps[2] = {0, 0};
u32 max_current_caps;
unsigned int ocr_avail;
+   unsigned int override_timeout_clk;
int ret;
 
WARN_ON(host == NULL);
@@ -2803,6 +2804,8 @@ int sdhci_add_host(struct sdhci_host *host)
if (debug_quirks2)
host-quirks2 = debug_quirks2;
 
+   override_timeout_clk = host-timeout_clk;
+
sdhci_do_reset(host, SDHCI_RESET_ALL);
 
host-version = sdhci_readw(host, SDHCI_HOST_VERSION);
@@ -2971,6 +2974,9 @@ int sdhci_add_host(struct sdhci_host *host)
mmc-max_busy_timeout /= host-timeout_clk;
}
 
+   if (override_timeout_clk)
+   host-timeout_clk = override_timeout_clk;
+
mmc-caps |= MMC_CAP_SDIO_IRQ | MMC_CAP_ERASE | MMC_CAP_CMD23;
mmc-caps2 |= MMC_CAP2_SDIO_IRQ_NOTHREAD;
 
-- 
1.8.3.2

--
To unsubscribe from this list: send the line unsubscribe linux-mmc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 00/12] clk: sunxi: Improve MMC clocks support

2014-09-22 Thread Maxime Ripard
Mike,

On Thu, Sep 11, 2014 at 10:18:14PM +0200, Maxime Ripard wrote:
 Hi everyone,
 
 Here is an attempt at improving the MMC clock support in the Allwinner
 SoCs.
 
 Until now, the MMC clocks were having a custom phase function that was
 directly setting an obscure value in the right register, because we
 were not really having any idea of what these values were.
 
 Now that we have more informations, we can introduce a common function
 call to get and set the phase of a particular clock, and use this in
 both our provider and our client.

It would be great that we have that custom phase API out of the kernel
for 3.18, and you were one of the greatest supporters to that idea,
could we please have your view on this?

Thanks,
Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com


signature.asc
Description: Digital signature


[PATCH 0/6] unshare and simplify omap_hsmmc platform struct

2014-09-22 Thread Andreas Fenkart
mmci and omap_hsmmc share very little fields in the platform
struct. unsharing significantly simplifies the omap_hsmmc driver

Andreas Fenkart (6):
  omap_hsmmc: unshare platform data struct with mmci driver
  omap_hsmmc: remove unused callbacks from platform data struct
  omap_hsmmc: remove unused fields in platform_data
  omap_hsmmc: remove unused get_context_loss_count callback
  omap_hsmmc: remove un-initialized callbacks from platform data
  omap_hsmmc: remove un-initialized get_cover_state callback

 arch/arm/mach-omap2/hsmmc.c|  61 ++
 arch/arm/mach-omap2/hsmmc.h|  10 --
 arch/arm/mach-omap2/mmc.h  |   6 +-
 .../mach-omap2/omap_hwmod_33xx_43xx_ipblock_data.c |   6 +-
 arch/arm/mach-omap2/omap_hwmod_3xxx_data.c |   6 +-
 drivers/mmc/host/omap_hsmmc.c  | 133 +++--
 include/linux/platform_data/hsmmc-omap.h   | 103 
 7 files changed, 142 insertions(+), 183 deletions(-)
 create mode 100644 include/linux/platform_data/hsmmc-omap.h

-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-mmc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/6] omap_hsmmc: remove unused callbacks from platform data struct

2014-09-22 Thread Andreas Fenkart
driver never references these fields

Signed-off-by: Andreas Fenkart afenk...@gmail.com
---
 arch/arm/mach-omap2/hsmmc.c  | 9 -
 arch/arm/mach-omap2/hsmmc.h  | 4 
 drivers/mmc/host/omap_hsmmc.c| 9 -
 include/linux/platform_data/hsmmc-omap.h | 4 
 4 files changed, 26 deletions(-)

diff --git a/arch/arm/mach-omap2/hsmmc.c b/arch/arm/mach-omap2/hsmmc.c
index e3555f2..d599195 100644
--- a/arch/arm/mach-omap2/hsmmc.c
+++ b/arch/arm/mach-omap2/hsmmc.c
@@ -49,9 +49,6 @@ static void omap_hsmmc1_before_set_reg(struct device *dev, 
int slot,
u32 reg, prog_io;
struct omap_hsmmc_platform_data *mmc = dev-platform_data;
 
-   if (mmc-slots[0].remux)
-   mmc-slots[0].remux(dev, slot, power_on);
-
/*
 * Assume we power both OMAP VMMC1 (for CMD, CLK, DAT0..3) and the
 * card with Vcc regulator (from twl4030 or whatever).  OMAP has both
@@ -137,9 +134,6 @@ static void hsmmc2_before_set_reg(struct device *dev, int 
slot,
 {
struct omap_hsmmc_platform_data *mmc = dev-platform_data;
 
-   if (mmc-slots[0].remux)
-   mmc-slots[0].remux(dev, slot, power_on);
-
if (power_on)
hsmmc2_select_input_clk_src(mmc);
 }
@@ -271,9 +265,6 @@ static int __init omap_hsmmc_pdata_init(struct 
omap2_hsmmc_info *c,
mmc-slots[0].switch_pin = c-gpio_cd;
mmc-slots[0].gpio_wp = c-gpio_wp;
 
-   mmc-slots[0].remux = c-remux;
-   mmc-slots[0].init_card = c-init_card;
-
if (c-cover_only)
mmc-slots[0].cover = 1;
 
diff --git a/arch/arm/mach-omap2/hsmmc.h b/arch/arm/mach-omap2/hsmmc.h
index 7f2e790..a8bc0c2 100644
--- a/arch/arm/mach-omap2/hsmmc.h
+++ b/arch/arm/mach-omap2/hsmmc.h
@@ -29,10 +29,6 @@ struct omap2_hsmmc_info {
int ocr_mask;   /* temporary HACK */
int max_freq;   /* maximum clock, if constrained by external
 * circuitry, or 0 for default */
-   /* Remux (pad configuration) when powering on/off */
-   void (*remux)(struct device *dev, int slot, int power_on);
-   /* init some special card */
-   void (*init_card)(struct mmc_card *card);
 };
 
 #if defined(CONFIG_MMC_OMAP_HS) || defined(CONFIG_MMC_OMAP_HS_MODULE)
diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 5f2b5b7..02f3438 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -1682,14 +1682,6 @@ static int omap_hsmmc_get_ro(struct mmc_host *mmc)
return mmc_slot(host).get_ro(host-dev, 0);
 }
 
-static void omap_hsmmc_init_card(struct mmc_host *mmc, struct mmc_card *card)
-{
-   struct omap_hsmmc_host *host = mmc_priv(mmc);
-
-   if (mmc_slot(host).init_card)
-   mmc_slot(host).init_card(card);
-}
-
 static void omap_hsmmc_enable_sdio_irq(struct mmc_host *mmc, int enable)
 {
struct omap_hsmmc_host *host = mmc_priv(mmc);
@@ -1838,7 +1830,6 @@ static const struct mmc_host_ops omap_hsmmc_ops = {
.set_ios = omap_hsmmc_set_ios,
.get_cd = omap_hsmmc_get_cd,
.get_ro = omap_hsmmc_get_ro,
-   .init_card = omap_hsmmc_init_card,
.enable_sdio_irq = omap_hsmmc_enable_sdio_irq,
 };
 
diff --git a/include/linux/platform_data/hsmmc-omap.h 
b/include/linux/platform_data/hsmmc-omap.h
index cb91db4..7620c21 100644
--- a/include/linux/platform_data/hsmmc-omap.h
+++ b/include/linux/platform_data/hsmmc-omap.h
@@ -116,19 +116,15 @@ struct omap_hsmmc_platform_data {
int switch_pin; /* gpio (card detect) */
int gpio_wp;/* gpio (write protect) */
 
-   int (*set_bus_mode)(struct device *dev, int slot, int bus_mode);
int (*set_power)(struct device *dev, int slot,
 int power_on, int vdd);
int (*get_ro)(struct device *dev, int slot);
-   void (*remux)(struct device *dev, int slot, int power_on);
/* Call back before enabling / disabling regulators */
void (*before_set_reg)(struct device *dev, int slot,
   int power_on, int vdd);
/* Call back after enabling / disabling regulators */
void (*after_set_reg)(struct device *dev, int slot,
  int power_on, int vdd);
-   /* if we have special card, init it using this callback */
-   void (*init_card)(struct mmc_card *card);
 
/* return MMC cover switch state, can be NULL if not supported.
 *
-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-mmc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 5/6] omap_hsmmc: remove un-initialized callbacks from platform data

2014-09-22 Thread Andreas Fenkart
Signed-off-by: Andreas Fenkart afenk...@gmail.com
---
 drivers/mmc/host/omap_hsmmc.c| 15 +--
 include/linux/platform_data/hsmmc-omap.h |  8 
 2 files changed, 1 insertion(+), 22 deletions(-)

diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 02f3438..465c34e 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -2195,18 +2195,10 @@ static int omap_hsmmc_probe(struct platform_device 
*pdev)
goto err_irq;
}
 
-   if (pdata-init != NULL) {
-   if (pdata-init(pdev-dev) != 0) {
-   dev_err(mmc_dev(host-mmc),
-   Unable to configure MMC IRQs\n);
-   goto err_irq;
-   }
-   }
-
if (omap_hsmmc_have_reg()  !mmc_slot(host).set_power) {
ret = omap_hsmmc_reg_get(host);
if (ret)
-   goto err_reg;
+   goto err_irq;
host-use_reg = 1;
}
 
@@ -2269,9 +2261,6 @@ err_slot_name:
 err_irq_cd:
if (host-use_reg)
omap_hsmmc_reg_put(host);
-err_reg:
-   if (host-pdata-cleanup)
-   host-pdata-cleanup(pdev-dev);
 err_irq:
if (host-tx_chan)
dma_release_channel(host-tx_chan);
@@ -2297,8 +2286,6 @@ static int omap_hsmmc_remove(struct platform_device *pdev)
mmc_remove_host(host-mmc);
if (host-use_reg)
omap_hsmmc_reg_put(host);
-   if (host-pdata-cleanup)
-   host-pdata-cleanup(pdev-dev);
 
if (host-tx_chan)
dma_release_channel(host-tx_chan);
diff --git a/include/linux/platform_data/hsmmc-omap.h 
b/include/linux/platform_data/hsmmc-omap.h
index 28b8cff..066075c 100644
--- a/include/linux/platform_data/hsmmc-omap.h
+++ b/include/linux/platform_data/hsmmc-omap.h
@@ -45,14 +45,6 @@ struct omap_hsmmc_platform_data {
 * maximum frequency on the MMC bus */
unsigned int max_freq;
 
-   /* switch the bus to a new slot */
-   int (*switch_slot)(struct device *dev, int slot);
-   /* initialize board-specific MMC functionality, can be NULL if
-* not supported */
-   int (*init)(struct device *dev);
-   void (*cleanup)(struct device *dev);
-   void (*shutdown)(struct device *dev);
-
/* To handle board related suspend/resume functionality for MMC */
int (*suspend)(struct device *dev, int slot);
int (*resume)(struct device *dev, int slot);
-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-mmc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/6] omap_hsmmc: remove unused fields in platform_data

2014-09-22 Thread Andreas Fenkart
Signed-off-by: Andreas Fenkart afenk...@gmail.com
---
 arch/arm/mach-omap2/hsmmc.c  | 13 -
 arch/arm/mach-omap2/hsmmc.h  |  5 -
 include/linux/platform_data/hsmmc-omap.h | 24 
 3 files changed, 42 deletions(-)

diff --git a/arch/arm/mach-omap2/hsmmc.c b/arch/arm/mach-omap2/hsmmc.c
index d599195..2f202bf 100644
--- a/arch/arm/mach-omap2/hsmmc.c
+++ b/arch/arm/mach-omap2/hsmmc.c
@@ -256,7 +256,6 @@ static int __init omap_hsmmc_pdata_init(struct 
omap2_hsmmc_info *c,
mmc-slots[0].name = hc_name;
mmc-nr_slots = 1;
mmc-slots[0].caps = c-caps;
-   mmc-slots[0].pm_caps = c-pm_caps;
mmc-slots[0].internal_clock = !c-ext_clock;
mmc-max_freq = c-max_freq;
mmc-reg_offset = 0;
@@ -271,18 +270,6 @@ static int __init omap_hsmmc_pdata_init(struct 
omap2_hsmmc_info *c,
if (c-nonremovable)
mmc-slots[0].nonremovable = 1;
 
-   if (c-power_saving)
-   mmc-slots[0].power_saving = 1;
-
-   if (c-no_off)
-   mmc-slots[0].no_off = 1;
-
-   if (c-no_off_init)
-   mmc-slots[0].no_regulator_off_init = c-no_off_init;
-
-   if (c-vcc_aux_disable_is_sleep)
-   mmc-slots[0].vcc_aux_disable_is_sleep = 1;
-
/*
 * NOTE:  MMC slots should have a Vcc regulator set up.
 * This may be from a TWL4030-family chip, another
diff --git a/arch/arm/mach-omap2/hsmmc.h b/arch/arm/mach-omap2/hsmmc.h
index a8bc0c2..b18059b 100644
--- a/arch/arm/mach-omap2/hsmmc.h
+++ b/arch/arm/mach-omap2/hsmmc.h
@@ -12,15 +12,10 @@ struct omap2_hsmmc_info {
u8  mmc;/* controller 1/2/3 */
u32 caps;   /* 4/8 wires and any additional host
 * capabilities OR'd (ref. linux/mmc/host.h) */
-   u32 pm_caps;/* PM capabilities */
booltransceiver;/* MMC-2 option */
boolext_clock;  /* use external pin for input clock */
boolcover_only; /* No card detect - just cover switch */
boolnonremovable;   /* Nonremovable e.g. eMMC */
-   boolpower_saving;   /* Try to sleep or power off when possible */
-   boolno_off; /* power_saving and power is not to go off */
-   boolno_off_init;/* no power off when not in MMC sleep state */
-   boolvcc_aux_disable_is_sleep; /* Regulator off remapped to sleep */
booldeferred;   /* mmc needs a deferred probe */
int gpio_cd;/* or -EINVAL */
int gpio_wp;/* or -EINVAL */
diff --git a/include/linux/platform_data/hsmmc-omap.h 
b/include/linux/platform_data/hsmmc-omap.h
index 7620c21..b80460d 100644
--- a/include/linux/platform_data/hsmmc-omap.h
+++ b/include/linux/platform_data/hsmmc-omap.h
@@ -30,8 +30,6 @@
 #define OMAP_HSMMC_BROKEN_MULTIBLOCK_READ  BIT(1)
 #define OMAP_HSMMC_SWAKEUP_MISSING BIT(2)
 
-struct mmc_card;
-
 struct omap_hsmmc_dev_attr {
u8 flags;
 };
@@ -73,16 +71,9 @@ struct omap_hsmmc_platform_data {
 * 4/8 wires and any additional host capabilities
 * need to OR'd all capabilities (ref. linux/mmc/host.h)
 */
-   u8  wires;  /* Used for the MMC driver on omap1 and 2420 */
u32 caps;   /* Used for the MMC driver on 2430 and later */
u32 pm_caps;/* PM capabilities of the mmc */
 
-   /*
-* nomux means standard muxing is wrong on this board, and
-* that board-specific code handled it before common init logic.
-*/
-   unsigned nomux:1;
-
/* switch pin can be for card detect (default) or card cover */
unsigned cover:1;
 
@@ -92,25 +83,13 @@ struct omap_hsmmc_platform_data {
/* nonremovable e.g. eMMC */
unsigned nonremovable:1;
 
-   /* Try to sleep or power off when possible */
-   unsigned power_saving:1;
-
-   /* If using power_saving and the MMC power is not to go off */
-   unsigned no_off:1;
-
/* eMMC does not handle power off when not in sleep state */
unsigned no_regulator_off_init:1;
 
-   /* Regulator off remapped to sleep */
-   unsigned vcc_aux_disable_is_sleep:1;
-
/* we can put the features above into this variable */
 #define HSMMC_HAS_PBIAS(1  0)
 #define HSMMC_HAS_UPDATED_RESET(1  1)
 #define HSMMC_HAS_HSPE_SUPPORT (1  2)
-#define MMC_OMAP7XX(1  3)
-#define MMC_OMAP15XX   (1  4)
-#define MMC_OMAP16XX   (1  5)
unsigned features;
 
int switch_pin; /* gpio (card detect) */
@@ -141,8 +120,5 @@ struct omap_hsmmc_platform_data {
int card_detect_irq;
 
int 

[PATCH 4/6] omap_hsmmc: remove unused get_context_loss_count callback

2014-09-22 Thread Andreas Fenkart
Signed-off-by: Andreas Fenkart afenk...@gmail.com
---
 arch/arm/mach-omap2/hsmmc.c  | 12 
 include/linux/platform_data/hsmmc-omap.h |  3 ---
 2 files changed, 15 deletions(-)

diff --git a/arch/arm/mach-omap2/hsmmc.c b/arch/arm/mach-omap2/hsmmc.c
index 2f202bf..9ed9f70 100644
--- a/arch/arm/mach-omap2/hsmmc.c
+++ b/arch/arm/mach-omap2/hsmmc.c
@@ -32,17 +32,6 @@ static u16 control_devconf1_offset;
 
 #define HSMMC_NAME_LEN 9
 
-#if defined(CONFIG_ARCH_OMAP3)  defined(CONFIG_PM)
-
-static int hsmmc_get_context_loss(struct device *dev)
-{
-   return omap_pm_get_dev_context_loss_count(dev);
-}
-
-#else
-#define hsmmc_get_context_loss NULL
-#endif
-
 static void omap_hsmmc1_before_set_reg(struct device *dev, int slot,
  int power_on, int vdd)
 {
@@ -259,7 +248,6 @@ static int __init omap_hsmmc_pdata_init(struct 
omap2_hsmmc_info *c,
mmc-slots[0].internal_clock = !c-ext_clock;
mmc-max_freq = c-max_freq;
mmc-reg_offset = 0;
-   mmc-get_context_loss_count = hsmmc_get_context_loss;
 
mmc-slots[0].switch_pin = c-gpio_cd;
mmc-slots[0].gpio_wp = c-gpio_wp;
diff --git a/include/linux/platform_data/hsmmc-omap.h 
b/include/linux/platform_data/hsmmc-omap.h
index b80460d..28b8cff 100644
--- a/include/linux/platform_data/hsmmc-omap.h
+++ b/include/linux/platform_data/hsmmc-omap.h
@@ -57,9 +57,6 @@ struct omap_hsmmc_platform_data {
int (*suspend)(struct device *dev, int slot);
int (*resume)(struct device *dev, int slot);
 
-   /* Return context loss count due to PM states changing */
-   int (*get_context_loss_count)(struct device *dev);
-
/* Integrating attributes from the omap_hwmod layer */
u8 controller_flags;
 
-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-mmc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 6/6] omap_hsmmc: remove un-initialized get_cover_state callback

2014-09-22 Thread Andreas Fenkart
Signed-off-by: Andreas Fenkart afenk...@gmail.com
---
 arch/arm/mach-omap2/hsmmc.c  |  3 --
 arch/arm/mach-omap2/hsmmc.h  |  1 -
 drivers/mmc/host/omap_hsmmc.c| 83 ++--
 include/linux/platform_data/hsmmc-omap.h | 10 
 4 files changed, 4 insertions(+), 93 deletions(-)

diff --git a/arch/arm/mach-omap2/hsmmc.c b/arch/arm/mach-omap2/hsmmc.c
index 9ed9f70..068ccf5 100644
--- a/arch/arm/mach-omap2/hsmmc.c
+++ b/arch/arm/mach-omap2/hsmmc.c
@@ -252,9 +252,6 @@ static int __init omap_hsmmc_pdata_init(struct 
omap2_hsmmc_info *c,
mmc-slots[0].switch_pin = c-gpio_cd;
mmc-slots[0].gpio_wp = c-gpio_wp;
 
-   if (c-cover_only)
-   mmc-slots[0].cover = 1;
-
if (c-nonremovable)
mmc-slots[0].nonremovable = 1;
 
diff --git a/arch/arm/mach-omap2/hsmmc.h b/arch/arm/mach-omap2/hsmmc.h
index b18059b..1c4a363 100644
--- a/arch/arm/mach-omap2/hsmmc.h
+++ b/arch/arm/mach-omap2/hsmmc.h
@@ -14,7 +14,6 @@ struct omap2_hsmmc_info {
 * capabilities OR'd (ref. linux/mmc/host.h) */
booltransceiver;/* MMC-2 option */
boolext_clock;  /* use external pin for input clock */
-   boolcover_only; /* No card detect - just cover switch */
boolnonremovable;   /* Nonremovable e.g. eMMC */
booldeferred;   /* mmc needs a deferred probe */
int gpio_cd;/* or -EINVAL */
diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 465c34e..a558c87 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -248,15 +248,6 @@ static int omap_hsmmc_get_wp(struct device *dev, int slot)
return gpio_get_value_cansleep(mmc-slots[0].gpio_wp);
 }
 
-static int omap_hsmmc_get_cover_state(struct device *dev, int slot)
-{
-   struct omap_hsmmc_host *host = dev_get_drvdata(dev);
-   struct omap_hsmmc_platform_data *mmc = host-pdata;
-
-   /* NOTE: assumes card detect signal is active-low */
-   return !gpio_get_value_cansleep(mmc-slots[0].switch_pin);
-}
-
 #ifdef CONFIG_PM
 
 static int omap_hsmmc_suspend_cdirq(struct device *dev, int slot)
@@ -454,11 +445,7 @@ static int omap_hsmmc_gpio_init(struct 
omap_hsmmc_platform_data *pdata)
int ret;
 
if (gpio_is_valid(pdata-slots[0].switch_pin)) {
-   if (pdata-slots[0].cover)
-   pdata-slots[0].get_cover_state =
-   omap_hsmmc_get_cover_state;
-   else
-   pdata-slots[0].card_detect = omap_hsmmc_card_detect;
+   pdata-slots[0].card_detect = omap_hsmmc_card_detect;
pdata-slots[0].card_detect_irq =
gpio_to_irq(pdata-slots[0].switch_pin);
ret = gpio_request(pdata-slots[0].switch_pin, mmc_cd);
@@ -786,29 +773,6 @@ static void send_init_stream(struct omap_hsmmc_host *host)
enable_irq(host-irq);
 }
 
-static inline
-int omap_hsmmc_cover_is_closed(struct omap_hsmmc_host *host)
-{
-   int r = 1;
-
-   if (mmc_slot(host).get_cover_state)
-   r = mmc_slot(host).get_cover_state(host-dev, host-slot_id);
-   return r;
-}
-
-static ssize_t
-omap_hsmmc_show_cover_switch(struct device *dev, struct device_attribute *attr,
-  char *buf)
-{
-   struct mmc_host *mmc = container_of(dev, struct mmc_host, class_dev);
-   struct omap_hsmmc_host *host = mmc_priv(mmc);
-
-   return sprintf(buf, %s\n,
-   omap_hsmmc_cover_is_closed(host) ? closed : open);
-}
-
-static DEVICE_ATTR(cover_switch, S_IRUGO, omap_hsmmc_show_cover_switch, NULL);
-
 static ssize_t
 omap_hsmmc_show_slot_name(struct device *dev, struct device_attribute *attr,
char *buf)
@@ -1256,30 +1220,6 @@ err:
return ret;
 }
 
-/* Protect the card while the cover is open */
-static void omap_hsmmc_protect_card(struct omap_hsmmc_host *host)
-{
-   if (!mmc_slot(host).get_cover_state)
-   return;
-
-   host-reqs_blocked = 0;
-   if (mmc_slot(host).get_cover_state(host-dev, host-slot_id)) {
-   if (host-protect_card) {
-   dev_info(host-dev, %s: cover is closed, 
-card is now accessible\n,
-mmc_hostname(host-mmc));
-   host-protect_card = 0;
-   }
-   } else {
-   if (!host-protect_card) {
-   dev_info(host-dev, %s: cover is open, 
-card is now inaccessible\n,
-mmc_hostname(host-mmc));
-   host-protect_card = 1;
-   }
-   }
-}
-
 /*
  * irq handler to notify the core about card insertion/removal
  */
@@ -1289,15 +1229,10 @@ static irqreturn_t 

[PATCH 1/6] omap_hsmmc: unshare platform data struct with mmci driver

2014-09-22 Thread Andreas Fenkart
- mmci driver supports multiple slots, omap_hsmmc only one
this leads to one of the major confusions in the omap_hsmmc driver

- platform data should be read-only for the driver
most callbacks are not set by the platform init code while being
required by the driver, leading to the fact that they are set by the
driver during it's probe function
typical example are card detect / read only detect callbacks

Signed-off-by: Andreas Fenkart afenk...@gmail.com
---
 arch/arm/mach-omap2/hsmmc.c|  24 ++--
 arch/arm/mach-omap2/mmc.h  |   6 +-
 .../mach-omap2/omap_hwmod_33xx_43xx_ipblock_data.c |   6 +-
 arch/arm/mach-omap2/omap_hwmod_3xxx_data.c |   6 +-
 drivers/mmc/host/omap_hsmmc.c  |  28 ++--
 include/linux/platform_data/hsmmc-omap.h   | 152 +
 6 files changed, 187 insertions(+), 35 deletions(-)

diff --git a/arch/arm/mach-omap2/hsmmc.c b/arch/arm/mach-omap2/hsmmc.c
index 07d4c7b..e3555f2 100644
--- a/arch/arm/mach-omap2/hsmmc.c
+++ b/arch/arm/mach-omap2/hsmmc.c
@@ -47,7 +47,7 @@ static void omap_hsmmc1_before_set_reg(struct device *dev, 
int slot,
  int power_on, int vdd)
 {
u32 reg, prog_io;
-   struct omap_mmc_platform_data *mmc = dev-platform_data;
+   struct omap_hsmmc_platform_data *mmc = dev-platform_data;
 
if (mmc-slots[0].remux)
mmc-slots[0].remux(dev, slot, power_on);
@@ -120,7 +120,7 @@ static void omap_hsmmc1_after_set_reg(struct device *dev, 
int slot,
}
 }
 
-static void hsmmc2_select_input_clk_src(struct omap_mmc_platform_data *mmc)
+static void hsmmc2_select_input_clk_src(struct omap_hsmmc_platform_data *mmc)
 {
u32 reg;
 
@@ -135,7 +135,7 @@ static void hsmmc2_select_input_clk_src(struct 
omap_mmc_platform_data *mmc)
 static void hsmmc2_before_set_reg(struct device *dev, int slot,
   int power_on, int vdd)
 {
-   struct omap_mmc_platform_data *mmc = dev-platform_data;
+   struct omap_hsmmc_platform_data *mmc = dev-platform_data;
 
if (mmc-slots[0].remux)
mmc-slots[0].remux(dev, slot, power_on);
@@ -147,7 +147,7 @@ static void hsmmc2_before_set_reg(struct device *dev, int 
slot,
 static int am35x_hsmmc2_set_power(struct device *dev, int slot,
  int power_on, int vdd)
 {
-   struct omap_mmc_platform_data *mmc = dev-platform_data;
+   struct omap_hsmmc_platform_data *mmc = dev-platform_data;
 
if (power_on)
hsmmc2_select_input_clk_src(mmc);
@@ -161,8 +161,8 @@ static int nop_mmc_set_power(struct device *dev, int slot, 
int power_on,
return 0;
 }
 
-static inline void omap_hsmmc_mux(struct omap_mmc_platform_data 
*mmc_controller,
-   int controller_nr)
+static inline void omap_hsmmc_mux(struct omap_hsmmc_platform_data
+ *mmc_controller, int controller_nr)
 {
if (gpio_is_valid(mmc_controller-slots[0].switch_pin) 
(mmc_controller-slots[0].switch_pin  OMAP_MAX_GPIO_LINES))
@@ -243,7 +243,7 @@ static inline void omap_hsmmc_mux(struct 
omap_mmc_platform_data *mmc_controller,
 }
 
 static int __init omap_hsmmc_pdata_init(struct omap2_hsmmc_info *c,
-   struct omap_mmc_platform_data *mmc)
+   struct omap_hsmmc_platform_data *mmc)
 {
char *hc_name;
 
@@ -368,7 +368,7 @@ static int omap_hsmmc_done;
 void omap_hsmmc_late_init(struct omap2_hsmmc_info *c)
 {
struct platform_device *pdev;
-   struct omap_mmc_platform_data *mmc_pdata;
+   struct omap_hsmmc_platform_data *mmc_pdata;
int res;
 
if (omap_hsmmc_done != 1)
@@ -408,12 +408,12 @@ static void __init omap_hsmmc_init_one(struct 
omap2_hsmmc_info *hsmmcinfo,
struct omap_device *od;
struct platform_device *pdev;
char oh_name[MAX_OMAP_MMC_HWMOD_NAME_LEN];
-   struct omap_mmc_platform_data *mmc_data;
-   struct omap_mmc_dev_attr *mmc_dev_attr;
+   struct omap_hsmmc_platform_data *mmc_data;
+   struct omap_hsmmc_dev_attr *mmc_dev_attr;
char *name;
int res;
 
-   mmc_data = kzalloc(sizeof(struct omap_mmc_platform_data), GFP_KERNEL);
+   mmc_data = kzalloc(sizeof(*mmc_data), GFP_KERNEL);
if (!mmc_data) {
pr_err(Cannot allocate memory for mmc device!\n);
return;
@@ -463,7 +463,7 @@ static void __init omap_hsmmc_init_one(struct 
omap2_hsmmc_info *hsmmcinfo,
}
 
res = platform_device_add_data(pdev, mmc_data,
- sizeof(struct omap_mmc_platform_data));
+ sizeof(struct omap_hsmmc_platform_data));
if (res) {
pr_err(Could not add pdata for %s\n, name);
goto put_pdev;
diff --git a/arch/arm/mach-omap2/mmc.h b/arch/arm/mach-omap2/mmc.h
index 

[PATCH] mmc: omap_hsmmc: Switch to using managed version to gpio request

2014-09-22 Thread Pramod Gurav
This change switches to managed version of gpio_request to simplify
module unloading and failure cases and does away with code to release
gpio resources.

Cc: Balaji T K balaj...@ti.com
Cc: Chris Ball ch...@printf.net
Cc: Ulf Hansson ulf.hans...@linaro.org
Cc: linux-mmc@vger.kernel.org
Signed-off-by: Pramod Gurav pramod.gu...@smartplayin.com
---
 drivers/mmc/host/omap_hsmmc.c |   38 +++---
 1 file changed, 11 insertions(+), 27 deletions(-)

diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 9656726..761d408 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -449,7 +449,8 @@ static inline int omap_hsmmc_have_reg(void)
 
 #endif
 
-static int omap_hsmmc_gpio_init(struct omap_mmc_platform_data *pdata)
+static int omap_hsmmc_gpio_init(struct platform_device *pdev,
+   struct omap_mmc_platform_data *pdata)
 {
int ret;
 
@@ -461,43 +462,29 @@ static int omap_hsmmc_gpio_init(struct 
omap_mmc_platform_data *pdata)
pdata-slots[0].card_detect = omap_hsmmc_card_detect;
pdata-slots[0].card_detect_irq =
gpio_to_irq(pdata-slots[0].switch_pin);
-   ret = gpio_request(pdata-slots[0].switch_pin, mmc_cd);
+   ret = devm_gpio_request(pdev-dev, pdata-slots[0].switch_pin,
+   mmc_cd);
if (ret)
return ret;
ret = gpio_direction_input(pdata-slots[0].switch_pin);
if (ret)
-   goto err_free_sp;
+   return ret;
} else
pdata-slots[0].switch_pin = -EINVAL;
 
if (gpio_is_valid(pdata-slots[0].gpio_wp)) {
pdata-slots[0].get_ro = omap_hsmmc_get_wp;
-   ret = gpio_request(pdata-slots[0].gpio_wp, mmc_wp);
+   ret = devm_gpio_request(pdev-dev, pdata-slots[0].gpio_wp,
+   mmc_wp);
if (ret)
-   goto err_free_cd;
+   return ret;
ret = gpio_direction_input(pdata-slots[0].gpio_wp);
if (ret)
-   goto err_free_wp;
+   return ret;
} else
pdata-slots[0].gpio_wp = -EINVAL;
 
return 0;
-
-err_free_wp:
-   gpio_free(pdata-slots[0].gpio_wp);
-err_free_cd:
-   if (gpio_is_valid(pdata-slots[0].switch_pin))
-err_free_sp:
-   gpio_free(pdata-slots[0].switch_pin);
-   return ret;
-}
-
-static void omap_hsmmc_gpio_free(struct omap_mmc_platform_data *pdata)
-{
-   if (gpio_is_valid(pdata-slots[0].gpio_wp))
-   gpio_free(pdata-slots[0].gpio_wp);
-   if (gpio_is_valid(pdata-slots[0].switch_pin))
-   gpio_free(pdata-slots[0].switch_pin);
 }
 
 /*
@@ -2052,14 +2039,14 @@ static int omap_hsmmc_probe(struct platform_device 
*pdev)
if (IS_ERR(base))
return PTR_ERR(base);
 
-   ret = omap_hsmmc_gpio_init(pdata);
+   ret = omap_hsmmc_gpio_init(pdev, pdata);
if (ret)
goto err;
 
mmc = mmc_alloc_host(sizeof(struct omap_hsmmc_host), pdev-dev);
if (!mmc) {
ret = -ENOMEM;
-   goto err_alloc;
+   goto err;
}
 
host= mmc_priv(mmc);
@@ -2282,8 +2269,6 @@ err_irq:
clk_disable_unprepare(host-dbclk);
 err1:
mmc_free_host(mmc);
-err_alloc:
-   omap_hsmmc_gpio_free(pdata);
 err:
return ret;
 }
@@ -2309,7 +2294,6 @@ static int omap_hsmmc_remove(struct platform_device *pdev)
if (host-dbclk)
clk_disable_unprepare(host-dbclk);
 
-   omap_hsmmc_gpio_free(host-pdata);
mmc_free_host(host-mmc);
 
return 0;
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-mmc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/4] mmc: slot-gpio: switch to use flags when getting GPIO

2014-09-22 Thread Linus Walleij
On Mon, Sep 22, 2014 at 10:20 AM, Adrian Hunter adrian.hun...@intel.com wrote:

 Unfortunately it doesn't seem to work.  I needed the patch
 below.


 From: Adrian Hunter adrian.hun...@intel.com
 Date: Mon, 22 Sep 2014 11:01:16 +0300
 Subject: [PATCH] gpio: Fix gpio direction flags not getting set

 GPIO direction flags are not getting set because
 an 'if' statement is the wrong way around.

 Signed-off-by: Adrian Hunter adrian.hun...@intel.com

Oopps that's a bug, patch applied for fixes, so it'll work when
this hits upstream.

Alex: confirm?

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line unsubscribe linux-mmc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/2] mmc: atmel-mci: Switch to using managed resource in probe

2014-09-22 Thread Ludovic Desroches
Hi Pramod,

Thanks for taking care of device managed resources conversion. My only
concern is about using devm_request_irq. There are several discussions
about races which can occur when using it.

Keeping request_irq and free_irq the time it takes to solve this issue
is probably better.

Regards

Ludovic

On Sat, Sep 20, 2014 at 12:22:30PM +0530, Pramod Gurav wrote:
 This change uses managed resource APIs to allocate resources such as,
 clk, gpio, irq in order to simplify the driver unload or failure cases.
 Hence does away with release statements of the same resorces in error
 lables and remove function.
 
 Cc: Ludovic Desroches ludovic.desroc...@atmel.com
 Cc: Chris Ball ch...@printf.net
 Cc: Ulf Hansson ulf.hans...@linaro.org
 Cc: linux-mmc@vger.kernel.org
 Signed-off-by: Pramod Gurav pramod.gu...@smartplayin.com
 ---
  drivers/mmc/host/atmel-mci.c | 57 
 
  1 file changed, 20 insertions(+), 37 deletions(-)
 
 diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
 index bb585d9..21a222c 100644
 --- a/drivers/mmc/host/atmel-mci.c
 +++ b/drivers/mmc/host/atmel-mci.c
 @@ -17,6 +17,7 @@
  #include linux/gpio.h
  #include linux/init.h
  #include linux/interrupt.h
 +#include linux/io.h
  #include linux/ioport.h
  #include linux/module.h
  #include linux/of.h
 @@ -2195,7 +2196,8 @@ static int __init atmci_init_slot(struct atmel_mci 
 *host,
   /* Assume card is present initially */
   set_bit(ATMCI_CARD_PRESENT, slot-flags);
   if (gpio_is_valid(slot-detect_pin)) {
 - if (gpio_request(slot-detect_pin, mmc_detect)) {
 + if (devm_gpio_request(host-pdev-dev, slot-detect_pin,
 +   mmc_detect)) {
   dev_dbg(mmc-class_dev, no detect pin available\n);
   slot-detect_pin = -EBUSY;
   } else if (gpio_get_value(slot-detect_pin) ^
 @@ -2208,7 +2210,8 @@ static int __init atmci_init_slot(struct atmel_mci 
 *host,
   mmc-caps |= MMC_CAP_NEEDS_POLL;
  
   if (gpio_is_valid(slot-wp_pin)) {
 - if (gpio_request(slot-wp_pin, mmc_wp)) {
 + if (devm_gpio_request(host-pdev-dev, slot-wp_pin,
 +   mmc_wp)) {
   dev_dbg(mmc-class_dev, no WP pin available\n);
   slot-wp_pin = -EBUSY;
   }
 @@ -2224,7 +2227,8 @@ static int __init atmci_init_slot(struct atmel_mci 
 *host,
   setup_timer(slot-detect_timer, atmci_detect_change,
   (unsigned long)slot);
  
 - ret = request_irq(gpio_to_irq(slot-detect_pin),
 + ret = devm_request_irq(host-pdev-dev,
 + gpio_to_irq(slot-detect_pin),
   atmci_detect_interrupt,
   IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
   mmc-detect, slot);
 @@ -2232,7 +2236,6 @@ static int __init atmci_init_slot(struct atmel_mci 
 *host,
   dev_dbg(mmc-class_dev,
   could not request IRQ %d for detect pin\n,
   gpio_to_irq(slot-detect_pin));
 - gpio_free(slot-detect_pin);
   slot-detect_pin = -EBUSY;
   }
   }
 @@ -2252,15 +2255,8 @@ static void __exit atmci_cleanup_slot(struct 
 atmel_mci_slot *slot,
  
   mmc_remove_host(slot-mmc);
  
 - if (gpio_is_valid(slot-detect_pin)) {
 - int pin = slot-detect_pin;
 -
 - free_irq(gpio_to_irq(pin), slot);
 + if (gpio_is_valid(slot-detect_pin))
   del_timer_sync(slot-detect_timer);
 - gpio_free(pin);
 - }
 - if (gpio_is_valid(slot-wp_pin))
 - gpio_free(slot-wp_pin);
  
   slot-host-slot[id] = NULL;
   mmc_free_host(slot-mmc);
 @@ -2395,7 +2391,7 @@ static int __init atmci_probe(struct platform_device 
 *pdev)
   if (irq  0)
   return irq;
  
 - host = kzalloc(sizeof(struct atmel_mci), GFP_KERNEL);
 + host = devm_kzalloc(pdev-dev, sizeof(*host), GFP_KERNEL);
   if (!host)
   return -ENOMEM;
  
 @@ -2403,20 +2399,18 @@ static int __init atmci_probe(struct platform_device 
 *pdev)
   spin_lock_init(host-lock);
   INIT_LIST_HEAD(host-queue);
  
 - host-mck = clk_get(pdev-dev, mci_clk);
 - if (IS_ERR(host-mck)) {
 - ret = PTR_ERR(host-mck);
 - goto err_clk_get;
 - }
 + host-mck = devm_clk_get(pdev-dev, mci_clk);
 + if (IS_ERR(host-mck))
 + return PTR_ERR(host-mck);
  
 - ret = -ENOMEM;
 - host-regs = ioremap(regs-start, resource_size(regs));
 + host-regs = devm_ioremap(pdev-dev, regs-start, resource_size(regs));
   if (!host-regs)
 - goto err_ioremap;
 + return -ENOMEM;
  
   ret = clk_prepare_enable(host-mck);
   if (ret)
 - goto 

[PATCH] mmc: don't request CD IRQ until mmc_start_host()

2014-09-22 Thread Stephen Warren
From: Stephen Warren swar...@nvidia.com

As soon as the CD IRQ is requested, it can trigger, since it's an
externally controlled event. If it does, delayed_work host-detect will
be scheduled.

Many host controller probe()s are roughly structured as:

*_probe() {
host = sdhci_pltfm_init();
mmc_of_parse(host-mmc);
rc = sdhci_add_host(host);
if (rc) {
sdhci_pltfm_free();
return rc;
}

In 3.17, CD IRQs can are enabled quite early via *_probe() -
mmc_of_parse() - mmc_gpio_request_cd() - mmc_gpiod_request_cd_irq().

Note that in linux-next, mmc_of_parse() calls mmc_gpio*d*_request_cd()
rather than mmc_gpio_request_cd(), and mmc_gpio*d*_request_cd() doesn't
call mmc_gpiod_request_cd_irq(). However, this issue still exists if
mmc_gpio_request_cd() is called directly before mmc_start_host().

sdhci_add_host() may fail part way through (e.g. due to deferred
probe for a vmmc regulator), and sdhci_pltfm_free() does nothing to
unrequest the CD IRQ nor cancel the delayed_work. sdhci_pltfm_free() is
coded to assume that if sdhci_add_host() failed, then the delayed_work
cannot (or should not) have been triggered.

This can lead to the following with CONFIG_DEBUG_OBJECTS_* enabled, when
kfree(host) is eventually called inside sdhci_pltfm_free():

WARNING: CPU: 2 PID: 6 at lib/debugobjects.c:263 debug_print_object+0x8c/0xb4()
ODEBUG: free active (active state 0) object type: timer_list hint: 
delayed_work_timer_fn+0x0/0x18

The object being complained about is host-detect.

There's no need to request the CD IRQ so early; mmc_start_host() already
requests it. For most SDHCI hosts at least, the typical call path that
does this is: *_probe() - sdhci_add_host() - mmc_add_host() -
mmc_start_host(). Therefore, remove the call to mmc_gpiod_request_cd_irq()
from mmc_gpio_request_cd(). This also matches mmc_gpio*d*_request_cd(),
which already doesn't call mmc_gpiod_request_cd_irq().

However, some host controller drivers call mmc_gpio_request_cd() after
mmc_start_host() has already been called, and assume that this will also
call mmc_gpiod_request_cd_irq(). Update those drivers to explicitly call
mmc_gpiod_request_cd_irq() themselves. Ideally, these drivers should be
modified to move their call to mmc_gpio_request_cd() before their call
to mmc_add_host(). However that's too large a change for stable.

This solves the problem (eliminates the kernel error message above),
since it guarantees that the IRQ can't trigger before mmc_start_host()
is called.

The critical point here is that once sdhci_add_host() calls
mmc_add_host() - mmc_start_host(), sdhci_add_host() is coded not to
fail. In other words, if there's a chance that mmc_start_host() may have
been called, and CD IRQs triggered, and the delayed_work scheduled,
sdhci_add_host() won't fail, and so cleanup is no longer via
sdhci_pltfm_free() (which doesn't free the IRQ or cancel the work queue)
but instead must be via sdhci_remove_host(), which calls mmc_remove_host()
- mmc_stop_host(), which does free the IRQ and cancel the work queue.

CC: Russell King li...@arm.linux.org.uk
Cc: Adrian Hunter adrian.hun...@intel.com
Cc: Alexandre Courbot acour...@nvidia.com
Cc: Linus Walleij linus.wall...@linaro.org
Signed-off-by: Stephen Warren swar...@nvidia.com
---
Note: This is a patch for v3.17 (and perhaps earlier); linux-next doesn't
have this problem due to other code re-structing. However, I think those
patches are too large to backport.

v3: Explicitly call mmc_gpiod_request_cd_irq() from drivers that call
mmc_gpio_request_cd() after calling mmc_add_host(), rather than modifying
the function signature of mmc_gpio_request_cd().

v2: Rather than completely removing mmc_gpio_request_cd()'s call to
mmc_gpiod_request_cd_irq(), make the call conditional.
---
 drivers/mmc/core/slot-gpio.c| 2 --
 drivers/mmc/host/mmc_spi.c  | 1 +
 drivers/mmc/host/sdhci-sirf.c   | 1 +
 drivers/mmc/host/tmio_mmc_pio.c | 1 +
 4 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/core/slot-gpio.c b/drivers/mmc/core/slot-gpio.c
index 5f89cb83d5f0..187f48a5795a 100644
--- a/drivers/mmc/core/slot-gpio.c
+++ b/drivers/mmc/core/slot-gpio.c
@@ -221,8 +221,6 @@ int mmc_gpio_request_cd(struct mmc_host *host, unsigned int 
gpio,
ctx-override_cd_active_level = true;
ctx-cd_gpio = gpio_to_desc(gpio);
 
-   mmc_gpiod_request_cd_irq(host);
-
return 0;
 }
 EXPORT_SYMBOL(mmc_gpio_request_cd);
diff --git a/drivers/mmc/host/mmc_spi.c b/drivers/mmc/host/mmc_spi.c
index cc8d4a6099cd..e4a07546f8b6 100644
--- a/drivers/mmc/host/mmc_spi.c
+++ b/drivers/mmc/host/mmc_spi.c
@@ -1436,6 +1436,7 @@ static int mmc_spi_probe(struct spi_device *spi)
 host-pdata-cd_debounce);
if (status != 0)
goto fail_add_host;
+   mmc_gpiod_request_cd_irq(mmc);
}
 
if (host-pdata  host-pdata-flags  MMC_SPI_USE_RO_GPIO) {
diff --git 

Re: [PATCH 1/2] mmc: atmel-mci: Switch to using managed resource in probe

2014-09-22 Thread Pramod Gurav


On 22-09-2014 09:15 PM, Ludovic Desroches wrote:
 Hi Pramod,
 
 Thanks for taking care of device managed resources conversion. My only
 concern is about using devm_request_irq. There are several discussions
 about races which can occur when using it.
 
 Keeping request_irq and free_irq the time it takes to solve this issue
 is probably better.
Oh, Thanks for letting me know this. I will resend this patch keeping
request_irq and free_irq in driver.

 
 Regards
 
 Ludovic
 
 On Sat, Sep 20, 2014 at 12:22:30PM +0530, Pramod Gurav wrote:
 This change uses managed resource APIs to allocate resources such as,
 clk, gpio, irq in order to simplify the driver unload or failure cases.
 Hence does away with release statements of the same resorces in error
 lables and remove function.

 Cc: Ludovic Desroches ludovic.desroc...@atmel.com
 Cc: Chris Ball ch...@printf.net
 Cc: Ulf Hansson ulf.hans...@linaro.org
 Cc: linux-mmc@vger.kernel.org
 Signed-off-by: Pramod Gurav pramod.gu...@smartplayin.com
 ---
  drivers/mmc/host/atmel-mci.c | 57 
 
  1 file changed, 20 insertions(+), 37 deletions(-)

 diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
 index bb585d9..21a222c 100644
 --- a/drivers/mmc/host/atmel-mci.c
 +++ b/drivers/mmc/host/atmel-mci.c
 @@ -17,6 +17,7 @@
  #include linux/gpio.h
  #include linux/init.h
  #include linux/interrupt.h
 +#include linux/io.h
  #include linux/ioport.h
  #include linux/module.h
  #include linux/of.h
 @@ -2195,7 +2196,8 @@ static int __init atmci_init_slot(struct atmel_mci 
 *host,
  /* Assume card is present initially */
  set_bit(ATMCI_CARD_PRESENT, slot-flags);
  if (gpio_is_valid(slot-detect_pin)) {
 -if (gpio_request(slot-detect_pin, mmc_detect)) {
 +if (devm_gpio_request(host-pdev-dev, slot-detect_pin,
 +  mmc_detect)) {
  dev_dbg(mmc-class_dev, no detect pin available\n);
  slot-detect_pin = -EBUSY;
  } else if (gpio_get_value(slot-detect_pin) ^
 @@ -2208,7 +2210,8 @@ static int __init atmci_init_slot(struct atmel_mci 
 *host,
  mmc-caps |= MMC_CAP_NEEDS_POLL;
  
  if (gpio_is_valid(slot-wp_pin)) {
 -if (gpio_request(slot-wp_pin, mmc_wp)) {
 +if (devm_gpio_request(host-pdev-dev, slot-wp_pin,
 +  mmc_wp)) {
  dev_dbg(mmc-class_dev, no WP pin available\n);
  slot-wp_pin = -EBUSY;
  }
 @@ -2224,7 +2227,8 @@ static int __init atmci_init_slot(struct atmel_mci 
 *host,
  setup_timer(slot-detect_timer, atmci_detect_change,
  (unsigned long)slot);
  
 -ret = request_irq(gpio_to_irq(slot-detect_pin),
 +ret = devm_request_irq(host-pdev-dev,
 +gpio_to_irq(slot-detect_pin),
  atmci_detect_interrupt,
  IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
  mmc-detect, slot);
 @@ -2232,7 +2236,6 @@ static int __init atmci_init_slot(struct atmel_mci 
 *host,
  dev_dbg(mmc-class_dev,
  could not request IRQ %d for detect pin\n,
  gpio_to_irq(slot-detect_pin));
 -gpio_free(slot-detect_pin);
  slot-detect_pin = -EBUSY;
  }
  }
 @@ -2252,15 +2255,8 @@ static void __exit atmci_cleanup_slot(struct 
 atmel_mci_slot *slot,
  
  mmc_remove_host(slot-mmc);
  
 -if (gpio_is_valid(slot-detect_pin)) {
 -int pin = slot-detect_pin;
 -
 -free_irq(gpio_to_irq(pin), slot);
 +if (gpio_is_valid(slot-detect_pin))
  del_timer_sync(slot-detect_timer);
 -gpio_free(pin);
 -}
 -if (gpio_is_valid(slot-wp_pin))
 -gpio_free(slot-wp_pin);
  
  slot-host-slot[id] = NULL;
  mmc_free_host(slot-mmc);
 @@ -2395,7 +2391,7 @@ static int __init atmci_probe(struct platform_device 
 *pdev)
  if (irq  0)
  return irq;
  
 -host = kzalloc(sizeof(struct atmel_mci), GFP_KERNEL);
 +host = devm_kzalloc(pdev-dev, sizeof(*host), GFP_KERNEL);
  if (!host)
  return -ENOMEM;
  
 @@ -2403,20 +2399,18 @@ static int __init atmci_probe(struct platform_device 
 *pdev)
  spin_lock_init(host-lock);
  INIT_LIST_HEAD(host-queue);
  
 -host-mck = clk_get(pdev-dev, mci_clk);
 -if (IS_ERR(host-mck)) {
 -ret = PTR_ERR(host-mck);
 -goto err_clk_get;
 -}
 +host-mck = devm_clk_get(pdev-dev, mci_clk);
 +if (IS_ERR(host-mck))
 +return PTR_ERR(host-mck);
  
 -ret = -ENOMEM;
 -host-regs = ioremap(regs-start, resource_size(regs));
 +host-regs = devm_ioremap(pdev-dev, regs-start, resource_size(regs));
  if (!host-regs)
 -goto err_ioremap;
 +

[PATCH 1/2] mmc: sdhci-msm: Make tuning block table endian agnostic

2014-09-22 Thread Stephen Boyd
If we're tuning on a big-endian CPU we'll never determine we properly
tuned the device because we compare the data we received from the
controller with a table that assumes the CPU is little-endian.
Change the table to be an array of bytes instead of 32-bit words
so we can use memcmp() without needing to byte-swap every word
depending on the endianess of the CPU.

Cc: Asutosh Das asuto...@codeaurora.org
Cc: Venkat Gopalakrishnan venk...@codeaurora.org
Reviewed-by: Georgi Djakov gdja...@mm-sol.com
Fixes: 415b5a75da43 mmc: sdhci-msm: Add platform_execute_tuning implementation
Signed-off-by: Stephen Boyd sb...@codeaurora.org
---
 drivers/mmc/host/sdhci-msm.c | 42 +++---
 1 file changed, 27 insertions(+), 15 deletions(-)

diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c
index 40573a58486a..5aabffc15ae8 100644
--- a/drivers/mmc/host/sdhci-msm.c
+++ b/drivers/mmc/host/sdhci-msm.c
@@ -47,22 +47,34 @@
 #define CMUX_SHIFT_PHASE_SHIFT 24
 #define CMUX_SHIFT_PHASE_MASK  (7  CMUX_SHIFT_PHASE_SHIFT)
 
-static const u32 tuning_block_64[] = {
-   0x00ff0fff, 0xccc3ccff, 0xffcc3cc3, 0xeffefffe,
-   0xddffdfff, 0xfbfffbff, 0xff7fffbf, 0xefbdf777,
-   0xf0fff0ff, 0x3cccfc0f, 0xcfcc33cc, 0xeeffefff,
-   0xfdfffdff, 0xffbfffdf, 0xfff7ffbb, 0xde7b7ff7
+static const u8 tuning_block_64[] = {
+   0xff, 0x0f, 0xff, 0x00, 0xff, 0xcc, 0xc3, 0xcc,
+   0xc3, 0x3c, 0xcc, 0xff, 0xfe, 0xff, 0xfe, 0xef,
+   0xff, 0xdf, 0xff, 0xdd, 0xff, 0xfb, 0xff, 0xfb,
+   0xbf, 0xff, 0x7f, 0xff, 0x77, 0xf7, 0xbd, 0xef,
+   0xff, 0xf0, 0xff, 0xf0, 0x0f, 0xfc, 0xcc, 0x3c,
+   0xcc, 0x33, 0xcc, 0xcf, 0xff, 0xef, 0xff, 0xee,
+   0xff, 0xfd, 0xff, 0xfd, 0xdf, 0xff, 0xbf, 0xff,
+   0xbb, 0xff, 0xf7, 0xff, 0xf7, 0x7f, 0x7b, 0xde,
 };
 
-static const u32 tuning_block_128[] = {
-   0xff00, 0x, 0x, 0x33cc,
-   0xcccc, 0x, 0xeeff, 0xffff,
-   0xffdd, 0x, 0xbbff, 0xbbff,
-   0xffbb, 0xff77, 0x77ff, 0xffeeddbb,
-   0x00ff, 0x00ff, 0xcc00, 0xcc33,
-   0x, 0xffcc, 0xffee, 0x,
-   0xddff, 0xddff, 0xffdd, 0xffbb,
-   0x, 0x77ff, 0xffff, 0xeeddbb77
+static const u8 tuning_block_128[] = {
+   0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00,
+   0xff, 0xff, 0xcc, 0xcc, 0xcc, 0x33, 0xcc, 0xcc,
+   0xcc, 0x33, 0x33, 0xcc, 0xcc, 0xcc, 0xff, 0xff,
+   0xff, 0xee, 0xff, 0xff, 0xff, 0xee, 0xee, 0xff,
+   0xff, 0xff, 0xdd, 0xff, 0xff, 0xff, 0xdd, 0xdd,
+   0xff, 0xff, 0xff, 0xbb, 0xff, 0xff, 0xff, 0xbb,
+   0xbb, 0xff, 0xff, 0xff, 0x77, 0xff, 0xff, 0xff,
+   0x77, 0x77, 0xff, 0x77, 0xbb, 0xdd, 0xee, 0xff,
+   0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
+   0x00, 0xff, 0xff, 0xcc, 0xcc, 0xcc, 0x33, 0xcc,
+   0xcc, 0xcc, 0x33, 0x33, 0xcc, 0xcc, 0xcc, 0xff,
+   0xff, 0xff, 0xee, 0xff, 0xff, 0xff, 0xee, 0xee,
+   0xff, 0xff, 0xff, 0xdd, 0xff, 0xff, 0xff, 0xdd,
+   0xdd, 0xff, 0xff, 0xff, 0xbb, 0xff, 0xff, 0xff,
+   0xbb, 0xbb, 0xff, 0xff, 0xff, 0x77, 0xff, 0xff,
+   0xff, 0x77, 0x77, 0xff, 0x77, 0xbb, 0xdd, 0xee,
 };
 
 struct sdhci_msm_host {
@@ -359,7 +371,7 @@ static int sdhci_msm_execute_tuning(struct sdhci_host 
*host, u32 opcode)
 {
int tuning_seq_cnt = 3;
u8 phase, *data_buf, tuned_phases[16], tuned_phase_cnt = 0;
-   const u32 *tuning_block_pattern = tuning_block_64;
+   const u8 *tuning_block_pattern = tuning_block_64;
int size = sizeof(tuning_block_64); /* Pattern size in bytes */
int rc;
struct mmc_host *mmc = host-mmc;
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation

--
To unsubscribe from this list: send the line unsubscribe linux-mmc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] mmc: Consolidate emmc tuning blocks

2014-09-22 Thread Stephen Boyd
The same tuning block exists in the dw_mmc h.c and sdhci-msm.c
files. Move these into mmc.c so that they can be shared across
drivers.

Reported-by: Jaehoon Chung jh80.ch...@samsung.com
Signed-off-by: Stephen Boyd sb...@codeaurora.org
---
 drivers/mmc/core/mmc.c   | 32 
 drivers/mmc/host/dw_mmc.c| 30 --
 drivers/mmc/host/sdhci-msm.c | 38 --
 include/linux/mmc/mmc.h  |  5 +
 4 files changed, 41 insertions(+), 64 deletions(-)

diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index 793c6f7ddb04..9608cc8a1f65 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -1135,6 +1135,38 @@ bus_speed:
return err;
 }
 
+const u8 tuning_blk_pattern_4bit[MMC_TUNING_BLK_PATTERN_4BIT_SIZE] = {
+   0xff, 0x0f, 0xff, 0x00, 0xff, 0xcc, 0xc3, 0xcc,
+   0xc3, 0x3c, 0xcc, 0xff, 0xfe, 0xff, 0xfe, 0xef,
+   0xff, 0xdf, 0xff, 0xdd, 0xff, 0xfb, 0xff, 0xfb,
+   0xbf, 0xff, 0x7f, 0xff, 0x77, 0xf7, 0xbd, 0xef,
+   0xff, 0xf0, 0xff, 0xf0, 0x0f, 0xfc, 0xcc, 0x3c,
+   0xcc, 0x33, 0xcc, 0xcf, 0xff, 0xef, 0xff, 0xee,
+   0xff, 0xfd, 0xff, 0xfd, 0xdf, 0xff, 0xbf, 0xff,
+   0xbb, 0xff, 0xf7, 0xff, 0xf7, 0x7f, 0x7b, 0xde,
+};
+EXPORT_SYMBOL(tuning_blk_pattern_4bit);
+
+const u8 tuning_blk_pattern_8bit[MMC_TUNING_BLK_PATTERN_8BIT_SIZE] = {
+   0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00,
+   0xff, 0xff, 0xcc, 0xcc, 0xcc, 0x33, 0xcc, 0xcc,
+   0xcc, 0x33, 0x33, 0xcc, 0xcc, 0xcc, 0xff, 0xff,
+   0xff, 0xee, 0xff, 0xff, 0xff, 0xee, 0xee, 0xff,
+   0xff, 0xff, 0xdd, 0xff, 0xff, 0xff, 0xdd, 0xdd,
+   0xff, 0xff, 0xff, 0xbb, 0xff, 0xff, 0xff, 0xbb,
+   0xbb, 0xff, 0xff, 0xff, 0x77, 0xff, 0xff, 0xff,
+   0x77, 0x77, 0xff, 0x77, 0xbb, 0xdd, 0xee, 0xff,
+   0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
+   0x00, 0xff, 0xff, 0xcc, 0xcc, 0xcc, 0x33, 0xcc,
+   0xcc, 0xcc, 0x33, 0x33, 0xcc, 0xcc, 0xcc, 0xff,
+   0xff, 0xff, 0xee, 0xff, 0xff, 0xff, 0xee, 0xee,
+   0xff, 0xff, 0xff, 0xdd, 0xff, 0xff, 0xff, 0xdd,
+   0xdd, 0xff, 0xff, 0xff, 0xbb, 0xff, 0xff, 0xff,
+   0xbb, 0xbb, 0xff, 0xff, 0xff, 0x77, 0xff, 0xff,
+   0xff, 0x77, 0x77, 0xff, 0x77, 0xbb, 0xdd, 0xee,
+};
+EXPORT_SYMBOL(tuning_blk_pattern_8bit);
+
 /*
  * Execute tuning sequence to seek the proper bus operating
  * conditions for HS200 and HS400, which sends CMD21 to the device.
diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
index 1ac227c603b7..f1cefdf5e2d0 100644
--- a/drivers/mmc/host/dw_mmc.c
+++ b/drivers/mmc/host/dw_mmc.c
@@ -81,36 +81,6 @@ struct idmac_desc {
 };
 #endif /* CONFIG_MMC_DW_IDMAC */
 
-static const u8 tuning_blk_pattern_4bit[] = {
-   0xff, 0x0f, 0xff, 0x00, 0xff, 0xcc, 0xc3, 0xcc,
-   0xc3, 0x3c, 0xcc, 0xff, 0xfe, 0xff, 0xfe, 0xef,
-   0xff, 0xdf, 0xff, 0xdd, 0xff, 0xfb, 0xff, 0xfb,
-   0xbf, 0xff, 0x7f, 0xff, 0x77, 0xf7, 0xbd, 0xef,
-   0xff, 0xf0, 0xff, 0xf0, 0x0f, 0xfc, 0xcc, 0x3c,
-   0xcc, 0x33, 0xcc, 0xcf, 0xff, 0xef, 0xff, 0xee,
-   0xff, 0xfd, 0xff, 0xfd, 0xdf, 0xff, 0xbf, 0xff,
-   0xbb, 0xff, 0xf7, 0xff, 0xf7, 0x7f, 0x7b, 0xde,
-};
-
-static const u8 tuning_blk_pattern_8bit[] = {
-   0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00,
-   0xff, 0xff, 0xcc, 0xcc, 0xcc, 0x33, 0xcc, 0xcc,
-   0xcc, 0x33, 0x33, 0xcc, 0xcc, 0xcc, 0xff, 0xff,
-   0xff, 0xee, 0xff, 0xff, 0xff, 0xee, 0xee, 0xff,
-   0xff, 0xff, 0xdd, 0xff, 0xff, 0xff, 0xdd, 0xdd,
-   0xff, 0xff, 0xff, 0xbb, 0xff, 0xff, 0xff, 0xbb,
-   0xbb, 0xff, 0xff, 0xff, 0x77, 0xff, 0xff, 0xff,
-   0x77, 0x77, 0xff, 0x77, 0xbb, 0xdd, 0xee, 0xff,
-   0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-   0x00, 0xff, 0xff, 0xcc, 0xcc, 0xcc, 0x33, 0xcc,
-   0xcc, 0xcc, 0x33, 0x33, 0xcc, 0xcc, 0xcc, 0xff,
-   0xff, 0xff, 0xee, 0xff, 0xff, 0xff, 0xee, 0xee,
-   0xff, 0xff, 0xff, 0xdd, 0xff, 0xff, 0xff, 0xdd,
-   0xdd, 0xff, 0xff, 0xff, 0xbb, 0xff, 0xff, 0xff,
-   0xbb, 0xbb, 0xff, 0xff, 0xff, 0x77, 0xff, 0xff,
-   0xff, 0x77, 0x77, 0xff, 0x77, 0xbb, 0xdd, 0xee,
-};
-
 static inline bool dw_mci_fifo_reset(struct dw_mci *host);
 static inline bool dw_mci_ctrl_all_reset(struct dw_mci *host);
 
diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c
index 5aabffc15ae8..da74c77f34cc 100644
--- a/drivers/mmc/host/sdhci-msm.c
+++ b/drivers/mmc/host/sdhci-msm.c
@@ -47,36 +47,6 @@
 #define CMUX_SHIFT_PHASE_SHIFT 24
 #define CMUX_SHIFT_PHASE_MASK  (7  CMUX_SHIFT_PHASE_SHIFT)
 
-static const u8 tuning_block_64[] = {
-   0xff, 0x0f, 0xff, 0x00, 0xff, 0xcc, 0xc3, 0xcc,
-   0xc3, 0x3c, 0xcc, 0xff, 0xfe, 0xff, 0xfe, 0xef,
-   0xff, 0xdf, 0xff, 0xdd, 0xff, 0xfb, 0xff, 0xfb,
-   0xbf, 0xff, 0x7f, 0xff, 0x77, 0xf7, 0xbd, 0xef,
-   0xff, 0xf0, 0xff, 0xf0, 0x0f, 0xfc, 0xcc, 0x3c,
-   0xcc, 0x33, 0xcc, 0xcf, 0xff, 0xef, 0xff, 0xee,
-   0xff, 0xfd, 

Re: [PATCH] mmc: don't request CD IRQ until mmc_start_host()

2014-09-22 Thread Adrian Hunter

On 22/09/2014 6:57 p.m., Stephen Warren wrote:

From: Stephen Warren swar...@nvidia.com

As soon as the CD IRQ is requested, it can trigger, since it's an
externally controlled event. If it does, delayed_work host-detect will
be scheduled.

Many host controller probe()s are roughly structured as:

*_probe() {
 host = sdhci_pltfm_init();
 mmc_of_parse(host-mmc);
 rc = sdhci_add_host(host);
 if (rc) {
 sdhci_pltfm_free();
 return rc;
 }

In 3.17, CD IRQs can are enabled quite early via *_probe() -
mmc_of_parse() - mmc_gpio_request_cd() - mmc_gpiod_request_cd_irq().

Note that in linux-next, mmc_of_parse() calls mmc_gpio*d*_request_cd()
rather than mmc_gpio_request_cd(), and mmc_gpio*d*_request_cd() doesn't
call mmc_gpiod_request_cd_irq(). However, this issue still exists if
mmc_gpio_request_cd() is called directly before mmc_start_host().

sdhci_add_host() may fail part way through (e.g. due to deferred
probe for a vmmc regulator), and sdhci_pltfm_free() does nothing to
unrequest the CD IRQ nor cancel the delayed_work. sdhci_pltfm_free() is
coded to assume that if sdhci_add_host() failed, then the delayed_work
cannot (or should not) have been triggered.

This can lead to the following with CONFIG_DEBUG_OBJECTS_* enabled, when
kfree(host) is eventually called inside sdhci_pltfm_free():

WARNING: CPU: 2 PID: 6 at lib/debugobjects.c:263 debug_print_object+0x8c/0xb4()
ODEBUG: free active (active state 0) object type: timer_list hint: 
delayed_work_timer_fn+0x0/0x18

The object being complained about is host-detect.

There's no need to request the CD IRQ so early; mmc_start_host() already
requests it. For most SDHCI hosts at least, the typical call path that
does this is: *_probe() - sdhci_add_host() - mmc_add_host() -
mmc_start_host(). Therefore, remove the call to mmc_gpiod_request_cd_irq()
from mmc_gpio_request_cd(). This also matches mmc_gpio*d*_request_cd(),
which already doesn't call mmc_gpiod_request_cd_irq().

However, some host controller drivers call mmc_gpio_request_cd() after
mmc_start_host() has already been called, and assume that this will also
call mmc_gpiod_request_cd_irq(). Update those drivers to explicitly call
mmc_gpiod_request_cd_irq() themselves. Ideally, these drivers should be
modified to move their call to mmc_gpio_request_cd() before their call
to mmc_add_host(). However that's too large a change for stable.

This solves the problem (eliminates the kernel error message above),
since it guarantees that the IRQ can't trigger before mmc_start_host()
is called.

The critical point here is that once sdhci_add_host() calls
mmc_add_host() - mmc_start_host(), sdhci_add_host() is coded not to
fail. In other words, if there's a chance that mmc_start_host() may have
been called, and CD IRQs triggered, and the delayed_work scheduled,
sdhci_add_host() won't fail, and so cleanup is no longer via
sdhci_pltfm_free() (which doesn't free the IRQ or cancel the work queue)
but instead must be via sdhci_remove_host(), which calls mmc_remove_host()
- mmc_stop_host(), which does free the IRQ and cancel the work queue.

CC: Russell King li...@arm.linux.org.uk
Cc: Adrian Hunter adrian.hun...@intel.com
Cc: Alexandre Courbot acour...@nvidia.com
Cc: Linus Walleij linus.wall...@linaro.org
Signed-off-by: Stephen Warren swar...@nvidia.com


Acked-by: Adrian Hunter adrian.hun...@intel.com


---
Note: This is a patch for v3.17 (and perhaps earlier); linux-next doesn't
have this problem due to other code re-structing. However, I think those
patches are too large to backport.

v3: Explicitly call mmc_gpiod_request_cd_irq() from drivers that call
mmc_gpio_request_cd() after calling mmc_add_host(), rather than modifying
the function signature of mmc_gpio_request_cd().

v2: Rather than completely removing mmc_gpio_request_cd()'s call to
mmc_gpiod_request_cd_irq(), make the call conditional.
---
  drivers/mmc/core/slot-gpio.c| 2 --
  drivers/mmc/host/mmc_spi.c  | 1 +
  drivers/mmc/host/sdhci-sirf.c   | 1 +
  drivers/mmc/host/tmio_mmc_pio.c | 1 +
  4 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/core/slot-gpio.c b/drivers/mmc/core/slot-gpio.c
index 5f89cb83d5f0..187f48a5795a 100644
--- a/drivers/mmc/core/slot-gpio.c
+++ b/drivers/mmc/core/slot-gpio.c
@@ -221,8 +221,6 @@ int mmc_gpio_request_cd(struct mmc_host *host, unsigned int 
gpio,
ctx-override_cd_active_level = true;
ctx-cd_gpio = gpio_to_desc(gpio);

-   mmc_gpiod_request_cd_irq(host);
-
return 0;
  }
  EXPORT_SYMBOL(mmc_gpio_request_cd);
diff --git a/drivers/mmc/host/mmc_spi.c b/drivers/mmc/host/mmc_spi.c
index cc8d4a6099cd..e4a07546f8b6 100644
--- a/drivers/mmc/host/mmc_spi.c
+++ b/drivers/mmc/host/mmc_spi.c
@@ -1436,6 +1436,7 @@ static int mmc_spi_probe(struct spi_device *spi)
 host-pdata-cd_debounce);
if (status != 0)
goto fail_add_host;
+   mmc_gpiod_request_cd_irq(mmc);