From 0ed232b15386616d186b67a3689e149581dcf2b7 Mon Sep 17 00:00:00 2001 From: Patrick Delaunay Date: Tue, 20 Mar 2018 10:54:52 +0100 Subject: [PATCH] stm32mp1: add eMMC support for ED1 Add command GPT support Add EMMC boot support Add the 2 other SDMMC instances for ED1: - SDMMC2 = mmc 1, eMMC on the ED1 board - SDMMC3 = extension connector, deactivated by default Signed-off-by: Patrick Delaunay --- arch/arm/dts/stm32mp157.dtsi | 28 +++++++++++ arch/arm/dts/stm32mp157c-ed1-u-boot.dtsi | 21 ++++++++ arch/arm/dts/stm32mp157c-ed1.dts | 37 ++++++++++++++ board/st/stm32mp1/README | 83 +++++++++++++++++++++++--------- configs/stm32mp15_basic_defconfig | 1 + include/configs/stm32mp1.h | 1 + 6 files changed, 147 insertions(+), 24 deletions(-) diff --git a/arch/arm/dts/stm32mp157.dtsi b/arch/arm/dts/stm32mp157.dtsi index 32d3984..77953c8 100644 --- a/arch/arm/dts/stm32mp157.dtsi +++ b/arch/arm/dts/stm32mp157.dtsi @@ -86,6 +86,20 @@ status = "disabled"; }; + sdmmc3: sdmmc@48004000 { + compatible = "st,stm32-sdmmc2"; + reg = <0x48004000 0x400>, <0x48005000 0x400>; + reg-names = "sdmmc", "delay"; + interrupts = ; + clocks = <&rcc_clk SDMMC3_K>; + resets = <&rcc_rst SDMMC3_R>; + st,idma = <1>; + cap-sd-highspeed; + cap-mmc-highspeed; + max-frequency = <120000000>; + status = "disabled"; + }; + rcc: rcc@50000000 { compatible = "syscon", "simple-mfd"; @@ -288,6 +302,20 @@ status = "disabled"; }; + sdmmc2: sdmmc@58007000 { + compatible = "st,stm32-sdmmc2"; + reg = <0x58007000 0x1000>, <0x58008000 0x1000>; + reg-names = "sdmmc", "delay"; + interrupts = ; + clocks = <&rcc_clk SDMMC2_K>; + resets = <&rcc_rst SDMMC2_R>; + st,idma = <1>; + cap-sd-highspeed; + cap-mmc-highspeed; + max-frequency = <120000000>; + status = "disabled"; + }; + i2c4: i2c@5c002000 { compatible = "st,stm32f7-i2c"; reg = <0x5c002000 0x400>; diff --git a/arch/arm/dts/stm32mp157c-ed1-u-boot.dtsi b/arch/arm/dts/stm32mp157c-ed1-u-boot.dtsi index 94d27fb..5d43753 100644 --- a/arch/arm/dts/stm32mp157c-ed1-u-boot.dtsi +++ b/arch/arm/dts/stm32mp157c-ed1-u-boot.dtsi @@ -11,6 +11,7 @@ / { aliases { mmc0 = &sdmmc1; + mmc1 = &sdmmc2; i2c3 = &i2c4; }; }; @@ -77,6 +78,7 @@ CLK_SDMMC12_PLL3R CLK_I2C46_PCLK5 CLK_I2C12_PCLK1 + CLK_SDMMC3_PLL3R CLK_I2C35_PCLK1 CLK_UART1_PCLK5 CLK_UART24_PCLK1 @@ -131,3 +133,22 @@ &sdmmc1 { u-boot,dm-spl; }; + +/* MMC2 boot */ +&sdmmc2_b4_pins_a { + u-boot,dm-spl; + pins { + u-boot,dm-spl; + }; +}; + +&sdmmc2_d47_pins_a { + u-boot,dm-spl; + pins { + u-boot,dm-spl; + }; +}; + +&sdmmc2 { + u-boot,dm-spl; +}; diff --git a/arch/arm/dts/stm32mp157c-ed1.dts b/arch/arm/dts/stm32mp157c-ed1.dts index 4b20fab..129cd02 100644 --- a/arch/arm/dts/stm32mp157c-ed1.dts +++ b/arch/arm/dts/stm32mp157c-ed1.dts @@ -112,6 +112,31 @@ bias-pull-up; }; }; + sdmmc2_b4_pins_a: sdmmc2-b4@0 { + pins { + pinmux = , /* SDMMC2_D0 */ + , /* SDMMC2_D1 */ + , /* SDMMC2_D2 */ + , /* SDMMC2_D3 */ + , /* SDMMC2_CK */ + ; /* SDMMC2_CMD */ + slew-rate = <3>; + drive-push-pull; + bias-pull-up; + }; + }; + + sdmmc2_d47_pins_a: sdmmc2-d47@0 { + pins { + pinmux = , /* SDMMC2_D4 */ + , /* SDMMC2_D5 */ + , /* SDMMC2_D6 */ + ; /* SDMMC2_D7 */ + slew-rate = <3>; + drive-push-pull; + bias-pull-up; + }; + }; }; &pinctrl_z { @@ -160,6 +185,18 @@ status = "okay"; }; +&sdmmc2 { + pinctrl-names = "default"; + pinctrl-0 = <&sdmmc2_b4_pins_a &sdmmc2_d47_pins_a>; + non-removable; + no-sd; + no-sdio; + st,dirpol; + st,negedge; + bus-width = <8>; + status = "okay"; +}; + &uart4 { pinctrl-names = "default"; pinctrl-0 = <&uart4_pins_a>; diff --git a/board/st/stm32mp1/README b/board/st/stm32mp1/README index 4adc978..42a39d0 100644 --- a/board/st/stm32mp1/README +++ b/board/st/stm32mp1/README @@ -115,7 +115,31 @@ the supported device trees for stm32mp157 are: + FSBL = spl/u-boot-spl.stm32 + SSBL = u-boot.img -6. Prepare an SDCard +6. Switch Setting for Boot Mode +=============================== + +You can select the boot mode, on the board ed1 with the switch SW1 + + ----------------------------------- + Boot Mode BOOT2 BOOT1 BOOT0 + ----------------------------------- + Reserved 0 0 0 + NOR 0 0 1 + SD-Card 1 1 1 + SD-Card 1 0 1 + eMMC 0 1 0 + NAND 0 1 1 + Recovery 1 1 0 + Recovery 0 0 0 + +Recovery is a boot from serial link (UART/USB) and it is used with +STM32CubeProgrammer tool to load executable in RAM and to update the flash +devices available on the board (NOR/NAND/eMMC/SDCARD). +The communication between HOST and board is based on +- for UARTs : the uart protocol used with all MCU STM32 +- for USB : based on USB DFU 1.1 (without the ST extensions used on MCU STM32) + +7. Prepare an SDCard =================== The minimal requirements for STMP32MP1 boot up to U-Boot are: @@ -147,13 +171,13 @@ for example: with gpt table with 128 entries # sgdisk -o /dev/ b) create minimal image - # sgdisk --resize-table=128 -a 1 \ + # sgdisk --resize-table=128 -a 1 \ -n 1:34:545 -c 1:fsbl1 \ -n 2:546:1057 -c 2:fsbl2 \ -n 3:1058:5153 -c 3:ssbl \ -p /dev/ - you can add other partition for kernel (rootfs) + you can add other partition for kernel (rootfs for example) c) copy the FSBL (2 times) and SSBL file on the correct partition. in this example in partition 1 to 3 @@ -163,29 +187,40 @@ for example: with gpt table with 128 entries # dd if=u-boot-spl.stm32 of=/dev/mmcblk0p2 # dd if=u-boot.img of=/dev/mmcblk0p3 -7. Switch Setting -================== - -You can select the boot mode, on the board ed1 with the switch SW1 +To boot from SDCard, select BootPinMode = 1 1 1 and reset. - ----------------------------------- - Boot Mode BOOT2 BOOT1 BOOT0 - ----------------------------------- - Reserved 0 0 0 - NOR 0 0 1 - SD-Card 1 1 1 - SD-Card 1 0 1 - eMMC 0 1 0 - NAND 0 1 1 - Recovery 1 1 0 - Recovery 0 0 0 +8. Prepare eMMC +=============== +You can use U-Boot to copy binary in eMMC. +In the next example, you need to boot from SDCARD and the images (u-boot-spl.stm32, u-boot.img) +are presents on SDCARD (mmc 0) in ext4 partition 4 (bootfs). To boot from SDCard, select BootPinMode = 1 1 1 and reset. -Recovery is a boot from serial link (UART/USB) and it is used with -STM32CubeProgrammer tool to load executable in RAM and to update the flash -devices available on the board (NOR/NAND/eMMC/SDCARD). -The communication between HOST and board is based on -- for UARTs : the uart protocol used with all MCU STM32 -- for USB : based on USB DFU 1.1 (without the ST extensions used on MCU STM32) +Then you update the eMMC with the next U-Boot command : + +a) prepare GPT on eMMC, + example with 2 partitions, bootfs and roots: + + # setenv emmc_part "name=ssbl,size=2MiB;name=bootfs,type=linux,bootable,size=64MiB;name=rootfs,type=linux,size=512" + # gpt write mmc 1 ${emmc_part} + +b) copy SPL on eMMC on firts boot partition + (SPL max size is 256kB, with LBA 512, 0x200) + + # ext4load mmc 0:4 0xC0000000 u-boot-spl.stm32 + # mmc dev 1 + # mmc partconf 1 1 1 1 + # mmc write ${fileaddr} 0 200 + # mmc partconf 1 1 1 0 + +b) copy U-Boot in first GPT partition of eMMC + + # ext4load mmc 0:4 0xC0000000 u-boot.img + # mmc dev 1 + # part start mmc 1 1 partstart + # part size mmc 1 1 partsize + # mmc write ${fileaddr} ${partstart} ${partsize} + +To boot from eMMC, select BootPinMode = 0 1 0 and reset. diff --git a/configs/stm32mp15_basic_defconfig b/configs/stm32mp15_basic_defconfig index 4ab1d4c..0f5950f 100644 --- a/configs/stm32mp15_basic_defconfig +++ b/configs/stm32mp15_basic_defconfig @@ -19,6 +19,7 @@ CONFIG_SYS_PROMPT="STM32MP> " # CONFIG_CMD_IMPORTENV is not set CONFIG_CMD_MEMINFO=y CONFIG_CMD_GPIO=y +CONFIG_CMD_GPT=y CONFIG_CMD_I2C=y CONFIG_CMD_MMC=y CONFIG_CMD_PMIC=y diff --git a/include/configs/stm32mp1.h b/include/configs/stm32mp1.h index aae2cb8..6281dd5 100644 --- a/include/configs/stm32mp1.h +++ b/include/configs/stm32mp1.h @@ -71,6 +71,7 @@ /*MMC SD*/ #define CONFIG_SYS_MMC_MAX_DEVICE 3 +#define CONFIG_SUPPORT_EMMC_BOOT #if !defined(CONFIG_SPL) || !defined(CONFIG_SPL_BUILD)