From eeea6e298dc83b4a93a18c846e8e567d9beb0c1f Mon Sep 17 00:00:00 2001 From: Nikhil M Jain Date: Wed, 21 Jun 2023 16:29:52 +0530 Subject: [PATCH 01/22] board: ti: am62x: evm: Include necessary header files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit At the time of compilation evm.c gives below warning for implicit declaration of enable_caches, to mitigate this include cpu_func.h. board/ti/am62x/evm.c: In function ‘spl_board_init’: board/ti/am62x/evm.c:90:9: warning: implicit declaration of function ‘enable_caches’ [-Wimplicit-function-declaration] 90 | enable_caches(); Signed-off-by: Nikhil M Jain --- board/ti/am62x/evm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/board/ti/am62x/evm.c b/board/ti/am62x/evm.c index 34830f445f..f7afd4f378 100644 --- a/board/ti/am62x/evm.c +++ b/board/ti/am62x/evm.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include From 2b36c623ef0751e01b40b2443c14a4455feee8b4 Mon Sep 17 00:00:00 2001 From: Nikhil M Jain Date: Wed, 21 Jun 2023 16:29:53 +0530 Subject: [PATCH 02/22] common: splash_source: Fix type casting errors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit During compilation splash_source puts out below warning for type conversion in splash_load_fit for bmp_load_addr and fit_header. Change their type to uintptr_t to fix the warnings. common/splash_source.c: In function ‘splash_load_fit’: common/splash_source.c:366:22: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] 366 | img_header = (struct legacy_img_hdr *)bmp_load_addr; | ^ common/splash_source.c:376:49: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] 376 | res = splash_storage_read_raw(location, (u32)fit_header, fit_size); | ^ common/splash_source.c:401:25: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] 401 | memmove((void *)bmp_load_addr, internal_splash_data, internal_splash_size); The above warnings are generated if CONFIG_FIT is enabled. Signed-off-by: Nikhil M Jain --- common/splash_source.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/common/splash_source.c b/common/splash_source.c index a260137619..7223a1aae7 100644 --- a/common/splash_source.c +++ b/common/splash_source.c @@ -363,7 +363,7 @@ static int splash_load_fit(struct splash_location *location, u32 bmp_load_addr) if (res < 0) return res; - img_header = (struct legacy_img_hdr *)bmp_load_addr; + img_header = (struct legacy_img_hdr *)(uintptr_t)bmp_load_addr; if (image_get_magic(img_header) != FDT_MAGIC) { printf("Could not find FDT magic\n"); return -EINVAL; @@ -373,7 +373,7 @@ static int splash_load_fit(struct splash_location *location, u32 bmp_load_addr) /* Read in entire FIT */ fit_header = (const u32 *)(bmp_load_addr + header_size); - res = splash_storage_read_raw(location, (u32)fit_header, fit_size); + res = splash_storage_read_raw(location, (uintptr_t)fit_header, fit_size); if (res < 0) return res; @@ -398,7 +398,7 @@ static int splash_load_fit(struct splash_location *location, u32 bmp_load_addr) /* Extract the splash data from FIT */ /* 1. Test if splash is in FIT internal data. */ if (!fit_image_get_data(fit_header, node_offset, &internal_splash_data, &internal_splash_size)) - memmove((void *)bmp_load_addr, internal_splash_data, internal_splash_size); + memmove((void *)(uintptr_t)bmp_load_addr, internal_splash_data, internal_splash_size); /* 2. Test if splash is in FIT external data with fixed position. */ else if (!fit_image_get_data_position(fit_header, node_offset, &external_splash_addr)) is_splash_external = true; From 11626a33fadc32f1315a7b1c278a5d96257537b5 Mon Sep 17 00:00:00 2001 From: Vignesh Raghavendra Date: Sun, 2 Jul 2023 14:46:54 +0530 Subject: [PATCH 03/22] arm: mach-k3: am62a7_init: Open up FSS_DAT_REG3 firewall On security enforced (HS-SE) devices ROM firewalls OSPI data region3 that is present in above 64bit region. Open this up in bootloader to allow Linux to access OSPI flashes in mmap mode. Without this kernel will crash when accessing this region due to firewall violations on HS-SE devices. Signed-off-by: Vignesh Raghavendra --- arch/arm/mach-k3/am62a7_init.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/arm/mach-k3/am62a7_init.c b/arch/arm/mach-k3/am62a7_init.c index 1f51b04089..8ac834cffd 100644 --- a/arch/arm/mach-k3/am62a7_init.c +++ b/arch/arm/mach-k3/am62a7_init.c @@ -14,6 +14,10 @@ #include #include +struct fwl_data cbass_main_fwls[] = { + { "FSS_DAT_REG3", 7, 8 }, +}; + /* * This uninitialized global variable would normal end up in the .bss section, * but the .bss is cleared between writing and reading this variable, so move @@ -166,6 +170,9 @@ void board_init_f(ulong dummy) /* Output System Firmware version info */ k3_sysfw_print_ver(); + /* Disable ROM configured firewalls right after loading sysfw */ + remove_fwl_configs(cbass_main_fwls, ARRAY_SIZE(cbass_main_fwls)); + #if defined(CONFIG_K3_AM62A_DDRSS) ret = uclass_get_device(UCLASS_RAM, 0, &dev); if (ret) From d50f82815d473e6d78cca458d4a8648ae65dd5e4 Mon Sep 17 00:00:00 2001 From: Nishanth Menon Date: Thu, 13 Jul 2023 14:36:34 -0500 Subject: [PATCH 04/22] arm: mach-k3: *: dev-data: Update to use ARRAY_SIZE Instead of hard-coding the count of entries manually, use ARRAY_SIZE to keep the count updates appropriately. Cc: Bryan Brattlof Suggested-by: Ravi Gunasekaran Signed-off-by: Nishanth Menon Reviewed-by: Bryan Brattlof Reviewed-by: Siddharth Vadapalli --- arch/arm/mach-k3/am62ax/dev-data.c | 8 ++++---- arch/arm/mach-k3/am62x/dev-data.c | 8 ++++---- arch/arm/mach-k3/j7200/dev-data.c | 8 ++++---- arch/arm/mach-k3/j721e/dev-data.c | 8 ++++---- arch/arm/mach-k3/j721s2/dev-data.c | 8 ++++---- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/arch/arm/mach-k3/am62ax/dev-data.c b/arch/arm/mach-k3/am62ax/dev-data.c index 74739c6385..abf5d8e91a 100644 --- a/arch/arm/mach-k3/am62ax/dev-data.c +++ b/arch/arm/mach-k3/am62ax/dev-data.c @@ -66,8 +66,8 @@ const struct ti_k3_pd_platdata am62ax_pd_platdata = { .pd = soc_pd_list, .lpsc = soc_lpsc_list, .devs = soc_dev_list, - .num_psc = 2, - .num_pd = 4, - .num_lpsc = 14, - .num_devs = 19, + .num_psc = ARRAY_SIZE(soc_psc_list), + .num_pd = ARRAY_SIZE(soc_pd_list), + .num_lpsc = ARRAY_SIZE(soc_lpsc_list), + .num_devs = ARRAY_SIZE(soc_dev_list), }; diff --git a/arch/arm/mach-k3/am62x/dev-data.c b/arch/arm/mach-k3/am62x/dev-data.c index 616d0650b9..1a6f9e2ca0 100644 --- a/arch/arm/mach-k3/am62x/dev-data.c +++ b/arch/arm/mach-k3/am62x/dev-data.c @@ -71,8 +71,8 @@ const struct ti_k3_pd_platdata am62x_pd_platdata = { .pd = soc_pd_list, .lpsc = soc_lpsc_list, .devs = soc_dev_list, - .num_psc = 2, - .num_pd = 5, - .num_lpsc = 16, - .num_devs = 21, + .num_psc = ARRAY_SIZE(soc_psc_list), + .num_pd = ARRAY_SIZE(soc_pd_list), + .num_lpsc = ARRAY_SIZE(soc_lpsc_list), + .num_devs = ARRAY_SIZE(soc_dev_list), }; diff --git a/arch/arm/mach-k3/j7200/dev-data.c b/arch/arm/mach-k3/j7200/dev-data.c index c1a4dab694..4ddc34210e 100644 --- a/arch/arm/mach-k3/j7200/dev-data.c +++ b/arch/arm/mach-k3/j7200/dev-data.c @@ -75,8 +75,8 @@ const struct ti_k3_pd_platdata j7200_pd_platdata = { .pd = soc_pd_list, .lpsc = soc_lpsc_list, .devs = soc_dev_list, - .num_psc = 2, - .num_pd = 6, - .num_lpsc = 17, - .num_devs = 23, + .num_psc = ARRAY_SIZE(soc_psc_list), + .num_pd = ARRAY_SIZE(soc_pd_list), + .num_lpsc = ARRAY_SIZE(soc_lpsc_list), + .num_devs = ARRAY_SIZE(soc_dev_list), }; diff --git a/arch/arm/mach-k3/j721e/dev-data.c b/arch/arm/mach-k3/j721e/dev-data.c index f0afa3552b..97f017f8af 100644 --- a/arch/arm/mach-k3/j721e/dev-data.c +++ b/arch/arm/mach-k3/j721e/dev-data.c @@ -73,8 +73,8 @@ const struct ti_k3_pd_platdata j721e_pd_platdata = { .pd = soc_pd_list, .lpsc = soc_lpsc_list, .devs = soc_dev_list, - .num_psc = 2, - .num_pd = 5, - .num_lpsc = 16, - .num_devs = 23, + .num_psc = ARRAY_SIZE(soc_psc_list), + .num_pd = ARRAY_SIZE(soc_pd_list), + .num_lpsc = ARRAY_SIZE(soc_lpsc_list), + .num_devs = ARRAY_SIZE(soc_dev_list), }; diff --git a/arch/arm/mach-k3/j721s2/dev-data.c b/arch/arm/mach-k3/j721s2/dev-data.c index 35e8b17eb1..8c999a3c5a 100644 --- a/arch/arm/mach-k3/j721s2/dev-data.c +++ b/arch/arm/mach-k3/j721s2/dev-data.c @@ -79,8 +79,8 @@ const struct ti_k3_pd_platdata j721s2_pd_platdata = { .pd = soc_pd_list, .lpsc = soc_lpsc_list, .devs = soc_dev_list, - .num_psc = 2, - .num_pd = 6, - .num_lpsc = 19, - .num_devs = 25, + .num_psc = ARRAY_SIZE(soc_psc_list), + .num_pd = ARRAY_SIZE(soc_pd_list), + .num_lpsc = ARRAY_SIZE(soc_lpsc_list), + .num_devs = ARRAY_SIZE(soc_dev_list), }; From f40f54bfeda228811038e0470abba888b20565c9 Mon Sep 17 00:00:00 2001 From: Nishanth Menon Date: Thu, 13 Jul 2023 14:40:51 -0500 Subject: [PATCH 05/22] arm: dts: Fix build of am62a7 dtbs am62a7 should be built with CONFIG_SOC_K3_AM62A7 not CONFIG_SOC_K3_AM625 Fixes: 6bdfa69155d8 ("arm: dts: introduce am62a7 u-boot dtbs") Cc: Bryan Brattlof Cc: Vignesh Raghavendra Cc: Francesco Dolcini Cc: Sjoerd Simons Cc: Wadim Egorov Reviewed-by: Bryan Brattlof Reviewed-by: Mattijs Korpershoek Signed-off-by: Nishanth Menon --- arch/arm/dts/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile index b13b26b861..b7780de776 100644 --- a/arch/arm/dts/Makefile +++ b/arch/arm/dts/Makefile @@ -1306,7 +1306,7 @@ dtb-$(CONFIG_SOC_K3_AM642) += k3-am642-evm.dtb \ dtb-$(CONFIG_SOC_K3_AM625) += k3-am625-sk.dtb \ k3-am625-r5-sk.dtb -dtb-$(CONFIG_SOC_K3_AM625) += k3-am62a7-sk.dtb \ +dtb-$(CONFIG_SOC_K3_AM62A7) += k3-am62a7-sk.dtb \ k3-am62a7-r5-sk.dtb dtb-$(CONFIG_ARCH_MEDIATEK) += \ From 7b7288df3415c7faa4a305b814bb8932876b2149 Mon Sep 17 00:00:00 2001 From: Emanuele Ghidoli Date: Fri, 14 Jul 2023 17:23:08 +0200 Subject: [PATCH 06/22] arm: k3: Fix ft_system_setup so it can be enabled on any SoC ft_system_setup cannot be enabled on SoC without msmc sram otherwise fdt_fixup_msmc_ram function fails causing system reset. Fix by moving fdt_fixup_msmc_ram to common_fdt.c file and creating SoC (AM654, J721E and J721S2) specific files for fdt fixups. This change was verified to not change anything on any existing board (all the J721S2, AM654 and J721E boards requires it, none of the remaining k3 boards require it). Fixes: 30e96a240156 ("arm: mach-k3: Move MSMC fixup to SoC level") Signed-off-by: Emanuele Ghidoli Signed-off-by: Francesco Dolcini --- arch/arm/mach-k3/Makefile | 6 +++ arch/arm/mach-k3/am654_fdt.c | 12 +++++ arch/arm/mach-k3/common.c | 91 --------------------------------- arch/arm/mach-k3/common_fdt.c | 95 +++++++++++++++++++++++++++++++++++ arch/arm/mach-k3/common_fdt.h | 11 ++++ arch/arm/mach-k3/j721e_fdt.c | 12 +++++ arch/arm/mach-k3/j721s2_fdt.c | 12 +++++ 7 files changed, 148 insertions(+), 91 deletions(-) create mode 100644 arch/arm/mach-k3/am654_fdt.c create mode 100644 arch/arm/mach-k3/common_fdt.c create mode 100644 arch/arm/mach-k3/common_fdt.h create mode 100644 arch/arm/mach-k3/j721e_fdt.c create mode 100644 arch/arm/mach-k3/j721s2_fdt.c diff --git a/arch/arm/mach-k3/Makefile b/arch/arm/mach-k3/Makefile index b5bc236781..499bdaa715 100644 --- a/arch/arm/mach-k3/Makefile +++ b/arch/arm/mach-k3/Makefile @@ -10,6 +10,12 @@ obj-$(CONFIG_SOC_K3_AM62A7) += am62ax/ obj-$(CONFIG_ARM64) += arm64-mmu.o obj-$(CONFIG_CPU_V7R) += r5_mpu.o lowlevel_init.o obj-$(CONFIG_ARM64) += cache.o +obj-$(CONFIG_OF_LIBFDT) += common_fdt.o +ifeq ($(CONFIG_OF_LIBFDT)$(CONFIG_OF_SYSTEM_SETUP),yy) +obj-$(CONFIG_SOC_K3_AM654) += am654_fdt.o +obj-$(CONFIG_SOC_K3_J721E) += j721e_fdt.o +obj-$(CONFIG_SOC_K3_J721S2) += j721s2_fdt.o +endif ifeq ($(CONFIG_SPL_BUILD),y) obj-$(CONFIG_SOC_K3_AM654) += am654_init.o obj-$(CONFIG_SOC_K3_J721E) += j721e_init.o diff --git a/arch/arm/mach-k3/am654_fdt.c b/arch/arm/mach-k3/am654_fdt.c new file mode 100644 index 0000000000..652fe8d32b --- /dev/null +++ b/arch/arm/mach-k3/am654_fdt.c @@ -0,0 +1,12 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright 2023 Toradex - https://www.toradex.com/ + */ + +#include "common_fdt.h" +#include + +int ft_system_setup(void *blob, struct bd_info *bd) +{ + return fdt_fixup_msmc_ram_k3(blob); +} diff --git a/arch/arm/mach-k3/common.c b/arch/arm/mach-k3/common.c index bda01527d3..a38882bef0 100644 --- a/arch/arm/mach-k3/common.c +++ b/arch/arm/mach-k3/common.c @@ -357,97 +357,6 @@ void board_fit_image_post_process(const void *fit, int node, void **p_image, } #endif -#if defined(CONFIG_OF_LIBFDT) -int fdt_fixup_msmc_ram(void *blob, char *parent_path, char *node_name) -{ - u64 msmc_start = 0, msmc_end = 0, msmc_size, reg[2]; - struct ti_sci_handle *ti_sci = get_ti_sci_handle(); - int ret, node, subnode, len, prev_node; - u32 range[4], addr, size; - const fdt32_t *sub_reg; - - ti_sci->ops.core_ops.query_msmc(ti_sci, &msmc_start, &msmc_end); - msmc_size = msmc_end - msmc_start + 1; - debug("%s: msmc_start = 0x%llx, msmc_size = 0x%llx\n", __func__, - msmc_start, msmc_size); - - /* find or create "msmc_sram node */ - ret = fdt_path_offset(blob, parent_path); - if (ret < 0) - return ret; - - node = fdt_find_or_add_subnode(blob, ret, node_name); - if (node < 0) - return node; - - ret = fdt_setprop_string(blob, node, "compatible", "mmio-sram"); - if (ret < 0) - return ret; - - reg[0] = cpu_to_fdt64(msmc_start); - reg[1] = cpu_to_fdt64(msmc_size); - ret = fdt_setprop(blob, node, "reg", reg, sizeof(reg)); - if (ret < 0) - return ret; - - fdt_setprop_cell(blob, node, "#address-cells", 1); - fdt_setprop_cell(blob, node, "#size-cells", 1); - - range[0] = 0; - range[1] = cpu_to_fdt32(msmc_start >> 32); - range[2] = cpu_to_fdt32(msmc_start & 0xffffffff); - range[3] = cpu_to_fdt32(msmc_size); - ret = fdt_setprop(blob, node, "ranges", range, sizeof(range)); - if (ret < 0) - return ret; - - subnode = fdt_first_subnode(blob, node); - prev_node = 0; - - /* Look for invalid subnodes and delete them */ - while (subnode >= 0) { - sub_reg = fdt_getprop(blob, subnode, "reg", &len); - addr = fdt_read_number(sub_reg, 1); - sub_reg++; - size = fdt_read_number(sub_reg, 1); - debug("%s: subnode = %d, addr = 0x%x. size = 0x%x\n", __func__, - subnode, addr, size); - if (addr + size > msmc_size || - !strncmp(fdt_get_name(blob, subnode, &len), "sysfw", 5) || - !strncmp(fdt_get_name(blob, subnode, &len), "l3cache", 7)) { - fdt_del_node(blob, subnode); - debug("%s: deleting subnode %d\n", __func__, subnode); - if (!prev_node) - subnode = fdt_first_subnode(blob, node); - else - subnode = fdt_next_subnode(blob, prev_node); - } else { - prev_node = subnode; - subnode = fdt_next_subnode(blob, prev_node); - } - } - - return 0; -} - -#if defined(CONFIG_OF_SYSTEM_SETUP) -int ft_system_setup(void *blob, struct bd_info *bd) -{ - int ret; - - ret = fdt_fixup_msmc_ram(blob, "/bus@100000", "sram@70000000"); - if (ret < 0) - ret = fdt_fixup_msmc_ram(blob, "/interconnect@100000", - "sram@70000000"); - if (ret) - printf("%s: fixing up msmc ram failed %d\n", __func__, ret); - - return ret; -} -#endif - -#endif - #ifndef CONFIG_SYSRESET void reset_cpu(void) { diff --git a/arch/arm/mach-k3/common_fdt.c b/arch/arm/mach-k3/common_fdt.c new file mode 100644 index 0000000000..c86fe3a589 --- /dev/null +++ b/arch/arm/mach-k3/common_fdt.c @@ -0,0 +1,95 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright 2023 Toradex - https://www.toradex.com/ + */ + +#include "common.h" +#include +#include +#include + +static int fdt_fixup_msmc_ram(void *blob, char *parent_path, char *node_name) +{ + u64 msmc_start = 0, msmc_end = 0, msmc_size, reg[2]; + struct ti_sci_handle *ti_sci = get_ti_sci_handle(); + int ret, node, subnode, len, prev_node; + u32 range[4], addr, size; + const fdt32_t *sub_reg; + + ti_sci->ops.core_ops.query_msmc(ti_sci, &msmc_start, &msmc_end); + msmc_size = msmc_end - msmc_start + 1; + debug("%s: msmc_start = 0x%llx, msmc_size = 0x%llx\n", __func__, + msmc_start, msmc_size); + + /* find or create "msmc_sram node */ + ret = fdt_path_offset(blob, parent_path); + if (ret < 0) + return ret; + + node = fdt_find_or_add_subnode(blob, ret, node_name); + if (node < 0) + return node; + + ret = fdt_setprop_string(blob, node, "compatible", "mmio-sram"); + if (ret < 0) + return ret; + + reg[0] = cpu_to_fdt64(msmc_start); + reg[1] = cpu_to_fdt64(msmc_size); + ret = fdt_setprop(blob, node, "reg", reg, sizeof(reg)); + if (ret < 0) + return ret; + + fdt_setprop_cell(blob, node, "#address-cells", 1); + fdt_setprop_cell(blob, node, "#size-cells", 1); + + range[0] = 0; + range[1] = cpu_to_fdt32(msmc_start >> 32); + range[2] = cpu_to_fdt32(msmc_start & 0xffffffff); + range[3] = cpu_to_fdt32(msmc_size); + ret = fdt_setprop(blob, node, "ranges", range, sizeof(range)); + if (ret < 0) + return ret; + + subnode = fdt_first_subnode(blob, node); + prev_node = 0; + + /* Look for invalid subnodes and delete them */ + while (subnode >= 0) { + sub_reg = fdt_getprop(blob, subnode, "reg", &len); + addr = fdt_read_number(sub_reg, 1); + sub_reg++; + size = fdt_read_number(sub_reg, 1); + debug("%s: subnode = %d, addr = 0x%x. size = 0x%x\n", __func__, + subnode, addr, size); + if (addr + size > msmc_size || + !strncmp(fdt_get_name(blob, subnode, &len), "sysfw", 5) || + !strncmp(fdt_get_name(blob, subnode, &len), "l3cache", 7)) { + fdt_del_node(blob, subnode); + debug("%s: deleting subnode %d\n", __func__, subnode); + if (!prev_node) + subnode = fdt_first_subnode(blob, node); + else + subnode = fdt_next_subnode(blob, prev_node); + } else { + prev_node = subnode; + subnode = fdt_next_subnode(blob, prev_node); + } + } + + return 0; +} + +int fdt_fixup_msmc_ram_k3(void *blob) +{ + int ret; + + ret = fdt_fixup_msmc_ram(blob, "/bus@100000", "sram@70000000"); + if (ret < 0) + ret = fdt_fixup_msmc_ram(blob, "/interconnect@100000", + "sram@70000000"); + if (ret) + printf("%s: fixing up msmc ram failed %d\n", __func__, ret); + + return ret; +} diff --git a/arch/arm/mach-k3/common_fdt.h b/arch/arm/mach-k3/common_fdt.h new file mode 100644 index 0000000000..46c3dc5e11 --- /dev/null +++ b/arch/arm/mach-k3/common_fdt.h @@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright 2023 Toradex - https://www.toradex.com/ + */ + +#ifndef _COMMON_FDT_H +#define _COMMON_FDT_H + +int fdt_fixup_msmc_ram_k3(void *blob); + +#endif /* _COMMON_FDT_H */ diff --git a/arch/arm/mach-k3/j721e_fdt.c b/arch/arm/mach-k3/j721e_fdt.c new file mode 100644 index 0000000000..652fe8d32b --- /dev/null +++ b/arch/arm/mach-k3/j721e_fdt.c @@ -0,0 +1,12 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright 2023 Toradex - https://www.toradex.com/ + */ + +#include "common_fdt.h" +#include + +int ft_system_setup(void *blob, struct bd_info *bd) +{ + return fdt_fixup_msmc_ram_k3(blob); +} diff --git a/arch/arm/mach-k3/j721s2_fdt.c b/arch/arm/mach-k3/j721s2_fdt.c new file mode 100644 index 0000000000..652fe8d32b --- /dev/null +++ b/arch/arm/mach-k3/j721s2_fdt.c @@ -0,0 +1,12 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright 2023 Toradex - https://www.toradex.com/ + */ + +#include "common_fdt.h" +#include + +int ft_system_setup(void *blob, struct bd_info *bd) +{ + return fdt_fixup_msmc_ram_k3(blob); +} From de3db252314eaa942b7aa6abf37a62e866821fe5 Mon Sep 17 00:00:00 2001 From: Emanuele Ghidoli Date: Fri, 14 Jul 2023 17:23:09 +0200 Subject: [PATCH 07/22] arm: mach-k3: am62: Add CTRLMMR_WKUP_JTAG_DEVICE_ID register definition Add register address and relevant bitmasks and shifts. Allow reading these information: - device identification - number of cores (part of device identification) - features (currently: PRU / no PRU) - security - functional safety - speed grade - temperature grade - package Signed-off-by: Emanuele Ghidoli Signed-off-by: Francesco Dolcini Reviewed-by: Andrew Davis --- arch/arm/mach-k3/include/mach/am62_hardware.h | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/arch/arm/mach-k3/include/mach/am62_hardware.h b/arch/arm/mach-k3/include/mach/am62_hardware.h index 88d5894726..acd2d109c2 100644 --- a/arch/arm/mach-k3/include/mach/am62_hardware.h +++ b/arch/arm/mach-k3/include/mach/am62_hardware.h @@ -20,6 +20,28 @@ #define MCU_CTRL_MMR0_BASE 0x04500000 #define WKUP_CTRL_MMR0_BASE 0x43000000 +#define CTRLMMR_WKUP_JTAG_DEVICE_ID (WKUP_CTRL_MMR0_BASE + 0x18) +#define JTAG_DEV_ID_MASK GENMASK(31, 18) +#define JTAG_DEV_ID_SHIFT 18 +#define JTAG_DEV_CORE_NR_MASK GENMASK(21, 19) +#define JTAG_DEV_CORE_NR_SHIFT 19 +#define JTAG_DEV_GPU_MASK BIT(18) +#define JTAG_DEV_GPU_SHIFT 18 +#define JTAG_DEV_FEATURES_MASK GENMASK(17, 13) +#define JTAG_DEV_FEATURES_SHIFT 13 +#define JTAG_DEV_SECURITY_MASK BIT(12) +#define JTAG_DEV_SECURITY_SHIFT 12 +#define JTAG_DEV_SAFETY_MASK BIT(11) +#define JTAG_DEV_SAFETY_SHIFT 11 +#define JTAG_DEV_SPEED_MASK GENMASK(10, 6) +#define JTAG_DEV_SPEED_SHIFT 6 +#define JTAG_DEV_TEMP_MASK GENMASK(5, 3) +#define JTAG_DEV_TEMP_SHIFT 3 +#define JTAG_DEV_PKG_MASK GENMASK(2, 0) +#define JTAG_DEV_PKG_SHIFT 0 + +#define JTAG_DEV_FEATURE_NO_PRU 0x4 + #define CTRLMMR_MAIN_DEVSTAT (WKUP_CTRL_MMR0_BASE + 0x30) #define MAIN_DEVSTAT_PRIMARY_BOOTMODE_MASK GENMASK(6, 3) #define MAIN_DEVSTAT_PRIMARY_BOOTMODE_SHIFT 3 From 70aa5a94d451cc4beb7345f8fc1e777668acb816 Mon Sep 17 00:00:00 2001 From: Emanuele Ghidoli Date: Fri, 14 Jul 2023 17:23:10 +0200 Subject: [PATCH 08/22] arm: mach-k3: am62: Fixup CPU core, gpu and pru nodes in fdt AM62x SoC is available in multiple variant: - CPU cores (Cortex-A) AM62x1 (1 core), AM62x2 (2 cores), AM62x4 (4 cores) - GPU AM625x with GPU, AM623x without GPU - PRU (Programmable RT unit) can be present or not on AM62x2/AM62x4 Remove the relevant FDT nodes by reading the actual configuration from the SoC registers, with that change is possible to have a single dts/dtb file handling the different variant at runtime. While removing GPU node and CPU nodes also the watchdog node in the same Module Domain is removed. A similar approach is implemented for example on i.MX8 and STM32MP1 SoC. Signed-off-by: Emanuele Ghidoli Signed-off-by: Francesco Dolcini --- arch/arm/mach-k3/Makefile | 1 + arch/arm/mach-k3/am625_fdt.c | 71 +++++++++++++++++++++++++++++++++++ arch/arm/mach-k3/common_fdt.c | 18 +++++++++ 3 files changed, 90 insertions(+) create mode 100644 arch/arm/mach-k3/am625_fdt.c diff --git a/arch/arm/mach-k3/Makefile b/arch/arm/mach-k3/Makefile index 499bdaa715..fd77b8bbba 100644 --- a/arch/arm/mach-k3/Makefile +++ b/arch/arm/mach-k3/Makefile @@ -15,6 +15,7 @@ ifeq ($(CONFIG_OF_LIBFDT)$(CONFIG_OF_SYSTEM_SETUP),yy) obj-$(CONFIG_SOC_K3_AM654) += am654_fdt.o obj-$(CONFIG_SOC_K3_J721E) += j721e_fdt.o obj-$(CONFIG_SOC_K3_J721S2) += j721s2_fdt.o +obj-$(CONFIG_SOC_K3_AM625) += am625_fdt.o endif ifeq ($(CONFIG_SPL_BUILD),y) obj-$(CONFIG_SOC_K3_AM654) += am654_init.o diff --git a/arch/arm/mach-k3/am625_fdt.c b/arch/arm/mach-k3/am625_fdt.c new file mode 100644 index 0000000000..37806907af --- /dev/null +++ b/arch/arm/mach-k3/am625_fdt.c @@ -0,0 +1,71 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright 2023 Toradex - https://www.toradex.com/ + */ + +#include +#include "common_fdt.h" +#include + +static void fdt_fixup_cores_nodes_am625(void *blob, int core_nr) +{ + char node_path[32]; + + if (core_nr < 1) + return; + + for (; core_nr < 4; core_nr++) { + snprintf(node_path, sizeof(node_path), "/cpus/cpu@%d", core_nr); + fdt_del_node_path(blob, node_path); + snprintf(node_path, sizeof(node_path), "/cpus/cpu-map/cluster0/core%d", core_nr); + fdt_del_node_path(blob, node_path); + snprintf(node_path, sizeof(node_path), "/bus@f0000/watchdog@e0%d0000", core_nr); + fdt_del_node_path(blob, node_path); + } +} + +static void fdt_fixup_gpu_nodes_am625(void *blob, int has_gpu) +{ + if (!has_gpu) { + fdt_del_node_path(blob, "/bus@f0000/gpu@fd00000"); + fdt_del_node_path(blob, "/bus@f0000/watchdog@e0f0000"); + } +} + +static void fdt_fixup_pru_node_am625(void *blob, int has_pru) +{ + if (!has_pru) + fdt_del_node_path(blob, "/bus@f0000/pruss@30040000"); +} + +static int k3_get_core_nr(void) +{ + u32 full_devid = readl(CTRLMMR_WKUP_JTAG_DEVICE_ID); + + return (full_devid & JTAG_DEV_CORE_NR_MASK) >> JTAG_DEV_CORE_NR_SHIFT; +} + +static int k3_has_pru(void) +{ + u32 full_devid = readl(CTRLMMR_WKUP_JTAG_DEVICE_ID); + u32 feature_mask = (full_devid & JTAG_DEV_FEATURES_MASK) >> + JTAG_DEV_FEATURES_SHIFT; + + return !(feature_mask & JTAG_DEV_FEATURE_NO_PRU); +} + +static int k3_has_gpu(void) +{ + u32 full_devid = readl(CTRLMMR_WKUP_JTAG_DEVICE_ID); + + return (full_devid & JTAG_DEV_GPU_MASK) >> JTAG_DEV_GPU_SHIFT; +} + +int ft_system_setup(void *blob, struct bd_info *bd) +{ + fdt_fixup_cores_nodes_am625(blob, k3_get_core_nr()); + fdt_fixup_gpu_nodes_am625(blob, k3_has_gpu()); + fdt_fixup_pru_node_am625(blob, k3_has_pru()); + + return 0; +} diff --git a/arch/arm/mach-k3/common_fdt.c b/arch/arm/mach-k3/common_fdt.c index c86fe3a589..9478f60544 100644 --- a/arch/arm/mach-k3/common_fdt.c +++ b/arch/arm/mach-k3/common_fdt.c @@ -93,3 +93,21 @@ int fdt_fixup_msmc_ram_k3(void *blob) return ret; } + +int fdt_del_node_path(void *blob, const char *path) +{ + int ret; + int nodeoff; + + nodeoff = fdt_path_offset(blob, path); + if (nodeoff < 0) + return 0; /* Not found, skip it */ + + ret = fdt_del_node(blob, nodeoff); + if (ret < 0) + printf("Unable to delete node %s, err=%s\n", path, fdt_strerror(ret)); + else + debug("Deleted node %s\n", path); + + return ret; +} From 300e475967ca2e7461e3f42593451dab9014be15 Mon Sep 17 00:00:00 2001 From: Andrew Davis Date: Fri, 14 Jul 2023 14:00:58 -0500 Subject: [PATCH 09/22] configs: k2x_evm: Always include FIT loading support Non-HS boards can use FIT images so include the env var commands for these unconditionally. Signed-off-by: Andrew Davis Reviewed-by: Nishanth Menon --- include/configs/k2e_evm.h | 11 ++--------- include/configs/k2hk_evm.h | 11 ++--------- include/configs/k2l_evm.h | 11 ++--------- 3 files changed, 6 insertions(+), 27 deletions(-) diff --git a/include/configs/k2e_evm.h b/include/configs/k2e_evm.h index 929c9a26de..630dfdc5b7 100644 --- a/include/configs/k2e_evm.h +++ b/include/configs/k2e_evm.h @@ -11,18 +11,11 @@ #include -#ifdef CONFIG_TI_SECURE_DEVICE -#define DEFAULT_SEC_BOOT_ENV \ - DEFAULT_FIT_TI_ARGS \ - "findfdt=setenv fdtfile ${name_fdt}\0" -#else -#define DEFAULT_SEC_BOOT_ENV -#endif - /* U-Boot general configuration */ #define ENV_KS2_BOARD_SETTINGS \ DEFAULT_FW_INITRAMFS_BOOT_ENV \ - DEFAULT_SEC_BOOT_ENV \ + DEFAULT_FIT_TI_ARGS \ + "findfdt=setenv fdtfile ${name_fdt}\0" \ "boot=ubi\0" \ "args_ubi=setenv bootargs ${bootargs} rootfstype=ubifs " \ "root=ubi0:rootfs rootflags=sync rw ubi.mtd=ubifs,2048\0" \ diff --git a/include/configs/k2hk_evm.h b/include/configs/k2hk_evm.h index 05b4a3c204..ed54be839f 100644 --- a/include/configs/k2hk_evm.h +++ b/include/configs/k2hk_evm.h @@ -11,18 +11,11 @@ #include -#ifdef CONFIG_TI_SECURE_DEVICE -#define DEFAULT_SEC_BOOT_ENV \ - DEFAULT_FIT_TI_ARGS \ - "findfdt=setenv fdtfile ${name_fdt}\0" -#else -#define DEFAULT_SEC_BOOT_ENV -#endif - /* U-Boot general configuration */ #define ENV_KS2_BOARD_SETTINGS \ DEFAULT_FW_INITRAMFS_BOOT_ENV \ - DEFAULT_SEC_BOOT_ENV \ + DEFAULT_FIT_TI_ARGS \ + "findfdt=setenv fdtfile ${name_fdt}\0" \ "boot=ubi\0" \ "args_ubi=setenv bootargs ${bootargs} rootfstype=ubifs " \ "root=ubi0:rootfs rootflags=sync rw ubi.mtd=ubifs,2048\0" \ diff --git a/include/configs/k2l_evm.h b/include/configs/k2l_evm.h index b1b839b504..69d42eaf9f 100644 --- a/include/configs/k2l_evm.h +++ b/include/configs/k2l_evm.h @@ -11,18 +11,11 @@ #include -#ifdef CONFIG_TI_SECURE_DEVICE -#define DEFAULT_SEC_BOOT_ENV \ - DEFAULT_FIT_TI_ARGS \ - "findfdt=setenv fdtfile ${name_fdt}\0" -#else -#define DEFAULT_SEC_BOOT_ENV -#endif - /* U-Boot general configuration */ #define ENV_KS2_BOARD_SETTINGS \ DEFAULT_FW_INITRAMFS_BOOT_ENV \ - DEFAULT_SEC_BOOT_ENV \ + DEFAULT_FIT_TI_ARGS \ + "findfdt=setenv fdtfile ${name_fdt}\0" \ "boot=ubi\0" \ "args_ubi=setenv bootargs ${bootargs} rootfstype=ubifs " \ "root=ubi0:rootfs rootflags=sync rw ubi.mtd=ubifs,4096\0" \ From 7c97b715e920bc41f628b39925ac829ff9cf7d8f Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Mon, 17 Jul 2023 15:26:43 -0400 Subject: [PATCH 10/22] arm: omap2: Fix warning in force_emif_self_refresh The function declaration for force_emif_self_refresh takes no parameters but does not specify this, only the prototype in the headers do. As clang will warn about this, correct it. Signed-off-by: Tom Rini --- arch/arm/mach-omap2/emif-common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/mach-omap2/emif-common.c b/arch/arm/mach-omap2/emif-common.c index a6a97af37d..9daaeef731 100644 --- a/arch/arm/mach-omap2/emif-common.c +++ b/arch/arm/mach-omap2/emif-common.c @@ -40,7 +40,7 @@ void set_lpmode_selfrefresh(u32 base) readl(&emif->emif_pwr_mgmt_ctrl); } -void force_emif_self_refresh() +void force_emif_self_refresh(void) { set_lpmode_selfrefresh(EMIF1_BASE); if (!is_dra72x()) From af7c33c103450e06aecf8adba8cbc8c522295be1 Mon Sep 17 00:00:00 2001 From: Bryan Brattlof Date: Mon, 17 Jul 2023 17:15:26 -0500 Subject: [PATCH 11/22] ram: k3-ddrss: do not touch ctrl regs during training During LPDDR initialization we will loop through a series of frequency changes in order to train at the various operating frequencies. During this training, accessing the DRAM_CLASS bitfield could happen during a frequency change and cause the read to hang. Store the DRAM type into the main structure to avoid multiple readings while the independent phy is training. Signed-off-by: Bryan Brattlof --- drivers/ram/k3-ddrss/k3-ddrss.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/ram/k3-ddrss/k3-ddrss.c b/drivers/ram/k3-ddrss/k3-ddrss.c index 7e445d2b73..b54557f02c 100644 --- a/drivers/ram/k3-ddrss/k3-ddrss.c +++ b/drivers/ram/k3-ddrss/k3-ddrss.c @@ -138,6 +138,7 @@ struct k3_ddrss_desc { u32 ddr_freq1; u32 ddr_freq2; u32 ddr_fhs_cnt; + u32 dram_class; struct udevice *vtt_supply; u32 instance; lpddr4_obj *driverdt; @@ -243,14 +244,11 @@ static void k3_lpddr4_freq_update(struct k3_ddrss_desc *ddrss) static void k3_lpddr4_ack_freq_upd_req(const lpddr4_privatedata *pd) { - u32 dram_class; struct k3_ddrss_desc *ddrss = (struct k3_ddrss_desc *)pd->ddr_instance; debug("--->>> LPDDR4 Initialization is in progress ... <<<---\n"); - dram_class = k3_lpddr4_read_ddr_type(pd); - - switch (dram_class) { + switch (ddrss->dram_class) { case DENALI_CTL_0_DRAM_CLASS_DDR4: break; case DENALI_CTL_0_DRAM_CLASS_LPDDR4: @@ -263,13 +261,12 @@ static void k3_lpddr4_ack_freq_upd_req(const lpddr4_privatedata *pd) static int k3_ddrss_init_freq(struct k3_ddrss_desc *ddrss) { - u32 dram_class; int ret; lpddr4_privatedata *pd = &ddrss->pd; - dram_class = k3_lpddr4_read_ddr_type(pd); + ddrss->dram_class = k3_lpddr4_read_ddr_type(pd); - switch (dram_class) { + switch (ddrss->dram_class) { case DENALI_CTL_0_DRAM_CLASS_DDR4: /* Set to ddr_freq1 from DT for DDR4 */ ret = clk_set_rate(&ddrss->ddr_clk, ddrss->ddr_freq1); From efda93c6b5aa57f06a8abda0626954cdc670320a Mon Sep 17 00:00:00 2001 From: Bryan Brattlof Date: Mon, 17 Jul 2023 18:01:33 -0500 Subject: [PATCH 12/22] arm: mach-k3: am62a7: change some prints to debug prints There is little need to print the devstat information or when we exit a function during a typical boot. Remove them to reduce the noise during typical operation Signed-off-by: Bryan Brattlof --- arch/arm/mach-k3/am62a7_init.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm/mach-k3/am62a7_init.c b/arch/arm/mach-k3/am62a7_init.c index 8ac834cffd..d72e19936b 100644 --- a/arch/arm/mach-k3/am62a7_init.c +++ b/arch/arm/mach-k3/am62a7_init.c @@ -181,7 +181,7 @@ void board_init_f(ulong dummy) setup_qos(); - printf("am62a_init: %s done\n", __func__); + debug("am62a_init: %s done\n", __func__); } static u32 __get_backup_bootmedia(u32 devstat) @@ -279,7 +279,7 @@ u32 spl_boot_device(void) else bootmedia = __get_backup_bootmedia(devstat); - printf("am62a_init: %s: devstat = 0x%x bootmedia = 0x%x bootindex = %d\n", + debug("am62a_init: %s: devstat = 0x%x bootmedia = 0x%x bootindex = %d\n", __func__, devstat, bootmedia, bootindex); return bootmedia; } From 149fb05b8346e6ac37df594ef0427cecff09053c Mon Sep 17 00:00:00 2001 From: Nikhil M Jain Date: Tue, 18 Jul 2023 14:27:27 +0530 Subject: [PATCH 13/22] common: spl: spl: Update stack pointer address At SPL stage when stack is relocated, the stack pointer needs to be updated, the stack pointer may point to stack in on chip memory even though stack is relocated. Signed-off-by: Nikhil M Jain Reviewed-by: Tom Rini --- common/spl/spl.c | 1 + 1 file changed, 1 insertion(+) diff --git a/common/spl/spl.c b/common/spl/spl.c index d74acec10b..d45dd1c923 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -992,6 +992,7 @@ ulong spl_relocate_stack_gd(void) #endif /* Get stack position: use 8-byte alignment for ABI compliance */ ptr = CONFIG_SPL_STACK_R_ADDR - roundup(sizeof(gd_t),16); + gd->start_addr_sp = ptr; new_gd = (gd_t *)ptr; memcpy(new_gd, (void *)gd, sizeof(gd_t)); #if CONFIG_IS_ENABLED(DM) From dd5d1c5dcc4d1868e0b82f26db2ea53c63bd15de Mon Sep 17 00:00:00 2001 From: Nikhil M Jain Date: Tue, 18 Jul 2023 14:27:28 +0530 Subject: [PATCH 14/22] arch: arm: mach-k3: common: Return a pointer after setting page table In spl_dcache_enable after setting up page table, set gd->relocaddr pointer to tlb_addr, to get next location to reserve memory. Align tlb_addr with 64KB address. Signed-off-by: Nikhil M Jain Reviewed-by: Devarsh Thakkar --- arch/arm/mach-k3/common.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm/mach-k3/common.c b/arch/arm/mach-k3/common.c index a38882bef0..450c7b7e4c 100644 --- a/arch/arm/mach-k3/common.c +++ b/arch/arm/mach-k3/common.c @@ -538,8 +538,10 @@ void spl_enable_dcache(void) ram_top = (phys_addr_t) 0x100000000; gd->arch.tlb_addr = ram_top - gd->arch.tlb_size; + gd->arch.tlb_addr &= ~(0x10000 - 1); debug("TLB table from %08lx to %08lx\n", gd->arch.tlb_addr, gd->arch.tlb_addr + gd->arch.tlb_size); + gd->relocaddr = gd->arch.tlb_addr; dcache_enable(); #endif From 12fdacea5a6608a9b77a3437e692b9e2ff5c807c Mon Sep 17 00:00:00 2001 From: Nikhil M Jain Date: Tue, 18 Jul 2023 14:27:29 +0530 Subject: [PATCH 15/22] board: ti: am62x: evm: Update function calls for splash screen Use spl_dcache_enable, in place of setup_dram, arch_reserve_mmu to set up pagetable, initialise DRAM and enable Dcache to avoid multiple function calls. Check for CONFIG_SPL_VIDEO in place of CONFIG_SPL_VIDEO_TIDSS to prevent any build failure in case video config is not defined and video related functions are called. Check for CONFIG_SPL_SPLASH_SCREEN and CONFIG_SPL_BMP before calling splash_display to avoid compilation failure. Signed-off-by: Nikhil M Jain --- arch/arm/mach-k3/am625_init.c | 1 + board/ti/am62x/evm.c | 41 +++++++++++++---------------------- 2 files changed, 16 insertions(+), 26 deletions(-) diff --git a/arch/arm/mach-k3/am625_init.c b/arch/arm/mach-k3/am625_init.c index 787fe92295..0e5d44269e 100644 --- a/arch/arm/mach-k3/am625_init.c +++ b/arch/arm/mach-k3/am625_init.c @@ -214,6 +214,7 @@ void board_init_f(ulong dummy) if (ret) panic("DRAM init failed: %d\n", ret); #endif + spl_enable_dcache(); } u32 spl_mmc_boot_mode(struct mmc *mmc, const u32 boot_device) diff --git a/board/ti/am62x/evm.c b/board/ti/am62x/evm.c index f7afd4f378..ad93908840 100644 --- a/board/ti/am62x/evm.c +++ b/board/ti/am62x/evm.c @@ -60,42 +60,31 @@ int dram_init_banksize(void) } #if defined(CONFIG_SPL_BUILD) -#ifdef CONFIG_SPL_VIDEO_TIDSS -static int setup_dram(void) -{ - dram_init(); - dram_init_banksize(); - gd->ram_base = CFG_SYS_SDRAM_BASE; - gd->ram_top = gd->ram_base + gd->ram_size; - gd->relocaddr = gd->ram_top; - return 0; -} - static int video_setup(void) { - ulong addr; - int ret; - addr = gd->relocaddr; + if (CONFIG_IS_ENABLED(VIDEO)) { + ulong addr; + int ret; + + addr = gd->relocaddr; + ret = video_reserve(&addr); + if (ret) + return ret; + debug("Reserving %luk for video at: %08lx\n", + ((unsigned long)gd->relocaddr - addr) >> 10, addr); + gd->relocaddr = addr; + } - ret = video_reserve(&addr); - if (ret) - return ret; - debug("Reserving %luk for video at: %08lx\n", - ((unsigned long)gd->relocaddr - addr) >> 10, addr); - gd->relocaddr = addr; return 0; } -#endif void spl_board_init(void) { -#if defined(CONFIG_SPL_VIDEO_TIDSS) - setup_dram(); - arch_reserve_mmu(); video_setup(); enable_caches(); - splash_display(); -#endif + if (IS_ENABLED(CONFIG_SPL_SPLASH_SCREEN) && IS_ENABLED(CONFIG_SPL_BMP)) + splash_display(); + } #if defined(CONFIG_K3_AM64_DDRSS) From ccd21ee50e41305ec3d35d5dc2b40277102cfd85 Mon Sep 17 00:00:00 2001 From: Nikhil M Jain Date: Tue, 18 Jul 2023 14:27:30 +0530 Subject: [PATCH 16/22] include: video: Reserve video using blob Add method to reserve video framebuffer information using blob, received from previous stage. Signed-off-by: Nikhil M Jain Reviewed-by: Simon Glass --- drivers/video/video-uclass.c | 11 +++++++++++ include/video.h | 9 +++++++++ 2 files changed, 20 insertions(+) diff --git a/drivers/video/video-uclass.c b/drivers/video/video-uclass.c index 95e874b770..435dab1f19 100644 --- a/drivers/video/video-uclass.c +++ b/drivers/video/video-uclass.c @@ -194,6 +194,17 @@ int video_fill_part(struct udevice *dev, int xstart, int ystart, int xend, return 0; } +int video_reserve_from_bloblist(struct video_handoff *ho) +{ + gd->video_bottom = ho->fb; + gd->fb_base = ho->fb; + gd->video_top = ho->fb + ho->size; + debug("Reserving %luk for video using blob at: %08x\n", + ((unsigned long)ho->size) >> 10, (u32)ho->fb); + + return 0; +} + int video_fill(struct udevice *dev, u32 colour) { struct video_priv *priv = dev_get_uclass_priv(dev); diff --git a/include/video.h b/include/video.h index 9729fa348a..269915160b 100644 --- a/include/video.h +++ b/include/video.h @@ -406,4 +406,13 @@ int bmp_display(ulong addr, int x, int y); */ int bmp_info(ulong addr); +/* + * video_reserve_from_bloblist()- Reserve frame-buffer memory for video devices + * using blobs. + * + * @ho: video information passed from SPL + * Returns: 0 (always) + */ +int video_reserve_from_bloblist(struct video_handoff *ho); + #endif From 5bc610a7d9d1ea1b83aaab7ca54ef847087d7167 Mon Sep 17 00:00:00 2001 From: Nikhil M Jain Date: Tue, 18 Jul 2023 14:27:31 +0530 Subject: [PATCH 17/22] common: board_f: Pass frame buffer info from SPL to u-boot U-boot proper can use frame buffer address passed from SPL to reserve the memory area used by framebuffer set in SPL so that splash image set in SPL continues to get displayed while u-boot proper is running. Put the framebuffer address and size in a bloblist to make them available at u-boot proper, if in u-boot proper CONFIG_VIDEO is defined. Signed-off-by: Nikhil M Jain Reviewed-by: Devarsh Thakkar Reviewed-by: Simon Glass --- common/board_f.c | 11 ++++++++++- drivers/video/video-uclass.c | 12 ++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/common/board_f.c b/common/board_f.c index e5969ec9a2..7d2c380e91 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -411,7 +411,16 @@ __weak int arch_reserve_mmu(void) static int reserve_video(void) { - if (IS_ENABLED(CONFIG_VIDEO)) { + if (IS_ENABLED(CONFIG_SPL_VIDEO) && spl_phase() > PHASE_SPL && + CONFIG_IS_ENABLED(BLOBLIST)) { + struct video_handoff *ho; + + ho = bloblist_find(BLOBLISTT_U_BOOT_VIDEO, sizeof(*ho)); + if (!ho) + return log_msg_ret("blf", -ENOENT); + video_reserve_from_bloblist(ho); + gd->relocaddr = ho->fb; + } else if (CONFIG_IS_ENABLED(VIDEO)) { ulong addr; int ret; diff --git a/drivers/video/video-uclass.c b/drivers/video/video-uclass.c index 435dab1f19..949595f1bc 100644 --- a/drivers/video/video-uclass.c +++ b/drivers/video/video-uclass.c @@ -6,12 +6,14 @@ #define LOG_CATEGORY UCLASS_VIDEO #include +#include #include #include #include #include #include #include +#include #include #include #include @@ -139,6 +141,16 @@ int video_reserve(ulong *addrp) debug("Video frame buffers from %lx to %lx\n", gd->video_bottom, gd->video_top); + if (spl_phase() == PHASE_SPL && CONFIG_IS_ENABLED(BLOBLIST)) { + struct video_handoff *ho; + + ho = bloblist_add(BLOBLISTT_U_BOOT_VIDEO, sizeof(*ho), 0); + if (!ho) + return log_msg_ret("blf", -ENOENT); + ho->fb = *addrp; + ho->size = size; + } + return 0; } From 63e73a13e994e5aa960418f02b148d023719021e Mon Sep 17 00:00:00 2001 From: Nikhil M Jain Date: Tue, 18 Jul 2023 14:27:32 +0530 Subject: [PATCH 18/22] drivers: video: Kconfig: Add config remove video This is required since user may want to either call the remove method of video driver and reset the display or not call the remove method to continue displaying until next stage. Signed-off-by: Nikhil M Jain Reviewed-by: Devarsh Thakkar Reviewed-by: Tom Rini --- drivers/video/Kconfig | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig index b8147f280c..b41dc60cec 100644 --- a/drivers/video/Kconfig +++ b/drivers/video/Kconfig @@ -871,6 +871,12 @@ config IHS_VIDEO_OUT out On-screen Display (OSD) used on gdsys FPGAs to control dynamic textual overlays of the display outputs. +config VIDEO_REMOVE + bool "Remove video driver" + help + Use this option to specify if user wants to call remove method of + video driver in u-boot proper stage. + config SPLASH_SCREEN bool "Show a splash-screen image" help @@ -1094,6 +1100,12 @@ config SPL_SYS_WHITE_ON_BLACK This can be better in low-light situations or to reduce eye strain in some cases. +config SPL_VIDEO_REMOVE + bool "Remove video driver after SPL stage" + help + if this option is enabled video driver will be removed at the end of + SPL stage, beforeloading the next stage. + if SPL_SPLASH_SCREEN config SPL_SPLASH_SCREEN_ALIGN From 954b0ad4a228112f68cf96522e93f4b30c7b6117 Mon Sep 17 00:00:00 2001 From: Nikhil M Jain Date: Tue, 18 Jul 2023 14:27:33 +0530 Subject: [PATCH 19/22] common: spl: spl: Remove video driver Use config SPL_VIDEO_REMOVE to remove video driver at SPL stage before jumping to next stage, in place of CONFIG_SPL_VIDEO, to allow user to remove video if required. Signed-off-by: Nikhil M Jain Reviewed-by: Devarsh Thakkar Reviewed-by: Simon Glass --- common/spl/spl.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/common/spl/spl.c b/common/spl/spl.c index d45dd1c923..f09bb97781 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -891,18 +891,18 @@ void board_init_r(gd_t *dummy1, ulong dummy2) debug("Failed to stash bootstage: err=%d\n", ret); #endif -#if defined(CONFIG_SPL_VIDEO) - struct udevice *dev; - int rc; + if (IS_ENABLED(CONFIG_SPL_VIDEO_REMOVE)) { + struct udevice *dev; + int rc; - rc = uclass_find_device(UCLASS_VIDEO, 0, &dev); - if (!rc && dev) { - rc = device_remove(dev, DM_REMOVE_NORMAL); - if (rc) - printf("Cannot remove video device '%s' (err=%d)\n", - dev->name, rc); + rc = uclass_find_device(UCLASS_VIDEO, 0, &dev); + if (!rc && dev) { + rc = device_remove(dev, DM_REMOVE_NORMAL); + if (rc) + printf("Cannot remove video device '%s' (err=%d)\n", + dev->name, rc); + } } -#endif spl_board_prepare_for_boot(); jump_to_image_no_args(&spl_image); From 1f7682383f4334afc21ea62b072392955d201d62 Mon Sep 17 00:00:00 2001 From: Nikhil M Jain Date: Tue, 18 Jul 2023 14:27:34 +0530 Subject: [PATCH 20/22] configs: am62x_evm_a53: Add bloblist address Set bloblist address to 0x80D00000. Signed-off-by: Nikhil M Jain Reviewed-by: Devarsh Thakkar --- configs/am62x_evm_a53_defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/configs/am62x_evm_a53_defconfig b/configs/am62x_evm_a53_defconfig index 7c3bc184cf..5c572dfb33 100644 --- a/configs/am62x_evm_a53_defconfig +++ b/configs/am62x_evm_a53_defconfig @@ -102,3 +102,4 @@ CONFIG_SYSRESET=y CONFIG_SPL_SYSRESET=y CONFIG_SYSRESET_TI_SCI=y CONFIG_FS_FAT_MAX_CLUSTSIZE=16384 +CONFIG_BLOBLIST_ADDR=0x80D00000 From a72532fa194ed31b559bdd8b287854df0a4903f8 Mon Sep 17 00:00:00 2001 From: Nikhil M Jain Date: Tue, 18 Jul 2023 14:27:35 +0530 Subject: [PATCH 21/22] doc: board: ti: am62x_sk: Add A53 SPL DDR layout To understand usage of DDR in A53 SPL stage, add a table showing region and space used by major components of SPL. Signed-off-by: Nikhil M Jain Reviewed-by: Tom Rini --- doc/board/ti/am62x_sk.rst | 57 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/doc/board/ti/am62x_sk.rst b/doc/board/ti/am62x_sk.rst index 27d7b527c6..8642bdf16d 100644 --- a/doc/board/ti/am62x_sk.rst +++ b/doc/board/ti/am62x_sk.rst @@ -230,6 +230,63 @@ Image formats: | +-------------------+ | +-----------------------+ +A53 SPL DDR Memory Layout +------------------------- + +This provides an overview memory usage in A53 SPL stage. + +.. list-table:: + :widths: 16 16 16 + :header-rows: 1 + + * - Region + - Start Address + - End Address + + * - EMPTY + - 0x80000000 + - 0x80080000 + + * - TEXT BASE + - 0x80080000 + - 0x800d8000 + + * - EMPTY + - 0x800d8000 + - 0x80200000 + + * - BMP IMAGE + - 0x80200000 + - 0x80b77660 + + * - STACK + - 0x80b77660 + - 0x80b77e60 + + * - GD + - 0x80b77e60 + - 0x80b78000 + + * - MALLOC + - 0x80b78000 + - 0x80b80000 + + * - EMPTY + - 0x80b80000 + - 0x80c80000 + + * - BSS + - 0x80c80000 + - 0x80d00000 + + * - BLOBS + - 0x80d00000 + - 0x80d00400 + + * - EMPTY + - 0x80d00400 + - 0x81000000 + Switch Setting for Boot Mode ---------------------------- From 373991d6939b01c47b352b1f620ef772419a9cf4 Mon Sep 17 00:00:00 2001 From: Samuel Dionne-Riel Date: Tue, 18 Jul 2023 14:27:36 +0530 Subject: [PATCH 22/22] common: Kconfig: Fix CMD_BMP/BMP dependency Using `default y` will not select BMP when CMD_BMP has been enabled, if it was already configured. By using `select`, if `CMD_BMP` is turned on, it will force the presence of `BMP`. Fixes: 072b0e16c4 ("common: Kconfig: Add BMP configs") Signed-off-by: Samuel Dionne-Riel Signed-off-by: Nikhil M Jain --- cmd/Kconfig | 1 + common/Kconfig | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/Kconfig b/cmd/Kconfig index ecfd575237..2d6e5f993f 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -2005,6 +2005,7 @@ config CMD_2048 config CMD_BMP bool "Enable 'bmp' command" depends on VIDEO + select BMP help This provides a way to obtain information about a BMP-format image and to display it. BMP (which presumably stands for BitMaP) is a diff --git a/common/Kconfig b/common/Kconfig index f5ad63ce16..973482f075 100644 --- a/common/Kconfig +++ b/common/Kconfig @@ -1167,7 +1167,6 @@ config IO_TRACE config BMP bool "Enable bmp image display" - default y if CMD_BMP help Enable bmp functions to display bmp image and get bmp info.