* [U-Boot] [PATCH v2 1/5] sunxi: Add mmc card-detect functionality
2014-10-06 17:57 [U-Boot] [PATCH v2 0/5] sunxi: Enable second sdcard slot found on some boards Hans de Goede
@ 2014-10-06 17:57 ` Hans de Goede
2014-10-11 15:39 ` Ian Campbell
2014-10-06 17:57 ` [U-Boot] [PATCH v2 2/5] sunxi: Turn MMC_SUNXI_SLOT_EXTRA into a proper Kconfig option Hans de Goede
` (3 subsequent siblings)
4 siblings, 1 reply; 14+ messages in thread
From: Hans de Goede @ 2014-10-06 17:57 UTC (permalink / raw)
To: u-boot
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
board/sunxi/Kconfig | 26 ++++++++++++++++++++++++++
drivers/mmc/sunxi_mmc.c | 21 +++++++++++++++++++++
include/configs/sunxi-common.h | 1 +
3 files changed, 48 insertions(+)
diff --git a/board/sunxi/Kconfig b/board/sunxi/Kconfig
index 622f7b4..497b093 100644
--- a/board/sunxi/Kconfig
+++ b/board/sunxi/Kconfig
@@ -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
diff --git a/drivers/mmc/sunxi_mmc.c b/drivers/mmc/sunxi_mmc.c
index bc2c4b3..0ea9f4d 100644
--- a/drivers/mmc/sunxi_mmc.c
+++ b/drivers/mmc/sunxi_mmc.c
@@ -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)
diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h
index af48c97..0ff67ee 100644
--- a/include/configs/sunxi-common.h
+++ b/include/configs/sunxi-common.h
@@ -183,6 +183,7 @@
/* GPIO */
#define CONFIG_SUNXI_GPIO
+#define CONFIG_SPL_GPIO_SUPPORT
#define CONFIG_CMD_GPIO
#ifdef CONFIG_VIDEO
--
2.1.0
^ permalink raw reply related [flat|nested] 14+ messages in thread* [U-Boot] [PATCH v2 1/5] sunxi: Add mmc card-detect functionality
2014-10-06 17:57 ` [U-Boot] [PATCH v2 1/5] sunxi: Add mmc card-detect functionality Hans de Goede
@ 2014-10-11 15:39 ` Ian Campbell
2014-10-12 8:30 ` Hans de Goede
0 siblings, 1 reply; 14+ messages in thread
From: Ian Campbell @ 2014-10-11 15:39 UTC (permalink / raw)
To: u-boot
On Mon, 2014-10-06 at 19:57 +0200, Hans de Goede wrote:
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
I presume that adding GPIO support to SPL isn't a problem size wise?
> ---
> board/sunxi/Kconfig | 26 ++++++++++++++++++++++++++
> drivers/mmc/sunxi_mmc.c | 21 +++++++++++++++++++++
> include/configs/sunxi-common.h | 1 +
> 3 files changed, 48 insertions(+)
>
> diff --git a/board/sunxi/Kconfig b/board/sunxi/Kconfig
> index 622f7b4..497b093 100644
> --- a/board/sunxi/Kconfig
> +++ b/board/sunxi/Kconfig
> @@ -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 <ijc@hellion.org.uk>
Ian.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [U-Boot] [PATCH v2 1/5] sunxi: Add mmc card-detect functionality
2014-10-11 15:39 ` Ian Campbell
@ 2014-10-12 8:30 ` Hans de Goede
0 siblings, 0 replies; 14+ messages in thread
From: Hans de Goede @ 2014-10-12 8:30 UTC (permalink / raw)
To: u-boot
Hi,
On 10/11/2014 05:39 PM, Ian Campbell wrote:
> On Mon, 2014-10-06 at 19:57 +0200, Hans de Goede wrote:
>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
>
> 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.
>> ---
>> board/sunxi/Kconfig | 26 ++++++++++++++++++++++++++
>> drivers/mmc/sunxi_mmc.c | 21 +++++++++++++++++++++
>> include/configs/sunxi-common.h | 1 +
>> 3 files changed, 48 insertions(+)
>>
>> diff --git a/board/sunxi/Kconfig b/board/sunxi/Kconfig
>> index 622f7b4..497b093 100644
>> --- a/board/sunxi/Kconfig
>> +++ b/board/sunxi/Kconfig
>> @@ -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?
Yes I checked, it will return -1 on the empty string.
> Assuming you have then: Acked-by: Ian Campbell <ijc@hellion.org.uk>
Regards,
Hans
^ permalink raw reply [flat|nested] 14+ messages in thread
* [U-Boot] [PATCH v2 2/5] sunxi: Turn MMC_SUNXI_SLOT_EXTRA into a proper Kconfig option
2014-10-06 17:57 [U-Boot] [PATCH v2 0/5] sunxi: Enable second sdcard slot found on some boards Hans de Goede
2014-10-06 17:57 ` [U-Boot] [PATCH v2 1/5] sunxi: Add mmc card-detect functionality Hans de Goede
@ 2014-10-06 17:57 ` Hans de Goede
2014-10-11 15:40 ` Ian Campbell
2014-10-06 17:57 ` [U-Boot] [PATCH v2 3/5] sunxi: When we've both mmc0 and mmc2, detect from which one we're booting Hans de Goede
` (2 subsequent siblings)
4 siblings, 1 reply; 14+ messages in thread
From: Hans de Goede @ 2014-10-06 17:57 UTC (permalink / raw)
To: u-boot
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.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
board/sunxi/Kconfig | 8 ++++++++
board/sunxi/board.c | 2 +-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/board/sunxi/Kconfig b/board/sunxi/Kconfig
index 497b093..cb4a881 100644
--- a/board/sunxi/Kconfig
+++ b/board/sunxi/Kconfig
@@ -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 ""
diff --git a/board/sunxi/board.c b/board/sunxi/board.c
index e819b12..4d602ca 100644
--- a/board/sunxi/board.c
+++ b/board/sunxi/board.c
@@ -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
--
2.1.0
^ permalink raw reply related [flat|nested] 14+ messages in thread* [U-Boot] [PATCH v2 2/5] sunxi: Turn MMC_SUNXI_SLOT_EXTRA into a proper Kconfig option
2014-10-06 17:57 ` [U-Boot] [PATCH v2 2/5] sunxi: Turn MMC_SUNXI_SLOT_EXTRA into a proper Kconfig option Hans de Goede
@ 2014-10-11 15:40 ` Ian Campbell
2014-10-12 8:32 ` Hans de Goede
0 siblings, 1 reply; 14+ messages in thread
From: Ian Campbell @ 2014-10-11 15:40 UTC (permalink / raw)
To: u-boot
On Mon, 2014-10-06 at 19:57 +0200, Hans de Goede wrote:
> 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.
>
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
> board/sunxi/Kconfig | 8 ++++++++
> board/sunxi/board.c | 2 +-
> 2 files changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/board/sunxi/Kconfig b/board/sunxi/Kconfig
> index 497b093..cb4a881 100644
> --- a/board/sunxi/Kconfig
> +++ b/board/sunxi/Kconfig
> @@ -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:
Acked-by: Ian Campbell <ijc@hellion.org.uk>
^ permalink raw reply [flat|nested] 14+ messages in thread
* [U-Boot] [PATCH v2 2/5] sunxi: Turn MMC_SUNXI_SLOT_EXTRA into a proper Kconfig option
2014-10-11 15:40 ` Ian Campbell
@ 2014-10-12 8:32 ` Hans de Goede
0 siblings, 0 replies; 14+ messages in thread
From: Hans de Goede @ 2014-10-12 8:32 UTC (permalink / raw)
To: u-boot
Hi,
On 10/11/2014 05:40 PM, Ian Campbell wrote:
> On Mon, 2014-10-06 at 19:57 +0200, Hans de Goede wrote:
>> 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.
>>
>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
>> ---
>> board/sunxi/Kconfig | 8 ++++++++
>> board/sunxi/board.c | 2 +-
>> 2 files changed, 9 insertions(+), 1 deletion(-)
>>
>> diff --git a/board/sunxi/Kconfig b/board/sunxi/Kconfig
>> index 497b093..cb4a881 100644
>> --- a/board/sunxi/Kconfig
>> +++ b/board/sunxi/Kconfig
>> @@ -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?
When writing this I was under the assumption that nothing was actually using
mmc1, I will fix the help text.
>
> Regardless:
>
> Acked-by: Ian Campbell <ijc@hellion.org.uk>
Regards,
Hans
^ permalink raw reply [flat|nested] 14+ messages in thread
* [U-Boot] [PATCH v2 3/5] sunxi: When we've both mmc0 and mmc2, detect from which one we're booting
2014-10-06 17:57 [U-Boot] [PATCH v2 0/5] sunxi: Enable second sdcard slot found on some boards Hans de Goede
2014-10-06 17:57 ` [U-Boot] [PATCH v2 1/5] sunxi: Add mmc card-detect functionality Hans de Goede
2014-10-06 17:57 ` [U-Boot] [PATCH v2 2/5] sunxi: Turn MMC_SUNXI_SLOT_EXTRA into a proper Kconfig option Hans de Goede
@ 2014-10-06 17:57 ` Hans de Goede
2014-10-11 15:43 ` Ian Campbell
2014-10-06 17:57 ` [U-Boot] [PATCH v2 4/5] sunxi: Use PG3 - PG8 as io-pins for mmc1 Hans de Goede
2014-10-06 17:57 ` [U-Boot] [PATCH v2 5/5] sunxi: Enable second sdcard slot found on some boards Hans de Goede
4 siblings, 1 reply; 14+ messages in thread
From: Hans de Goede @ 2014-10-06 17:57 UTC (permalink / raw)
To: u-boot
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.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
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(-)
diff --git a/arch/arm/include/asm/arch-sunxi/mmc.h b/arch/arm/include/asm/arch-sunxi/mmc.h
index 53196e3..ff2602d 100644
--- a/arch/arm/include/asm/arch-sunxi/mmc.h
+++ b/arch/arm/include/asm/arch-sunxi/mmc.h
@@ -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 */
diff --git a/board/sunxi/board.c b/board/sunxi/board.c
index 4d602ca..0a7be31 100644
--- a/board/sunxi/board.c
+++ b/board/sunxi/board.c
@@ -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;
diff --git a/drivers/mmc/sunxi_mmc.c b/drivers/mmc/sunxi_mmc.c
index 0ea9f4d..7526540 100644
--- a/drivers/mmc/sunxi_mmc.c
+++ b/drivers/mmc/sunxi_mmc.c
@@ -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]);
}
--
2.1.0
^ permalink raw reply related [flat|nested] 14+ messages in thread* [U-Boot] [PATCH v2 3/5] sunxi: When we've both mmc0 and mmc2, detect from which one we're booting
2014-10-06 17:57 ` [U-Boot] [PATCH v2 3/5] sunxi: When we've both mmc0 and mmc2, detect from which one we're booting Hans de Goede
@ 2014-10-11 15:43 ` Ian Campbell
2014-10-12 9:20 ` Hans de Goede
0 siblings, 1 reply; 14+ messages in thread
From: Ian Campbell @ 2014-10-11 15:43 UTC (permalink / raw)
To: u-boot
On Mon, 2014-10-06 at 19:57 +0200, Hans de Goede wrote:
> @@ -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 &&
If sunxi_mmx_init failed then mmc0 might be NULL here.
> + 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.
^ permalink raw reply [flat|nested] 14+ messages in thread* [U-Boot] [PATCH v2 3/5] sunxi: When we've both mmc0 and mmc2, detect from which one we're booting
2014-10-11 15:43 ` Ian Campbell
@ 2014-10-12 9:20 ` Hans de Goede
0 siblings, 0 replies; 14+ messages in thread
From: Hans de Goede @ 2014-10-12 9:20 UTC (permalink / raw)
To: u-boot
Hi,
On 10/11/2014 05:43 PM, Ian Campbell wrote:
> On Mon, 2014-10-06 at 19:57 +0200, Hans de Goede wrote:
>> @@ -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 &&
>
> If sunxi_mmx_init failed then mmc0 might be NULL here.
>
>> + 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
>
> Ian.
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* [U-Boot] [PATCH v2 4/5] sunxi: Use PG3 - PG8 as io-pins for mmc1
2014-10-06 17:57 [U-Boot] [PATCH v2 0/5] sunxi: Enable second sdcard slot found on some boards Hans de Goede
` (2 preceding siblings ...)
2014-10-06 17:57 ` [U-Boot] [PATCH v2 3/5] sunxi: When we've both mmc0 and mmc2, detect from which one we're booting Hans de Goede
@ 2014-10-06 17:57 ` Hans de Goede
2014-10-11 15:44 ` Ian Campbell
2014-10-06 17:57 ` [U-Boot] [PATCH v2 5/5] sunxi: Enable second sdcard slot found on some boards Hans de Goede
4 siblings, 1 reply; 14+ messages in thread
From: Hans de Goede @ 2014-10-06 17:57 UTC (permalink / raw)
To: u-boot
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.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
arch/arm/include/asm/arch-sunxi/gpio.h | 2 ++
board/sunxi/board.c | 6 +++---
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/arch/arm/include/asm/arch-sunxi/gpio.h b/arch/arm/include/asm/arch-sunxi/gpio.h
index f7f3d8c..3f46f78 100644
--- a/arch/arm/include/asm/arch-sunxi/gpio.h
+++ b/arch/arm/include/asm/arch-sunxi/gpio.h
@@ -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
diff --git a/board/sunxi/board.c b/board/sunxi/board.c
index 0a7be31..23f8887 100644
--- a/board/sunxi/board.c
+++ b/board/sunxi/board.c
@@ -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);
}
--
2.1.0
^ permalink raw reply related [flat|nested] 14+ messages in thread* [U-Boot] [PATCH v2 4/5] sunxi: Use PG3 - PG8 as io-pins for mmc1
2014-10-06 17:57 ` [U-Boot] [PATCH v2 4/5] sunxi: Use PG3 - PG8 as io-pins for mmc1 Hans de Goede
@ 2014-10-11 15:44 ` Ian Campbell
0 siblings, 0 replies; 14+ messages in thread
From: Ian Campbell @ 2014-10-11 15:44 UTC (permalink / raw)
To: u-boot
On Mon, 2014-10-06 at 19:57 +0200, Hans de Goede wrote:
> 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.
>
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Ian Campbell <ijc@hellion.org.uk>
(right address this time ;-))
> ---
> arch/arm/include/asm/arch-sunxi/gpio.h | 2 ++
> board/sunxi/board.c | 6 +++---
> 2 files changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/arch/arm/include/asm/arch-sunxi/gpio.h b/arch/arm/include/asm/arch-sunxi/gpio.h
> index f7f3d8c..3f46f78 100644
> --- a/arch/arm/include/asm/arch-sunxi/gpio.h
> +++ b/arch/arm/include/asm/arch-sunxi/gpio.h
> @@ -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
>
> diff --git a/board/sunxi/board.c b/board/sunxi/board.c
> index 0a7be31..23f8887 100644
> --- a/board/sunxi/board.c
> +++ b/board/sunxi/board.c
> @@ -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);
> }
^ permalink raw reply [flat|nested] 14+ messages in thread
* [U-Boot] [PATCH v2 5/5] sunxi: Enable second sdcard slot found on some boards
2014-10-06 17:57 [U-Boot] [PATCH v2 0/5] sunxi: Enable second sdcard slot found on some boards Hans de Goede
` (3 preceding siblings ...)
2014-10-06 17:57 ` [U-Boot] [PATCH v2 4/5] sunxi: Use PG3 - PG8 as io-pins for mmc1 Hans de Goede
@ 2014-10-06 17:57 ` Hans de Goede
2014-10-11 15:47 ` Ian Campbell
4 siblings, 1 reply; 14+ messages in thread
From: Hans de Goede @ 2014-10-06 17:57 UTC (permalink / raw)
To: u-boot
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.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
configs/A10s-OLinuXino-M_defconfig | 3 +++
configs/A20-OLinuXino_MICRO_defconfig | 3 +++
configs/Mele_M3_defconfig | 2 ++
3 files changed, 8 insertions(+)
diff --git a/configs/A10s-OLinuXino-M_defconfig b/configs/A10s-OLinuXino-M_defconfig
index a578c06..2aad834 100644
--- a/configs/A10s-OLinuXino-M_defconfig
+++ b/configs/A10s-OLinuXino-M_defconfig
@@ -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
diff --git a/configs/A20-OLinuXino_MICRO_defconfig b/configs/A20-OLinuXino_MICRO_defconfig
index 20a947c..0e0a7de 100644
--- a/configs/A20-OLinuXino_MICRO_defconfig
+++ b/configs/A20-OLinuXino_MICRO_defconfig
@@ -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
diff --git a/configs/Mele_M3_defconfig b/configs/Mele_M3_defconfig
index 645b236..a043ad2 100644
--- a/configs/Mele_M3_defconfig
+++ b/configs/Mele_M3_defconfig
@@ -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
--
2.1.0
^ permalink raw reply related [flat|nested] 14+ messages in thread* [U-Boot] [PATCH v2 5/5] sunxi: Enable second sdcard slot found on some boards
2014-10-06 17:57 ` [U-Boot] [PATCH v2 5/5] sunxi: Enable second sdcard slot found on some boards Hans de Goede
@ 2014-10-11 15:47 ` Ian Campbell
0 siblings, 0 replies; 14+ messages in thread
From: Ian Campbell @ 2014-10-11 15:47 UTC (permalink / raw)
To: u-boot
On Mon, 2014-10-06 at 19:57 +0200, Hans de Goede wrote:
> 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.
>
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Ian Campbell <ijc@hellion.org.uk>
^ permalink raw reply [flat|nested] 14+ messages in thread