Skip to contentSkip to conversation

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

PATCH Superseded Yangbo Lu 2 participants 10 messages Dec 8, 2016 – Jan 13, 2017 MMC, SD and SDIO

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Yangbo Lu

author
#0 lore raw

PATCH v3 1/3 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.

---
Changes for v2:
- None
Changes for v3:
- None

---
 drivers/mmc/fsl_esdhc.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)
drivers/mmc/fsl_esdhc.c +14 -7
index 9796d39..68de04e 100644
@@ -908,17 +908,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",
@@ -931,8 +940,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 v3 1/3 mmc: fsl_esdhc: move 'status' property fixup into a weak function

Hi York,

Any comments on this patchset?
Thanks a lot.

Best regards,
Yangbo Lu

Quoted 65 lines

-----Original Message-----
From: Yangbo Lu [mailto:yangbo.lu at nxp.com]
Sent: Thursday, December 08, 2016 11:42 AM
To: u-boot at lists.denx.de
Cc: york sun; Y.B. Lu
Subject: [v3, 1/3] 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.

---
Changes for v2:
- None
Changes for v3:
- None

---
 drivers/mmc/fsl_esdhc.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)
drivers/mmc/fsl_esdhc.c index renamed from drivers/mmc/fsl_esdhc.c +0 -0

9796d39..68de04e 100644

drivers/mmc/fsl_esdhc.c +13 -8
@@ -908,17 +908,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", @@ -
 931,8 +940,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
 
--

2.1.0.27.g96db324

#2 lore raw

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

Quoted 4 lines · Y.B. Lu

Hi York,

Any comments on this patchset?
Thanks a lot.

You didn't CC me for this set. I didn't notice them in the list. See comment below.

Quoted 32 lines

Best regards,
Yangbo Lu

Quoted 27 lines

-----Original Message-----
From: Yangbo Lu [mailto:yangbo.lu at nxp.com]
Sent: Thursday, December 08, 2016 11:42 AM
To: u-boot at lists.denx.de
Cc: york sun; Y.B. Lu
Subject: [v3, 1/3] 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.

---
Changes for v2:
- None
Changes for v3:
- None

---
 drivers/mmc/fsl_esdhc.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)
drivers/mmc/fsl_esdhc.c index renamed from drivers/mmc/fsl_esdhc.c +0 -0

9796d39..68de04e 100644

drivers/mmc/fsl_esdhc.c +0 -0
@@ -908,17 +908,26 @@ void mmc_adapter_card_type_ident(void)  #endif
 
Quoted 13 lines

drivers/mmc/fsl_esdhc.c void mmc_adapter_card_type_ident(void) · line 917

Quoted 13 lines
drivers/mmc/fsl_esdhc.c +3 -5
 #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;

What's your intention for the non-zero return? It is not considered an error, is it?

Quoted 4 lines
Quoted 4 lines
drivers/mmc/fsl_esdhc.c +2 -0
 	}
 #endif
+	do_fixup_by_compat(blob, compat, "status", "okay",
+			   sizeof("okay"), 1);
Quoted 8 lines

drivers/mmc/fsl_esdhc.c void mmc_adapter_card_type_ident(void) · line 930

Quoted 8 lines
drivers/mmc/fsl_esdhc.c +8 -0
+	return 0;
+}
+
+void fdt_fixup_esdhc(void *blob, bd_t *bd) {
+	const char *compat = "fsl,esdhc";
+
+	if (esdhc_status_fixup(blob, compat))
+		return;

With non-zero return, following code will be skipped. This is the same as code flow before this change. What are you going to do with the new board-level function?

Review comment continues on other patches in this set.

York

author
#3 lore raw

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

Quoted 48 lines

-----Original Message-----
From: york sun
Sent: Friday, January 13, 2017 1:09 AM
To: Y.B. Lu; u-boot at lists.denx.de
Subject: Re: [v3, 1/3] mmc: fsl_esdhc: move 'status' property fixup into a weak function

Quoted 4 lines · Y.B. Lu

Hi York,

Any comments on this patchset?
Thanks a lot.

You didn't CC me for this set. I didn't notice them in the list. See comment below.

Quoted 32 lines

Best regards,
Yangbo Lu

Quoted 27 lines

-----Original Message-----
From: Yangbo Lu [mailto:yangbo.lu at nxp.com]
Sent: Thursday, December 08, 2016 11:42 AM
To: u-boot at lists.denx.de
Cc: york sun; Y.B. Lu
Subject: [v3, 1/3] 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.

---
Changes for v2:
- None
Changes for v3:
- None

---
 drivers/mmc/fsl_esdhc.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)
drivers/mmc/fsl_esdhc.c index renamed from drivers/mmc/fsl_esdhc.c +0 -0

9796d39..68de04e 100644

drivers/mmc/fsl_esdhc.c +0 -0
@@ -908,17 +908,26 @@ void mmc_adapter_card_type_ident(void)  #endif
 
Quoted 17 lines
Quoted 5 lines
Quoted 5 lines
drivers/mmc/fsl_esdhc.c +1 -2
 #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";
Quoted 8 lines

drivers/mmc/fsl_esdhc.c void mmc_adapter_card_type_ident(void) · line 917

Quoted 8 lines
drivers/mmc/fsl_esdhc.c +2 -3
-
 #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;

What's your intention for the non-zero return? It is not considered an error, is it?

[Lu Yangbo-B47093] I intend to get non-zero return when there is no esdhc with 'okay' status. Then the following fixup could be dropped.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/mmc/fsl_esdhc.c +6 -0
 	}
 #endif
+	do_fixup_by_compat(blob, compat, "status", "okay",
+			   sizeof("okay"), 1);
+	return 0;
+}
+
+void fdt_fixup_esdhc(void *blob, bd_t *bd) {
Quoted 8 lines
Quoted 4 lines

drivers/mmc/fsl_esdhc.c void mmc_adapter_card_type_ident(void) · line 930

Quoted 4 lines
drivers/mmc/fsl_esdhc.c +4 -0
+	const char *compat = "fsl,esdhc";
+
+	if (esdhc_status_fixup(blob, compat))
+		return;

With non-zero return, following code will be skipped. This is the same as code flow before this change. What are you going to do with the new board-level function?

[Lu Yangbo-B47093] As I said, if we 'disabled' the status, the following fixup could be dropped. The new board-level function is for some specific boards which have some hardware issue of esdhc. We need to check board hardware in board-level function first and decide to enable it or not.

Quoted 4 lines

Review comment continues on other patches in this set.

York

author
#4 lore raw

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

In reply to Yangbo Lu

The LS1012AQDS board has a hardware issue. When there is no eMMC adapter card inserted in SDHC2 adapter slot, the command inhibit bits of eSDHC2_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 for QDS to disable SDHC2 status if no eMMC adapter card is detected.

---
Changes for v2:
- Added annotation in code
- Added return value
- Modified commit message
Changes for v3:
- None

---
 board/freescale/ls1012aqds/ls1012aqds.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
board/freescale/ls1012aqds/ls1012aqds.c +28 -0
index 94440b3..88fb4ce 100644
@@ -121,6 +121,34 @@ 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);
+
+	/*
+	 * The Presence Detect 2 register detects the installation
+	 * of cards in various PCI Express or SGMII slots.
+	 *
+	 * STAT_PRS2[7:5]: Specifies the type of card installed in the
+	 * SDHC2 Adapter slot. 0b111 indicates no adapter is installed.
+	 */
+	card_id = (QIXIS_READ(present2) & 0xe0) >> 5;
+
+	/* If no adapter is installed in SDHC2, disable SDHC2 */
+	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);
+	return 0;
+}
+
 #ifdef CONFIG_OF_BOARD_SETUP
 int ft_board_setup(void *blob, bd_t *bd)
 {
Signature · 1 line
2.1.0.27.g96db324
#5 lore raw

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

Quoted 29 lines · Yangbo Lu

The LS1012AQDS board has a hardware issue. When there is no eMMC adapter card inserted in SDHC2 adapter slot, the command inhibit bits of eSDHC2_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 for QDS to disable SDHC2 status if no eMMC adapter card is detected.

---
Changes for v2:
- Added annotation in code
- Added return value
- Modified commit message
Changes for v3:
- None

---
 board/freescale/ls1012aqds/ls1012aqds.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
board/freescale/ls1012aqds/ls1012aqds.c +0 -0
index 94440b3..88fb4ce 100644
@@ -121,6 +121,34 @@ 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 131

Quoted 10 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);

Don't you need to search it by compatible? Is the path always correct?

I guess it is always "okay" for esdhc0?
This new function doesn't check hwconfig. Do you need to check?

Quoted 14 lines
board/freescale/ls1012aqds/ls1012aqds.c +13 -0
+
+	/*
+	 * The Presence Detect 2 register detects the installation
+	 * of cards in various PCI Express or SGMII slots.
+	 *
+	 * STAT_PRS2[7:5]: Specifies the type of card installed in the
+	 * SDHC2 Adapter slot. 0b111 indicates no adapter is installed.
+	 */
+	card_id = (QIXIS_READ(present2) & 0xe0) >> 5;
+
+	/* If no adapter is installed in SDHC2, disable SDHC2 */
+	if (card_id == 0x7)
+		do_fixup_by_path(blob, esdhc1_path, "status", "disabled",

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

Quoted 10 lines
board/freescale/ls1012aqds/ls1012aqds.c +7 -0
+				 sizeof("disabled"), 1);
+	else
+		do_fixup_by_path(blob, esdhc1_path, "status", "okay",
+				 sizeof("okay"), 1);
+	return 0;
+}
+
 #ifdef CONFIG_OF_BOARD_SETUP
 int ft_board_setup(void *blob, bd_t *bd)
 {

York

author
#6 lore raw

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

Quoted 41 lines

-----Original Message-----
From: york sun
Sent: Friday, January 13, 2017 1:09 AM
To: Y.B. Lu; u-boot at lists.denx.de
Subject: Re: [U-Boot, v3, 2/3] armv8: ls1012a: define esdhc_status_fixup for QDS board

Quoted 33 lines · Yangbo Lu

The LS1012AQDS board has a hardware issue. When there is no eMMC adapter card inserted in SDHC2 adapter slot, the command inhibit bits of eSDHC2_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 for QDS to disable SDHC2 status if no eMMC adapter card is detected.

---
Changes for v2:
- Added annotation in code
- Added return value
- Modified commit message
Changes for v3:
- None

---
 board/freescale/ls1012aqds/ls1012aqds.c | 28
++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
board/freescale/ls1012aqds/ls1012aqds.c +0 -0
index 94440b3..88fb4ce 100644
@@ -121,6 +121,34 @@ int board_eth_init(bd_t *bis)
 	return pci_eth_init(bis);
 }
 
Quoted 9 lines

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

Quoted 7 lines
board/freescale/ls1012aqds/ls1012aqds.c +7 -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);

Don't you need to search it by compatible? Is the path always correct?

[Lu Yangbo-B47093] Both eSDHC controllers of ls1012a have below compatibles. 'fsl,esdhc'
'fsl,ls1012a-esdhc'

Different compatibles for the two eSDHC controllers are not rejected since they are the same IP. The path will always be correct for ls1012a.

Quoted 4 lines

I guess it is always "okay" for esdhc0?
This new function doesn't check hwconfig. Do you need to check?

[Lu Yangbo-B47093] Yes. Because this function is for ls1012aqds board. I removed hwconfig checking which it doesn't need.

Quoted 25 lines
Quoted 13 lines
board/freescale/ls1012aqds/ls1012aqds.c +13 -0
+
+	/*
+	 * The Presence Detect 2 register detects the installation
+	 * of cards in various PCI Express or SGMII slots.
+	 *
+	 * STAT_PRS2[7:5]: Specifies the type of card installed in the
+	 * SDHC2 Adapter slot. 0b111 indicates no adapter is installed.
+	 */
+	card_id = (QIXIS_READ(present2) & 0xe0) >> 5;
+
+	/* If no adapter is installed in SDHC2, disable SDHC2 */
+	if (card_id == 0x7)
+		do_fixup_by_path(blob, esdhc1_path, "status", "disabled",

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

Quoted 10 lines
board/freescale/ls1012aqds/ls1012aqds.c +7 -0
+				 sizeof("disabled"), 1);
+	else
+		do_fixup_by_path(blob, esdhc1_path, "status", "okay",
+				 sizeof("okay"), 1);
+	return 0;
+}
+
 #ifdef CONFIG_OF_BOARD_SETUP
 int ft_board_setup(void *blob, bd_t *bd)  {
 

York

author
#7 lore raw

PATCH v3 3/3 armv8: ls1012a: define esdhc_status_fixup for RDB board

In reply to Yangbo Lu

On LS1012ARDB board, three dual 1:4 mux/demux devices drive the SDHC2 signals to eMMC, SDIO wifi, SPI and Ardiuno shield. Only when we select eMMC and SDIO wifi, the SDHC2 could be used. Otherwise, the command inhibit bits of eSDHC2_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 for RDB to disable SDHC2 status if no SDIO wifi or eMMC is selected.

---
Changes for v2:
- Added this patch
Changes for v3:
- Fixed checkpatch issue

---
 board/freescale/ls1012ardb/ls1012ardb.c | 39 +++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)
board/freescale/ls1012ardb/ls1012ardb.c +39 -0
index 778434d..708e0a1 100644
@@ -113,6 +113,45 @@ int board_init(void)
 	return 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 io = 0;
+	u8 mux_sdhc2;
+
+	do_fixup_by_path(blob, esdhc0_path, "status", "okay",
+			 sizeof("okay"), 1);
+
+	/* Initialize i2c early for serial flash bank information */
+	i2c_set_bus_num(0);
+
+	/*
+	 * The I2C IO-expander for mux select is used to control the muxing
+	 * of various onboard interfaces.
+	 *
+	 * IO1[3:2] indicates SDHC2 interface demultiplexer select lines.
+	 *	00 - SDIO wifi
+	 *	01 - GPIO (to Arduino)
+	 *	10 - eMMC Memory
+	 *	11 - SPI
+	 */
+	if (i2c_read(I2C_MUX_IO1_ADDR, 0, 1, &io, 1) < 0) {
+		printf("Error reading i2c boot information!\n");
+		return 0; /* Don't want to hang() on this error */
+	}
+
+	mux_sdhc2 = (io & 0x0c) >> 2;
+	/* Enable SDHC2 only when use SDIO wifi and eMMC */
+	if (mux_sdhc2 == 2 || mux_sdhc2 == 0)
+		do_fixup_by_path(blob, esdhc1_path, "status", "okay",
+				 sizeof("okay"), 1);
+	else
+		do_fixup_by_path(blob, esdhc1_path, "status", "disabled",
+				 sizeof("disabled"), 1);
+	return 0;
+}
+
 int ft_board_setup(void *blob, bd_t *bd)
 {
 	arch_fixup_fdt(blob);
Signature · 1 line
2.1.0.27.g96db324
#8 lore raw

PATCH v3 3/3 armv8: ls1012a: define esdhc_status_fixup for RDB board

Quoted 32 lines · Yangbo Lu

On LS1012ARDB board, three dual 1:4 mux/demux devices drive the SDHC2 signals to eMMC, SDIO wifi, SPI and Ardiuno shield. Only when we select eMMC and SDIO wifi, the SDHC2 could be used. Otherwise, the command inhibit bits of eSDHC2_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 for RDB to disable SDHC2 status if no SDIO wifi or eMMC is selected.

---
Changes for v2:
- Added this patch
Changes for v3:
- Fixed checkpatch issue

---
 board/freescale/ls1012ardb/ls1012ardb.c | 39 +++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)
board/freescale/ls1012ardb/ls1012ardb.c +2 -0
index 778434d..708e0a1 100644
@@ -113,6 +113,45 @@ int board_init(void)
 	return 0;
 }
 
+int esdhc_status_fixup(void *blob, const char *compat)
+{

board/freescale/ls1012ardb/ls1012ardb.c int board_init(void) · line 127

Quoted 10 lines
board/freescale/ls1012ardb/ls1012ardb.c +10 -0
+	char esdhc0_path[] = "/soc/esdhc at 1560000";
+	char esdhc1_path[] = "/soc/esdhc at 1580000";
+	u8 io = 0;
+	u8 mux_sdhc2;
+
+	do_fixup_by_path(blob, esdhc0_path, "status", "okay",
+			 sizeof("okay"), 1);
+
+	/* Initialize i2c early for serial flash bank information */
+	i2c_set_bus_num(0);

What do you mean "early" in the comment? This function is called after I2C is initialized.

Quoted 4 lines
board/freescale/ls1012ardb/ls1012ardb.c +4 -0
+
+	/*
+	 * The I2C IO-expander for mux select is used to control the muxing
+	 * of various onboard interfaces.

board/freescale/ls1012ardb/ls1012ardb.c int board_init(void) · line 141

Quoted 10 lines
board/freescale/ls1012ardb/ls1012ardb.c +10 -0
+	 *
+	 * IO1[3:2] indicates SDHC2 interface demultiplexer select lines.
+	 *	00 - SDIO wifi
+	 *	01 - GPIO (to Arduino)
+	 *	10 - eMMC Memory
+	 *	11 - SPI
+	 */
+	if (i2c_read(I2C_MUX_IO1_ADDR, 0, 1, &io, 1) < 0) {
+		printf("Error reading i2c boot information!\n");
+		return 0; /* Don't want to hang() on this error */

In case of this error, do you want to "disable" esdhc1?

Quoted 7 lines
board/freescale/ls1012ardb/ls1012ardb.c +6 -0
+	}
+
+	mux_sdhc2 = (io & 0x0c) >> 2;
+	/* Enable SDHC2 only when use SDIO wifi and eMMC */
+	if (mux_sdhc2 == 2 || mux_sdhc2 == 0)
+		do_fixup_by_path(blob, esdhc1_path, "status", "okay",

board/freescale/ls1012ardb/ls1012ardb.c int board_init(void) · line 157

Quoted 10 lines
board/freescale/ls1012ardb/ls1012ardb.c +7 -0
+				 sizeof("okay"), 1);
+	else
+		do_fixup_by_path(blob, esdhc1_path, "status", "disabled",
+				 sizeof("disabled"), 1);
+	return 0;
+}
+
 int ft_board_setup(void *blob, bd_t *bd)
 {
 	arch_fixup_fdt(blob);

York

author
#9 lore raw

PATCH v3 3/3 armv8: ls1012a: define esdhc_status_fixup for RDB board

Quoted 40 lines

-----Original Message-----
From: york sun
Sent: Friday, January 13, 2017 1:09 AM
To: Y.B. Lu; u-boot at lists.denx.de
Subject: Re: [U-Boot, v3, 3/3] armv8: ls1012a: define esdhc_status_fixup for RDB board

Quoted 32 lines · Yangbo Lu

On LS1012ARDB board, three dual 1:4 mux/demux devices drive the SDHC2 signals to eMMC, SDIO wifi, SPI and Ardiuno shield. Only when we select eMMC and SDIO wifi, the SDHC2 could be used. Otherwise, the command inhibit bits of eSDHC2_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 for RDB to disable SDHC2 status if no SDIO wifi or eMMC is selected.

---
Changes for v2:
- Added this patch
Changes for v3:
- Fixed checkpatch issue

---
 board/freescale/ls1012ardb/ls1012ardb.c | 39
+++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)
board/freescale/ls1012ardb/ls1012ardb.c +0 -0
index 778434d..708e0a1 100644
@@ -113,6 +113,45 @@ int board_init(void)
 	return 0;
 }
 
Quoted 15 lines

board/freescale/ls1012ardb/ls1012ardb.c int board_init(void) · line 127

Quoted 11 lines
board/freescale/ls1012ardb/ls1012ardb.c +11 -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 io = 0;
+	u8 mux_sdhc2;
+
+	do_fixup_by_path(blob, esdhc0_path, "status", "okay",
+			 sizeof("okay"), 1);
+
+	/* Initialize i2c early for serial flash bank information */
+	i2c_set_bus_num(0);

What do you mean "early" in the comment? This function is called after I2C is initialized.

[Lu Yangbo-B47093] Sorry, it's really confusing comment. I will remove it.

Quoted 8 lines
Quoted 8 lines
board/freescale/ls1012ardb/ls1012ardb.c +8 -0
+
+	/*
+	 * The I2C IO-expander for mux select is used to control the muxing
+	 * of various onboard interfaces.
+	 *
+	 * IO1[3:2] indicates SDHC2 interface demultiplexer select lines.
+	 *	00 - SDIO wifi
+	 *	01 - GPIO (to Arduino)
Quoted 8 lines

board/freescale/ls1012ardb/ls1012ardb.c int board_init(void) · line 141

Quoted 6 lines
board/freescale/ls1012ardb/ls1012ardb.c +6 -0
+	 *	10 - eMMC Memory
+	 *	11 - SPI
+	 */
+	if (i2c_read(I2C_MUX_IO1_ADDR, 0, 1, &io, 1) < 0) {
+		printf("Error reading i2c boot information!\n");
+		return 0; /* Don't want to hang() on this error */

In case of this error, do you want to "disable" esdhc1?

[Lu Yangbo-B47093] If error occurs here, I just used return to let kernel dts decide to use it or not.

Quoted 19 lines
Quoted 7 lines
board/freescale/ls1012ardb/ls1012ardb.c +6 -0
+	}
+
+	mux_sdhc2 = (io & 0x0c) >> 2;
+	/* Enable SDHC2 only when use SDIO wifi and eMMC */
+	if (mux_sdhc2 == 2 || mux_sdhc2 == 0)
+		do_fixup_by_path(blob, esdhc1_path, "status", "okay",

board/freescale/ls1012ardb/ls1012ardb.c int board_init(void)

Quoted 10 lines
board/freescale/ls1012ardb/ls1012ardb.c +7 -0
+				 sizeof("okay"), 1);
+	else
+		do_fixup_by_path(blob, esdhc1_path, "status", "disabled",
+				 sizeof("disabled"), 1);
+	return 0;
+}
+
 int ft_board_setup(void *blob, bd_t *bd)  {
 	arch_fixup_fdt(blob);
 

York