* [PATCH] mmc: core: Set correct bus mode before card init
@ 2011-09-15 15:50 Ulf Hansson
2011-09-16 2:05 ` Aaron Lu
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Ulf Hansson @ 2011-09-15 15:50 UTC (permalink / raw)
To: linux-mmc, Chris Ball
Cc: Per Forlin, Ulf Hansson, Lee Jones, Stefan Nilsson XK
From: Stefan Nilsson XK <stefan.xk.nilsson@stericsson.com>
Earlier all cards where initiated with bus mode set as OPENDRAIN, and then
later switched to PUSHPULL. According to the MMC/SD/SDIO specifications only
MMC cards use OPENDRAIN during init. For both SD and SDIO the bus mode shall
be PUSHPULL before attempting to init the card.
The consequence of having incorrect bus mode can lead to not being able
to detect the card. Therefore the default behavior have now been changed to
PUSHPULL in mmc_power_up, and will only be temporarily switched when trying
to attach or init a MMC card.
Signed-off-by: Stefan Nilsson XK <stefan.xk.nilsson@stericsson.com>
Signed-off-by: Ulf HANSSON <ulf.hansson@stericsson.com>
---
drivers/mmc/core/core.c | 8 +++-----
drivers/mmc/core/mmc.c | 8 ++++++++
drivers/mmc/core/sd.c | 2 --
drivers/mmc/core/sdio.c | 2 --
4 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 91a0a74..2a47973 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -1098,13 +1098,11 @@ static void mmc_power_up(struct mmc_host *host)
bit = fls(host->ocr_avail) - 1;
host->ios.vdd = bit;
- if (mmc_host_is_spi(host)) {
+ if (mmc_host_is_spi(host))
host->ios.chip_select = MMC_CS_HIGH;
- host->ios.bus_mode = MMC_BUSMODE_PUSHPULL;
- } else {
+ else
host->ios.chip_select = MMC_CS_DONTCARE;
- host->ios.bus_mode = MMC_BUSMODE_OPENDRAIN;
- }
+ host->ios.bus_mode = MMC_BUSMODE_PUSHPULL;
host->ios.power_mode = MMC_POWER_UP;
host->ios.bus_width = MMC_BUS_WIDTH_1;
host->ios.timing = MMC_TIMING_LEGACY;
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index 5700b1c..b36d786 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -548,6 +548,10 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
BUG_ON(!host);
WARN_ON(!host->claimed);
+ /* Set correct bus mode for MMC before attempting init */
+ if (!mmc_host_is_spi(host))
+ mmc_set_bus_mode(host, MMC_BUSMODE_OPENDRAIN);
+
/*
* Since we're changing the OCR value, we seem to
* need to tell some cards to go back to the idle
@@ -1016,6 +1020,10 @@ int mmc_attach_mmc(struct mmc_host *host)
BUG_ON(!host);
WARN_ON(!host->claimed);
+ /* Set correct bus mode for MMC before attempting attach */
+ if (!mmc_host_is_spi(host))
+ mmc_set_bus_mode(host, MMC_BUSMODE_OPENDRAIN);
+
err = mmc_send_op_cond(host, 0, &ocr);
if (err)
return err;
diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
index 633975f..b0f0216 100644
--- a/drivers/mmc/core/sd.c
+++ b/drivers/mmc/core/sd.c
@@ -904,8 +904,6 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr,
err = mmc_send_relative_addr(host, &card->rca);
if (err)
return err;
-
- mmc_set_bus_mode(host, MMC_BUSMODE_PUSHPULL);
}
if (!oldcard) {
diff --git a/drivers/mmc/core/sdio.c b/drivers/mmc/core/sdio.c
index 262fff0..7fc9953 100644
--- a/drivers/mmc/core/sdio.c
+++ b/drivers/mmc/core/sdio.c
@@ -408,8 +408,6 @@ static int mmc_sdio_init_card(struct mmc_host *host, u32 ocr,
*/
if (oldcard)
oldcard->rca = card->rca;
-
- mmc_set_bus_mode(host, MMC_BUSMODE_PUSHPULL);
}
/*
--
1.7.5.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] mmc: core: Set correct bus mode before card init
2011-09-15 15:50 [PATCH] mmc: core: Set correct bus mode before card init Ulf Hansson
@ 2011-09-16 2:05 ` Aaron Lu
2011-09-16 6:57 ` Stefan Nilsson XK
2011-09-20 6:48 ` Linus Walleij
2011-09-21 18:20 ` Chris Ball
2 siblings, 1 reply; 5+ messages in thread
From: Aaron Lu @ 2011-09-16 2:05 UTC (permalink / raw)
To: Ulf Hansson
Cc: linux-mmc, Chris Ball, Per Forlin, Lee Jones, Stefan Nilsson XK
Hi Ulf,
I'm not familiar with mmc, but I've some questions on sd below.
On Thu, Sep 15, 2011 at 05:50:38PM +0200, Ulf Hansson wrote:
> Earlier all cards where initiated with bus mode set as OPENDRAIN, and then
> later switched to PUSHPULL. According to the MMC/SD/SDIO specifications only
> MMC cards use OPENDRAIN during init. For both SD and SDIO the bus mode shall
> be PUSHPULL before attempting to init the card.
AFAIK, there is no open drain mode in sd, and the sd host controller
actually does not care about this setting(sdhci_set_ios does not
manipulate bus_mode stored in ios).
>
> The consequence of having incorrect bus mode can lead to not being able
> to detect the card. Therefore the default behavior have now been changed to
> PUSHPULL in mmc_power_up, and will only be temporarily switched when trying
> to attach or init a MMC card.
Do you see any sd cards that failed to be detected due to the incorrect
bus_mode setting?
Anyway, your patch removed an unnecessary call to mmc_set_bus_mode which
should have no effect if the underlying controller is sdhci.
-Aaron
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] mmc: core: Set correct bus mode before card init
2011-09-16 2:05 ` Aaron Lu
@ 2011-09-16 6:57 ` Stefan Nilsson XK
0 siblings, 0 replies; 5+ messages in thread
From: Stefan Nilsson XK @ 2011-09-16 6:57 UTC (permalink / raw)
To: Aaron Lu
Cc: Ulf HANSSON, linux-mmc@vger.kernel.org, Chris Ball, Per FORLIN,
Lee Jones
Hi Aaron,
On 09/16/2011 04:05 AM, Aaron Lu wrote:
> Hi Ulf,
>
> I'm not familiar with mmc, but I've some questions on sd below.
>
> On Thu, Sep 15, 2011 at 05:50:38PM +0200, Ulf Hansson wrote:
>> Earlier all cards where initiated with bus mode set as OPENDRAIN, and then
>> later switched to PUSHPULL. According to the MMC/SD/SDIO specifications only
>> MMC cards use OPENDRAIN during init. For both SD and SDIO the bus mode shall
>> be PUSHPULL before attempting to init the card.
> AFAIK, there is no open drain mode in sd, and the sd host controller
> actually does not care about this setting(sdhci_set_ios does not
> manipulate bus_mode stored in ios).
We are currently using a ARM PL18X derivative with added SDIO support
meaning we have one host controller for both MMC, SD and SDIO. This
means that we have to take action on the open drain bit in our host
driver (mmci.c) and set it as indicated by the framework. During card
detection (and likewise during reinitialization after being powered off
due to power save features), the former implementation actually sets
open drain as default, meaning that open drain is set during early card
detection of both MMC, SD and SDIO cards/devices, and then later
switched to push pull which we believe is not correct for SD and SDIO.
>> The consequence of having incorrect bus mode can lead to not being able
>> to detect the card. Therefore the default behavior have now been changed to
>> PUSHPULL in mmc_power_up, and will only be temporarily switched when trying
>> to attach or init a MMC card.
> Do you see any sd cards that failed to be detected due to the incorrect
> bus_mode setting?
We have not seen any SD card fail due to this, but the SDIO device we
have connected (WLAN) does fail to be detected if bus mode is
incorrectly set to open drain during card detect (mmc_rescan).
>
> Anyway, your patch removed an unnecessary call to mmc_set_bus_mode which
> should have no effect if the underlying controller is sdhci.
Great, thanks for your feeback! :o)
Best Regards
Stefan Nilsson
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] mmc: core: Set correct bus mode before card init
2011-09-15 15:50 [PATCH] mmc: core: Set correct bus mode before card init Ulf Hansson
2011-09-16 2:05 ` Aaron Lu
@ 2011-09-20 6:48 ` Linus Walleij
2011-09-21 18:20 ` Chris Ball
2 siblings, 0 replies; 5+ messages in thread
From: Linus Walleij @ 2011-09-20 6:48 UTC (permalink / raw)
To: Ulf Hansson
Cc: linux-mmc, Chris Ball, Per Forlin, Lee Jones, Stefan Nilsson XK
On Thu, Sep 15, 2011 at 5:50 PM, Ulf Hansson <ulf.hansson@stericsson.com> wrote:
> From: Stefan Nilsson XK <stefan.xk.nilsson@stericsson.com>
>
> Earlier all cards where initiated with bus mode set as OPENDRAIN, and then
> later switched to PUSHPULL. According to the MMC/SD/SDIO specifications only
> MMC cards use OPENDRAIN during init. For both SD and SDIO the bus mode shall
> be PUSHPULL before attempting to init the card.
>
> The consequence of having incorrect bus mode can lead to not being able
> to detect the card. Therefore the default behavior have now been changed to
> PUSHPULL in mmc_power_up, and will only be temporarily switched when trying
> to attach or init a MMC card.
>
> Signed-off-by: Stefan Nilsson XK <stefan.xk.nilsson@stericsson.com>
> Signed-off-by: Ulf HANSSON <ulf.hansson@stericsson.com>
Looks solid to me,
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Thanks,
Linus Walleij
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] mmc: core: Set correct bus mode before card init
2011-09-15 15:50 [PATCH] mmc: core: Set correct bus mode before card init Ulf Hansson
2011-09-16 2:05 ` Aaron Lu
2011-09-20 6:48 ` Linus Walleij
@ 2011-09-21 18:20 ` Chris Ball
2 siblings, 0 replies; 5+ messages in thread
From: Chris Ball @ 2011-09-21 18:20 UTC (permalink / raw)
To: Ulf Hansson; +Cc: linux-mmc, Per Forlin, Lee Jones, Stefan Nilsson XK
Hi,
On Thu, Sep 15 2011, Ulf Hansson wrote:
> From: Stefan Nilsson XK <stefan.xk.nilsson@stericsson.com>
>
> Earlier all cards where initiated with bus mode set as OPENDRAIN, and then
> later switched to PUSHPULL. According to the MMC/SD/SDIO specifications only
> MMC cards use OPENDRAIN during init. For both SD and SDIO the bus mode shall
> be PUSHPULL before attempting to init the card.
>
> The consequence of having incorrect bus mode can lead to not being able
> to detect the card. Therefore the default behavior have now been changed to
> PUSHPULL in mmc_power_up, and will only be temporarily switched when trying
> to attach or init a MMC card.
>
> Signed-off-by: Stefan Nilsson XK <stefan.xk.nilsson@stericsson.com>
> Signed-off-by: Ulf HANSSON <ulf.hansson@stericsson.com>
Thanks, pushed to mmc-next for 3.2 with Linus W's ACK.
- Chris.
--
Chris Ball <cjb@laptop.org> <http://printf.net/>
One Laptop Per Child
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-09-21 18:20 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-15 15:50 [PATCH] mmc: core: Set correct bus mode before card init Ulf Hansson
2011-09-16 2:05 ` Aaron Lu
2011-09-16 6:57 ` Stefan Nilsson XK
2011-09-20 6:48 ` Linus Walleij
2011-09-21 18:20 ` Chris Ball
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox