From a3e3d4698e3c5812bba76cf0f35a0f71b27d5973 Mon Sep 17 00:00:00 2001 From: T Karthik Reddy Date: Fri, 1 Oct 2021 16:38:38 +0530 Subject: [PATCH 01/69] mmc: zynq_sdhci: Add xilinx_pm_request weak function Mini emmc does not use any pmufw and ZYNQMP_FIRMWARE is disabled. xilinx_pm_request() will not be compiled and causes undefined reference to `xilinx_pm_request' error. So add a weak function in zynq_sdhci.c file. Signed-off-by: T Karthik Reddy Signed-off-by: Ashok Reddy Soma Link: https://lore.kernel.org/r/1633086518-32636-1-git-send-email-t.karthik.reddy@xilinx.com Signed-off-by: Michal Simek --- drivers/mmc/zynq_sdhci.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/mmc/zynq_sdhci.c b/drivers/mmc/zynq_sdhci.c index c94825dceb..5cea4c695e 100644 --- a/drivers/mmc/zynq_sdhci.c +++ b/drivers/mmc/zynq_sdhci.c @@ -69,6 +69,12 @@ __weak int zynqmp_mmio_write(const u32 address, const u32 mask, const u32 value) return 0; } +__weak int xilinx_pm_request(u32 api_id, u32 arg0, u32 arg1, u32 arg2, + u32 arg3, u32 *ret_payload) +{ + return 0; +} + #if defined(CONFIG_ARCH_ZYNQMP) || defined(CONFIG_ARCH_VERSAL) /* Default settings for ZynqMP Clock Phases */ static const u32 zynqmp_iclk_phases[] = {0, 63, 63, 0, 63, 0, From 398a74ae330dfc4e46744874ebbe5394d2679c37 Mon Sep 17 00:00:00 2001 From: Jorge Ramirez-Ortiz Date: Wed, 13 Oct 2021 15:48:00 +0200 Subject: [PATCH 02/69] zynqmp: restore the jtag interface When boot.bin is configured for secure boot the CSU will disable the JTAG interface on all cases. Some boards might rely on this interface for flashing to QSPI in which case those systems might end up bricked during development. This commit will restore the interface under CSU control Signed-off-by: Jorge Ramirez-Ortiz Link: https://lore.kernel.org/r/20211013134800.19452-1-jorge@foundries.io Signed-off-by: Michal Simek --- arch/arm/mach-zynqmp/Kconfig | 8 +++++ arch/arm/mach-zynqmp/include/mach/hardware.h | 31 +++++++++++++++----- board/xilinx/zynqmp/zynqmp.c | 19 ++++++++++++ 3 files changed, 51 insertions(+), 7 deletions(-) diff --git a/arch/arm/mach-zynqmp/Kconfig b/arch/arm/mach-zynqmp/Kconfig index f7b08db355..e4f2e24b7f 100644 --- a/arch/arm/mach-zynqmp/Kconfig +++ b/arch/arm/mach-zynqmp/Kconfig @@ -149,6 +149,14 @@ config SPL_ZYNQMP_ALT_BOOTMODE_ENABLED Overwrite bootmode selected via boot mode pins to tell SPL what should be the next boot device. +config SPL_ZYNQMP_RESTORE_JTAG + bool "Restore JTAG" + depends on SPL + help + Booting SPL in secure mode causes the CSU to disable the JTAG interface + even if no eFuses were burnt. This option restores the interface if + possible. + config ZYNQ_SDHCI_MAX_FREQ default 200000000 diff --git a/arch/arm/mach-zynqmp/include/mach/hardware.h b/arch/arm/mach-zynqmp/include/mach/hardware.h index eebf38551c..e6a3ee4a57 100644 --- a/arch/arm/mach-zynqmp/include/mach/hardware.h +++ b/arch/arm/mach-zynqmp/include/mach/hardware.h @@ -39,20 +39,26 @@ #define RESET_REASON_INTERNAL BIT(1) #define RESET_REASON_EXTERNAL BIT(0) +#define CRLAPB_DBG_LPD_CTRL_SETUP_CLK 0x01002002 +#define CRLAPB_RST_LPD_DBG_RESET 0 + struct crlapb_regs { u32 reserved0[36]; u32 cpu_r5_ctrl; /* 0x90 */ - u32 reserved1[37]; + u32 reserved1[7]; + u32 dbg_lpd_ctrl; /* 0xB0 */ + u32 reserved2[29]; u32 timestamp_ref_ctrl; /* 0x128 */ - u32 reserved2[53]; + u32 reserved3[53]; u32 boot_mode; /* 0x200 */ - u32 reserved3_0[7]; + u32 reserved4_0[7]; u32 reset_reason; /* 0x220 */ - u32 reserved3_1[6]; + u32 reserved4_1[6]; u32 rst_lpd_top; /* 0x23C */ - u32 reserved4[4]; + u32 rst_lpd_dbg; /* 0x240 */ + u32 reserved5[3]; u32 boot_pin_ctrl; /* 0x250 */ - u32 reserved5[21]; + u32 reserved6[21]; }; #define crlapb_base ((struct crlapb_regs *)ZYNQMP_CRL_APB_BASEADDR) @@ -141,12 +147,23 @@ struct apu_regs { #define ZYNQMP_SILICON_VER_MASK 0xF #define ZYNQMP_SILICON_VER_SHIFT 0 +#define CSU_JTAG_SEC_GATE_DISABLE GENMASK(7, 0) +#define CSU_JTAG_DAP_ENABLE_DEBUG GENMASK(7, 0) +#define CSU_JTAG_CHAIN_WR_SETUP GENMASK(1, 0) +#define CSU_PCAP_PROG_RELEASE_PL BIT(0) + struct csu_regs { u32 reserved0[4]; u32 multi_boot; - u32 reserved1[11]; + u32 reserved1[7]; + u32 jtag_chain_status_wr; + u32 jtag_chain_status; + u32 jtag_sec; + u32 jtag_dap_cfg; u32 idcode; u32 version; + u32 reserved2[3055]; + u32 pcap_prog; }; #define csu_base ((struct csu_regs *)ZYNQMP_CSU_BASEADDR) diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c index 000a7cde8d..b24db5306a 100644 --- a/board/xilinx/zynqmp/zynqmp.c +++ b/board/xilinx/zynqmp/zynqmp.c @@ -358,6 +358,21 @@ static int multi_boot(void) return multiboot; } +#if defined(CONFIG_SPL_BUILD) +static void restore_jtag(void) +{ + if (current_el() != 3) + return; + + writel(CSU_JTAG_SEC_GATE_DISABLE, &csu_base->jtag_sec); + writel(CSU_JTAG_DAP_ENABLE_DEBUG, &csu_base->jtag_dap_cfg); + writel(CSU_JTAG_CHAIN_WR_SETUP, &csu_base->jtag_chain_status_wr); + writel(CRLAPB_DBG_LPD_CTRL_SETUP_CLK, &crlapb_base->dbg_lpd_ctrl); + writel(CRLAPB_RST_LPD_DBG_RESET, &crlapb_base->rst_lpd_dbg); + writel(CSU_PCAP_PROG_RELEASE_PL, &csu_base->pcap_prog); +} +#endif + #define PS_SYSMON_ANALOG_BUS_VAL 0x3210 #define PS_SYSMON_ANALOG_BUS_REG 0xFFA50914 @@ -377,6 +392,10 @@ int board_init(void) zynqmp_pmufw_load_config_object(zynqmp_pm_cfg_obj, zynqmp_pm_cfg_obj_size); printf("Silicon version:\t%d\n", zynqmp_get_silicon_version()); + + /* the CSU disables the JTAG interface when secure boot is enabled */ + if (CONFIG_IS_ENABLED(SPL_ZYNQMP_RESTORE_JTAG)) + restore_jtag(); #else if (CONFIG_IS_ENABLED(DM_I2C) && CONFIG_IS_ENABLED(I2C_EEPROM)) xilinx_read_eeprom(); From 181419446af7facaab2fe159225064ef6c736a3c Mon Sep 17 00:00:00 2001 From: Liam Beguin Date: Wed, 20 Oct 2021 11:25:18 -0400 Subject: [PATCH 03/69] arm64: zynqmp: allow overriding board name There is no need to use zynqmp name as SYS_BOARD for all boards. The patch is adding an option to change it. Signed-off-by: Liam Beguin Link: https://lore.kernel.org/r/20211020152518.3511912-1-liambeguin@gmail.com Signed-off-by: Michal Simek --- arch/arm/mach-zynqmp/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm/mach-zynqmp/Kconfig b/arch/arm/mach-zynqmp/Kconfig index e4f2e24b7f..f8b5906039 100644 --- a/arch/arm/mach-zynqmp/Kconfig +++ b/arch/arm/mach-zynqmp/Kconfig @@ -25,6 +25,7 @@ config SPL_SPI default y if ZYNQ_QSPI config SYS_BOARD + string "Board name" default "zynqmp" config SYS_VENDOR From d2d14383bae4732c11b68c14aa33cf7b9f3bf40c Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Thu, 14 Oct 2021 19:07:52 +0200 Subject: [PATCH 04/69] arm64: zynqmp: Add support for DLC21 (Smartlynq+) board DLC21 is used as fast jtag cable. The patch adds support for this board from PS perspective. The most interesting part on the board is seps525 oled display. Also i2c, gpio, ethernet, uart, SD and eMMC are tested. Signed-off-by: Michal Simek Link: https://lore.kernel.org/r/3d35cd6a11cffc7456e21a88b214cc965734e852.1634231268.git.michal.simek@xilinx.com --- arch/arm/dts/Makefile | 1 + arch/arm/dts/zynqmp-dlc21-revA.dts | 221 +++++ .../zynqmp/zynqmp-dlc21-revA/psu_init_gpl.c | 922 ++++++++++++++++++ configs/xilinx_zynqmp_virt_defconfig | 2 +- 4 files changed, 1145 insertions(+), 1 deletion(-) create mode 100644 arch/arm/dts/zynqmp-dlc21-revA.dts create mode 100644 board/xilinx/zynqmp/zynqmp-dlc21-revA/psu_init_gpl.c diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile index ed3d360bb1..5adf0c8126 100644 --- a/arch/arm/dts/Makefile +++ b/arch/arm/dts/Makefile @@ -312,6 +312,7 @@ dtb-$(CONFIG_ARCH_ZYNQMP) += \ avnet-ultra96-rev1.dtb \ avnet-ultrazedev-cc-v1.0-ultrazedev-som-v1.0.dtb \ zynqmp-a2197-revA.dtb \ + zynqmp-dlc21-revA.dtb \ zynqmp-e-a2197-00-revA.dtb \ zynqmp-g-a2197-00-revA.dtb \ zynqmp-m-a2197-01-revA.dtb \ diff --git a/arch/arm/dts/zynqmp-dlc21-revA.dts b/arch/arm/dts/zynqmp-dlc21-revA.dts new file mode 100644 index 0000000000..cf0aadf03c --- /dev/null +++ b/arch/arm/dts/zynqmp-dlc21-revA.dts @@ -0,0 +1,221 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * dts file for Xilinx ZynqMP DLC21 revA + * + * (C) Copyright 2019 - 2021, Xilinx, Inc. + * + * Michal Simek + */ +/dts-v1/; + +#include "zynqmp.dtsi" +#include "zynqmp-clk-ccf.dtsi" +#include +#include +#include + +/ { + model = "Smartlynq+ DLC21 RevA"; + compatible = "xlnx,zynqmp-dlc21-revA", "xlnx,zynqmp-dlc21", + "xlnx,zynqmp"; + + aliases { + ethernet0 = &gem0; + gpio0 = &gpio; + i2c0 = &i2c0; + mmc0 = &sdhci0; + mmc1 = &sdhci1; + rtc0 = &rtc; + serial0 = &uart0; + serial2 = &dcc; + usb0 = &usb0; + usb1 = &usb1; + spi0 = &spi0; + nvmem0 = &eeprom; + }; + + chosen { + bootargs = "earlycon"; + stdout-path = "serial0:115200n8"; + }; + + memory@0 { + device_type = "memory"; + reg = <0 0 0 0x80000000>, <0x8 0 0x3 0x80000000>; + }; + + si5332_1: si5332_1 { /* clk0_sgmii - u142 */ + compatible = "fixed-clock"; + #clock-cells = <0>; + clock-frequency = <125000000>; + }; + + si5332_2: si5332_2 { /* clk1_usb - u142 */ + compatible = "fixed-clock"; + #clock-cells = <0>; + clock-frequency = <26000000>; + }; +}; + +&sdhci0 { /* emmc MIO 13-23 - with some settings 16GB */ + status = "okay"; + non-removable; + disable-wp; + bus-width = <8>; + xlnx,mio_bank = <0>; +}; + +&sdhci1 { /* sd1 MIO45-51 cd in place */ + status = "okay"; + no-1-8-v; + disable-wp; + xlnx,mio_bank = <1>; +}; + +&psgtr { + status = "okay"; + /* sgmii, usb3 */ + clocks = <&si5332_1>, <&si5332_2>; + clock-names = "ref0", "ref1"; +}; + +&uart0 { /* uart0 MIO38-39 */ + status = "okay"; + u-boot,dm-pre-reloc; +}; + +&gem0 { + status = "okay"; + phy-handle = <&phy0>; + phy-mode = "sgmii"; /* DTG generates this properly 1512 */ + is-internal-pcspma; + /* phy-reset-gpios = <&gpio 142 GPIO_ACTIVE_LOW>; */ + phy0: ethernet-phy@0 { + reg = <0>; + }; +}; + +&gpio { + status = "okay"; + gpio-line-names = "", "", "", "", "", /* 0 - 4 */ + "", "", "", "", "", /* 5 - 9 */ + "", "", "", "EMMC_DAT0", "EMMC_DAT1", /* 10 - 14 */ + "EMMC_DAT2", "EMMC_DAT3", "EMMC_DAT4", "EMMC_DAT5", "EMMC_DAT6", /* 15 - 19 */ + "EMMC_DAT7", "EMMC_CMD", "EMMC_CLK", "EMMC_RST_B", "", /* 20 - 24 */ + "", "DISP_SCL", "DISP_DC_B", "DISP_RES_B", "DISP_CS_B", /* 25 - 29 */ + "", "DISP_SDI", "SYSTEM_RST_R_B", "", "I2C0_SCL", /* 30 - 34 */ + "I2C0_SDA", "", "", "UART0_RXD_IN", "UART0_TXD_OUT", /* 35 - 39 */ + "", "", "ETH_RESET_B", "", "", /* 40 - 44 */ + "SD1_CD_B", "SD1_DATA0", "SD1_DATA1", "SD1_DATA2", "SD1_DATA3", /* 45 - 49 */ + "SD1_CMD", "SD1_CLK", "USB0_CLK", "USB0_DIR", "USB0_DATA2", /* 50 - 54 */ + "USB0_NXT", "USB0_DATA0", "USB0_DATA1", "USB0_STP", "USB0_DATA3", /* 55 - 59 */ + "USB0_DATA4", "USB0_DATA5", "USB0_DATA6", "USB0_DATA7", "USB1_CLK", /* 60 - 64 */ + "USB1_DIR", "USB1_DATA2", "USB1_NXT", "USB1_DATA0", "USB1_DATA1", /* 65 - 69 */ + "USB1_STP", "USB1_DATA3", "USB1_DATA4", "USB1_DATA5", "USB1_DATA6", /* 70 - 74 */ + "USB1_DATA7", "ETH_MDC", "ETH_MDIO", /* 75 - 77, MIO end and EMIO start */ + "", "", /* 78 - 79 */ + "", "", "", "", "", /* 80 - 84 */ + "", "", "", "", "", /* 85 -89 */ + "", "", "", "", "", /* 90 - 94 */ + "", "VCCO_500_RBIAS", "VCCO_501_RBIAS", "VCCO_502_RBIAS", "VCCO_500_RBIAS_LED", /* 95 - 99 */ + "VCCO_501_RBIAS_LED", "VCCO_502_RBIAS_LED", "SYSCTLR_VCCINT_EN", "SYSCTLR_VCC_IO_SOC_EN", "SYSCTLR_VCC_PMC_EN", /* 100 - 104 */ + "", "", "", "", "", /* 105 - 109 */ + "SYSCTLR_VCCO_500_EN", "SYSCTLR_VCCO_501_EN", "SYSCTLR_VCCO_502_EN", "SYSCTLR_VCCO_503_EN", "SYSCTLR_VCC1V8_EN", /* 110 - 114 */ + "SYSCTLR_VCC3V3_EN", "SYSCTLR_VCC1V2_DDR4_EN", "SYSCTLR_VCC1V1_LP4_EN", "SYSCTLR_VDD1_1V8_LP4_EN", "SYSCTLR_VADJ_FMC_EN", /* 115 - 119 */ + "", "", "", "SYSCTLR_UTIL_1V13_EN", "SYSCTLR_UTIL_1V8_EN", /* 120 - 124 */ + "SYSCTLR_UTIL_2V5_EN", "", "", "", "", /* 125 - 129 */ + "", "", "SYSCTLR_USBC_SBU1", "SYSCTLR_USBC_SBU2", "", /* 130 - 134 */ + "", "SYSCTLR_MIC2005_EN_B", "SYSCTLR_MIC2005_FAULT_B", "SYSCTLR_TUSB320_INT_B", "SYSCTLR_TUSB320_ID", /* 135 - 139 */ + "", "", "SYSCTLR_ETH_RESET_B", "", "", /* 140 - 144 */ + "", "", "", "", "", /* 145 - 149 */ + "", "", "", "", "", /* 150 - 154 */ + "", "", "", "", "", /* 155 - 159 */ + "", "", "", "", "", /* 160 - 164 */ + "", "", "", "", "", /* 165 - 169 */ + "", "", "", ""; /* 170 - 174 */ +}; + +&i2c0 { /* MIO34/35 */ + status = "okay"; + clock-frequency = <400000>; + + jtag_vref: mcp4725@62 { + compatible = "microchip,mcp4725"; + reg = <0x62>; + vref-millivolt = <3300>; + }; + + eeprom: eeprom@50 { /* u46 */ + compatible = "atmel,24c32"; + reg = <0x50>; + }; + /* u138 - TUSB320IRWBR - for USB-C */ +}; + + +&usb0 { + status = "okay"; + xlnx,usb-polarity = <0>; + xlnx,usb-reset-mode = <0>; +}; + +&dwc3_0 { + status = "okay"; + dr_mode = "peripheral"; + snps,dis_u2_susphy_quirk; + snps,dis_u3_susphy_quirk; + maximum-speed = "super-speed"; + phy-names = "usb3-phy"; + phys = <&psgtr 1 PHY_TYPE_USB3 0 1>; +}; + +&usb1 { + status = "disabled"; /* Any unknown issue with USB-C */ + xlnx,usb-polarity = <0>; + xlnx,usb-reset-mode = <0>; +}; + +&dwc3_1 { + /delete-property/ phy-names ; + /delete-property/ phys ; + dr_mode = "host"; + maximum-speed = "high-speed"; + snps,dis_u2_susphy_quirk ; + snps,dis_u3_susphy_quirk ; + status = "okay"; +}; + +&xilinx_ams { + status = "okay"; +}; + +&ams_ps { + status = "okay"; +}; + +&ams_pl { + status = "okay"; +}; + +&spi0 { + status = "okay"; + is-decoded-cs = <0>; + num-cs = <1>; + u-boot,dm-pre-reloc; + displayspi@0 { + compatible = "syncoam,seps525"; + u-boot,dm-pre-reloc; + reg = <0>; + status = "okay"; + spi-max-frequency = <10000000>; + spi-cpol; + spi-cpha; + rotate = <0>; + fps = <50>; + buswidth = <8>; + txbuflen = <64000>; + reset-gpios = <&gpio 0x1c GPIO_ACTIVE_LOW>; + dc-gpios = <&gpio 0x1b GPIO_ACTIVE_HIGH>; + debug = <0>; + }; +}; diff --git a/board/xilinx/zynqmp/zynqmp-dlc21-revA/psu_init_gpl.c b/board/xilinx/zynqmp/zynqmp-dlc21-revA/psu_init_gpl.c new file mode 100644 index 0000000000..528958d83e --- /dev/null +++ b/board/xilinx/zynqmp/zynqmp-dlc21-revA/psu_init_gpl.c @@ -0,0 +1,922 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * (c) Copyright 2015 Xilinx, Inc. All rights reserved. + */ + +#include +#include + +static unsigned long psu_pll_init_data(void) +{ + psu_mask_write(0xFF5E0034, 0xFE7FEDEFU, 0x7E4B0C62U); + psu_mask_write(0xFF5E0030, 0x00717F00U, 0x00014000U); + psu_mask_write(0xFF5E0030, 0x00000008U, 0x00000008U); + psu_mask_write(0xFF5E0030, 0x00000001U, 0x00000001U); + psu_mask_write(0xFF5E0030, 0x00000001U, 0x00000000U); + mask_poll(0xFF5E0040, 0x00000002U); + psu_mask_write(0xFF5E0030, 0x00000008U, 0x00000000U); + psu_mask_write(0xFF5E0048, 0x00003F00U, 0x00000200U); + psu_mask_write(0xFF5E0038, 0x8000FFFFU, 0x00000000U); + psu_mask_write(0xFF5E0108, 0x013F3F07U, 0x01012300U); + psu_mask_write(0xFF5E0024, 0xFE7FEDEFU, 0x7E4B0C82U); + psu_mask_write(0xFF5E0020, 0x00717F00U, 0x00015A00U); + psu_mask_write(0xFF5E0020, 0x00000008U, 0x00000008U); + psu_mask_write(0xFF5E0020, 0x00000001U, 0x00000001U); + psu_mask_write(0xFF5E0020, 0x00000001U, 0x00000000U); + mask_poll(0xFF5E0040, 0x00000001U); + psu_mask_write(0xFF5E0020, 0x00000008U, 0x00000000U); + psu_mask_write(0xFF5E0044, 0x00003F00U, 0x00000300U); + psu_mask_write(0xFF5E0028, 0x8000FFFFU, 0x00000000U); + psu_mask_write(0xFD1A0024, 0xFE7FEDEFU, 0x7E4B0C62U); + psu_mask_write(0xFD1A0020, 0x00717F00U, 0x00014800U); + psu_mask_write(0xFD1A0020, 0x00000008U, 0x00000008U); + psu_mask_write(0xFD1A0020, 0x00000001U, 0x00000001U); + psu_mask_write(0xFD1A0020, 0x00000001U, 0x00000000U); + mask_poll(0xFD1A0044, 0x00000001U); + psu_mask_write(0xFD1A0020, 0x00000008U, 0x00000000U); + psu_mask_write(0xFD1A0048, 0x00003F00U, 0x00000300U); + psu_mask_write(0xFD1A0028, 0x8000FFFFU, 0x00000000U); + psu_mask_write(0xFD1A0030, 0xFE7FEDEFU, 0x7E4B0C62U); + psu_mask_write(0xFD1A002C, 0x00717F00U, 0x00014000U); + psu_mask_write(0xFD1A002C, 0x00000008U, 0x00000008U); + psu_mask_write(0xFD1A002C, 0x00000001U, 0x00000001U); + psu_mask_write(0xFD1A002C, 0x00000001U, 0x00000000U); + mask_poll(0xFD1A0044, 0x00000002U); + psu_mask_write(0xFD1A002C, 0x00000008U, 0x00000000U); + psu_mask_write(0xFD1A004C, 0x00003F00U, 0x00000200U); + psu_mask_write(0xFD1A0034, 0x8000FFFFU, 0x00000000U); + psu_mask_write(0xFD1A003C, 0xFE7FEDEFU, 0x7E4B0C62U); + psu_mask_write(0xFD1A0038, 0x00717F00U, 0x00014000U); + psu_mask_write(0xFD1A0038, 0x00000008U, 0x00000008U); + psu_mask_write(0xFD1A0038, 0x00000001U, 0x00000001U); + psu_mask_write(0xFD1A0038, 0x00000001U, 0x00000000U); + mask_poll(0xFD1A0044, 0x00000004U); + psu_mask_write(0xFD1A0038, 0x00000008U, 0x00000000U); + psu_mask_write(0xFD1A0050, 0x00003F00U, 0x00000200U); + psu_mask_write(0xFD1A0040, 0x8000FFFFU, 0x00000000U); + + return 1; +} + +static unsigned long psu_clock_init_data(void) +{ + psu_mask_write(0xFF5E0050, 0x063F3F07U, 0x06013C00U); + psu_mask_write(0xFF180360, 0x00000003U, 0x00000001U); + psu_mask_write(0xFF180308, 0x00000006U, 0x00000006U); + psu_mask_write(0xFF5E0100, 0x013F3F07U, 0x01010600U); + psu_mask_write(0xFF5E0060, 0x023F3F07U, 0x02010600U); + psu_mask_write(0xFF5E0064, 0x023F3F07U, 0x02010600U); + psu_mask_write(0xFF5E004C, 0x023F3F07U, 0x02031900U); + psu_mask_write(0xFF5E006C, 0x013F3F07U, 0x01010800U); + psu_mask_write(0xFF5E0070, 0x013F3F07U, 0x01010800U); + psu_mask_write(0xFF18030C, 0x00020003U, 0x00000000U); + psu_mask_write(0xFF5E0074, 0x013F3F07U, 0x01010F00U); + psu_mask_write(0xFF5E0120, 0x013F3F07U, 0x01010F00U); + psu_mask_write(0xFF5E007C, 0x013F3F07U, 0x01010702U); + psu_mask_write(0xFF5E0090, 0x01003F07U, 0x01000302U); + psu_mask_write(0xFF5E009C, 0x01003F07U, 0x01000400U); + psu_mask_write(0xFF5E00A4, 0x01003F07U, 0x01000800U); + psu_mask_write(0xFF5E00A8, 0x01003F07U, 0x01000200U); + psu_mask_write(0xFF5E00AC, 0x01003F07U, 0x01000F02U); + psu_mask_write(0xFF5E00B0, 0x01003F07U, 0x01000602U); + psu_mask_write(0xFF5E00B8, 0x01003F07U, 0x01000200U); + psu_mask_write(0xFF5E00C0, 0x013F3F07U, 0x01010502U); + psu_mask_write(0xFF5E00C4, 0x013F3F07U, 0x01010802U); + psu_mask_write(0xFF5E00C8, 0x013F3F07U, 0x01010402U); + psu_mask_write(0xFF5E00CC, 0x013F3F07U, 0x01030A00U); + psu_mask_write(0xFF5E0108, 0x013F3F07U, 0x01011E02U); + psu_mask_write(0xFF5E0104, 0x00000007U, 0x00000000U); + psu_mask_write(0xFF5E0128, 0x01003F07U, 0x01000104U); + psu_mask_write(0xFD1A0060, 0x03003F07U, 0x03000100U); + psu_mask_write(0xFD1A0068, 0x01003F07U, 0x01000200U); + psu_mask_write(0xFD1A0080, 0x00003F07U, 0x00000200U); + psu_mask_write(0xFD1A0084, 0x07003F07U, 0x07000100U); + psu_mask_write(0xFD1A00B8, 0x01003F07U, 0x01000203U); + psu_mask_write(0xFD1A00BC, 0x01003F07U, 0x01000203U); + psu_mask_write(0xFD1A00C0, 0x01003F07U, 0x01000202U); + psu_mask_write(0xFD1A00C4, 0x01003F07U, 0x01000502U); + psu_mask_write(0xFD1A00F8, 0x00003F07U, 0x00000200U); + psu_mask_write(0xFF180380, 0x000000FFU, 0x00000000U); + psu_mask_write(0xFD610100, 0x00000001U, 0x00000000U); + psu_mask_write(0xFF180300, 0x00000001U, 0x00000000U); + psu_mask_write(0xFF410050, 0x00000001U, 0x00000000U); + + return 1; +} + +static unsigned long psu_ddr_init_data(void) +{ + psu_mask_write(0xFD1A0108, 0x00000008U, 0x00000008U); + psu_mask_write(0xFD070000, 0xE30FBE3DU, 0x43041010U); + psu_mask_write(0xFD070010, 0x8000F03FU, 0x00000030U); + psu_mask_write(0xFD070020, 0x000003F3U, 0x00000200U); + psu_mask_write(0xFD070024, 0xFFFFFFFFU, 0x00800000U); + psu_mask_write(0xFD070030, 0x0000007FU, 0x00000008U); + psu_mask_write(0xFD070034, 0x00FFFF1FU, 0x00408410U); + psu_mask_write(0xFD070050, 0x00F1F1F4U, 0x00210000U); + psu_mask_write(0xFD070054, 0x0FFF0FFFU, 0x00000000U); + psu_mask_write(0xFD070060, 0x00000073U, 0x00000001U); + psu_mask_write(0xFD070064, 0x0FFF83FFU, 0x00818126U); + psu_mask_write(0xFD070070, 0x00000017U, 0x00000010U); + psu_mask_write(0xFD070074, 0x00000003U, 0x00000000U); + psu_mask_write(0xFD0700C4, 0x3F000391U, 0x10000200U); + psu_mask_write(0xFD0700C8, 0x01FF1F3FU, 0x0040051FU); + psu_mask_write(0xFD0700D0, 0xC3FF0FFFU, 0x00020106U); + psu_mask_write(0xFD0700D4, 0x01FF7F0FU, 0x00020000U); + psu_mask_write(0xFD0700D8, 0x0000FF0FU, 0x00002305U); + psu_mask_write(0xFD0700DC, 0xFFFFFFFFU, 0x07300501U); + psu_mask_write(0xFD0700E0, 0xFFFFFFFFU, 0x00200200U); + psu_mask_write(0xFD0700E4, 0x00FF03FFU, 0x00210004U); + psu_mask_write(0xFD0700E8, 0xFFFFFFFFU, 0x00000700U); + psu_mask_write(0xFD0700EC, 0xFFFF0000U, 0x08190000U); + psu_mask_write(0xFD0700F0, 0x0000003FU, 0x00000010U); + psu_mask_write(0xFD0700F4, 0x00000FFFU, 0x0000066FU); + psu_mask_write(0xFD070100, 0x7F3F7F3FU, 0x110C2412U); + psu_mask_write(0xFD070104, 0x001F1F7FU, 0x0004041CU); + psu_mask_write(0xFD070108, 0x3F3F3F3FU, 0x0708060DU); + psu_mask_write(0xFD07010C, 0x3FF3F3FFU, 0x0050400CU); + psu_mask_write(0xFD070110, 0x1F0F0F1FU, 0x08030309U); + psu_mask_write(0xFD070114, 0x0F0F3F1FU, 0x06060403U); + psu_mask_write(0xFD070118, 0x0F0F000FU, 0x01010004U); + psu_mask_write(0xFD07011C, 0x00000F0FU, 0x00000606U); + psu_mask_write(0xFD070120, 0x7F7F7F7FU, 0x04040D0BU); + psu_mask_write(0xFD070124, 0x40070F3FU, 0x0002020BU); + psu_mask_write(0xFD07012C, 0x7F1F031FU, 0x1607010EU); + psu_mask_write(0xFD070130, 0x00030F1FU, 0x00020608U); + psu_mask_write(0xFD070180, 0xF7FF03FFU, 0x81000040U); + psu_mask_write(0xFD070184, 0x3FFFFFFFU, 0x020196E5U); + psu_mask_write(0xFD070190, 0x1FBFBF3FU, 0x048B820BU); + psu_mask_write(0xFD070194, 0xF31F0F0FU, 0x00030304U); + psu_mask_write(0xFD070198, 0x0FF1F1F1U, 0x07000101U); + psu_mask_write(0xFD07019C, 0x000000F1U, 0x00000021U); + psu_mask_write(0xFD0701A0, 0xC3FF03FFU, 0x00400003U); + psu_mask_write(0xFD0701A4, 0x00FF00FFU, 0x00C800FFU); + psu_mask_write(0xFD0701B0, 0x00000007U, 0x00000000U); + psu_mask_write(0xFD0701B4, 0x00003F3FU, 0x00000909U); + psu_mask_write(0xFD0701C0, 0x00000007U, 0x00000001U); + psu_mask_write(0xFD070200, 0x0000001FU, 0x00000018U); + psu_mask_write(0xFD070204, 0x001F1F1FU, 0x001F0909U); + psu_mask_write(0xFD070208, 0x0F0F0F0FU, 0x01010101U); + psu_mask_write(0xFD07020C, 0x0F0F0F0FU, 0x0F010101U); + psu_mask_write(0xFD070210, 0x00000F0FU, 0x00000F0FU); + psu_mask_write(0xFD070214, 0x0F0F0F0FU, 0x070F0707U); + psu_mask_write(0xFD070218, 0x8F0F0F0FU, 0x07070707U); + psu_mask_write(0xFD07021C, 0x00000F0FU, 0x00000F07U); + psu_mask_write(0xFD070220, 0x00001F1FU, 0x00000700U); + psu_mask_write(0xFD070224, 0x0F0F0F0FU, 0x07070707U); + psu_mask_write(0xFD070228, 0x0F0F0F0FU, 0x07070707U); + psu_mask_write(0xFD07022C, 0x0000000FU, 0x00000007U); + psu_mask_write(0xFD070240, 0x0F1F0F7CU, 0x06000600U); + psu_mask_write(0xFD070244, 0x00003333U, 0x00000201U); + psu_mask_write(0xFD070250, 0x7FFF3F07U, 0x01002001U); + psu_mask_write(0xFD070264, 0xFF00FFFFU, 0x08000040U); + psu_mask_write(0xFD07026C, 0xFF00FFFFU, 0x08000040U); + psu_mask_write(0xFD070280, 0xFFFFFFFFU, 0x00000000U); + psu_mask_write(0xFD070284, 0xFFFFFFFFU, 0x00000000U); + psu_mask_write(0xFD070288, 0xFFFFFFFFU, 0x00000000U); + psu_mask_write(0xFD07028C, 0xFFFFFFFFU, 0x00000000U); + psu_mask_write(0xFD070290, 0x0000FFFFU, 0x00000000U); + psu_mask_write(0xFD070294, 0x00000001U, 0x00000001U); + psu_mask_write(0xFD070300, 0x00000011U, 0x00000001U); + psu_mask_write(0xFD07030C, 0x80000033U, 0x00000000U); + psu_mask_write(0xFD070320, 0x00000001U, 0x00000000U); + psu_mask_write(0xFD070400, 0x00000111U, 0x00000101U); + psu_mask_write(0xFD070404, 0x000073FFU, 0x0000200FU); + psu_mask_write(0xFD070408, 0x000073FFU, 0x0000200FU); + psu_mask_write(0xFD070490, 0x00000001U, 0x00000001U); + psu_mask_write(0xFD070494, 0x0033000FU, 0x0020000BU); + psu_mask_write(0xFD070498, 0x07FF07FFU, 0x00000000U); + psu_mask_write(0xFD0704B4, 0x000073FFU, 0x0000200FU); + psu_mask_write(0xFD0704B8, 0x000073FFU, 0x0000200FU); + psu_mask_write(0xFD070540, 0x00000001U, 0x00000001U); + psu_mask_write(0xFD070544, 0x03330F0FU, 0x02000B03U); + psu_mask_write(0xFD070548, 0x07FF07FFU, 0x00000000U); + psu_mask_write(0xFD070564, 0x000073FFU, 0x0000200FU); + psu_mask_write(0xFD070568, 0x000073FFU, 0x0000200FU); + psu_mask_write(0xFD0705F0, 0x00000001U, 0x00000001U); + psu_mask_write(0xFD0705F4, 0x03330F0FU, 0x02000B03U); + psu_mask_write(0xFD0705F8, 0x07FF07FFU, 0x00000000U); + psu_mask_write(0xFD070614, 0x000073FFU, 0x0000200FU); + psu_mask_write(0xFD070618, 0x000073FFU, 0x0000200FU); + psu_mask_write(0xFD0706A0, 0x00000001U, 0x00000001U); + psu_mask_write(0xFD0706A4, 0x0033000FU, 0x00100003U); + psu_mask_write(0xFD0706A8, 0x07FF07FFU, 0x0000004FU); + psu_mask_write(0xFD0706AC, 0x0033000FU, 0x00100003U); + psu_mask_write(0xFD0706B0, 0x000007FFU, 0x0000004FU); + psu_mask_write(0xFD0706C4, 0x000073FFU, 0x0000200FU); + psu_mask_write(0xFD0706C8, 0x000073FFU, 0x0000200FU); + psu_mask_write(0xFD070750, 0x00000001U, 0x00000001U); + psu_mask_write(0xFD070754, 0x0033000FU, 0x00100003U); + psu_mask_write(0xFD070758, 0x07FF07FFU, 0x0000004FU); + psu_mask_write(0xFD07075C, 0x0033000FU, 0x00100003U); + psu_mask_write(0xFD070760, 0x000007FFU, 0x0000004FU); + psu_mask_write(0xFD070774, 0x000073FFU, 0x0000200FU); + psu_mask_write(0xFD070778, 0x000073FFU, 0x0000200FU); + psu_mask_write(0xFD070800, 0x00000001U, 0x00000001U); + psu_mask_write(0xFD070804, 0x0033000FU, 0x00100003U); + psu_mask_write(0xFD070808, 0x07FF07FFU, 0x0000004FU); + psu_mask_write(0xFD07080C, 0x0033000FU, 0x00100003U); + psu_mask_write(0xFD070810, 0x000007FFU, 0x0000004FU); + psu_mask_write(0xFD070F04, 0x000001FFU, 0x00000000U); + psu_mask_write(0xFD070F08, 0x000000FFU, 0x00000000U); + psu_mask_write(0xFD070F0C, 0x000001FFU, 0x00000010U); + psu_mask_write(0xFD070F10, 0x000000FFU, 0x0000000FU); + psu_mask_write(0xFD072190, 0x1FBFBF3FU, 0x07828002U); + psu_mask_write(0xFD1A0108, 0x0000000CU, 0x00000000U); + psu_mask_write(0xFD080010, 0xFFFFFFFFU, 0x07001E00U); + psu_mask_write(0xFD080018, 0xFFFFFFFFU, 0x00F10010U); + psu_mask_write(0xFD08001C, 0xFFFFFFFFU, 0x55AA5480U); + psu_mask_write(0xFD080024, 0xFFFFFFFFU, 0x010100F4U); + psu_mask_write(0xFD080040, 0xFFFFFFFFU, 0x42C21590U); + psu_mask_write(0xFD080044, 0xFFFFFFFFU, 0xD05512C0U); + psu_mask_write(0xFD080068, 0xFFFFFFFFU, 0x01100000U); + psu_mask_write(0xFD080090, 0xFFFFFFFFU, 0x02A04161U); + psu_mask_write(0xFD0800C0, 0xFFFFFFFFU, 0x00000000U); + psu_mask_write(0xFD0800C4, 0xFFFFFFFFU, 0x000000E0U); + psu_mask_write(0xFD080100, 0xFFFFFFFFU, 0x0800040CU); + psu_mask_write(0xFD080110, 0xFFFFFFFFU, 0x06240F08U); + psu_mask_write(0xFD080114, 0xFFFFFFFFU, 0x28170008U); + psu_mask_write(0xFD080118, 0xFFFFFFFFU, 0x000F0300U); + psu_mask_write(0xFD08011C, 0xFFFFFFFFU, 0x83000800U); + psu_mask_write(0xFD080120, 0xFFFFFFFFU, 0x024B2B07U); + psu_mask_write(0xFD080124, 0xFFFFFFFFU, 0x00370F08U); + psu_mask_write(0xFD080128, 0xFFFFFFFFU, 0x00000E0FU); + psu_mask_write(0xFD080140, 0xFFFFFFFFU, 0x08400020U); + psu_mask_write(0xFD080144, 0xFFFFFFFFU, 0x00000C80U); + psu_mask_write(0xFD080150, 0xFFFFFFFFU, 0x00000000U); + psu_mask_write(0xFD080154, 0xFFFFFFFFU, 0x00000200U); + psu_mask_write(0xFD080180, 0xFFFFFFFFU, 0x00000630U); + psu_mask_write(0xFD080184, 0xFFFFFFFFU, 0x00000501U); + psu_mask_write(0xFD080188, 0xFFFFFFFFU, 0x00000020U); + psu_mask_write(0xFD08018C, 0xFFFFFFFFU, 0x00000200U); + psu_mask_write(0xFD080190, 0xFFFFFFFFU, 0x00000000U); + psu_mask_write(0xFD080194, 0xFFFFFFFFU, 0x00000700U); + psu_mask_write(0xFD080198, 0xFFFFFFFFU, 0x00000819U); + psu_mask_write(0xFD0801AC, 0xFFFFFFFFU, 0x00000000U); + psu_mask_write(0xFD0801B0, 0xFFFFFFFFU, 0x0000004DU); + psu_mask_write(0xFD0801B4, 0xFFFFFFFFU, 0x00000008U); + psu_mask_write(0xFD0801B8, 0xFFFFFFFFU, 0x0000004DU); + psu_mask_write(0xFD0801D8, 0xFFFFFFFFU, 0x00000000U); + psu_mask_write(0xFD080200, 0xFFFFFFFFU, 0x810091C7U); + psu_mask_write(0xFD080204, 0xFFFFFFFFU, 0x00030236U); + psu_mask_write(0xFD080240, 0xFFFFFFFFU, 0x00141054U); + psu_mask_write(0xFD080250, 0xFFFFFFFFU, 0x00088000U); + psu_mask_write(0xFD080414, 0xFFFFFFFFU, 0x12344000U); + psu_mask_write(0xFD0804F4, 0xFFFFFFFFU, 0x00000005U); + psu_mask_write(0xFD080500, 0xFFFFFFFFU, 0x30000028U); + psu_mask_write(0xFD080508, 0xFFFFFFFFU, 0x00000000U); + psu_mask_write(0xFD08050C, 0xFFFFFFFFU, 0x00000005U); + psu_mask_write(0xFD080510, 0xFFFFFFFFU, 0x00000000U); + psu_mask_write(0xFD080520, 0xFFFFFFFFU, 0x0300B0CEU); + psu_mask_write(0xFD080528, 0xFFFFFFFFU, 0xF9032019U); + psu_mask_write(0xFD08052C, 0xFFFFFFFFU, 0x07F001E3U); + psu_mask_write(0xFD080544, 0xFFFFFFFFU, 0x00000000U); + psu_mask_write(0xFD080548, 0xFFFFFFFFU, 0x00000000U); + psu_mask_write(0xFD080558, 0xFFFFFFFFU, 0x00000000U); + psu_mask_write(0xFD08055C, 0xFFFFFFFFU, 0x00000000U); + psu_mask_write(0xFD080560, 0xFFFFFFFFU, 0x00000000U); + psu_mask_write(0xFD080564, 0xFFFFFFFFU, 0x00000000U); + psu_mask_write(0xFD080680, 0xFFFFFFFFU, 0x008AAA58U); + psu_mask_write(0xFD080684, 0xFFFFFFFFU, 0x000079DDU); + psu_mask_write(0xFD080694, 0xFFFFFFFFU, 0x01E10210U); + psu_mask_write(0xFD080698, 0xFFFFFFFFU, 0x01E10000U); + psu_mask_write(0xFD0806A4, 0xFFFFFFFFU, 0x000879DBU); + psu_mask_write(0xFD080700, 0xFFFFFFFFU, 0x40800604U); + psu_mask_write(0xFD080704, 0xFFFFFFFFU, 0x00007FFFU); + psu_mask_write(0xFD08070C, 0xFFFFFFFFU, 0x3F000008U); + psu_mask_write(0xFD080710, 0xFFFFFFFFU, 0x0E00B03CU); + psu_mask_write(0xFD080714, 0xFFFFFFFFU, 0x09094F4FU); + psu_mask_write(0xFD080718, 0xFFFFFFFFU, 0x09092B2BU); + psu_mask_write(0xFD080800, 0xFFFFFFFFU, 0x40800604U); + psu_mask_write(0xFD080804, 0xFFFFFFFFU, 0x00007FFFU); + psu_mask_write(0xFD08080C, 0xFFFFFFFFU, 0x3F000008U); + psu_mask_write(0xFD080810, 0xFFFFFFFFU, 0x0E00B03CU); + psu_mask_write(0xFD080814, 0xFFFFFFFFU, 0x09094F4FU); + psu_mask_write(0xFD080818, 0xFFFFFFFFU, 0x09092B2BU); + psu_mask_write(0xFD080900, 0xFFFFFFFFU, 0x40800604U); + psu_mask_write(0xFD080904, 0xFFFFFFFFU, 0x00007FFFU); + psu_mask_write(0xFD08090C, 0xFFFFFFFFU, 0x3F000008U); + psu_mask_write(0xFD080910, 0xFFFFFFFFU, 0x0E00B00CU); + psu_mask_write(0xFD080914, 0xFFFFFFFFU, 0x09094F4FU); + psu_mask_write(0xFD080918, 0xFFFFFFFFU, 0x09092B2BU); + psu_mask_write(0xFD080A00, 0xFFFFFFFFU, 0x40800604U); + psu_mask_write(0xFD080A04, 0xFFFFFFFFU, 0x00007FFFU); + psu_mask_write(0xFD080A0C, 0xFFFFFFFFU, 0x3F000008U); + psu_mask_write(0xFD080A10, 0xFFFFFFFFU, 0x0E00B00CU); + psu_mask_write(0xFD080A14, 0xFFFFFFFFU, 0x09094F4FU); + psu_mask_write(0xFD080A18, 0xFFFFFFFFU, 0x09092B2BU); + psu_mask_write(0xFD080B00, 0xFFFFFFFFU, 0x80803660U); + psu_mask_write(0xFD080B04, 0xFFFFFFFFU, 0x55556000U); + psu_mask_write(0xFD080B08, 0xFFFFFFFFU, 0xAAAAAAAAU); + psu_mask_write(0xFD080B0C, 0xFFFFFFFFU, 0x0029A4A4U); + psu_mask_write(0xFD080B10, 0xFFFFFFFFU, 0x0C00B000U); + psu_mask_write(0xFD080B14, 0xFFFFFFFFU, 0x09094F4FU); + psu_mask_write(0xFD080B18, 0xFFFFFFFFU, 0x09092B2BU); + psu_mask_write(0xFD080C00, 0xFFFFFFFFU, 0x80803660U); + psu_mask_write(0xFD080C04, 0xFFFFFFFFU, 0x55556000U); + psu_mask_write(0xFD080C08, 0xFFFFFFFFU, 0xAAAAAAAAU); + psu_mask_write(0xFD080C0C, 0xFFFFFFFFU, 0x0029A4A4U); + psu_mask_write(0xFD080C10, 0xFFFFFFFFU, 0x0C00B000U); + psu_mask_write(0xFD080C14, 0xFFFFFFFFU, 0x09094F4FU); + psu_mask_write(0xFD080C18, 0xFFFFFFFFU, 0x09092B2BU); + psu_mask_write(0xFD080D00, 0xFFFFFFFFU, 0x80803660U); + psu_mask_write(0xFD080D04, 0xFFFFFFFFU, 0x55556000U); + psu_mask_write(0xFD080D08, 0xFFFFFFFFU, 0xAAAAAAAAU); + psu_mask_write(0xFD080D0C, 0xFFFFFFFFU, 0x0029A4A4U); + psu_mask_write(0xFD080D10, 0xFFFFFFFFU, 0x0C00B000U); + psu_mask_write(0xFD080D14, 0xFFFFFFFFU, 0x09094F4FU); + psu_mask_write(0xFD080D18, 0xFFFFFFFFU, 0x09092B2BU); + psu_mask_write(0xFD080E00, 0xFFFFFFFFU, 0x80803660U); + psu_mask_write(0xFD080E04, 0xFFFFFFFFU, 0x55556000U); + psu_mask_write(0xFD080E08, 0xFFFFFFFFU, 0xAAAAAAAAU); + psu_mask_write(0xFD080E0C, 0xFFFFFFFFU, 0x0029A4A4U); + psu_mask_write(0xFD080E10, 0xFFFFFFFFU, 0x0C00B000U); + psu_mask_write(0xFD080E14, 0xFFFFFFFFU, 0x09094F4FU); + psu_mask_write(0xFD080E18, 0xFFFFFFFFU, 0x09092B2BU); + psu_mask_write(0xFD080F00, 0xFFFFFFFFU, 0x80803660U); + psu_mask_write(0xFD080F04, 0xFFFFFFFFU, 0x55556000U); + psu_mask_write(0xFD080F08, 0xFFFFFFFFU, 0xAAAAAAAAU); + psu_mask_write(0xFD080F0C, 0xFFFFFFFFU, 0x0029A4A4U); + psu_mask_write(0xFD080F10, 0xFFFFFFFFU, 0x0C00B000U); + psu_mask_write(0xFD080F14, 0xFFFFFFFFU, 0x09094F4FU); + psu_mask_write(0xFD080F18, 0xFFFFFFFFU, 0x09092B2BU); + psu_mask_write(0xFD081400, 0xFFFFFFFFU, 0x2A019FFEU); + psu_mask_write(0xFD081404, 0xFFFFFFFFU, 0x01100000U); + psu_mask_write(0xFD08141C, 0xFFFFFFFFU, 0x01264300U); + psu_mask_write(0xFD08142C, 0xFFFFFFFFU, 0x00041800U); + psu_mask_write(0xFD081430, 0xFFFFFFFFU, 0x70800000U); + psu_mask_write(0xFD081440, 0xFFFFFFFFU, 0x2A019FFEU); + psu_mask_write(0xFD081444, 0xFFFFFFFFU, 0x01100000U); + psu_mask_write(0xFD08145C, 0xFFFFFFFFU, 0x01264300U); + psu_mask_write(0xFD08146C, 0xFFFFFFFFU, 0x00041800U); + psu_mask_write(0xFD081470, 0xFFFFFFFFU, 0x70800000U); + psu_mask_write(0xFD081480, 0xFFFFFFFFU, 0x15019FFEU); + psu_mask_write(0xFD081484, 0xFFFFFFFFU, 0x21100000U); + psu_mask_write(0xFD08149C, 0xFFFFFFFFU, 0x01266300U); + psu_mask_write(0xFD0814AC, 0xFFFFFFFFU, 0x00041800U); + psu_mask_write(0xFD0814B0, 0xFFFFFFFFU, 0x70400000U); + psu_mask_write(0xFD0814C0, 0xFFFFFFFFU, 0x15019FFEU); + psu_mask_write(0xFD0814C4, 0xFFFFFFFFU, 0x21100000U); + psu_mask_write(0xFD0814DC, 0xFFFFFFFFU, 0x01266300U); + psu_mask_write(0xFD0814EC, 0xFFFFFFFFU, 0x00041800U); + psu_mask_write(0xFD0814F0, 0xFFFFFFFFU, 0x70400000U); + psu_mask_write(0xFD081500, 0xFFFFFFFFU, 0x15019FFEU); + psu_mask_write(0xFD081504, 0xFFFFFFFFU, 0x21100000U); + psu_mask_write(0xFD08151C, 0xFFFFFFFFU, 0x01266300U); + psu_mask_write(0xFD08152C, 0xFFFFFFFFU, 0x00041800U); + psu_mask_write(0xFD081530, 0xFFFFFFFFU, 0x70400000U); + psu_mask_write(0xFD0817DC, 0xFFFFFFFFU, 0x012643C4U); + + return 1; +} + +static unsigned long psu_ddr_qos_init_data(void) +{ + psu_mask_write(0xFD360008, 0x0000000FU, 0x00000000U); + psu_mask_write(0xFD36001C, 0x0000000FU, 0x00000000U); + psu_mask_write(0xFD370008, 0x0000000FU, 0x00000000U); + psu_mask_write(0xFD37001C, 0x0000000FU, 0x00000000U); + psu_mask_write(0xFD380008, 0x0000000FU, 0x00000000U); + psu_mask_write(0xFD38001C, 0x0000000FU, 0x00000000U); + psu_mask_write(0xFD390008, 0x0000000FU, 0x00000000U); + psu_mask_write(0xFD39001C, 0x0000000FU, 0x00000000U); + psu_mask_write(0xFD3A0008, 0x0000000FU, 0x00000000U); + psu_mask_write(0xFD3A001C, 0x0000000FU, 0x00000000U); + psu_mask_write(0xFD3B0008, 0x0000000FU, 0x00000000U); + psu_mask_write(0xFD3B001C, 0x0000000FU, 0x00000000U); + psu_mask_write(0xFF9B0008, 0x0000000FU, 0x00000000U); + psu_mask_write(0xFF9B001C, 0x0000000FU, 0x00000000U); + + return 1; +} + +static unsigned long psu_mio_init_data(void) +{ + psu_mask_write(0xFF180034, 0x000000FEU, 0x00000008U); + psu_mask_write(0xFF180038, 0x000000FEU, 0x00000008U); + psu_mask_write(0xFF18003C, 0x000000FEU, 0x00000008U); + psu_mask_write(0xFF180040, 0x000000FEU, 0x00000008U); + psu_mask_write(0xFF180044, 0x000000FEU, 0x00000008U); + psu_mask_write(0xFF180048, 0x000000FEU, 0x00000008U); + psu_mask_write(0xFF18004C, 0x000000FEU, 0x00000008U); + psu_mask_write(0xFF180050, 0x000000FEU, 0x00000008U); + psu_mask_write(0xFF180054, 0x000000FEU, 0x00000008U); + psu_mask_write(0xFF180058, 0x000000FEU, 0x00000008U); + psu_mask_write(0xFF18005C, 0x000000FEU, 0x00000008U); + psu_mask_write(0xFF180068, 0x000000FEU, 0x00000080U); + psu_mask_write(0xFF18006C, 0x000000FEU, 0x00000000U); + psu_mask_write(0xFF180070, 0x000000FEU, 0x00000000U); + psu_mask_write(0xFF180074, 0x000000FEU, 0x00000080U); + psu_mask_write(0xFF180078, 0x000000FEU, 0x00000080U); + psu_mask_write(0xFF18007C, 0x000000FEU, 0x00000080U); + psu_mask_write(0xFF180080, 0x000000FEU, 0x00000000U); + psu_mask_write(0xFF180084, 0x000000FEU, 0x00000000U); + psu_mask_write(0xFF180088, 0x000000FEU, 0x00000040U); + psu_mask_write(0xFF18008C, 0x000000FEU, 0x00000040U); + psu_mask_write(0xFF180090, 0x000000FEU, 0x00000000U); + psu_mask_write(0xFF180094, 0x000000FEU, 0x00000000U); + psu_mask_write(0xFF180098, 0x000000FEU, 0x000000C0U); + psu_mask_write(0xFF18009C, 0x000000FEU, 0x000000C0U); + psu_mask_write(0xFF1800A0, 0x000000FEU, 0x00000000U); + psu_mask_write(0xFF1800A4, 0x000000FEU, 0x00000000U); + psu_mask_write(0xFF1800A8, 0x000000FEU, 0x00000000U); + psu_mask_write(0xFF1800AC, 0x000000FEU, 0x00000000U); + psu_mask_write(0xFF1800B0, 0x000000FEU, 0x00000000U); + psu_mask_write(0xFF1800B4, 0x000000FEU, 0x00000010U); + psu_mask_write(0xFF1800B8, 0x000000FEU, 0x00000010U); + psu_mask_write(0xFF1800BC, 0x000000FEU, 0x00000010U); + psu_mask_write(0xFF1800C0, 0x000000FEU, 0x00000010U); + psu_mask_write(0xFF1800C4, 0x000000FEU, 0x00000010U); + psu_mask_write(0xFF1800C8, 0x000000FEU, 0x00000010U); + psu_mask_write(0xFF1800CC, 0x000000FEU, 0x00000010U); + psu_mask_write(0xFF1800D0, 0x000000FEU, 0x00000004U); + psu_mask_write(0xFF1800D4, 0x000000FEU, 0x00000004U); + psu_mask_write(0xFF1800D8, 0x000000FEU, 0x00000004U); + psu_mask_write(0xFF1800DC, 0x000000FEU, 0x00000004U); + psu_mask_write(0xFF1800E0, 0x000000FEU, 0x00000004U); + psu_mask_write(0xFF1800E4, 0x000000FEU, 0x00000004U); + psu_mask_write(0xFF1800E8, 0x000000FEU, 0x00000004U); + psu_mask_write(0xFF1800EC, 0x000000FEU, 0x00000004U); + psu_mask_write(0xFF1800F0, 0x000000FEU, 0x00000004U); + psu_mask_write(0xFF1800F4, 0x000000FEU, 0x00000004U); + psu_mask_write(0xFF1800F8, 0x000000FEU, 0x00000004U); + psu_mask_write(0xFF1800FC, 0x000000FEU, 0x00000004U); + psu_mask_write(0xFF180100, 0x000000FEU, 0x00000004U); + psu_mask_write(0xFF180104, 0x000000FEU, 0x00000004U); + psu_mask_write(0xFF180108, 0x000000FEU, 0x00000004U); + psu_mask_write(0xFF18010C, 0x000000FEU, 0x00000004U); + psu_mask_write(0xFF180110, 0x000000FEU, 0x00000004U); + psu_mask_write(0xFF180114, 0x000000FEU, 0x00000004U); + psu_mask_write(0xFF180118, 0x000000FEU, 0x00000004U); + psu_mask_write(0xFF18011C, 0x000000FEU, 0x00000004U); + psu_mask_write(0xFF180120, 0x000000FEU, 0x00000004U); + psu_mask_write(0xFF180124, 0x000000FEU, 0x00000004U); + psu_mask_write(0xFF180128, 0x000000FEU, 0x00000004U); + psu_mask_write(0xFF18012C, 0x000000FEU, 0x00000004U); + psu_mask_write(0xFF180130, 0x000000FEU, 0x00000060U); + psu_mask_write(0xFF180134, 0x000000FEU, 0x00000060U); + psu_mask_write(0xFF180204, 0xFCFFE000U, 0x00000000U); + psu_mask_write(0xFF180208, 0xFFFFFFFFU, 0x00B02040U); + psu_mask_write(0xFF18020C, 0x00003FFFU, 0x0000000BU); + psu_mask_write(0xFF180138, 0x03FFFFFFU, 0x03FFFFFFU); + psu_mask_write(0xFF18013C, 0x03FFFFFFU, 0x03FFFFFFU); + psu_mask_write(0xFF180140, 0x03FFFFFFU, 0x033FFFFFU); + psu_mask_write(0xFF180144, 0x03FFFFFFU, 0x03FFFFFFU); + psu_mask_write(0xFF180148, 0x03FFFFFFU, 0x03FFFFFFU); + psu_mask_write(0xFF18014C, 0x03FFFFFFU, 0x03FFFFFFU); + psu_mask_write(0xFF180154, 0x03FFFFFFU, 0x03FFFFFFU); + psu_mask_write(0xFF180158, 0x03FFFFFFU, 0x03FFFFFFU); + psu_mask_write(0xFF18015C, 0x03FFFFFFU, 0x01FF9FFFU); + psu_mask_write(0xFF180160, 0x03FFFFFFU, 0x03FFFFFFU); + psu_mask_write(0xFF180164, 0x03FFFFFFU, 0x03FFFFFFU); + psu_mask_write(0xFF180168, 0x03FFFFFFU, 0x03F76FFFU); + psu_mask_write(0xFF180170, 0x03FFFFFFU, 0x03FFFFFFU); + psu_mask_write(0xFF180174, 0x03FFFFFFU, 0x03FFFFFFU); + psu_mask_write(0xFF180178, 0x03FFFFFFU, 0x02FBFFBFU); + psu_mask_write(0xFF18017C, 0x03FFFFFFU, 0x03FFFFFFU); + psu_mask_write(0xFF180180, 0x03FFFFFFU, 0x03FFFFFFU); + psu_mask_write(0xFF180184, 0x03FFFFFFU, 0x03FF4FF4U); + psu_mask_write(0xFF180200, 0x0000000FU, 0x00000000U); + + return 1; +} + +static unsigned long psu_peripherals_pre_init_data(void) +{ + psu_mask_write(0xFF5E0108, 0x013F3F07U, 0x01012302U); + + return 1; +} + +static unsigned long psu_peripherals_init_data(void) +{ + psu_mask_write(0xFD1A0100, 0x0000807CU, 0x00000000U); + psu_mask_write(0xFF5E0238, 0x001A0000U, 0x00000000U); + psu_mask_write(0xFF5E023C, 0x0093C018U, 0x00000000U); + psu_mask_write(0xFF5E0230, 0x00000001U, 0x00000000U); + psu_mask_write(0xFF5E023C, 0x00000C00U, 0x00000000U); + psu_mask_write(0xFF5E0238, 0x00000060U, 0x00000000U); + psu_mask_write(0xFF180310, 0x00008001U, 0x00000001U); + psu_mask_write(0xFF180320, 0x33843384U, 0x00801284U); + psu_mask_write(0xFF18031C, 0x00007FFEU, 0x00006450U); + psu_mask_write(0xFF180358, 0x00080000U, 0x00080000U); + psu_mask_write(0xFF18031C, 0x7FFE0000U, 0x64500000U); + psu_mask_write(0xFF180358, 0x00000008U, 0x00000008U); + psu_mask_write(0xFF180324, 0x000003C0U, 0x00000000U); + psu_mask_write(0xFF180324, 0x03C00000U, 0x00000000U); + psu_mask_write(0xFF5E0238, 0x00000200U, 0x00000000U); + psu_mask_write(0xFF5E0238, 0x00008000U, 0x00000000U); + psu_mask_write(0xFF5E0238, 0x00000008U, 0x00000000U); + psu_mask_write(0xFF5E0238, 0x00007800U, 0x00000000U); + psu_mask_write(0xFF5E0238, 0x00000002U, 0x00000000U); + psu_mask_write(0xFF000034, 0x000000FFU, 0x00000005U); + psu_mask_write(0xFF000018, 0x0000FFFFU, 0x0000008FU); + psu_mask_write(0xFF000000, 0x000001FFU, 0x00000017U); + psu_mask_write(0xFF000004, 0x000003FFU, 0x00000020U); + psu_mask_write(0xFF5E0238, 0x00040000U, 0x00000000U); + psu_mask_write(0xFF4B0024, 0x000000FFU, 0x000000FFU); + psu_mask_write(0xFFCA5000, 0x00001FFFU, 0x00000000U); + psu_mask_write(0xFD5C0060, 0x000F000FU, 0x00000000U); + psu_mask_write(0xFFA60040, 0x80000000U, 0x80000000U); + psu_mask_write(0xFF260020, 0xFFFFFFFFU, 0x01FC9F08U); + psu_mask_write(0xFF260000, 0x00000001U, 0x00000001U); + psu_mask_write(0xFF5E0250, 0x00000F0FU, 0x00000202U); + + mask_delay(1); + psu_mask_write(0xFF5E0250, 0x00000F0FU, 0x00000002U); + + mask_delay(5); + psu_mask_write(0xFF5E0250, 0x00000F0FU, 0x00000202U); + + return 1; +} + +static unsigned long psu_serdes_init_data(void) +{ + psu_mask_write(0xFD410000, 0x0000001FU, 0x0000000FU); + psu_mask_write(0xFD410004, 0x0000001FU, 0x00000008U); + psu_mask_write(0xFD402860, 0x00000080U, 0x00000080U); + psu_mask_write(0xFD402864, 0x00000080U, 0x00000080U); + psu_mask_write(0xFD406094, 0x00000010U, 0x00000010U); + psu_mask_write(0xFD406368, 0x000000FFU, 0x00000038U); + psu_mask_write(0xFD40636C, 0x00000007U, 0x00000003U); + psu_mask_write(0xFD406370, 0x000000FFU, 0x000000F4U); + psu_mask_write(0xFD406374, 0x000000FFU, 0x00000031U); + psu_mask_write(0xFD406378, 0x000000FFU, 0x00000002U); + psu_mask_write(0xFD40637C, 0x00000033U, 0x00000030U); + psu_mask_write(0xFD40106C, 0x0000000FU, 0x0000000FU); + psu_mask_write(0xFD4000F4, 0x0000000BU, 0x0000000BU); + psu_mask_write(0xFD40506C, 0x00000003U, 0x00000003U); + psu_mask_write(0xFD4040F4, 0x00000003U, 0x00000003U); + psu_mask_write(0xFD4050CC, 0x00000020U, 0x00000020U); + psu_mask_write(0xFD401074, 0x00000010U, 0x00000010U); + psu_mask_write(0xFD405074, 0x00000010U, 0x00000010U); + psu_mask_write(0xFD409074, 0x00000010U, 0x00000010U); + psu_mask_write(0xFD40D074, 0x00000010U, 0x00000010U); + psu_mask_write(0xFD40189C, 0x00000080U, 0x00000080U); + psu_mask_write(0xFD4018F8, 0x000000FFU, 0x0000007DU); + psu_mask_write(0xFD4018FC, 0x000000FFU, 0x0000007DU); + psu_mask_write(0xFD401990, 0x000000FFU, 0x00000000U); + psu_mask_write(0xFD401924, 0x000000FFU, 0x00000082U); + psu_mask_write(0xFD401928, 0x000000FFU, 0x00000000U); + psu_mask_write(0xFD401900, 0x000000FFU, 0x00000064U); + psu_mask_write(0xFD40192C, 0x000000FFU, 0x00000000U); + psu_mask_write(0xFD401980, 0x000000FFU, 0x000000FFU); + psu_mask_write(0xFD401914, 0x000000FFU, 0x000000FFU); + psu_mask_write(0xFD401918, 0x00000001U, 0x00000001U); + psu_mask_write(0xFD401940, 0x000000FFU, 0x000000FFU); + psu_mask_write(0xFD401944, 0x00000001U, 0x00000001U); + psu_mask_write(0xFD401994, 0x00000007U, 0x00000007U); + psu_mask_write(0xFD40589C, 0x00000080U, 0x00000080U); + psu_mask_write(0xFD4058F8, 0x000000FFU, 0x0000001AU); + psu_mask_write(0xFD4058FC, 0x000000FFU, 0x0000001AU); + psu_mask_write(0xFD405990, 0x000000FFU, 0x00000010U); + psu_mask_write(0xFD405924, 0x000000FFU, 0x000000FEU); + psu_mask_write(0xFD405928, 0x000000FFU, 0x00000000U); + psu_mask_write(0xFD405900, 0x000000FFU, 0x0000001AU); + psu_mask_write(0xFD40592C, 0x000000FFU, 0x00000000U); + psu_mask_write(0xFD405980, 0x000000FFU, 0x000000FFU); + psu_mask_write(0xFD405914, 0x000000FFU, 0x000000F7U); + psu_mask_write(0xFD405918, 0x00000001U, 0x00000001U); + psu_mask_write(0xFD405940, 0x000000FFU, 0x000000F7U); + psu_mask_write(0xFD405944, 0x00000001U, 0x00000001U); + psu_mask_write(0xFD405994, 0x00000007U, 0x00000007U); + psu_mask_write(0xFD409994, 0x00000007U, 0x00000007U); + psu_mask_write(0xFD40D994, 0x00000007U, 0x00000007U); + psu_mask_write(0xFD40107C, 0x0000000FU, 0x00000001U); + psu_mask_write(0xFD40507C, 0x0000000FU, 0x00000001U); + psu_mask_write(0xFD40907C, 0x0000000FU, 0x00000001U); + psu_mask_write(0xFD40D07C, 0x0000000FU, 0x00000001U); + psu_mask_write(0xFD4019A4, 0x000000FFU, 0x000000FFU); + psu_mask_write(0xFD401038, 0x00000040U, 0x00000040U); + psu_mask_write(0xFD40102C, 0x00000040U, 0x00000040U); + psu_mask_write(0xFD4059A4, 0x000000FFU, 0x000000FFU); + psu_mask_write(0xFD405038, 0x00000040U, 0x00000040U); + psu_mask_write(0xFD40502C, 0x00000040U, 0x00000040U); + psu_mask_write(0xFD4099A4, 0x000000FFU, 0x000000FFU); + psu_mask_write(0xFD409038, 0x00000040U, 0x00000040U); + psu_mask_write(0xFD40902C, 0x00000040U, 0x00000040U); + psu_mask_write(0xFD40D9A4, 0x000000FFU, 0x000000FFU); + psu_mask_write(0xFD40D038, 0x00000040U, 0x00000040U); + psu_mask_write(0xFD40D02C, 0x00000040U, 0x00000040U); + psu_mask_write(0xFD4019AC, 0x00000003U, 0x00000000U); + psu_mask_write(0xFD4059AC, 0x00000003U, 0x00000000U); + psu_mask_write(0xFD4099AC, 0x00000003U, 0x00000000U); + psu_mask_write(0xFD40D9AC, 0x00000003U, 0x00000000U); + psu_mask_write(0xFD401978, 0x00000010U, 0x00000010U); + psu_mask_write(0xFD405978, 0x00000010U, 0x00000010U); + psu_mask_write(0xFD409978, 0x00000010U, 0x00000010U); + psu_mask_write(0xFD40D978, 0x00000010U, 0x00000010U); + psu_mask_write(0xFD410010, 0x00000077U, 0x00000035U); + psu_mask_write(0xFD410040, 0x00000003U, 0x00000000U); + psu_mask_write(0xFD410044, 0x00000003U, 0x00000000U); + + return 1; +} + +static unsigned long psu_resetout_init_data(void) +{ + psu_mask_write(0xFF5E023C, 0x00000400U, 0x00000000U); + psu_mask_write(0xFF9D0080, 0x00000001U, 0x00000001U); + psu_mask_write(0xFF9D007C, 0x00000001U, 0x00000000U); + psu_mask_write(0xFF5E023C, 0x00000140U, 0x00000000U); + psu_mask_write(0xFF5E023C, 0x00000800U, 0x00000000U); + psu_mask_write(0xFF9E0080, 0x00000001U, 0x00000001U); + psu_mask_write(0xFF9E007C, 0x00000001U, 0x00000001U); + psu_mask_write(0xFF5E023C, 0x00000280U, 0x00000000U); + psu_mask_write(0xFF5E0230, 0x00000001U, 0x00000000U); + psu_mask_write(0xFE20C200, 0x00023FFFU, 0x00022457U); + psu_mask_write(0xFE20C630, 0x003FFF00U, 0x00000000U); + psu_mask_write(0xFE20C11C, 0x00000600U, 0x00000600U); + psu_mask_write(0xFE20C12C, 0x00004000U, 0x00004000U); + psu_mask_write(0xFE30C200, 0x00023FFFU, 0x00022457U); + psu_mask_write(0xFE30C630, 0x003FFF00U, 0x00000000U); + psu_mask_write(0xFE30C12C, 0x00004000U, 0x00004000U); + psu_mask_write(0xFE30C11C, 0x00000400U, 0x00000400U); + psu_mask_write(0xFD480064, 0x00000200U, 0x00000200U); + mask_poll(0xFD4023E4, 0x00000010U); + mask_poll(0xFD4063E4, 0x00000010U); + + return 1; +} + +static unsigned long psu_resetin_init_data(void) +{ + psu_mask_write(0xFF5E023C, 0x00000540U, 0x00000540U); + psu_mask_write(0xFF5E023C, 0x00000A80U, 0x00000A80U); + psu_mask_write(0xFF5E0230, 0x00000001U, 0x00000001U); + + return 1; +} + +static unsigned long psu_afi_config(void) +{ + psu_mask_write(0xFD1A0100, 0x00001F80U, 0x00000000U); + psu_mask_write(0xFF5E023C, 0x00080000U, 0x00000000U); + psu_mask_write(0xFD615000, 0x00000F00U, 0x00000A00U); + psu_mask_write(0xFF419000, 0x00000300U, 0x00000000U); + psu_mask_write(0xFD360000, 0x00000003U, 0x00000000U); + psu_mask_write(0xFD360014, 0x00000003U, 0x00000000U); + + return 1; +} + +static unsigned long psu_ddr_phybringup_data(void) +{ + unsigned int regval = 0; + unsigned int pll_retry = 10; + unsigned int pll_locked = 0; + int cur_r006_trefprd; + + while ((pll_retry > 0) && (!pll_locked)) { + Xil_Out32(0xFD080004, 0x00040010); + Xil_Out32(0xFD080004, 0x00040011); + + while ((Xil_In32(0xFD080030) & 0x1) != 1) + ; + pll_locked = (Xil_In32(0xFD080030) & 0x80000000) + >> 31; + pll_locked &= (Xil_In32(0xFD0807E0) & 0x10000) + >> 16; + pll_locked &= (Xil_In32(0xFD0809E0) & 0x10000) + >> 16; + pll_retry--; + } + Xil_Out32(0xFD0800C4, Xil_In32(0xFD0800C4) | (pll_retry << 16)); + if (!pll_locked) + return 0; + + Xil_Out32(0xFD080004U, 0x00040063U); + + while ((Xil_In32(0xFD080030U) & 0x0000000FU) != 0x0000000FU) + ; + prog_reg(0xFD080004U, 0x00000001U, 0x00000000U, 0x00000001U); + + while ((Xil_In32(0xFD080030U) & 0x000000FFU) != 0x0000001FU) + ; + Xil_Out32(0xFD0701B0U, 0x00000001U); + Xil_Out32(0xFD070320U, 0x00000001U); + while ((Xil_In32(0xFD070004U) & 0x0000000FU) != 0x00000001U) + ; + prog_reg(0xFD080014U, 0x00000040U, 0x00000006U, 0x00000001U); + Xil_Out32(0xFD080004, 0x0004FE01); + regval = Xil_In32(0xFD080030); + while (regval != 0x80000FFF) + regval = Xil_In32(0xFD080030); + regval = ((Xil_In32(0xFD080030) & 0x1FFF0000) >> 18); + if (regval != 0) + return 0; + + Xil_Out32(0xFD080200U, 0x110091C7U); + + cur_r006_trefprd = (Xil_In32(0xFD080018U) & 0x0003FFFFU) >> 0x00000000U; + prog_reg(0xFD080018, 0x3FFFF, 0x0, cur_r006_trefprd); + + prog_reg(0xFD08001CU, 0x00000018U, 0x00000003U, 0x00000003U); + prog_reg(0xFD08142CU, 0x00000030U, 0x00000004U, 0x00000003U); + prog_reg(0xFD08146CU, 0x00000030U, 0x00000004U, 0x00000003U); + prog_reg(0xFD0814ACU, 0x00000030U, 0x00000004U, 0x00000003U); + prog_reg(0xFD0814ECU, 0x00000030U, 0x00000004U, 0x00000003U); + prog_reg(0xFD08152CU, 0x00000030U, 0x00000004U, 0x00000003U); + + Xil_Out32(0xFD080004, 0x00060001); + regval = Xil_In32(0xFD080030); + while ((regval & 0x80004001) != 0x80004001) + regval = Xil_In32(0xFD080030); + + prog_reg(0xFD08001CU, 0x00000018U, 0x00000003U, 0x00000000U); + prog_reg(0xFD08142CU, 0x00000030U, 0x00000004U, 0x00000000U); + prog_reg(0xFD08146CU, 0x00000030U, 0x00000004U, 0x00000000U); + prog_reg(0xFD0814ACU, 0x00000030U, 0x00000004U, 0x00000000U); + prog_reg(0xFD0814ECU, 0x00000030U, 0x00000004U, 0x00000000U); + prog_reg(0xFD08152CU, 0x00000030U, 0x00000004U, 0x00000000U); + + Xil_Out32(0xFD080200U, 0x810091C7U); + prog_reg(0xFD080018, 0x3FFFF, 0x0, cur_r006_trefprd); + + Xil_Out32(0xFD080004, 0x0000C001); + regval = Xil_In32(0xFD080030); + while ((regval & 0x80000C01) != 0x80000C01) + regval = Xil_In32(0xFD080030); + + Xil_Out32(0xFD070180U, 0x01000040U); + Xil_Out32(0xFD070060U, 0x00000000U); + prog_reg(0xFD080014U, 0x00000040U, 0x00000006U, 0x00000000U); + + return 1; +} + +static int serdes_enb_coarse_saturation(void) +{ + Xil_Out32(0xFD402094, 0x00000010); + Xil_Out32(0xFD406094, 0x00000010); + Xil_Out32(0xFD40A094, 0x00000010); + Xil_Out32(0xFD40E094, 0x00000010); + return 1; +} + +static int serdes_fixcal_code(void) +{ + int maskstatus = 1; + unsigned int rdata = 0; + unsigned int match_pmos_code[23]; + unsigned int match_nmos_code[23]; + unsigned int match_ical_code[7]; + unsigned int match_rcal_code[7]; + unsigned int p_code = 0, n_code = 0, i_code = 0, r_code = 0; + unsigned int repeat_count = 0; + unsigned int L3_TM_CALIB_DIG20 = 0; + unsigned int L3_TM_CALIB_DIG19 = 0; + unsigned int L3_TM_CALIB_DIG18 = 0; + unsigned int L3_TM_CALIB_DIG16 = 0; + unsigned int L3_TM_CALIB_DIG15 = 0; + unsigned int L3_TM_CALIB_DIG14 = 0; + int count = 0, i = 0; + + rdata = Xil_In32(0xFD40289C); + rdata = rdata & ~0x03; + rdata = rdata | 0x1; + Xil_Out32(0xFD40289C, rdata); + + do { + if (count == 1100000) + break; + rdata = Xil_In32(0xFD402B1C); + count++; + } while ((rdata & 0x0000000E) != 0x0000000E); + + for (i = 0; i < 23; i++) { + match_pmos_code[i] = 0; + match_nmos_code[i] = 0; + } + for (i = 0; i < 7; i++) { + match_ical_code[i] = 0; + match_rcal_code[i] = 0; + } + + do { + Xil_Out32(0xFD410010, 0x00000000); + Xil_Out32(0xFD410014, 0x00000000); + + Xil_Out32(0xFD410010, 0x00000001); + Xil_Out32(0xFD410014, 0x00000000); + + maskstatus = mask_poll(0xFD40EF14, 0x2); + if (maskstatus == 0) { + xil_printf("#SERDES initialization timed out\n\r"); + return maskstatus; + } + + p_code = mask_read(0xFD40EF18, 0xFFFFFFFF); + n_code = mask_read(0xFD40EF1C, 0xFFFFFFFF); + ; + i_code = mask_read(0xFD40EF24, 0xFFFFFFFF); + r_code = mask_read(0xFD40EF28, 0xFFFFFFFF); + ; + + if (p_code >= 0x26 && p_code <= 0x3C) + match_pmos_code[p_code - 0x26] += 1; + + if (n_code >= 0x26 && n_code <= 0x3C) + match_nmos_code[n_code - 0x26] += 1; + + if (i_code >= 0xC && i_code <= 0x12) + match_ical_code[i_code - 0xc] += 1; + + if (r_code >= 0x6 && r_code <= 0xC) + match_rcal_code[r_code - 0x6] += 1; + + } while (repeat_count++ < 10); + + for (i = 0; i < 23; i++) { + if (match_pmos_code[i] >= match_pmos_code[0]) { + match_pmos_code[0] = match_pmos_code[i]; + p_code = 0x26 + i; + } + if (match_nmos_code[i] >= match_nmos_code[0]) { + match_nmos_code[0] = match_nmos_code[i]; + n_code = 0x26 + i; + } + } + + for (i = 0; i < 7; i++) { + if (match_ical_code[i] >= match_ical_code[0]) { + match_ical_code[0] = match_ical_code[i]; + i_code = 0xC + i; + } + if (match_rcal_code[i] >= match_rcal_code[0]) { + match_rcal_code[0] = match_rcal_code[i]; + r_code = 0x6 + i; + } + } + + L3_TM_CALIB_DIG20 = mask_read(0xFD40EC50, 0xFFFFFFF0); + L3_TM_CALIB_DIG20 = L3_TM_CALIB_DIG20 | 0x8 | ((p_code >> 2) & 0x7); + + L3_TM_CALIB_DIG19 = mask_read(0xFD40EC4C, 0xFFFFFF18); + L3_TM_CALIB_DIG19 = L3_TM_CALIB_DIG19 | ((p_code & 0x3) << 6) + | 0x20 | 0x4 | ((n_code >> 3) & 0x3); + + L3_TM_CALIB_DIG18 = mask_read(0xFD40EC48, 0xFFFFFF0F); + L3_TM_CALIB_DIG18 = L3_TM_CALIB_DIG18 | ((n_code & 0x7) << 5) | 0x10; + + L3_TM_CALIB_DIG16 = mask_read(0xFD40EC40, 0xFFFFFFF8); + L3_TM_CALIB_DIG16 = L3_TM_CALIB_DIG16 | ((r_code >> 1) & 0x7); + + L3_TM_CALIB_DIG15 = mask_read(0xFD40EC3C, 0xFFFFFF30); + L3_TM_CALIB_DIG15 = L3_TM_CALIB_DIG15 | ((r_code & 0x1) << 7) + | 0x40 | 0x8 | ((i_code >> 1) & 0x7); + + L3_TM_CALIB_DIG14 = mask_read(0xFD40EC38, 0xFFFFFF3F); + L3_TM_CALIB_DIG14 = L3_TM_CALIB_DIG14 | ((i_code & 0x1) << 7) | 0x40; + + Xil_Out32(0xFD40EC50, L3_TM_CALIB_DIG20); + Xil_Out32(0xFD40EC4C, L3_TM_CALIB_DIG19); + Xil_Out32(0xFD40EC48, L3_TM_CALIB_DIG18); + Xil_Out32(0xFD40EC40, L3_TM_CALIB_DIG16); + Xil_Out32(0xFD40EC3C, L3_TM_CALIB_DIG15); + Xil_Out32(0xFD40EC38, L3_TM_CALIB_DIG14); + return maskstatus; +} + +static int init_serdes(void) +{ + int status = 1; + + status &= psu_resetin_init_data(); + + status &= serdes_fixcal_code(); + status &= serdes_enb_coarse_saturation(); + + status &= psu_serdes_init_data(); + status &= psu_resetout_init_data(); + + return status; +} + +static void init_peripheral(void) +{ + psu_mask_write(0xFD5F0018, 0x8000001FU, 0x8000001FU); +} + +int psu_init(void) +{ + int status = 1; + + status &= psu_mio_init_data(); + status &= psu_peripherals_pre_init_data(); + status &= psu_pll_init_data(); + status &= psu_clock_init_data(); + status &= psu_ddr_init_data(); + status &= psu_ddr_phybringup_data(); + status &= psu_peripherals_init_data(); + status &= init_serdes(); + init_peripheral(); + + status &= psu_afi_config(); + psu_ddr_qos_init_data(); + + if (status == 0) + return 1; + return 0; +} diff --git a/configs/xilinx_zynqmp_virt_defconfig b/configs/xilinx_zynqmp_virt_defconfig index ff5c8dc9bf..6c2a13257d 100644 --- a/configs/xilinx_zynqmp_virt_defconfig +++ b/configs/xilinx_zynqmp_virt_defconfig @@ -81,7 +81,7 @@ CONFIG_CMD_MTDPARTS_SHOW_NET_SIZES=y CONFIG_CMD_UBI=y CONFIG_PARTITION_TYPE_GUID=y CONFIG_SPL_OF_CONTROL=y -CONFIG_OF_LIST="avnet-ultra96-rev1 zynqmp-a2197-revA zynqmp-e-a2197-00-revA zynqmp-g-a2197-00-revA zynqmp-m-a2197-01-revA zynqmp-m-a2197-02-revA zynqmp-m-a2197-03-revA zynqmp-p-a2197-00-revA zynqmp-zc1232-revA zynqmp-zc1254-revA zynqmp-zc1751-xm015-dc1 zynqmp-zc1751-xm016-dc2 zynqmp-zc1751-xm017-dc3 zynqmp-zc1751-xm018-dc4 zynqmp-zc1751-xm019-dc5 zynqmp-zcu100-revC zynqmp-zcu102-rev1.1 zynqmp-zcu102-rev1.0 zynqmp-zcu102-revA zynqmp-zcu102-revB zynqmp-zcu104-revA zynqmp-zcu104-revC zynqmp-zcu106-revA zynqmp-zcu111-revA zynqmp-zcu1275-revA zynqmp-zcu1275-revB zynqmp-zcu1285-revA zynqmp-zcu208-revA zynqmp-zcu216-revA zynqmp-topic-miamimp-xilinx-xdp-v1r1 zynqmp-sm-k26-revA zynqmp-smk-k26-revA" +CONFIG_OF_LIST="avnet-ultra96-rev1 zynqmp-a2197-revA zynqmp-e-a2197-00-revA zynqmp-g-a2197-00-revA zynqmp-m-a2197-01-revA zynqmp-m-a2197-02-revA zynqmp-m-a2197-03-revA zynqmp-p-a2197-00-revA zynqmp-zc1232-revA zynqmp-zc1254-revA zynqmp-zc1751-xm015-dc1 zynqmp-zc1751-xm016-dc2 zynqmp-zc1751-xm017-dc3 zynqmp-zc1751-xm018-dc4 zynqmp-zc1751-xm019-dc5 zynqmp-zcu100-revC zynqmp-zcu102-rev1.1 zynqmp-zcu102-rev1.0 zynqmp-zcu102-revA zynqmp-zcu102-revB zynqmp-zcu104-revA zynqmp-zcu104-revC zynqmp-zcu106-revA zynqmp-zcu111-revA zynqmp-zcu1275-revA zynqmp-zcu1275-revB zynqmp-zcu1285-revA zynqmp-zcu208-revA zynqmp-zcu216-revA zynqmp-topic-miamimp-xilinx-xdp-v1r1 zynqmp-sm-k26-revA zynqmp-smk-k26-revA zynqmp-dlc21-revA" CONFIG_OF_SPL_REMOVE_PROPS="pinctrl-0 pinctrl-names interrupt-parent interrupts iommus power-domains" CONFIG_ENV_IS_NOWHERE=y CONFIG_ENV_IS_IN_FAT=y From 599becb0ae6a8a52db74c2922f0c8ea601d7b003 Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Fri, 15 Oct 2021 14:48:20 +0200 Subject: [PATCH 05/69] arm64: zynqmp: Fix sgmii clock input freq for p-a2197 Input frequency for sgmii is 125MHz on all Xilinx designs. Signed-off-by: Michal Simek Link: https://lore.kernel.org/r/87153c59cc526f5955b3bff3db11027b5848c042.1634302099.git.michal.simek@xilinx.com --- arch/arm/dts/zynqmp-p-a2197-00-revA.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/dts/zynqmp-p-a2197-00-revA.dts b/arch/arm/dts/zynqmp-p-a2197-00-revA.dts index c893aaaafd..5d21795de9 100644 --- a/arch/arm/dts/zynqmp-p-a2197-00-revA.dts +++ b/arch/arm/dts/zynqmp-p-a2197-00-revA.dts @@ -46,7 +46,7 @@ si5332_1: si5332_1 { /* clk0_sgmii - u142 */ compatible = "fixed-clock"; #clock-cells = <0>; - clock-frequency = <33333333>; /* FIXME */ + clock-frequency = <125000000>; }; si5332_2: si5332_2 { /* clk1_usb - u142 */ From eafdcda4a854932c0319656de7bf3f017f17ae67 Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Fri, 15 Oct 2021 15:03:29 +0200 Subject: [PATCH 06/69] net: gem: Disable broadcast setting There is no need for GEM to accepts broadcast packets because they are not handled by u-boot anyway. That's why use HW IP feature and don't waste time on these packats which will be dropped anyway. Signed-off-by: Michal Simek Reviewed-by: Ramon Fried Link: https://lore.kernel.org/r/0e236c3a6514a2a633ef3a5b71a967c46f7fbae7.1634303007.git.michal.simek@xilinx.com --- drivers/net/zynq_gem.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/zynq_gem.c b/drivers/net/zynq_gem.c index ff59982267..c309c3c954 100644 --- a/drivers/net/zynq_gem.c +++ b/drivers/net/zynq_gem.c @@ -60,6 +60,7 @@ #define ZYNQ_GEM_NWCFG_SPEED100 0x00000001 /* 100 Mbps operation */ #define ZYNQ_GEM_NWCFG_SPEED1000 0x00000400 /* 1Gbps operation */ #define ZYNQ_GEM_NWCFG_FDEN 0x00000002 /* Full Duplex mode */ +#define ZYNQ_GEM_NWCFG_NO_BRDC BIT(5) /* No broadcast */ #define ZYNQ_GEM_NWCFG_FSREM 0x00020000 /* FCS removal */ #define ZYNQ_GEM_NWCFG_SGMII_ENBL 0x08000000 /* SGMII Enable */ #define ZYNQ_GEM_NWCFG_PCS_SEL 0x00000800 /* PCS select */ @@ -77,6 +78,7 @@ #define ZYNQ_GEM_NWCFG_INIT (ZYNQ_GEM_DBUS_WIDTH | \ ZYNQ_GEM_NWCFG_FDEN | \ + ZYNQ_GEM_NWCFG_NO_BRDC | \ ZYNQ_GEM_NWCFG_FSREM | \ ZYNQ_GEM_NWCFG_MDCCLKDIV) From b05cc389bac1151aa6b14e2d6a66d06329d7e3fe Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Fri, 15 Oct 2021 16:57:38 +0200 Subject: [PATCH 07/69] firmware: zynqmp: Handle errors from ipi_req properly There are multiple errors what can happen in ipi_req but they are not propagated properly. That's why propage all error properly. Signed-off-by: Michal Simek Reviewed-by: Adrian Fiergolski Link: https://lore.kernel.org/r/7ac4f3b2104f04c72d287c46d1ccbce20f138fd4.1634309856.git.michal.simek@xilinx.com --- drivers/firmware/firmware-zynqmp.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/firmware/firmware-zynqmp.c b/drivers/firmware/firmware-zynqmp.c index d4dc856baf..7e0acc5bc8 100644 --- a/drivers/firmware/firmware-zynqmp.c +++ b/drivers/firmware/firmware-zynqmp.c @@ -164,6 +164,7 @@ int __maybe_unused xilinx_pm_request(u32 api_id, u32 arg0, u32 arg1, u32 arg2, * firmware API is limited by the SMC call size */ u32 regs[] = {api_id, arg0, arg1, arg2, arg3}; + int ret; if (api_id == PM_FPGA_LOAD) { /* Swap addr_hi/low because of incompatibility */ @@ -173,7 +174,10 @@ int __maybe_unused xilinx_pm_request(u32 api_id, u32 arg0, u32 arg1, u32 arg2, regs[2] = temp; } - ipi_req(regs, PAYLOAD_ARG_CNT, ret_payload, PAYLOAD_ARG_CNT); + ret = ipi_req(regs, PAYLOAD_ARG_CNT, ret_payload, + PAYLOAD_ARG_CNT); + if (ret) + return ret; #else return -EPERM; #endif From 53f5d1688e33f4c9c1e68ba132d50f8aca06fc3b Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Fri, 15 Oct 2021 16:57:39 +0200 Subject: [PATCH 08/69] firmware: zynqmp: fix write to an uninitialised pointer in ipi_req() When a caller is not interested in the returned message, the ret_payload pointer is set to NULL in the u-boot-sources. In this case, under EL3, the memory from address 0x0 would be overwritten by ipi_req() with the returned IPI message, damaging the original data under this address. The patch, in case ret_payload is NULL, assigns the pointer to the array holding the IPI message being sent. Signed-off-by: Adrian Fiergolski Signed-off-by: Michal Simek Reviewed-by: Adrian Fiergolski Link: https://lore.kernel.org/r/3178ff7651948270b714daa4adad48b94eaca9ba.1634309856.git.michal.simek@xilinx.com --- drivers/firmware/firmware-zynqmp.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/firmware/firmware-zynqmp.c b/drivers/firmware/firmware-zynqmp.c index 7e0acc5bc8..b44fede307 100644 --- a/drivers/firmware/firmware-zynqmp.c +++ b/drivers/firmware/firmware-zynqmp.c @@ -29,6 +29,10 @@ static int ipi_req(const u32 *req, size_t req_len, u32 *res, size_t res_maxlen) { struct zynqmp_ipi_msg msg; int ret; + u32 buffer[PAYLOAD_ARG_CNT]; + + if (!res) + res = buffer; if (req_len > PMUFW_PAYLOAD_ARG_CNT || res_maxlen > PMUFW_PAYLOAD_ARG_CNT) From f510927d55e44bc06a742cd774515197b5c6c128 Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Mon, 18 Oct 2021 13:30:04 +0200 Subject: [PATCH 09/69] xilinx: zynqmp: Handle fallthrough statement properly Now intentional fallthrough in switch-case should be labelled that's why convert comment. Signed-off-by: Michal Simek Reviewed-by: Oleksandr Suvorov Link: https://lore.kernel.org/r/b3e976bd3b9bbe7061fec5ba0a3b4e78fdd78394.1634556602.git.michal.simek@xilinx.com --- board/xilinx/zynqmp/zynqmp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c index b24db5306a..e8ae549698 100644 --- a/board/xilinx/zynqmp/zynqmp.c +++ b/board/xilinx/zynqmp/zynqmp.c @@ -710,7 +710,7 @@ int board_late_init(void) break; case SD1_LSHFT_MODE: puts("LVL_SHFT_"); - /* fall through */ + fallthrough; case SD_MODE1: puts("SD_MODE1\n"); if (uclass_get_device_by_name(UCLASS_MMC, From 60705883d245c135f20660ebc7e2ed20c294387a Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Mon, 18 Oct 2021 14:02:15 +0200 Subject: [PATCH 10/69] xilinx: zynqmp: Use CONFIG_SPL_FS_LOAD_PAYLOAD_NAME There is no need to use u-boot.itb as name when this is already recorded in CONFIG_SPL_FS_LOAD_PAYLOAD_NAME macro. Signed-off-by: Michal Simek Reviewed-by: Oleksandr Suvorov Link: https://lore.kernel.org/r/38a236ed317510c26b37525da0e7bc26b411222c.1634558534.git.michal.simek@xilinx.com --- board/xilinx/zynqmp/zynqmp.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c index e8ae549698..6335184467 100644 --- a/board/xilinx/zynqmp/zynqmp.c +++ b/board/xilinx/zynqmp/zynqmp.c @@ -875,20 +875,23 @@ void set_dfu_alt_info(char *interface, char *devstr) if (!multiboot) snprintf(buf, DFU_ALT_BUF_LEN, "mmc %d:1=boot.bin fat %d 1;" - "u-boot.itb fat %d 1", - bootseq, bootseq, bootseq); + "%s fat %d 1", + bootseq, bootseq, + CONFIG_SPL_FS_LOAD_PAYLOAD_NAME, bootseq); else snprintf(buf, DFU_ALT_BUF_LEN, "mmc %d:1=boot%04d.bin fat %d 1;" - "u-boot.itb fat %d 1", - bootseq, multiboot, bootseq, bootseq); + "%s fat %d 1", + bootseq, multiboot, bootseq, + CONFIG_SPL_FS_LOAD_PAYLOAD_NAME, bootseq); break; case QSPI_MODE_24BIT: case QSPI_MODE_32BIT: snprintf(buf, DFU_ALT_BUF_LEN, "sf 0:0=boot.bin raw %x 0x1500000;" - "u-boot.itb raw 0x%x 0x500000", - multiboot * SZ_32K, CONFIG_SYS_SPI_U_BOOT_OFFS); + "%s raw 0x%x 0x500000", + multiboot * SZ_32K, CONFIG_SPL_FS_LOAD_PAYLOAD_NAME, + CONFIG_SYS_SPI_U_BOOT_OFFS); break; default: return; From 4f9d25537ce969b3792c217298aa69df9116477b Mon Sep 17 00:00:00 2001 From: Ashok Reddy Soma Date: Tue, 19 Oct 2021 19:43:00 +0530 Subject: [PATCH 11/69] spi: zynqmp_gqspi: Fix write issue at low frequencies With current implementation we are seeing write issues at low frequencies below 15Mhz. Make below changes to fix the issue. 1. Remove dummy genfifo entry in zynqmp_qspi_chipselect() which was incorrectly added in the past 2. Enable and poll for TX_FIFO_Empty after Tx data is filled in FIFO in zynqmp_qspi_fill_tx_fifo(). Signed-off-by: Ashok Reddy Soma Link: https://lore.kernel.org/r/1634652780-21755-1-git-send-email-ashok.reddy.soma@xilinx.com Signed-off-by: Michal Simek --- drivers/spi/zynqmp_gqspi.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/spi/zynqmp_gqspi.c b/drivers/spi/zynqmp_gqspi.c index 2db4ae20f1..c772bae3cc 100644 --- a/drivers/spi/zynqmp_gqspi.c +++ b/drivers/spi/zynqmp_gqspi.c @@ -37,6 +37,7 @@ */ #define GQSPI_IXR_TXNFULL_MASK 0x00000004 /* QSPI TX FIFO Overflow */ #define GQSPI_IXR_TXFULL_MASK 0x00000008 /* QSPI TX FIFO is full */ +#define GQSPI_IXR_TXFIFOEMPTY_MASK 0x00000100 /* QSPI TX FIFO is Empty */ #define GQSPI_IXR_RXNEMTY_MASK 0x00000010 /* QSPI RX FIFO Not Empty */ #define GQSPI_IXR_GFEMTY_MASK 0x00000080 /* QSPI Generic FIFO Empty */ #define GQSPI_IXR_GFNFULL_MASK 0x00000200 /* QSPI GENFIFO not full */ @@ -279,9 +280,6 @@ static void zynqmp_qspi_chipselect(struct zynqmp_qspi_priv *priv, int is_on) debug("GFIFO_CMD_CS: 0x%x\n", gqspi_fifo_reg); - /* Dummy generic FIFO entry */ - zynqmp_qspi_fill_gen_fifo(priv, 0); - zynqmp_qspi_fill_gen_fifo(priv, gqspi_fifo_reg); } @@ -470,6 +468,13 @@ static int zynqmp_qspi_fill_tx_fifo(struct zynqmp_qspi_priv *priv, u32 size) } } + ret = wait_for_bit_le32(®s->isr, GQSPI_IXR_TXFIFOEMPTY_MASK, 1, + GQSPI_TIMEOUT, 1); + if (ret) { + printf("%s: Timeout\n", __func__); + return ret; + } + priv->tx_buf += len; return 0; } From e8b43c6409a064429285e8c2bf6e1a27879f995a Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Mon, 25 Oct 2021 10:10:52 +0200 Subject: [PATCH 12/69] xilinx: zynqmp: Save multiboot as variable Save multiboot register as u-boot variable. And use it as primary source for composing dfu_alt_info for capsule update. If variable is not defined Signed-off-by: Michal Simek Reviewed-by: Oleksandr Suvorov Link: https://lore.kernel.org/r/96556221443489c952717bcb340b4707901c9bdd.1635149450.git.michal.simek@xilinx.com --- board/xilinx/zynqmp/zynqmp.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c index 6335184467..6c17b92f41 100644 --- a/board/xilinx/zynqmp/zynqmp.c +++ b/board/xilinx/zynqmp/zynqmp.c @@ -640,7 +640,7 @@ int board_late_init(void) const char *mode; char *new_targets; char *env_targets; - int ret; + int ret, multiboot; #if defined(CONFIG_USB_ETHER) && !defined(CONFIG_USB_GADGET_DOWNLOAD) usb_ether_init(); @@ -658,6 +658,10 @@ int board_late_init(void) if (ret) return ret; + multiboot = multi_boot(); + if (multiboot >= 0) + env_set_hex("multiboot", multiboot); + bootmode = zynqmp_get_bootmode(); puts("Bootmode: "); @@ -864,6 +868,10 @@ void set_dfu_alt_info(char *interface, char *devstr) memset(buf, 0, sizeof(buf)); multiboot = multi_boot(); + if (multiboot < 0) + multiboot = 0; + + multiboot = env_get_hex("multiboot", multiboot); debug("Multiboot: %d\n", multiboot); switch (zynqmp_get_bootmode()) { From 412ab133286af968732c2ff3cc2b615e078d8da1 Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Thu, 21 Oct 2021 08:58:50 +0200 Subject: [PATCH 13/69] arm64: zynqmp: Replace comma by semicolon Fix issue reported by checkpatch.pl WARNING: Possible comma where semicolon could be used #499: FILE: board/xilinx/zynqmp/zynqmp.c:499: + size = ALIGN(CONFIG_SYS_MALLOC_LEN + total_size, MMU_SECTION_SIZE), + reg = lmb_alloc(&lmb, size, MMU_SECTION_SIZE); Signed-off-by: Michal Simek Reviewed-by: Simon Glass Link: https://lore.kernel.org/r/ef264451ef9455ada9784bedbc91f74b94b8a237.1634799528.git.michal.simek@xilinx.com --- board/xilinx/zynqmp/zynqmp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c index 6c17b92f41..dfb5dab7af 100644 --- a/board/xilinx/zynqmp/zynqmp.c +++ b/board/xilinx/zynqmp/zynqmp.c @@ -496,7 +496,7 @@ ulong board_get_usable_ram_top(ulong total_size) lmb_init(&lmb); lmb_add(&lmb, gd->ram_base, gd->ram_size); boot_fdt_add_mem_rsv_regions(&lmb, (void *)gd->fdt_blob); - size = ALIGN(CONFIG_SYS_MALLOC_LEN + total_size, MMU_SECTION_SIZE), + size = ALIGN(CONFIG_SYS_MALLOC_LEN + total_size, MMU_SECTION_SIZE); reg = lmb_alloc(&lmb, size, MMU_SECTION_SIZE); if (!reg) From 11c0255cd8a7177e2b714040efcfd51844cb5d8e Mon Sep 17 00:00:00 2001 From: Ricardo Salveti Date: Thu, 4 Nov 2021 16:28:02 -0300 Subject: [PATCH 14/69] xilinx: zynqmp: fix ZYNQMP_RESTORE_JTAG check Config check should be done without the SPL_ prefix. Signed-off-by: Ricardo Salveti Reviewed-by: Oleksandr Suvorov Link: https://lore.kernel.org/r/20211104192802.3093811-1-ricardo@foundries.io Signed-off-by: Michal Simek --- board/xilinx/zynqmp/zynqmp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c index dfb5dab7af..2b5239ccb4 100644 --- a/board/xilinx/zynqmp/zynqmp.c +++ b/board/xilinx/zynqmp/zynqmp.c @@ -394,7 +394,7 @@ int board_init(void) printf("Silicon version:\t%d\n", zynqmp_get_silicon_version()); /* the CSU disables the JTAG interface when secure boot is enabled */ - if (CONFIG_IS_ENABLED(SPL_ZYNQMP_RESTORE_JTAG)) + if (CONFIG_IS_ENABLED(ZYNQMP_RESTORE_JTAG)) restore_jtag(); #else if (CONFIG_IS_ENABLED(DM_I2C) && CONFIG_IS_ENABLED(I2C_EEPROM)) From 9d3d981661000d8496d3b7836f3bd55d6534dd05 Mon Sep 17 00:00:00 2001 From: Alistair Delva Date: Wed, 20 Oct 2021 21:31:32 +0000 Subject: [PATCH 15/69] arm64: relocate-rela: Add support for ld.lld Cap end of relocations by the binary size. Linkers like to insert some auxiliary sections between .rela.dyn and .bss_start. These sections don't make their way to the final binary, but reloc_rela still tries to relocate them, resulting in attempted read past the end of file. When linking U-Boot with ld.lld, the STATIC_RELA feature (enabled by default on arm64) breaks the build. After this patch, U-Boot can be linked successfully with and without CONFIG_STATIC_RELA. Originally-from: Elena Petrova Signed-off-by: Alistair Delva Cc: David Brazdil Cc: Scott Wood Cc: Tom Rini --- tools/relocate-rela.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/tools/relocate-rela.c b/tools/relocate-rela.c index 6a524014b7..f0bc548617 100644 --- a/tools/relocate-rela.c +++ b/tools/relocate-rela.c @@ -63,7 +63,7 @@ int main(int argc, char **argv) { FILE *f; int i, num; - uint64_t rela_start, rela_end, text_base; + uint64_t rela_start, rela_end, text_base, file_size; if (argc != 5) { fprintf(stderr, "Statically apply ELF rela relocations\n"); @@ -87,8 +87,7 @@ int main(int argc, char **argv) return 3; } - if (rela_start > rela_end || rela_start < text_base || - (rela_end - rela_start) % sizeof(Elf64_Rela)) { + if (rela_start > rela_end || rela_start < text_base) { fprintf(stderr, "%s: bad rela bounds\n", argv[0]); return 3; } @@ -96,6 +95,21 @@ int main(int argc, char **argv) rela_start -= text_base; rela_end -= text_base; + fseek(f, 0, SEEK_END); + file_size = ftell(f); + rewind(f); + + if (rela_end > file_size) { + // Most likely compiler inserted some section that didn't get + // objcopy-ed into the final binary + rela_end = file_size; + } + + if ((rela_end - rela_start) % sizeof(Elf64_Rela)) { + fprintf(stderr, "%s: rela size isn't a multiple of Elf64_Rela\n", argv[0]); + return 3; + } + num = (rela_end - rela_start) / sizeof(Elf64_Rela); for (i = 0; i < num; i++) { From 679530c3c6ac99bc4da4dbf73a8e169bc9654e5b Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Tue, 2 Nov 2021 11:36:45 +0100 Subject: [PATCH 16/69] board: rename "tqc" vendor to "tq" The subdivision name "TQ Components" hasn't been in use for a long time. Rename the vendor directory to "tq", which also matches our Device Tree vendor prefix. Signed-off-by: Matthias Schiffer --- arch/arm/mach-imx/mx6/Kconfig | 2 +- board/{tqc => tq}/tqma6/Kconfig | 8 ++++---- board/{tqc => tq}/tqma6/MAINTAINERS | 2 +- board/{tqc => tq}/tqma6/Makefile | 0 board/{tqc => tq}/tqma6/README | 0 board/{tqc => tq}/tqma6/clocks.cfg | 0 board/{tqc => tq}/tqma6/tqma6.c | 0 board/{tqc => tq}/tqma6/tqma6_bb.h | 0 board/{tqc => tq}/tqma6/tqma6_mba6.c | 0 board/{tqc => tq}/tqma6/tqma6_wru4.c | 0 board/{tqc => tq}/tqma6/tqma6dl.cfg | 0 board/{tqc => tq}/tqma6/tqma6q.cfg | 0 board/{tqc => tq}/tqma6/tqma6s.cfg | 0 13 files changed, 6 insertions(+), 6 deletions(-) rename board/{tqc => tq}/tqma6/Kconfig (90%) rename board/{tqc => tq}/tqma6/MAINTAINERS (87%) rename board/{tqc => tq}/tqma6/Makefile (100%) rename board/{tqc => tq}/tqma6/README (100%) rename board/{tqc => tq}/tqma6/clocks.cfg (100%) rename board/{tqc => tq}/tqma6/tqma6.c (100%) rename board/{tqc => tq}/tqma6/tqma6_bb.h (100%) rename board/{tqc => tq}/tqma6/tqma6_mba6.c (100%) rename board/{tqc => tq}/tqma6/tqma6_wru4.c (100%) rename board/{tqc => tq}/tqma6/tqma6dl.cfg (100%) rename board/{tqc => tq}/tqma6/tqma6q.cfg (100%) rename board/{tqc => tq}/tqma6/tqma6s.cfg (100%) diff --git a/arch/arm/mach-imx/mx6/Kconfig b/arch/arm/mach-imx/mx6/Kconfig index b4c8511cb8..d701a46cd6 100644 --- a/arch/arm/mach-imx/mx6/Kconfig +++ b/arch/arm/mach-imx/mx6/Kconfig @@ -688,7 +688,7 @@ source "board/somlabs/visionsom-6ull/Kconfig" source "board/technexion/pico-imx6/Kconfig" source "board/technexion/pico-imx6ul/Kconfig" source "board/tbs/tbs2910/Kconfig" -source "board/tqc/tqma6/Kconfig" +source "board/tq/tqma6/Kconfig" source "board/toradex/apalis_imx6/Kconfig" source "board/toradex/colibri_imx6/Kconfig" source "board/toradex/colibri-imx6ull/Kconfig" diff --git a/board/tqc/tqma6/Kconfig b/board/tq/tqma6/Kconfig similarity index 90% rename from board/tqc/tqma6/Kconfig rename to board/tq/tqma6/Kconfig index a2a5905290..cb1b8749ce 100644 --- a/board/tqc/tqma6/Kconfig +++ b/board/tq/tqma6/Kconfig @@ -4,7 +4,7 @@ config SYS_BOARD default "tqma6" config SYS_VENDOR - default "tqc" + default "tq" config SYS_CONFIG_NAME default "tqma6" @@ -89,8 +89,8 @@ config SYS_TEXT_BASE default 0x4fc00000 if TQMA6Q || TQMA6DL config IMX_CONFIG - default "board/tqc/tqma6/tqma6q.cfg" if TQMA6Q - default "board/tqc/tqma6/tqma6dl.cfg" if TQMA6DL - default "board/tqc/tqma6/tqma6s.cfg" if TQMA6S + default "board/tq/tqma6/tqma6q.cfg" if TQMA6Q + default "board/tq/tqma6/tqma6dl.cfg" if TQMA6DL + default "board/tq/tqma6/tqma6s.cfg" if TQMA6S endif diff --git a/board/tqc/tqma6/MAINTAINERS b/board/tq/tqma6/MAINTAINERS similarity index 87% rename from board/tqc/tqma6/MAINTAINERS rename to board/tq/tqma6/MAINTAINERS index 91cd244499..dae719f00b 100644 --- a/board/tqc/tqma6/MAINTAINERS +++ b/board/tq/tqma6/MAINTAINERS @@ -1,6 +1,6 @@ TQ SYSTEMS TQMA6 BOARD M: Markus Niebel S: Maintained -F: board/tqc/tqma6/ +F: board/tq/tqma6/ F: include/configs/tqma6.h F: configs/tqma6*_defconfig diff --git a/board/tqc/tqma6/Makefile b/board/tq/tqma6/Makefile similarity index 100% rename from board/tqc/tqma6/Makefile rename to board/tq/tqma6/Makefile diff --git a/board/tqc/tqma6/README b/board/tq/tqma6/README similarity index 100% rename from board/tqc/tqma6/README rename to board/tq/tqma6/README diff --git a/board/tqc/tqma6/clocks.cfg b/board/tq/tqma6/clocks.cfg similarity index 100% rename from board/tqc/tqma6/clocks.cfg rename to board/tq/tqma6/clocks.cfg diff --git a/board/tqc/tqma6/tqma6.c b/board/tq/tqma6/tqma6.c similarity index 100% rename from board/tqc/tqma6/tqma6.c rename to board/tq/tqma6/tqma6.c diff --git a/board/tqc/tqma6/tqma6_bb.h b/board/tq/tqma6/tqma6_bb.h similarity index 100% rename from board/tqc/tqma6/tqma6_bb.h rename to board/tq/tqma6/tqma6_bb.h diff --git a/board/tqc/tqma6/tqma6_mba6.c b/board/tq/tqma6/tqma6_mba6.c similarity index 100% rename from board/tqc/tqma6/tqma6_mba6.c rename to board/tq/tqma6/tqma6_mba6.c diff --git a/board/tqc/tqma6/tqma6_wru4.c b/board/tq/tqma6/tqma6_wru4.c similarity index 100% rename from board/tqc/tqma6/tqma6_wru4.c rename to board/tq/tqma6/tqma6_wru4.c diff --git a/board/tqc/tqma6/tqma6dl.cfg b/board/tq/tqma6/tqma6dl.cfg similarity index 100% rename from board/tqc/tqma6/tqma6dl.cfg rename to board/tq/tqma6/tqma6dl.cfg diff --git a/board/tqc/tqma6/tqma6q.cfg b/board/tq/tqma6/tqma6q.cfg similarity index 100% rename from board/tqc/tqma6/tqma6q.cfg rename to board/tq/tqma6/tqma6q.cfg diff --git a/board/tqc/tqma6/tqma6s.cfg b/board/tq/tqma6/tqma6s.cfg similarity index 100% rename from board/tqc/tqma6/tqma6s.cfg rename to board/tq/tqma6/tqma6s.cfg From a5e305256b072d9eea97e106df479704f5b4f24f Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Tue, 2 Nov 2021 11:36:46 +0100 Subject: [PATCH 17/69] board: tq: fix spelling of "TQ-Systems" "TQ-Systems" is written with a dash. Signed-off-by: Matthias Schiffer --- arch/arm/mach-imx/mx6/Kconfig | 2 +- board/tq/tqma6/MAINTAINERS | 2 +- board/tq/tqma6/README | 6 +++--- board/tq/tqma6/tqma6.c | 2 +- board/tq/tqma6/tqma6_bb.h | 2 +- board/tq/tqma6/tqma6_mba6.c | 2 +- board/tq/tqma6/tqma6_wru4.c | 2 +- include/configs/tqma6.h | 2 +- include/configs/tqma6_mba6.h | 2 +- 9 files changed, 11 insertions(+), 11 deletions(-) diff --git a/arch/arm/mach-imx/mx6/Kconfig b/arch/arm/mach-imx/mx6/Kconfig index d701a46cd6..62de942a32 100644 --- a/arch/arm/mach-imx/mx6/Kconfig +++ b/arch/arm/mach-imx/mx6/Kconfig @@ -569,7 +569,7 @@ config TARGET_KP_IMX6Q_TPC imply CMD_SPL config TARGET_TQMA6 - bool "TQ Systems TQMa6 board" + bool "TQ-Systems TQMa6 board" select BOARD_EARLY_INIT_F select BOARD_LATE_INIT select MXC_SPI diff --git a/board/tq/tqma6/MAINTAINERS b/board/tq/tqma6/MAINTAINERS index dae719f00b..c4fb6ec206 100644 --- a/board/tq/tqma6/MAINTAINERS +++ b/board/tq/tqma6/MAINTAINERS @@ -1,4 +1,4 @@ -TQ SYSTEMS TQMA6 BOARD +TQ-SYSTEMS TQMA6 BOARD M: Markus Niebel S: Maintained F: board/tq/tqma6/ diff --git a/board/tq/tqma6/README b/board/tq/tqma6/README index c47cb21eeb..bd2466c60a 100644 --- a/board/tq/tqma6/README +++ b/board/tq/tqma6/README @@ -1,7 +1,7 @@ -U-Boot for the TQ Systems TQMa6 modules +U-Boot for the TQ-Systems TQMa6 modules This file contains information for the port of -U-Boot to the TQ Systems TQMa6 modules. +U-Boot to the TQ-Systems TQMa6 modules. 1. Boot source -------------- @@ -14,7 +14,7 @@ The following boot source is supported: 2. Building ------------ -To build U-Boot for the TQ Systems TQMa6 modules: +To build U-Boot for the TQ-Systems TQMa6 modules: make tqma6___config make diff --git a/board/tq/tqma6/tqma6.c b/board/tq/tqma6/tqma6.c index de9c00174a..1c2228c77a 100644 --- a/board/tq/tqma6/tqma6.c +++ b/board/tq/tqma6/tqma6.c @@ -3,7 +3,7 @@ * Copyright (C) 2012 Freescale Semiconductor, Inc. * Author: Fabio Estevam * - * Copyright (C) 2013, 2014 TQ Systems (ported SabreSD to TQMa6x) + * Copyright (C) 2013, 2014 TQ-Systems (ported SabreSD to TQMa6x) * Author: Markus Niebel */ diff --git a/board/tq/tqma6/tqma6_bb.h b/board/tq/tqma6/tqma6_bb.h index b0f1f99a83..ca81bdf585 100644 --- a/board/tq/tqma6/tqma6_bb.h +++ b/board/tq/tqma6/tqma6_bb.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0+ */ /* - * Copyright (C) 2013, 2014 TQ Systems + * Copyright (C) 2013, 2014 TQ-Systems * Author: Markus Niebel */ diff --git a/board/tq/tqma6/tqma6_mba6.c b/board/tq/tqma6/tqma6_mba6.c index 801619e80b..52851dd5b5 100644 --- a/board/tq/tqma6/tqma6_mba6.c +++ b/board/tq/tqma6/tqma6_mba6.c @@ -3,7 +3,7 @@ * Copyright (C) 2012 Freescale Semiconductor, Inc. * Author: Fabio Estevam * - * Copyright (C) 2013, 2014 TQ Systems (ported SabreSD to TQMa6x) + * Copyright (C) 2013, 2014 TQ-Systems (ported SabreSD to TQMa6x) * Author: Markus Niebel */ diff --git a/board/tq/tqma6/tqma6_wru4.c b/board/tq/tqma6/tqma6_wru4.c index 3b1bc603ce..5d239913fc 100644 --- a/board/tq/tqma6/tqma6_wru4.c +++ b/board/tq/tqma6/tqma6_wru4.c @@ -3,7 +3,7 @@ * Copyright (C) 2012 Freescale Semiconductor, Inc. * Author: Fabio Estevam * - * Copyright (C) 2013, 2014 TQ Systems (ported SabreSD to TQMa6x) + * Copyright (C) 2013, 2014 TQ-Systems (ported SabreSD to TQMa6x) * Author: Markus Niebel * * Copyright (C) 2015 Stefan Roese diff --git a/include/configs/tqma6.h b/include/configs/tqma6.h index 374a65aef4..233031bc38 100644 --- a/include/configs/tqma6.h +++ b/include/configs/tqma6.h @@ -2,7 +2,7 @@ /* * Copyright (C) 2013, 2014, 2017 Markus Niebel * - * Configuration settings for the TQ Systems TQMa6 module. + * Configuration settings for the TQ-Systems TQMa6 module. */ #ifndef __CONFIG_H diff --git a/include/configs/tqma6_mba6.h b/include/configs/tqma6_mba6.h index bee6d2f33b..a19ea351c2 100644 --- a/include/configs/tqma6_mba6.h +++ b/include/configs/tqma6_mba6.h @@ -2,7 +2,7 @@ /* * Copyright (C) 2013 - 2017 Markus Niebel * - * Configuration settings for the TQ Systems TQMa6 module on + * Configuration settings for the TQ-Systems TQMa6 module on * MBa6 starter kit */ From 5130102fc43f7f3a897796b14918305ad96e1b4c Mon Sep 17 00:00:00 2001 From: Angelo Dureghello Date: Fri, 5 Nov 2021 16:20:24 +0100 Subject: [PATCH 18/69] makefile: add missing semicolons On some distributions, as Debian GNU 11, this targets fails with errors. Signed-off-by: Angelo Dureghello --- Makefile | 2 +- scripts/Makefile.autoconf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 0220e8ded9..50649963a4 100644 --- a/Makefile +++ b/Makefile @@ -1246,7 +1246,7 @@ binary_size_check: u-boot-nodtb.bin FORCE echo "u-boot.map shows a binary size of $$map_size" >&2 ; \ echo " but u-boot-nodtb.bin shows $$file_size" >&2 ; \ exit 1; \ - fi \ + fi; \ fi ifeq ($(CONFIG_INIT_SP_RELATIVE)$(CONFIG_OF_SEPARATE),yy) diff --git a/scripts/Makefile.autoconf b/scripts/Makefile.autoconf index 0bfc1b2a62..8a3efdb2db 100644 --- a/scripts/Makefile.autoconf +++ b/scripts/Makefile.autoconf @@ -61,7 +61,7 @@ quiet_cmd_autoconf = GEN $@ if [ -n "${KCONFIG_IGNORE_DUPLICATES}" ] || \ ! grep -q "$${line%=*}=" include/config/auto.conf; then \ echo "$$line"; \ - fi \ + fi; \ done > $@ quiet_cmd_u_boot_cfg = CFG $@ From 4d492b0c0f2238b22c5561437b1a519b3781f1fd Mon Sep 17 00:00:00 2001 From: Masami Hiramatsu Date: Wed, 10 Nov 2021 09:40:07 +0900 Subject: [PATCH 19/69] configs: synquacer: Fix dfu_alt_info to use nor1 Fix dfu_alt_info to use nor1 instead of the device name. This reverts a part of commit 59bd18d4c4d7 ("configs: synquacer: Remove mtdparts settings and update DFU setting") because the commit a4f2d8341455 ("mtd: spi: nor: force mtd name to "nor%d"") changed the mtd device naming scheme to nor%d. Signed-off-by: Masami Hiramatsu Acked-by: Ilias Apalodimas --- include/configs/synquacer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/configs/synquacer.h b/include/configs/synquacer.h index 28f5463763..3d099b4f11 100644 --- a/include/configs/synquacer.h +++ b/include/configs/synquacer.h @@ -52,7 +52,7 @@ /* #define CONFIG_SYS_PCI_64BIT 1 */ #define DEFAULT_DFU_ALT_INFO "dfu_alt_info=" \ - "mtd mx66u51235f=u-boot.bin raw 200000 100000;" \ + "mtd nor1=u-boot.bin raw 200000 100000;" \ "fip.bin raw 180000 78000;" \ "optee.bin raw 500000 100000\0" From 38de2bad642ad3032e56fcad3b21f12bd609a294 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre-Cl=C3=A9ment=20Tosi?= Date: Wed, 10 Nov 2021 15:04:40 +0100 Subject: [PATCH 20/69] arm: Fix bad memcpy.S str8w macro argument count MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove the extra (empty) argument passed to str8w, causing the following error: :40:47: error: too many positional arguments str8w r0, r3, r4, r5, r6, r7, r8, r9, ip, , abort=19f ^ u-boot/arch/arm/lib/memcpy.S:240:5: note: while in macro instantiation 17: forward_copy_shift pull=16 push=16 ^ Note: no functional change intended. Fixes: d8834a1323af ("arm: Use optimized memcpy and memset from linux") Signed-off-by: Pierre-Clément Tosi --- arch/arm/lib/memcpy.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/lib/memcpy.S b/arch/arm/lib/memcpy.S index f7fb77235c..eee7a219ce 100644 --- a/arch/arm/lib/memcpy.S +++ b/arch/arm/lib/memcpy.S @@ -210,7 +210,7 @@ ENTRY(memcpy) orr r9, r9, ip, lspush #\push mov ip, ip, lspull #\pull orr ip, ip, lr, lspush #\push - str8w r0, r3, r4, r5, r6, r7, r8, r9, ip, , abort=19f + str8w r0, r3, r4, r5, r6, r7, r8, r9, ip, abort=19f bge 12b PLD( cmn r2, #96 ) PLD( bge 13b ) From b5f3850727c86811767c10218b68552e63ff2a6a Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Fri, 12 Nov 2021 18:37:47 +0300 Subject: [PATCH 21/69] usb: doc: Fix spelling issues in README.usb Fix spelling issues in README.usb. Signed-off-by: Andy Shevchenko --- doc/README.usb | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/doc/README.usb b/doc/README.usb index 05c62c3413..650a6daae0 100644 --- a/doc/README.usb +++ b/doc/README.usb @@ -18,8 +18,8 @@ How it works: ------------- The USB (at least the USB UHCI) needs a frame list (4k), transfer -descripor and queue headers which are all located in the main memory. -The UHCI allocates every milisecond the PCI bus and reads the current +descriptor and queue headers which are all located in the main memory. +The UHCI allocates every millisecond the PCI bus and reads the current frame pointer. This may cause to crash the OS during boot. So the USB _MUST_ be stopped during OS boot. This is the reason, why the USB is NOT automatically started during start-up. If someone needs the USB @@ -27,10 +27,10 @@ he has to start it and should therefore be aware that he had to stop it before booting the OS. For USB keyboards this can be done by a script which is automatically -started after the U-Boot is up and running. To boot an OS with a an +started after the U-Boot is up and running. To boot an OS with a USB keyboard another script is necessary, which first disables the USB and then executes the boot command. If the boot command fails, -the script can reenable the USB kbd. +the script can re-enable the USB keyboard. Common USB Commands: - usb start: @@ -40,10 +40,10 @@ Common USB Commands: - usb info [dev]: shows all USB infos of the device dev, or of all the devices - usb stop [f]: stops the USB. If f==1 the USB will also stop if - an USB keyboard is assigned as stdin. The stdin + a USB keyboard is assigned as stdin. The stdin is then switched to serial input. Storage USB Commands: -- usb scan: scans the USB for storage devices.The USB must be +- usb scan: scans the USB for storage devices. The USB must be running for this command (usb start) - usb device [dev]: show or set current USB storage device - usb part [dev]: print partition table of one or all USB storage @@ -57,7 +57,7 @@ Storage USB Commands: Config Switches: ---------------- CONFIG_CMD_USB enables basic USB support and the usb command -CONFIG_USB_UHCI defines the lowlevel part.A lowlevel part must be defined +CONFIG_USB_UHCI defines the lowlevel part. A lowlevel part must be defined if using CONFIG_CMD_USB CONFIG_USB_KEYBOARD enables the USB Keyboard CONFIG_USB_STORAGE enables the USB storage devices @@ -124,7 +124,7 @@ bootp To enable USB Host Ethernet in U-Boot, your platform must of course support USB with CONFIG_CMD_USB enabled and working. You will need to -add some config settings to your board config: +add some settings to your board configuration: CONFIG_CMD_USB=y /* the 'usb' interactive command */ CONFIG_USB_HOST_ETHER=y /* Enable USB Ethernet adapters */ @@ -158,7 +158,7 @@ settings should start you off: You can also set the default IP address of your board and the server as well as the default file to load when a 'bootp' command is issued. However note that encoding these individual network settings into a -common exectuable is discouraged, as it leads to potential conflicts, +common executable is discouraged, as it leads to potential conflicts, and all the parameters can either get stored in the board's external environment, or get obtained from the bootp server if not set. @@ -166,7 +166,6 @@ environment, or get obtained from the bootp server if not set. #define CONFIG_SERVERIP 10.0.0.1 (replace with your value) #define CONFIG_BOOTFILE "uImage" - The 'usb start' command should identify the adapter something like this: CrOS> usb start @@ -211,8 +210,8 @@ MAC Addresses Most Ethernet dongles have a built-in MAC address which is unique in the world. This is important so that devices on the network can be -distinguised from each other. MAC address conflicts are evil and -generally result in strange and eratic behaviour. +distinguished from each other. MAC address conflicts are evil and +generally result in strange and erratic behaviour. Some boards have USB Ethernet chips on-board, and these sometimes do not have an assigned MAC address. In this case it is up to you to assign From 4b32531be236bbd9ca60f26447511f79e214f79e Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Mon, 8 Nov 2021 21:03:38 +0300 Subject: [PATCH 22/69] image: Explicitly declare do_bdinfo() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Compiler is not happy: common/image-board.c: In function ‘boot_get_kbd’: common/image-board.c:902:17: warning: implicit declaration of function ‘do_bdinfo’ [-Wimplicit-function-declaration] 902 | do_bdinfo(NULL, 0, 0, NULL); | ^~~~~~~~~ Move the forward declaration to a header. Signed-off-by: Andy Shevchenko Reviewed-by: Simon Glass --- boot/image-board.c | 1 + boot/image.c | 6 +----- include/init.h | 2 ++ 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/boot/image-board.c b/boot/image-board.c index ddf30c6730..bf8817165c 100644 --- a/boot/image-board.c +++ b/boot/image-board.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include diff --git a/boot/image.c b/boot/image.c index 992e72991d..f792f2aa69 100644 --- a/boot/image.c +++ b/boot/image.c @@ -9,6 +9,7 @@ #ifndef USE_HOSTCC #include #include +#include #include #include #include @@ -29,11 +30,6 @@ #include #include -#ifdef CONFIG_CMD_BDI -extern int do_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, - char *const argv[]); -#endif - DECLARE_GLOBAL_DATA_PTR; /* Set this if we have less than 4 MB of malloc() space */ diff --git a/include/init.h b/include/init.h index c781789e36..f2cd46dead 100644 --- a/include/init.h +++ b/include/init.h @@ -332,6 +332,8 @@ void bdinfo_print_mhz(const char *name, unsigned long hz); /* Show arch-specific information for the 'bd' command */ void arch_print_bdinfo(void); +int do_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); + #endif /* __ASSEMBLY__ */ /* Put only stuff here that the assembler can digest */ From ebb6d74df3a33f8f65febfdf14f131197949cc46 Mon Sep 17 00:00:00 2001 From: Mathew McBride Date: Thu, 11 Nov 2021 04:06:26 +0000 Subject: [PATCH 23/69] cmd: tpm-v1: fix compile error in TPMv1 list resources command This command is not compiled by default and was not updated to pass the udevice to tpm_get_capability. Signed-off-by: Mathew McBride Reviewed-by: Ilias Apalodimas Signed-off-by: Ilias Apalodimas --- cmd/tpm-v1.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cmd/tpm-v1.c b/cmd/tpm-v1.c index 3a7e35d525..55f2aeff46 100644 --- a/cmd/tpm-v1.c +++ b/cmd/tpm-v1.c @@ -582,6 +582,7 @@ static int do_tpm_flush(struct cmd_tbl *cmdtp, int flag, int argc, static int do_tpm_list(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { + struct udevice *dev; int type = 0; u16 res_count; u8 buf[288]; @@ -589,6 +590,10 @@ static int do_tpm_list(struct cmd_tbl *cmdtp, int flag, int argc, int err; uint i; + err = get_tpm(&dev); + if (err) + return err; + if (argc != 2) return CMD_RET_USAGE; @@ -619,7 +624,7 @@ static int do_tpm_list(struct cmd_tbl *cmdtp, int flag, int argc, } /* fetch list of already loaded resources in the TPM */ - err = tpm_get_capability(TPM_CAP_HANDLE, type, buf, + err = tpm_get_capability(dev, TPM_CAP_HANDLE, type, buf, sizeof(buf)); if (err) { printf("tpm_get_capability returned error %d.\n", err); From e845dd7c8ba8fcab504c813da0eea59550bc7b05 Mon Sep 17 00:00:00 2001 From: Mathew McBride Date: Thu, 11 Nov 2021 04:06:27 +0000 Subject: [PATCH 24/69] cmd: tpm-v1: fix load_key_by_sha1 compile errors This command is not compiled by default and has not been updated alongside changes to the tpmv1 API, such as passing the TPM udevice to the relevant functions. Signed-off-by: Mathew McBride Reviewed-by: Ilias Apalodimas Signed-off-by: Ilias Apalodimas --- cmd/tpm-v1.c | 10 +++++----- lib/tpm-v1.c | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cmd/tpm-v1.c b/cmd/tpm-v1.c index 55f2aeff46..bf238a9f2e 100644 --- a/cmd/tpm-v1.c +++ b/cmd/tpm-v1.c @@ -406,9 +406,9 @@ static int do_tpm_load_key_by_sha1(struct cmd_tbl *cmdtp, int flag, int argc, void *key; struct udevice *dev; - rc = get_tpm(&dev); - if (rc) - return rc; + err = get_tpm(&dev); + if (err) + return err; if (argc < 5) return CMD_RET_USAGE; @@ -420,7 +420,7 @@ static int do_tpm_load_key_by_sha1(struct cmd_tbl *cmdtp, int flag, int argc, return CMD_RET_FAILURE; parse_byte_string(argv[4], usage_auth, NULL); - err = tpm_find_key_sha1(usage_auth, parent_hash, &parent_handle); + err = tpm1_find_key_sha1(dev, usage_auth, parent_hash, &parent_handle); if (err) { printf("Could not find matching parent key (err = %d)\n", err); return CMD_RET_FAILURE; @@ -428,7 +428,7 @@ static int do_tpm_load_key_by_sha1(struct cmd_tbl *cmdtp, int flag, int argc, printf("Found parent key %08x\n", parent_handle); - err = tpm_load_key2_oiap(parent_handle, key, key_len, usage_auth, + err = tpm1_load_key2_oiap(dev, parent_handle, key, key_len, usage_auth, &key_handle); if (!err) { printf("Key handle is 0x%x\n", key_handle); diff --git a/lib/tpm-v1.c b/lib/tpm-v1.c index 8dc144080c..22a769c587 100644 --- a/lib/tpm-v1.c +++ b/lib/tpm-v1.c @@ -840,7 +840,7 @@ u32 tpm1_find_key_sha1(struct udevice *dev, const u8 auth[20], unsigned int i; /* fetch list of already loaded keys in the TPM */ - err = tpm_get_capability(dev, TPM_CAP_HANDLE, TPM_RT_KEY, buf, + err = tpm1_get_capability(dev, TPM_CAP_HANDLE, TPM_RT_KEY, buf, sizeof(buf)); if (err) return -1; @@ -852,7 +852,7 @@ u32 tpm1_find_key_sha1(struct udevice *dev, const u8 auth[20], /* now search a(/ the) key which we can access with the given auth */ for (i = 0; i < key_count; ++i) { buf_len = sizeof(buf); - err = tpm_get_pub_key_oiap(key_handles[i], auth, buf, &buf_len); + err = tpm1_get_pub_key_oiap(dev, key_handles[i], auth, buf, &buf_len); if (err && err != TPM_AUTHFAIL) return -1; if (err) From 02f50d8ebbcf318e068c30882b3638dd1cfbf03e Mon Sep 17 00:00:00 2001 From: Mathew McBride Date: Thu, 11 Nov 2021 04:06:28 +0000 Subject: [PATCH 25/69] drivers: tpm: atmel_twi: drop non-DM_I2C compatibility There are no users of this driver without DM_I2C Signed-off-by: Mathew McBride Reviewed-by: Ilias Apalodimas Signed-off-by: Ilias Apalodimas --- drivers/tpm/tpm_atmel_twi.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/drivers/tpm/tpm_atmel_twi.c b/drivers/tpm/tpm_atmel_twi.c index 2dcc2af67f..4ff4cf4cd4 100644 --- a/drivers/tpm/tpm_atmel_twi.c +++ b/drivers/tpm/tpm_atmel_twi.c @@ -81,22 +81,15 @@ static int tpm_atmel_twi_xfer(struct udevice *dev, print_buffer(0, (void *)sendbuf, 1, send_size, 0); #endif -#if !CONFIG_IS_ENABLED(DM_I2C) - res = i2c_write(0x29, 0, 0, (uchar *)sendbuf, send_size); -#else res = dm_i2c_write(dev, 0, sendbuf, send_size); -#endif if (res) { printf("i2c_write returned %d\n", res); return -1; } start = get_timer(0); -#if !CONFIG_IS_ENABLED(DM_I2C) - while ((res = i2c_read(0x29, 0, 0, recvbuf, 10))) -#else + while ((res = dm_i2c_read(dev, 0, recvbuf, 10))) -#endif { /* TODO Use TIS_TIMEOUT from tpm_tis_infineon.h */ if (get_timer(start) > ATMEL_TPM_TIMEOUT_MS) { @@ -116,12 +109,7 @@ static int tpm_atmel_twi_xfer(struct udevice *dev, return -1; } else { *recv_len = hdr_recv_len; -#if !CONFIG_IS_ENABLED(DM_I2C) - res = i2c_read(0x29, 0, 0, recvbuf, *recv_len); -#else res = dm_i2c_read(dev, 0, recvbuf, *recv_len); -#endif - } } if (res) { From fdb4a5fcd7458d6cf075d908a499f822a9787fac Mon Sep 17 00:00:00 2001 From: Mathew McBride Date: Thu, 11 Nov 2021 04:06:29 +0000 Subject: [PATCH 26/69] drivers: tpm: atmel_twi: do not use an offset byte This driver was broken due to an empty offset byte being prepended at the start of every transmission. The hardware does not mimic an EEPROM device with registers so an offset byte is not required. Signed-off-by: Mathew McBride Acked-by: Ilias Apalodimas Signed-off-by: Ilias Apalodimas --- drivers/tpm/tpm_atmel_twi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/tpm/tpm_atmel_twi.c b/drivers/tpm/tpm_atmel_twi.c index 4ff4cf4cd4..71b101406d 100644 --- a/drivers/tpm/tpm_atmel_twi.c +++ b/drivers/tpm/tpm_atmel_twi.c @@ -131,6 +131,7 @@ static int tpm_atmel_twi_xfer(struct udevice *dev, static int tpm_atmel_twi_probe(struct udevice *dev) { + i2c_set_chip_offset_len(dev, 0); return 0; } From fb30d99df831c7235e61bd0c4e07a25ae20926b3 Mon Sep 17 00:00:00 2001 From: Mathew McBride Date: Thu, 11 Nov 2021 04:06:30 +0000 Subject: [PATCH 27/69] drivers: tpm: atmel_twi: implement get_desc operation Without get_desc, the tpm command will not provide a description of the device in 'tpm device' or 'tpm info'. Due to the characteristics of the Atmel TPM it isn't possible to determine certain attributes (e.g open/close status) without using the TPM stack (compare Infineon and ST TPM drivers), so just print out the chip model and udevice name as the identifier. Signed-off-by: Mathew McBride Signed-off-by: Ilias Apalodimas --- drivers/tpm/tpm_atmel_twi.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/tpm/tpm_atmel_twi.c b/drivers/tpm/tpm_atmel_twi.c index 71b101406d..a5dfb34846 100644 --- a/drivers/tpm/tpm_atmel_twi.c +++ b/drivers/tpm/tpm_atmel_twi.c @@ -52,7 +52,10 @@ static int tpm_atmel_twi_close(struct udevice *dev) */ static int tpm_atmel_twi_get_desc(struct udevice *dev, char *buf, int size) { - return 0; + if (size < 50) + return -ENOSPC; + + return snprintf(buf, size, "Atmel AT97SC3204T I2C 1.2 TPM (%s)", dev->name); } /* From 4a08dba019cda7bd6d81694ecb3230dedf54d46f Mon Sep 17 00:00:00 2001 From: Mathew McBride Date: Thu, 11 Nov 2021 04:06:31 +0000 Subject: [PATCH 28/69] drivers: tpm: atmel_twi: fix printf specifier compile warning %d was being used as the specifier for size_t, leading to a compiler warning Signed-off-by: Mathew McBride Reviewed-by: Ilias Apalodimas Signed-off-by: Ilias Apalodimas --- drivers/tpm/tpm_atmel_twi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/tpm/tpm_atmel_twi.c b/drivers/tpm/tpm_atmel_twi.c index a5dfb34846..fa4fbec6bb 100644 --- a/drivers/tpm/tpm_atmel_twi.c +++ b/drivers/tpm/tpm_atmel_twi.c @@ -116,7 +116,7 @@ static int tpm_atmel_twi_xfer(struct udevice *dev, } } if (res) { - printf("i2c_read returned %d (rlen=%d)\n", res, *recv_len); + printf("i2c_read returned %d (rlen=%zu)\n", res, *recv_len); #ifdef DEBUG print_buffer(0, recvbuf, 1, *recv_len, 0); #endif From 0171d056ec8b9be9d90af64adce54c6a5571dd15 Mon Sep 17 00:00:00 2001 From: Masami Hiramatsu Date: Thu, 18 Nov 2021 14:45:25 +0900 Subject: [PATCH 29/69] Revert "board: synquacer: developerbox: Don't set gd->env_addr to default_environment" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Without default setting of gd->env_addr, U-Boot will cause a synchronous abort if the env-variables on the SPI flash is broken or not saved corectly. Set gd->env_addr correctly. This reverts commit 535870f3b0fb09ee9b2885409f05304111464643. Signed-off-by: Masami Hiramatsu Reviewed-by: Marek Behún --- board/socionext/developerbox/developerbox.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/board/socionext/developerbox/developerbox.c b/board/socionext/developerbox/developerbox.c index 31b1349514..9552bfcdc3 100644 --- a/board/socionext/developerbox/developerbox.c +++ b/board/socionext/developerbox/developerbox.c @@ -82,6 +82,8 @@ int board_init(void) { gd->bd->bi_boot_params = CONFIG_SYS_LOAD_ADDR + LOAD_OFFSET; + gd->env_addr = (ulong)&default_environment[0]; + synquacer_setup_scbm_smmu(); return 0; From 50f7b2effd4971439e9b66467e4abf6688a124d9 Mon Sep 17 00:00:00 2001 From: schspa Date: Wed, 20 Oct 2021 20:15:55 +0800 Subject: [PATCH 30/69] part: return -ENOSYS when get_info not valid. In some case, get_info() interface can be NULL, add this check to stop from crash. Signed-off-by: schspa Reviewed-by: Simon Glass --- disk/part.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/disk/part.c b/disk/part.c index a6a8f7052b..fe1ebd4adf 100644 --- a/disk/part.c +++ b/disk/part.c @@ -668,6 +668,13 @@ int part_get_info_by_name_type(struct blk_desc *dev_desc, const char *name, part_drv = part_driver_lookup_type(dev_desc); if (!part_drv) return -1; + + if (!part_drv->get_info) { + log_debug("## Driver %s does not have the get_info() method\n", + part_drv->name); + return -ENOSYS; + } + for (i = 1; i < part_drv->max_entries; i++) { ret = part_drv->get_info(dev_desc, i, info); if (ret != 0) { From 47d7d03622ba8b52f87274c7eea917a15e76053b Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Sat, 13 Nov 2021 18:34:04 +0100 Subject: [PATCH 31/69] board_f: Copy GD to new GD even if relocation disabled Even if U-Boot has relocation disabled via GD_FLG_SKIP_RELOC , the relocated stage of U-Boot still picks GD from new_gd location. The U-Boot itself is not relocated, but GD might be, so copy the GD to new GD location even if relocation is disabled. Signed-off-by: Marek Vasut Cc: Peng Fan Cc: Simon Glass Cc: Tom Rini --- common/board_f.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/common/board_f.c b/common/board_f.c index 3dc0eaa59c..f7ea7c7a1e 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -673,30 +673,32 @@ static int reloc_bloblist(void) static int setup_reloc(void) { - if (gd->flags & GD_FLG_SKIP_RELOC) { - debug("Skipping relocation due to flag\n"); - return 0; - } - + if (!(gd->flags & GD_FLG_SKIP_RELOC)) { #ifdef CONFIG_SYS_TEXT_BASE #ifdef ARM - gd->reloc_off = gd->relocaddr - (unsigned long)__image_copy_start; + gd->reloc_off = gd->relocaddr - (unsigned long)__image_copy_start; #elif defined(CONFIG_M68K) - /* - * On all ColdFire arch cpu, monitor code starts always - * just after the default vector table location, so at 0x400 - */ - gd->reloc_off = gd->relocaddr - (CONFIG_SYS_TEXT_BASE + 0x400); + /* + * On all ColdFire arch cpu, monitor code starts always + * just after the default vector table location, so at 0x400 + */ + gd->reloc_off = gd->relocaddr - (CONFIG_SYS_TEXT_BASE + 0x400); #elif !defined(CONFIG_SANDBOX) - gd->reloc_off = gd->relocaddr - CONFIG_SYS_TEXT_BASE; + gd->reloc_off = gd->relocaddr - CONFIG_SYS_TEXT_BASE; #endif #endif + } + memcpy(gd->new_gd, (char *)gd, sizeof(gd_t)); - debug("Relocation Offset is: %08lx\n", gd->reloc_off); - debug("Relocating to %08lx, new gd at %08lx, sp at %08lx\n", - gd->relocaddr, (ulong)map_to_sysmem(gd->new_gd), - gd->start_addr_sp); + if (gd->flags & GD_FLG_SKIP_RELOC) { + debug("Skipping relocation due to flag\n"); + } else { + debug("Relocation Offset is: %08lx\n", gd->reloc_off); + debug("Relocating to %08lx, new gd at %08lx, sp at %08lx\n", + gd->relocaddr, (ulong)map_to_sysmem(gd->new_gd), + gd->start_addr_sp); + } return 0; } From bd994c007ae232ade284c9c22c9150077961fe19 Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Sat, 13 Nov 2021 18:34:37 +0100 Subject: [PATCH 32/69] lmb: Reserve U-Boot separately if relocation is disabled In case U-Boot starts with GD_FLG_SKIP_RELOC, the U-Boot code is not relocated, however the stack and heap is at the end of DRAM after relocation. Reserve a LMB area for the non-relocated U-Boot code so it won't be overwritten. Signed-off-by: Marek Vasut Cc: Simon Glass Cc: Tom Rini --- lib/lmb.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/lmb.c b/lib/lmb.c index 676b3a0bda..f72996a424 100644 --- a/lib/lmb.c +++ b/lib/lmb.c @@ -13,6 +13,7 @@ #include #include +#include DECLARE_GLOBAL_DATA_PTR; @@ -144,6 +145,10 @@ void arch_lmb_reserve_generic(struct lmb *lmb, ulong sp, ulong end, ulong align) bank_end = end - 1; lmb_reserve(lmb, sp, bank_end - sp + 1); + + if (gd->flags & GD_FLG_SKIP_RELOC) + lmb_reserve(lmb, (phys_addr_t)(uintptr_t)_start, gd->mon_len); + break; } } From b1f3f982fa1cdcf08717a37e00adcb6fc3d89bf4 Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Sat, 13 Nov 2021 18:34:59 +0100 Subject: [PATCH 33/69] arm64: Add missing GD_FLG_SKIP_RELOC handling In case U-Boot enters relocation with GD_FLG_SKIP_RELOC, skip the relocation. The code still has to set up new_gd pointer and new stack pointer. Signed-off-by: Marek Vasut Cc: Simon Glass Cc: Tom Rini --- arch/arm/lib/crt0_64.S | 4 ++++ lib/asm-offsets.c | 3 +++ 2 files changed, 7 insertions(+) diff --git a/arch/arm/lib/crt0_64.S b/arch/arm/lib/crt0_64.S index 680e674fa3..28c8356aee 100644 --- a/arch/arm/lib/crt0_64.S +++ b/arch/arm/lib/crt0_64.S @@ -104,6 +104,10 @@ ENTRY(_main) bic sp, x0, #0xf /* 16-byte alignment for ABI compliance */ ldr x18, [x18, #GD_NEW_GD] /* x18 <- gd->new_gd */ + /* Skip relocation in case gd->gd_flags & GD_FLG_SKIP_RELOC */ + ldr x0, [x18, #GD_FLAGS] /* x0 <- gd->flags */ + tbnz x0, 11, relocation_return /* GD_FLG_SKIP_RELOC is bit 11 */ + adr lr, relocation_return #if CONFIG_POSITION_INDEPENDENT /* Add in link-vs-runtime offset */ diff --git a/lib/asm-offsets.c b/lib/asm-offsets.c index c691066332..0808cd4b0c 100644 --- a/lib/asm-offsets.c +++ b/lib/asm-offsets.c @@ -29,6 +29,9 @@ int main(void) DEFINE(GD_SIZE, sizeof(struct global_data)); DEFINE(GD_BD, offsetof(struct global_data, bd)); + + DEFINE(GD_FLAGS, offsetof(struct global_data, flags)); + #if CONFIG_VAL(SYS_MALLOC_F_LEN) DEFINE(GD_MALLOC_BASE, offsetof(struct global_data, malloc_base)); #endif From 886d36efdb98bc0bb44e65e917dea903ab377e54 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 13 Nov 2021 07:07:15 -0700 Subject: [PATCH 34/69] pinctrl: meson: Correct the driver GPIO declaration This should use the provided U_BOOT_DRIVER() macro so that the driver gets added to the appropriate linker list. Fix it. Signed-off-by: Simon Glass Fixes: 7c9dcfed50f ("pinctrl: meson: rework gx pmx function") Reported-by: Tom Rini Tested-by: Tom Rini on libretech-cc Signed-off-by: Neil Armstrong --- drivers/pinctrl/meson/pinctrl-meson-gx-pmx.c | 2 +- drivers/pinctrl/meson/pinctrl-meson-gx.h | 2 +- drivers/pinctrl/meson/pinctrl-meson-gxbb.c | 4 ++-- drivers/pinctrl/meson/pinctrl-meson-gxl.c | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/pinctrl/meson/pinctrl-meson-gx-pmx.c b/drivers/pinctrl/meson/pinctrl-meson-gx-pmx.c index 159f3406a2..99502d89c6 100644 --- a/drivers/pinctrl/meson/pinctrl-meson-gx-pmx.c +++ b/drivers/pinctrl/meson/pinctrl-meson-gx-pmx.c @@ -145,7 +145,7 @@ static const struct dm_gpio_ops meson_gx_gpio_ops = { .direction_output = meson_gpio_direction_output, }; -const struct driver meson_gx_gpio_driver = { +U_BOOT_DRIVER(meson_gx_gpio_driver) = { .name = "meson-gx-gpio", .id = UCLASS_GPIO, .probe = meson_gpio_probe, diff --git a/drivers/pinctrl/meson/pinctrl-meson-gx.h b/drivers/pinctrl/meson/pinctrl-meson-gx.h index 4c1aa1a300..c70c1f51c6 100644 --- a/drivers/pinctrl/meson/pinctrl-meson-gx.h +++ b/drivers/pinctrl/meson/pinctrl-meson-gx.h @@ -43,6 +43,6 @@ struct meson_gx_pmx_data { } extern const struct pinctrl_ops meson_gx_pinctrl_ops; -extern const struct driver meson_gx_gpio_driver; +extern U_BOOT_DRIVER(meson_gx_gpio_driver); #endif /* __PINCTRL_MESON_GX_H__ */ diff --git a/drivers/pinctrl/meson/pinctrl-meson-gxbb.c b/drivers/pinctrl/meson/pinctrl-meson-gxbb.c index 8c01c73906..93a895c9fa 100644 --- a/drivers/pinctrl/meson/pinctrl-meson-gxbb.c +++ b/drivers/pinctrl/meson/pinctrl-meson-gxbb.c @@ -439,7 +439,7 @@ struct meson_pinctrl_data meson_gxbb_periphs_pinctrl_data = { .num_groups = ARRAY_SIZE(meson_gxbb_periphs_groups), .num_funcs = ARRAY_SIZE(meson_gxbb_periphs_functions), .num_banks = ARRAY_SIZE(meson_gxbb_periphs_banks), - .gpio_driver = &meson_gx_gpio_driver, + .gpio_driver = DM_DRIVER_REF(meson_gx_gpio_driver), }; struct meson_pinctrl_data meson_gxbb_aobus_pinctrl_data = { @@ -452,7 +452,7 @@ struct meson_pinctrl_data meson_gxbb_aobus_pinctrl_data = { .num_groups = ARRAY_SIZE(meson_gxbb_aobus_groups), .num_funcs = ARRAY_SIZE(meson_gxbb_aobus_functions), .num_banks = ARRAY_SIZE(meson_gxbb_aobus_banks), - .gpio_driver = &meson_gx_gpio_driver, + .gpio_driver = DM_DRIVER_REF(meson_gx_gpio_driver), }; static const struct udevice_id meson_gxbb_pinctrl_match[] = { diff --git a/drivers/pinctrl/meson/pinctrl-meson-gxl.c b/drivers/pinctrl/meson/pinctrl-meson-gxl.c index 51a0b4c5ca..a44145e2d4 100644 --- a/drivers/pinctrl/meson/pinctrl-meson-gxl.c +++ b/drivers/pinctrl/meson/pinctrl-meson-gxl.c @@ -701,7 +701,7 @@ struct meson_pinctrl_data meson_gxl_periphs_pinctrl_data = { .num_groups = ARRAY_SIZE(meson_gxl_periphs_groups), .num_funcs = ARRAY_SIZE(meson_gxl_periphs_functions), .num_banks = ARRAY_SIZE(meson_gxl_periphs_banks), - .gpio_driver = &meson_gx_gpio_driver, + .gpio_driver = DM_DRIVER_REF(meson_gx_gpio_driver), }; struct meson_pinctrl_data meson_gxl_aobus_pinctrl_data = { @@ -714,7 +714,7 @@ struct meson_pinctrl_data meson_gxl_aobus_pinctrl_data = { .num_groups = ARRAY_SIZE(meson_gxl_aobus_groups), .num_funcs = ARRAY_SIZE(meson_gxl_aobus_functions), .num_banks = ARRAY_SIZE(meson_gxl_aobus_banks), - .gpio_driver = &meson_gx_gpio_driver, + .gpio_driver = DM_DRIVER_REF(meson_gx_gpio_driver), }; static const struct udevice_id meson_gxl_pinctrl_match[] = { From bdc68df4ddc1330b7d34a520e94d58608d057019 Mon Sep 17 00:00:00 2001 From: Neil Armstrong Date: Wed, 17 Nov 2021 12:04:10 +0100 Subject: [PATCH 35/69] configs: meson64_android: bypass other checks on run_fastboot=1 This can lead to GPT and BCB errors even if fastboot was selected early by usb rom boot and the eMMC is blank/invalid. Signed-off-by: Neil Armstrong Signed-off-by: Mattijs Korpershoek --- include/configs/meson64_android.h | 35 +++++++++++++++++-------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/include/configs/meson64_android.h b/include/configs/meson64_android.h index fb3ccc329a..93d8f8ec99 100644 --- a/include/configs/meson64_android.h +++ b/include/configs/meson64_android.h @@ -140,24 +140,27 @@ "echo Fastboot forced by usb rom boot;" \ "setenv run_fastboot 1;" \ "fi;" \ - "if gpt verify mmc ${mmcdev} ${partitions}; then; " \ - "else " \ - "echo Broken MMC partition scheme;" \ - "setenv run_fastboot 1;" \ - "fi;" \ - "if bcb load " __stringify(CONFIG_FASTBOOT_FLASH_MMC_DEV) " " \ - CONTROL_PARTITION "; then " \ - "if bcb test command = bootonce-bootloader; then " \ - "echo BCB: Bootloader boot...; " \ - "bcb clear command; bcb store; " \ + "if test \"${run_fastboot}\" -eq 0; then " \ + "if gpt verify mmc ${mmcdev} ${partitions}; then; " \ + "else " \ + "echo Broken MMC partition scheme;" \ "setenv run_fastboot 1;" \ "fi; " \ - "if bcb test command = boot-fastboot; then " \ - "echo BCB: fastboot userspace boot...; " \ - "setenv force_recovery 1;" \ - "fi; " \ - "else " \ - "echo Warning: BCB is corrupted or does not exist; " \ + "fi;" \ + "if test \"${run_fastboot}\" -eq 0; then " \ + "if bcb load " __stringify(CONFIG_FASTBOOT_FLASH_MMC_DEV) " " \ + CONTROL_PARTITION "; then " \ + "if bcb test command = bootonce-bootloader; then " \ + "echo BCB: Bootloader boot...; " \ + "bcb clear command; bcb store; " \ + "setenv run_fastboot 1;" \ + "elif bcb test command = boot-fastboot; then " \ + "echo BCB: fastboot userspace boot...; " \ + "setenv force_recovery 1;" \ + "fi; " \ + "else " \ + "echo Warning: BCB is corrupted or does not exist; " \ + "fi;" \ "fi;" \ "if test \"${run_fastboot}\" -eq 1; then " \ "echo Running Fastboot...;" \ From 28f70cfcfd82ac509c8da772b74e5dc2df795fd2 Mon Sep 17 00:00:00 2001 From: Neil Armstrong Date: Wed, 17 Nov 2021 12:04:11 +0100 Subject: [PATCH 36/69] configs: meson64_android: add PANIC stage for SYSTEM fails If bootloader was updated without running oem format, reboot will cause boot loop because the SYSTEM stage fails. Add a final PANIC stage running fastboot to permit recovery. Signed-off-by: Neil Armstrong Signed-off-by: Mattijs Korpershoek --- include/configs/meson64_android.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/include/configs/meson64_android.h b/include/configs/meson64_android.h index 93d8f8ec99..7cd1ab0341 100644 --- a/include/configs/meson64_android.h +++ b/include/configs/meson64_android.h @@ -233,16 +233,24 @@ "echo Running Android...;" \ BOOT_CMD \ "fi;" \ - "echo Failed to boot Android...;" \ - "reset\0" + "echo Failed to boot Android...;\0" #define BOOTENV_DEV_NAME_SYSTEM(devtypeu, devtypel, instance) \ "system " +#define BOOTENV_DEV_PANIC(devtypeu, devtypel, instance) \ + "bootcmd_panic=" \ + "fastboot " __stringify(CONFIG_FASTBOOT_USB_DEV) "; " \ + "reset\0" + +#define BOOTENV_DEV_NAME_PANIC(devtypeu, devtypel, instance) \ + "panic " + #define BOOT_TARGET_DEVICES(func) \ func(FASTBOOT, fastboot, na) \ func(RECOVERY, recovery, na) \ func(SYSTEM, system, na) \ + func(PANIC, panic, na) \ #define PREBOOT_LOAD_LOGO \ "if test \"${boot_source}\" != \"usb\" && " \ From 5a515132d9f25b1ff2c15e2013de9be33bf71067 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sun, 14 Nov 2021 08:41:07 +0100 Subject: [PATCH 37/69] lmb: remove lmb_is_nomap() from include Defining static functions in includes should be avoided. Function lmb_is_nomap() is only used in the unit test. So move it to the unit test. Signed-off-by: Heinrich Schuchardt Acked-by: Ilias Apalodimas --- include/lmb.h | 7 ------- test/lib/lmb.c | 5 +++++ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/include/lmb.h b/include/lmb.h index 1984291132..ee5b938e19 100644 --- a/include/lmb.h +++ b/include/lmb.h @@ -124,13 +124,6 @@ void board_lmb_reserve(struct lmb *lmb); void arch_lmb_reserve(struct lmb *lmb); void arch_lmb_reserve_generic(struct lmb *lmb, ulong sp, ulong end, ulong align); -/* Low level functions */ - -static inline bool lmb_is_nomap(struct lmb_property *m) -{ - return m->flags & LMB_NOMAP; -} - #endif /* __KERNEL__ */ #endif /* _LINUX_LMB_H */ diff --git a/test/lib/lmb.c b/test/lib/lmb.c index b2c2b99ef1..157c26394d 100644 --- a/test/lib/lmb.c +++ b/test/lib/lmb.c @@ -12,6 +12,11 @@ #include #include +static inline bool lmb_is_nomap(struct lmb_property *m) +{ + return m->flags & LMB_NOMAP; +} + static int check_lmb(struct unit_test_state *uts, struct lmb *lmb, phys_addr_t ram_base, phys_size_t ram_size, unsigned long num_reserved, From 4ad4c2daeb44a1761e944e819213ceb3c3bd1340 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sun, 14 Nov 2021 08:43:07 +0100 Subject: [PATCH 38/69] doc: add include/lmb.h to the HTML documentation Correct Sphinx style comments in include/lmb.h Add the logical memory block API to the HTML documentation. Signed-off-by: Heinrich Schuchardt Acked-by: Ilias Apalodimas --- doc/api/index.rst | 1 + doc/api/lmb.rst | 7 +++++++ include/lmb.h | 23 ++++++++++++----------- 3 files changed, 20 insertions(+), 11 deletions(-) create mode 100644 doc/api/lmb.rst diff --git a/doc/api/index.rst b/doc/api/index.rst index 281d1dca96..806c7385a6 100644 --- a/doc/api/index.rst +++ b/doc/api/index.rst @@ -10,6 +10,7 @@ U-Boot API documentation efi getopt linker_lists + lmb logging pinctrl rng diff --git a/doc/api/lmb.rst b/doc/api/lmb.rst new file mode 100644 index 0000000000..2095bfa161 --- /dev/null +++ b/doc/api/lmb.rst @@ -0,0 +1,7 @@ +.. SPDX-License-Identifier: GPL-2.0+ + +Logical memory blocks +===================== + +.. kernel-doc:: include/lmb.h + :internal: diff --git a/include/lmb.h b/include/lmb.h index ee5b938e19..5efdf9d2e8 100644 --- a/include/lmb.h +++ b/include/lmb.h @@ -25,8 +25,9 @@ enum lmb_flags { /** * struct lmb_property - Description of one region. * - * @base: Base address of the region. - * @size: Size of the region + * @base: Base address of the region. + * @size: Size of the region + * @flags: memory region attributes */ struct lmb_property { phys_addr_t base; @@ -83,11 +84,11 @@ extern long lmb_reserve(struct lmb *lmb, phys_addr_t base, phys_size_t size); /** * lmb_reserve_flags - Reserve one region with a specific flags bitfield. * - * @lmb the logical memory block struct - * @base base address of the memory region - * @size size of the memory region - * @flags flags for the memory region - * @return 0 if OK, > 0 for coalesced region or a negative error code. + * @lmb: the logical memory block struct + * @base: base address of the memory region + * @size: size of the memory region + * @flags: flags for the memory region + * Return: 0 if OK, > 0 for coalesced region or a negative error code. */ long lmb_reserve_flags(struct lmb *lmb, phys_addr_t base, phys_size_t size, enum lmb_flags flags); @@ -103,10 +104,10 @@ extern int lmb_is_reserved(struct lmb *lmb, phys_addr_t addr); /** * lmb_is_reserved_flags - test if tha address is in reserved region with a bitfield flag * - * @lmb the logical memory block struct - * @addr address to be tested - * @flags flags bitfied to be tested - * @return 0 if not reserved or reserved without the requested flag else 1 + * @lmb: the logical memory block struct + * @addr: address to be tested + * @flags: flags bitfied to be tested + * Return: if not reserved or reserved without the requested flag else 1 */ int lmb_is_reserved_flags(struct lmb *lmb, phys_addr_t addr, int flags); extern long lmb_free(struct lmb *lmb, phys_addr_t base, phys_size_t size); From 951a8c487120b7f0a4badecb9402d7eaaad8dbfb Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sun, 14 Nov 2021 08:52:48 +0100 Subject: [PATCH 39/69] lmb: remove extern keyword in lmb.h The extern keyword is not needed in include/lmb.h to declare functions. Remove it. Signed-off-by: Heinrich Schuchardt Acked-by: Ilias Apalodimas --- include/lmb.h | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/include/lmb.h b/include/lmb.h index 5efdf9d2e8..6182054f68 100644 --- a/include/lmb.h +++ b/include/lmb.h @@ -74,13 +74,12 @@ struct lmb { #endif }; -extern void lmb_init(struct lmb *lmb); -extern void lmb_init_and_reserve(struct lmb *lmb, struct bd_info *bd, - void *fdt_blob); -extern void lmb_init_and_reserve_range(struct lmb *lmb, phys_addr_t base, - phys_size_t size, void *fdt_blob); -extern long lmb_add(struct lmb *lmb, phys_addr_t base, phys_size_t size); -extern long lmb_reserve(struct lmb *lmb, phys_addr_t base, phys_size_t size); +void lmb_init(struct lmb *lmb); +void lmb_init_and_reserve(struct lmb *lmb, struct bd_info *bd, void *fdt_blob); +void lmb_init_and_reserve_range(struct lmb *lmb, phys_addr_t base, + phys_size_t size, void *fdt_blob); +long lmb_add(struct lmb *lmb, phys_addr_t base, phys_size_t size); +long lmb_reserve(struct lmb *lmb, phys_addr_t base, phys_size_t size); /** * lmb_reserve_flags - Reserve one region with a specific flags bitfield. * @@ -92,15 +91,14 @@ extern long lmb_reserve(struct lmb *lmb, phys_addr_t base, phys_size_t size); */ long lmb_reserve_flags(struct lmb *lmb, phys_addr_t base, phys_size_t size, enum lmb_flags flags); -extern phys_addr_t lmb_alloc(struct lmb *lmb, phys_size_t size, ulong align); -extern phys_addr_t lmb_alloc_base(struct lmb *lmb, phys_size_t size, ulong align, - phys_addr_t max_addr); -extern phys_addr_t __lmb_alloc_base(struct lmb *lmb, phys_size_t size, ulong align, - phys_addr_t max_addr); -extern phys_addr_t lmb_alloc_addr(struct lmb *lmb, phys_addr_t base, - phys_size_t size); -extern phys_size_t lmb_get_free_size(struct lmb *lmb, phys_addr_t addr); -extern int lmb_is_reserved(struct lmb *lmb, phys_addr_t addr); +phys_addr_t lmb_alloc(struct lmb *lmb, phys_size_t size, ulong align); +phys_addr_t lmb_alloc_base(struct lmb *lmb, phys_size_t size, ulong align, + phys_addr_t max_addr); +phys_addr_t __lmb_alloc_base(struct lmb *lmb, phys_size_t size, ulong align, + phys_addr_t max_addr); +phys_addr_t lmb_alloc_addr(struct lmb *lmb, phys_addr_t base, phys_size_t size); +phys_size_t lmb_get_free_size(struct lmb *lmb, phys_addr_t addr); +int lmb_is_reserved(struct lmb *lmb, phys_addr_t addr); /** * lmb_is_reserved_flags - test if tha address is in reserved region with a bitfield flag * @@ -110,10 +108,10 @@ extern int lmb_is_reserved(struct lmb *lmb, phys_addr_t addr); * Return: if not reserved or reserved without the requested flag else 1 */ int lmb_is_reserved_flags(struct lmb *lmb, phys_addr_t addr, int flags); -extern long lmb_free(struct lmb *lmb, phys_addr_t base, phys_size_t size); +long lmb_free(struct lmb *lmb, phys_addr_t base, phys_size_t size); -extern void lmb_dump_all(struct lmb *lmb); -extern void lmb_dump_all_force(struct lmb *lmb); +void lmb_dump_all(struct lmb *lmb); +void lmb_dump_all_force(struct lmb *lmb); static inline phys_size_t lmb_size_bytes(struct lmb_region *type, unsigned long region_nr) From 7db07aa24fa869bfa0e56709ffaa992051075942 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sun, 14 Nov 2021 09:03:27 +0100 Subject: [PATCH 40/69] lmb: drop unused lmb_size_bytes() lmb_size_bytes() is unused. Signed-off-by: Heinrich Schuchardt Acked-by: Ilias Apalodimas --- include/lmb.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/include/lmb.h b/include/lmb.h index 6182054f68..ab277ca800 100644 --- a/include/lmb.h +++ b/include/lmb.h @@ -113,12 +113,6 @@ long lmb_free(struct lmb *lmb, phys_addr_t base, phys_size_t size); void lmb_dump_all(struct lmb *lmb); void lmb_dump_all_force(struct lmb *lmb); -static inline phys_size_t -lmb_size_bytes(struct lmb_region *type, unsigned long region_nr) -{ - return type->region[region_nr].size; -} - void board_lmb_reserve(struct lmb *lmb); void arch_lmb_reserve(struct lmb *lmb); void arch_lmb_reserve_generic(struct lmb *lmb, ulong sp, ulong end, ulong align); From ac7606af7d4a91d6bad0e5de51b72a513e6ae440 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sun, 14 Nov 2021 09:38:53 +0100 Subject: [PATCH 41/69] lmb: fix typo 'commun' %s/commun/common/ Signed-off-by: Heinrich Schuchardt Acked-by: Ilias Apalodimas --- lib/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Kconfig b/lib/Kconfig index 70bf8e7a46..807a4c6ade 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -793,7 +793,7 @@ config LMB Support the library logical memory blocks. config LMB_USE_MAX_REGIONS - bool "Use a commun number of memory and reserved regions in lmb lib" + bool "Use a common number of memory and reserved regions in lmb lib" depends on LMB default y help From 0c9e8bf2bb617e08d9e07f219fe2bcf6d6de0ab4 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Mon, 15 Nov 2021 19:06:55 +0100 Subject: [PATCH 42/69] test: test truncation in snprintf() Test that the return value of snprintf() is correct in the case of truncation. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- test/print_ut.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/print_ut.c b/test/print_ut.c index 152a8c3334..7b2e7bb152 100644 --- a/test/print_ut.c +++ b/test/print_ut.c @@ -31,6 +31,7 @@ static int print_guid(struct unit_test_state *uts) 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }; char str[40]; + int ret; sprintf(str, "%pUb", guid); ut_assertok(strcmp("01020304-0506-0708-090a-0b0c0d0e0f10", str)); @@ -40,6 +41,9 @@ static int print_guid(struct unit_test_state *uts) ut_assertok(strcmp("04030201-0605-0807-090a-0b0c0d0e0f10", str)); sprintf(str, "%pUL", guid); ut_assertok(strcmp("04030201-0605-0807-090A-0B0C0D0E0F10", str)); + ret = snprintf(str, 4, "%pUL", guid); + ut_asserteq(0, str[3]); + ut_asserteq(36, ret); return 0; } @@ -349,6 +353,20 @@ static int print_itoa(struct unit_test_state *uts) } PRINT_TEST(print_itoa, 0); +static int snprint(struct unit_test_state *uts) +{ + char buf[10] = "xxxxxxxxx"; + int ret; + + ret = snprintf(buf, 4, "%s:%s", "abc", "def"); + ut_asserteq(0, buf[3]); + ut_asserteq(7, ret); + ret = snprintf(buf, 4, "%s:%d", "abc", 9999); + ut_asserteq(8, ret); + return 0; +} +PRINT_TEST(snprint, 0); + static int print_xtoa(struct unit_test_state *uts) { ut_asserteq_str("7f", simple_xtoa(127)); From dfec0e9d9c6e19fb24d16e79da612f68e9a91544 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Tue, 16 Nov 2021 18:56:43 +0100 Subject: [PATCH 43/69] scripts: update spelling.txt from upstream Linux This list is used by checkpatch.pl. The Linux v5.15 version has several words that where mispelled in U-Boot too. Signed-off-by: Heinrich Schuchardt --- scripts/spelling.txt | 365 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 360 insertions(+), 5 deletions(-) diff --git a/scripts/spelling.txt b/scripts/spelling.txt index 9a058cff49..17fdc620d5 100644 --- a/scripts/spelling.txt +++ b/scripts/spelling.txt @@ -9,7 +9,12 @@ # abandonning||abandoning abigious||ambiguous +abitrary||arbitrary abitrate||arbitrate +abnornally||abnormally +abnrormal||abnormal +abord||abort +aboslute||absolute abov||above abreviated||abbreviated absense||absence @@ -17,6 +22,7 @@ absolut||absolute absoulte||absolute acccess||access acceess||access +accelaration||acceleration acceleratoin||acceleration accelleration||acceleration accesing||accessing @@ -25,6 +31,7 @@ accessable||accessible accesss||access accidentaly||accidentally accidentually||accidentally +acclerated||accelerated accoding||according accomodate||accommodate accomodates||accommodates @@ -34,8 +41,11 @@ accout||account accquire||acquire accquired||acquired accross||across +accumalate||accumulate +accumalator||accumulator acessable||accessible acess||access +acessing||accessing achitecture||architecture acient||ancient acitions||actions @@ -49,7 +59,9 @@ activete||activate actived||activated actualy||actually acumulating||accumulating +acumulative||accumulative acumulator||accumulator +acutally||actually adapater||adapter addional||additional additionaly||additionally @@ -58,18 +70,22 @@ addres||address adddress||address addreses||addresses addresss||address +addrress||address aditional||additional aditionally||additionally aditionaly||additionally adminstrative||administrative adress||address adresses||addresses +adrresses||addresses +advertisment||advertisement adviced||advised afecting||affecting againt||against agaist||against aggreataon||aggregation aggreation||aggregation +ajust||adjust albumns||albums alegorical||allegorical algined||aligned @@ -77,6 +93,7 @@ algorith||algorithm algorithmical||algorithmically algoritm||algorithm algoritms||algorithms +algorithmn||algorithm algorrithm||algorithm algorritm||algorithm aligment||alignment @@ -88,6 +105,7 @@ alloated||allocated allocatote||allocate allocatrd||allocated allocte||allocate +allocted||allocated allpication||application alocate||allocate alogirhtms||algorithms @@ -95,11 +113,16 @@ alogrithm||algorithm alot||a lot alow||allow alows||allows +alreay||already +alredy||already altough||although alue||value ambigious||ambiguous +ambigous||ambiguous amoung||among amout||amount +amplifer||amplifier +amplifyer||amplifier an union||a union an user||a user an userspace||a userspace @@ -130,6 +153,7 @@ arbitary||arbitrary architechture||architecture arguement||argument arguements||arguments +arithmatic||arithmetic aritmetic||arithmetic arne't||aren't arraival||arrival @@ -138,27 +162,42 @@ artillary||artillery asign||assign asser||assert assertation||assertion +assertting||asserting +assgined||assigned assiged||assigned assigment||assignment assigments||assignments assistent||assistant +assocaited||associated +assocating||associating assocation||association associcated||associated assotiated||associated +asssert||assert assum||assume assumtpion||assumption asuming||assuming asycronous||asynchronous asynchnous||asynchronous +asynchromous||asynchronous +asymetric||asymmetric +asymmeric||asymmetric +atleast||at least atomatically||automatically atomicly||atomically atempt||attempt +atrributes||attributes attachement||attachment +attatch||attach attched||attached +attemp||attempt attemps||attempts attemping||attempting +attepmpt||attempt +attnetion||attention attruibutes||attributes authentification||authentication +authenicated||authenticated automaticaly||automatically automaticly||automatically automatize||automate @@ -172,6 +211,7 @@ avaible||available availabe||available availabled||available availablity||availability +availaible||available availale||available availavility||availability availble||available @@ -205,28 +245,42 @@ boardcast||broadcast borad||board boundry||boundary brievely||briefly +brigde||bridge +broadcase||broadcast broadcat||broadcast +bufer||buffer +bufufer||buffer cacluated||calculated +caculate||calculate caculation||calculation +cadidate||candidate +cahces||caches calender||calendar calescing||coalescing calle||called callibration||calibration +callled||called +callser||caller calucate||calculate calulate||calculate cancelation||cancellation cancle||cancel +canot||cannot capabilites||capabilities +capabilties||capabilities capabilty||capability capabitilies||capabilities +capablity||capability capatibilities||capabilities capapbilities||capabilities +caputure||capture carefuly||carefully cariage||carriage catagory||category cehck||check challange||challenge challanges||challenges +chache||cache chanell||channel changable||changeable chanined||chained @@ -240,6 +294,7 @@ charaters||characters charcter||character chcek||check chck||check +checksumed||checksummed checksuming||checksumming childern||children childs||children @@ -255,7 +310,9 @@ claread||cleared clared||cleared closeing||closing clustred||clustered +cnfiguration||configuration coexistance||coexistence +colescing||coalescing collapsable||collapsible colorfull||colorful comand||command @@ -266,14 +323,17 @@ comminucation||communication commited||committed commiting||committing committ||commit +commnunication||communication commoditiy||commodity comsume||consume comsumer||consumer comsuming||consuming compability||compatibility compaibility||compatibility +comparsion||comparison compatability||compatibility compatable||compatible +compatibililty||compatibility compatibiliy||compatibility compatibilty||compatibility compatiblity||compatibility @@ -285,22 +345,32 @@ completly||completely complient||compliant componnents||components compoment||component +comppatible||compatible compres||compress compresion||compression comression||compression +comunicate||communicate comunication||communication conbination||combination conditionaly||conditionally +conditon||condition +condtion||condition conected||connected -connecetd||connected +conector||connector +configration||configuration +configred||configured configuartion||configuration +configuation||configuration +configued||configured configuratoin||configuration configuraton||configuration configuretion||configuration configutation||configuration conider||consider conjuction||conjunction +connecetd||connected connectinos||connections +connetor||connector connnection||connection connnections||connections consistancy||consistency @@ -310,11 +380,13 @@ containts||contains contaisn||contains contant||contact contence||contents +contiguos||contiguous continious||continuous continous||continuous continously||continuously continueing||continuing contraints||constraints +contruct||construct contol||control contoller||controller controled||controlled @@ -340,15 +412,23 @@ cunter||counter curently||currently cylic||cyclic dafault||default +deactive||deactivate deafult||default deamon||daemon +debouce||debounce +decendant||descendant +decendants||descendants decompres||decompress +decsribed||described decription||description dectected||detected defailt||default +deferal||deferral +deffered||deferred defferred||deferred definate||definite definately||definitely +definiation||definition defintion||definition defintions||definitions defualt||default @@ -362,29 +442,35 @@ delare||declare delares||declares delaring||declaring delemiter||delimiter +delievered||delivered demodualtor||demodulator demension||dimension dependancies||dependencies dependancy||dependency dependant||dependent +dependend||dependent depreacted||deprecated depreacte||deprecate desactivate||deactivate desciptor||descriptor desciptors||descriptors +descripto||descriptor descripton||description descrition||description descritptor||descriptor desctiptor||descriptor desriptor||descriptor desriptors||descriptors +desination||destination destionation||destination +destoried||destroyed destory||destroy destoryed||destroyed destorys||destroys destroied||destroyed detabase||database deteced||detected +detectt||detect develope||develop developement||development developped||developed @@ -394,44 +480,74 @@ developpment||development deveolpment||development devided||divided deviece||device +devision||division diable||disable +diabled||disabled +dicline||decline dictionnary||dictionary didnt||didn't diferent||different differrence||difference diffrent||different +differenciate||differentiate diffrentiate||differentiate difinition||definition +digial||digital +dimention||dimension dimesions||dimensions +diconnected||disconnected +disabed||disabled +disble||disable +disgest||digest +disired||desired +dispalying||displaying diplay||display +directon||direction +direcly||directly direectly||directly +diregard||disregard disassocation||disassociation disapear||disappear disapeared||disappeared disappared||disappeared +disbale||disable +disbaled||disabled disble||disable disbled||disabled disconnet||disconnect discontinous||discontinuous +disharge||discharge +disnabled||disabled dispertion||dispersion dissapears||disappears +dissconect||disconnect distiction||distinction +divisable||divisible +divsiors||divisors docuentation||documentation documantation||documentation documentaion||documentation documment||document doesnt||doesn't +donwload||download +donwloading||downloading dorp||drop dosen||doesn downlad||download downlads||downloads +droped||dropped +droput||dropout druing||during +dyanmic||dynamic dynmaic||dynamic +eanable||enable +eanble||enable easilly||easily ecspecially||especially edditable||editable editting||editing efective||effective +effectivness||effectiveness efficently||efficiently ehther||ether eigth||eight @@ -439,16 +555,23 @@ elementry||elementary eletronic||electronic embeded||embedded enabledi||enabled +enbale||enable +enble||enable enchanced||enhanced encorporating||incorporating encrupted||encrypted encrypiton||encryption encryptio||encryption endianess||endianness +enpoint||endpoint enhaced||enhanced enlightnment||enlightenment +enqueing||enqueuing +entires||entries +entites||entities entrys||entries enocded||encoded +enought||enough enterily||entirely enviroiment||environment enviroment||environment @@ -460,13 +583,23 @@ equivelant||equivalent equivilant||equivalent eror||error errorr||error +errror||error estbalishment||establishment etsablishment||establishment etsbalishment||establishment +evalute||evaluate +evalutes||evaluates +evalution||evaluation excecutable||executable exceded||exceeded +exceds||exceeds +exceeed||exceed excellant||excellent +execeeded||exceeded +execeeds||exceeds exeed||exceed +exeeds||exceeds +exeuction||execution existance||existence existant||existent exixt||exist @@ -474,6 +607,7 @@ exlcude||exclude exlcusive||exclusive exmaple||example expecially||especially +experies||expires explicite||explicit explicitely||explicitly explict||explicit @@ -482,11 +616,16 @@ explictly||explicitly expresion||expression exprimental||experimental extened||extended +exteneded||extended extensability||extensibility extention||extension +extenstion||extension extracter||extractor -falied||failed +faied||failed +faield||failed faild||failed +failded||failed +failer||failure faill||fail failied||failed faillure||failure @@ -504,8 +643,12 @@ feautures||features fetaure||feature fetaures||features fileystem||filesystem +fimrware||firmware fimware||firmware +firmare||firmware +firmaware||firmware firware||firmware +firwmare||firmware finanize||finalize findn||find finilizes||finalizes @@ -520,13 +663,18 @@ forseeable||foreseeable forse||force fortan||fortran forwardig||forwarding +frambuffer||framebuffer framming||framing framwork||framework +frequence||frequency frequncy||frequency +frequancy||frequency frome||from fucntion||function fuction||function fuctions||functions +fullill||fulfill +funcation||function funcion||function functionallity||functionality functionaly||functionally @@ -537,14 +685,19 @@ funtions||functions furthur||further futhermore||furthermore futrue||future +gatable||gateable +gateing||gating +gauage||gauge gaurenteed||guaranteed generiously||generously genereate||generate +genereted||generated genric||generic globel||global grabing||grabbing grahical||graphical grahpical||graphical +granularty||granularity grapic||graphic grranted||granted guage||gauge @@ -553,14 +706,22 @@ guarentee||guarantee halfs||halves hander||handler handfull||handful +hanlde||handle hanled||handled happend||happened +hardare||hardware harware||hardware +havind||having heirarchically||hierarchically +heirarchy||hierarchy helpfull||helpful +hearbeat||heartbeat +heterogenous||heterogeneous +hexdecimal||hexadecimal hybernate||hibernate hierachy||hierarchy hierarchie||hierarchy +homogenous||homogeneous howver||however hsould||should hypervior||hypervisor @@ -568,12 +729,16 @@ hypter||hyper identidier||identifier iligal||illegal illigal||illegal +illgal||illegal +iomaped||iomapped imblance||imbalance immeadiately||immediately immedaite||immediate +immedate||immediate immediatelly||immediately immediatly||immediately immidiate||immediate +immutible||immutable impelentation||implementation impementated||implemented implemantation||implementation @@ -591,10 +756,13 @@ incative||inactive incomming||incoming incompatabilities||incompatibilities incompatable||incompatible +incompatble||incompatible inconsistant||inconsistent increas||increase incremeted||incremented incrment||increment +incuding||including +inculde||include indendation||indentation indended||intended independant||independent @@ -603,6 +771,8 @@ independed||independent indiate||indicate indicat||indicate inexpect||inexpected +inferface||interface +infinit||infinite infomation||information informatiom||information informations||information @@ -617,14 +787,24 @@ initalize||initialize initation||initiation initators||initiators initialiazation||initialization +initializationg||initialization initializiation||initialization +initialze||initialize initialzed||initialized +initialzing||initializing initilization||initialization initilize||initialize +initliaze||initialize +initilized||initialized inofficial||unofficial +inrerface||interface insititute||institute +instace||instance instal||install +instanciate||instantiate instanciated||instantiated +instuments||instruments +insufficent||insufficient inteface||interface integreated||integrated integrety||integrity @@ -635,17 +815,20 @@ interanl||internal interchangable||interchangeable interferring||interfering interger||integer +intergrated||integrated intermittant||intermittent internel||internal interoprability||interoperability interuupt||interrupt +interupt||interrupt +interupts||interrupts interrface||interface interrrupt||interrupt interrup||interrupt interrups||interrupts interruptted||interrupted interupted||interrupted -interupt||interrupt +intiailized||initialized intial||initial intialisation||initialisation intialised||initialised @@ -654,10 +837,14 @@ intialization||initialization intialized||initialized intialize||initialize intregral||integral +intrerrupt||interrupt intrrupt||interrupt intterrupt||interrupt intuative||intuitive +inavlid||invalid invaid||invalid +invaild||invalid +invailid||invalid invald||invalid invalde||invalid invalide||invalid @@ -666,14 +853,18 @@ invalud||invalid invididual||individual invokation||invocation invokations||invocations +ireelevant||irrelevant irrelevent||irrelevant isnt||isn't isssue||issue +issus||issues +iteraions||iterations iternations||iterations itertation||iteration itslef||itself jave||java jeffies||jiffies +jumpimng||jumping juse||just jus||just kown||known @@ -683,6 +874,7 @@ langauge||language langugage||language lauch||launch layed||laid +legnth||length leightweight||lightweight lengh||length lenght||length @@ -693,29 +885,45 @@ libary||library librairies||libraries libraris||libraries licenceing||licencing +limted||limited +logaritmic||logarithmic loggging||logging loggin||login logile||logfile +loobpack||loopback loosing||losing losted||lost +maangement||management machinary||machinery +maibox||mailbox maintainance||maintenance maintainence||maintenance maintan||maintain makeing||making +mailformed||malformed malplaced||misplaced malplace||misplace managable||manageable +managament||management managment||management mangement||management +manger||manager manoeuvering||maneuvering +manufaucturing||manufacturing mappping||mapping +maping||mapping +matchs||matches mathimatical||mathematical mathimatic||mathematic mathimatics||mathematics +maximium||maximum maxium||maximum mechamism||mechanism meetign||meeting +memeory||memory +memmber||member +memoery||memory +memroy||memory ment||meant mergable||mergeable mesage||message @@ -723,11 +931,14 @@ messags||messages messgaes||messages messsage||message messsages||messages +metdata||metadata micropone||microphone microprocesspr||microprocessor +migrateable||migratable milliseonds||milliseconds minium||minimum minimam||minimum +miniumum||minimum minumum||minimum misalinged||misaligned miscelleneous||miscellaneous @@ -736,21 +947,28 @@ mispelled||misspelled mispelt||misspelt mising||missing mismactch||mismatch +missign||missing missmanaged||mismanaged missmatch||mismatch +misssing||missing miximum||maximum mmnemonic||mnemonic mnay||many +modfiy||modify +modifer||modifier modulues||modules momery||memory memomry||memory +monitring||monitoring monochorome||monochrome monochromo||monochrome monocrome||monochrome mopdule||module mroe||more +multipler||multiplier mulitplied||multiplied multidimensionnal||multidimensional +multipe||multiple multple||multiple mumber||number muticast||multicast @@ -772,21 +990,30 @@ nerver||never nescessary||necessary nessessary||necessary noticable||noticeable +notication||notification notications||notifications +notifcations||notifications notifed||notified +notity||notify +nubmer||number numebr||number numner||number obtaion||obtain +obusing||abusing occassionally||occasionally occationally||occasionally occurance||occurrence occurances||occurrences +occurd||occurred occured||occurred occurence||occurrence occure||occurred -occured||occurred occuring||occurring +offser||offset offet||offset +offlaod||offload +offloded||offloaded +offseting||offsetting omited||omitted omiting||omitting omitt||omit @@ -794,22 +1021,28 @@ ommiting||omitting ommitted||omitted onself||oneself ony||only +openning||opening operatione||operation opertaions||operations +opportunies||opportunities optionnal||optional optmizations||optimizations orientatied||orientated orientied||oriented orignal||original +originial||original otherise||otherwise ouput||output oustanding||outstanding overaall||overall overhread||overhead overlaping||overlapping +overflw||overflow +overlfow||overflow overide||override overrided||overridden overriden||overridden +overrrun||overrun overun||overrun overwritting||overwriting overwriten||overwritten @@ -820,6 +1053,7 @@ packege||package packge||package packtes||packets pakage||package +paket||packet pallette||palette paln||plan paramameters||parameters @@ -829,23 +1063,34 @@ parametes||parameters parametised||parametrised paramter||parameter paramters||parameters +parmaters||parameters particuarly||particularly particularily||particularly +partion||partition +partions||partitions partiton||partition pased||passed passin||passing pathes||paths +pattrns||patterns pecularities||peculiarities peformance||performance +peforming||performing peice||piece pendantic||pedantic peprocessor||preprocessor +perfomance||performance perfoming||performing +perfomring||performing +periperal||peripheral +peripherial||peripheral permissons||permissions peroid||period persistance||persistence persistant||persistent +phoneticly||phonetically plalform||platform +platfoem||platform platfrom||platform plattform||platform pleaes||please @@ -857,7 +1102,10 @@ poiter||pointer posible||possible positon||position possibilites||possibilities +potocol||protocol powerfull||powerful +pramater||parameter +preamle||preamble preample||preamble preapre||prepare preceeded||preceded @@ -868,9 +1116,16 @@ precission||precision preemptable||preemptible prefered||preferred prefferably||preferably +prefitler||prefilter +preform||perform premption||preemption prepaired||prepared +prepate||prepare +preperation||preparation +preprare||prepare pressre||pressure +presuambly||presumably +previosuly||previously primative||primitive princliple||principle priorty||priority @@ -878,6 +1133,7 @@ privilaged||privileged privilage||privilege priviledge||privilege priviledges||privileges +privleges||privileges probaly||probably procceed||proceed proccesors||processors @@ -891,12 +1147,16 @@ processsed||processed processsing||processing procteted||protected prodecure||procedure +progamming||programming progams||programs progess||progress +programable||programmable programers||programmers programm||program programms||programs progresss||progress +prohibitted||prohibited +prohibitting||prohibiting promiscous||promiscuous promps||prompts pronnounced||pronounced @@ -906,35 +1166,45 @@ pronunce||pronounce propery||property propigate||propagate propigation||propagation +propogation||propagation propogate||propagate prosess||process protable||portable protcol||protocol protecion||protection +protedcted||protected protocoll||protocol promixity||proximity psudo||pseudo psuedo||pseudo psychadelic||psychedelic +purgable||purgeable pwoer||power +queing||queuing quering||querying +queus||queues randomally||randomly raoming||roaming reasearcher||researcher reasearchers||researchers reasearch||research +receieve||receive recepient||recipient +recevied||received receving||receiving +recievd||received recieved||received recieve||receive reciever||receiver recieves||receives +recieving||receiving recogniced||recognised recognizeable||recognizable recommanded||recommended recyle||recycle redircet||redirect redirectrion||redirection +redundacy||redundancy reename||rename refcounf||refcount refence||reference @@ -944,7 +1214,9 @@ refering||referring refernces||references refernnce||reference refrence||reference +registed||registered registerd||registered +registeration||registration registeresd||registered registerred||registered registes||registers @@ -957,6 +1229,7 @@ regulamentations||regulations reigstration||registration releated||related relevent||relevant +reloade||reload remoote||remote remore||remote removeable||removable @@ -967,25 +1240,38 @@ replys||replies reponse||response representaion||representation reqeust||request +reqister||register +requed||requeued requestied||requested requiere||require requirment||requirement requred||required requried||required requst||request +requsted||requested +reregisteration||reregistration reseting||resetting +reseved||reserved +reseverd||reserved resizeable||resizable resouce||resource resouces||resources resoures||resources responce||response +resrouce||resource ressizes||resizes ressource||resource ressources||resources +restesting||retesting +resumbmitting||resubmitting retransmited||retransmitted retreived||retrieved retreive||retrieve +retreiving||retrieving retrive||retrieve +retrived||retrieved +retrun||return +retun||return retuned||returned reudce||reduce reuest||request @@ -1006,30 +1292,42 @@ sacrifying||sacrificing safly||safely safty||safety savable||saveable +scaleing||scaling scaned||scanned scaning||scanning scarch||search +schdule||schedule seach||search searchs||searches +secion||section secquence||sequence secund||second segement||segment +seleted||selected +semaphone||semaphore +senario||scenario senarios||scenarios sentivite||sensitive separatly||separately sepcify||specify -sepc||spec seperated||separated seperately||separately seperate||separate seperatly||separately seperator||separator sepperate||separate +seqeunce||sequence +seqeuncer||sequencer +seqeuencer||sequencer sequece||sequence +sequemce||sequence sequencial||sequential +serivce||service serveral||several +servive||service setts||sets settting||setting +shapshot||snapshot shotdown||shutdown shoud||should shouldnt||shouldn't @@ -1037,6 +1335,7 @@ shoule||should shrinked||shrunk siginificantly||significantly signabl||signal +significanly||significantly similary||similarly similiar||similar simlar||similar @@ -1046,15 +1345,22 @@ singaled||signaled singal||signal singed||signed sleeped||slept +sliped||slipped +softwade||software softwares||software +soley||solely +souce||source speach||speech specfic||specific +specfield||specified speciefied||specified specifc||specific specifed||specified specificatin||specification specificaton||specification +specificed||specified specifing||specifying +specifiy||specify specifiying||specifying speficied||specified speicify||specify @@ -1071,8 +1377,12 @@ staion||station standardss||standards standartization||standardization standart||standard +standy||standby +stardard||standard staticly||statically +statuss||status stoped||stopped +stoping||stopping stoppped||stopped straming||streaming struc||struct @@ -1084,13 +1394,17 @@ sturcture||structure subdirectoires||subdirectories suble||subtle substract||subtract +submited||submitted submition||submission +succeded||succeeded +suceed||succeed succesfully||successfully succesful||successful successed||succeeded successfull||successful successfuly||successfully sucessfully||successfully +sucessful||successful sucess||success superflous||superfluous superseeded||superseded @@ -1103,11 +1417,13 @@ supportin||supporting suppoted||supported suppported||supported suppport||support +supprot||support supress||suppress surpressed||suppressed surpresses||suppresses susbsystem||subsystem suspeneded||suspended +suspsend||suspend suspicously||suspiciously swaping||swapping switchs||switches @@ -1119,9 +1435,11 @@ swithcing||switching swithed||switched swithing||switching swtich||switch +syfs||sysfs symetric||symmetric synax||syntax synchonized||synchronized +synchronuously||synchronously syncronize||synchronize syncronized||synchronized syncronizing||synchronizing @@ -1130,28 +1448,43 @@ syste||system sytem||system sythesis||synthesis taht||that +tansmit||transmit targetted||targeted targetting||targeting +taskelt||tasklet teh||the temorary||temporary temproarily||temporarily +temperture||temperature +thead||thread therfore||therefore thier||their threds||threads +threee||three threshhold||threshold thresold||threshold throught||through +trackling||tracking troughput||throughput +trys||tries thses||these +tiggers||triggers tiggered||triggered tipically||typically +timeing||timing timout||timeout tmis||this +toogle||toggle torerable||tolerable +traget||target +traking||tracking tramsmitted||transmitted tramsmit||transmit tranasction||transaction +tranceiver||transceiver tranfer||transfer +tranmission||transmission +transcevier||transceiver transciever||transceiver transferd||transferred transfered||transferred @@ -1162,6 +1495,8 @@ transormed||transformed trasfer||transfer trasmission||transmission treshold||threshold +triggerd||triggered +trigerred||triggered trigerring||triggering trun||turn tunning||tuning @@ -1169,8 +1504,12 @@ ture||true tyep||type udpate||update uesd||used +uknown||unknown +usccess||success uncommited||uncommitted +uncompatible||incompatible unconditionaly||unconditionally +undeflow||underflow underun||underrun unecessary||unnecessary unexecpted||unexpected @@ -1181,11 +1520,16 @@ unexpeted||unexpected unexpexted||unexpected unfortunatelly||unfortunately unifiy||unify +uniterrupted||uninterrupted unintialized||uninitialized +unitialized||uninitialized unkmown||unknown unknonw||unknown +unknouwn||unknown unknow||unknown unkown||unknown +unamed||unnamed +uneeded||unneeded unneded||unneeded unneccecary||unnecessary unneccesary||unnecessary @@ -1194,6 +1538,7 @@ unnecesary||unnecessary unneedingly||unnecessarily unnsupported||unsupported unmached||unmatched +unprecise||imprecise unregester||unregister unresgister||unregister unrgesiter||unregister @@ -1203,13 +1548,17 @@ unsolicitied||unsolicited unsuccessfull||unsuccessful unsuported||unsupported untill||until +ununsed||unused unuseful||useless +unvalid||invalid upate||update +upsupported||unsupported usefule||useful usefull||useful usege||usage usera||users usualy||usually +usupported||unsupported utilites||utilities utillities||utilities utilties||utilities @@ -1224,6 +1573,8 @@ varible||variable varient||variant vaule||value verbse||verbose +veify||verify +veriosn||version verisons||versions verison||version verson||version @@ -1233,7 +1584,9 @@ virtaul||virtual virtiual||virtual visiters||visitors vitual||virtual +vunerable||vulnerable wakeus||wakeups +wathdog||watchdog wating||waiting wiat||wait wether||whether @@ -1247,8 +1600,10 @@ wiil||will wirte||write withing||within wnat||want +wont||won't workarould||workaround writeing||writing writting||writing +wtih||with zombe||zombie zomebie||zombie From 3f80064fd55fa0c4767e92bb359dd4a582849584 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Tue, 16 Nov 2021 18:38:47 +0100 Subject: [PATCH 44/69] doc: fix typos in trace.rst Fix obvious typos. Use US spelling consistently. Signed-off-by: Heinrich Schuchardt --- doc/develop/trace.rst | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/doc/develop/trace.rst b/doc/develop/trace.rst index 7776c48428..09f5745a90 100644 --- a/doc/develop/trace.rst +++ b/doc/develop/trace.rst @@ -4,7 +4,7 @@ Tracing in U-Boot ================= -U-Boot supports a simple tracing feature which allows a record of excecution +U-Boot supports a simple tracing feature which allows a record of execution to be collected and sent to a host machine for analysis. At present the main use for this is to profile boot time. @@ -161,10 +161,10 @@ limit of the trace buffer size you have specified. Once that is exhausted no more data will be collected. Collecting trace data has an affect on execution time/performance. You -will notice this particularly with trvial functions - the overhead of +will notice this particularly with trivial functions - the overhead of recording their execution may even exceed their normal execution time. In practice this doesn't matter much so long as you are aware of the -effect. Once you have done your optimisations, turn off tracing before +effect. Once you have done your optimizations, turn off tracing before doing end-to-end timing. The best time to start tracing is right at the beginning of U-Boot. The @@ -184,7 +184,7 @@ the OS. In practical terms, U-Boot runs the 'fakegocmd' environment variable at this point. This variable should have a short script which collects the trace data and writes it somewhere. -Trace data collection relies on a microsecond timer, accesed through +Trace data collection relies on a microsecond timer, accessed through timer_get_us(). So the first think you should do is make sure that this produces sensible results for your board. Suitable sources for this timer include high resolution timers, PWMs or profile timers if @@ -285,7 +285,7 @@ Options Specify U-Boot map file -p - Specifiy profile/trace file + Specify profile/trace file Commands: @@ -315,11 +315,11 @@ time: 2. Build U-Boot with tracing and run it. Note the difference in boot time (it is common for tracing to add 10% to the time) -3. Collect the trace information as descibed above. Use this to find where +3. Collect the trace information as described above. Use this to find where all the time is being spent. -4. Take a look at that code and see if you can optimise it. Perhaps it is - possible to speed up the initialisation of a device, or remove an unused +4. Take a look at that code and see if you can optimize it. Perhaps it is + possible to speed up the initialization of a device, or remove an unused feature. 5. Rebuild, run and collect again. Compare your results. From 45c16fd0c2457d64fa94ddf3f96818542ebf72b6 Mon Sep 17 00:00:00 2001 From: Masahisa Kojima Date: Fri, 12 Nov 2021 16:24:27 +0900 Subject: [PATCH 45/69] efi: add comment for efi_system_table and efi_configuration_table This commit adds the comment for efi_system_table and efi_configuration_table structure. Signed-off-by: Masahisa Kojima Reviewed-by: Simon Glass Reviewed-by: Heinrich Schuchardt --- include/efi_api.h | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/include/efi_api.h b/include/efi_api.h index 0accad08c8..db35819473 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -417,6 +417,15 @@ struct efi_runtime_services { EFI_GUID(0x1e2ed096, 0x30e2, 0x4254, 0xbd, \ 0x89, 0x86, 0x3b, 0xbe, 0xf8, 0x23, 0x25) +/** + * struct efi_configuration_table - EFI Configuration Table + * + * This table contains a set of GUID/pointer pairs. + * The EFI Configuration Table may contain at most one instance of each table type. + * + * @guid: GUID that uniquely identifies the system configuration table + * @table: A pointer to the table associated with guid + */ struct efi_configuration_table { efi_guid_t guid; void *table; @@ -424,6 +433,29 @@ struct efi_configuration_table { #define EFI_SYSTEM_TABLE_SIGNATURE ((u64)0x5453595320494249ULL) +/** + * struct efi_system_table - EFI System Table + * + * EFI System Table contains pointers to the runtime and boot services tables. + * + * @hdr: The table header for the EFI System Table + * @fw_vendor: A pointer to a null terminated string that identifies the vendor + * that produces the system firmware + * @fw_revision: The revision of the system firmware + * @con_in_handle: The handle for the active console input device + * @con_in: A pointer to the EFI_SIMPLE_TEXT_INPUT_PROTOCOL interface + * that is associated with con_in_handle + * @con_out_handle: The handle for the active console output device + * @con_out: A pointer to the EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL interface + * that is associated with con_out_handle + * @stderr_handle: The handle for the active standard error console device + * @std_err: A pointer to the EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL interface + * that is associated with stderr_handle + * @runtime: A pointer to the EFI Runtime Services Table + * @boottime: A pointer to the EFI Boot Services Table + * @nr_tables: The number of system configuration tables + * @tables: A pointer to the system configuration tables + */ struct efi_system_table { struct efi_table_hdr hdr; u16 *fw_vendor; /* physical addr of wchar_t vendor string */ From e032cb2ac98d7085bec258dd19617409f0f70e90 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sat, 20 Nov 2021 09:28:54 +0100 Subject: [PATCH 46/69] efi_loader: Sphinx comments in efi_api.h Fix incorrect Sphinx comments in efi_api.h: * add missing 'struct' * correct indentation Signed-off-by: Heinrich Schuchardt --- include/efi_api.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/include/efi_api.h b/include/efi_api.h index db35819473..41516cc7eb 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -902,8 +902,8 @@ struct efi_hii_package_list_header { * @fields: 'fields' replaces the bit-fields defined in the EFI * specification to to avoid possible compiler incompatibilities:: * - * u32 length:24; - * u32 type:8; + * u32 length:24; + * u32 type:8; */ struct efi_hii_package_header { u32 fields; @@ -1841,7 +1841,7 @@ struct efi_system_resource_table { 0x34, 0x7d, 0x37, 0x56, 0x65, 0xa7) /** - * win_certificate_uefi_guid - A certificate that encapsulates + * struct win_certificate_uefi_guid - A certificate that encapsulates * a GUID-specific signature * * @hdr: Windows certificate header @@ -1855,7 +1855,7 @@ struct win_certificate_uefi_guid { } __attribute__((__packed__)); /** - * efi_variable_authentication_2 - A time-based authentication method + * struct efi_variable_authentication_2 - A time-based authentication method * descriptor * * This structure describes an authentication information for @@ -1872,7 +1872,7 @@ struct efi_variable_authentication_2 { } __attribute__((__packed__)); /** - * efi_firmware_image_authentication - Capsule authentication method + * struct efi_firmware_image_authentication - Capsule authentication method * descriptor * * This structure describes an authentication information for @@ -1890,7 +1890,7 @@ struct efi_firmware_image_authentication { /** - * efi_signature_data - A format of signature + * struct efi_signature_data - A format of signature * * This structure describes a single signature in signature database. * @@ -1903,7 +1903,7 @@ struct efi_signature_data { } __attribute__((__packed__)); /** - * efi_signature_list - A format of signature database + * struct efi_signature_list - A format of signature database * * This structure describes a list of signatures with the same type. * An authenticated variable's value is a concatenation of one or more From 3961bd9b552bfb3c08664fb09f18744c6f691456 Mon Sep 17 00:00:00 2001 From: Masahisa Kojima Date: Tue, 9 Nov 2021 20:35:53 +0900 Subject: [PATCH 47/69] efi_loader: Reduce efi_tcg2 logging statement log_info() is used for the debug level logging statement which should use log_debug() instead. Convert it to reduce the log output. Signed-off-by: Masahisa Kojima Reviewed-by: Heinrich Schuchardt Signed-off-by: Heinrich Schuchardt --- lib/efi_loader/efi_tcg2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/efi_loader/efi_tcg2.c b/lib/efi_loader/efi_tcg2.c index 189e4a5ba5..2771fd6b5f 100644 --- a/lib/efi_loader/efi_tcg2.c +++ b/lib/efi_loader/efi_tcg2.c @@ -1472,7 +1472,7 @@ static efi_status_t tcg2_measure_boot_variable(struct udevice *dev) &var_data_size); if (!bootvar) { - log_info("%ls not found\n", boot_name); + log_debug("%ls not found\n", boot_name); continue; } From 5d49b32f0a34cc4c23da8060ac18345984c9b96c Mon Sep 17 00:00:00 2001 From: Masami Hiramatsu Date: Fri, 12 Nov 2021 22:05:15 +0900 Subject: [PATCH 48/69] efi_loader: capsule: Record capsule result only if capsule is read Record capsule update result only if the capsule file is successfully read, because the capsule GUID is not sure when the file can not be read or the file is not a capsule. Without this fix, if user puts a dummy (non-capsule) file under (ESP)EFI/UpdateCapsule, U-Boot causes a synchronous abort. This also fixes use-after-free bug of the 'capsule' variable. Fixes: c74cd8bd08d1 ("efi_loader: capsule: add capsule_on_disk support") Signed-off-by: Masami Hiramatsu Reviewed-by: Ilias Apalodimas --- lib/efi_loader/efi_capsule.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/efi_loader/efi_capsule.c b/lib/efi_loader/efi_capsule.c index 850937fd12..502bcfca6e 100644 --- a/lib/efi_loader/efi_capsule.c +++ b/lib/efi_loader/efi_capsule.c @@ -1108,13 +1108,13 @@ efi_status_t efi_launch_capsules(void) log_err("Applying capsule %ls failed\n", files[i]); + /* create CapsuleXXXX */ + set_capsule_result(index, capsule, ret); + free(capsule); } else { log_err("Reading capsule %ls failed\n", files[i]); } - /* create CapsuleXXXX */ - set_capsule_result(index, capsule, ret); - /* delete a capsule either in case of success or failure */ ret = efi_capsule_delete_file(files[i]); if (ret != EFI_SUCCESS) From 43eaf5b13f31395afbef3ff89d99a4f6c1a2ba63 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Tue, 16 Nov 2021 18:46:27 +0100 Subject: [PATCH 49/69] efi_loader: EFI_EVENT_GROUP_BEFORE_EXIT_BOOT_SERVICES Implement the EFI_EVENT_GROUP_BEFORE_EXIT_BOOT_SERVICES event group handling. Add the definition of EFI_EVENT_GROUP_AFTER_READY_TO_BOOT. Signed-off-by: Heinrich Schuchardt --- include/efi_api.h | 9 +++++++++ lib/efi_loader/efi_boottime.c | 13 +++++++++++++ 2 files changed, 22 insertions(+) diff --git a/include/efi_api.h b/include/efi_api.h index 41516cc7eb..1e956569a0 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -360,10 +360,15 @@ struct efi_runtime_services { }; /* EFI event group GUID definitions */ + #define EFI_EVENT_GROUP_EXIT_BOOT_SERVICES \ EFI_GUID(0x27abf055, 0xb1b8, 0x4c26, 0x80, 0x48, \ 0x74, 0x8f, 0x37, 0xba, 0xa2, 0xdf) +#define EFI_EVENT_GROUP_BEFORE_EXIT_BOOT_SERVICES \ + EFI_GUID(0x8be0e274, 0x3970, 0x4b44, 0x80, 0xc5, \ + 0x1a, 0xb9, 0x50, 0x2f, 0x3b, 0xfc) + #define EFI_EVENT_GROUP_VIRTUAL_ADDRESS_CHANGE \ EFI_GUID(0x13fa7698, 0xc831, 0x49c7, 0x87, 0xea, \ 0x8f, 0x43, 0xfc, 0xc2, 0x51, 0x96) @@ -376,6 +381,10 @@ struct efi_runtime_services { EFI_GUID(0x7ce88fb3, 0x4bd7, 0x4679, 0x87, 0xa8, \ 0xa8, 0xd8, 0xde, 0xe5, 0x0d, 0x2b) +#define EFI_EVENT_GROUP_AFTER_READY_TO_BOOT \ + EFI_GUID(0x3a2a00ad, 0x98b9, 0x4cdf, 0xa4, 0x78, \ + 0x70, 0x27, 0x77, 0xf1, 0xc1, 0xb) + #define EFI_EVENT_GROUP_RESET_SYSTEM \ EFI_GUID(0x62da6a56, 0x13fb, 0x485a, 0xa8, 0xda, \ 0xa3, 0xdd, 0x79, 0x12, 0xcb, 0x6b) diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index 1823990d9b..6fdd0ef77a 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -71,6 +71,9 @@ const efi_guid_t efi_guid_driver_binding_protocol = /* event group ExitBootServices() invoked */ const efi_guid_t efi_guid_event_group_exit_boot_services = EFI_EVENT_GROUP_EXIT_BOOT_SERVICES; +/* event group before ExitBootServices() invoked */ +const efi_guid_t efi_guid_event_group_before_exit_boot_services = + EFI_EVENT_GROUP_BEFORE_EXIT_BOOT_SERVICES; /* event group SetVirtualAddressMap() invoked */ const efi_guid_t efi_guid_event_group_virtual_address_change = EFI_EVENT_GROUP_VIRTUAL_ADDRESS_CHANGE; @@ -2123,6 +2126,16 @@ static efi_status_t EFIAPI efi_exit_boot_services(efi_handle_t image_handle, if (!systab.boottime) goto out; + /* Notify EFI_EVENT_GROUP_BEFORE_EXIT_BOOT_SERVICES event group. */ + list_for_each_entry(evt, &efi_events, link) { + if (evt->group && + !guidcmp(evt->group, + &efi_guid_event_group_before_exit_boot_services)) { + efi_signal_event(evt); + break; + } + } + /* Stop all timer related activities */ timers_enabled = false; From 22ad3f5f7b31e2ff3e3415047c584dfdff388aea Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Wed, 17 Nov 2021 18:52:35 +0100 Subject: [PATCH 50/69] efi_selftest: unit test for EFI_GROUP_BEFORE_EXIT_BOOT_SERVICE Add a test for the EFI_GROUP_BEFORE_EXIT_BOOT_SERVICE event group. Signed-off-by: Heinrich Schuchardt --- .../efi_selftest_exitbootservices.c | 67 ++++++++++++++++--- 1 file changed, 56 insertions(+), 11 deletions(-) diff --git a/lib/efi_selftest/efi_selftest_exitbootservices.c b/lib/efi_selftest/efi_selftest_exitbootservices.c index 4fecd1b415..59ab15407a 100644 --- a/lib/efi_selftest/efi_selftest_exitbootservices.c +++ b/lib/efi_selftest/efi_selftest_exitbootservices.c @@ -10,9 +10,34 @@ #include +static efi_guid_t guid_before_exit_boot_services = + EFI_GUID(0x8be0e274, 0x3970, 0x4b44, 0x80, 0xc5, + 0x1a, 0xb9, 0x50, 0x2f, 0x3b, 0xfc); +#define CAPACITY 4 + +struct notification_record { + unsigned int count; + unsigned int type[CAPACITY]; +}; + +struct notification_context { + struct notification_record *record; + unsigned int type; +}; + static struct efi_boot_services *boottime; static struct efi_event *event_notify; -static unsigned int notification_count; +struct notification_record record; + +struct notification_context context_before = { + .record = &record, + .type = 1, +}; + +struct notification_context context = { + .record = &record, + .type = 2, +}; /* * Notification function, increments the notification count. @@ -20,11 +45,15 @@ static unsigned int notification_count; * @event notified event * @context pointer to the notification count */ -static void EFIAPI notify(struct efi_event *event, void *context) +static void EFIAPI ebs_notify(struct efi_event *event, void *context) { - unsigned int *count = context; + struct notification_context *ctx = context; - ++*count; + if (ctx->record->count >= CAPACITY) + return; + + ctx->record->type[ctx->record->count] = ctx->type; + ctx->record->count++; } /* @@ -43,15 +72,23 @@ static int setup(const efi_handle_t handle, boottime = systable->boottime; - notification_count = 0; ret = boottime->create_event(EVT_SIGNAL_EXIT_BOOT_SERVICES, - TPL_CALLBACK, notify, - (void *)¬ification_count, + TPL_CALLBACK, ebs_notify, + &context, &event_notify); if (ret != EFI_SUCCESS) { efi_st_error("could not create event\n"); return EFI_ST_FAILURE; } + ret = boottime->create_event_ex(0, TPL_CALLBACK, ebs_notify, + &context_before, + &guid_before_exit_boot_services, + &event_notify); + if (ret != EFI_SUCCESS) { + efi_st_error("could not create event\n"); + return EFI_ST_FAILURE; + } + return EFI_ST_SUCCESS; } @@ -68,13 +105,21 @@ static int setup(const efi_handle_t handle, */ static int execute(void) { - if (notification_count != 1) { - efi_st_error("ExitBootServices was not notified\n"); + if (record.count != 2) { + efi_st_error("Incorrect event count %u\n", record.count); + return EFI_ST_FAILURE; + } + if (record.type[0] != 1) { + efi_st_error("EFI_GROUP_BEFORE_EXIT_BOOT_SERVICE not notified\n"); + return EFI_ST_FAILURE; + } + if (record.type[1] != 2) { + efi_st_error("EVT_SIGNAL_EXIT_BOOT_SERVICES was not notified\n"); return EFI_ST_FAILURE; } efi_st_exit_boot_services(); - if (notification_count != 1) { - efi_st_error("ExitBootServices was notified twice\n"); + if (record.count != 2) { + efi_st_error("Incorrect event count %u\n", record.count); return EFI_ST_FAILURE; } return EFI_ST_SUCCESS; From dc52578d7b48342c04484184199831893a983cbf Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Wed, 17 Nov 2021 18:55:59 +0100 Subject: [PATCH 51/69] efi_loader: bump EFI_SPECIFICATION_VERSION to 2.9 We have implemented all what is new in UEFI specification 2.9 and relevant for U-Boot. Signed-off-by: Heinrich Schuchardt --- include/efi_api.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/efi_api.h b/include/efi_api.h index 1e956569a0..80109f012b 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -20,8 +20,8 @@ #include #include -/* UEFI spec version 2.8 */ -#define EFI_SPECIFICATION_VERSION (2 << 16 | 80) +/* UEFI spec version 2.9 */ +#define EFI_SPECIFICATION_VERSION (2 << 16 | 90) /* Types and defines for EFI CreateEvent */ enum efi_timer_delay { From 5ba0397049b4ad5e2e23e47a8ae412e2d9044c67 Mon Sep 17 00:00:00 2001 From: Ilias Apalodimas Date: Thu, 18 Nov 2021 09:03:39 +0200 Subject: [PATCH 52/69] efi_loader: fix FinalEvents table if an EFI app invoked GetEventLog As described in the TCG spec [1] in sections 7.1.1 and 7.1.2 the FinalEvent table should include events after GetEventLog has been called. This currently works for us as long as the kernel is the only EFI application calling that. Specifically we only implement what's described in 7.1.1. So refactor the code a bit and support EFI application(s) calling GetEventLog. Events will now be logged in both the EventLog and FinalEvent table as long as ExitBootServices haven't been invoked. [1] https://trustedcomputinggroup.org/wp-content/uploads/EFI-Protocol-Specification-rev13-160330final.pdf Signed-off-by: Ilias Apalodimas --- lib/efi_loader/efi_tcg2.c | 99 +++++++++++++++++++++++++++------------ 1 file changed, 70 insertions(+), 29 deletions(-) diff --git a/lib/efi_loader/efi_tcg2.c b/lib/efi_loader/efi_tcg2.c index 2771fd6b5f..6e32f52089 100644 --- a/lib/efi_loader/efi_tcg2.c +++ b/lib/efi_loader/efi_tcg2.c @@ -27,6 +27,17 @@ #include #include +/** + * struct event_log_buffer - internal eventlog management structure + * + * @buffer: eventlog buffer + * @final_buffer: finalevent config table buffer + * @pos: current position of 'buffer' + * @final_pos: current position of 'final_buffer' + * @get_event_called: true if GetEventLog has been invoked at least once + * @ebs_called: true if ExitBootServices has been invoked + * @truncated: true if the 'buffer' is truncated + */ struct event_log_buffer { void *buffer; void *final_buffer; @@ -34,6 +45,7 @@ struct event_log_buffer { size_t final_pos; /* final events config table position */ size_t last_event_size; bool get_event_called; + bool ebs_called; bool truncated; }; @@ -186,39 +198,29 @@ static efi_status_t tcg2_pcr_extend(struct udevice *dev, u32 pcr_index, return EFI_SUCCESS; } -/* tcg2_agile_log_append - Append an agile event to out eventlog +/* put_event - Append an agile event to an eventlog * * @pcr_index: PCR index * @event_type: type of event added * @digest_list: list of digest algorithms to add * @size: size of event * @event: event to add + * @log: log buffer to append the event * - * @Return: status code */ -static efi_status_t tcg2_agile_log_append(u32 pcr_index, u32 event_type, - struct tpml_digest_values *digest_list, - u32 size, u8 event[]) +static void put_event(u32 pcr_index, u32 event_type, + struct tpml_digest_values *digest_list, u32 size, + u8 event[], void *log) { - void *log = (void *)((uintptr_t)event_log.buffer + event_log.pos); size_t pos; size_t i; u32 event_size; - if (event_log.get_event_called) - log = (void *)((uintptr_t)event_log.final_buffer + - event_log.final_pos); - /* * size refers to the length of event[] only, we need to check against * the final tcg_pcr_event2 size */ event_size = size + tcg_event_final_size(digest_list); - if (event_log.pos + event_size > TPM2_EVENT_LOG_SIZE || - event_log.final_pos + event_size > TPM2_EVENT_LOG_SIZE) { - event_log.truncated = true; - return EFI_VOLUME_FULL; - } put_unaligned_le32(pcr_index, log); pos = offsetof(struct tcg_pcr_event2, event_type); @@ -242,25 +244,62 @@ static efi_status_t tcg2_agile_log_append(u32 pcr_index, u32 event_type, memcpy((void *)((uintptr_t)log + pos), event, size); pos += size; - /* make sure the calculated buffer is what we checked against */ + /* + * make sure the calculated buffer is what we checked against + * This check should never fail. It checks the code above is + * calculating the right length for the event we are adding + */ if (pos != event_size) - return EFI_INVALID_PARAMETER; + log_err("Appending to the EventLog failed\n"); +} - /* if GetEventLog hasn't been called update the normal log */ - if (!event_log.get_event_called) { - event_log.pos += pos; - event_log.last_event_size = pos; - } else { - /* if GetEventLog has been called update config table log */ - struct efi_tcg2_final_events_table *final_event; +/* tcg2_agile_log_append - Append an agile event to an eventlog + * + * @pcr_index: PCR index + * @event_type: type of event added + * @digest_list: list of digest algorithms to add + * @size: size of event + * @event: event to add + * @log: log buffer to append the event + * + * @Return: status code + */ +static efi_status_t tcg2_agile_log_append(u32 pcr_index, u32 event_type, + struct tpml_digest_values *digest_list, + u32 size, u8 event[]) +{ + void *log = (void *)((uintptr_t)event_log.buffer + event_log.pos); + u32 event_size = size + tcg_event_final_size(digest_list); + struct efi_tcg2_final_events_table *final_event; + efi_status_t ret = EFI_SUCCESS; - final_event = - (struct efi_tcg2_final_events_table *)(event_log.final_buffer); - final_event->number_of_events++; - event_log.final_pos += pos; + /* if ExitBootServices hasn't been called update the normal log */ + if (!event_log.ebs_called) { + if (event_log.truncated || + event_log.pos + event_size > TPM2_EVENT_LOG_SIZE) { + event_log.truncated = true; + return EFI_VOLUME_FULL; + } + put_event(pcr_index, event_type, digest_list, size, event, log); + event_log.pos += event_size; + event_log.last_event_size = event_size; } - return EFI_SUCCESS; + if (!event_log.get_event_called) + return ret; + + /* if GetEventLog has been called update FinalEventLog as well */ + if (event_log.final_pos + event_size > TPM2_EVENT_LOG_SIZE) + return EFI_VOLUME_FULL; + + log = (void *)((uintptr_t)event_log.final_buffer + event_log.final_pos); + put_event(pcr_index, event_type, digest_list, size, event, log); + + final_event = event_log.final_buffer; + final_event->number_of_events++; + event_log.final_pos += event_size; + + return ret; } /** @@ -1303,6 +1342,7 @@ static efi_status_t efi_init_event_log(void) event_log.pos = 0; event_log.last_event_size = 0; event_log.get_event_called = false; + event_log.ebs_called = false; event_log.truncated = false; /* @@ -1792,6 +1832,7 @@ efi_tcg2_notify_exit_boot_services(struct efi_event *event, void *context) EFI_ENTRY("%p, %p", event, context); + event_log.ebs_called = true; ret = platform_get_tpm2_device(&dev); if (ret != EFI_SUCCESS) goto out; From d6b55a420cfce660343cc1f60e68fcad0157925a Mon Sep 17 00:00:00 2001 From: Ilias Apalodimas Date: Thu, 18 Nov 2021 10:13:42 +0200 Subject: [PATCH 53/69] efi_loader: startup the tpm device when installing the protocol Due to U-Boot's lazy binding mentality the TPM is probed but not properly initialized. The user can startup the device from the command line e.g 'tpm2 startup TPM2_SU_CLEAR'. However we can initialize the TPM during the TCG protocol installation, which is easier to use overall. Signed-off-by: Ilias Apalodimas Reviewed-by: Heinrich Schuchardt --- lib/efi_loader/efi_tcg2.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/efi_loader/efi_tcg2.c b/lib/efi_loader/efi_tcg2.c index 6e32f52089..8c1f22e337 100644 --- a/lib/efi_loader/efi_tcg2.c +++ b/lib/efi_loader/efi_tcg2.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -1943,6 +1944,7 @@ efi_status_t efi_tcg2_register(void) efi_status_t ret = EFI_SUCCESS; struct udevice *dev; struct efi_event *event; + u32 err; ret = platform_get_tpm2_device(&dev); if (ret != EFI_SUCCESS) { @@ -1950,6 +1952,13 @@ efi_status_t efi_tcg2_register(void) return EFI_SUCCESS; } + /* initialize the TPM as early as possible. */ + err = tpm_startup(dev, TPM_ST_CLEAR); + if (err) { + log_err("TPM startup failed\n"); + goto fail; + } + ret = efi_init_event_log(); if (ret != EFI_SUCCESS) goto fail; From 3f73e79de83ecc78b9a9c823b8118ab1fba63b0a Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Fri, 19 Nov 2021 16:33:04 -0500 Subject: [PATCH 54/69] efi: Call bootm_disable_interrupts earlier in efi_exit_boot_services If we look at the path that bootm/booti take when preparing to boot the OS, we see that as part of (or prior to calling do_bootm_states, explicitly) the process, bootm_disable_interrupts() is called prior to announce_and_cleanup() which is where udc_disconnect() / board_quiesce_devices() / dm_remove_devices_flags() are called from. In the EFI path, these are called afterwards. In efi_exit_boot_services() however we have been calling bootm_disable_interrupts() after the above functions, as part of ensuring that we disable interrupts as required by the spec. However, bootm_disable_interrupts() is also where we go and call usb_stop(). While this has been fine before, on the TI J721E platform this leads us to an exception. This exception seems likely to be the case that we're trying to stop devices that we have already disabled clocks for. The most direct way to handle this particular problem is to make EFI behave like the do_bootm_states() process and ensure we call bootm_disable_interrupts() prior to ending up in usb_stop(). Cc: Ilias Apalodimas Cc: Heinrich Schuchardt Cc: Simon Glass Suggested-by: Ilias Apalodimas Signed-off-by: Tom Rini Reviewed-by: Ilias Apalodimas --- lib/efi_loader/efi_boottime.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index 6fdd0ef77a..8492b732f3 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -2167,6 +2167,7 @@ static efi_status_t EFIAPI efi_exit_boot_services(efi_handle_t image_handle, } if (!efi_st_keep_devices) { + bootm_disable_interrupts(); if (IS_ENABLED(CONFIG_USB_DEVICE)) udc_disconnect(); board_quiesce_devices(); @@ -2179,9 +2180,6 @@ static efi_status_t EFIAPI efi_exit_boot_services(efi_handle_t image_handle, /* Fix up caches for EFI payloads if necessary */ efi_exit_caches(); - /* This stops all lingering devices */ - bootm_disable_interrupts(); - /* Disable boot time services */ systab.con_in_handle = NULL; systab.con_in = NULL; From cd9a26bfe56344822c75edbc771526099efe63e6 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sat, 20 Nov 2021 13:56:02 +0100 Subject: [PATCH 55/69] efi_loader: efi_disk_register() should not fail Our algorithm for creating USB device paths may lead to duplicate device paths which result in efi_disk_register() failing. Instead we should just skip devices that cannot be registered as EFI block devices. Fix a memory leak in efi_disk_add_dev() caused by the duplicate device path. Signed-off-by: Heinrich Schuchardt --- lib/efi_loader/efi_disk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c index ef8b5c88ff..45127d1768 100644 --- a/lib/efi_loader/efi_disk.c +++ b/lib/efi_loader/efi_disk.c @@ -424,7 +424,7 @@ static efi_status_t efi_disk_add_dev( &efi_block_io_guid, &diskobj->ops, guid, NULL, NULL)); if (ret != EFI_SUCCESS) - return ret; + goto error; /* * On partitions or whole disks without partitions install the @@ -573,7 +573,7 @@ efi_status_t efi_disk_register(void) if (ret) { log_err("ERROR: failure to add disk device %s, r = %lu\n", dev->name, ret & ~EFI_ERROR_MASK); - return ret; + continue; } disks++; From 7a001e0f3d516d0c626375ca934438596a94702d Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sat, 20 Nov 2021 14:49:18 +0100 Subject: [PATCH 56/69] sandbox: poweroff in efi_system_reset() efi_system_reset() should exit if called with EFI_RESET_SHUTDOWN. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- arch/sandbox/cpu/start.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c index a74f5ec7ba..13b0731ec3 100644 --- a/arch/sandbox/cpu/start.c +++ b/arch/sandbox/cpu/start.c @@ -434,8 +434,10 @@ void __efi_runtime EFIAPI efi_reset_system( efi_status_t reset_status, unsigned long data_size, void *reset_data) { - os_fd_restore(); - os_relaunch(os_argv); + if (reset_type == EFI_RESET_SHUTDOWN) + sandbox_exit(); + else + sandbox_reset(); } void sandbox_reset(void) From 1ae35c72b8196dc353b99e9c73ff9f138808ac28 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Mon, 22 Nov 2021 08:24:08 +0100 Subject: [PATCH 57/69] test: address some pylint warnings * remove unused variables * module description must precede import statements * fix inconsistent return values Signed-off-by: Heinrich Schuchardt --- test/py/tests/test_efi_loader.py | 10 +++++----- test/py/tests/test_efi_selftest.py | 6 ++---- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/test/py/tests/test_efi_loader.py b/test/py/tests/test_efi_loader.py index fc8d6b8655..85473a9049 100644 --- a/test/py/tests/test_efi_loader.py +++ b/test/py/tests/test_efi_loader.py @@ -6,9 +6,6 @@ # Test efi loader implementation -import pytest -import u_boot_utils - """ Note: This test relies on boardenv_* containing configuration values to define which network environment is available for testing. Without this, the parts @@ -50,6 +47,9 @@ env__efi_loader_helloworld_file = { } """ +import pytest +import u_boot_utils + net_set_up = False def test_efi_pre_commands(u_boot_console): @@ -80,7 +80,7 @@ def test_efi_setup_dhcp(u_boot_console): env_vars = u_boot_console.config.env.get('env__net_static_env_vars', None) if not env_vars: pytest.skip('No DHCP server available') - return None + return u_boot_console.run_command('setenv autoload no') output = u_boot_console.run_command('dhcp') @@ -193,7 +193,7 @@ def test_efi_grub_net(u_boot_console): check_smbios = u_boot_console.config.env.get('env__efi_loader_check_smbios', False) if check_smbios: u_boot_console.wait_for('grub>') - output = u_boot_console.run_command('lsefisystab', wait_for_prompt=False, wait_for_echo=False) + u_boot_console.run_command('lsefisystab', wait_for_prompt=False, wait_for_echo=False) u_boot_console.wait_for('SMBIOS') # Then exit cleanly diff --git a/test/py/tests/test_efi_selftest.py b/test/py/tests/test_efi_selftest.py index 63218efbc2..0161a6ea24 100644 --- a/test/py/tests/test_efi_selftest.py +++ b/test/py/tests/test_efi_selftest.py @@ -73,8 +73,7 @@ def test_efi_selftest_text_input(u_boot_console): This function calls the text input EFI selftest. """ u_boot_console.run_command(cmd='setenv efi_selftest text input') - output = u_boot_console.run_command(cmd='bootefi selftest', - wait_for_prompt=False) + u_boot_console.run_command(cmd='bootefi selftest', wait_for_prompt=False) m = u_boot_console.p.expect([r'To terminate type \'x\'']) if m != 0: raise Exception('No prompt for \'text input\' test') @@ -143,8 +142,7 @@ def test_efi_selftest_text_input_ex(u_boot_console): This function calls the extended text input EFI selftest. """ u_boot_console.run_command(cmd='setenv efi_selftest extended text input') - output = u_boot_console.run_command(cmd='bootefi selftest', - wait_for_prompt=False) + u_boot_console.run_command(cmd='bootefi selftest', wait_for_prompt=False) m = u_boot_console.p.expect([r'To terminate type \'CTRL\+x\'']) if m != 0: raise Exception('No prompt for \'text input\' test') From 9d1564dabc5897ebaf2fad842d800473790479a2 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sat, 20 Nov 2021 11:53:12 +0100 Subject: [PATCH 58/69] efi_loader: segfault in efi_clear_os_indications() If we call efi_clear_os_indications() before initializing the memory store for UEFI variables a NULL pointer dereference occurs. The error was observed on the sandbox with: usb start host bind 0 sandbox.img load host 0:1 $kernel_addr_r helloworld.efi bootefi $kernel_addr_r Here efi_resister_disk() failed due to an error in the BTRFS implementation. Move the logic to clear EFI_OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED to the rest of the capsule code. If CONFIG_EFI_IGNORE_OSINDICATIONS=y, we should still clear the flag. If OsIndications does not exist, we should not create it as it is owned by the operating system. Fixes: 149108a3eb59 ("efi_loader: clear OsIndications") Signed-off-by: Heinrich Schuchardt Acked-by: Ilias Apalodimas --- lib/efi_loader/efi_capsule.c | 43 ++++++++++++++++++++++++------------ lib/efi_loader/efi_setup.c | 36 +----------------------------- 2 files changed, 30 insertions(+), 49 deletions(-) diff --git a/lib/efi_loader/efi_capsule.c b/lib/efi_loader/efi_capsule.c index 502bcfca6e..8301eed631 100644 --- a/lib/efi_loader/efi_capsule.c +++ b/lib/efi_loader/efi_capsule.c @@ -1037,30 +1037,45 @@ efi_status_t __weak efi_load_capsule_drivers(void) } /** - * check_run_capsules - Check whether capsule update should run + * check_run_capsules() - check whether capsule update should run * * The spec says OsIndications must be set in order to run the capsule update * on-disk. Since U-Boot doesn't support runtime SetVariable, allow capsules to * run explicitly if CONFIG_EFI_IGNORE_OSINDICATIONS is selected + * + * Return: EFI_SUCCESS if update to run, EFI_NOT_FOUND otherwise */ -static bool check_run_capsules(void) +static efi_status_t check_run_capsules(void) { u64 os_indications; efi_uintn_t size; - efi_status_t ret; - - if (IS_ENABLED(CONFIG_EFI_IGNORE_OSINDICATIONS)) - return true; + efi_status_t r; size = sizeof(os_indications); - ret = efi_get_variable_int(L"OsIndications", &efi_global_variable_guid, - NULL, &size, &os_indications, NULL); - if (ret == EFI_SUCCESS && - (os_indications - & EFI_OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED)) - return true; + r = efi_get_variable_int(L"OsIndications", &efi_global_variable_guid, + NULL, &size, &os_indications, NULL); + if (r != EFI_SUCCESS || size != sizeof(os_indications)) + return EFI_NOT_FOUND; - return false; + if (os_indications & + EFI_OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED) { + os_indications &= + ~EFI_OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED; + r = efi_set_variable_int(L"OsIndications", + &efi_global_variable_guid, + EFI_VARIABLE_NON_VOLATILE | + EFI_VARIABLE_BOOTSERVICE_ACCESS | + EFI_VARIABLE_RUNTIME_ACCESS, + sizeof(os_indications), + &os_indications, false); + if (r != EFI_SUCCESS) + log_err("Setting %ls failed\n", L"OsIndications"); + return EFI_SUCCESS; + } else if (IS_ENABLED(CONFIG_EFI_IGNORE_OSINDICATIONS)) { + return EFI_SUCCESS; + } else { + return EFI_NOT_FOUND; + } } /** @@ -1078,7 +1093,7 @@ efi_status_t efi_launch_capsules(void) unsigned int nfiles, index, i; efi_status_t ret; - if (!check_run_capsules()) + if (check_run_capsules() != EFI_SUCCESS) return EFI_SUCCESS; index = get_last_capsule(); diff --git a/lib/efi_loader/efi_setup.c b/lib/efi_loader/efi_setup.c index a2338d74af..1aba71cd96 100644 --- a/lib/efi_loader/efi_setup.c +++ b/lib/efi_loader/efi_setup.c @@ -175,36 +175,6 @@ static efi_status_t efi_init_os_indications(void) } -/** - * efi_clear_os_indications() - clear OsIndications - * - * Clear EFI_OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED - */ -static efi_status_t efi_clear_os_indications(void) -{ - efi_uintn_t size; - u64 os_indications; - efi_status_t ret; - - size = sizeof(os_indications); - ret = efi_get_variable_int(L"OsIndications", &efi_global_variable_guid, - NULL, &size, &os_indications, NULL); - if (ret != EFI_SUCCESS) - os_indications = 0; - else - os_indications &= - ~EFI_OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED; - ret = efi_set_variable_int(L"OsIndications", &efi_global_variable_guid, - EFI_VARIABLE_NON_VOLATILE | - EFI_VARIABLE_BOOTSERVICE_ACCESS | - EFI_VARIABLE_RUNTIME_ACCESS, - sizeof(os_indications), &os_indications, - false); - if (ret != EFI_SUCCESS) - log_err("Setting %ls failed\n", L"OsIndications"); - return ret; -} - /** * efi_init_obj_list() - Initialize and populate EFI object list * @@ -212,7 +182,7 @@ static efi_status_t efi_clear_os_indications(void) */ efi_status_t efi_init_obj_list(void) { - efi_status_t r, ret = EFI_SUCCESS; + efi_status_t ret = EFI_SUCCESS; /* Initialize once only */ if (efi_obj_list_initialized != OBJ_LIST_NOT_INITIALIZED) @@ -331,11 +301,7 @@ efi_status_t efi_init_obj_list(void) if (IS_ENABLED(CONFIG_EFI_CAPSULE_ON_DISK) && !IS_ENABLED(CONFIG_EFI_CAPSULE_ON_DISK_EARLY)) ret = efi_launch_capsules(); - out: - r = efi_clear_os_indications(); - if (ret == EFI_SUCCESS) - ret = r; efi_obj_list_initialized = ret; return ret; } From 9abd2ca96ea0e8e68a9ffb5b41d1107ea73ddc0f Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Thu, 25 Nov 2021 18:55:09 +0100 Subject: [PATCH 59/69] efi_selftest: simplify endian conversion for FDT test UEFI code is always little-endian. Remove a superfluous test. Remove a superfluous type conversion. Signed-off-by: Heinrich Schuchardt --- lib/efi_selftest/efi_selftest_fdt.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/efi_selftest/efi_selftest_fdt.c b/lib/efi_selftest/efi_selftest_fdt.c index eae98208f6..412ba286ea 100644 --- a/lib/efi_selftest/efi_selftest_fdt.c +++ b/lib/efi_selftest/efi_selftest_fdt.c @@ -23,23 +23,24 @@ static const char *fdt; static const efi_guid_t fdt_guid = EFI_FDT_GUID; static const efi_guid_t acpi_guid = EFI_ACPI_TABLE_GUID; -/* - * Convert FDT value to host endianness. +/** + * f2h() - convert FDT value to host endianness. * - * @val FDT value - * @return converted value + * UEFI code is always low endian. The FDT is big endian. + * + * @val: FDT value + * Return: converted value */ static uint32_t f2h(fdt32_t val) { char *buf = (char *)&val; char i; -#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ /* Swap the bytes */ i = buf[0]; buf[0] = buf[3]; buf[3] = i; i = buf[1]; buf[1] = buf[2]; buf[2] = i; -#endif - return *(uint32_t *)buf; + + return val; } /** From 09e409810a7f716b105793c74b83c43fda8443f4 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Tue, 23 Nov 2021 00:01:45 +0100 Subject: [PATCH 60/69] test: fix pylint errors in multiplexed_log.py * don't inherit from object * remove superfluous comprehension * add module docstring Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- test/py/multiplexed_log.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/test/py/multiplexed_log.py b/test/py/multiplexed_log.py index 545a774302..442edada12 100644 --- a/test/py/multiplexed_log.py +++ b/test/py/multiplexed_log.py @@ -2,8 +2,10 @@ # Copyright (c) 2015 Stephen Warren # Copyright (c) 2015-2016, NVIDIA CORPORATION. All rights reserved. -# Generate an HTML-formatted log file containing multiple streams of data, -# each represented in a well-delineated/-structured fashion. +""" +Generate an HTML-formatted log file containing multiple streams of data, +each represented in a well-delineated/-structured fashion. +""" import datetime import html @@ -178,7 +180,7 @@ class RunAndLog(object): raise exception return output -class SectionCtxMgr(object): +class SectionCtxMgr: """A context manager for Python's "with" statement, which allows a certain portion of test code to be logged to a separate section of the log file. Objects of this type should be created by factory functions in the Logfile @@ -206,7 +208,7 @@ class SectionCtxMgr(object): def __exit__(self, extype, value, traceback): self.log.end_section(self.marker) -class Logfile(object): +class Logfile: """Generates an HTML-formatted log file containing multiple streams of data, each represented in a well-delineated/-structured fashion.""" @@ -320,8 +322,8 @@ $(document).ready(function () { # The set of characters that should be represented as hexadecimal codes in # the log file. _nonprint = {ord('%')} - _nonprint.update({c for c in range(0, 32) if c not in (9, 10)}) - _nonprint.update({c for c in range(127, 256)}) + _nonprint.update(c for c in range(0, 32) if c not in (9, 10)) + _nonprint.update(range(127, 256)) def _escape(self, data): """Render data format suitable for inclusion in an HTML document. From 67e9b64701601eefc87f995f706b4cc7c0543312 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Tue, 23 Nov 2021 00:01:46 +0100 Subject: [PATCH 61/69] test: fix pylint errors in u_boot_spawn.py * don't inherit from object * imports should be on the top level * avoid unused variable names * avoid unnecessary else after raise Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- test/py/u_boot_spawn.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/test/py/u_boot_spawn.py b/test/py/u_boot_spawn.py index e34cb217e8..7c48d96210 100644 --- a/test/py/u_boot_spawn.py +++ b/test/py/u_boot_spawn.py @@ -1,7 +1,9 @@ # SPDX-License-Identifier: GPL-2.0 # Copyright (c) 2015-2016, NVIDIA CORPORATION. All rights reserved. -# Logic to spawn a sub-process and interact with its stdio. +""" +Logic to spawn a sub-process and interact with its stdio. +""" import os import re @@ -9,12 +11,12 @@ import pty import signal import select import time +import traceback class Timeout(Exception): """An exception sub-class that indicates that a timeout occurred.""" - pass -class Spawn(object): +class Spawn: """Represents the stdio of a freshly created sub-process. Commands may be sent to the process, and responses waited for. @@ -58,14 +60,14 @@ class Spawn(object): os.execvp(args[0], args) except: print('CHILD EXECEPTION:') - import traceback traceback.print_exc() finally: os._exit(255) try: self.poll = select.poll() - self.poll.register(self.fd, select.POLLIN | select.POLLPRI | select.POLLERR | select.POLLHUP | select.POLLNVAL) + self.poll.register(self.fd, select.POLLIN | select.POLLPRI | select.POLLERR | + select.POLLHUP | select.POLLNVAL) except: self.close() raise @@ -106,7 +108,7 @@ class Spawn(object): elif os.WIFSIGNALED(status): signum = os.WTERMSIG(status) self.exit_code = -signum - self.exit_info = 'signal %d (%s)' % (signum, signal.Signals(signum)) + self.exit_info = 'signal %d (%s)' % (signum, signal.Signals(signum).name) self.waited = True return False, self.exit_code, self.exit_info @@ -196,13 +198,11 @@ class Spawn(object): # shouldn't and explain why. This is much more friendly than # just dying with an I/O error if err.errno == 5: # Input/output error - alive, exit_code, info = self.checkalive() + alive, _, info = self.checkalive() if alive: - raise - else: - raise ValueError('U-Boot exited with %s' % info) - else: - raise + raise err + raise ValueError('U-Boot exited with %s' % info) + raise err if self.logfile_read: self.logfile_read.write(c) self.buf += c @@ -227,7 +227,7 @@ class Spawn(object): """ os.close(self.fd) - for i in range(100): + for _ in range(100): if not self.isalive(): break time.sleep(0.1) From 9aa1a14d13831cbddbdab8d28cd6005bf663bcea Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Tue, 23 Nov 2021 00:01:47 +0100 Subject: [PATCH 62/69] test: fix pylint errors in u_boot_utils.py * there is no os.path.unlink() method * don't inherit from object * add module docstring * move imports to the top * avoid unused variable Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- test/py/u_boot_utils.py | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/test/py/u_boot_utils.py b/test/py/u_boot_utils.py index e816c7fbb6..089eda5434 100644 --- a/test/py/u_boot_utils.py +++ b/test/py/u_boot_utils.py @@ -1,17 +1,20 @@ # SPDX-License-Identifier: GPL-2.0 # Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. -# Utility code shared across multiple tests. +""" +Utility code shared across multiple tests. +""" import hashlib import inspect import os import os.path -import pytest +import pathlib import signal import sys import time import re +import pytest def md5sum_data(data): """Calculate the MD5 hash of some data. @@ -48,7 +51,7 @@ def md5sum_file(fn, max_length=None): data = fh.read(*params) return md5sum_data(data) -class PersistentRandomFile(object): +class PersistentRandomFile: """Generate and store information about a persistent file containing random data.""" @@ -144,7 +147,7 @@ def wait_until_file_open_fails(fn, ignore_errors): Nothing. """ - for i in range(100): + for _ in range(100): fh = attempt_to_open_file(fn) if not fh: return @@ -192,9 +195,9 @@ def run_and_log_expect_exception(u_boot_console, cmd, retcode, msg): try: runner = u_boot_console.log.get_runner(cmd[0], sys.stdout) runner.run(cmd) - except Exception as e: - assert(retcode == runner.exit_status) - assert(msg in runner.output) + except Exception: + assert retcode == runner.exit_status + assert msg in runner.output else: raise Exception("Expected an exception with retcode %d message '%s'," "but it was not raised" % (retcode, msg)) @@ -279,17 +282,17 @@ class PersistentFileHelperCtxMgr(object): if filename_timestamp < self.module_timestamp: self.log.action('Removing stale generated file ' + self.filename) - os.unlink(self.filename) + pathlib.Path(self.filename).unlink() def __exit__(self, extype, value, traceback): if extype: try: - os.path.unlink(self.filename) - except: + pathlib.Path(self.filename).unlink() + except Exception: pass return logged = False - for i in range(20): + for _ in range(20): filename_timestamp = os.path.getmtime(self.filename) if filename_timestamp > self.module_timestamp: break From 6e6d37f7f9ed860a44443d144e1e689a72f05c78 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Tue, 23 Nov 2021 00:01:48 +0100 Subject: [PATCH 63/69] test: fix pylint error in u_boot_console_sandbox.py * provide module docstring Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- test/py/u_boot_console_sandbox.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/py/u_boot_console_sandbox.py b/test/py/u_boot_console_sandbox.py index 836f5a9e2b..7e1eb0e0b4 100644 --- a/test/py/u_boot_console_sandbox.py +++ b/test/py/u_boot_console_sandbox.py @@ -2,7 +2,9 @@ # Copyright (c) 2015 Stephen Warren # Copyright (c) 2015-2016, NVIDIA CORPORATION. All rights reserved. -# Logic to interact with the sandbox port of U-Boot, running as a sub-process. +""" +Logic to interact with the sandbox port of U-Boot, running as a sub-process. +""" import time from u_boot_spawn import Spawn From 2b5e7108594d4e100c88f44353d1fed6456d6471 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Tue, 23 Nov 2021 00:01:49 +0100 Subject: [PATCH 64/69] test: fix pylint error in u_boot_console_exec_attach.py * provide module docstring Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- test/py/u_boot_console_exec_attach.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/py/u_boot_console_exec_attach.py b/test/py/u_boot_console_exec_attach.py index 27834b55cd..8dd8cc1230 100644 --- a/test/py/u_boot_console_exec_attach.py +++ b/test/py/u_boot_console_exec_attach.py @@ -2,8 +2,10 @@ # Copyright (c) 2015 Stephen Warren # Copyright (c) 2015-2016, NVIDIA CORPORATION. All rights reserved. -# Logic to interact with U-Boot running on real hardware, typically via a -# physical serial port. +""" +Logic to interact with U-Boot running on real hardware, typically via a +physical serial port. +""" import sys from u_boot_spawn import Spawn From 4469d3b4db69bc2eab2a18527df7014a3bbd2881 Mon Sep 17 00:00:00 2001 From: Sean Anderson Date: Tue, 23 Nov 2021 23:23:40 -0500 Subject: [PATCH 65/69] clk: Add myself as a maintainer for the clock subsystem Lukasz has not been very responsive in reviewing clock patches. Add myself as a maintainer. Signed-off-by: Sean Anderson Acked-by: Lukasz Majewski --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index 6db5354322..d30daff724 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -667,6 +667,7 @@ F: drivers/mtd/jedec_flash.c CLOCK M: Lukasz Majewski +M: Sean Anderson S: Maintained T: git https://source.denx.de/u-boot/custodians/u-boot-clk.git F: drivers/clk/ From 7d3bebb2066a807ee8c63b8e99d40663ae534089 Mon Sep 17 00:00:00 2001 From: Sean Anderson Date: Tue, 23 Nov 2021 23:33:11 -0500 Subject: [PATCH 66/69] fastboot: Add maintainers entry Add an entry in maintainers for fastboot. It is starting off orphaned, but hopefully someone can pick it up. Signed-off-by: Sean Anderson --- MAINTAINERS | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index d30daff724..e718ad2135 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -761,6 +761,18 @@ F: test/env/ F: tools/env* F: tools/mkenvimage.c +FASTBOOT +S: Orphaned +F: cmd/fastboot.c +F: doc/android/fastboot*.rst +F: include/fastboot.h +F: include/fastboot-internal.h +F: include/net/fastboot.h +F: drivers/fastboot/ +F: drivers/usb/gadget/f_fastboot.c +F: net/fastboot.c +F: test/dm/fastboot.c + FPGA M: Michal Simek S: Maintained From 270eeb6871a995abb89b51273dbf531efe7524ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vincent=20Stehl=C3=A9?= Date: Wed, 24 Nov 2021 15:54:20 +0100 Subject: [PATCH 67/69] qemu: common: Fix build with update capsule MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The common emulation Makefile has a dependency on a non-existent qemu_capsule.o when building with support for capsule update enabled (CONFIG_EFI_RUNTIME_UPDATE_CAPSULE=y). The code which was in qemu_capsule.c has been completely moved to lib/efi_loader/efi_capsule.c by commit 7a6fb28c8e4b ("efi_loader: capsule: add back efi_get_public_key_data()"). Remove the false dependency. This fixes the following build error: make[1]: *** No rule to make target 'board/emulation/common/qemu_capsule.o', needed by 'board/emulation/common/built-in.o'. Stop. Fixes: commit 47a25e81d35c ("Revert "efi_capsule: Move signature from DTB to .rodata"") Signed-off-by: Vincent Stehlé Cc: Simon Glass --- board/emulation/common/Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/board/emulation/common/Makefile b/board/emulation/common/Makefile index 7ed447a69d..c5b452e7e3 100644 --- a/board/emulation/common/Makefile +++ b/board/emulation/common/Makefile @@ -2,4 +2,3 @@ obj-$(CONFIG_SYS_MTDPARTS_RUNTIME) += qemu_mtdparts.o obj-$(CONFIG_SET_DFU_ALT_INFO) += qemu_dfu.o -obj-$(CONFIG_EFI_CAPSULE_FIRMWARE_MANAGEMENT) += qemu_capsule.o From 2f7c7aeb5c1be8f1df4043b354de4c55d401125b Mon Sep 17 00:00:00 2001 From: Ivan Mikhaylov Date: Sun, 28 Nov 2021 21:57:01 +0000 Subject: [PATCH 68/69] board: iot2050: update build documentation for OP-TEE MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Set ta-target explicitly to correspond with OP-TEE recipe in siemens/meta-iot2050. Errors without explicit set of ta-target: aarch64-linux-gnu-gcc: error: unrecognized command-line option ‘-mthumb’ aarch64-linux-gnu-gcc: error: unrecognized command-line option ‘-mno-unaligned-access’ aarch64-linux-gnu-gcc: error: unrecognized command-line option ‘-mfloat-abi=hard’ make: *** [mk/compile.mk:159: out/arm-plat-k3/ta_arm32-lib/libdl/dlfcn.o] Error 1 Signed-off-by: Ivan Mikhaylov Reviewed-by: Jan Kiszka --- doc/board/siemens/iot2050.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/board/siemens/iot2050.rst b/doc/board/siemens/iot2050.rst index 592c59be03..7e97f817ce 100644 --- a/doc/board/siemens/iot2050.rst +++ b/doc/board/siemens/iot2050.rst @@ -49,7 +49,7 @@ OP-TEE: .. code-block:: text - $ make PLATFORM=k3-am65x CFG_ARM64_core=y CFG_TEE_CORE_LOG_LEVEL=2 CFG_CONSOLE_UART=1 + $ make PLATFORM=k3-am65x CFG_ARM64_core=y CFG_TEE_CORE_LOG_LEVEL=2 CFG_CONSOLE_UART=1 CFG_USER_TA_TARGETS="ta_arm64" U-Boot: From ade37460a944aed36ae6ee634c4d4a9a22690461 Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Mon, 29 Nov 2021 11:16:03 -0500 Subject: [PATCH 69/69] Prepare v2022.01-rc3 Signed-off-by: Tom Rini --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 50649963a4..179d31483e 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ VERSION = 2022 PATCHLEVEL = 01 SUBLEVEL = -EXTRAVERSION = -rc2 +EXTRAVERSION = -rc3 NAME = # *DOCUMENTATION*