All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] mmc: core: Do not set mmc voltage to 1.8V when 'no-1-8-v' is present
@ 2015-06-13 20:24 Fabio Estevam
  2015-06-15 11:44 ` Otavio Salvador
  2015-06-15 12:08 ` Ulf Hansson
  0 siblings, 2 replies; 10+ messages in thread
From: Fabio Estevam @ 2015-06-13 20:24 UTC (permalink / raw)
  To: ulf.hansson
  Cc: aisheng.dong, kevin.lemoi, otavio, kernel, linux, chuanxiao.dong,
	linux-mmc, Fabio Estevam

From: Fabio Estevam <fabio.estevam@freescale.com>

Since commit 312449efd16bb06 ("mmc: core: Fix sequence for I/O voltage
in DDR mode for eMMC") the mmc voltage is set to 1.8V inside 
mmc_select_hs_ddr(), even if 'no-1-8-v' property is present.

This causes the following error on a mx6sl board with the 'no-1-8-v' 
property passed in the device tree:

mmc0: power class selection to bus width 8 ddr 4 failed
mmc0: error -110 whilst initialising MMC card

Fix this problem by only setting the mmc voltage to 1.8V if the 
'no-1-8-v' property is absent.

Reported-by: Kevin Lemoi <kevin.lemoi@savant.com>
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
Changes since v1:
- Fix it in the core code instead of doing it inside the sdhci imx code

 drivers/mmc/core/host.c  | 2 ++
 drivers/mmc/core/mmc.c   | 8 +++++++-
 include/linux/mmc/host.h | 1 +
 include/linux/mmc/mmc.h  | 1 +
 4 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
index 01fa1ed..736c985 100644
--- a/drivers/mmc/core/host.c
+++ b/drivers/mmc/core/host.c
@@ -527,6 +527,8 @@ int mmc_of_parse(struct mmc_host *host)
 		host->caps2 |= MMC_CAP2_HS400_1_8V | MMC_CAP2_HS200_1_8V_SDR;
 	if (of_find_property(np, "mmc-hs400-1_2v", &len))
 		host->caps2 |= MMC_CAP2_HS400_1_2V | MMC_CAP2_HS200_1_2V_SDR;
+	if (of_find_property(np, "no-1-8-v", &len))
+		host->caps2 |= MMC_CAP_3_3V_ONLY_DDR;
 
 	host->dsr_req = !of_property_read_u32(np, "dsr", &host->dsr);
 	if (host->dsr_req && (host->dsr & ~0xffff)) {
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index e726903..e76b9af 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -205,6 +205,10 @@ static void mmc_select_card_type(struct mmc_card *card)
 		avail_type |= EXT_CSD_CARD_TYPE_DDR_1_8V;
 	}
 
+	if (caps2 & MMC_CAP_3_3V_ONLY_DDR &&
+	    card_type & EXT_CSD_CARD_TYPE_DDR_1_8V)
+		avail_type |= EXT_CSD_CARD_TYPE_DDR_3_3V_ONLY;
+
 	if (caps & MMC_CAP_1_2V_DDR &&
 	    card_type & EXT_CSD_CARD_TYPE_DDR_1_2V) {
 		hs_max_dtr = MMC_HIGH_DDR_MAX_DTR;
@@ -1028,7 +1032,9 @@ static int mmc_select_hs_ddr(struct mmc_card *card)
 		err = __mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_120);
 
 	if (err && (card->mmc_avail_type & EXT_CSD_CARD_TYPE_DDR_1_8V))
-		err = __mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_180);
+		if (!(card->mmc_avail_type & EXT_CSD_CARD_TYPE_DDR_3_3V_ONLY))
+			err = __mmc_set_signal_voltage(host,
+						       MMC_SIGNAL_VOLTAGE_180);
 
 	/* make sure vccq is 3.3v after switching disaster */
 	if (err)
diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
index 1369e54..5aa999f 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -289,6 +289,7 @@ struct mmc_host {
 #define MMC_CAP2_HSX00_1_2V	(MMC_CAP2_HS200_1_2V_SDR | MMC_CAP2_HS400_1_2V)
 #define MMC_CAP2_SDIO_IRQ_NOTHREAD (1 << 17)
 #define MMC_CAP2_NO_WRITE_PROTECT (1 << 18)	/* No physical write protect pin, assume that card is always read-write */
+#define MMC_CAP_3_3V_ONLY_DDR	(1 << 19)	/* Only supports 3.3V DDR */
 
 	mmc_pm_flag_t		pm_caps;	/* supported pm features */
 
diff --git a/include/linux/mmc/mmc.h b/include/linux/mmc/mmc.h
index 15f2c4a..b3cbd3c 100644
--- a/include/linux/mmc/mmc.h
+++ b/include/linux/mmc/mmc.h
@@ -380,6 +380,7 @@ struct _mmc_csd {
 #define EXT_CSD_CARD_TYPE_HS400_1_2V	(1<<7)	/* Card can run at 200MHz DDR, 1.2V */
 #define EXT_CSD_CARD_TYPE_HS400		(EXT_CSD_CARD_TYPE_HS400_1_8V | \
 					 EXT_CSD_CARD_TYPE_HS400_1_2V)
+#define EXT_CSD_CARD_TYPE_DDR_3_3V_ONLY	(1<<8)
 
 #define EXT_CSD_BUS_WIDTH_1	0	/* Card is in 1 bit mode */
 #define EXT_CSD_BUS_WIDTH_4	1	/* Card is in 4 bit mode */
-- 
1.9.1


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

end of thread, other threads:[~2015-06-18 14:29 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-13 20:24 [PATCH v2] mmc: core: Do not set mmc voltage to 1.8V when 'no-1-8-v' is present Fabio Estevam
2015-06-15 11:44 ` Otavio Salvador
2015-06-15 12:08 ` Ulf Hansson
2015-06-15 12:23   ` Fabio Estevam
2015-06-15 12:49     ` Fabio Estevam
2015-06-16  9:31       ` Ulf Hansson
2015-06-17 16:25         ` Fabio Estevam
2015-06-18  7:58           ` Ulf Hansson
2015-06-18 14:25             ` Dong Aisheng
2015-06-18 14:03         ` Dong Aisheng

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