Skip to contentSkip to conversation

sunxi: Enable second sdcard slot found on some boards

PATCH Superseded Hans de Goede 2 participants 14 messages Oct 6, 2014 – Oct 12, 2014

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover sunxi: Enable second sdcard slot found on some boards

Hi Ian, et al,

Here is v2 of my second sdcard slot support patch-set. Changes since v1:

-Drop "sunxi: Add sunxi_gpio_get_val function", use gpio_direction_input
instead
-"sunxi: Add mmc card-detect functionality":
Instead of using magic integer numbers for the card-detect pin, make it a string and use name_to_gpio
-"sunxi: When we've both mmc0 and mmc2, detect from which one we're booting":
Add some extra info about why we swap the devs to the commit message.
-"sunxi: Enable second sdcard slot found on some boards"
Changed defconfig settings for card-detect pins to P?# strings

Ian, note I'm travelling for work for the next 2 weeks, so assuming you don't find any issues during review, can you merge this into u-boot-sunxi/next please ?

Regards,

Hans

#1 lore raw

PATCH v2 1/5 sunxi: Add mmc card-detect functionality

---
 board/sunxi/Kconfig            | 26 ++++++++++++++++++++++++++
 drivers/mmc/sunxi_mmc.c        | 21 +++++++++++++++++++++
 include/configs/sunxi-common.h |  1 +
 3 files changed, 48 insertions(+)
board/sunxi/Kconfig +26 -0
index 622f7b4..497b093 100644
@@ -32,4 +32,30 @@ config USB_KEYBOARD
 	Say Y here to add support for using a USB keyboard (typically used
 	in combination with a graphical console on HDMI).
 
+config MMC0_CD_PIN
+	string "Card detect pin for mmc0"
+	default ""
+	---help---
+	Set the card detect pin for mmc0, leave empty to not use cd. This
+	takes a string in the format understood by sunxi_name_to_gpio, e.g.
+	PH1 for pin 1 of port H.
+
+config MMC1_CD_PIN
+	string "Card detect pin for mmc1"
+	default ""
+	---help---
+	See MMC0_CD_PIN help text.
+
+config MMC2_CD_PIN
+	string "Card detect pin for mmc2"
+	default ""
+	---help---
+	See MMC0_CD_PIN help text.
+
+config MMC3_CD_PIN
+	string "Card detect pin for mmc3"
+	default ""
+	---help---
+	See MMC0_CD_PIN help text.
+
 endif
drivers/mmc/sunxi_mmc.c +21 -0
index bc2c4b3..0ea9f4d 100644
@@ -14,7 +14,9 @@
 #include <asm/io.h>
 #include <asm/arch/clock.h>
 #include <asm/arch/cpu.h>
+#include <asm/arch/gpio.h>
 #include <asm/arch/mmc.h>
+#include <asm-generic/gpio.h>
 
 struct sunxi_mmc_host {
 	unsigned mmc_no;
@@ -343,10 +345,29 @@ out:
 	return error;
 }
 
+static int sunxi_mmc_getcd(struct mmc *mmc)
+{
+	struct sunxi_mmc_host *mmchost = mmc->priv;
+	int cd_pin = -1;
+
+	switch (mmchost->mmc_no) {
+	case 0: cd_pin = sunxi_name_to_gpio(CONFIG_MMC0_CD_PIN); break;
+	case 1: cd_pin = sunxi_name_to_gpio(CONFIG_MMC1_CD_PIN); break;
+	case 2: cd_pin = sunxi_name_to_gpio(CONFIG_MMC2_CD_PIN); break;
+	case 3: cd_pin = sunxi_name_to_gpio(CONFIG_MMC3_CD_PIN); break;
+	}
+
+	if (cd_pin == -1)
+		return 1;
+
+	return !gpio_direction_input(cd_pin);
+}
+
 static const struct mmc_ops sunxi_mmc_ops = {
 	.send_cmd	= mmc_send_cmd,
 	.set_ios	= mmc_set_ios,
 	.init		= mmc_core_init,
+	.getcd		= sunxi_mmc_getcd,
 };
 
 int sunxi_mmc_init(int sdc_no)
include/configs/sunxi-common.h +1 -0
index af48c97..0ff67ee 100644
@@ -183,6 +183,7 @@
 
 /* GPIO */
 #define CONFIG_SUNXI_GPIO
+#define CONFIG_SPL_GPIO_SUPPORT
 #define CONFIG_CMD_GPIO
 
 #ifdef CONFIG_VIDEO
Signature · 1 line
2.1.0
#2 lore raw

PATCH v2 1/5 sunxi: Add mmc card-detect functionality

Quoted 1 line · Hans de Goede

I presume that adding GPIO support to SPL isn't a problem size wise?

Quoted 11 lines
---
 board/sunxi/Kconfig            | 26 ++++++++++++++++++++++++++
 drivers/mmc/sunxi_mmc.c        | 21 +++++++++++++++++++++
 include/configs/sunxi-common.h |  1 +
 3 files changed, 48 insertions(+)
board/sunxi/Kconfig +0 -0
index 622f7b4..497b093 100644

board/sunxi/Kconfig config USB_KEYBOARD · line 39

Quoted 8 lines
board/sunxi/Kconfig +5 -0
@@ -32,4 +32,30 @@ config USB_KEYBOARD
 	Say Y here to add support for using a USB keyboard (typically used
 	in combination with a graphical console on HDMI).
 
+config MMC0_CD_PIN
+	string "Card detect pin for mmc0"
+	default ""
+	---help---
+	Set the card detect pin for mmc0, leave empty to not use cd.

sunxi_name_to_gpio() doesn't handle the empty string directly, but I think it will do the right thing (i.e. return -1) via a more or less convoluted path. Did you check this?

Assuming you have then: Acked-by: Ian Campbell <[email protected]>

Ian.

#3 lore raw

PATCH v2 1/5 sunxi: Add mmc card-detect functionality

Hi,

Quoted 4 lines · Ian Campbell
Quoted 1 line · Hans de Goede

I presume that adding GPIO support to SPL isn't a problem size wise?

We do link time size checking and "./MAKEALL -s sunxi" still works fine, so yes it is not a problem.

Quoted 14 lines
Quoted 14 lines
---
 board/sunxi/Kconfig            | 26 ++++++++++++++++++++++++++
 drivers/mmc/sunxi_mmc.c        | 21 +++++++++++++++++++++
 include/configs/sunxi-common.h |  1 +
 3 files changed, 48 insertions(+)
board/sunxi/Kconfig +0 -0
index 622f7b4..497b093 100644
@@ -32,4 +32,30 @@ config USB_KEYBOARD
 	Say Y here to add support for using a USB keyboard (typically used
 	in combination with a graphical console on HDMI).
 
Quoted 9 lines

board/sunxi/Kconfig config USB_KEYBOARD

Quoted 5 lines
board/sunxi/Kconfig +5 -0
+config MMC0_CD_PIN
+	string "Card detect pin for mmc0"
+	default ""
+	---help---
+	Set the card detect pin for mmc0, leave empty to not use cd.

sunxi_name_to_gpio() doesn't handle the empty string directly, but I think it will do the right thing (i.e. return -1) via a more or less convoluted path. Did you check this?

Yes I checked, it will return -1 on the empty string.

Quoted 1 line

Assuming you have then: Acked-by: Ian Campbell <[email protected]>

Regards,

Hans

#4 lore raw

PATCH v2 2/5 sunxi: Turn MMC_SUNXI_SLOT_EXTRA into a proper Kconfig option

In reply to Hans de Goede

Note we also drop the SPL check for initializing the 2nd mmc slot, the SPL check is not necessary with Kconfig, because only options explicitly marked as also being for the SPL get set during SPL builds.

---
 board/sunxi/Kconfig | 8 ++++++++
 board/sunxi/board.c | 2 +-
 2 files changed, 9 insertions(+), 1 deletion(-)
board/sunxi/Kconfig +8 -0
index 497b093..cb4a881 100644
@@ -32,6 +32,14 @@ config USB_KEYBOARD
 	Say Y here to add support for using a USB keyboard (typically used
 	in combination with a graphical console on HDMI).
 
+config MMC_SUNXI_SLOT_EXTRA
+	int "mmc extra slot number"
+	default -1
+	---help---
+	sunxi builds always enable mmc0, some boards also have a sdcard slot
+	or emmc on mmc2 or mmc3. Setting this to 2 or 3 will enable support
+	for this.
+
 config MMC0_CD_PIN
 	string "Card detect pin for mmc0"
 	default ""
board/sunxi/board.c +1 -1
index e819b12..4d602ca 100644
@@ -110,7 +110,7 @@ int board_mmc_init(bd_t *bis)
 {
 	mmc_pinmux_setup(CONFIG_MMC_SUNXI_SLOT);
 	sunxi_mmc_init(CONFIG_MMC_SUNXI_SLOT);
-#if !defined (CONFIG_SPL_BUILD) && defined (CONFIG_MMC_SUNXI_SLOT_EXTRA)
+#if CONFIG_MMC_SUNXI_SLOT_EXTRA != -1
 	mmc_pinmux_setup(CONFIG_MMC_SUNXI_SLOT_EXTRA);
 	sunxi_mmc_init(CONFIG_MMC_SUNXI_SLOT_EXTRA);
 #endif
Signature · 1 line
2.1.0
#5 lore raw

PATCH v2 2/5 sunxi: Turn MMC_SUNXI_SLOT_EXTRA into a proper Kconfig option

Quoted 15 lines · Hans de Goede

Note we also drop the SPL check for initializing the 2nd mmc slot, the SPL check is not necessary with Kconfig, because only options explicitly marked as also being for the SPL get set during SPL builds.

---
 board/sunxi/Kconfig | 8 ++++++++
 board/sunxi/board.c | 2 +-
 2 files changed, 9 insertions(+), 1 deletion(-)
board/sunxi/Kconfig +0 -0
index 497b093..cb4a881 100644

board/sunxi/Kconfig config USB_KEYBOARD · line 41

Quoted 10 lines
board/sunxi/Kconfig +7 -0
@@ -32,6 +32,14 @@ config USB_KEYBOARD
 	Say Y here to add support for using a USB keyboard (typically used
 	in combination with a graphical console on HDMI).
 
+config MMC_SUNXI_SLOT_EXTRA
+	int "mmc extra slot number"
+	default -1
+	---help---
+	sunxi builds always enable mmc0, some boards also have a sdcard slot
+	or emmc on mmc2 or mmc3. Setting this to 2 or 3 will enable support
+	for this.

What happened to mmc1?

Regardless:

#6 lore raw

PATCH v2 2/5 sunxi: Turn MMC_SUNXI_SLOT_EXTRA into a proper Kconfig option

Hi,

Quoted 19 lines · Ian Campbell
Quoted 18 lines · Hans de Goede

Note we also drop the SPL check for initializing the 2nd mmc slot, the SPL check is not necessary with Kconfig, because only options explicitly marked as also being for the SPL get set during SPL builds.

---
 board/sunxi/Kconfig | 8 ++++++++
 board/sunxi/board.c | 2 +-
 2 files changed, 9 insertions(+), 1 deletion(-)
board/sunxi/Kconfig +0 -0
index 497b093..cb4a881 100644
@@ -32,6 +32,14 @@ config USB_KEYBOARD
 	Say Y here to add support for using a USB keyboard (typically used
 	in combination with a graphical console on HDMI).
 
Quoted 9 lines

board/sunxi/Kconfig config USB_KEYBOARD · line 41

Quoted 7 lines
board/sunxi/Kconfig +7 -0
+config MMC_SUNXI_SLOT_EXTRA
+	int "mmc extra slot number"
+	default -1
+	---help---
+	sunxi builds always enable mmc0, some boards also have a sdcard slot
+	or emmc on mmc2 or mmc3. Setting this to 2 or 3 will enable support
+	for this.

What happened to mmc1?

When writing this I was under the assumption that nothing was actually using mmc1, I will fix the help text.

Quoted 4 lines

Regardless:

Regards,

Hans

#7 lore raw

PATCH v2 3/5 sunxi: When we've both mmc0 and mmc2, detect from which one we're booting

In reply to Hans de Goede

sunxi SOCs can boot from both mmc0 and mmc2, detect from which one we're booting, and make that one "mmc dev 0" so that a single u-boot binary can be used for both the onboard eMMC and for external sdcards.

When we're booting from mmc2, we make it dev 0 because that is where the SPL will load the tertiary payload (the actual u-boot binary in our case) from,
see: common/spl/spl_mmc.c, which has dev 0 hardcoded everywhere.

---
 arch/arm/include/asm/arch-sunxi/mmc.h |  2 +-
 board/sunxi/board.c                   | 25 +++++++++++++++++++++++--
 drivers/mmc/sunxi_mmc.c               |  7 ++-----
 3 files changed, 26 insertions(+), 8 deletions(-)
arch/arm/include/asm/arch-sunxi/mmc.h +1 -1
index 53196e3..ff2602d 100644
@@ -120,5 +120,5 @@ struct sunxi_mmc {
 #define SUNXI_MMC_IDIE_TXIRQ		(0x1 << 0)
 #define SUNXI_MMC_IDIE_RXIRQ		(0x1 << 1)
 
-int sunxi_mmc_init(int sdc_no);
+struct mmc *sunxi_mmc_init(int sdc_no);
 #endif /* _SUNXI_MMC_H */
board/sunxi/board.c +23 -2
index 4d602ca..0a7be31 100644
@@ -12,6 +12,7 @@
  */
 
 #include <common.h>
+#include <mmc.h>
 #ifdef CONFIG_AXP152_POWER
 #include <axp152.h>
 #endif
@@ -108,11 +109,31 @@ static void mmc_pinmux_setup(int sdc)
 
 int board_mmc_init(bd_t *bis)
 {
+	__maybe_unused struct mmc *mmc0, *mmc1;
+	__maybe_unused char buf[512];
+
 	mmc_pinmux_setup(CONFIG_MMC_SUNXI_SLOT);
-	sunxi_mmc_init(CONFIG_MMC_SUNXI_SLOT);
+	mmc0 = sunxi_mmc_init(CONFIG_MMC_SUNXI_SLOT);
 #if CONFIG_MMC_SUNXI_SLOT_EXTRA != -1
 	mmc_pinmux_setup(CONFIG_MMC_SUNXI_SLOT_EXTRA);
-	sunxi_mmc_init(CONFIG_MMC_SUNXI_SLOT_EXTRA);
+	mmc1 = sunxi_mmc_init(CONFIG_MMC_SUNXI_SLOT_EXTRA);
+#endif
+
+#if CONFIG_MMC_SUNXI_SLOT == 0 && CONFIG_MMC_SUNXI_SLOT_EXTRA == 2
+	/*
+	 * Both mmc0 and mmc2 are bootable, figure out where we're booting
+	 * from. Try mmc0 first, just like the brom does.
+	 */
+	if (mmc_getcd(mmc0) && mmc_init(mmc0) == 0 &&
+	    mmc0->block_dev.block_read(0, 16, 1, buf) == 1) {
+		buf[12] = 0;
+		if (strcmp(&buf[4], "eGON.BT0") == 0)
+			return 0;
+	}
+
+	/* no bootable card in mmc0, so we must be booting from mmc2, swap */
+	mmc0->block_dev.dev = 1;
+	mmc1->block_dev.dev = 0;
 #endif
 
 	return 0;
drivers/mmc/sunxi_mmc.c +2 -5
index 0ea9f4d..7526540 100644
@@ -370,7 +370,7 @@ static const struct mmc_ops sunxi_mmc_ops = {
 	.getcd		= sunxi_mmc_getcd,
 };
 
-int sunxi_mmc_init(int sdc_no)
+struct mmc *sunxi_mmc_init(int sdc_no)
 {
 	struct mmc_config *cfg = &mmc_host[sdc_no].cfg;
 
@@ -393,8 +393,5 @@ int sunxi_mmc_init(int sdc_no)
 	mmc_resource_init(sdc_no);
 	mmc_clk_io_on(sdc_no);
 
-	if (mmc_create(cfg, &mmc_host[sdc_no]) == NULL)
-		return -1;
-
-	return 0;
+	return mmc_create(cfg, &mmc_host[sdc_no]);
 }
Signature · 1 line
2.1.0
#8 lore raw

PATCH v2 3/5 sunxi: When we've both mmc0 and mmc2, detect from which one we're booting

Quoted 12 lines · Hans de Goede
board/sunxi/board.c +4 -1
@@ -108,11 +109,31 @@ static void mmc_pinmux_setup(int sdc)
 
 int board_mmc_init(bd_t *bis)
 {
+	__maybe_unused struct mmc *mmc0, *mmc1;
+	__maybe_unused char buf[512];
+
 	mmc_pinmux_setup(CONFIG_MMC_SUNXI_SLOT);
-	sunxi_mmc_init(CONFIG_MMC_SUNXI_SLOT);
+	mmc0 = sunxi_mmc_init(CONFIG_MMC_SUNXI_SLOT);
 #if CONFIG_MMC_SUNXI_SLOT_EXTRA != -1
 	mmc_pinmux_setup(CONFIG_MMC_SUNXI_SLOT_EXTRA);

board/sunxi/board.c static void mmc_pinmux_setup(int sdc) · line 127

Quoted 10 lines
board/sunxi/board.c +9 -1
-	sunxi_mmc_init(CONFIG_MMC_SUNXI_SLOT_EXTRA);
+	mmc1 = sunxi_mmc_init(CONFIG_MMC_SUNXI_SLOT_EXTRA);
+#endif
+
+#if CONFIG_MMC_SUNXI_SLOT == 0 && CONFIG_MMC_SUNXI_SLOT_EXTRA == 2
+	/*
+	 * Both mmc0 and mmc2 are bootable, figure out where we're booting
+	 * from. Try mmc0 first, just like the brom does.
+	 */
+	if (mmc_getcd(mmc0) && mmc_init(mmc0) == 0 &&

If sunxi_mmx_init failed then mmc0 might be NULL here.

board/sunxi/board.c static void mmc_pinmux_setup(int sdc) · line 136

Quoted 9 lines
board/sunxi/board.c +9 -0
+	    mmc0->block_dev.block_read(0, 16, 1, buf) == 1) {
+		buf[12] = 0;
+		if (strcmp(&buf[4], "eGON.BT0") == 0)
+			return 0;
+	}
+
+	/* no bootable card in mmc0, so we must be booting from mmc2, swap */
+	mmc0->block_dev.dev = 1;
+	mmc1->block_dev.dev = 0;

and mmc1 could be NULL here.

Ian.

#9 lore raw

PATCH v2 3/5 sunxi: When we've both mmc0 and mmc2, detect from which one we're booting

Hi,

Quoted 26 lines · Ian Campbell
Quoted 12 lines · Hans de Goede
board/sunxi/board.c +4 -1
@@ -108,11 +109,31 @@ static void mmc_pinmux_setup(int sdc)
 
 int board_mmc_init(bd_t *bis)
 {
+	__maybe_unused struct mmc *mmc0, *mmc1;
+	__maybe_unused char buf[512];
+
 	mmc_pinmux_setup(CONFIG_MMC_SUNXI_SLOT);
-	sunxi_mmc_init(CONFIG_MMC_SUNXI_SLOT);
+	mmc0 = sunxi_mmc_init(CONFIG_MMC_SUNXI_SLOT);
 #if CONFIG_MMC_SUNXI_SLOT_EXTRA != -1
 	mmc_pinmux_setup(CONFIG_MMC_SUNXI_SLOT_EXTRA);

board/sunxi/board.c static void mmc_pinmux_setup(int sdc) · line 127

Quoted 10 lines
board/sunxi/board.c +9 -1
-	sunxi_mmc_init(CONFIG_MMC_SUNXI_SLOT_EXTRA);
+	mmc1 = sunxi_mmc_init(CONFIG_MMC_SUNXI_SLOT_EXTRA);
+#endif
+
+#if CONFIG_MMC_SUNXI_SLOT == 0 && CONFIG_MMC_SUNXI_SLOT_EXTRA == 2
+	/*
+	 * Both mmc0 and mmc2 are bootable, figure out where we're booting
+	 * from. Try mmc0 first, just like the brom does.
+	 */
+	if (mmc_getcd(mmc0) && mmc_init(mmc0) == 0 &&

If sunxi_mmx_init failed then mmc0 might be NULL here.

Quoted 11 lines

board/sunxi/board.c static void mmc_pinmux_setup(int sdc) · line 136

Quoted 9 lines
board/sunxi/board.c +9 -0
+	    mmc0->block_dev.block_read(0, 16, 1, buf) == 1) {
+		buf[12] = 0;
+		if (strcmp(&buf[4], "eGON.BT0") == 0)
+			return 0;
+	}
+
+	/* no bootable card in mmc0, so we must be booting from mmc2, swap */
+	mmc0->block_dev.dev = 1;
+	mmc1->block_dev.dev = 0;

and mmc1 could be NULL here.

Hmm, this only happens when the calloc in mmc_create fails. I'll fix this in v3, but I really believe that we should just switch u-boot over to the glib malloc model of malloc should never fail.

Regards,

Hans

Quoted 3 lines

Ian.

#10 lore raw

PATCH v2 4/5 sunxi: Use PG3 - PG8 as io-pins for mmc1

In reply to Hans de Goede

None of the known sunxi devices actually use mmc1 routed through PH, where as some devices do actually use mmc1 routed through PG, so change the routing of mmc1 to PG. If in the future we encounter devices with mmc1 routed through PH, we will need to change things to be a bit more flexible.

---
 arch/arm/include/asm/arch-sunxi/gpio.h | 2 ++
 board/sunxi/board.c                    | 6 +++---
 2 files changed, 5 insertions(+), 3 deletions(-)
arch/arm/include/asm/arch-sunxi/gpio.h +2 -0
index f7f3d8c..3f46f78 100644
@@ -117,6 +117,8 @@ enum sunxi_gpio_number {
 #define SUN5I_GPB19_UART0_TX	2
 #define SUN5I_GPB20_UART0_RX	2
 
+#define SUN5I_GPG3_SDC1		2
+
 #define SUN5I_GPG3_UART1_TX	4
 #define SUN5I_GPG4_UART1_RX	4
 
board/sunxi/board.c +3 -3
index 0a7be31..23f8887 100644
@@ -75,9 +75,9 @@ static void mmc_pinmux_setup(int sdc)
 		break;
 
 	case 1:
-		/* CMD-PH22, CLK-PH23, D0~D3-PH24~27 : 5 */
-		for (pin = SUNXI_GPH(22); pin <= SUNXI_GPH(27); pin++) {
-			sunxi_gpio_set_cfgpin(pin, SUN4I_GPH22_SDC1);
+		/* CMD-PG3, CLK-PG4, D0~D3-PG5-8 */
+		for (pin = SUNXI_GPG(3); pin <= SUNXI_GPG(8); pin++) {
+			sunxi_gpio_set_cfgpin(pin, SUN5I_GPG3_SDC1);
 			sunxi_gpio_set_pull(pin, SUNXI_GPIO_PULL_UP);
 			sunxi_gpio_set_drv(pin, 2);
 		}
Signature · 1 line
2.1.0
#11 lore raw

PATCH v2 4/5 sunxi: Use PG3 - PG8 as io-pins for mmc1

Quoted 6 lines · Hans de Goede

None of the known sunxi devices actually use mmc1 routed through PH, where as some devices do actually use mmc1 routed through PG, so change the routing of mmc1 to PG. If in the future we encounter devices with mmc1 routed through PH, we will need to change things to be a bit more flexible.

(right address this time ;-))

Quoted 35 lines
---
 arch/arm/include/asm/arch-sunxi/gpio.h | 2 ++
 board/sunxi/board.c                    | 6 +++---
 2 files changed, 5 insertions(+), 3 deletions(-)
arch/arm/include/asm/arch-sunxi/gpio.h +2 -0
index f7f3d8c..3f46f78 100644
@@ -117,6 +117,8 @@ enum sunxi_gpio_number {
 #define SUN5I_GPB19_UART0_TX	2
 #define SUN5I_GPB20_UART0_RX	2
 
+#define SUN5I_GPG3_SDC1		2
+
 #define SUN5I_GPG3_UART1_TX	4
 #define SUN5I_GPG4_UART1_RX	4
 
board/sunxi/board.c +3 -3
index 0a7be31..23f8887 100644
@@ -75,9 +75,9 @@ static void mmc_pinmux_setup(int sdc)
 		break;
 
 	case 1:
-		/* CMD-PH22, CLK-PH23, D0~D3-PH24~27 : 5 */
-		for (pin = SUNXI_GPH(22); pin <= SUNXI_GPH(27); pin++) {
-			sunxi_gpio_set_cfgpin(pin, SUN4I_GPH22_SDC1);
+		/* CMD-PG3, CLK-PG4, D0~D3-PG5-8 */
+		for (pin = SUNXI_GPG(3); pin <= SUNXI_GPG(8); pin++) {
+			sunxi_gpio_set_cfgpin(pin, SUN5I_GPG3_SDC1);
 			sunxi_gpio_set_pull(pin, SUNXI_GPIO_PULL_UP);
 			sunxi_gpio_set_drv(pin, 2);
 		}
#12 lore raw

PATCH v2 5/5 sunxi: Enable second sdcard slot found on some boards

In reply to Hans de Goede

Enable the second sdcard slot found on some boards. Note that we do not set CONFIG_MMC_SUNXI_SLOT_EXTRA for the SPL, as having it there is not useful,

Except for on the Mele-M3 where the second sdcard is an eMMC, from which the device can also boot, and there we want to have both in the SPL, so that a single u-boot binary can both from both. So for the M3 we do prefix the defconfig setting with the special "+S:" syntax so that it applies to the SPL too.

---
 configs/A10s-OLinuXino-M_defconfig    | 3 +++
 configs/A20-OLinuXino_MICRO_defconfig | 3 +++
 configs/Mele_M3_defconfig             | 2 ++
 3 files changed, 8 insertions(+)
configs/A10s-OLinuXino-M_defconfig +3 -0
index a578c06..2aad834 100644
@@ -1,5 +1,8 @@
 CONFIG_SPL=y
 CONFIG_SYS_EXTRA_OPTIONS="A10S_OLINUXINO_M,AXP152_POWER,SUNXI_EMAC,USB_EHCI,SUNXI_USB_VBUS0_GPIO=SUNXI_GPB(10)"
 CONFIG_FDTFILE="sun5i-a10s-olinuxino-micro.dtb"
+CONFIG_MMC_SUNXI_SLOT_EXTRA=1
++S:CONFIG_MMC0_CD_PIN="PG1"
++S:CONFIG_MMC1_CD_PIN="PG13"
 +S:CONFIG_ARM=y
 +S:CONFIG_TARGET_SUN5I=y
configs/A20-OLinuXino_MICRO_defconfig +3 -0
index 20a947c..0e0a7de 100644
@@ -1,5 +1,8 @@
 CONFIG_SPL=y
 CONFIG_SYS_EXTRA_OPTIONS="A20_OLINUXINO_M,AXP209_POWER,SUNXI_GMAC,AHCI,SATAPWR=SUNXI_GPB(8),USB_EHCI"
 CONFIG_FDTFILE="sun7i-a20-olinuxino-micro.dtb"
+CONFIG_MMC_SUNXI_SLOT_EXTRA=3
++S:CONFIG_MMC0_CD_PIN="PH1"
++S:CONFIG_MMC3_CD_PIN="PH11"
 +S:CONFIG_ARM=y
 +S:CONFIG_TARGET_SUN7I=y
configs/Mele_M3_defconfig +2 -0
index 645b236..a043ad2 100644
@@ -1,5 +1,7 @@
 CONFIG_SPL=y
 CONFIG_SYS_EXTRA_OPTIONS="MELE_M3,AXP209_POWER,SUNXI_GMAC,USB_EHCI"
 CONFIG_FDTFILE="sun7i-a20-m3.dtb"
++S:CONFIG_MMC_SUNXI_SLOT_EXTRA=2
++S:CONFIG_MMC0_CD_PIN="PH1"
 +S:CONFIG_ARM=y
 +S:CONFIG_TARGET_SUN7I=y
Signature · 1 line
2.1.0
#13 lore raw

PATCH v2 5/5 sunxi: Enable second sdcard slot found on some boards

Quoted 10 lines · Hans de Goede

Enable the second sdcard slot found on some boards. Note that we do not set CONFIG_MMC_SUNXI_SLOT_EXTRA for the SPL, as having it there is not useful,

Except for on the Mele-M3 where the second sdcard is an eMMC, from which the device can also boot, and there we want to have both in the SPL, so that a single u-boot binary can both from both. So for the M3 we do prefix the defconfig setting with the special "+S:" syntax so that it applies to the SPL too.