diff options
author | Patrick Delaunay <patrick.delaunay@st.com> | 2018-03-12 10:46:18 +0100 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2018-03-19 16:14:22 -0400 |
commit | f8598d9815c7f89aed28e3f880b489260bd50a49 (patch) | |
tree | 2a2bb5b046cab4532908d2585a31db61dbe624d4 /board | |
parent | 3d2d115a30e870b0ce7adfe1a6d8bdf73a016571 (diff) | |
download | u-boot-f8598d9815c7f89aed28e3f880b489260bd50a49.tar.gz |
board: st: add generic board for STM32MP1 family
Add first support for STM32MP157C-ED1 board with "Basic" boot chain
1/ Boot Rom: load SPL with STM32 image header in SYSRAM
2/ SPL: power up and initialize the DDR and load U-Boot image
from SDCARD in DDR
3/ U-Boot: search and load extlinux.conf in SDCARD
(DISTRO activated)
Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Diffstat (limited to 'board')
-rw-r--r-- | board/st/stm32mp1/Kconfig | 12 | ||||
-rw-r--r-- | board/st/stm32mp1/MAINTAINERS | 7 | ||||
-rw-r--r-- | board/st/stm32mp1/Makefile | 13 | ||||
-rw-r--r-- | board/st/stm32mp1/README | 191 | ||||
-rw-r--r-- | board/st/stm32mp1/board.c | 75 | ||||
-rw-r--r-- | board/st/stm32mp1/spl.c | 33 | ||||
-rw-r--r-- | board/st/stm32mp1/stm32mp1.c | 27 |
7 files changed, 358 insertions, 0 deletions
diff --git a/board/st/stm32mp1/Kconfig b/board/st/stm32mp1/Kconfig new file mode 100644 index 0000000000..5ab94151a9 --- /dev/null +++ b/board/st/stm32mp1/Kconfig @@ -0,0 +1,12 @@ +if TARGET_STM32MP1 + +config SYS_BOARD + default "stm32mp1" + +config SYS_VENDOR + default "st" + +config SYS_CONFIG_NAME + default "stm32mp1" + +endif diff --git a/board/st/stm32mp1/MAINTAINERS b/board/st/stm32mp1/MAINTAINERS new file mode 100644 index 0000000000..65266bce3f --- /dev/null +++ b/board/st/stm32mp1/MAINTAINERS @@ -0,0 +1,7 @@ +STM32MP1 BOARD +M: Patrick Delaunay <patrick.delaunay@st.com> +S: Maintained +F: board/st/stm32mp1 +F: include/configs/stm32mp1.h +F: configs/stm32mp15_basic_defconfig +F: arch/arm/dts/stm32mp157* diff --git a/board/st/stm32mp1/Makefile b/board/st/stm32mp1/Makefile new file mode 100644 index 0000000000..eaf45b7787 --- /dev/null +++ b/board/st/stm32mp1/Makefile @@ -0,0 +1,13 @@ +# +# Copyright (C) 2018, STMicroelectronics - All Rights Reserved +# +# SPDX-License-Identifier: GPL-2.0+ BSD-3-Clause +# + +ifdef CONFIG_SPL_BUILD +obj-y += spl.o +else +obj-y += stm32mp1.o +endif + +obj-y += board.o diff --git a/board/st/stm32mp1/README b/board/st/stm32mp1/README new file mode 100644 index 0000000000..4adc978d1e --- /dev/null +++ b/board/st/stm32mp1/README @@ -0,0 +1,191 @@ +# +# Copyright (C) 2018 STMicroelectronics - All Rights Reserved +# +# SPDX-License-Identifier: GPL-2.0+ BSD-3-Clause +# + +U-Boot on STMicroelectronics STM32MP1 +====================================== + +1. Summary +========== +This is a quick instruction for setup stm32mp1 boards. + +2. Supported devices +==================== +U-Boot supports one STMP32MP1 SoCs: STM32MP157 + +The STM32MP157 is a Cortex-A MPU aimed at various applications. +It features: +- Dual core Cortex-A7 application core +- 2D/3D image composition with GPU +- Standard memories interface support +- Standard connectivity, widely inherited from the STM32 MCU family +- Comprehensive security support + +Everything is supported in Linux but U-Boot is limited to: +1. UART +2. SDCard/MMC controller (SDMMC) + +And the necessary drivers +1. I2C +2. STPMU1 +3. Clock, Reset + +Currently the following boards are supported: ++ stm32mp157c-ed1 + +3. Boot Sequences +================= + +BootRom => FSBL in SYSRAM => SSBL in DDR => OS (Linux Kernel) + +with FSBL = First Stage Bootloader + SSBL = Second Stage Bootloader + +One boot configuration is supported: + + The "Basic" boot chain (defconfig_file : stm32mp15_basic_defconfig) + BootRom => FSBL = U-Boot SPL => SSBL = U-Boot + SPL has limited security initialisation + U-Boot is running in secure mode and provide a secure monitor to the kernel + with only PSCI support (Power State Coordination Interface defined by ARM) + +All the STM32MP1 board supported by U-Boot use the same generic board +stm32mp1 which support all the bootable devices. + +Each board is configurated only with the associated device tree. + +4. Device Tree Selection +======================== + +You need to select the appropriate device tree for your board, +the supported device trees for stm32mp157 are: + ++ ed1: daughter board with pmic stpmu1 + dts: stm32mp157c-ed1 + +5. Build Procedure +================== + +1. Install required tools for U-Boot + + + install package needed in U-Boot makefile + (libssl-dev, swig, libpython-dev...) + + install ARMv7 toolchain for 32bit Cortex-A (from Linaro, + from SDK for STM32MP1, or any crosstoolchains from your distribution) + +2. Set the cross compiler: + + # export CROSS_COMPILE=/path/to/toolchain/arm-linux-gnueabi- + (you can use any gcc cross compiler compatible with U-Boot) + +3. Select the output directory (optional) + + # export KBUILD_OUTPUT=/path/to/output + + for example: use one output directory for each configuration + # export KBUILD_OUTPUT=stm32mp15_basic + +4. Configure the U-Boot: + + # make <defconfig_file> + + - For basic boot mode: "stm32mp15_basic_defconfig" + +5. Configure the device-tree and build the U-Boot image: + + # make DEVICE_TREE=<name> all + + + example: + basic boot on ed1 + # export KBUILD_OUTPUT=stm32mp15_basic + # make stm32mp15_basic_defconfig + # make DEVICE_TREE=stm32mp157c-ed1 all + +6. Output files + + BootRom and ATF expect binaries with STM32 image header + SPL expects file with U-Boot uImage header + + So in the output directory (selected by KBUILD_OUTPUT), + you can found the needed files: + + + FSBL = spl/u-boot-spl.stm32 + + SSBL = u-boot.img + +6. Prepare an SDCard +=================== + +The minimal requirements for STMP32MP1 boot up to U-Boot are: +- GPT partitioning (with gdisk or with sgdisk) +- 2 fsbl partitions, named fsbl1 and fsbl2, size at least 256KiB +- one ssbl partition for U-Boot + +Then the minimal GPT partition is: + ----- ------- --------- ------------- + | Num | Name | Size | Content | + ----- ------- -------- -------------- + | 1 | fsbl1 | 256 KiB | ATF or SPL | + | 2 | fsbl2 | 256 KiB | ATF or SPL | + | 3 | ssbl | enought | U-Boot | + | * | - | - | Boot/Rootfs| + ----- ------- --------- ------------- + +(*) add bootable partition for extlinux.conf + following Generic Distribution + (doc/README.distro for use) + + according the used card reader select the block device + (/dev/sdx or /dev/mmcblk0) + in the next example I use /dev/mmcblk0 + +for example: with gpt table with 128 entries + + a) remove previous formatting + # sgdisk -o /dev/<SDCard dev> + + b) create minimal image + # 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/<SDCard dev> + + you can add other partition for kernel (rootfs) + + c) copy the FSBL (2 times) and SSBL file on the correct partition. + in this example in partition 1 to 3 + + for basic boot mode : <SDCard dev> = /dev/mmcblk0 + # dd if=u-boot-spl.stm32 of=/dev/mmcblk0p1 + # 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 + + ----------------------------------- + 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 + + +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) diff --git a/board/st/stm32mp1/board.c b/board/st/stm32mp1/board.c new file mode 100644 index 0000000000..03f900a365 --- /dev/null +++ b/board/st/stm32mp1/board.c @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2018, STMicroelectronics - All Rights Reserved + * + * SPDX-License-Identifier: GPL-2.0+ BSD-3-Clause + */ + +#include <common.h> +#include <dm.h> +#include <asm/io.h> +#include <asm/arch/ddr.h> +#include <power/pmic.h> +#include <power/stpmu1.h> + +#ifdef CONFIG_PMIC_STPMU1 +int board_ddr_power_init(void) +{ + struct udevice *dev; + int ret; + + ret = uclass_get_device_by_driver(UCLASS_PMIC, + DM_GET_DRIVER(pmic_stpmu1), &dev); + if (ret) + /* No PMIC on board */ + return 0; + + /* Set LDO3 to sync mode */ + ret = pmic_reg_read(dev, STPMU1_LDOX_CTRL_REG(STPMU1_LDO3)); + if (ret < 0) + return ret; + + ret &= ~STPMU1_LDO3_MODE; + ret &= ~STPMU1_LDO12356_OUTPUT_MASK; + ret |= STPMU1_LDO3_DDR_SEL << STPMU1_LDO12356_OUTPUT_SHIFT; + + ret = pmic_reg_write(dev, STPMU1_LDOX_CTRL_REG(STPMU1_LDO3), + ret); + if (ret < 0) + return ret; + + /* Set BUCK2 to 1.35V */ + ret = pmic_clrsetbits(dev, + STPMU1_BUCKX_CTRL_REG(STPMU1_BUCK2), + STPMU1_BUCK_OUTPUT_MASK, + STPMU1_BUCK2_1350000V); + if (ret < 0) + return ret; + + /* Enable BUCK2 and VREF */ + ret = pmic_clrsetbits(dev, + STPMU1_BUCKX_CTRL_REG(STPMU1_BUCK2), + STPMU1_BUCK_EN, STPMU1_BUCK_EN); + if (ret < 0) + return ret; + + mdelay(STPMU1_DEFAULT_START_UP_DELAY_MS); + + ret = pmic_clrsetbits(dev, STPMU1_VREF_CTRL_REG, + STPMU1_VREF_EN, STPMU1_VREF_EN); + if (ret < 0) + return ret; + + mdelay(STPMU1_DEFAULT_START_UP_DELAY_MS); + + /* Enable LDO3 */ + ret = pmic_clrsetbits(dev, + STPMU1_LDOX_CTRL_REG(STPMU1_LDO3), + STPMU1_LDO_EN, STPMU1_LDO_EN); + if (ret < 0) + return ret; + + mdelay(STPMU1_DEFAULT_START_UP_DELAY_MS); + + return 0; +} +#endif diff --git a/board/st/stm32mp1/spl.c b/board/st/stm32mp1/spl.c new file mode 100644 index 0000000000..b7e5f247e7 --- /dev/null +++ b/board/st/stm32mp1/spl.c @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2018, STMicroelectronics - All Rights Reserved + * + * SPDX-License-Identifier: GPL-2.0+ BSD-3-Clause + */ + +#include <config.h> +#include <common.h> +#include <spl.h> +#include <dm.h> +#include <ram.h> +#include <asm/io.h> +#include <post.h> +#include <power/pmic.h> +#include <power/stpmu1.h> +#include <asm/arch/ddr.h> + +void spl_board_init(void) +{ + /* Keep vdd on during the reset cycle */ +#if defined(CONFIG_PMIC_STPMU1) && defined(CONFIG_SPL_POWER_SUPPORT) + struct udevice *dev; + int ret; + + ret = uclass_get_device_by_driver(UCLASS_PMIC, + DM_GET_DRIVER(pmic_stpmu1), &dev); + if (!ret) + pmic_clrsetbits(dev, + STPMU1_MASK_RESET_BUCK, + STPMU1_MASK_RESET_BUCK3, + STPMU1_MASK_RESET_BUCK3); +#endif +} diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c new file mode 100644 index 0000000000..84c971c793 --- /dev/null +++ b/board/st/stm32mp1/stm32mp1.c @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2018, STMicroelectronics - All Rights Reserved + * + * SPDX-License-Identifier: GPL-2.0+ BSD-3-Clause + */ +#include <config.h> +#include <common.h> +#include <asm/arch/stm32.h> + +/* + * Get a global data pointer + */ +DECLARE_GLOBAL_DATA_PTR; + +int board_late_init(void) +{ + return 0; +} + +/* board dependent setup after realloc */ +int board_init(void) +{ + /* address of boot parameters */ + gd->bd->bi_boot_params = STM32_DDR_BASE + 0x100; + + return 0; +} |