Skip to contentSkip to conversation

sunxi: Skip MMC0 init when its pinmux conflicts with UART0

PATCH Applied Samuel Holland 3 participants 6 messages Apr 10, 2022 – May 24, 2022

Subsystems (2)
lore
Share & tools
lore

Samuel Holland

author maintainer
#0 lore raw

PATCH 1/2 sunxi: Skip MMC0 init when its pinmux conflicts with UART0

Currently, selecting UART0_PORT_F entirely disables MMC support on sunxi platforms. But this is a bigger hammer then needed. Muxing UART0 to the pins on port F only causes a conflict with MMC0, so minimize the impact by specifically skipping MMC0 init. We can continue to use MMC1/2 if those are enabled.

Let's also remove the preprocessor check while refacting this function.

---

 board/sunxi/board.c | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)
board/sunxi/board.c +10 -12
index 89324159d5..7822001d99 100644
@@ -516,19 +516,17 @@ static void mmc_pinmux_setup(int sdc)
 
 int board_mmc_init(struct bd_info *bis)
 {
-	__maybe_unused struct mmc *mmc0, *mmc1;
-
-	mmc_pinmux_setup(CONFIG_MMC_SUNXI_SLOT);
-	mmc0 = sunxi_mmc_init(CONFIG_MMC_SUNXI_SLOT);
-	if (!mmc0)
-		return -1;
+	if (!IS_ENABLED(CONFIG_UART0_PORT_F)) {
+		mmc_pinmux_setup(CONFIG_MMC_SUNXI_SLOT);
+		if (!sunxi_mmc_init(CONFIG_MMC_SUNXI_SLOT))
+			return -1;
+	}
 
-#if CONFIG_MMC_SUNXI_SLOT_EXTRA != -1
-	mmc_pinmux_setup(CONFIG_MMC_SUNXI_SLOT_EXTRA);
-	mmc1 = sunxi_mmc_init(CONFIG_MMC_SUNXI_SLOT_EXTRA);
-	if (!mmc1)
-		return -1;
-#endif
+	if (CONFIG_MMC_SUNXI_SLOT_EXTRA != -1) {
+		mmc_pinmux_setup(CONFIG_MMC_SUNXI_SLOT_EXTRA);
+		if (!sunxi_mmc_init(CONFIG_MMC_SUNXI_SLOT_EXTRA))
+			return -1;
+	}
 
 	return 0;
 }
Signature · 1 line
2.35.1
author maintainer
#1 lore raw

PATCH 2/2 mmc: sunxi: Remove unnecessary pinmux option dependency

Now that the pinmux conflict is handled in the board code (by skipping setup for the one conflicting MMC controller), the driver does not need to be entirely disabled based on the UART pinmux.

---

 drivers/mmc/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/Kconfig +1 -1
index f04cc44e19..5e2921ce41 100644
@@ -727,7 +727,7 @@ config ZYNQ_HISPD_BROKEN
 
 config MMC_SUNXI
 	bool "Allwinner sunxi SD/MMC Host Controller support"
-	depends on ARCH_SUNXI && !UART0_PORT_F
+	depends on ARCH_SUNXI
 	default y
 	help
 	  This selects support for the SD/MMC Host Controller on
Signature · 1 line
2.35.1
Reviewed-by Peng Fan on v1 2/2
#2 lore raw

Re: [PATCH 2/2] mmc: sunxi: Remove unnecessary pinmux option dependency

Quoted 5 lines · Samuel Holland

Now that the pinmux conflict is handled in the board code (by skipping setup for the one conflicting MMC controller), the driver does not need to be entirely disabled based on the UART pinmux.

Quoted 19 lines

---

  drivers/mmc/Kconfig | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/Kconfig +1 -1
index f04cc44e19..5e2921ce41 100644
@@ -727,7 +727,7 @@ config ZYNQ_HISPD_BROKEN
 
  config MMC_SUNXI
  	bool "Allwinner sunxi SD/MMC Host Controller support"
-	depends on ARCH_SUNXI && !UART0_PORT_F
+	depends on ARCH_SUNXI
  	default y
  	help
  	  This selects support for the SD/MMC Host Controller on
#3 lore raw

Re: [PATCH 2/2] mmc: sunxi: Remove unnecessary pinmux option dependency

In reply to Samuel Holland
Quoted 5 lines · On Sun, 10 Apr 2022 00:13:34 -0500 Samuel Holland <[email protected]> wrote:

Now that the pinmux conflict is handled in the board code (by skipping setup for the one conflicting MMC controller), the driver does not need to be entirely disabled based on the UART pinmux.

Applied to sunxi/master.

Thanks,
Andre

Quoted 18 lines

---

 drivers/mmc/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/Kconfig +1 -1
index f04cc44e19..5e2921ce41 100644
@@ -727,7 +727,7 @@ config ZYNQ_HISPD_BROKEN
 
 config MMC_SUNXI
 	bool "Allwinner sunxi SD/MMC Host Controller support"
-	depends on ARCH_SUNXI && !UART0_PORT_F
+	depends on ARCH_SUNXI
 	default y
 	help
 	  This selects support for the SD/MMC Host Controller on
#4 lore raw
In reply to Samuel Holland
Quoted 7 lines · On Sun, 10 Apr 2022 00:13:33 -0500 Samuel Holland <[email protected]> wrote:

Currently, selecting UART0_PORT_F entirely disables MMC support on sunxi platforms. But this is a bigger hammer then needed. Muxing UART0 to the pins on port F only causes a conflict with MMC0, so minimize the impact by specifically skipping MMC0 init. We can continue to use MMC1/2 if those are enabled.

Let's also remove the preprocessor check while refacting this function.

I like this very much, that should solve a bunch of problems at once and looks nicer.
I will need to test that, but plan on taking it as a fix ASAP.

Thanks,
Andre.

Quoted 41 lines

---

 board/sunxi/board.c | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)
board/sunxi/board.c +10 -12
index 89324159d5..7822001d99 100644
@@ -516,19 +516,17 @@ static void mmc_pinmux_setup(int sdc)
 
 int board_mmc_init(struct bd_info *bis)
 {
-	__maybe_unused struct mmc *mmc0, *mmc1;
-
-	mmc_pinmux_setup(CONFIG_MMC_SUNXI_SLOT);
-	mmc0 = sunxi_mmc_init(CONFIG_MMC_SUNXI_SLOT);
-	if (!mmc0)
-		return -1;
+	if (!IS_ENABLED(CONFIG_UART0_PORT_F)) {
+		mmc_pinmux_setup(CONFIG_MMC_SUNXI_SLOT);
+		if (!sunxi_mmc_init(CONFIG_MMC_SUNXI_SLOT))
+			return -1;
+	}
 
-#if CONFIG_MMC_SUNXI_SLOT_EXTRA != -1
-	mmc_pinmux_setup(CONFIG_MMC_SUNXI_SLOT_EXTRA);
-	mmc1 = sunxi_mmc_init(CONFIG_MMC_SUNXI_SLOT_EXTRA);
-	if (!mmc1)
-		return -1;
-#endif
+	if (CONFIG_MMC_SUNXI_SLOT_EXTRA != -1) {
+		mmc_pinmux_setup(CONFIG_MMC_SUNXI_SLOT_EXTRA);
+		if (!sunxi_mmc_init(CONFIG_MMC_SUNXI_SLOT_EXTRA))
+			return -1;
+	}
 
 	return 0;
 }
#5 lore raw
In reply to Samuel Holland
Quoted 9 lines · On Sun, 10 Apr 2022 00:13:33 -0500 Samuel Holland <[email protected]> wrote:

Currently, selecting UART0_PORT_F entirely disables MMC support on sunxi platforms. But this is a bigger hammer then needed. Muxing UART0 to the pins on port F only causes a conflict with MMC0, so minimize the impact by specifically skipping MMC0 init. We can continue to use MMC1/2 if those are enabled.

Let's also remove the preprocessor check while refacting this function.

Applied to sunxi/master.

Thanks,
Andre

Quoted 39 lines

---

 board/sunxi/board.c | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)
board/sunxi/board.c +10 -12
index 89324159d5..7822001d99 100644
@@ -516,19 +516,17 @@ static void mmc_pinmux_setup(int sdc)
 
 int board_mmc_init(struct bd_info *bis)
 {
-	__maybe_unused struct mmc *mmc0, *mmc1;
-
-	mmc_pinmux_setup(CONFIG_MMC_SUNXI_SLOT);
-	mmc0 = sunxi_mmc_init(CONFIG_MMC_SUNXI_SLOT);
-	if (!mmc0)
-		return -1;
+	if (!IS_ENABLED(CONFIG_UART0_PORT_F)) {
+		mmc_pinmux_setup(CONFIG_MMC_SUNXI_SLOT);
+		if (!sunxi_mmc_init(CONFIG_MMC_SUNXI_SLOT))
+			return -1;
+	}
 
-#if CONFIG_MMC_SUNXI_SLOT_EXTRA != -1
-	mmc_pinmux_setup(CONFIG_MMC_SUNXI_SLOT_EXTRA);
-	mmc1 = sunxi_mmc_init(CONFIG_MMC_SUNXI_SLOT_EXTRA);
-	if (!mmc1)
-		return -1;
-#endif
+	if (CONFIG_MMC_SUNXI_SLOT_EXTRA != -1) {
+		mmc_pinmux_setup(CONFIG_MMC_SUNXI_SLOT_EXTRA);
+		if (!sunxi_mmc_init(CONFIG_MMC_SUNXI_SLOT_EXTRA))
+			return -1;
+	}
 
 	return 0;
 }