Skip to contentSkip to conversation

mmc: fsl_esdhc: move 'status' property fixup into a weak function

PATCH Superseded Yangbo Lu 2 participants 4 messages Dec 7, 2016 – Dec 8, 2016 MMC, SD and SDIO

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Yangbo Lu

author
#0 lore raw

PATCH 1/2 mmc: fsl_esdhc: move 'status' property fixup into a weak function

Move fdt fixup of 'status' property into a weak function. This allows board to define 'status' fdt fixup by themselves.

---
 drivers/mmc/fsl_esdhc.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)
drivers/mmc/fsl_esdhc.c +14 -7
index 0ae1cfd..7b7863f 100644
@@ -911,17 +911,26 @@ void mmc_adapter_card_type_ident(void)
 #endif
 
 #ifdef CONFIG_OF_LIBFDT
-void fdt_fixup_esdhc(void *blob, bd_t *bd)
+__weak int esdhc_status_fixup(void *blob, const char *compat)
 {
-	const char *compat = "fsl,esdhc";
-
 #ifdef CONFIG_FSL_ESDHC_PIN_MUX
 	if (!hwconfig("esdhc")) {
 		do_fixup_by_compat(blob, compat, "status", "disabled",
-				8 + 1, 1);
-		return;
+				sizeof("disabled"), 1);
+		return 1;
 	}
 #endif
+	do_fixup_by_compat(blob, compat, "status", "okay",
+			   sizeof("okay"), 1);
+	return 0;
+}
+
+void fdt_fixup_esdhc(void *blob, bd_t *bd)
+{
+	const char *compat = "fsl,esdhc";
+
+	if (esdhc_status_fixup(blob, compat))
+		return;
 
 #ifdef CONFIG_FSL_ESDHC_USE_PERIPHERAL_CLK
 	do_fixup_by_compat_u32(blob, compat, "peripheral-frequency",
@@ -934,8 +943,6 @@ void fdt_fixup_esdhc(void *blob, bd_t *bd)
 	do_fixup_by_compat_u32(blob, compat, "adapter-type",
 			       (u32)(gd->arch.sdhc_adapter), 1);
 #endif
-	do_fixup_by_compat(blob, compat, "status", "okay",
-			   4 + 1, 1);
 }
 #endif
 
Signature · 1 line
2.1.0.27.g96db324
author
#1 lore raw

PATCH 2/2 armv8: ls1012a: define esdhc_status_fixup for QDS board

The LS1012AQDS board has a hardware issue. When there is no eMMC adapter card inserted, the command inhibit bits of eSDHC_PRSSTAT register will never release. This would cause below continious error messages in linux since it uses polling mode to detect card. "mmc1: Controller never released inhibit bit(s)."
"mmc1: Controller never released inhibit bit(s)."
"mmc1: Controller never released inhibit bit(s)."
This patch is to define esdhc_status_fixup function to disable eSDHC2 status if no eMMC adapter card is detected.

---
 board/freescale/ls1012aqds/ls1012aqds.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
board/freescale/ls1012aqds/ls1012aqds.c +19 -0
index 94440b3..a3229f7 100644
@@ -121,6 +121,25 @@ int board_eth_init(bd_t *bis)
 	return pci_eth_init(bis);
 }
 
+int esdhc_status_fixup(void *blob, const char *compat)
+{
+	char esdhc0_path[] = "/soc/esdhc at 1560000";
+	char esdhc1_path[] = "/soc/esdhc at 1580000";
+	u8 card_id;
+
+	do_fixup_by_path(blob, esdhc0_path, "status", "okay",
+			 sizeof("okay"), 1);
+
+	card_id = (QIXIS_READ(present2) & 0xe0) >> 5;
+
+	if (card_id == 0x7)
+		do_fixup_by_path(blob, esdhc1_path, "status", "disabled",
+				 sizeof("disabled"), 1);
+	else
+		do_fixup_by_path(blob, esdhc1_path, "status", "okay",
+				 sizeof("okay"), 1);
+}
+
 #ifdef CONFIG_OF_BOARD_SETUP
 int ft_board_setup(void *blob, bd_t *bd)
 {
Signature · 1 line
2.1.0.27.g96db324
#2 lore raw

PATCH 2/2 armv8: ls1012a: define esdhc_status_fixup for QDS board

Quoted 22 lines · Yangbo Lu

The LS1012AQDS board has a hardware issue. When there is no eMMC adapter card inserted, the command inhibit bits of eSDHC_PRSSTAT register will never release. This would cause below continious error messages in linux since it uses polling mode to detect card. "mmc1: Controller never released inhibit bit(s)."
"mmc1: Controller never released inhibit bit(s)."
"mmc1: Controller never released inhibit bit(s)."
This patch is to define esdhc_status_fixup function to disable eSDHC2 status if no eMMC adapter card is detected.

---
 board/freescale/ls1012aqds/ls1012aqds.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
board/freescale/ls1012aqds/ls1012aqds.c +0 -0
index 94440b3..a3229f7 100644
@@ -121,6 +121,25 @@ int board_eth_init(bd_t *bis)
 	return pci_eth_init(bis);
 }

board/freescale/ls1012aqds/ls1012aqds.c int board_eth_init(bd_t *bis) · line 132

Quoted 10 lines
board/freescale/ls1012aqds/ls1012aqds.c +9 -0
 
+int esdhc_status_fixup(void *blob, const char *compat)
+{
+	char esdhc0_path[] = "/soc/esdhc at 1560000";
+	char esdhc1_path[] = "/soc/esdhc at 1580000";
+	u8 card_id;
+
+	do_fixup_by_path(blob, esdhc0_path, "status", "okay",
+			 sizeof("okay"), 1);
+

This controller is always "okay", isn't it?

board/freescale/ls1012aqds/ls1012aqds.c int board_eth_init(bd_t *bis) · line 135

Quoted 3 lines
board/freescale/ls1012aqds/ls1012aqds.c +3 -0
+	card_id = (QIXIS_READ(present2) & 0xe0) >> 5;
+
+	if (card_id == 0x7)

Please put a comment here to explain what present2 has and what 0x7 is.

board/freescale/ls1012aqds/ls1012aqds.c int board_eth_init(bd_t *bis) · line 142

Quoted 7 lines
board/freescale/ls1012aqds/ls1012aqds.c +7 -0
+		do_fixup_by_path(blob, esdhc1_path, "status", "disabled",
+				 sizeof("disabled"), 1);
+	else
+		do_fixup_by_path(blob, esdhc1_path, "status", "okay",
+				 sizeof("okay"), 1);
+}
+

York

author
#3 lore raw

PATCH 2/2 armv8: ls1012a: define esdhc_status_fixup for QDS board

Quoted 32 lines

-----Original Message-----
From: york sun
Sent: Thursday, December 08, 2016 12:03 AM
To: Y.B. Lu; u-boot at lists.denx.de
Subject: Re: [PATCH 2/2] armv8: ls1012a: define esdhc_status_fixup for QDS board

Quoted 24 lines · Yangbo Lu

The LS1012AQDS board has a hardware issue. When there is no eMMC adapter card inserted, the command inhibit bits of eSDHC_PRSSTAT register will never release. This would cause below continious error messages in linux since it uses polling mode to detect card. "mmc1: Controller never released inhibit bit(s)."
"mmc1: Controller never released inhibit bit(s)."
"mmc1: Controller never released inhibit bit(s)."
This patch is to define esdhc_status_fixup function to disable eSDHC2 status if no eMMC adapter card is detected.

---
 board/freescale/ls1012aqds/ls1012aqds.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
board/freescale/ls1012aqds/ls1012aqds.c +0 -0
index 94440b3..a3229f7 100644
@@ -121,6 +121,25 @@ int board_eth_init(bd_t *bis)
 	return pci_eth_init(bis);
 }
 
Quoted 10 lines

board/freescale/ls1012aqds/ls1012aqds.c int board_eth_init(bd_t *bis) · line 132

Quoted 8 lines
board/freescale/ls1012aqds/ls1012aqds.c +8 -0
+int esdhc_status_fixup(void *blob, const char *compat) {
+	char esdhc0_path[] = "/soc/esdhc at 1560000";
+	char esdhc1_path[] = "/soc/esdhc at 1580000";
+	u8 card_id;
+
+	do_fixup_by_path(blob, esdhc0_path, "status", "okay",
+			 sizeof("okay"), 1);
+

This controller is always "okay", isn't it?

[Lu Yangbo-B47093] Yes. Only sdhc2 has issue. I will emphasize it's sdhc2 in commit message.

Quoted 6 lines

board/freescale/ls1012aqds/ls1012aqds.c int board_eth_init(bd_t *bis) · line 135

Quoted 4 lines
board/freescale/ls1012aqds/ls1012aqds.c +3 -0
+	card_id = (QIXIS_READ(present2) & 0xe0) >> 5;
+
+	if (card_id == 0x7)

Please put a comment here to explain what present2 has and what 0x7 is.

[Lu Yangbo-B47093] No problem, thanks. Will send the v2.

Quoted 10 lines

board/freescale/ls1012aqds/ls1012aqds.c int board_eth_init(bd_t *bis) · line 142

Quoted 8 lines
board/freescale/ls1012aqds/ls1012aqds.c +7 -0
+		do_fixup_by_path(blob, esdhc1_path, "status", "disabled",
+				 sizeof("disabled"), 1);
+	else
+		do_fixup_by_path(blob, esdhc1_path, "status", "okay",
+				 sizeof("okay"), 1);
+}
+

York