From ba2c20ce7aba106d0101e04910be64fe3f855096 Mon Sep 17 00:00:00 2001 From: Patrick Delaunay Date: Mon, 13 Jan 2020 15:17:40 +0100 Subject: stm32mp1: move stboard command in board/st/common directory Move the ST command in board/st/common, as this command is only used by ST board. Prepare the support in U-Boot of boards with STM32MP15x SOC but not STMicroelectronics. Signed-off-by: Patrick Delaunay Reviewed-by: Patrice Chotard --- board/st/common/Kconfig | 6 ++ board/st/common/MAINTAINERS | 6 ++ board/st/common/Makefile | 6 ++ board/st/common/cmd_stboard.c | 148 ++++++++++++++++++++++++++++++++++++++++ board/st/stm32mp1/Kconfig | 9 +-- board/st/stm32mp1/Makefile | 1 - board/st/stm32mp1/cmd_stboard.c | 145 --------------------------------------- 7 files changed, 168 insertions(+), 153 deletions(-) create mode 100644 board/st/common/Kconfig create mode 100644 board/st/common/MAINTAINERS create mode 100644 board/st/common/Makefile create mode 100644 board/st/common/cmd_stboard.c delete mode 100644 board/st/stm32mp1/cmd_stboard.c (limited to 'board') diff --git a/board/st/common/Kconfig b/board/st/common/Kconfig new file mode 100644 index 00000000000..1824087afcf --- /dev/null +++ b/board/st/common/Kconfig @@ -0,0 +1,6 @@ +config CMD_STBOARD + bool "stboard - command for OTP board information" + default y + help + This compile the stboard command to + read and write the board in the OTP. diff --git a/board/st/common/MAINTAINERS b/board/st/common/MAINTAINERS new file mode 100644 index 00000000000..3b02f4ab986 --- /dev/null +++ b/board/st/common/MAINTAINERS @@ -0,0 +1,6 @@ +ST BOARDS +M: Patrick Delaunay +L: uboot-stm32@st-md-mailman.stormreply.com (moderated for non-subscribers) +T: git https://gitlab.denx.de/u-boot/custodians/u-boot-stm.git +S: Maintained +F: board/st/common/ diff --git a/board/st/common/Makefile b/board/st/common/Makefile new file mode 100644 index 00000000000..8553606b904 --- /dev/null +++ b/board/st/common/Makefile @@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause +# +# Copyright (C) 2020, STMicroelectronics - All Rights Reserved +# + +obj-$(CONFIG_CMD_STBOARD) += cmd_stboard.o diff --git a/board/st/common/cmd_stboard.c b/board/st/common/cmd_stboard.c new file mode 100644 index 00000000000..e994a88e717 --- /dev/null +++ b/board/st/common/cmd_stboard.c @@ -0,0 +1,148 @@ +// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause +/* + * Copyright (C) 2019, STMicroelectronics - All Rights Reserved + */ + +#ifndef CONFIG_SPL_BUILD +#include +#include +#include +#include +#include + +static bool check_stboard(u16 board) +{ + unsigned int i; + const u16 st_board_id[] = { + 0x1272, + 0x1263, + 0x1264, + 0x1298, + 0x1341, + 0x1497, + }; + + for (i = 0; i < ARRAY_SIZE(st_board_id); i++) + if (board == st_board_id[i]) + return true; + + return false; +} + +static void display_stboard(u32 otp) +{ + printf("Board: MB%04x Var%d Rev.%c-%02d\n", + otp >> 16, + (otp >> 12) & 0xF, + ((otp >> 8) & 0xF) - 1 + 'A', + otp & 0xF); +} + +static int do_stboard(cmd_tbl_t *cmdtp, int flag, int argc, + char * const argv[]) +{ + int ret; + u32 otp; + u8 revision; + unsigned long board, variant, bom; + struct udevice *dev; + int confirmed = argc == 6 && !strcmp(argv[1], "-y"); + + argc -= 1 + confirmed; + argv += 1 + confirmed; + + if (argc != 0 && argc != 4) + return CMD_RET_USAGE; + + ret = uclass_get_device_by_driver(UCLASS_MISC, + DM_GET_DRIVER(stm32mp_bsec), + &dev); + + ret = misc_read(dev, STM32_BSEC_SHADOW(BSEC_OTP_BOARD), + &otp, sizeof(otp)); + + if (ret < 0) { + puts("OTP read error"); + return CMD_RET_FAILURE; + } + + if (argc == 0) { + if (!otp) + puts("Board : OTP board FREE\n"); + else + display_stboard(otp); + return CMD_RET_SUCCESS; + } + + if (otp) { + display_stboard(otp); + printf("ERROR: OTP board not FREE\n"); + return CMD_RET_FAILURE; + } + + if (strict_strtoul(argv[0], 16, &board) < 0 || + board == 0 || board > 0xFFFF) { + printf("argument %d invalid: %s\n", 1, argv[0]); + return CMD_RET_USAGE; + } + + if (strict_strtoul(argv[1], 10, &variant) < 0 || + variant == 0 || variant > 15) { + printf("argument %d invalid: %s\n", 2, argv[1]); + return CMD_RET_USAGE; + } + + revision = argv[2][0] - 'A' + 1; + if (strlen(argv[2]) > 1 || revision == 0 || revision > 15) { + printf("argument %d invalid: %s\n", 3, argv[2]); + return CMD_RET_USAGE; + } + + if (strict_strtoul(argv[3], 10, &bom) < 0 || + bom == 0 || bom > 15) { + printf("argument %d invalid: %s\n", 4, argv[3]); + return CMD_RET_USAGE; + } + + otp = (board << 16) | (variant << 12) | (revision << 8) | bom; + display_stboard(otp); + printf("=> OTP[%d] = %08X\n", BSEC_OTP_BOARD, otp); + + if (!check_stboard((u16)board)) { + printf("Unknown board MB%04x\n", (u16)board); + return CMD_RET_FAILURE; + } + if (!confirmed) { + printf("Warning: Programming BOARD in OTP is irreversible!\n"); + printf("Really perform this OTP programming? \n"); + + if (!confirm_yesno()) { + puts("BOARD programming aborted\n"); + return CMD_RET_FAILURE; + } + } + + ret = misc_write(dev, STM32_BSEC_OTP(BSEC_OTP_BOARD), + &otp, sizeof(otp)); + + if (ret) { + puts("BOARD programming error\n"); + return CMD_RET_FAILURE; + } + puts("BOARD programming done\n"); + + return CMD_RET_SUCCESS; +} + +U_BOOT_CMD(stboard, 6, 0, do_stboard, + "read/write board reference in OTP", + "\n" + " Print current board information\n" + "stboard [-y] \n" + " Write board information\n" + " - Board: xxxx, example 1264 for MB1264\n" + " - Variant: 1 ... 15\n" + " - Revision: A...O\n" + " - BOM: 1...15\n"); + +#endif diff --git a/board/st/stm32mp1/Kconfig b/board/st/stm32mp1/Kconfig index 4fa2360b4f9..9f985e57752 100644 --- a/board/st/stm32mp1/Kconfig +++ b/board/st/stm32mp1/Kconfig @@ -15,15 +15,10 @@ config ENV_SECT_SIZE config ENV_OFFSET default 0x280000 if ENV_IS_IN_SPI_FLASH -config CMD_STBOARD - bool "stboard - command for OTP board information" - default y - help - This compile the stboard command to - read and write the board in the OTP. - config TARGET_STM32MP157C_DK2 bool "support of STMicroelectronics STM32MP157C-DK2 Discovery Board" default y +source "board/st/common/Kconfig" + endif diff --git a/board/st/stm32mp1/Makefile b/board/st/stm32mp1/Makefile index 3c6c035b118..8188075b1a3 100644 --- a/board/st/stm32mp1/Makefile +++ b/board/st/stm32mp1/Makefile @@ -7,7 +7,6 @@ ifdef CONFIG_SPL_BUILD obj-y += spl.o else obj-y += stm32mp1.o -obj-$(CONFIG_CMD_STBOARD) += cmd_stboard.o endif obj-y += board.o diff --git a/board/st/stm32mp1/cmd_stboard.c b/board/st/stm32mp1/cmd_stboard.c deleted file mode 100644 index 04352ae8ed2..00000000000 --- a/board/st/stm32mp1/cmd_stboard.c +++ /dev/null @@ -1,145 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause -/* - * Copyright (C) 2019, STMicroelectronics - All Rights Reserved - */ - -#include -#include -#include -#include -#include - -static bool check_stboard(u16 board) -{ - unsigned int i; - const u16 st_board_id[] = { - 0x1272, - 0x1263, - 0x1264, - 0x1298, - 0x1341, - 0x1497, - }; - - for (i = 0; i < ARRAY_SIZE(st_board_id); i++) - if (board == st_board_id[i]) - return true; - - return false; -} - -static void display_stboard(u32 otp) -{ - printf("Board: MB%04x Var%d Rev.%c-%02d\n", - otp >> 16, - (otp >> 12) & 0xF, - ((otp >> 8) & 0xF) - 1 + 'A', - otp & 0xF); -} - -static int do_stboard(cmd_tbl_t *cmdtp, int flag, int argc, - char * const argv[]) -{ - int ret; - u32 otp; - u8 revision; - unsigned long board, variant, bom; - struct udevice *dev; - int confirmed = argc == 6 && !strcmp(argv[1], "-y"); - - argc -= 1 + confirmed; - argv += 1 + confirmed; - - if (argc != 0 && argc != 4) - return CMD_RET_USAGE; - - ret = uclass_get_device_by_driver(UCLASS_MISC, - DM_GET_DRIVER(stm32mp_bsec), - &dev); - - ret = misc_read(dev, STM32_BSEC_SHADOW(BSEC_OTP_BOARD), - &otp, sizeof(otp)); - - if (ret < 0) { - puts("OTP read error"); - return CMD_RET_FAILURE; - } - - if (argc == 0) { - if (!otp) - puts("Board : OTP board FREE\n"); - else - display_stboard(otp); - return CMD_RET_SUCCESS; - } - - if (otp) { - display_stboard(otp); - printf("ERROR: OTP board not FREE\n"); - return CMD_RET_FAILURE; - } - - if (strict_strtoul(argv[0], 16, &board) < 0 || - board == 0 || board > 0xFFFF) { - printf("argument %d invalid: %s\n", 1, argv[0]); - return CMD_RET_USAGE; - } - - if (strict_strtoul(argv[1], 10, &variant) < 0 || - variant == 0 || variant > 15) { - printf("argument %d invalid: %s\n", 2, argv[1]); - return CMD_RET_USAGE; - } - - revision = argv[2][0] - 'A' + 1; - if (strlen(argv[2]) > 1 || revision == 0 || revision > 15) { - printf("argument %d invalid: %s\n", 3, argv[2]); - return CMD_RET_USAGE; - } - - if (strict_strtoul(argv[3], 10, &bom) < 0 || - bom == 0 || bom > 15) { - printf("argument %d invalid: %s\n", 4, argv[3]); - return CMD_RET_USAGE; - } - - otp = (board << 16) | (variant << 12) | (revision << 8) | bom; - display_stboard(otp); - printf("=> OTP[%d] = %08X\n", BSEC_OTP_BOARD, otp); - - if (!check_stboard((u16)board)) { - printf("Unknown board MB%04x\n", (u16)board); - return CMD_RET_FAILURE; - } - if (!confirmed) { - printf("Warning: Programming BOARD in OTP is irreversible!\n"); - printf("Really perform this OTP programming? \n"); - - if (!confirm_yesno()) { - puts("BOARD programming aborted\n"); - return CMD_RET_FAILURE; - } - } - - ret = misc_write(dev, STM32_BSEC_OTP(BSEC_OTP_BOARD), - &otp, sizeof(otp)); - - if (ret) { - puts("BOARD programming error\n"); - return CMD_RET_FAILURE; - } - puts("BOARD programming done\n"); - - return CMD_RET_SUCCESS; -} - -U_BOOT_CMD(stboard, 6, 0, do_stboard, - "read/write board reference in OTP", - "\n" - " Print current board information\n" - "stboard [-y] \n" - " Write board information\n" - " - Board: xxxx, example 1264 for MB1264\n" - " - Variant: 1 ... 15\n" - " - Revision: A...O\n" - " - BOM: 1...15\n"); -- cgit v1.3.1 From 493305716c7c91e91b3fcdcdd4a1bd662157c1ff Mon Sep 17 00:00:00 2001 From: Patrick Delaunay Date: Mon, 13 Jan 2020 15:17:41 +0100 Subject: board: stm32mp1: move CONFIG_ENV_XXX in defconfig Move CONFIG_ENV_SECT_SIZE and CONFIG_ENV_OFFSET in stm32mp15_*_defconfig for ST board with NOR support (STM32MP15xx-EV1 boards) - CONFIG_SECT_SIZE values = the max supported NOR erase size (256KB) - CONFIG_ENV_OFFSET = offset for NOR (ENV_IS_IN_SPI_FLASH) This Patch prepares the U-Boot support of boards with STM32MP15x SOC not provided by STMicroelectronics. Signed-off-by: Patrick Delaunay Reviewed-by: Patrice Chotard --- board/st/stm32mp1/Kconfig | 6 ------ configs/stm32mp15_basic_defconfig | 2 ++ configs/stm32mp15_optee_defconfig | 2 ++ configs/stm32mp15_trusted_defconfig | 2 ++ 4 files changed, 6 insertions(+), 6 deletions(-) (limited to 'board') diff --git a/board/st/stm32mp1/Kconfig b/board/st/stm32mp1/Kconfig index 9f985e57752..89fc5627460 100644 --- a/board/st/stm32mp1/Kconfig +++ b/board/st/stm32mp1/Kconfig @@ -9,12 +9,6 @@ config SYS_VENDOR config SYS_CONFIG_NAME default "stm32mp1" -config ENV_SECT_SIZE - default 0x40000 if ENV_IS_IN_SPI_FLASH - -config ENV_OFFSET - default 0x280000 if ENV_IS_IN_SPI_FLASH - config TARGET_STM32MP157C_DK2 bool "support of STMicroelectronics STM32MP157C-DK2 Discovery Board" default y diff --git a/configs/stm32mp15_basic_defconfig b/configs/stm32mp15_basic_defconfig index c85369ca0fb..1061d38d8a8 100644 --- a/configs/stm32mp15_basic_defconfig +++ b/configs/stm32mp15_basic_defconfig @@ -1,6 +1,8 @@ CONFIG_ARM=y CONFIG_ARCH_STM32MP=y CONFIG_SYS_MALLOC_F_LEN=0x3000 +CONFIG_ENV_SECT_SIZE=0x40000 +CONFIG_ENV_OFFSET=0x280000 CONFIG_SPL_MMC_SUPPORT=y CONFIG_SPL=y CONFIG_TARGET_STM32MP1=y diff --git a/configs/stm32mp15_optee_defconfig b/configs/stm32mp15_optee_defconfig index c192d8d441f..6a112023a19 100644 --- a/configs/stm32mp15_optee_defconfig +++ b/configs/stm32mp15_optee_defconfig @@ -1,6 +1,8 @@ CONFIG_ARM=y CONFIG_ARCH_STM32MP=y CONFIG_SYS_MALLOC_F_LEN=0x3000 +CONFIG_ENV_SECT_SIZE=0x40000 +CONFIG_ENV_OFFSET=0x280000 CONFIG_TARGET_STM32MP1=y CONFIG_STM32MP1_OPTEE=y CONFIG_DISTRO_DEFAULTS=y diff --git a/configs/stm32mp15_trusted_defconfig b/configs/stm32mp15_trusted_defconfig index a846962af50..35a8929ae0f 100644 --- a/configs/stm32mp15_trusted_defconfig +++ b/configs/stm32mp15_trusted_defconfig @@ -1,6 +1,8 @@ CONFIG_ARM=y CONFIG_ARCH_STM32MP=y CONFIG_SYS_MALLOC_F_LEN=0x3000 +CONFIG_ENV_SECT_SIZE=0x40000 +CONFIG_ENV_OFFSET=0x280000 CONFIG_TARGET_STM32MP1=y CONFIG_DISTRO_DEFAULTS=y CONFIG_FIT=y -- cgit v1.3.1 From 846254888e2e1bd91edeedd208fca44eea512845 Mon Sep 17 00:00:00 2001 From: Patrick Delaunay Date: Mon, 13 Jan 2020 15:17:42 +0100 Subject: stm32mp1: split board and SOC support for STM32MP15x family Split the board and SOC support for STM32MP15x family and prepare the introduction of new boards with STM32MP15x. This path define the 2 configurations: - STM32MP15x: STM32MP15x soc support (new) - TARGET_ST_STM32MP15x: STMicroelectronics board support (choice) Signed-off-by: Patrick Delaunay Reviewed-by: Patrice Chotard --- arch/arm/dts/Makefile | 2 +- arch/arm/mach-stm32mp/Kconfig | 32 ++++++++++++++++++++++++-------- board/st/common/Kconfig | 3 ++- board/st/stm32mp1/Kconfig | 7 +------ board/st/stm32mp1/stm32mp1.c | 2 +- configs/stm32mp15_basic_defconfig | 2 +- configs/stm32mp15_optee_defconfig | 2 +- configs/stm32mp15_trusted_defconfig | 2 +- 8 files changed, 32 insertions(+), 20 deletions(-) (limited to 'board') diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile index 04a8cccda5e..8c111731711 100644 --- a/arch/arm/dts/Makefile +++ b/arch/arm/dts/Makefile @@ -862,7 +862,7 @@ dtb-$(CONFIG_ARCH_ASPEED) += ast2500-evb.dtb dtb-$(CONFIG_ARCH_STI) += stih410-b2260.dtb -dtb-$(CONFIG_TARGET_STM32MP1) += \ +dtb-$(CONFIG_STM32MP15x) += \ stm32mp157a-dk1.dtb \ stm32mp157a-avenger96.dtb \ stm32mp157c-dk2.dtb \ diff --git a/arch/arm/mach-stm32mp/Kconfig b/arch/arm/mach-stm32mp/Kconfig index bf8a18a0c31..137178aa453 100644 --- a/arch/arm/mach-stm32mp/Kconfig +++ b/arch/arm/mach-stm32mp/Kconfig @@ -33,8 +33,8 @@ config SYS_MALLOC_LEN config ENV_SIZE default 0x2000 -config TARGET_STM32MP1 - bool "Support stm32mp1xx" +config STM32MP15x + bool "Support STMicroelectronics STM32MP15x Soc" select ARCH_SUPPORT_PSCI if !STM32MP1_TRUSTED select CPU_V7A select CPU_V7_HAS_NONSEC if !STM32MP1_TRUSTED @@ -45,19 +45,35 @@ config TARGET_STM32MP1 select STM32_RESET select STM32_SERIAL select SYS_ARCH_TIMER + imply SYSRESET_PSCI if STM32MP1_TRUSTED + imply SYSRESET_SYSCON if !STM32MP1_TRUSTED + help + support of STMicroelectronics SOC STM32MP15x family + STM32MP157, STM32MP153 or STM32MP151 + STMicroelectronics MPU with core ARMv7 + dual core A7 for STM32MP157/3, monocore for STM32MP151 + target all the STMicroelectronics board with SOC STM32MP1 family + +choice + prompt "STM32MP15x board select" + optional + +config TARGET_ST_STM32MP15x + bool "STMicroelectronics STM32MP15x boards" + select STM32MP15x imply BOOTCOUNT_LIMIT imply CMD_BOOTCOUNT imply CMD_CLS if CMD_BMP imply DISABLE_CONSOLE imply PRE_CONSOLE_BUFFER imply SILENT_CONSOLE - imply SYSRESET_PSCI if STM32MP1_TRUSTED - imply SYSRESET_SYSCON if !STM32MP1_TRUSTED help - target STMicroelectronics SOC STM32MP1 family - STM32MP157, STM32MP153 or STM32MP151 - STMicroelectronics MPU with core ARMv7 - dual core A7 for STM32MP157/3, monocore for STM32MP151 + target the STMicroelectronics board with SOC STM32MP15x + managed by board/st/stm32mp1: + Evalulation board (EV1) or Discovery board (DK1 and DK2). + The difference between board are managed with devicetree + +endchoice config STM32MP1_TRUSTED bool "Support trusted boot with TF-A" diff --git a/board/st/common/Kconfig b/board/st/common/Kconfig index 1824087afcf..af01ca4891c 100644 --- a/board/st/common/Kconfig +++ b/board/st/common/Kconfig @@ -1,6 +1,7 @@ config CMD_STBOARD bool "stboard - command for OTP board information" - default y + depends on ARCH_STM32MP + default y if TARGET_ST_STM32MP15x help This compile the stboard command to read and write the board in the OTP. diff --git a/board/st/stm32mp1/Kconfig b/board/st/stm32mp1/Kconfig index 89fc5627460..c5ab7553d4f 100644 --- a/board/st/stm32mp1/Kconfig +++ b/board/st/stm32mp1/Kconfig @@ -1,4 +1,4 @@ -if TARGET_STM32MP1 +if TARGET_ST_STM32MP15x config SYS_BOARD default "stm32mp1" @@ -9,10 +9,5 @@ config SYS_VENDOR config SYS_CONFIG_NAME default "stm32mp1" -config TARGET_STM32MP157C_DK2 - bool "support of STMicroelectronics STM32MP157C-DK2 Discovery Board" - default y - source "board/st/common/Kconfig" - endif diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c index 1d4a54c9026..4e298dabcbf 100644 --- a/board/st/stm32mp1/stm32mp1.c +++ b/board/st/stm32mp1/stm32mp1.c @@ -607,7 +607,7 @@ error: static bool board_is_dk2(void) { - if (CONFIG_IS_ENABLED(TARGET_STM32MP157C_DK2) && + if (CONFIG_IS_ENABLED(TARGET_ST_STM32MP15x) && of_machine_is_compatible("st,stm32mp157c-dk2")) return true; diff --git a/configs/stm32mp15_basic_defconfig b/configs/stm32mp15_basic_defconfig index 1061d38d8a8..0b646da2b13 100644 --- a/configs/stm32mp15_basic_defconfig +++ b/configs/stm32mp15_basic_defconfig @@ -5,7 +5,7 @@ CONFIG_ENV_SECT_SIZE=0x40000 CONFIG_ENV_OFFSET=0x280000 CONFIG_SPL_MMC_SUPPORT=y CONFIG_SPL=y -CONFIG_TARGET_STM32MP1=y +CONFIG_TARGET_ST_STM32MP15x=y CONFIG_SPL_SPI_FLASH_SUPPORT=y CONFIG_SPL_SPI_SUPPORT=y # CONFIG_ARMV7_VIRT is not set diff --git a/configs/stm32mp15_optee_defconfig b/configs/stm32mp15_optee_defconfig index 6a112023a19..b45462b2f0f 100644 --- a/configs/stm32mp15_optee_defconfig +++ b/configs/stm32mp15_optee_defconfig @@ -3,7 +3,7 @@ CONFIG_ARCH_STM32MP=y CONFIG_SYS_MALLOC_F_LEN=0x3000 CONFIG_ENV_SECT_SIZE=0x40000 CONFIG_ENV_OFFSET=0x280000 -CONFIG_TARGET_STM32MP1=y +CONFIG_TARGET_ST_STM32MP15x=y CONFIG_STM32MP1_OPTEE=y CONFIG_DISTRO_DEFAULTS=y CONFIG_FIT=y diff --git a/configs/stm32mp15_trusted_defconfig b/configs/stm32mp15_trusted_defconfig index 35a8929ae0f..5dc530f1ab0 100644 --- a/configs/stm32mp15_trusted_defconfig +++ b/configs/stm32mp15_trusted_defconfig @@ -3,7 +3,7 @@ CONFIG_ARCH_STM32MP=y CONFIG_SYS_MALLOC_F_LEN=0x3000 CONFIG_ENV_SECT_SIZE=0x40000 CONFIG_ENV_OFFSET=0x280000 -CONFIG_TARGET_STM32MP1=y +CONFIG_TARGET_ST_STM32MP15x=y CONFIG_DISTRO_DEFAULTS=y CONFIG_FIT=y CONFIG_BOOTCOMMAND="run bootcmd_stm32mp" -- cgit v1.3.1