From ec1ee5a9272f1393caf5275309cd08cf48e49dd0 Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Wed, 22 Apr 2020 13:18:09 +0200 Subject: ARM: stm32: Add default config for DHCOR Add default U-Boot configuration for the DHCOR SoM on AV96 board. Reviewed-by: Patrick Delaunay Signed-off-by: Marek Vasut Cc: Manivannan Sadhasivam Cc: Patrick Delaunay Cc: Patrice Chotard --- board/dhelectronics/dh_stm32mp1/MAINTAINERS | 1 + 1 file changed, 1 insertion(+) (limited to 'board/dhelectronics') diff --git a/board/dhelectronics/dh_stm32mp1/MAINTAINERS b/board/dhelectronics/dh_stm32mp1/MAINTAINERS index 1511ecb65d..fd70131f9e 100644 --- a/board/dhelectronics/dh_stm32mp1/MAINTAINERS +++ b/board/dhelectronics/dh_stm32mp1/MAINTAINERS @@ -4,4 +4,5 @@ S: Maintained F: arch/arm/dts/stm32mp15xx-dhcom* F: board/dhelectronics/dh_stm32mp1/ F: configs/stm32mp15_dhcom_basic_defconfig +F: configs/stm32mp15_dhcor_basic_defconfig F: include/configs/stm32mp1.h -- cgit From 731fd50e27fb3e9e55eb508cebebc7a111616a30 Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Wed, 22 Apr 2020 13:18:11 +0200 Subject: ARM: stm32: Implement board coding on AV96 The AV96 board does exist in multiple variants. To cater for all of them, implement board code handling. There are two GPIOs which code the type of the board, read them out and use the value to pick the correct device tree from an fitImage. Reviewed-by: Patrick Delaunay Signed-off-by: Marek Vasut Cc: Manivannan Sadhasivam Cc: Patrick Delaunay Cc: Patrice Chotard Change-Id: Iddb330b9a66500495885457cbe17edc0eacaaf43 --- board/dhelectronics/dh_stm32mp1/Kconfig | 2 +- board/dhelectronics/dh_stm32mp1/board.c | 61 ++++++++++++++++++++++++ board/dhelectronics/dh_stm32mp1/u-boot-dhcom.its | 39 +++++++++++++++ board/dhelectronics/dh_stm32mp1/u-boot-dhcor.its | 39 +++++++++++++++ 4 files changed, 140 insertions(+), 1 deletion(-) create mode 100644 board/dhelectronics/dh_stm32mp1/u-boot-dhcom.its create mode 100644 board/dhelectronics/dh_stm32mp1/u-boot-dhcor.its (limited to 'board/dhelectronics') diff --git a/board/dhelectronics/dh_stm32mp1/Kconfig b/board/dhelectronics/dh_stm32mp1/Kconfig index 8eab986640..0a839f2546 100644 --- a/board/dhelectronics/dh_stm32mp1/Kconfig +++ b/board/dhelectronics/dh_stm32mp1/Kconfig @@ -7,7 +7,7 @@ config SYS_VENDOR default "dhelectronics" config SYS_CONFIG_NAME - default "stm32mp1" + default "dh_stm32mp1" config ENV_SECT_SIZE default 0x10000 if ENV_IS_IN_SPI_FLASH diff --git a/board/dhelectronics/dh_stm32mp1/board.c b/board/dhelectronics/dh_stm32mp1/board.c index 322558157e..5193868d7c 100644 --- a/board/dhelectronics/dh_stm32mp1/board.c +++ b/board/dhelectronics/dh_stm32mp1/board.c @@ -133,6 +133,62 @@ int checkboard(void) return 0; } +#ifdef CONFIG_BOARD_EARLY_INIT_F +static u8 brdcode __section("data"); +static u8 somcode __section("data"); + +static void board_get_coding_straps(void) +{ + struct gpio_desc gpio[4]; + ofnode node; + int i, ret; + + node = ofnode_path("/config"); + if (!ofnode_valid(node)) { + printf("%s: no /config node?\n", __func__); + return; + } + + brdcode = 0; + somcode = 0; + + ret = gpio_request_list_by_name_nodev(node, "dh,som-coding-gpios", + gpio, ARRAY_SIZE(gpio), + GPIOD_IS_IN); + for (i = 0; i < ret; i++) + somcode |= !!dm_gpio_get_value(&(gpio[i])) << i; + + ret = gpio_request_list_by_name_nodev(node, "dh,board-coding-gpios", + gpio, ARRAY_SIZE(gpio), + GPIOD_IS_IN); + for (i = 0; i < ret; i++) + brdcode |= !!dm_gpio_get_value(&(gpio[i])) << i; + + printf("Code: SoM:rev=%d Board:rev=%d\n", somcode, brdcode); +} + +int board_early_init_f(void) +{ + board_get_coding_straps(); + + return 0; +} + +#ifdef CONFIG_SPL_LOAD_FIT +int board_fit_config_name_match(const char *name) +{ + char test[20]; + + snprintf(test, sizeof(test), "somrev%d_boardrev%d", somcode, brdcode); + + if (!strcmp(name, test)) + return 0; + + return -EINVAL; +} +#endif +#endif + static void board_key_check(void) { #if defined(CONFIG_FASTBOOT) || defined(CONFIG_CMD_STM32PROG) @@ -478,6 +534,11 @@ int board_late_init(void) if (!strcmp(boot_device, "serial") || !strcmp(boot_device, "usb")) env_set("bootdelay", "0"); +#ifdef CONFIG_BOARD_EARLY_INIT_F + env_set_ulong("dh_som_rev", somcode); + env_set_ulong("dh_board_rev", brdcode); +#endif + return 0; } diff --git a/board/dhelectronics/dh_stm32mp1/u-boot-dhcom.its b/board/dhelectronics/dh_stm32mp1/u-boot-dhcom.its new file mode 100644 index 0000000000..2776c41af1 --- /dev/null +++ b/board/dhelectronics/dh_stm32mp1/u-boot-dhcom.its @@ -0,0 +1,39 @@ +/dts-v1/; + +/ { + description = "U-Boot mainline"; + #address-cells = <1>; + + images { + uboot { + description = "U-Boot (32-bit)"; + data = /incbin/("u-boot-nodtb.bin"); + type = "standalone"; + os = "U-Boot"; + arch = "arm"; + compression = "none"; + load = <0xc0100000>; + entry = <0xc0100000>; + }; + + fdt-1 { + description = ".dtb"; + data = /incbin/("arch/arm/dts/stm32mp15xx-dhcom-pdk2.dtb"); + type = "flat_dt"; + arch = "arm"; + compression = "none"; + }; + }; + + configurations { + default = "config-1"; + + config-1 { + description = "somrev0_boardrev0"; /* SoM+board model */ + loadables = "uboot"; + fdt = "fdt-1"; + }; + + /* Add 587-100..587-400 with fdt-2..fdt-4 here */ + }; +}; diff --git a/board/dhelectronics/dh_stm32mp1/u-boot-dhcor.its b/board/dhelectronics/dh_stm32mp1/u-boot-dhcor.its new file mode 100644 index 0000000000..8844508f1a --- /dev/null +++ b/board/dhelectronics/dh_stm32mp1/u-boot-dhcor.its @@ -0,0 +1,39 @@ +/dts-v1/; + +/ { + description = "U-Boot mainline"; + #address-cells = <1>; + + images { + uboot { + description = "U-Boot (32-bit)"; + data = /incbin/("u-boot-nodtb.bin"); + type = "standalone"; + os = "U-Boot"; + arch = "arm"; + compression = "none"; + load = <0xc0100000>; + entry = <0xc0100000>; + }; + + fdt-1 { + description = ".dtb"; + data = /incbin/("arch/arm/dts/stm32mp15xx-dhcor-avenger96.dtb"); + type = "flat_dt"; + arch = "arm"; + compression = "none"; + }; + }; + + configurations { + default = "config-1"; + + config-1 { + description = "somrev0_boardrev1"; /* SoM+board model */ + loadables = "uboot"; + fdt = "fdt-1"; + }; + + /* Add 586-200..586-400 with fdt-2..fdt-4 here */ + }; +}; -- cgit From 2d68365da17b7dc45543daaa9c5010c11332ba09 Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Wed, 22 Apr 2020 13:18:14 +0200 Subject: ARM: stm32: Implement DDR3 coding on DHCOR SoM The DHCOR board does exist in multiple variants with different DDR3 DRAM sizes. To cater for all of them, implement DDR3 code handling. There are two GPIOs which code the DRAM size populated on the SoM, read them out and use the value to pick the correct DDR3 config. Reviewed-by: Patrick Delaunay Signed-off-by: Marek Vasut Cc: Manivannan Sadhasivam Cc: Patrick Delaunay Cc: Patrice Chotard --- board/dhelectronics/dh_stm32mp1/board.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'board/dhelectronics') diff --git a/board/dhelectronics/dh_stm32mp1/board.c b/board/dhelectronics/dh_stm32mp1/board.c index 5193868d7c..9a2926bbe5 100644 --- a/board/dhelectronics/dh_stm32mp1/board.c +++ b/board/dhelectronics/dh_stm32mp1/board.c @@ -135,6 +135,7 @@ int checkboard(void) #ifdef CONFIG_BOARD_EARLY_INIT_F static u8 brdcode __section("data"); +static u8 ddr3code __section("data"); static u8 somcode __section("data"); static void board_get_coding_straps(void) @@ -150,6 +151,7 @@ static void board_get_coding_straps(void) } brdcode = 0; + ddr3code = 0; somcode = 0; ret = gpio_request_list_by_name_nodev(node, "dh,som-coding-gpios", @@ -158,13 +160,34 @@ static void board_get_coding_straps(void) for (i = 0; i < ret; i++) somcode |= !!dm_gpio_get_value(&(gpio[i])) << i; + ret = gpio_request_list_by_name_nodev(node, "dh,ddr3-coding-gpios", + gpio, ARRAY_SIZE(gpio), + GPIOD_IS_IN); + for (i = 0; i < ret; i++) + ddr3code |= !!dm_gpio_get_value(&(gpio[i])) << i; + ret = gpio_request_list_by_name_nodev(node, "dh,board-coding-gpios", gpio, ARRAY_SIZE(gpio), GPIOD_IS_IN); for (i = 0; i < ret; i++) brdcode |= !!dm_gpio_get_value(&(gpio[i])) << i; - printf("Code: SoM:rev=%d Board:rev=%d\n", somcode, brdcode); + printf("Code: SoM:rev=%d,ddr3=%d Board:rev=%d\n", + somcode, ddr3code, brdcode); +} + +int board_stm32mp1_ddr_config_name_match(struct udevice *dev, + const char *name) +{ + if (ddr3code == 2 && + !strcmp(name, "st,ddr3-1066-888-bin-g-1x4gb-533mhz")) + return 0; + + if (ddr3code == 3 && + !strcmp(name, "st,ddr3-1066-888-bin-g-2x4gb-533mhz")) + return 0; + + return -EINVAL; } int board_early_init_f(void) @@ -537,6 +560,7 @@ int board_late_init(void) #ifdef CONFIG_BOARD_EARLY_INIT_F env_set_ulong("dh_som_rev", somcode); env_set_ulong("dh_board_rev", brdcode); + env_set_ulong("dh_ddr3_code", ddr3code); #endif return 0; -- cgit From 939ba160aa7e4f926599befc5e5cd0a4545dff6e Mon Sep 17 00:00:00 2001 From: Patrick Delaunay Date: Wed, 18 Mar 2020 09:22:44 +0100 Subject: board: stm32mp1: move board_get_mtdparts in st common directory Move the stm32mp1 common code board_get_mtdparts() in common directory, this patch reduce the maintenance effort on this generic part (not board dependent). Signed-off-by: Patrick Delaunay Reviewed-by: Patrice Chotard --- board/dhelectronics/dh_stm32mp1/Makefile | 1 + board/dhelectronics/dh_stm32mp1/board.c | 89 -------------------------------- 2 files changed, 1 insertion(+), 89 deletions(-) (limited to 'board/dhelectronics') diff --git a/board/dhelectronics/dh_stm32mp1/Makefile b/board/dhelectronics/dh_stm32mp1/Makefile index b42c4e4c04..c77a1e3a84 100644 --- a/board/dhelectronics/dh_stm32mp1/Makefile +++ b/board/dhelectronics/dh_stm32mp1/Makefile @@ -8,3 +8,4 @@ obj-y += ../../st/stm32mp1/spl.o endif obj-y += ../../st/stm32mp1/board.o board.o +obj-$(CONFIG_SYS_MTDPARTS_RUNTIME) += ../../st/common/stm32mp_mtdparts.o diff --git a/board/dhelectronics/dh_stm32mp1/board.c b/board/dhelectronics/dh_stm32mp1/board.c index 9a2926bbe5..5f3fe452ce 100644 --- a/board/dhelectronics/dh_stm32mp1/board.c +++ b/board/dhelectronics/dh_stm32mp1/board.c @@ -655,95 +655,6 @@ enum env_location env_get_location(enum env_operation op, int prio) #endif } -#ifdef CONFIG_SYS_MTDPARTS_RUNTIME - -#define MTDPARTS_LEN 256 -#define MTDIDS_LEN 128 - -/** - * The mtdparts_nand0 and mtdparts_nor0 variable tends to be long. - * If we need to access it before the env is relocated, then we need - * to use our own stack buffer. gd->env_buf will be too small. - * - * @param buf temporary buffer pointer MTDPARTS_LEN long - * @return mtdparts variable string, NULL if not found - */ -static const char *env_get_mtdparts(const char *str, char *buf) -{ - if (gd->flags & GD_FLG_ENV_READY) - return env_get(str); - if (env_get_f(str, buf, MTDPARTS_LEN) != -1) - return buf; - - return NULL; -} - -/** - * update the variables "mtdids" and "mtdparts" with content of mtdparts_ - */ -static void board_get_mtdparts(const char *dev, - char *mtdids, - char *mtdparts) -{ - char env_name[32] = "mtdparts_"; - char tmp_mtdparts[MTDPARTS_LEN]; - const char *tmp; - - /* name of env variable to read = mtdparts_ */ - strcat(env_name, dev); - tmp = env_get_mtdparts(env_name, tmp_mtdparts); - if (tmp) { - /* mtdids: "=, ...." */ - if (mtdids[0] != '\0') - strcat(mtdids, ","); - strcat(mtdids, dev); - strcat(mtdids, "="); - strcat(mtdids, dev); - - /* mtdparts: "mtdparts=:>;..." */ - if (mtdparts[0] != '\0') - strncat(mtdparts, ";", MTDPARTS_LEN); - else - strcat(mtdparts, "mtdparts="); - strncat(mtdparts, dev, MTDPARTS_LEN); - strncat(mtdparts, ":", MTDPARTS_LEN); - strncat(mtdparts, tmp, MTDPARTS_LEN); - } -} - -void board_mtdparts_default(const char **mtdids, const char **mtdparts) -{ - struct udevice *dev; - static char parts[3 * MTDPARTS_LEN + 1]; - static char ids[MTDIDS_LEN + 1]; - static bool mtd_initialized; - - if (mtd_initialized) { - *mtdids = ids; - *mtdparts = parts; - return; - } - - memset(parts, 0, sizeof(parts)); - memset(ids, 0, sizeof(ids)); - - /* probe all MTD devices */ - for (uclass_first_device(UCLASS_MTD, &dev); - dev; - uclass_next_device(&dev)) { - pr_debug("mtd device = %s\n", dev->name); - } - - if (!uclass_get_device(UCLASS_SPI_FLASH, 0, &dev)) - board_get_mtdparts("nor0", ids, parts); - - mtd_initialized = true; - *mtdids = ids; - *mtdparts = parts; - debug("%s:mtdids=%s & mtdparts=%s\n", __func__, ids, parts); -} -#endif - #if defined(CONFIG_OF_BOARD_SETUP) int ft_board_setup(void *blob, bd_t *bd) { -- cgit From ec2933e543dfe80bbb7b3c015392b44894081452 Mon Sep 17 00:00:00 2001 From: Patrick Delaunay Date: Wed, 18 Mar 2020 09:22:45 +0100 Subject: board: stm32mp1: move set_dfu_alt_info in st common directory Move the stm32mp1 common code set_dfu_alt_info() in common directory, this patch reduce the maintenance effort on this generic part (not board dependent). Signed-off-by: Patrick Delaunay Reviewed-by: Patrice Chotard --- board/dhelectronics/dh_stm32mp1/Makefile | 2 ++ board/dhelectronics/dh_stm32mp1/board.c | 50 -------------------------------- 2 files changed, 2 insertions(+), 50 deletions(-) (limited to 'board/dhelectronics') diff --git a/board/dhelectronics/dh_stm32mp1/Makefile b/board/dhelectronics/dh_stm32mp1/Makefile index c77a1e3a84..e8f218da08 100644 --- a/board/dhelectronics/dh_stm32mp1/Makefile +++ b/board/dhelectronics/dh_stm32mp1/Makefile @@ -8,4 +8,6 @@ obj-y += ../../st/stm32mp1/spl.o endif obj-y += ../../st/stm32mp1/board.o board.o + obj-$(CONFIG_SYS_MTDPARTS_RUNTIME) += ../../st/common/stm32mp_mtdparts.o +obj-$(CONFIG_SET_DFU_ALT_INFO) += ../../st/common/stm32mp_dfu.o diff --git a/board/dhelectronics/dh_stm32mp1/board.c b/board/dhelectronics/dh_stm32mp1/board.c index 5f3fe452ce..873fa86e53 100644 --- a/board/dhelectronics/dh_stm32mp1/board.c +++ b/board/dhelectronics/dh_stm32mp1/board.c @@ -662,56 +662,6 @@ int ft_board_setup(void *blob, bd_t *bd) } #endif -#ifdef CONFIG_SET_DFU_ALT_INFO -#define DFU_ALT_BUF_LEN SZ_1K - -static void board_get_alt_info(const char *dev, char *buff) -{ - char var_name[32] = "dfu_alt_info_"; - int ret; - - ALLOC_CACHE_ALIGN_BUFFER(char, tmp_alt, DFU_ALT_BUF_LEN); - - /* name of env variable to read = dfu_alt_info_ */ - strcat(var_name, dev); - ret = env_get_f(var_name, tmp_alt, DFU_ALT_BUF_LEN); - if (ret) { - if (buff[0] != '\0') - strcat(buff, "&"); - strncat(buff, tmp_alt, DFU_ALT_BUF_LEN); - } -} - -void set_dfu_alt_info(char *interface, char *devstr) -{ - struct udevice *dev; - - ALLOC_CACHE_ALIGN_BUFFER(char, buf, DFU_ALT_BUF_LEN); - - if (env_get("dfu_alt_info")) - return; - - memset(buf, 0, sizeof(buf)); - - /* probe all MTD devices */ - mtd_probe_devices(); - - board_get_alt_info("ram", buf); - - if (!uclass_get_device(UCLASS_MMC, 0, &dev)) - board_get_alt_info("mmc0", buf); - - if (!uclass_get_device(UCLASS_MMC, 1, &dev)) - board_get_alt_info("mmc1", buf); - - if (!uclass_get_device(UCLASS_SPI_FLASH, 0, &dev)) - board_get_alt_info("nor0", buf); - - env_set("dfu_alt_info", buf); - puts("DFU alt info setting: done\n"); -} -#endif - static void board_copro_image_process(ulong fw_image, size_t fw_size) { int ret, id = 0; /* Copro id fixed to 0 as only one coproc on mp1 */ -- cgit From 31325e1b8b9ce06b34add643f4a9d0b58235434a Mon Sep 17 00:00:00 2001 From: Patrick Delaunay Date: Wed, 18 Mar 2020 09:22:46 +0100 Subject: stm32mp1: dynamically build DFU_ALT_INFO This patch reduces the stm32mp1 environment size and builds dynamically the DFU board configuration with gpt and mtd partitions and information from defconfig (CONFIG_DFU_ALT_RAM0). Signed-off-by: Patrick Delaunay Reviewed-by: Patrice Chotard --- board/dhelectronics/dh_stm32mp1/Kconfig | 1 + 1 file changed, 1 insertion(+) (limited to 'board/dhelectronics') diff --git a/board/dhelectronics/dh_stm32mp1/Kconfig b/board/dhelectronics/dh_stm32mp1/Kconfig index 0a839f2546..1fc792c9d1 100644 --- a/board/dhelectronics/dh_stm32mp1/Kconfig +++ b/board/dhelectronics/dh_stm32mp1/Kconfig @@ -18,4 +18,5 @@ config ENV_OFFSET config ENV_OFFSET_REDUND default 0x1F0000 if ENV_IS_IN_SPI_FLASH +source "board/st/common/Kconfig" endif -- cgit From 43df0a159df6ef4c627553915634cd3d961d4da8 Mon Sep 17 00:00:00 2001 From: Patrick Delaunay Date: Wed, 18 Mar 2020 09:22:49 +0100 Subject: stm32mp1: dynamically detect op-tee presence Activate OP-TEE driver for trusted and optee defconfig. This driver allows detection of TEE presence for boot from flash; CONFIG_STM32MP1_OPTEE is also removed. Signed-off-by: Patrick Delaunay Reviewed-by: Patrice Chotard --- board/dhelectronics/dh_stm32mp1/board.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'board/dhelectronics') diff --git a/board/dhelectronics/dh_stm32mp1/board.c b/board/dhelectronics/dh_stm32mp1/board.c index 873fa86e53..ec1edd5c68 100644 --- a/board/dhelectronics/dh_stm32mp1/board.c +++ b/board/dhelectronics/dh_stm32mp1/board.c @@ -116,9 +116,7 @@ int checkboard(void) const char *fdt_compat; int fdt_compat_len; - if (IS_ENABLED(CONFIG_STM32MP1_OPTEE)) - mode = "trusted with OP-TEE"; - else if (IS_ENABLED(CONFIG_TFABOOT)) + if (IS_ENABLED(CONFIG_TFABOOT)) mode = "trusted"; else mode = "basic"; -- cgit From 92ca0f7446c5948f364bfb3377f9e08fad7ff857 Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Wed, 29 Apr 2020 15:08:38 +0200 Subject: ARM: dts: stm32: Synchronize DDR setttings on DH SoMs Add custom DDR DRAM settings for the DHCOR and DHCOM SoMs and put them into use by the board file instead of the default ones. These new DRAM settings are a better fit for the SoMs. Signed-off-by: Marek Vasut Cc: Patrick Delaunay Cc: Patrice Chotard Reviewed-by: Patrick Delaunay --- board/dhelectronics/dh_stm32mp1/board.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'board/dhelectronics') diff --git a/board/dhelectronics/dh_stm32mp1/board.c b/board/dhelectronics/dh_stm32mp1/board.c index ec1edd5c68..85d56f6082 100644 --- a/board/dhelectronics/dh_stm32mp1/board.c +++ b/board/dhelectronics/dh_stm32mp1/board.c @@ -177,12 +177,16 @@ static void board_get_coding_straps(void) int board_stm32mp1_ddr_config_name_match(struct udevice *dev, const char *name) { + if (ddr3code == 1 && + !strcmp(name, "st,ddr3l-dhsom-1066-888-bin-g-2x1gb-533mhz")) + return 0; + if (ddr3code == 2 && - !strcmp(name, "st,ddr3-1066-888-bin-g-1x4gb-533mhz")) + !strcmp(name, "st,ddr3l-dhsom-1066-888-bin-g-2x2gb-533mhz")) return 0; if (ddr3code == 3 && - !strcmp(name, "st,ddr3-1066-888-bin-g-2x4gb-533mhz")) + !strcmp(name, "st,ddr3l-dhsom-1066-888-bin-g-2x4gb-533mhz")) return 0; return -EINVAL; -- cgit