diff mbox series

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

Message ID 20220410051335.52093-1-samuel@sholland.org
State Accepted
Commit 3ba0a25c444a0197662367131ca2533a4bccf16a
Delegated to: Andre Przywara
Headers show
Series [1/2] sunxi: Skip MMC0 init when its pinmux conflicts with UART0 | expand

Commit Message

Samuel Holland April 10, 2022, 5:13 a.m. UTC
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.

Signed-off-by: Samuel Holland <samuel@sholland.org>
---

 board/sunxi/board.c | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

Comments

Andre Przywara April 26, 2022, 12:58 p.m. UTC | #1
On Sun, 10 Apr 2022 00:13:33 -0500
Samuel Holland <samuel@sholland.org> 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.

> 
> Signed-off-by: Samuel Holland <samuel@sholland.org>
> ---
> 
>  board/sunxi/board.c | 22 ++++++++++------------
>  1 file changed, 10 insertions(+), 12 deletions(-)
> 
> diff --git a/board/sunxi/board.c b/board/sunxi/board.c
> index 89324159d5..7822001d99 100644
> --- a/board/sunxi/board.c
> +++ b/board/sunxi/board.c
> @@ -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;
>  }
Andre Przywara May 24, 2022, 4:14 p.m. UTC | #2
On Sun, 10 Apr 2022 00:13:33 -0500
Samuel Holland <samuel@sholland.org> 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.
> 
> Signed-off-by: Samuel Holland <samuel@sholland.org>

Applied to sunxi/master.

Thanks,
Andre

> ---
> 
>  board/sunxi/board.c | 22 ++++++++++------------
>  1 file changed, 10 insertions(+), 12 deletions(-)
> 
> diff --git a/board/sunxi/board.c b/board/sunxi/board.c
> index 89324159d5..7822001d99 100644
> --- a/board/sunxi/board.c
> +++ b/board/sunxi/board.c
> @@ -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;
>  }
diff mbox series

Patch

diff --git a/board/sunxi/board.c b/board/sunxi/board.c
index 89324159d5..7822001d99 100644
--- a/board/sunxi/board.c
+++ b/board/sunxi/board.c
@@ -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;
 }