From 11d30963bc19c400517c4edd83f83ca06775a05c Mon Sep 17 00:00:00 2001 From: Billy Tsai Date: Fri, 29 Apr 2022 11:50:48 +0800 Subject: [PATCH 01/18] pwm: aspeed: Select SYSCON to get parent detail. To work correctly, this driver depends on SYSCON to get the base address from the parent dts node. Signed-off-by: Billy Tsai Reviewed-by: Chia-Wei Wang --- drivers/pwm/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig index 8fd5a2e205..6e79868d0e 100644 --- a/drivers/pwm/Kconfig +++ b/drivers/pwm/Kconfig @@ -12,6 +12,7 @@ config DM_PWM config PWM_ASPEED bool "Enable support for the Aspeed PWM" depends on DM_PWM + select SYSCON help This PWM is found on Ast2600 SoCs. It supports a programmable period and duty cycle. It provides 16 channels which can be independently From 6ac4774426d687b5c365c79c9187e88f6c874878 Mon Sep 17 00:00:00 2001 From: Vyacheslav Bocharov Date: Sun, 3 Jul 2022 15:49:09 +0300 Subject: [PATCH 02/18] cmd: fix do_adc_single() The source code contains an error: - argv[2] contains arg, variable for env_set is in argv[3] - number of args is 4 Revert 54d24d72601321f4470c4edf31c6b29adae424a7 cmd: simplify do_adc_single() Fixes 9de612ae4ded53f742f5f99929c06d0839471ced cmd: adc: Add support for storing ADC result in env variable Reviewed-by: Simon Glass --- cmd/adc.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cmd/adc.c b/cmd/adc.c index 195efa8661..1c5d3e10a3 100644 --- a/cmd/adc.c +++ b/cmd/adc.c @@ -71,6 +71,7 @@ static int do_adc_info(struct cmd_tbl *cmdtp, int flag, int argc, static int do_adc_single(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { + char *varname = NULL; struct udevice *dev; unsigned int data; int ret, uV, val; @@ -78,6 +79,9 @@ static int do_adc_single(struct cmd_tbl *cmdtp, int flag, int argc, if (argc < 3) return CMD_RET_USAGE; + if (argc >= 4) + varname = argv[3]; + ret = adc_channel_single_shot(argv[1], simple_strtol(argv[2], NULL, 0), &data); if (ret) { @@ -95,7 +99,8 @@ static int do_adc_single(struct cmd_tbl *cmdtp, int flag, int argc, printf("%u\n", data); } - env_set_ulong(argv[2], val); + if (varname) + env_set_ulong(varname, val); return CMD_RET_SUCCESS; } @@ -160,5 +165,5 @@ static char adc_help_text[] = U_BOOT_CMD_WITH_SUBCMDS(adc, "ADC sub-system", adc_help_text, U_BOOT_SUBCMD_MKENT(list, 1, 1, do_adc_list), U_BOOT_SUBCMD_MKENT(info, 2, 1, do_adc_info), - U_BOOT_SUBCMD_MKENT(single, 3, 1, do_adc_single), + U_BOOT_SUBCMD_MKENT(single, 4, 1, do_adc_single), U_BOOT_SUBCMD_MKENT(scan, 3, 1, do_adc_scan)); From c588ca873488605b3b4ee9fa756b2e25d3bd167a Mon Sep 17 00:00:00 2001 From: Dmytro Firsov Date: Mon, 4 Jul 2022 12:05:38 +0000 Subject: [PATCH 03/18] drivers: xen: events: fix build issues with disabled Xen HVC Some setups do not use Xen hypervisor console for logging, e.g. they use emulated PL011 hardware or shared peripherals (real UART). In such cases Xen HVC will be disabled on a build time and will cause issues in current driver implementation. This commit fixes build issues in Xen event channel driver, caused by absense of console event channel, that is not available when console config is disabled. Now console related code will be removed when Xen HVC is turned off. Signed-off-by: Dmytro Firsov Reviewed-by: Anastasiia Lukianenko Reviewed-by: Anastasiia Lukianenko > Signed-off-by: Dmytro Firsov > --- drivers/xen/events.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/xen/events.c b/drivers/xen/events.c index 5e90a65846..532216fece 100644 --- a/drivers/xen/events.c +++ b/drivers/xen/events.c @@ -23,7 +23,9 @@ #include #include +#if CONFIG_IS_ENABLED(XEN_SERIAL) extern u32 console_evtchn; +#endif /* CONFIG_IS_ENABLED(XEN_SERIAL) */ #define NR_EVS 1024 @@ -51,8 +53,11 @@ void unbind_all_ports(void) struct vcpu_info *vcpu_info = &s->vcpu_info[cpu]; for (i = 0; i < NR_EVS; i++) { +#if CONFIG_IS_ENABLED(XEN_SERIAL) if (i == console_evtchn) continue; +#endif /* CONFIG_IS_ENABLED(XEN_SERIAL) */ + if (test_and_clear_bit(i, bound_ports)) { printf("port %d still bound!\n", i); unbind_evtchn(i); From bf28d9a65999bcf60425e65a7daf0d539838a845 Mon Sep 17 00:00:00 2001 From: Harald Seiler Date: Mon, 11 Jul 2022 14:35:32 +0200 Subject: [PATCH 04/18] spl: mmc: Use correct MMC device when loading image When attempting to load images from multiple MMC devices in sequence, spl_mmc_load() chooses the wrong device from the second attempt onwards. The reason is that MMC initialization is only done on its first call and spl_mmc_load() will then continue using this same device for all future calls. Fix this by checking the devnum of the "cached" device struct against the one which is requested. If they match, use the cached one but if they do not match, initialize the new device. This fixes specifying multiple MMC devices in the SPL's boot order to fall back when U-Boot Proper is corrupted or missing on the first attempted MMC device. Fixes: e1eb6ada4e38 ("spl: Make image loader infrastructure more universal") Signed-off-by: Harald Seiler --- common/spl/spl_mmc.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c index f66147477e..23a395e63d 100644 --- a/common/spl/spl_mmc.c +++ b/common/spl/spl_mmc.c @@ -398,6 +398,17 @@ int __weak spl_mmc_emmc_boot_partition(struct mmc *mmc) return default_spl_mmc_emmc_boot_partition(mmc); } +static int spl_mmc_get_mmc_devnum(struct mmc *mmc) +{ + struct blk_desc *block_dev; +#if !CONFIG_IS_ENABLED(BLK) + block_dev = &mmc->block_dev; +#else + block_dev = dev_get_uclass_plat(mmc->dev); +#endif + return block_dev->devnum; +} + int spl_mmc_load(struct spl_image_info *spl_image, struct spl_boot_device *bootdev, const char *filename, @@ -408,9 +419,11 @@ int spl_mmc_load(struct spl_image_info *spl_image, u32 boot_mode; int err = 0; __maybe_unused int part = 0; + int mmc_dev; - /* Perform peripheral init only once */ - if (!mmc) { + /* Perform peripheral init only once for an mmc device */ + mmc_dev = spl_mmc_get_device_index(bootdev->boot_device); + if (!mmc || spl_mmc_get_mmc_devnum(mmc) != mmc_dev) { err = spl_mmc_find_device(&mmc, bootdev->boot_device); if (err) return err; From 689525b12e00881b88cc8f02c9c711ae9b2f6b5a Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Mon, 11 Jul 2022 20:01:12 +0200 Subject: [PATCH 05/18] cmd: undefined return value of do_extension_apply() If 'extension apply all' is executed and no extension is found, the return value of do_extension_apply() is undefined. Return CMD_RET_FAILURE in this case. Fixes: 2f84e9cf06d3 ("cmd: add support for a new "extension" command") Signed-off-by: Heinrich Schuchardt Reviewed-by: Kory Maincent --- cmd/extension_board.c | 1 + 1 file changed, 1 insertion(+) diff --git a/cmd/extension_board.c b/cmd/extension_board.c index bbb4812ff8..f94abd612d 100644 --- a/cmd/extension_board.c +++ b/cmd/extension_board.c @@ -111,6 +111,7 @@ static int do_extension_apply(struct cmd_tbl *cmdtp, int flag, return CMD_RET_USAGE; if (strcmp(argv[1], "all") == 0) { + ret = CMD_RET_FAILURE; list_for_each_entry(extension, &extension_list, list) { ret = extension_apply(extension); if (ret != CMD_RET_SUCCESS) From 88513fe584466fda2d58c88a7c0bf988346e61d3 Mon Sep 17 00:00:00 2001 From: Jim Liu Date: Tue, 12 Jul 2022 17:24:07 +0800 Subject: [PATCH 06/18] ARM: dts: npcm7xx: add npcm750 full function node add npcm750 BMC full function node Signed-off-by: Jim Liu --- arch/arm/dts/nuvoton-common-npcm7xx.dtsi | 3 + arch/arm/dts/nuvoton-npcm750-evb.dts | 63 ++++- arch/arm/dts/nuvoton-npcm750.dtsi | 1 + arch/arm/dts/nuvoton-npcm7xx-u-boot.dtsi | 287 +++++++++++++++++++++++ 4 files changed, 343 insertions(+), 11 deletions(-) create mode 100644 arch/arm/dts/nuvoton-npcm7xx-u-boot.dtsi diff --git a/arch/arm/dts/nuvoton-common-npcm7xx.dtsi b/arch/arm/dts/nuvoton-common-npcm7xx.dtsi index 02ee4d78e2..feb88872fc 100644 --- a/arch/arm/dts/nuvoton-common-npcm7xx.dtsi +++ b/arch/arm/dts/nuvoton-common-npcm7xx.dtsi @@ -559,6 +559,9 @@ #size-cells = <1>; compatible = "nuvoton,npcm750-pinctrl", "syscon", "simple-mfd"; ranges = <0 0xf0010000 0x8000>; + reg = <0xf0010000 0x8000>; + syscon-gcr = <&gcr>; + syscon-rst = <&rst>; gpio0: gpio@f0010000 { gpio-controller; #gpio-cells = <2>; diff --git a/arch/arm/dts/nuvoton-npcm750-evb.dts b/arch/arm/dts/nuvoton-npcm750-evb.dts index 3e4abe6610..d4667a1df4 100644 --- a/arch/arm/dts/nuvoton-npcm750-evb.dts +++ b/arch/arm/dts/nuvoton-npcm750-evb.dts @@ -12,8 +12,8 @@ compatible = "nuvoton,npcm750-evb", "nuvoton,npcm750"; aliases { - ethernet2 = &gmac0; - ethernet3 = &gmac1; + eth0 = &emc0; + eth1 = &gmac0; serial0 = &serial0; serial1 = &serial1; serial2 = &serial2; @@ -34,11 +34,11 @@ i2c13 = &i2c13; i2c14 = &i2c14; i2c15 = &i2c15; - spi0 = &spi0; - spi1 = &spi1; - fiu0 = &fiu0; - fiu1 = &fiu3; - fiu2 = &fiux; + spi0 = &fiu0; + spi1 = &fiu3; + spi2 = &fiux; + spi3 = &spi0; + spi4 = &spi1; }; chosen { @@ -51,18 +51,20 @@ }; }; -&gmac0 { - phy-mode = "rgmii-id"; +&udc0 { status = "okay"; + phys = <&usbphy1 0>; }; -&gmac1 { +&gmac0 { phy-mode = "rgmii-id"; + snps,eee-force-disable; status = "okay"; }; &ehci1 { status = "okay"; + phys = <&usbphy2 3>; }; &fiu0 { @@ -151,7 +153,7 @@ spix-mode; }; -&watchdog1 { +&watchdog0 { status = "okay"; }; @@ -159,6 +161,14 @@ status = "okay"; }; +&sha { + status = "okay"; +}; + +&aes { + status = "okay"; +}; + &serial0 { status = "okay"; clock-frequency = <24000000>; @@ -403,3 +413,34 @@ &pin255_input>; }; +&ehci1 { + status = "okay"; + phys = <&usbphy2 3>; +}; + +&otp { + status = "okay"; +}; + +&usbphy1 { + status = "okay"; +}; + +&usbphy2 { + status = "okay"; +}; + +&emc0 { + status = "okay"; + pinctrl-names = "default"; + pinctrl-0 = <&r1_pins + &r1err_pins>; + fixed-link { + speed = <100>; + full-dulpex; + }; +}; + +&sdhci0 { + status = "okay"; +}; diff --git a/arch/arm/dts/nuvoton-npcm750.dtsi b/arch/arm/dts/nuvoton-npcm750.dtsi index 13eee0fe56..c286353832 100644 --- a/arch/arm/dts/nuvoton-npcm750.dtsi +++ b/arch/arm/dts/nuvoton-npcm750.dtsi @@ -3,6 +3,7 @@ // Copyright 2018 Google, Inc. #include "nuvoton-common-npcm7xx.dtsi" +#include "nuvoton-npcm7xx-u-boot.dtsi" / { #address-cells = <1>; diff --git a/arch/arm/dts/nuvoton-npcm7xx-u-boot.dtsi b/arch/arm/dts/nuvoton-npcm7xx-u-boot.dtsi new file mode 100644 index 0000000000..c547e433e7 --- /dev/null +++ b/arch/arm/dts/nuvoton-npcm7xx-u-boot.dtsi @@ -0,0 +1,287 @@ +// SPDX-License-Identifier: GPL-2.0 + +/ { + #address-cells = <1>; + #size-cells = <1>; + interrupt-parent = <&gic>; + + wdt-reboot { + compatible = "wdt-reboot"; + wdt = <&watchdog0>; + }; + + ahb { + udc0:udc@f0830100 { + compatible = "nuvoton,npcm750-udc"; + reg = <0xf0830100 0x200 + 0xfffd0000 0x800>; + interrupts = ; + resets = <&rstc NPCM7XX_RESET_IPSRST3 NPCM7XX_RESET_UDC0>; + status = "disabled"; + clocks = <&clk NPCM7XX_CLK_SU>; + clock-names = "clk_usb_bridge"; + }; + + udc1:udc@f0831100 { + compatible = "nuvoton,npcm750-udc"; + reg = <0xf0831100 0x200 + 0xfffd0800 0x800>; + interrupts = ; + status = "disabled"; + clocks = <&clk NPCM7XX_CLK_SU>; + clock-names = "clk_usb_bridge"; + }; + + udc2: udc@f0832100 { + compatible = "nuvoton,npcm750-udc"; + reg = <0xf0832100 0x200 + 0xfffd1000 0x800>; + interrupts = ; + status = "disabled"; + clocks = <&clk NPCM7XX_CLK_SU>; + clock-names = "clk_usb_bridge"; + }; + + udc3: udc@f0833100 { + compatible = "nuvoton,npcm750-udc"; + reg = <0xf0833100 0x200 + 0xfffd1800 0x800>; + interrupts = ; + status = "disabled"; + clocks = <&clk NPCM7XX_CLK_SU>; + clock-names = "clk_usb_bridge"; + }; + + udc4: udc@f0834100 { + compatible = "nuvoton,npcm750-udc"; + reg = <0xf0834100 0x200 + 0xfffd2000 0x800>; + interrupts = ; + status = "disabled"; + clocks = <&clk NPCM7XX_CLK_SU>; + clock-names = "clk_usb_bridge"; + }; + + udc5: udc@f0835100 { + compatible = "nuvoton,npcm750-udc"; + reg = <0xf0835100 0x200 + 0xfffd2800 0x800>; + interrupts = ; + status = "disabled"; + clocks = <&clk NPCM7XX_CLK_SU>; + clock-names = "clk_usb_bridge"; + }; + + udc6: udc@f0836100 { + compatible = "nuvoton,npcm750-udc"; + reg = <0xf0836100 0x200 + 0xfffd3000 0x800>; + interrupts = ; + status = "disabled"; + clocks = <&clk NPCM7XX_CLK_SU>; + clock-names = "clk_usb_bridge"; + }; + + udc7: udc@f0837100 { + compatible = "nuvoton,npcm750-udc"; + reg = <0xf0837100 0x200 + 0xfffd3800 0x800>; + interrupts = ; + status = "disabled"; + clocks = <&clk NPCM7XX_CLK_SU>; + clock-names = "clk_usb_bridge"; + }; + + udc8: udc@f0838100 { + compatible = "nuvoton,npcm750-udc"; + reg = <0xf0838100 0x200 + 0xfffd4000 0x800>; + interrupts = ; + status = "disabled"; + clocks = <&clk NPCM7XX_CLK_SU>; + clock-names = "clk_usb_bridge"; + }; + + udc9: udc@f0839100 { + compatible = "nuvoton,npcm750-udc"; + reg = <0xf0839100 0x200 + 0xfffd4800 0x800>; + interrupts = ; + status = "disabled"; + clocks = <&clk NPCM7XX_CLK_SU>; + clock-names = "clk_usb_bridge"; + }; + + emc0: eth@f0825000 { + device_type = "network"; + compatible = "nuvoton,npcm750-emc"; + reg = <0xf0825000 0x1000>; + phy-mode = "rmii"; + id = <0>; + syscon-gcr = <&gcr>; + interrupts = , + ; + clocks = <&clk NPCM7XX_CLK_AHB>; + clock-names = "clk_emc"; + resets = <&rstc NPCM7XX_RESET_IPSRST1 NPCM7XX_RESET_EMC1>; + pinctrl-names = "default"; + pinctrl-0 = <&r1_pins + &r1md_pins>; + status = "disabled"; + }; + + ohci1: ohci@f0807000 { + compatible = "nuvoton,npcm750-ohci"; + reg = <0xf0807000 0x1000>; + interrupts = ; + resets = <&rstc NPCM7XX_RESET_IPSRST2 NPCM7XX_RESET_USB_HOST>; + status = "disabled"; + }; + + usbphy { + compatible = "simple-bus", "nuvoton,npcm750-usb-phy"; + #address-cells = <1>; + #size-cells = <0>; + syscon = <&gcr>; + usbphy1: usbphy1 { + compatible = "nuvoton,npcm750-usb-phy"; + #phy-cells = <1>; + reg = <1>; + resets = <&rstc NPCM7XX_RESET_IPSRST3 NPCM7XX_RESET_USB_PHY_1>; + status = "disabled"; + }; + usbphy2: usbphy2 { + compatible = "nuvoton,npcm750-usb-phy"; + #phy-cells = <1>; + reg = <2>; + resets =<&rstc NPCM7XX_RESET_IPSRST3 NPCM7XX_RESET_USB_PHY_2>; + status = "disabled"; + }; + }; + + sdhci0: sdhci0@f0842000 { + compatible = "nuvoton,npcm750-sdhci"; + reg = <0xf0842000 0x200>; + index = <0x0>; + bus-width = <0x8>; + cap-mmc-highspeed; + interrupts = ; + clocks = <&clk NPCM7XX_CLK_SDHC>; + clock-frequency = <50000000>; + pinctrl-names = "default"; + pinctrl-0 = <&mmc_pins + &mmc8_pins>; + status = "disabled"; + }; + + sdhci1: sdhci1@f0840000 { + compatible = "nuvoton,npcm750-sdhci"; + reg = <0xf0840000 0x2000>; + index = <0x1>; + bus-width = <0x4>; + cap-mmc-highspeed; + pinctrl-names = "default"; + pinctrl-0 = <&sd1_pins>; + status = "disabled"; + }; + + aes: aes@f0858000 { + compatible = "nuvoton,npcm750-aes"; + reg = <0xf0858000 0x1000>; + clocks = <&clk NPCM7XX_CLK_AHB>; + clock-names = "clk_ahb"; + status = "disabled"; + }; + + sha: sha@f085a000 { + compatible = "nuvoton,npcm750-sha"; + reg = <0xf085a000 0x1000>; + clocks = <&clk NPCM7XX_CLK_AHB>; + clock-names = "clk_ahb"; + status = "disabled"; + }; + + //ehci1 + usb@f0806000 { + resets = <&rstc NPCM7XX_RESET_IPSRST2 NPCM7XX_RESET_USB_HOST>; + }; + + apb { + otp:otp@189000 { + compatible = "nuvoton,npcm750-otp"; + reg = <0x189000 0x1000 + 0x18a000 0x1000>; + status = "disabled"; + clocks = <&clk NPCM7XX_CLK_APB4>; + clock-names = "clk_apb4"; + }; + + rng@b000 { + clocks = <&clk NPCM7XX_CLK_APB1>; + }; + gpio_0: gpio0@10000 { + compatible = "nuvoton,npcm-gpio"; + reg = <0x10000 0xB0>; + #gpio-cells = <2>; + gpio-controller; + gpio-bank-name = "gpio0"; + }; + + gpio_1: gpio1@11000 { + compatible = "nuvoton,npcm-gpio"; + reg = <0x11000 0xB0>; + #gpio-cells = <2>; + gpio-controller; + gpio-bank-name = "gpio1"; + }; + + gpio_2: gpio2@12000 { + compatible = "nuvoton,npcm-gpio"; + reg = <0x12000 0xB0>; + #gpio-cells = <2>; + gpio-controller; + gpio-bank-name = "gpio2"; + }; + gpio_3: gpio3@13000 { + compatible = "nuvoton,npcm-gpio"; + reg = <0x13000 0xB0>; + #gpio-cells = <2>; + gpio-controller; + gpio-bank-name = "gpio3"; + }; + + gpio_4: gpio4@14000 { + compatible = "nuvoton,npcm-gpio"; + reg = <0x14000 0xB0>; + #gpio-cells = <2>; + gpio-controller; + gpio-bank-name = "gpio4"; + }; + + gpio_5: gpio5@15000 { + compatible = "nuvoton,npcm-gpio"; + reg = <0x15000 0xB0>; + #gpio-cells = <2>; + gpio-controller; + gpio-bank-name = "gpio5"; + }; + + gpio_6: gpio6@16000 { + compatible = "nuvoton,npcm-gpio"; + reg = <0x16000 0xB0>; + #gpio-cells = <2>; + gpio-controller; + gpio-bank-name = "gpio6"; + }; + gpio_7: gpio7@17000 { + compatible = "nuvoton,npcm-gpio"; + reg = <0x17000 0xB0>; + #gpio-cells = <2>; + gpio-controller; + gpio-bank-name = "gpio7"; + }; + + }; + }; +}; + From 5536a5f4ac12f4f14e31c85305c2fc7647d5fc03 Mon Sep 17 00:00:00 2001 From: Quentin Schulz Date: Tue, 12 Jul 2022 17:44:19 +0200 Subject: [PATCH 07/18] gpio: fix incorrect depends on for SPL_GPIO_HOG Since commit 83061dbd1c89 ("Rename GPIO_SUPPORT to GPIO"), SPL_GPIO_SUPPORT has been renamed to SPL_GPIO, meaning that SPL_GPIO_HOG can never be enabled. Let's fix this by using the proper name for the Kconfig option. Fixes: 1d99e673c752 ("gpio: Enable hogging support in SPL") Cc: Quentin Schulz Signed-off-by: Quentin Schulz Reviewed-by: Simon Glass --- drivers/gpio/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index 82a8bca270..7e4c3577b3 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -70,7 +70,7 @@ config GPIO_HOG config SPL_GPIO_HOG bool "Enable GPIO hog support in SPL" - depends on SPL_GPIO_SUPPORT + depends on SPL_GPIO help Enable gpio hog support in SPL The GPIO chip may contain GPIO hog definitions. GPIO hogging From 2c9cf3b644149cd32df5310f065ac47cbdfbc762 Mon Sep 17 00:00:00 2001 From: Quentin Schulz Date: Tue, 12 Jul 2022 17:44:20 +0200 Subject: [PATCH 08/18] mx7ulp_com: fix incorrect select for SPL options SPL_GPIO_SUPPORT is named SPL_GPIO since commit 83061dbd1c89 ("Rename GPIO_SUPPORT to GPIO"), SPL_MMC_SUPPORT is named SPL_MMC since commit 103c5f180694 ("mmc: Rename MMC_SUPPORT to MMC"), SPL_SERIAL_SUPPORT is named SPL_SERIAL since commit 2a7360666871 ("serial: Rename SERIAL_SUPPORT to SERIAL") so let's select the correct Kconfig options. Fixes: 8b71576f3842 ("mx7ulp_com: add support for SPL") Cc: Quentin Schulz Signed-off-by: Quentin Schulz --- arch/arm/mach-imx/mx7ulp/Kconfig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/arm/mach-imx/mx7ulp/Kconfig b/arch/arm/mach-imx/mx7ulp/Kconfig index 615d75bdd0..632c4bf6fa 100644 --- a/arch/arm/mach-imx/mx7ulp/Kconfig +++ b/arch/arm/mach-imx/mx7ulp/Kconfig @@ -24,16 +24,16 @@ config TARGET_MX7ULP_COM select MX7ULP select SYS_ARCH_TIMER select SPL_DM if SPL - select SPL_GPIO_SUPPORT if SPL + select SPL_GPIO if SPL select SPL_LIBCOMMON_SUPPORT if SPL select SPL_LIBDISK_SUPPORT if SPL select SPL_LIBGENERIC_SUPPORT if SPL - select SPL_MMC_SUPPORT if SPL + select SPL_MMC if SPL select SPL_OF_CONTROL if SPL select SPL_OF_LIBFDT if SPL select SPL_PINCTRL if SPL select SPL_SEPARATE_BSS if SPL - select SPL_SERIAL_SUPPORT if SPL + select SPL_SERIAL if SPL select SUPPORT_SPL config TARGET_MX7ULP_EVK From 58d258c8c4710504dd3dad4ce9773353417a9db2 Mon Sep 17 00:00:00 2001 From: Quentin Schulz Date: Tue, 12 Jul 2022 17:44:21 +0200 Subject: [PATCH 09/18] imx: imx8mp_rsb3720a1: fix incorrect ifdef check on SPL_MMC Since commit 103c5f180694 ("mmc: Rename MMC_SUPPORT to MMC"), SPL_MMC_SUPPORT is named SPL_MMC, so let's fix the ifdef. Fixes: fbc6b1414342 ("imx: imx8mp_rsb3720a1: convert to DM_SERIAL") Cc: Quentin Schulz Signed-off-by: Quentin Schulz --- board/advantech/imx8mp_rsb3720a1/imx8mp_rsb3720a1.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/board/advantech/imx8mp_rsb3720a1/imx8mp_rsb3720a1.c b/board/advantech/imx8mp_rsb3720a1/imx8mp_rsb3720a1.c index 0a1b2c9416..aa9687f7a9 100644 --- a/board/advantech/imx8mp_rsb3720a1/imx8mp_rsb3720a1.c +++ b/board/advantech/imx8mp_rsb3720a1/imx8mp_rsb3720a1.c @@ -206,7 +206,7 @@ int board_late_init(void) return 0; } -#ifdef CONFIG_SPL_MMC_SUPPORT +#ifdef CONFIG_SPL_MMC #define UBOOT_RAW_SECTOR_OFFSET 0x40 unsigned long spl_mmc_get_uboot_raw_sector(struct mmc *mmc) { @@ -219,4 +219,4 @@ unsigned long spl_mmc_get_uboot_raw_sector(struct mmc *mmc) return CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR; } } -#endif /* CONFIG_SPL_MMC_SUPPORT */ +#endif /* CONFIG_SPL_MMC */ From 81df9ed45e879fc3cbb79b182f4fba888b3f927f Mon Sep 17 00:00:00 2001 From: Quentin Schulz Date: Tue, 12 Jul 2022 17:44:22 +0200 Subject: [PATCH 10/18] vpl: fix reference in comment to non-existing SPL_SERIAL_SUPPORT Since commit 2a7360666871 ("serial: Rename SERIAL_SUPPORT to SERIAL") SPL_SERIAL_SUPPORT is named SPL_SERIAL. So let's update the comment to point to the correct Kconfig option in the comment of VPL_SERIAL. Fixes: 747093dd408 ("vpl: Add Kconfig options for VPL") Cc: Quentin Schulz Signed-off-by: Quentin Schulz Reviewed-by: Simon Glass --- common/spl/Kconfig.vpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/spl/Kconfig.vpl b/common/spl/Kconfig.vpl index ba4b2e4f99..f33162276d 100644 --- a/common/spl/Kconfig.vpl +++ b/common/spl/Kconfig.vpl @@ -166,7 +166,7 @@ config VPL_SERIAL select VPL_PRINTF select VPL_STRTO help - Enable support for serial in VPL. See SPL_SERIAL_SUPPORT for + Enable support for serial in VPL. See SPL_SERIAL for details. config VPL_SIZE_LIMIT From 63de2161e4b50ea2ce22088f6a73520504087a0c Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Thu, 14 Jul 2022 08:53:46 +0200 Subject: [PATCH 11/18] cmd: remove deprecated LCD support No board uses lcd_clear() anymore. So we can remove support for it. Signed-off-by: Heinrich Schuchardt --- cmd/cls.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/cmd/cls.c b/cmd/cls.c index 502d5ed697..ba36220d9e 100644 --- a/cmd/cls.c +++ b/cmd/cls.c @@ -8,7 +8,6 @@ #include #include #include -#include #include #define CSI "\x1b[" @@ -20,19 +19,12 @@ static int do_video_clear(struct cmd_tbl *cmdtp, int flag, int argc, /* Send clear screen and home */ printf(CSI "2J" CSI "1;1H"); -#if defined(CONFIG_DM_VIDEO) -#if !defined(CONFIG_VIDEO_ANSI) - if (uclass_first_device_err(UCLASS_VIDEO, &dev)) - return CMD_RET_FAILURE; - - if (video_clear(dev)) - return CMD_RET_FAILURE; -#endif -#elif defined(CONFIG_LCD) - lcd_clear(); -#else - return CMD_RET_FAILURE; -#endif + if (CONFIG_IS_ENABLED(DM_VIDEO) && !CONFIG_IS_ENABLED(VIDEO_ANSI)) { + if (uclass_first_device_err(UCLASS_VIDEO, &dev)) + return CMD_RET_FAILURE; + if (video_clear(dev)) + return CMD_RET_FAILURE; + } return CMD_RET_SUCCESS; } From d1c079557fe3098da02ba92bb4e4d382e6f9b12a Mon Sep 17 00:00:00 2001 From: Andrew Davis Date: Fri, 15 Jul 2022 11:34:32 -0500 Subject: [PATCH 12/18] arm: mach-k3: Add support for device type detection K3 SoCs are available in a number of device types such as GP, HS-FS, EMU, etc. Like OMAP SoCs we can detect this at runtime and should print this out as part of the SoC information line. We add this as part of the common.c file as it will be used to also modify our security state early in the device boot. Signed-off-by: Andrew Davis Reviewed-by: Tom Rini --- arch/arm/mach-k3/common.c | 51 +++++++++++++++++++++++- arch/arm/mach-k3/common.h | 10 +++++ arch/arm/mach-k3/include/mach/hardware.h | 10 +++++ 3 files changed, 70 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-k3/common.c b/arch/arm/mach-k3/common.c index 70f6444e79..ac14975694 100644 --- a/arch/arm/mach-k3/common.c +++ b/arch/arm/mach-k3/common.c @@ -396,7 +396,54 @@ void reset_cpu(void) } #endif +enum k3_device_type get_device_type(void) +{ + u32 sys_status = readl(K3_SEC_MGR_SYS_STATUS); + + u32 sys_dev_type = (sys_status & SYS_STATUS_DEV_TYPE_MASK) >> + SYS_STATUS_DEV_TYPE_SHIFT; + + u32 sys_sub_type = (sys_status & SYS_STATUS_SUB_TYPE_MASK) >> + SYS_STATUS_SUB_TYPE_SHIFT; + + switch (sys_dev_type) { + case SYS_STATUS_DEV_TYPE_GP: + return K3_DEVICE_TYPE_GP; + case SYS_STATUS_DEV_TYPE_TEST: + return K3_DEVICE_TYPE_TEST; + case SYS_STATUS_DEV_TYPE_EMU: + return K3_DEVICE_TYPE_EMU; + case SYS_STATUS_DEV_TYPE_HS: + if (sys_sub_type == SYS_STATUS_SUB_TYPE_VAL_FS) + return K3_DEVICE_TYPE_HS_FS; + else + return K3_DEVICE_TYPE_HS_SE; + default: + return K3_DEVICE_TYPE_BAD; + } +} + #if defined(CONFIG_DISPLAY_CPUINFO) +static const char *get_device_type_name(void) +{ + enum k3_device_type type = get_device_type(); + + switch (type) { + case K3_DEVICE_TYPE_GP: + return "GP"; + case K3_DEVICE_TYPE_TEST: + return "TEST"; + case K3_DEVICE_TYPE_EMU: + return "EMU"; + case K3_DEVICE_TYPE_HS_FS: + return "HS-FS"; + case K3_DEVICE_TYPE_HS_SE: + return "HS-SE"; + default: + return "BAD"; + } +} + int print_cpuinfo(void) { struct udevice *soc; @@ -418,9 +465,11 @@ int print_cpuinfo(void) ret = soc_get_revision(soc, name, 64); if (!ret) { - printf("%s\n", name); + printf("%s ", name); } + printf("%s\n", get_device_type_name()); + return 0; } #endif diff --git a/arch/arm/mach-k3/common.h b/arch/arm/mach-k3/common.h index e81b70d7c3..8f38fcef7f 100644 --- a/arch/arm/mach-k3/common.h +++ b/arch/arm/mach-k3/common.h @@ -18,6 +18,15 @@ struct fwl_data { u16 regions; }; +enum k3_device_type { + K3_DEVICE_TYPE_BAD, + K3_DEVICE_TYPE_GP, + K3_DEVICE_TYPE_TEST, + K3_DEVICE_TYPE_EMU, + K3_DEVICE_TYPE_HS_FS, + K3_DEVICE_TYPE_HS_SE, +}; + void setup_k3_mpu_regions(void); int early_console_init(void); void disable_linefill_optimization(void); @@ -27,4 +36,5 @@ void k3_sysfw_print_ver(void); void spl_enable_dcache(void); void mmr_unlock(phys_addr_t base, u32 partition); bool is_rom_loaded_sysfw(struct rom_extended_boot_data *data); +enum k3_device_type get_device_type(void); void ti_secure_image_post_process(void **p_image, size_t *p_size); diff --git a/arch/arm/mach-k3/include/mach/hardware.h b/arch/arm/mach-k3/include/mach/hardware.h index 7bbd5c22c9..028482b3b6 100644 --- a/arch/arm/mach-k3/include/mach/hardware.h +++ b/arch/arm/mach-k3/include/mach/hardware.h @@ -32,6 +32,16 @@ #define JTAG_ID_VARIANT_MASK (0xf << 28) #define JTAG_ID_PARTNO_SHIFT 12 #define JTAG_ID_PARTNO_MASK (0xffff << 12) +#define K3_SEC_MGR_SYS_STATUS 0x44234100 +#define SYS_STATUS_DEV_TYPE_SHIFT 0 +#define SYS_STATUS_DEV_TYPE_MASK (0xf) +#define SYS_STATUS_DEV_TYPE_GP 0x3 +#define SYS_STATUS_DEV_TYPE_TEST 0x5 +#define SYS_STATUS_DEV_TYPE_EMU 0x9 +#define SYS_STATUS_DEV_TYPE_HS 0xa +#define SYS_STATUS_SUB_TYPE_SHIFT 8 +#define SYS_STATUS_SUB_TYPE_MASK (0xf << 8) +#define SYS_STATUS_SUB_TYPE_VAL_FS 0xa #define K3_ROM_BOOT_HEADER_MAGIC "EXTBOOT" From e1ef04fb3e3a1eb417700e34510714be0277bee9 Mon Sep 17 00:00:00 2001 From: Andrew Davis Date: Fri, 15 Jul 2022 11:34:33 -0500 Subject: [PATCH 13/18] arm: mach-k3: security: Allow signing bypass if type is HS-FS On HS-FS devices signing boot images is optional. To ease use we check if we are HS-FS and if no certificate is attached to the image we skip the authentication step with a warning that this will fail when the device is set to security enforcing. Signed-off-by: Andrew Davis --- arch/arm/mach-k3/security.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-k3/security.c b/arch/arm/mach-k3/security.c index 8de9739a40..5bfcecd44d 100644 --- a/arch/arm/mach-k3/security.c +++ b/arch/arm/mach-k3/security.c @@ -2,10 +2,11 @@ /* * K3: Security functions * - * Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/ + * Copyright (C) 2018-2022 Texas Instruments Incorporated - http://www.ti.com/ * Andrew F. Davis */ +#include #include #include #include @@ -18,6 +19,17 @@ #include #include +#include "common.h" + +static bool ti_secure_cert_detected(void *p_image) +{ + /* Primitive certificate detection, check for DER starting with + * two 4-Octet SEQUENCE tags + */ + return (((u8 *)p_image)[0] == 0x30 && ((u8 *)p_image)[1] == 0x82 && + ((u8 *)p_image)[4] == 0x30 && ((u8 *)p_image)[5] == 0x82); +} + void ti_secure_image_post_process(void **p_image, size_t *p_size) { struct ti_sci_handle *ti_sci = get_ti_sci_handle(); @@ -29,6 +41,14 @@ void ti_secure_image_post_process(void **p_image, size_t *p_size) image_addr = (uintptr_t)*p_image; image_size = *p_size; + if (get_device_type() != K3_DEVICE_TYPE_HS_SE && + !ti_secure_cert_detected(*p_image)) { + printf("Warning: Did not detect image signing certificate. " + "Skipping authentication to prevent boot failure. " + "This will fail on Security Enforcing(HS-SE) devices\n"); + return; + } + debug("Authenticating image at address 0x%016llx\n", image_addr); debug("Authenticating image of size %d bytes\n", image_size); From a0379c6fe3bfac4e0d7633830b9d23166f3edacf Mon Sep 17 00:00:00 2001 From: Andrew Davis Date: Fri, 15 Jul 2022 11:34:34 -0500 Subject: [PATCH 14/18] arm: mach-k3: security: Bypass image signing at runtime for GP devices We can skip the image authentication check at runtime if the device is GP. This reduces the delta between GP and HS U-Boot builds. End goal is to re-unify the two build types into one build that can run on all device types. Signed-off-by: Andrew Davis --- arch/arm/mach-k3/Makefile | 3 +-- arch/arm/mach-k3/common.c | 2 -- arch/arm/mach-k3/security.c | 3 +++ 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/arm/mach-k3/Makefile b/arch/arm/mach-k3/Makefile index 0dce8802db..6ac2b61c3d 100644 --- a/arch/arm/mach-k3/Makefile +++ b/arch/arm/mach-k3/Makefile @@ -8,7 +8,6 @@ obj-$(CONFIG_SOC_K3_J721S2) += j721s2/ obj-$(CONFIG_SOC_K3_AM625) += am62x/ obj-$(CONFIG_ARM64) += arm64-mmu.o obj-$(CONFIG_CPU_V7R) += r5_mpu.o lowlevel_init.o -obj-$(CONFIG_TI_SECURE_DEVICE) += security.o obj-$(CONFIG_ARM64) += cache.o ifeq ($(CONFIG_SPL_BUILD),y) obj-$(CONFIG_SOC_K3_AM654) += am654_init.o @@ -18,4 +17,4 @@ obj-$(CONFIG_SOC_K3_AM642) += am642_init.o obj-$(CONFIG_SOC_K3_AM625) += am625_init.o obj-$(CONFIG_K3_LOAD_SYSFW) += sysfw-loader.o endif -obj-y += common.o +obj-y += common.o security.o diff --git a/arch/arm/mach-k3/common.c b/arch/arm/mach-k3/common.c index ac14975694..3962f2800f 100644 --- a/arch/arm/mach-k3/common.c +++ b/arch/arm/mach-k3/common.c @@ -290,9 +290,7 @@ void board_fit_image_post_process(const void *fit, int node, void **p_image, } #endif -#if IS_ENABLED(CONFIG_TI_SECURE_DEVICE) ti_secure_image_post_process(p_image, p_size); -#endif } #endif diff --git a/arch/arm/mach-k3/security.c b/arch/arm/mach-k3/security.c index 5bfcecd44d..add7f413a4 100644 --- a/arch/arm/mach-k3/security.c +++ b/arch/arm/mach-k3/security.c @@ -41,6 +41,9 @@ void ti_secure_image_post_process(void **p_image, size_t *p_size) image_addr = (uintptr_t)*p_image; image_size = *p_size; + if (!image_size || get_device_type() == K3_DEVICE_TYPE_GP) + return; + if (get_device_type() != K3_DEVICE_TYPE_HS_SE && !ti_secure_cert_detected(*p_image)) { printf("Warning: Did not detect image signing certificate. " From b661c1bc92f9ac096ffaf0aec7e60a5413ce8b34 Mon Sep 17 00:00:00 2001 From: Andrew Davis Date: Fri, 15 Jul 2022 11:34:35 -0500 Subject: [PATCH 15/18] arm: mach-k3: security: Remove certificate if detected on GP device If the device is a GP and we detect a signing certificate then remove it. It would fail to authenticate otherwise as the device is GP and has no secure authentication services in SYSFW. This shouldn't happen often as trying to boot signed images on GP devices doesn't make much sense, but if we run into a signed image we should at least try to ignore the certificate and boot the image anyway. This could help with users of GP devices who only have HS images available. If this does happen, print a nice big warning. Signed-off-by: Andrew Davis Reviewed-by: Tom Rini --- arch/arm/mach-k3/security.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-k3/security.c b/arch/arm/mach-k3/security.c index add7f413a4..d8d41ec515 100644 --- a/arch/arm/mach-k3/security.c +++ b/arch/arm/mach-k3/security.c @@ -30,10 +30,19 @@ static bool ti_secure_cert_detected(void *p_image) ((u8 *)p_image)[4] == 0x30 && ((u8 *)p_image)[5] == 0x82); } +/* Primitive certificate length, assumes one 2-Octet sized SEQUENCE */ +static size_t ti_secure_cert_length(void *p_image) +{ + size_t seq_length = be16_to_cpu(readw_relaxed(p_image + 2)); + /* Add 4 for the SEQUENCE tag length */ + return seq_length + 4; +} + void ti_secure_image_post_process(void **p_image, size_t *p_size) { struct ti_sci_handle *ti_sci = get_ti_sci_handle(); struct ti_sci_proc_ops *proc_ops = &ti_sci->ops.proc_ops; + size_t cert_length; u64 image_addr; u32 image_size; int ret; @@ -41,9 +50,28 @@ void ti_secure_image_post_process(void **p_image, size_t *p_size) image_addr = (uintptr_t)*p_image; image_size = *p_size; - if (!image_size || get_device_type() == K3_DEVICE_TYPE_GP) + if (!image_size) return; + if (get_device_type() == K3_DEVICE_TYPE_GP) { + if (ti_secure_cert_detected(*p_image)) { + printf("Warning: Detected image signing certificate on GP device. " + "Skipping certificate to prevent boot failure. " + "This will fail if the image was also encrypted\n"); + + cert_length = ti_secure_cert_length(*p_image); + if (cert_length > *p_size) { + printf("Invalid signing certificate size\n"); + return; + } + + *p_image += cert_length; + *p_size -= cert_length; + } + + return; + } + if (get_device_type() != K3_DEVICE_TYPE_HS_SE && !ti_secure_cert_detected(*p_image)) { printf("Warning: Did not detect image signing certificate. " From 31a7688cbe0ed5edf4108a1f7ef4653659610d4b Mon Sep 17 00:00:00 2001 From: Heiko Thiery Date: Wed, 20 Jul 2022 12:31:33 +0200 Subject: [PATCH 16/18] tools: mkeficapsule: use pkg-config to get -luuid and -lgnutls Instead of hardcoding -luuid -lgnutls as the flags needed to build mkeficapsule, use pkg-config when available. We gracefully fallback on the previous behavior of hardcoding -luuid -lgnutls if pkg-config is not available or fails with an error. Reviewed-by: Heinrich Schuchardt Signed-off-by: Heiko Thiery --- tools/Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/Makefile b/tools/Makefile index 9f2339666a..aab06aec93 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -242,7 +242,10 @@ hostprogs-$(CONFIG_MIPS) += mips-relocs hostprogs-$(CONFIG_ASN1_COMPILER) += asn1_compiler HOSTCFLAGS_asn1_compiler.o = -idirafter $(srctree)/include -HOSTLDLIBS_mkeficapsule += -lgnutls -luuid +HOSTCFLAGS_mkeficapsule.o += \ + $(shell pkg-config --cflags gnutls uuid 2> /dev/null || echo "") +HOSTLDLIBS_mkeficapsule += \ + $(shell pkg-config --libs gnutls uuid 2> /dev/null || echo "-lgnutls -luuid") hostprogs-$(CONFIG_TOOLS_MKEFICAPSULE) += mkeficapsule # We build some files with extra pedantic flags to try to minimize things From 124b21e7bd3d0ad5258c7cf84540301bff27012a Mon Sep 17 00:00:00 2001 From: Heiko Thiery Date: Wed, 20 Jul 2022 12:31:35 +0200 Subject: [PATCH 17/18] tools: kwboot: use pkg-config to get -ltinfo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of hardcoding -ltinfo as the flags needed to build kwboot, use pkg-config when available. We gracefully fallback on the previous behavior of hardcoding -ltinfo if pkg-config is not available or fails with an error. Reviewed-by: Pali Rohár Signed-off-by: Heiko Thiery --- tools/Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/Makefile b/tools/Makefile index aab06aec93..005e7362a3 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -198,7 +198,9 @@ hostprogs-$(CONFIG_EXYNOS5420) += mkexynosspl HOSTCFLAGS_mkexynosspl.o := -pedantic HOSTCFLAGS_kwboot.o += -pthread -HOSTLDLIBS_kwboot += -pthread -ltinfo +HOSTLDLIBS_kwboot += -pthread +HOSTLDLIBS_kwboot += \ + $(shell pkg-config --libs tinfo 2> /dev/null || echo "-ltinfo") ifdtool-objs := $(LIBFDT_OBJS) ifdtool.o hostprogs-$(CONFIG_X86) += ifdtool From 2ecc354b8e461c7ecf0189601a8ed7b304596224 Mon Sep 17 00:00:00 2001 From: Michal Vasilek Date: Fri, 22 Jul 2022 19:55:53 +0200 Subject: [PATCH 18/18] tools: mkimage: fix build with LibreSSL RSA_get0_* functions are not available in LibreSSL Signed-off-by: Michal Vasilek Reviewed-by: Simon Glass --- tools/sunxi_toc0.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/sunxi_toc0.c b/tools/sunxi_toc0.c index bab5d17b7d..56200bd927 100644 --- a/tools/sunxi_toc0.c +++ b/tools/sunxi_toc0.c @@ -34,6 +34,12 @@ #define pr_warn(fmt, args...) fprintf(stderr, pr_fmt(fmt), "warning", ##args) #define pr_info(fmt, args...) fprintf(stderr, pr_fmt(fmt), "info", ##args) +#if defined(LIBRESSL_VERSION_NUMBER) +#define RSA_get0_n(key) (key)->n +#define RSA_get0_e(key) (key)->e +#define RSA_get0_d(key) (key)->d +#endif + struct __packed toc0_key_item { __le32 vendor_id; __le32 key0_n_len;