sunxi: Enable second sdcard slot found on some boards
Subsystems (3)
v3 cover sunxi: Enable second sdcard slot found on some boards
Hi Ian,
Here is v3 of my second sdcard slot patch-set.
Changes since v2:
- Rebased on top of latest u-boot-sunxi-next
- Fixed Kconfig help text for : "sunxi: Turn MMC_SUNXI_SLOT_EXTRA into a proper Kconfig option" to also mention mmc1
- Added checks for sunxi_mmc_init failing to: "sunxi: When we've both mmc0 and mmc2, detect from which one we're booting"
- Added a 6th patch with my version of the Kconfig unification, to avoid you needing to rebase yours.
I believe this patch is ready to go upstream now, so if I can have your Acked-by for patches 3 and 6, then I'll push this to next, or you can push this to next yourself.
Regards,
Hans
PATCH v3 1/6 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
@@ -41,4 +41,30 @@ config SYS_SOC config FDTFILE string "Default fdtfile env setting for this board" +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
@@ -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;
@@ -346,10 +348,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
@@ -183,6 +183,7 @@/* GPIO */ #define CONFIG_SUNXI_GPIO +#define CONFIG_SPL_GPIO_SUPPORT #define CONFIG_CMD_GPIO /* Ethernet support */
Signature · 1 line
2.1.0
PATCH v3 2/6 sunxi: Turn MMC_SUNXI_SLOT_EXTRA into a proper Kconfig option
In reply to Hans de GoedeNote 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
@@ -67,4 +67,12 @@ config MMC3_CD_PIN ---help--- See MMC0_CD_PIN help text. +config MMC_SUNXI_SLOT_EXTRA + int "mmc extra slot number" + default -1 + ---help--- + sunxi builds always enable mmc0, some boards also have a second sdcard + slot or emmc on mmc1 - mmc3. Setting this to 1, 2 or 3 will enable + support for this. + endif
board/sunxi/board.c +1 -1
@@ -106,7 +106,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
PATCH v3 3/6 sunxi: When we've both mmc0 and mmc2, detect from which one we're booting
In reply to Hans de Goedesunxi 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 | 30 ++++++++++++++++++++++++++++-- drivers/mmc/sunxi_mmc.c | 7 ++----- 3 files changed, 31 insertions(+), 8 deletions(-)
arch/arm/include/asm/arch-sunxi/mmc.h +1 -1
@@ -123,5 +123,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 +28 -2
@@ -12,6 +12,7 @@*/ #include <common.h> +#include <mmc.h> #ifdef CONFIG_AXP152_POWER #include <axp152.h> #endif
@@ -104,11 +105,36 @@ 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 (!mmc0) +return -1 ; +#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 ); +if (!mmc1) +return -1 ; +#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
@@ -373,7 +373,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;
@@ -396,8 +396,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
PATCH v3 3/6 sunxi: When we've both mmc0 and mmc2, detect from which one we're booting
Quoted 9 lines · 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.Signed-off-by Hans de Goede <[email protected]>
PATCH v3 4/6 sunxi: Use PG3 - PG8 as io-pins for mmc1
In reply to Hans de GoedeNone 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
@@ -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
@@ -71,9 +71,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
PATCH v3 5/6 sunxi: Enable second sdcard slot found on some boards
In reply to Hans de GoedeEnable 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
@@ -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
@@ -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
@@ -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
PATCH v3 6/6 sunxi: Kconfig: Unify sunxi Kconfig code
In reply to Hans de GoedeUnify the sunxi Kconfig code, instead of having seperate code blocks for each of sun4i, sun5i and sun7i.
--- board/sunxi/Kconfig | 32 +++++--------------------------- 1 file changed, 5 insertions(+), 27 deletions(-)
board/sunxi/Kconfig +5 -27
@@ -1,33 +1,11 @@ -if TARGET_SUN4I - -config SYS_CONFIG_NAME - default "sun4i" - -endif - -if TARGET_SUN5I - -config SYS_CONFIG_NAME - default "sun5i" - -endif - -if TARGET_SUN6I +if TARGET_SUN4I || TARGET_SUN5I || TARGET_SUN6I || TARGET_SUN7I config SYS_CONFIG_NAME string - default "sun6i" - -endif - -if TARGET_SUN7I - -config SYS_CONFIG_NAME - default "sun7i" - -endif - -if TARGET_SUN4I || TARGET_SUN5I || TARGET_SUN6I || TARGET_SUN7I + default "sun4i" if TARGET_SUN4I + default "sun5i" if TARGET_SUN5I + default "sun6i" if TARGET_SUN5I + default "sun7i" if TARGET_SUN7I config SYS_CPU default "armv7"
Signature · 1 line
2.1.0
PATCH v3 6/6 sunxi: Kconfig: Unify sunxi Kconfig code
Quoted 1 line · Hans de Goede
Unify the sunxi
Kconfigcode, instead of having seperate code blocks for
"separate"
Quoted 3 lines
each of sun4i, sun5i and sun7i.
Signed-off-by Hans de Goede <[email protected]>
Looks pretty familiar ;-)
Quoted 47 lines
--- board/sunxi/Kconfig | 32 +++++--------------------------- 1 file changed, 5 insertions(+), 27 deletions(-)board/sunxi/Kconfig +5
-27@@ -1,33 +1,11 @@ -if TARGET_SUN4I - -config SYS_CONFIG_NAME - default "sun4i" - -endif - -if TARGET_SUN5I - -config SYS_CONFIG_NAME - default "sun5i" - -endif - -if TARGET_SUN6I +if TARGET_SUN4I || TARGET_SUN5I || TARGET_SUN6I || TARGET_SUN7I config SYS_CONFIG_NAME string - default "sun6i" - -endif - -if TARGET_SUN7I - -config SYS_CONFIG_NAME - default "sun7i" - -endif - -if TARGET_SUN4I || TARGET_SUN5I || TARGET_SUN6I || TARGET_SUN7I + default "sun4i" if TARGET_SUN4I + default "sun5i" if TARGET_SUN5I + default "sun6i" if TARGET_SUN5I + default "sun7i" if TARGET_SUN7I config SYS_CPU default "armv7"
PATCH v3 6/6 sunxi: Kconfig: Unify sunxi Kconfig code
Quoted 4 lines · Ian Campbell
board/sunxi/Kconfig line 7
Quoted 4 lines
board/sunxi/Kconfig +3
-1-if TARGET_SUN4I || TARGET_SUN5I || TARGET_SUN6I || TARGET_SUN7I + default "sun4i" if TARGET_SUN4I + default "sun5i" if TARGET_SUN5I + default "sun6i" if TARGET_SUN5I
There is a typo here which is apparent with "MAKEALL -s sunxi", since it causes Colombus_defconfig not to build.
Patch is below but given the breakage is only in u-boot-sunxi.git#next right now I think it would be better to fold it into the original patch.
Ian.
8<----------------------------
PATCH v3 6/6 sunxi: Kconfig: Unify sunxi Kconfig code
Quoted 11 lines · Ian Campbell
Quoted 4 lines · Ian Campbell
board/sunxi/Kconfig line 7
Quoted 4 lines
board/sunxi/Kconfig +3
-1-if TARGET_SUN4I || TARGET_SUN5I || TARGET_SUN6I || TARGET_SUN7I + default "sun4i" if TARGET_SUN4I + default "sun5i" if TARGET_SUN5I + default "sun6i" if TARGET_SUN5IThere is a typo here which is apparent with "MAKEALL -s sunxi", since it causes
Colombus_defconfignot to build.Patch is below but given the breakage is only in u-boot-sunxi.git#next right now I think it would be better to fold it into the original patch.
Yes, fold it in, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20141021/d5698803/attachment.pgp>
PATCH v3 6/6 sunxi: Kconfig: Unify sunxi Kconfig code
In reply to Ian CampbellHi,
Quoted 11 lines · Ian Campbell
Quoted 4 lines · Ian Campbell
board/sunxi/Kconfig line 7
Quoted 4 lines
board/sunxi/Kconfig +3
-1-if TARGET_SUN4I || TARGET_SUN5I || TARGET_SUN6I || TARGET_SUN7I + default "sun4i" if TARGET_SUN4I + default "sun5i" if TARGET_SUN5I + default "sun6i" if TARGET_SUN5IThere is a typo here which is apparent with "MAKEALL -s sunxi", since it causes
Colombus_defconfignot to build.Patch is below but given the breakage is only in u-boot-sunxi.git#next right now I think it would be better to fold it into the original patch.
Good catch thanks, I've squashed this into the original commit and done a forced push to u-boot-sunxi/next with this.
Regards,
Hans
v3 cover sunxi: Enable second sdcard slot found on some boards
In reply to Hans de GoedeQuoted 13 lines · Hans de Goede
Hi Ian,
Here is v3 of my second sdcard slot patch-set.
Changes since v2:
- Rebased on top of latest u-boot-sunxi-next
- FixedKconfighelp text for : "sunxi: TurnMMC_SUNXI_SLOT_EXTRAinto a properKconfigoption" to also mention mmc1
- Added checks forsunxi_mmc_initfailing to: "sunxi: When we've both mmc0 and mmc2, detect from which one we're booting"
- Added a 6th patch with my version of theKconfigunification, to avoid you needing to rebase yours.
Quoted 3 lines
I believe this patch is ready to go upstream now, so if I can have your Acked-by for patches 3 and 6, then I'll push this to next, or you can push this to next yourself.
All Acked. I'm not going to commit tonight and I'm on trains all day tomorrow (heading to D?sseldorf), unless I hear otherwise I'll assume you are doing it.
Ian.
v3 cover sunxi: Enable second sdcard slot found on some boards
Hi,
Quoted 14 lines · Ian Campbell
Quoted 13 lines · Hans de Goede
Hi Ian,
Here is v3 of my second sdcard slot patch-set.
Changes since v2:
- Rebased on top of latest u-boot-sunxi-next
- FixedKconfighelp text for : "sunxi: TurnMMC_SUNXI_SLOT_EXTRAinto a properKconfigoption" to also mention mmc1
- Added checks forsunxi_mmc_initfailing to: "sunxi: When we've both mmc0 and mmc2, detect from which one we're booting"
- Added a 6th patch with my version of theKconfigunification, to avoid you needing to rebase yours.
Quoted 7 lines
Quoted 3 lines
I believe this patch is ready to go upstream now, so if I can have your Acked-by for patches 3 and 6, then I'll push this to next, or you can push this to next yourself.
All Acked. I'm not going to commit tonight and I'm on trains all day tomorrow (heading to D?sseldorf), unless I hear otherwise I'll assume you are doing it.
Done.
And good to hear that you're heading over to Dusseldorf too. I'll be at the u-boot mini-summit the entire day today (currently in the train towards Dusseldorf). We definitely should get together, even if just to say hi :)
Maybe I'll see you at the u-boot mini-summit ? If you cannot make it, maybe you can make the u-boot dinner tonight ? :
http://www.denx.de/wiki/U-Boot/MiniSummitELCE2014
Regards,
Hans
v3 cover sunxi: Enable second sdcard slot found on some boards
Quoted 25 lines · Hans de Goede
Hi,
Quoted 14 lines · Ian Campbell
Quoted 13 lines · Hans de Goede
Hi Ian,
Here is v3 of my second sdcard slot patch-set.
Changes since v2:
- Rebased on top of latest u-boot-sunxi-next
- FixedKconfighelp text for : "sunxi: TurnMMC_SUNXI_SLOT_EXTRAinto a properKconfigoption" to also mention mmc1
- Added checks forsunxi_mmc_initfailing to: "sunxi: When we've both mmc0 and mmc2, detect from which one we're booting"
- Added a 6th patch with my version of theKconfigunification, to avoid you needing to rebase yours.Quoted 7 lines
Quoted 3 lines
I believe this patch is ready to go upstream now, so if I can have your Acked-by for patches 3 and 6, then I'll push this to next, or you can push this to next yourself.
All Acked. I'm not going to commit tonight and I'm on trains all day tomorrow (heading to D?sseldorf), unless I hear otherwise I'll assume you are doing it.
Quoted 5 lines
Done.
And good to hear that you're heading over to Dusseldorf too. I'll be at the u-boot mini-summit the entire day today (currently in the train towards Dusseldorf). We definitely should get together, even if just to say hi :)
Absolutely. I'm in town all week for LPC and plumbers.
Quoted 2 lines
Maybe I'll see you at the u-boot mini-summit ? If you cannot make it, maybe you can make the u-boot dinner tonight ? :
I should be arriving not long after 5, so I think it's doubtful I'll make the mini-summit, with finding my hotel etc. I didn't know about the evening bit, now that I do I'll try and make it down.
Ian.
Quoted 7 lines
http://www.denx.de/wiki/U-Boot/MiniSummitELCE2014
Regards,
Hans