From 7fce7396659c162f55b1747d84599d822b11c6a7 Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Thu, 9 Jul 2020 14:09:52 +0200 Subject: lib: fdt: Introduce fdtdec_setup_mem_size_base_lowest() New function should be called from board dram_init() because it initialized gd->ram_base/ram_size. It finds the lowest available memory. On systems with multiple memory nodes finding out the first memory node by fdtdec_setup_mem_size_base() is not enough because this memory can be above actual U-Boot VA mapping. Currently only mapping till 39bit is supported (Full 44bit mapping was removed by commit 7985cdf74b28 ("arm64: Remove non-full-va map code")). If DT starts with the first memory node above 39bit address then system can be unpredictable. The function is available only when multiple memory bank support is enabled. Calling fdtdec_setup_memory_banksize() from dram_init() is not possible because fdtdec_setup_memory_banksize() is saving dram information to bd structure which is placed on stack but not initialized at this time. Also stack is placed at location setup in dram_init(). Signed-off-by: Michal Simek Reviewed-by: Simon Glass --- include/fdtdec.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'include') diff --git a/include/fdtdec.h b/include/fdtdec.h index 760b392bdfb..bc79389260a 100644 --- a/include/fdtdec.h +++ b/include/fdtdec.h @@ -926,6 +926,23 @@ int fdtdec_decode_display_timing(const void *blob, int node, int index, */ int fdtdec_setup_mem_size_base(void); +/** + * fdtdec_setup_mem_size_base_lowest() - decode and setup gd->ram_size and + * gd->ram_start by lowest available memory base + * + * Decode the /memory 'reg' property to determine the lowest start of the memory + * bank bank and populate the global data with it. + * + * This function should be called from a boards dram_init(). This helper + * function allows for boards to query the device tree for DRAM size and start + * address instead of hard coding the value in the case where the memory size + * and start address cannot be detected automatically. + * + * @return 0 if OK, -EINVAL if the /memory node or reg property is missing or + * invalid + */ +int fdtdec_setup_mem_size_base_lowest(void); + /** * fdtdec_setup_memory_banksize() - decode and populate gd->bd->bi_dram * -- cgit v1.2.3 From 8d00d224c97b3c871afa12ce53249fef99ee403a Mon Sep 17 00:00:00 2001 From: Ashok Reddy Soma Date: Mon, 6 Apr 2020 07:58:32 -0600 Subject: arm64: zynqmp: Reduce malloc memory for mini QSPI configuration Mini U-boot runs on lower foot print of 256KB OCM. Hence 8K memory for malloc may not be required. Reduce it by 1.5K. Signed-off-by: Ashok Reddy Soma Signed-off-by: Michal Simek --- include/configs/xilinx_zynqmp_mini_qspi.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/configs/xilinx_zynqmp_mini_qspi.h b/include/configs/xilinx_zynqmp_mini_qspi.h index 129af6e9329..205ddb4ae09 100644 --- a/include/configs/xilinx_zynqmp_mini_qspi.h +++ b/include/configs/xilinx_zynqmp_mini_qspi.h @@ -13,6 +13,6 @@ #include #define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_TEXT_BASE + 0x20000) -#define CONFIG_SYS_MALLOC_LEN 0x2000 +#define CONFIG_SYS_MALLOC_LEN 0x1a00 #endif /* __CONFIG_ZYNQMP_MINI_QSPI_H */ -- cgit v1.2.3 From 9643000e1402b7f1bb2961166d4ab03785893b7a Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Wed, 15 Jul 2020 15:43:52 +0200 Subject: xilinx: Align dfu ram with booti command Image should be loaded to 0x80000 address and not to $kernel_addr_r. Also kernel_addr, fdt_addr and fdt_size in zynqmp case are not defined that's why define it to be aligned with Versal. Signed-off-by: Michal Simek --- include/configs/xilinx_versal.h | 2 +- include/configs/xilinx_zynqmp.h | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/configs/xilinx_versal.h b/include/configs/xilinx_versal.h index 804525dcad2..32cd5b21f7b 100644 --- a/include/configs/xilinx_versal.h +++ b/include/configs/xilinx_versal.h @@ -54,7 +54,7 @@ #define DFU_ALT_INFO_RAM \ "dfu_ram_info=" \ "setenv dfu_alt_info " \ - "Image ram $kernel_addr_r $kernel_size_r\\\\;" \ + "Image ram 80000 $kernel_size_r\\\\;" \ "system.dtb ram $fdt_addr_r $fdt_size_r\0" \ "dfu_ram=run dfu_ram_info && dfu 0 ram 0\0" \ "thor_ram=run dfu_ram_info && thordown 0 ram 0\0" diff --git a/include/configs/xilinx_zynqmp.h b/include/configs/xilinx_zynqmp.h index 72aea1285f9..bbcdc48c749 100644 --- a/include/configs/xilinx_zynqmp.h +++ b/include/configs/xilinx_zynqmp.h @@ -58,8 +58,8 @@ #define DFU_ALT_INFO_RAM \ "dfu_ram_info=" \ "setenv dfu_alt_info " \ - "Image ram $kernel_addr $kernel_size\\\\;" \ - "system.dtb ram $fdt_addr $fdt_size\0" \ + "Image ram 80000 $kernel_size_r\\\\;" \ + "system.dtb ram $fdt_addr_r $fdt_size_r\0" \ "dfu_ram=run dfu_ram_info && dfu 0 ram 0\0" \ "thor_ram=run dfu_ram_info && thordown 0 ram 0\0" @@ -101,8 +101,10 @@ #define ENV_MEM_LAYOUT_SETTINGS \ "fdt_high=10000000\0" \ "fdt_addr_r=0x40000000\0" \ + "fdt_size_r=0x400000\0" \ "pxefile_addr_r=0x10000000\0" \ "kernel_addr_r=0x18000000\0" \ + "kernel_size_r=0x10000000\0" \ "scriptaddr=0x20000000\0" \ "ramdisk_addr_r=0x02100000\0" \ "script_size_f=0x80000\0" \ -- cgit v1.2.3 From 2d06361a11e88e6ca5bbd11e3ed5717d7715bfe1 Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Wed, 15 Jul 2020 14:20:34 +0200 Subject: xilinx: zynqmp: Enable DFU tftp support Enable DFU tftp support for firmware update. Fill dfu_ram_tftp variable to have command present for showing how to use it. boot FIT image has been created from below fragment. Key part is that type of image has to be firmware. Also based on experiment load property is completely ignored and base addresses are taken from dfu_alt_info variable. $ cat update_uboot.its /dts-v1/; / { description = "Automatic U-Boot update"; #address-cells = <1>; images { Image { description = "Kernel"; data = /incbin/("/tftpboot/Image"); compression = "none"; arch = "arm64"; type = "firmware"; os = "linux"; load = <0x80000>; entry = <0x80000>; hash-1 { algo = "sha1"; }; }; system.dtb { description = "DTB"; data = /incbin/("/tftpboot/system.dtb"); compression = "none"; arch = "arm64"; type = "firmware"; load = <0>; hash-1 { algo = "sha1"; }; }; }; }; $ mkimage -f update_uboot.its /tftpboot/boot When U-Boot starts get IP address and server IP. dhcp setenv serverip 192.168.0.105 And then run prepared command. run dfu_ram_tftp Signed-off-by: Michal Simek --- include/configs/xilinx_zynqmp.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/configs/xilinx_zynqmp.h b/include/configs/xilinx_zynqmp.h index bbcdc48c749..7c24bf632e3 100644 --- a/include/configs/xilinx_zynqmp.h +++ b/include/configs/xilinx_zynqmp.h @@ -61,7 +61,9 @@ "Image ram 80000 $kernel_size_r\\\\;" \ "system.dtb ram $fdt_addr_r $fdt_size_r\0" \ "dfu_ram=run dfu_ram_info && dfu 0 ram 0\0" \ - "thor_ram=run dfu_ram_info && thordown 0 ram 0\0" + "thor_ram=run dfu_ram_info && thordown 0 ram 0\0" \ + "dfu_ram_tftp=run dfu_ram_info && setenv updatefile boot && " \ + "setenv loadaddr 10000000 && dfu tftp ram 0\0" #define DFU_ALT_INFO \ DFU_ALT_INFO_RAM -- cgit v1.2.3 From f6cccbb5f24ff7a19be84fb755d8566aee647244 Mon Sep 17 00:00:00 2001 From: Ibai Erkiaga Date: Tue, 4 Aug 2020 23:17:26 +0100 Subject: xilinx: zynqmp: synchronize firmware call return payload Removes duplicated definition of PAYLOAD_ARG_CNT and define it in the firmware driver. Additionally fixes payload buffer declarations without macro usage Signed-off-by: Ibai Erkiaga Signed-off-by: Michal Simek --- include/zynqmp_firmware.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'include') diff --git a/include/zynqmp_firmware.h b/include/zynqmp_firmware.h index 93d771ece26..2c44951f861 100644 --- a/include/zynqmp_firmware.h +++ b/include/zynqmp_firmware.h @@ -77,6 +77,15 @@ enum pm_api_id { #define PMUFW_V1_0 ((1 << ZYNQMP_PM_VERSION_MAJOR_SHIFT) | 0) +/* + * Return payload size + * Not every firmware call expects the same amount of return bytes, however the + * firmware driver always copies 5 bytes from RX buffer to the ret_payload + * buffer. Therefore allocating with this defined value is recommended to avoid + * overflows. + */ +#define PAYLOAD_ARG_CNT 5U + unsigned int zynqmp_firmware_version(void); void zynqmp_pmufw_load_config_object(const void *cfg_obj, size_t size); int xilinx_pm_request(u32 api_id, u32 arg0, u32 arg1, u32 arg2, -- cgit v1.2.3 From 0bfb43dfc14ec4ca5a07f5d22063f1869c45de45 Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Wed, 12 Aug 2020 12:04:50 +0200 Subject: xilinx: common: Get rid of fdt_high variable There is no need to setup this variable if bootm_low and bootm_size variable are properly setup. If fdt_high variable is missing U-Boot is asking LMB to return free memory which is not used. Signed-off-by: Michal Simek --- include/configs/xilinx_versal.h | 1 - include/configs/xilinx_zynqmp.h | 1 - include/configs/zynq-common.h | 1 - 3 files changed, 3 deletions(-) (limited to 'include') diff --git a/include/configs/xilinx_versal.h b/include/configs/xilinx_versal.h index 32cd5b21f7b..d7255a05dff 100644 --- a/include/configs/xilinx_versal.h +++ b/include/configs/xilinx_versal.h @@ -79,7 +79,6 @@ #define CONFIG_CLOCKS #define ENV_MEM_LAYOUT_SETTINGS \ - "fdt_high=10000000\0" \ "fdt_addr_r=0x40000000\0" \ "fdt_size_r=0x400000\0" \ "pxefile_addr_r=0x10000000\0" \ diff --git a/include/configs/xilinx_zynqmp.h b/include/configs/xilinx_zynqmp.h index 7c24bf632e3..15ad4198a6b 100644 --- a/include/configs/xilinx_zynqmp.h +++ b/include/configs/xilinx_zynqmp.h @@ -101,7 +101,6 @@ #define CONFIG_CLOCKS #define ENV_MEM_LAYOUT_SETTINGS \ - "fdt_high=10000000\0" \ "fdt_addr_r=0x40000000\0" \ "fdt_size_r=0x400000\0" \ "pxefile_addr_r=0x10000000\0" \ diff --git a/include/configs/zynq-common.h b/include/configs/zynq-common.h index 79c75784f2b..1607a8d0651 100644 --- a/include/configs/zynq-common.h +++ b/include/configs/zynq-common.h @@ -196,7 +196,6 @@ /* Default environment */ #ifndef CONFIG_EXTRA_ENV_SETTINGS #define CONFIG_EXTRA_ENV_SETTINGS \ - "fdt_high=0x20000000\0" \ "scriptaddr=0x20000\0" \ "script_size_f=0x40000\0" \ "fdt_addr_r=0x1f00000\0" \ -- cgit v1.2.3 From 29af2ac48c8f910cc2efc8099323f9d619fb2bd5 Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Thu, 23 Jul 2020 09:24:06 +0200 Subject: clk: versal: Move pm_query_id out of clock driver There is no reason to have firmware specific structure in clock driver. Move it to generic location and also initialize enum values which is based on https://lore.kernel.org/linux-arm-kernel/20200318125003.GA2727094@kroah.com/ recommended way to go to make sure that values guaranteed by compiler. Signed-off-by: Michal Simek --- include/zynqmp_firmware.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'include') diff --git a/include/zynqmp_firmware.h b/include/zynqmp_firmware.h index 2c44951f861..f6f82bf8828 100644 --- a/include/zynqmp_firmware.h +++ b/include/zynqmp_firmware.h @@ -62,6 +62,23 @@ enum pm_api_id { PM_API_MAX, }; +enum pm_query_id { + PM_QID_INVALID = 0, + PM_QID_CLOCK_GET_NAME = 1, + PM_QID_CLOCK_GET_TOPOLOGY = 2, + PM_QID_CLOCK_GET_FIXEDFACTOR_PARAMS = 3, + PM_QID_CLOCK_GET_PARENTS = 4, + PM_QID_CLOCK_GET_ATTRIBUTES = 5, + PM_QID_PINCTRL_GET_NUM_PINS = 6, + PM_QID_PINCTRL_GET_NUM_FUNCTIONS = 7, + PM_QID_PINCTRL_GET_NUM_FUNCTION_GROUPS = 8, + PM_QID_PINCTRL_GET_FUNCTION_NAME = 9, + PM_QID_PINCTRL_GET_FUNCTION_GROUPS = 10, + PM_QID_PINCTRL_GET_PIN_GROUPS = 11, + PM_QID_CLOCK_GET_NUM_CLOCKS = 12, + PM_QID_CLOCK_GET_MAX_DIVISOR = 13, +}; + #define PM_SIP_SVC 0xc2000000 #define ZYNQMP_PM_VERSION_MAJOR 1 -- cgit v1.2.3