summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Kconfig2
-rw-r--r--MAINTAINERS2
-rw-r--r--arch/arm/Kconfig7
-rw-r--r--arch/arm/cpu/armv7/Makefile1
-rw-r--r--arch/arm/cpu/armv7/exception_level.c56
-rw-r--r--arch/arm/cpu/armv7/smccc-call.S2
-rw-r--r--arch/arm/cpu/armv8/Makefile1
-rw-r--r--arch/arm/cpu/armv8/exception_level.c55
-rw-r--r--arch/arm/cpu/armv8/smccc-call.S2
-rw-r--r--arch/arm/dts/armada-8040-clearfog-gt-8k.dts8
-rw-r--r--arch/arm/dts/armada-8040-mcbin.dts2
-rw-r--r--arch/arm/dts/bcm63158.dtsi102
-rw-r--r--arch/arm/dts/bcm6858.dtsi17
-rw-r--r--arch/arm/dts/bcm963158.dts31
-rw-r--r--arch/arm/dts/exynos5250-spring.dts77
-rw-r--r--arch/arm/dts/stm32mp157c-ed1-u-boot.dtsi27
-rw-r--r--arch/arm/lib/Makefile6
-rw-r--r--arch/arm/mach-exynos/Kconfig7
-rw-r--r--arch/arm/mach-exynos/include/mach/mmc.h2
-rw-r--r--arch/arm/mach-k3/common.c28
-rw-r--r--arch/arm/mach-s5pc1xx/Kconfig2
-rw-r--r--arch/arm/mach-s5pc1xx/Makefile1
-rw-r--r--arch/arm/mach-s5pc1xx/pinmux.c20
-rw-r--r--arch/mips/dts/brcm,bcm6838.dtsi17
-rw-r--r--arch/x86/cpu/i386/call64.S4
-rw-r--r--arch/x86/cpu/i386/cpu.c31
-rw-r--r--arch/x86/include/asm/arch-tangier/acpi/southcluster.asl87
-rw-r--r--arch/x86/include/asm/string.h31
-rw-r--r--arch/x86/lib/Makefile2
-rw-r--r--board/BuR/brppt1/board.c5
-rw-r--r--board/BuR/brxre1/board.c2
-rw-r--r--board/BuR/common/bur_common.h2
-rw-r--r--board/BuR/common/common.c7
-rw-r--r--board/alliedtelesis/x530/x530.c2
-rw-r--r--board/broadcom/bcm963158/Kconfig17
-rw-r--r--board/broadcom/bcm963158/MAINTAINERS6
-rw-r--r--board/broadcom/bcm963158/Makefile3
-rw-r--r--board/broadcom/bcm963158/bcm963158.c61
-rw-r--r--board/broadcom/bcm968580xref/MAINTAINERS4
-rw-r--r--board/samsung/common/board.c52
-rw-r--r--board/samsung/common/exynos5-dt.c29
-rw-r--r--cmd/Kconfig2
-rw-r--r--cmd/bootefi.c152
-rw-r--r--cmd/sata.c4
-rw-r--r--common/Kconfig8
-rw-r--r--common/board_r.c5
-rw-r--r--common/bootm.c10
-rw-r--r--common/image-fdt.c21
-rw-r--r--configs/A20-OLinuXino-Lime2-eMMC_defconfig1
-rw-r--r--configs/am57xx_hs_evm_defconfig1
-rw-r--r--configs/am57xx_hs_evm_usb_defconfig98
-rw-r--r--configs/am65x_evm_r5_defconfig1
-rw-r--r--configs/axs101_defconfig1
-rw-r--r--configs/axs103_defconfig1
-rw-r--r--configs/bcm963158_ram_defconfig42
-rw-r--r--configs/bcm968380gerg_ram_defconfig2
-rw-r--r--configs/bcm968580xref_ram_defconfig (renamed from configs/bcm968580_ram_defconfig)3
-rw-r--r--configs/brppt1_mmc_defconfig1
-rw-r--r--configs/brppt1_nand_defconfig1
-rw-r--r--configs/brppt1_spi_defconfig1
-rw-r--r--configs/chromebook_link64_defconfig1
-rw-r--r--configs/dra7xx_hs_evm_defconfig8
-rw-r--r--configs/dra7xx_hs_evm_usb_defconfig113
-rw-r--r--configs/edison_defconfig2
-rw-r--r--configs/kp_imx6q_tpc_defconfig1
-rw-r--r--configs/odroid-xu3_defconfig1
-rw-r--r--configs/odroid_defconfig1
-rw-r--r--configs/orangepi_zero_plus_defconfig3
-rw-r--r--configs/qemu-x86_64_defconfig1
-rw-r--r--configs/spring_defconfig1
-rw-r--r--configs/stm32f429-discovery_defconfig1
-rw-r--r--configs/stm32f429-evaluation_defconfig1
-rw-r--r--configs/stm32f469-discovery_defconfig1
-rw-r--r--configs/stm32mp15_basic_defconfig1
-rw-r--r--configs/tbs_a711_defconfig2
-rw-r--r--doc/README.fdt-control7
-rw-r--r--doc/README.ti-secure8
-rw-r--r--doc/README.uefi10
-rw-r--r--doc/device-tree-bindings/clock/st,stm32mp1.txt10
-rw-r--r--doc/driver-model/of-plat.txt31
-rw-r--r--drivers/clk/clk_stm32mp1.c120
-rw-r--r--drivers/core/of_access.c18
-rw-r--r--drivers/core/read.c8
-rw-r--r--drivers/core/uclass.c2
-rw-r--r--drivers/i2c/i2c-uclass.c54
-rw-r--r--drivers/i2c/muxes/i2c-mux-uclass.c29
-rw-r--r--drivers/misc/misc-uclass.c3
-rw-r--r--drivers/mmc/mmc.c28
-rw-r--r--drivers/mmc/omap_hsmmc.c108
-rw-r--r--drivers/mmc/renesas-sdhi.c10
-rw-r--r--drivers/mmc/s5p_sdhci.c50
-rw-r--r--drivers/mmc/tmio-common.c11
-rw-r--r--drivers/mmc/tmio-common.h1
-rw-r--r--drivers/mmc/uniphier-sd.c1
-rw-r--r--drivers/pci/pcie_dw_mvebu.c4
-rw-r--r--drivers/power/regulator/regulator-uclass.c13
-rw-r--r--drivers/serial/serial_pl01x.c2
-rw-r--r--drivers/sound/Kconfig14
-rw-r--r--drivers/sound/Makefile1
-rw-r--r--drivers/sound/max98088.c424
-rw-r--r--drivers/sound/max98088.h192
-rw-r--r--drivers/sound/max98090.c7
-rw-r--r--drivers/sound/max98095.c7
-rw-r--r--drivers/sound/maxim_codec.c3
-rw-r--r--drivers/sound/samsung-i2s.c16
-rw-r--r--drivers/sound/samsung_sound.c6
-rw-r--r--drivers/timer/tsc_timer.c55
-rw-r--r--drivers/watchdog/Kconfig2
-rw-r--r--drivers/watchdog/bcm6345_wdt.c10
-rw-r--r--dts/Kconfig6
-rw-r--r--fs/fs.c2
-rw-r--r--include/bootm.h5
-rw-r--r--include/charset.h23
-rw-r--r--include/config_distro_bootcmd.h40
-rw-r--r--include/configs/am65x_evm.h2
-rw-r--r--include/configs/axs10x.h5
-rw-r--r--include/configs/broadcom_bcm963158.h37
-rw-r--r--include/configs/hsdk.h5
-rw-r--r--include/configs/odroid.h1
-rw-r--r--include/configs/odroid_xu3.h1
-rw-r--r--include/configs/omap3_cairo.h10
-rw-r--r--include/dm/of_access.h10
-rw-r--r--include/dm/read.h16
-rw-r--r--include/dt-bindings/clock/stm32mp1-clks.h3
-rw-r--r--include/efi.h2
-rw-r--r--include/efi_api.h445
-rw-r--r--include/efi_loader.h24
-rw-r--r--include/fdtdec.h20
-rw-r--r--include/i2s.h11
-rw-r--r--include/initcall.h35
-rw-r--r--include/power/regulator.h11
-rw-r--r--include/samsung/misc.h2
-rw-r--r--include/test/lib.h14
-rw-r--r--include/test/suites.h1
-rw-r--r--lib/Makefile1
-rw-r--r--lib/charset.c29
-rw-r--r--lib/efi_driver/efi_uclass.c3
-rw-r--r--lib/efi_loader/Kconfig16
-rw-r--r--lib/efi_loader/Makefile4
-rw-r--r--lib/efi_loader/efi_boottime.c34
-rw-r--r--lib/efi_loader/efi_file.c18
-rw-r--r--lib/efi_loader/efi_freestanding.c90
-rw-r--r--lib/efi_loader/efi_hii.c1095
-rw-r--r--lib/efi_loader/efi_hii_config.c146
-rw-r--r--lib/efi_loader/efi_memory.c6
-rw-r--r--lib/efi_loader/efi_runtime.c3
-rw-r--r--lib/efi_loader/efi_setup.c86
-rw-r--r--lib/efi_loader/efi_variable.c300
-rw-r--r--lib/efi_loader/helloworld.c36
-rw-r--r--lib/efi_selftest/Makefile11
-rw-r--r--lib/efi_selftest/efi_selftest_block_device.c6
-rw-r--r--lib/efi_selftest/efi_selftest_events.c6
-rw-r--r--lib/efi_selftest/efi_selftest_hii.c1035
-rw-r--r--lib/efi_selftest/efi_selftest_hii_data.c453
-rw-r--r--lib/efi_selftest/efi_selftest_snp.c8
-rw-r--r--lib/efi_selftest/efi_selftest_tpl.c4
-rw-r--r--lib/efi_selftest/efi_selftest_variables.c17
-rw-r--r--lib/fdtdec.c40
-rw-r--r--lib/hashtable.c13
-rw-r--r--lib/initcall.c39
-rw-r--r--lib/vsprintf.c10
-rw-r--r--scripts/Makefile.lib2
-rw-r--r--scripts/config_whitelist.txt1
-rw-r--r--test/Kconfig8
-rw-r--r--test/cmd_ut.c6
-rw-r--r--test/dm/core.c4
-rw-r--r--test/dm/regulator.c21
-rw-r--r--test/dm/test-fdt.c23
-rw-r--r--test/env/Makefile1
-rw-r--r--test/env/hashtable.c125
-rw-r--r--test/lib/Makefile2
-rw-r--r--test/lib/cmd_ut_lib.c20
-rw-r--r--test/lib/string.c194
-rw-r--r--test/py/tests/test_net.py9
-rw-r--r--test/unicode_ut.c23
-rw-r--r--tools/buildman/builderthread.py3
-rw-r--r--tools/buildman/control.py2
-rw-r--r--tools/k3_x509template.txt2
-rwxr-xr-xtools/moveconfig.py27
179 files changed, 6516 insertions, 775 deletions
diff --git a/Kconfig b/Kconfig
index 2a48f53256..512c7beb89 100644
--- a/Kconfig
+++ b/Kconfig
@@ -227,7 +227,7 @@ config BUILD_ROM
config BUILD_TARGET
string "Build target special images"
default "u-boot-with-spl.sfp" if ARCH_SOCFPGA
- default "u-boot-spl.kwb" if ARCH_MVEBU && SPL_BUILD
+ default "u-boot-spl.kwb" if ARCH_MVEBU && SPL
default "u-boot-elf.srec" if RCAR_GEN3
default "u-boot.itb" if SPL_LOAD_FIT && ARCH_SUNXI
default "u-boot.kwb" if KIRKWOOD
diff --git a/MAINTAINERS b/MAINTAINERS
index 69131e4ffa..29449ffed6 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -720,7 +720,9 @@ F: configs/am335x_hs_evm_defconfig
F: configs/am335x_hs_evm_uart_defconfig
F: configs/am43xx_hs_evm_defconfig
F: configs/am57xx_hs_evm_defconfig
+F: configs/am57xx_hs_evm_usb_defconfig
F: configs/dra7xx_hs_evm_defconfig
+F: configs/dra7xx_hs_evm_usb_defconfig
F: configs/k2hk_hs_evm_defconfig
F: configs/k2e_hs_evm_defconfig
F: configs/k2g_hs_evm_defconfig
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index f0edb10003..455f06cfee 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -528,6 +528,12 @@ config ARCH_BCM283X
imply CMD_DM
imply FAT_WRITE
+config ARCH_BCM63158
+ bool "Broadcom BCM63158 family"
+ select DM
+ select OF_CONTROL
+ imply CMD_DM
+
config ARCH_BCM6858
bool "Broadcom BCM6858 family"
select DM
@@ -1526,6 +1532,7 @@ source "board/armltd/vexpress/Kconfig"
source "board/armltd/vexpress64/Kconfig"
source "board/broadcom/bcm23550_w1d/Kconfig"
source "board/broadcom/bcm28155_ap/Kconfig"
+source "board/broadcom/bcm963158/Kconfig"
source "board/broadcom/bcm968580xref/Kconfig"
source "board/broadcom/bcmcygnus/Kconfig"
source "board/broadcom/bcmnsp/Kconfig"
diff --git a/arch/arm/cpu/armv7/Makefile b/arch/arm/cpu/armv7/Makefile
index 4f4647c90a..8c955d0d52 100644
--- a/arch/arm/cpu/armv7/Makefile
+++ b/arch/arm/cpu/armv7/Makefile
@@ -14,6 +14,7 @@ obj-$(CONFIG_SYS_ARM_MPU) += mpu_v7r.o
ifneq ($(CONFIG_SPL_BUILD),y)
obj-$(CONFIG_EFI_LOADER) += sctlr.o
+obj-$(CONFIG_ARMV7_NONSEC) += exception_level.o
endif
ifneq ($(CONFIG_SKIP_LOWLEVEL_INIT),y)
diff --git a/arch/arm/cpu/armv7/exception_level.c b/arch/arm/cpu/armv7/exception_level.c
new file mode 100644
index 0000000000..274f03d8bb
--- /dev/null
+++ b/arch/arm/cpu/armv7/exception_level.c
@@ -0,0 +1,56 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Switch to non-secure mode
+ *
+ * Copyright (c) 2018 Heinrich Schuchardt
+ *
+ * This module contains the ARMv7 specific code required for leaving the
+ * secure mode before booting an operating system.
+ */
+
+#include <common.h>
+#include <bootm.h>
+#include <asm/armv7.h>
+#include <asm/secure.h>
+#include <asm/setjmp.h>
+
+/**
+ * entry_non_secure() - entry point when switching to non-secure mode
+ *
+ * When switching to non-secure mode switch_to_non_secure_mode() calls this
+ * function passing a jump buffer. We use this jump buffer to restore the
+ * original stack and register state.
+ *
+ * @non_secure_jmp: jump buffer for restoring stack and registers
+ */
+static void entry_non_secure(struct jmp_buf_data *non_secure_jmp)
+{
+ dcache_enable();
+ debug("Reached non-secure mode\n");
+
+ /* Restore stack and registers saved in switch_to_non_secure_mode() */
+ longjmp(non_secure_jmp, 1);
+}
+
+/**
+ * switch_to_non_secure_mode() - switch to non-secure mode
+ *
+ * Operating systems may expect to run in non-secure mode. Here we check if
+ * we are running in secure mode and switch to non-secure mode if necessary.
+ */
+void switch_to_non_secure_mode(void)
+{
+ static bool is_nonsec;
+ struct jmp_buf_data non_secure_jmp;
+
+ if (armv7_boot_nonsec() && !is_nonsec) {
+ if (setjmp(&non_secure_jmp))
+ return;
+ dcache_disable(); /* flush cache before switch to HYP */
+ armv7_init_nonsec();
+ is_nonsec = true;
+ secure_ram_addr(_do_nonsec_entry)(entry_non_secure,
+ (uintptr_t)&non_secure_jmp,
+ 0, 0);
+ }
+}
diff --git a/arch/arm/cpu/armv7/smccc-call.S b/arch/arm/cpu/armv7/smccc-call.S
index eae69e36c3..f70728f2c4 100644
--- a/arch/arm/cpu/armv7/smccc-call.S
+++ b/arch/arm/cpu/armv7/smccc-call.S
@@ -7,7 +7,9 @@
#include <asm/opcodes-sec.h>
#include <asm/opcodes-virt.h>
+#ifdef CONFIG_EFI_LOADER
.section .text.efi_runtime
+#endif
#define UNWIND(x...)
/*
diff --git a/arch/arm/cpu/armv8/Makefile b/arch/arm/cpu/armv8/Makefile
index 4c4b13c9e7..a5f54330e3 100644
--- a/arch/arm/cpu/armv8/Makefile
+++ b/arch/arm/cpu/armv8/Makefile
@@ -14,6 +14,7 @@ ifdef CONFIG_SPL_BUILD
obj-$(CONFIG_ARMV8_SPL_EXCEPTION_VECTORS) += exceptions.o
else
obj-y += exceptions.o
+obj-y += exception_level.o
endif
obj-y += cache.o
obj-y += tlb.o
diff --git a/arch/arm/cpu/armv8/exception_level.c b/arch/arm/cpu/armv8/exception_level.c
new file mode 100644
index 0000000000..57824eb2ac
--- /dev/null
+++ b/arch/arm/cpu/armv8/exception_level.c
@@ -0,0 +1,55 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Switch to non-secure mode
+ *
+ * Copyright (c) 2018 Heinrich Schuchardt
+ *
+ * This module contains the ARMv8 specific code required to adjust the exception
+ * level before booting an operating system.
+ */
+
+#include <common.h>
+#include <bootm.h>
+#include <asm/setjmp.h>
+
+/**
+ * entry_non_secure() - entry point when switching to non-secure mode
+ *
+ * When switching to non-secure mode switch_to_non_secure_mode() calls this
+ * function passing a jump buffer. We use this jump buffer to restore the
+ * original stack and register state.
+ *
+ * @non_secure_jmp: jump buffer for restoring stack and registers
+ */
+static void entry_non_secure(struct jmp_buf_data *non_secure_jmp)
+{
+ dcache_enable();
+ debug("Reached non-secure mode\n");
+
+ /* Restore stack and registers saved in switch_to_non_secure_mode() */
+ longjmp(non_secure_jmp, 1);
+}
+
+/**
+ * switch_to_non_secure_mode() - switch to non-secure mode
+ *
+ * Exception level EL3 is meant to be used by the secure monitor only (ARM
+ * trusted firmware being one embodiment). The operating system shall be
+ * started at exception level EL2. So here we check the exception level
+ * and switch it if necessary.
+ */
+void switch_to_non_secure_mode(void)
+{
+ struct jmp_buf_data non_secure_jmp;
+
+ /* On AArch64 we need to make sure we call our payload in < EL3 */
+ if (current_el() == 3) {
+ if (setjmp(&non_secure_jmp))
+ return;
+ dcache_disable(); /* flush cache before switch to EL2 */
+
+ /* Move into EL2 and keep running there */
+ armv8_switch_to_el2((uintptr_t)&non_secure_jmp, 0, 0, 0,
+ (uintptr_t)entry_non_secure, ES_TO_AARCH64);
+ }
+}
diff --git a/arch/arm/cpu/armv8/smccc-call.S b/arch/arm/cpu/armv8/smccc-call.S
index 86de4b4089..dc92b28777 100644
--- a/arch/arm/cpu/armv8/smccc-call.S
+++ b/arch/arm/cpu/armv8/smccc-call.S
@@ -6,7 +6,9 @@
#include <linux/arm-smccc.h>
#include <generated/asm-offsets.h>
+#ifdef CONFIG_EFI_LOADER
.section .text.efi_runtime
+#endif
.macro SMCCC instr
.cfi_startproc
diff --git a/arch/arm/dts/armada-8040-clearfog-gt-8k.dts b/arch/arm/dts/armada-8040-clearfog-gt-8k.dts
index 498105f25f..cdff44aca5 100644
--- a/arch/arm/dts/armada-8040-clearfog-gt-8k.dts
+++ b/arch/arm/dts/armada-8040-clearfog-gt-8k.dts
@@ -99,6 +99,11 @@
0 0 0 0 0 0 0xe 0xe 0xe 0xe
0xe 0xe 0 >;
+ cpm_pcie_reset_pins: cpm-pcie-reset-pins {
+ marvell,pins = < 32 >;
+ marvell,function = <0>;
+ };
+
cpm_xhci_vbus_pins: cpm-xhci-vbus-pins {
marvell,pins = < 47 >;
marvell,function = <0>;
@@ -120,6 +125,9 @@
&cpm_pcie0 {
num-lanes = <1>;
+ pinctrl-names = "default";
+ pinctrl-0 = <&cpm_pcie_reset_pins>;
+ marvell,reset-gpio = <&cpm_gpio1 0 GPIO_ACTIVE_LOW>;
status = "okay";
};
diff --git a/arch/arm/dts/armada-8040-mcbin.dts b/arch/arm/dts/armada-8040-mcbin.dts
index 7e8e2f707c..5a046d9de4 100644
--- a/arch/arm/dts/armada-8040-mcbin.dts
+++ b/arch/arm/dts/armada-8040-mcbin.dts
@@ -132,7 +132,7 @@
num-lanes = <4>;
pinctrl-names = "default";
pinctrl-0 = <&cpm_pcie_reset_pins>;
- marvell,reset-gpio = <&cpm_gpio1 20 GPIO_ACTIVE_HIGH>; /* GPIO[52] */
+ marvell,reset-gpio = <&cpm_gpio1 20 GPIO_ACTIVE_LOW>; /* GPIO[52] */
status = "okay";
};
diff --git a/arch/arm/dts/bcm63158.dtsi b/arch/arm/dts/bcm63158.dtsi
new file mode 100644
index 0000000000..6a3fbc9093
--- /dev/null
+++ b/arch/arm/dts/bcm63158.dtsi
@@ -0,0 +1,102 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2019 Philippe Reynes <philippe.reynes@softathome.com>
+ */
+
+#include "skeleton64.dtsi"
+
+/ {
+ compatible = "brcm,bcm63158";
+ #address-cells = <2>;
+ #size-cells = <2>;
+
+ cpus {
+ #address-cells = <2>;
+ #size-cells = <0>;
+ u-boot,dm-pre-reloc;
+
+ cpu0: cpu@0 {
+ compatible = "arm,cortex-a53", "arm,armv8";
+ device_type = "cpu";
+ reg = <0x0 0x0>;
+ next-level-cache = <&l2>;
+ u-boot,dm-pre-reloc;
+ };
+
+ cpu1: cpu@1 {
+ compatible = "arm,cortex-a53", "arm,armv8";
+ device_type = "cpu";
+ reg = <0x0 0x1>;
+ next-level-cache = <&l2>;
+ u-boot,dm-pre-reloc;
+ };
+
+ cpu2: cpu@2 {
+ compatible = "arm,cortex-a53", "arm,armv8";
+ device_type = "cpu";
+ reg = <0x0 0x2>;
+ next-level-cache = <&l2>;
+ u-boot,dm-pre-reloc;
+ };
+
+ cpu3: cpu@3 {
+ compatible = "arm,cortex-a53", "arm,armv8";
+ device_type = "cpu";
+ reg = <0x0 0x3>;
+ next-level-cache = <&l2>;
+ u-boot,dm-pre-reloc;
+ };
+
+ l2: l2-cache0 {
+ compatible = "cache";
+ u-boot,dm-pre-reloc;
+ };
+ };
+
+ clocks {
+ compatible = "simple-bus";
+ #address-cells = <2>;
+ #size-cells = <2>;
+ ranges;
+ u-boot,dm-pre-reloc;
+
+ periph_osc: periph-osc {
+ compatible = "fixed-clock";
+ #clock-cells = <0>;
+ clock-frequency = <0xbebc200>;
+ u-boot,dm-pre-reloc;
+ };
+ };
+
+ ubus {
+ compatible = "simple-bus";
+ #address-cells = <2>;
+ #size-cells = <2>;
+ u-boot,dm-pre-reloc;
+
+ uart0: serial@ff812000 {
+ compatible = "arm,pl011", "arm,primecell";
+ reg = <0x0 0xff812000 0x0 0x1000>;
+ clock = <50000000>;
+
+ status = "disabled";
+ };
+
+ wdt1: watchdog@ff800480 {
+ compatible = "brcm,bcm6345-wdt";
+ reg = <0x0 0xff800480 0x0 0x14>;
+ clocks = <&periph_osc>;
+ };
+
+ wdt2: watchdog@ff8004c0 {
+ compatible = "brcm,bcm6345-wdt";
+ reg = <0x0 0xff8004c0 0x0 0x14>;
+ clocks = <&periph_osc>;
+ };
+
+ wdt-reboot {
+ compatible = "wdt-reboot";
+ wdt = <&wdt1>;
+ };
+ };
+};
diff --git a/arch/arm/dts/bcm6858.dtsi b/arch/arm/dts/bcm6858.dtsi
index d78d34d213..23b80c67a6 100644
--- a/arch/arm/dts/bcm6858.dtsi
+++ b/arch/arm/dts/bcm6858.dtsi
@@ -81,5 +81,22 @@
status = "disabled";
};
+
+ wdt1: watchdog@ff802780 {
+ compatible = "brcm,bcm6345-wdt";
+ reg = <0x0 0xff802780 0x0 0x14>;
+ clocks = <&periph_osc>;
+ };
+
+ wdt2: watchdog@ff8027c0 {
+ compatible = "brcm,bcm6345-wdt";
+ reg = <0x0 0xff8027c0 0x0 0x14>;
+ clocks = <&periph_osc>;
+ };
+
+ wdt-reboot {
+ compatible = "wdt-reboot";
+ wdt = <&wdt1>;
+ };
};
};
diff --git a/arch/arm/dts/bcm963158.dts b/arch/arm/dts/bcm963158.dts
new file mode 100644
index 0000000000..dc5afb5a24
--- /dev/null
+++ b/arch/arm/dts/bcm963158.dts
@@ -0,0 +1,31 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2019 Philippe Reynes <philippe.reynes@softathome.com>
+ */
+
+/dts-v1/;
+
+#include "bcm63158.dtsi"
+
+/ {
+ model = "Broadcom bcm963158";
+ compatible = "broadcom,bcm963158", "brcm,bcm63158";
+
+ aliases {
+ serial0 = &uart0;
+ };
+
+ chosen {
+ stdout-path = "serial0:115200n8";
+ };
+
+ memory {
+ device_type = "memory";
+ reg = <0x0 0x0 0x0 0x40000000>;
+ };
+};
+
+&uart0 {
+ u-boot,dm-pre-reloc;
+ status = "okay";
+};
diff --git a/arch/arm/dts/exynos5250-spring.dts b/arch/arm/dts/exynos5250-spring.dts
index 191e12af6a..c7553208ad 100644
--- a/arch/arm/dts/exynos5250-spring.dts
+++ b/arch/arm/dts/exynos5250-spring.dts
@@ -40,9 +40,46 @@
reg = <0x40000000 0x80000000>;
};
+ iram {
+ reg = <0x02020000 0x60000>;
+ };
+
+ config {
+ samsung,bl1-offset = <0x1400>;
+ samsung,bl2-offset = <0x3400>;
+ u-boot-memory = "/memory";
+ u-boot-offset = <0x3e00000 0x100000>;
+ };
+
flash@0 {
- spl { /* spl size override */
- size = <0x8000>;
+ reg = <0 0x100000>;
+ #address-cells = <1>;
+ #size-cells = <1>;
+ pre-boot {
+ label = "bl1 pre-boot";
+ reg = <0 0x2000>;
+ read-only;
+ filename = "e5250.nbl1.bin";
+ type = "blob exynos-bl1";
+ required;
+ };
+
+ spl {
+ label = "bl2 spl";
+ reg = <0x2000 0x8000>;
+ read-only;
+ filename = "bl2.bin";
+ type = "blob exynos-bl2 boot,dtb";
+ payload = "/flash/ro-boot";
+ required;
+ };
+
+ ro-boot {
+ label = "u-boot";
+ reg = <0xa000 0xb0000>;
+ read-only;
+ type = "blob boot,dtb";
+ required;
};
};
@@ -93,6 +130,22 @@
samsung,vbus-gpio = <&gpx2 7 GPIO_ACTIVE_HIGH>;
};
+ sound {
+ compatible = "google,spring-audio-max98088";
+
+ samsung,model = "Spring-I2S-MAX98088";
+ samsung,audio-codec = <&max98088>;
+ codec-enable-gpio = <&gpx1 7 0>;
+
+ cpu {
+ sound-dai = <&i2s1 0>;
+ };
+
+ codec {
+ sound-dai = <&max98088 0>;
+ };
+ };
+
spi@12d30000 {
spi-max-frequency = <50000000>;
firmware_storage_spi: flash@0 {
@@ -638,27 +691,11 @@
};
};
- max98095: soundcodec@10 {
+ max98088: soundcodec@10 {
reg = <0x10>;
- compatible = "maxim,max98095";
+ compatible = "maxim,max98088";
#sound-dai-cells = <1>;
};
-
- sound {
- compatible = "google,spring-audio-max98095";
-
- samsung,model = "Spring-I2S-MAX98095";
- samsung,audio-codec = <&max98095>;
-
- cpu {
- sound-dai = <&i2s0 0>;
- };
-
- codec {
- sound-dai = <&max98095 0>;
- };
- };
-
};
#include "cros-ec-keyboard.dtsi"
diff --git a/arch/arm/dts/stm32mp157c-ed1-u-boot.dtsi b/arch/arm/dts/stm32mp157c-ed1-u-boot.dtsi
index 4898483e1d..70bbf66704 100644
--- a/arch/arm/dts/stm32mp157c-ed1-u-boot.dtsi
+++ b/arch/arm/dts/stm32mp157c-ed1-u-boot.dtsi
@@ -39,6 +39,10 @@
};
};
+&clk_hse {
+ st,digbypass;
+};
+
&uart4_pins_a {
u-boot,dm-pre-reloc;
pins1 {
@@ -68,7 +72,6 @@
u-boot,dm-pre-reloc;
};
-/* CLOCK init */
&rcc {
st,clksrc = <
CLK_MPU_PLL1P
@@ -101,7 +104,7 @@
CLK_FMC_ACLK
CLK_QSPI_ACLK
CLK_ETH_DISABLED
- CLK_SDMMC12_PLL3R
+ CLK_SDMMC12_PLL4P
CLK_DSI_DSIPLL
CLK_STGEN_HSE
CLK_USBPHY_HSE
@@ -110,7 +113,7 @@
CLK_SPI45_HSI
CLK_SPI6_HSI
CLK_I2C46_HSI
- CLK_SDMMC3_PLL3R
+ CLK_SDMMC3_PLL4P
CLK_USBO_USBPHY
CLK_ADC_CKPER
CLK_CEC_LSE
@@ -121,17 +124,17 @@
CLK_UART35_HSI
CLK_UART6_HSI
CLK_UART78_HSI
- CLK_SPDIF_PLL3Q
+ CLK_SPDIF_PLL4P
CLK_FDCAN_PLL4Q
CLK_SAI1_PLL3Q
CLK_SAI2_PLL3Q
CLK_SAI3_PLL3Q
CLK_SAI4_PLL3Q
- CLK_RNG1_CSI
- CLK_RNG2_CSI
+ CLK_RNG1_LSI
+ CLK_RNG2_LSI
CLK_LPTIM1_PCLK1
CLK_LPTIM23_PCLK3
- CLK_LPTIM45_PCLK3
+ CLK_LPTIM45_LSE
>;
/* VCO = 1300.0 MHz => P = 650 (CPU) */
@@ -148,16 +151,16 @@
u-boot,dm-pre-reloc;
};
- /* VCO = 786.4 MHz => P = 197, Q = 49, R = 98 */
+ /* VCO = 417.8 MHz => P = 209, Q = 24, R = 11 */
pll3: st,pll@2 {
- cfg = < 2 97 3 15 7 PQR(1,1,1) >;
- frac = < 0x9ba >;
+ cfg = < 1 33 1 16 36 PQR(1,1,1) >;
+ frac = < 0x1a04 >;
u-boot,dm-pre-reloc;
};
- /* VCO = 508.0 MHz => P = 56, Q = 56, R = 56 */
+ /* VCO = 594.0 MHz => P = 99, Q = 74, R = 74 */
pll4: st,pll@3 {
- cfg = < 5 126 8 8 8 PQR(1,1,1) >;
+ cfg = < 3 98 5 7 7 PQR(1,1,1) >;
u-boot,dm-pre-reloc;
};
};
diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile
index 655727f431..48ee6c3c60 100644
--- a/arch/arm/lib/Makefile
+++ b/arch/arm/lib/Makefile
@@ -106,5 +106,9 @@ CFLAGS_$(EFI_RELOC) := $(CFLAGS_EFI)
CFLAGS_REMOVE_$(EFI_RELOC) := $(CFLAGS_NON_EFI)
extra-$(CONFIG_CMD_BOOTEFI_HELLO_COMPILE) += $(EFI_CRT0) $(EFI_RELOC)
-extra-$(CONFIG_CMD_BOOTEFI_SELFTEST) += $(EFI_CRT0) $(EFI_RELOC)
+# TODO: As of v2019.01 the relocation code for the EFI application cannot
+# be built on ARMv7-M.
+ifndef CONFIG_CPU_V7M
+#extra-$(CONFIG_CMD_BOOTEFI_SELFTEST) += $(EFI_CRT0) $(EFI_RELOC)
+endif
extra-$(CONFIG_EFI) += $(EFI_CRT0) $(EFI_RELOC)
diff --git a/arch/arm/mach-exynos/Kconfig b/arch/arm/mach-exynos/Kconfig
index ed04369cfa..3807770362 100644
--- a/arch/arm/mach-exynos/Kconfig
+++ b/arch/arm/mach-exynos/Kconfig
@@ -8,6 +8,8 @@ config ARCH_EXYNOS4
bool "Exynos4 SoC family"
select BOARD_EARLY_INIT_F
select CPU_V7A
+ select BLK
+ select DM_MMC
help
Samsung Exynos4 SoC family are based on ARM Cortex-A9 CPU. There
are multiple SoCs in this family including Exynos4210, Exynos4412,
@@ -24,6 +26,9 @@ config ARCH_EXYNOS5
imply USB_ETHER_ASIX
imply USB_ETHER_RTL8152
imply USB_ETHER_SMSC95XX
+ select BLK
+ select DM_MMC
+
help
Samsung Exynos5 SoC family are based on ARM Cortex-A15 CPU (and
Cortex-A7 CPU in big.LITTLE configuration). There are multiple SoCs
@@ -33,6 +38,8 @@ config ARCH_EXYNOS7
bool "Exynos7 SoC family"
select ARM64
select BOARD_EARLY_INIT_F
+ select BLK
+ select DM_MMC
help
Samsung Exynos7 SoC family are based on ARM Cortex-A57 CPU or
Cortex-A53 CPU (and some in a big.LITTLE configuration). There are
diff --git a/arch/arm/mach-exynos/include/mach/mmc.h b/arch/arm/mach-exynos/include/mach/mmc.h
index ca4e7eda34..eece44ea1a 100644
--- a/arch/arm/mach-exynos/include/mach/mmc.h
+++ b/arch/arm/mach-exynos/include/mach/mmc.h
@@ -64,6 +64,4 @@ static inline int s5p_mmc_init(int index, int bus_width)
return s5p_sdhci_init(base, index, bus_width);
}
-int exynos_mmc_init(const void *blob);
-
#endif
diff --git a/arch/arm/mach-k3/common.c b/arch/arm/mach-k3/common.c
index cc89d4a296..5909bbfa8f 100644
--- a/arch/arm/mach-k3/common.c
+++ b/arch/arm/mach-k3/common.c
@@ -19,33 +19,25 @@ void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image)
/*
* It is assumed that remoteproc device 1 is the corresponding
- * cortex A core which runs ATF. Make sure DT reflects the same.
+ * Cortex-A core which runs ATF. Make sure DT reflects the same.
*/
ret = rproc_dev_init(1);
- if (ret) {
- printf("%s: ATF failed to Initialize on rproc: ret= %d\n",
- __func__, ret);
- hang();
- }
+ if (ret)
+ panic("%s: ATF failed to initialize on rproc (%d)\n", __func__,
+ ret);
ret = rproc_load(1, spl_image->entry_point, 0x200);
- if (ret) {
- printf("%s: ATF failed to load on rproc: ret= %d\n",
- __func__, ret);
- hang();
- }
+ if (ret)
+ panic("%s: ATF failed to load on rproc (%d)\n", __func__, ret);
- /* Add an extra newline to differentiate the ATF logs from SPL*/
+ /* Add an extra newline to differentiate the ATF logs from SPL */
printf("Starting ATF on ARM64 core...\n\n");
ret = rproc_start(1);
- if (ret) {
- printf("%s: ATF failed to start on rproc: ret= %d\n",
- __func__, ret);
- hang();
- }
+ if (ret)
+ panic("%s: ATF failed to start on rproc (%d)\n", __func__, ret);
- debug("ATF started. Wait indefiniely\n");
+ debug("ATF started. Waiting indefinitely...\n");
while (1)
asm volatile("wfe");
}
diff --git a/arch/arm/mach-s5pc1xx/Kconfig b/arch/arm/mach-s5pc1xx/Kconfig
index 04acdaad79..8cffced551 100644
--- a/arch/arm/mach-s5pc1xx/Kconfig
+++ b/arch/arm/mach-s5pc1xx/Kconfig
@@ -7,6 +7,8 @@ choice
config TARGET_S5P_GONI
bool "S5P Goni board"
select OF_CONTROL
+ select BLK
+ select DM_MMC
config TARGET_SMDKC100
bool "Support smdkc100 board"
diff --git a/arch/arm/mach-s5pc1xx/Makefile b/arch/arm/mach-s5pc1xx/Makefile
index a4be3fcbda..ab804604d5 100644
--- a/arch/arm/mach-s5pc1xx/Makefile
+++ b/arch/arm/mach-s5pc1xx/Makefile
@@ -10,3 +10,4 @@ obj-y = cache.o
obj-y += reset.o
obj-y += clock.o
+obj-y += pinmux.o
diff --git a/arch/arm/mach-s5pc1xx/pinmux.c b/arch/arm/mach-s5pc1xx/pinmux.c
new file mode 100644
index 0000000000..818d75164d
--- /dev/null
+++ b/arch/arm/mach-s5pc1xx/pinmux.c
@@ -0,0 +1,20 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Dummy functions to keep s5p_goni building (although it won't work)
+ *
+ * Copyright 2018 Google LLC
+ * Written by Simon Glass <sjg@chromium.org>
+ */
+
+#include <common.h>
+#include <asm/arch/pinmux.h>
+
+int exynos_pinmux_config(int peripheral, int flags)
+{
+ return 0;
+}
+
+int pinmux_decode_periph_id(const void *blob, int node)
+{
+ return 0;
+}
diff --git a/arch/mips/dts/brcm,bcm6838.dtsi b/arch/mips/dts/brcm,bcm6838.dtsi
index 77d6a8e214..b6f9559147 100644
--- a/arch/mips/dts/brcm,bcm6838.dtsi
+++ b/arch/mips/dts/brcm,bcm6838.dtsi
@@ -73,6 +73,23 @@
status = "disabled";
};
+ wdt0: watchdog@14e002d0 {
+ compatible = "brcm,bcm6345-wdt";
+ reg = <0x14e002d0 0xc>;
+ clocks = <&periph_osc>;
+ };
+
+ wdt1: watchdog@14e002dc {
+ compatible = "brcm,bcm6345-wdt";
+ reg = <0x14e002dc 0xc>;
+ clocks = <&periph_osc>;
+ };
+
+ wdt-reboot {
+ compatible = "wdt-reboot";
+ wdt = <&wdt0>;
+ };
+
leds: led-controller@14e00f00 {
compatible = "brcm,bcm6328-leds";
reg = <0x14e00f00 0x28>;
diff --git a/arch/x86/cpu/i386/call64.S b/arch/x86/cpu/i386/call64.S
index 8f86728d42..275063c4af 100644
--- a/arch/x86/cpu/i386/call64.S
+++ b/arch/x86/cpu/i386/call64.S
@@ -79,6 +79,10 @@ lret_target:
mov %eax, %eax /* Clear bits 63:32 */
jmp *%eax /* Jump to the 64-bit target */
+.globl call64_stub_size
+call64_stub_size:
+ .long . - cpu_call64
+
.data
.align 16
.globl gdt64
diff --git a/arch/x86/cpu/i386/cpu.c b/arch/x86/cpu/i386/cpu.c
index 208ef08562..3bde44ebf5 100644
--- a/arch/x86/cpu/i386/cpu.c
+++ b/arch/x86/cpu/i386/cpu.c
@@ -462,6 +462,7 @@ int cpu_has_64bit(void)
has_long_mode();
}
+#define PAGETABLE_BASE 0x80000
#define PAGETABLE_SIZE (6 * 4096)
/**
@@ -522,33 +523,21 @@ int cpu_jump_to_64bit_uboot(ulong target)
typedef void (*func_t)(ulong pgtable, ulong setup_base, ulong target);
uint32_t *pgtable;
func_t func;
+ char *ptr;
- /* TODO(sjg@chromium.org): Find a better place for this */
- pgtable = (uint32_t *)0x1000000;
- if (!pgtable)
- return -ENOMEM;
+ pgtable = (uint32_t *)PAGETABLE_BASE;
build_pagetable(pgtable);
- /* TODO(sjg@chromium.org): Find a better place for this */
- char *ptr = (char *)0x3000000;
- char *gdt = (char *)0x3100000;
-
- extern char gdt64[];
-
- memcpy(ptr, cpu_call64, 0x1000);
- memcpy(gdt, gdt64, 0x100);
+ extern long call64_stub_size;
+ ptr = malloc(call64_stub_size);
+ if (!ptr) {
+ printf("Failed to allocate the cpu_call64 stub\n");
+ return -ENOMEM;
+ }
+ memcpy(ptr, cpu_call64, call64_stub_size);
- /*
- * TODO(sjg@chromium.org): This manually inserts the pointers into
- * the code. Tidy this up to avoid this.
- */
func = (func_t)ptr;
- ulong ofs = (ulong)cpu_call64 - (ulong)ptr;
- *(ulong *)(ptr + 7) = (ulong)gdt;
- *(ulong *)(ptr + 0xc) = (ulong)gdt + 2;
- *(ulong *)(ptr + 0x13) = (ulong)gdt;
- *(ulong *)(ptr + 0x117 - 0xd4) -= ofs;
/*
* Copy U-Boot from ROM
diff --git a/arch/x86/include/asm/arch-tangier/acpi/southcluster.asl b/arch/x86/include/asm/arch-tangier/acpi/southcluster.asl
index e166e510cb..baad98b1c7 100644
--- a/arch/x86/include/asm/arch-tangier/acpi/southcluster.asl
+++ b/arch/x86/include/asm/arch-tangier/acpi/southcluster.asl
@@ -320,6 +320,93 @@ Device (PCI0)
})
}
}
+
+ Device (IPC1)
+ {
+ Name (_ADR, 0x00130000)
+
+ Method (_STA, 0, NotSerialized)
+ {
+ Return (STA_VISIBLE)
+ }
+
+ Device (PMIC)
+ {
+ Name (_ADR, Zero)
+ Name (_HID, "INTC100E")
+ Name (_CID, "INTC100E")
+ Name (_DDN, "Basin Cove PMIC")
+ Name (_DEP, Package ()
+ {
+ IPC1
+ })
+
+ Method (_STA, 0, NotSerialized)
+ {
+ Return (STA_VISIBLE)
+ }
+
+ Method (_CRS, 0, Serialized)
+ {
+ Name (RBUF, ResourceTemplate()
+ {
+ /*
+ * Shadow registers in SRAM for PMIC:
+ * SRAM PMIC register
+ * --------------------
+ * 0x00- Unknown
+ * 0x03 THRMIRQ (0x04)
+ * 0x04 BCUIRQ (0x05)
+ * 0x05 ADCIRQ (0x06)
+ * 0x06 CHGRIRQ0 (0x07)
+ * 0x07 CHGRIRQ1 (0x08)
+ * 0x08- Unknown
+ * 0x0a PBSTATUS (0x27)
+ * 0x0b- Unknown
+ */
+ Memory32Fixed(ReadWrite, 0xFFFFF610, 0x00000010)
+ Interrupt(ResourceConsumer, Level, ActiveHigh, Shared, ,, ) { 30 }
+ Interrupt(ResourceConsumer, Level, ActiveHigh, Shared, ,, ) { 23 }
+ Interrupt(ResourceConsumer, Level, ActiveHigh, Shared, ,, ) { 52 }
+ Interrupt(ResourceConsumer, Level, ActiveHigh, Shared, ,, ) { 51 }
+ Interrupt(ResourceConsumer, Level, ActiveHigh, Shared, ,, ) { 50 }
+ Interrupt(ResourceConsumer, Level, ActiveHigh, Shared, ,, ) { 27 }
+ Interrupt(ResourceConsumer, Level, ActiveHigh, Shared, ,, ) { 49 }
+ })
+ Return (RBUF)
+ }
+
+ OperationRegion (PMOP, 0x8D, Zero, 0x0100)
+ Field (PMOP, DWordAcc, NoLock, Preserve)
+ {
+ SEL1, 32,
+ SEL2, 32,
+ VCCL, 32,
+ VNNL, 32,
+ AONL, 32,
+ CNTC, 32,
+ CNTN, 32,
+ AONN, 32,
+ CNT1, 32,
+ CNT2, 32,
+ CNT3, 32,
+ FLEX, 32,
+ PRG1, 32,
+ PRG2, 32,
+ PRG3, 32,
+ VLDO, 32,
+ }
+
+ Name (AVBL, Zero)
+ Method (_REG, 2, NotSerialized)
+ {
+ If ((Arg0 == 0x8D))
+ {
+ AVBL = Arg1
+ }
+ }
+ }
+ }
}
Device (FLIS)
diff --git a/arch/x86/include/asm/string.h b/arch/x86/include/asm/string.h
index 38afd23684..c15b264a5c 100644
--- a/arch/x86/include/asm/string.h
+++ b/arch/x86/include/asm/string.h
@@ -9,22 +9,37 @@
extern char *strncpy(char *__dest, __const__ char *__src, __kernel_size_t __n);
#undef __HAVE_ARCH_STRRCHR
-extern char * strrchr(const char * s, int c);
+extern char *strrchr(const char *s, int c);
#undef __HAVE_ARCH_STRCHR
-extern char * strchr(const char * s, int c);
+extern char *strchr(const char *s, int c);
+
+#ifdef CONFIG_X86_64
+
+#undef __HAVE_ARCH_MEMCPY
+extern void *memcpy(void *, const void *, __kernel_size_t);
+
+#undef __HAVE_ARCH_MEMMOVE
+extern void *memmove(void *, const void *, __kernel_size_t);
+
+#undef __HAVE_ARCH_MEMSET
+extern void *memset(void *, int, __kernel_size_t);
+
+#else
#define __HAVE_ARCH_MEMCPY
-extern void * memcpy(void *, const void *, __kernel_size_t);
+extern void *memcpy(void *, const void *, __kernel_size_t);
#define __HAVE_ARCH_MEMMOVE
-extern void * memmove(void *, const void *, __kernel_size_t);
-
-#undef __HAVE_ARCH_MEMCHR
-extern void * memchr(const void *, int, __kernel_size_t);
+extern void *memmove(void *, const void *, __kernel_size_t);
#define __HAVE_ARCH_MEMSET
-extern void * memset(void *, int, __kernel_size_t);
+extern void *memset(void *, int, __kernel_size_t);
+
+#endif /* CONFIG_X86_64 */
+
+#undef __HAVE_ARCH_MEMCHR
+extern void *memchr(const void *, int, __kernel_size_t);
#undef __HAVE_ARCH_MEMZERO
extern void memzero(void *ptr, __kernel_size_t n);
diff --git a/arch/x86/lib/Makefile b/arch/x86/lib/Makefile
index 1e8efcc44f..56fd680033 100644
--- a/arch/x86/lib/Makefile
+++ b/arch/x86/lib/Makefile
@@ -7,6 +7,7 @@ ifndef CONFIG_X86_64
obj-y += bios.o
obj-y += bios_asm.o
obj-y += bios_interrupts.o
+obj-y += string.o
endif
ifndef CONFIG_SPL_BUILD
obj-$(CONFIG_CMD_BOOTM) += bootm.o
@@ -32,7 +33,6 @@ obj-$(CONFIG_X86_RAMTEST) += ramtest.o
obj-$(CONFIG_INTEL_MID) += scu.o
obj-y += sections.o
obj-y += sfi.o
-obj-y += string.o
obj-y += acpi.o
obj-$(CONFIG_HAVE_ACPI_RESUME) += acpi_s3.o
ifndef CONFIG_QEMU
diff --git a/board/BuR/brppt1/board.c b/board/BuR/brppt1/board.c
index d2e7c72242..b8ab19c0e7 100644
--- a/board/BuR/brppt1/board.c
+++ b/board/BuR/brppt1/board.c
@@ -106,9 +106,8 @@ void am33xx_spl_board_init(void)
/* setup I2C */
enable_i2c_pin_mux();
- i2c_set_bus_num(0);
- i2c_init(CONFIG_SYS_OMAP24_I2C_SPEED, CONFIG_SYS_OMAP24_I2C_SLAVE);
- pmicsetup(0);
+
+ pmicsetup(0, 0);
/* peripheral reset */
rc = gpio_request(64 + 29, "GPMC_WAIT1");
diff --git a/board/BuR/brxre1/board.c b/board/BuR/brxre1/board.c
index 41ed28b4bc..82c53d5bc2 100644
--- a/board/BuR/brxre1/board.c
+++ b/board/BuR/brxre1/board.c
@@ -132,7 +132,7 @@ void am33xx_spl_board_init(void)
puts("ERROR: i2c_set_bus_speed failed! (turn on PWR_nEN)\n");
}
- pmicsetup(0);
+ pmicsetup(0, 0);
}
const struct dpll_params *get_dpll_ddr_params(void)
diff --git a/board/BuR/common/bur_common.h b/board/BuR/common/bur_common.h
index 5f2d0d055f..f743194c34 100644
--- a/board/BuR/common/bur_common.h
+++ b/board/BuR/common/bur_common.h
@@ -15,7 +15,7 @@
int load_lcdtiming(struct am335x_lcdpanel *panel);
void br_summaryscreen(void);
-void pmicsetup(u32 mpupll);
+void pmicsetup(u32 mpupll, unsigned int bus);
void enable_uart0_pin_mux(void);
void enable_i2c_pin_mux(void);
void enable_board_pin_mux(void);
diff --git a/board/BuR/common/common.c b/board/BuR/common/common.c
index f3eae5cbc1..a1f7c44abf 100644
--- a/board/BuR/common/common.c
+++ b/board/BuR/common/common.c
@@ -269,13 +269,14 @@ int ft_board_setup(void *blob, bd_t *bd)
static struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE;
-void pmicsetup(u32 mpupll)
+void pmicsetup(u32 mpupll, unsigned int bus)
{
int mpu_vdd;
int usb_cur_lim;
- if (i2c_probe(TPS65217_CHIP_PM)) {
- puts("PMIC (0x24) not found! skip further initalization.\n");
+ if (power_tps65217_init(bus)) {
+ printf("WARN: cannot setup PMIC 0x24 @ bus #%d, not found!.\n",
+ bus);
return;
}
diff --git a/board/alliedtelesis/x530/x530.c b/board/alliedtelesis/x530/x530.c
index b34ae51345..d7d1942fe6 100644
--- a/board/alliedtelesis/x530/x530.c
+++ b/board/alliedtelesis/x530/x530.c
@@ -57,7 +57,7 @@ static struct mv_ddr_topology_map board_topology_map = {
SPEED_BIN_DDR_1866M, /* speed_bin */
MV_DDR_DEV_WIDTH_16BIT, /* sdram device width */
MV_DDR_DIE_CAP_4GBIT, /* die capacity */
- MV_DDR_FREQ_933, /* frequency */
+ MV_DDR_FREQ_SAR, /* frequency */
0, 0, /* cas_l cas_wl */
MV_DDR_TEMP_LOW, /* temperature */
MV_DDR_TIM_2T} }, /* timing */
diff --git a/board/broadcom/bcm963158/Kconfig b/board/broadcom/bcm963158/Kconfig
new file mode 100644
index 0000000000..41b6adbb80
--- /dev/null
+++ b/board/broadcom/bcm963158/Kconfig
@@ -0,0 +1,17 @@
+if ARCH_BCM63158
+
+config SYS_VENDOR
+ default "broadcom"
+
+config SYS_BOARD
+ default "bcm963158"
+
+config SYS_CONFIG_NAME
+ default "broadcom_bcm963158"
+
+endif
+
+config TARGET_BCM963158
+ bool "Support Broadcom bcm963158"
+ depends on ARCH_BCM63158
+ select ARM64
diff --git a/board/broadcom/bcm963158/MAINTAINERS b/board/broadcom/bcm963158/MAINTAINERS
new file mode 100644
index 0000000000..d28d971f9d
--- /dev/null
+++ b/board/broadcom/bcm963158/MAINTAINERS
@@ -0,0 +1,6 @@
+BROADCOM BCM963158
+M: Philippe Reynes <philippe.reynes@softathome.com>
+S: Maintained
+F: board/broadcom/bcm963158/
+F: include/configs/broadcom_bcm963158.h
+F: configs/bcm963158_ram_defconfig
diff --git a/board/broadcom/bcm963158/Makefile b/board/broadcom/bcm963158/Makefile
new file mode 100644
index 0000000000..0a902c9cf6
--- /dev/null
+++ b/board/broadcom/bcm963158/Makefile
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0+
+
+obj-y += bcm963158.o
diff --git a/board/broadcom/bcm963158/bcm963158.c b/board/broadcom/bcm963158/bcm963158.c
new file mode 100644
index 0000000000..db82cd570d
--- /dev/null
+++ b/board/broadcom/bcm963158/bcm963158.c
@@ -0,0 +1,61 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2019 Philippe Reynes <philippe.reynes@softathome.com>
+ */
+
+#include <common.h>
+#include <fdtdec.h>
+#include <linux/io.h>
+
+#ifdef CONFIG_ARM64
+#include <asm/armv8/mmu.h>
+
+static struct mm_region broadcom_bcm963158_mem_map[] = {
+ {
+ /* RAM */
+ .virt = 0x00000000UL,
+ .phys = 0x00000000UL,
+ .size = 8UL * SZ_1G,
+ .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
+ PTE_BLOCK_INNER_SHARE
+ }, {
+ /* SoC */
+ .virt = 0x80000000UL,
+ .phys = 0x80000000UL,
+ .size = 0xff80000000UL,
+ .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
+ PTE_BLOCK_NON_SHARE |
+ PTE_BLOCK_PXN | PTE_BLOCK_UXN
+ }, {
+ /* List terminator */
+ 0,
+ }
+};
+
+struct mm_region *mem_map = broadcom_bcm963158_mem_map;
+#endif
+
+int board_init(void)
+{
+ return 0;
+}
+
+int dram_init(void)
+{
+ if (fdtdec_setup_mem_size_base() != 0)
+ printf("fdtdec_setup_mem_size_base() has failed\n");
+
+ return 0;
+}
+
+int dram_init_banksize(void)
+{
+ fdtdec_setup_memory_banksize();
+
+ return 0;
+}
+
+int print_cpuinfo(void)
+{
+ return 0;
+}
diff --git a/board/broadcom/bcm968580xref/MAINTAINERS b/board/broadcom/bcm968580xref/MAINTAINERS
index 1ecdfbc0bb..5ee0c4dd4e 100644
--- a/board/broadcom/bcm968580xref/MAINTAINERS
+++ b/board/broadcom/bcm968580xref/MAINTAINERS
@@ -1,6 +1,6 @@
-BROADCOM BCM968580XREF
+BCM968580XREF BOARD
M: Philippe Reynes <philippe.reynes@softathome.com>
S: Maintained
F: board/broadcom/bcm968580xref/
F: include/configs/broadcom_bcm968580xref.h
-F: configs/bcm968580_ram_defconfig
+F: configs/bcm968580xref_ram_defconfig
diff --git a/board/samsung/common/board.c b/board/samsung/common/board.c
index 6fd26a3a91..96228a86a1 100644
--- a/board/samsung/common/board.c
+++ b/board/samsung/common/board.c
@@ -249,56 +249,16 @@ int board_eth_init(bd_t *bis)
return 0;
}
-#ifdef CONFIG_MMC
-static int init_mmc(void)
-{
-#ifdef CONFIG_MMC_SDHCI
- return exynos_mmc_init(gd->fdt_blob);
-#else
- return 0;
-#endif
-}
-
-static int init_dwmmc(void)
-{
-#ifdef CONFIG_MMC_DW
- return exynos_dwmmc_init(gd->fdt_blob);
-#else
- return 0;
-#endif
-}
-
-int board_mmc_init(bd_t *bis)
-{
- int ret;
-
- if (get_boot_mode() == BOOT_MODE_SD) {
- ret = init_mmc();
- ret |= init_dwmmc();
- } else {
- ret = init_dwmmc();
- ret |= init_mmc();
- }
-
- if (ret)
- debug("mmc init failed\n");
-
- return ret;
-}
-#endif
-
#ifdef CONFIG_DISPLAY_BOARDINFO
int checkboard(void)
{
- const char *board_info;
+ if (IS_ENABLED(CONFIG_BOARD_TYPES)) {
+ const char *board_info = get_board_type();
+
+ if (board_info)
+ printf("Type: %s\n", board_info);
+ }
- board_info = fdt_getprop(gd->fdt_blob, 0, "model", NULL);
- printf("Board: %s\n", board_info ? board_info : "unknown");
-#ifdef CONFIG_BOARD_TYPES
- board_info = get_board_type();
- if (board_info)
- printf("Type: %s\n", board_info);
-#endif
return 0;
}
#endif
diff --git a/board/samsung/common/exynos5-dt.c b/board/samsung/common/exynos5-dt.c
index c183965b92..87eb381345 100644
--- a/board/samsung/common/exynos5-dt.c
+++ b/board/samsung/common/exynos5-dt.c
@@ -34,37 +34,8 @@
DECLARE_GLOBAL_DATA_PTR;
-static void board_enable_audio_codec(void)
-{
- int node, ret;
- struct gpio_desc en_gpio;
-
- node = fdtdec_next_compatible(gd->fdt_blob, 0,
- COMPAT_SAMSUNG_EXYNOS5_SOUND);
- if (node <= 0)
- return;
-
- ret = gpio_request_by_name_nodev(offset_to_ofnode(node),
- "codec-enable-gpio", 0, &en_gpio,
- GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE);
- if (ret == -FDT_ERR_NOTFOUND)
- return;
-
- /* Turn on the GPIO which connects to the codec's "enable" line. */
- gpio_set_pull(gpio_get_number(&en_gpio), S5P_GPIO_PULL_NONE);
-
-#ifdef CONFIG_SOUND_MAX98095
- /* Enable MAX98095 Codec */
- gpio_request(EXYNOS5_GPIO_X17, "max98095_enable");
- gpio_direction_output(EXYNOS5_GPIO_X17, 1);
- gpio_set_pull(EXYNOS5_GPIO_X17, S5P_GPIO_PULL_NONE);
-#endif
-}
-
int exynos_init(void)
{
- board_enable_audio_codec();
-
return 0;
}
diff --git a/cmd/Kconfig b/cmd/Kconfig
index ea1a325eb3..3ea42e4256 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -226,7 +226,7 @@ config CMD_BOOTEFI
config CMD_BOOTEFI_HELLO_COMPILE
bool "Compile a standard EFI hello world binary for testing"
- depends on CMD_BOOTEFI && (ARM || X86 || RISCV)
+ depends on CMD_BOOTEFI && !CPU_V7M && !SANDBOX
default y
help
This compiles a standard EFI hello world application with U-Boot so
diff --git a/cmd/bootefi.c b/cmd/bootefi.c
index 38679ffc56..ee685d8644 100644
--- a/cmd/bootefi.c
+++ b/cmd/bootefi.c
@@ -5,8 +5,9 @@
* Copyright (c) 2016 Alexander Graf
*/
-#include <charset.h>
#include <common.h>
+#include <bootm.h>
+#include <charset.h>
#include <command.h>
#include <dm.h>
#include <efi_loader.h>
@@ -21,93 +22,11 @@
#include <asm-generic/unaligned.h>
#include <linux/linkage.h>
-#ifdef CONFIG_ARMV7_NONSEC
-#include <asm/armv7.h>
-#include <asm/secure.h>
-#endif
-
DECLARE_GLOBAL_DATA_PTR;
-#define OBJ_LIST_NOT_INITIALIZED 1
-
-static efi_status_t efi_obj_list_initialized = OBJ_LIST_NOT_INITIALIZED;
-
static struct efi_device_path *bootefi_image_path;
static struct efi_device_path *bootefi_device_path;
-/* Initialize and populate EFI object list */
-efi_status_t efi_init_obj_list(void)
-{
- efi_status_t ret = EFI_SUCCESS;
-
- /*
- * On the ARM architecture gd is mapped to a fixed register (r9 or x18).
- * As this register may be overwritten by an EFI payload we save it here
- * and restore it on every callback entered.
- */
- efi_save_gd();
-
- /* Initialize once only */
- if (efi_obj_list_initialized != OBJ_LIST_NOT_INITIALIZED)
- return efi_obj_list_initialized;
-
- /* Initialize system table */
- ret = efi_initialize_system_table();
- if (ret != EFI_SUCCESS)
- goto out;
-
- /* Initialize root node */
- ret = efi_root_node_register();
- if (ret != EFI_SUCCESS)
- goto out;
-
- /* Initialize EFI driver uclass */
- ret = efi_driver_init();
- if (ret != EFI_SUCCESS)
- goto out;
-
- ret = efi_console_register();
- if (ret != EFI_SUCCESS)
- goto out;
-#ifdef CONFIG_PARTITIONS
- ret = efi_disk_register();
- if (ret != EFI_SUCCESS)
- goto out;
-#endif
-#if defined(CONFIG_LCD) || defined(CONFIG_DM_VIDEO)
- ret = efi_gop_register();
- if (ret != EFI_SUCCESS)
- goto out;
-#endif
-#ifdef CONFIG_NET
- ret = efi_net_register();
- if (ret != EFI_SUCCESS)
- goto out;
-#endif
-#ifdef CONFIG_GENERATE_ACPI_TABLE
- ret = efi_acpi_register();
- if (ret != EFI_SUCCESS)
- goto out;
-#endif
-#ifdef CONFIG_GENERATE_SMBIOS_TABLE
- ret = efi_smbios_register();
- if (ret != EFI_SUCCESS)
- goto out;
-#endif
- ret = efi_watchdog_register();
- if (ret != EFI_SUCCESS)
- goto out;
-
- /* Initialize EFI runtime services */
- ret = efi_reset_system_init();
- if (ret != EFI_SUCCESS)
- goto out;
-
-out:
- efi_obj_list_initialized = ret;
- return ret;
-}
-
/*
* Allow unaligned memory access.
*
@@ -228,34 +147,6 @@ static efi_status_t efi_do_enter(
return ret;
}
-#ifdef CONFIG_ARM64
-static efi_status_t efi_run_in_el2(EFIAPI efi_status_t (*entry)(
- efi_handle_t image_handle, struct efi_system_table *st),
- efi_handle_t image_handle, struct efi_system_table *st)
-{
- /* Enable caches again */
- dcache_enable();
-
- return efi_do_enter(image_handle, st, entry);
-}
-#endif
-
-#ifdef CONFIG_ARMV7_NONSEC
-static bool is_nonsec;
-
-static efi_status_t efi_run_in_hyp(EFIAPI efi_status_t (*entry)(
- efi_handle_t image_handle, struct efi_system_table *st),
- efi_handle_t image_handle, struct efi_system_table *st)
-{
- /* Enable caches again */
- dcache_enable();
-
- is_nonsec = true;
-
- return efi_do_enter(image_handle, st, entry);
-}
-#endif
-
/*
* efi_carve_out_dt_rsv() - Carve out DT reserved memory ranges
*
@@ -386,7 +277,7 @@ static efi_status_t do_bootefi_exec(void *efi,
if (!device_path && !image_path) {
printf("WARNING: using memory device/image path, this may confuse some payloads!\n");
/* actual addresses filled in after efi_load_pe() */
- memdp = efi_dp_from_mem(0, 0, 0);
+ memdp = efi_dp_from_mem(EFI_RESERVED_MEMORY_TYPE, 0, 0);
device_path = image_path = memdp;
/*
* Grub expects that the device path of the loaded image is
@@ -428,46 +319,13 @@ static efi_status_t do_bootefi_exec(void *efi,
"{ro,boot}(blob)0000000000000000");
/* Call our payload! */
- debug("%s:%d Jumping to 0x%lx\n", __func__, __LINE__, (long)entry);
+ debug("%s: Jumping to 0x%p\n", __func__, entry);
if (setjmp(&image_obj->exit_jmp)) {
ret = image_obj->exit_status;
goto err_prepare;
}
-#ifdef CONFIG_ARM64
- /* On AArch64 we need to make sure we call our payload in < EL3 */
- if (current_el() == 3) {
- smp_kick_all_cpus();
- dcache_disable(); /* flush cache before switch to EL2 */
-
- /* Move into EL2 and keep running there */
- armv8_switch_to_el2((ulong)entry,
- (ulong)&image_obj->header,
- (ulong)&systab, 0, (ulong)efi_run_in_el2,
- ES_TO_AARCH64);
-
- /* Should never reach here, efi exits with longjmp */
- while (1) { }
- }
-#endif
-
-#ifdef CONFIG_ARMV7_NONSEC
- if (armv7_boot_nonsec() && !is_nonsec) {
- dcache_disable(); /* flush cache before switch to HYP */
-
- armv7_init_nonsec();
- secure_ram_addr(_do_nonsec_entry)(
- efi_run_in_hyp,
- (uintptr_t)entry,
- (uintptr_t)&image_obj->header,
- (uintptr_t)&systab);
-
- /* Should never reach here, efi exits with longjmp */
- while (1) { }
- }
-#endif
-
ret = efi_do_enter(&image_obj->header, &systab, entry);
err_prepare:
@@ -553,6 +411,8 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
/* Allow unaligned memory access */
allow_unaligned();
+ switch_to_non_secure_mode();
+
/* Initialize EFI drivers */
r = efi_init_obj_list();
if (r != EFI_SUCCESS) {
diff --git a/cmd/sata.c b/cmd/sata.c
index 6d62ba8f74..a73cc54bd3 100644
--- a/cmd/sata.c
+++ b/cmd/sata.c
@@ -60,6 +60,10 @@ int sata_probe(int devnum)
printf("Cannot probe SATA device %d (err=%d)\n", devnum, rc);
return CMD_RET_FAILURE;
}
+ if (!dev) {
+ printf("No SATA device found!\n");
+ return CMD_RET_FAILURE;
+ }
rc = sata_scan(dev);
if (rc) {
printf("Cannot scan SATA device %d (err=%d)\n", devnum, rc);
diff --git a/common/Kconfig b/common/Kconfig
index 8f9d2959ba..0a14bdedaa 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -656,6 +656,14 @@ config BOUNCE_BUFFER
A second possible use of bounce buffers is their ability to
provide aligned buffers for DMA operations.
+config BOARD_TYPES
+ bool "Call get_board_type() to get and display the board type"
+ help
+ If this option is enabled, checkboard() will call get_board_type()
+ to get a string containing the board type and this will be
+ displayed immediately after the model is shown on the console
+ early in boot.
+
menu "Start-up hooks"
config ARCH_EARLY_INIT_R
diff --git a/common/board_r.c b/common/board_r.c
index 5f3d27aa9f..472987d5d5 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -633,10 +633,7 @@ static int run_main_loop(void)
}
/*
- * Over time we hope to remove these functions with code fragments and
- * stub functions, and instead call the relevant function directly.
- *
- * We also hope to remove most of the driver-related init and do it if/when
+ * We hope to remove most of the driver-related init and do it if/when
* the driver is later used.
*
* TODO: perhaps reset the watchdog in the initcall function after each call?
diff --git a/common/bootm.c b/common/bootm.c
index 7c7505f092..3adbceaa38 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -912,6 +912,16 @@ static const void *boot_get_kernel(cmd_tbl_t *cmdtp, int flag, int argc,
return buf;
}
+
+/**
+ * switch_to_non_secure_mode() - switch to non-secure mode
+ *
+ * This routine is overridden by architectures requiring this feature.
+ */
+void __weak switch_to_non_secure_mode(void)
+{
+}
+
#else /* USE_HOSTCC */
void memmove_wd(void *to, void *from, size_t len, ulong chunksz)
diff --git a/common/image-fdt.c b/common/image-fdt.c
index 5988808f18..94089b2215 100644
--- a/common/image-fdt.c
+++ b/common/image-fdt.c
@@ -268,6 +268,7 @@ int boot_get_fdt(int flag, int argc, char * const argv[], uint8_t arch,
ulong load, load_end;
ulong image_start, image_data, image_end;
#endif
+ ulong img_addr;
ulong fdt_addr;
char *fdt_blob = NULL;
void *buf;
@@ -283,6 +284,9 @@ int boot_get_fdt(int flag, int argc, char * const argv[], uint8_t arch,
*of_flat_tree = NULL;
*of_size = 0;
+ img_addr = simple_strtoul(argv[0], NULL, 16);
+ buf = map_sysmem(img_addr, 0);
+
if (argc > 2)
select = argv[2];
if (select || genimg_has_config(images)) {
@@ -453,6 +457,23 @@ int boot_get_fdt(int flag, int argc, char * const argv[], uint8_t arch,
debug("## No Flattened Device Tree\n");
goto no_fdt;
}
+#ifdef CONFIG_ANDROID_BOOT_IMAGE
+ } else if (genimg_get_format(buf) == IMAGE_FORMAT_ANDROID) {
+ struct andr_img_hdr *hdr = buf;
+ ulong fdt_data, fdt_len;
+
+ if (android_image_get_second(hdr, &fdt_data, &fdt_len) != 0)
+ goto no_fdt;
+
+ fdt_blob = (char *)fdt_data;
+ if (fdt_check_header(fdt_blob) != 0)
+ goto no_fdt;
+
+ if (fdt_totalsize(fdt_blob) != fdt_len)
+ goto error;
+
+ debug("## Using FDT found in Android image second area\n");
+#endif
} else {
debug("## No Flattened Device Tree\n");
goto no_fdt;
diff --git a/configs/A20-OLinuXino-Lime2-eMMC_defconfig b/configs/A20-OLinuXino-Lime2-eMMC_defconfig
index 7863a4e8e0..1010f41325 100644
--- a/configs/A20-OLinuXino-Lime2-eMMC_defconfig
+++ b/configs/A20-OLinuXino-Lime2-eMMC_defconfig
@@ -1,6 +1,7 @@
CONFIG_ARM=y
CONFIG_ARCH_SUNXI=y
CONFIG_SPL=y
+CONFIG_SPL_SPI_SUNXI=y
CONFIG_MACH_SUN7I=y
CONFIG_DRAM_CLK=384
CONFIG_MMC0_CD_PIN="PH1"
diff --git a/configs/am57xx_hs_evm_defconfig b/configs/am57xx_hs_evm_defconfig
index f9805d24f3..7a0fd927b8 100644
--- a/configs/am57xx_hs_evm_defconfig
+++ b/configs/am57xx_hs_evm_defconfig
@@ -32,6 +32,7 @@ CONFIG_SPL_DMA_SUPPORT=y
CONFIG_SPL_SPI_LOAD=y
# CONFIG_CMD_FLASH is not set
# CONFIG_CMD_SETEXPR is not set
+# CONFIG_CMD_PMIC is not set
CONFIG_OF_CONTROL=y
CONFIG_SPL_OF_CONTROL=y
CONFIG_DEFAULT_DEVICE_TREE="am57xx-beagle-x15"
diff --git a/configs/am57xx_hs_evm_usb_defconfig b/configs/am57xx_hs_evm_usb_defconfig
new file mode 100644
index 0000000000..6e4580ae39
--- /dev/null
+++ b/configs/am57xx_hs_evm_usb_defconfig
@@ -0,0 +1,98 @@
+CONFIG_ARM=y
+CONFIG_ARCH_OMAP2PLUS=y
+CONFIG_TI_SECURE_DEVICE=y
+CONFIG_TI_COMMON_CMD_OPTIONS=y
+CONFIG_SYS_MALLOC_F_LEN=0x2000
+CONFIG_OMAP54XX=y
+CONFIG_TI_SECURE_EMIF_REGION_START=0xbdb00000
+CONFIG_TI_SECURE_EMIF_TOTAL_REGION_SIZE=0x02000000
+CONFIG_TI_SECURE_EMIF_PROTECTED_REGION_SIZE=0x01c00000
+CONFIG_ISW_ENTRY_ADDR=0x40306d50
+CONFIG_TARGET_AM57XX_EVM=y
+CONFIG_SPL=y
+CONFIG_SPL_SPI_FLASH_SUPPORT=y
+CONFIG_SPL_SPI_SUPPORT=y
+CONFIG_ARMV7_LPAE=y
+CONFIG_DISTRO_DEFAULTS=y
+CONFIG_NR_DRAM_BANKS=2
+CONFIG_FIT_IMAGE_POST_PROCESS=y
+CONFIG_SPL_LOAD_FIT=y
+CONFIG_SPL_FIT_IMAGE_POST_PROCESS=y
+CONFIG_OF_BOARD_SETUP=y
+CONFIG_USE_BOOTARGS=y
+CONFIG_BOOTARGS="androidboot.serialno=${serial#} console=ttyS2,115200 androidboot.console=ttyS2 androidboot.hardware=beagle_x15board"
+# CONFIG_USE_BOOTCOMMAND is not set
+CONFIG_SYS_CONSOLE_INFO_QUIET=y
+# CONFIG_MISC_INIT_R is not set
+CONFIG_VERSION_VARIABLE=y
+CONFIG_BOARD_EARLY_INIT_F=y
+CONFIG_SPL_SYS_MALLOC_SIMPLE=y
+CONFIG_SPL_SEPARATE_BSS=y
+CONFIG_SPL_DMA_SUPPORT=y
+# CONFIG_SPL_NAND_SUPPORT is not set
+CONFIG_SPL_RAM_SUPPORT=y
+CONFIG_SPL_SPI_LOAD=y
+CONFIG_SPL_USB_GADGET=y
+CONFIG_SPL_DFU=y
+CONFIG_SPL_YMODEM_SUPPORT=y
+# CONFIG_CMD_FLASH is not set
+# CONFIG_CMD_SETEXPR is not set
+# CONFIG_CMD_PMIC is not set
+CONFIG_OF_CONTROL=y
+CONFIG_SPL_OF_CONTROL=y
+CONFIG_DEFAULT_DEVICE_TREE="am57xx-beagle-x15"
+CONFIG_OF_LIST="am57xx-beagle-x15 am57xx-beagle-x15-revb1 am57xx-beagle-x15-revc am572x-idk am571x-idk am574x-idk"
+CONFIG_ENV_IS_IN_MMC=y
+CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
+CONFIG_DM=y
+CONFIG_SPL_DM=y
+CONFIG_SPL_DM_SEQ_ALIAS=y
+CONFIG_SCSI_AHCI=y
+# CONFIG_BLK is not set
+CONFIG_DFU_MMC=y
+CONFIG_DFU_RAM=y
+CONFIG_USB_FUNCTION_FASTBOOT=y
+CONFIG_FASTBOOT_BUF_ADDR=0x82000000
+CONFIG_FASTBOOT_BUF_SIZE=0x2F000000
+CONFIG_FASTBOOT_USB_DEV=1
+CONFIG_FASTBOOT_FLASH=y
+CONFIG_FASTBOOT_FLASH_MMC_DEV=1
+CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
+CONFIG_DM_GPIO=y
+CONFIG_DM_I2C=y
+CONFIG_MISC=y
+CONFIG_DM_MMC=y
+CONFIG_MMC_OMAP_HS=y
+CONFIG_DM_SPI_FLASH=y
+CONFIG_SPI_FLASH=y
+CONFIG_SPI_FLASH_BAR=y
+CONFIG_SPI_FLASH_SPANSION=y
+CONFIG_PHY_MICREL=y
+CONFIG_PHY_MICREL_KSZ90X1=y
+CONFIG_DM_ETH=y
+CONFIG_MII=y
+CONFIG_DRIVER_TI_CPSW=y
+CONFIG_PHY=y
+CONFIG_PIPE3_PHY=y
+CONFIG_OMAP_USB2_PHY=y
+CONFIG_DM_PMIC=y
+CONFIG_PMIC_PALMAS=y
+CONFIG_DM_REGULATOR=y
+CONFIG_DM_REGULATOR_PALMAS=y
+CONFIG_DM_SERIAL=y
+CONFIG_SPI=y
+CONFIG_DM_SPI=y
+CONFIG_TI_QSPI=y
+CONFIG_USB=y
+CONFIG_DM_USB=y
+CONFIG_DM_USB_GADGET=y
+CONFIG_SPL_DM_USB_GADGET=y
+CONFIG_USB_XHCI_HCD=y
+CONFIG_USB_XHCI_DWC3=y
+CONFIG_USB_DWC3=y
+CONFIG_USB_DWC3_GADGET=y
+CONFIG_USB_DWC3_GENERIC=y
+CONFIG_USB_GADGET=y
+CONFIG_USB_GADGET_MANUFACTURER="Texas Instruments"
+CONFIG_USB_GADGET_VENDOR_NUM=0x0451
+CONFIG_USB_GADGET_PRODUCT_NUM=0xd022
diff --git a/configs/am65x_evm_r5_defconfig b/configs/am65x_evm_r5_defconfig
index d2ec2dd7fe..49498b13b6 100644
--- a/configs/am65x_evm_r5_defconfig
+++ b/configs/am65x_evm_r5_defconfig
@@ -33,6 +33,7 @@ CONFIG_HUSH_PARSER=y
CONFIG_CMD_BOOTZ=y
CONFIG_CMD_ASKENV=y
# CONFIG_CMD_FLASH is not set
+CONFIG_CMD_GPT=y
CONFIG_CMD_MMC=y
CONFIG_CMD_REMOTEPROC=y
# CONFIG_CMD_SETEXPR is not set
diff --git a/configs/axs101_defconfig b/configs/axs101_defconfig
index b77ecc1781..6ef6616554 100644
--- a/configs/axs101_defconfig
+++ b/configs/axs101_defconfig
@@ -8,6 +8,7 @@ CONFIG_DEBUG_UART=y
CONFIG_BOOTDELAY=3
CONFIG_USE_BOOTARGS=y
CONFIG_BOOTARGS="console=ttyS3,115200n8"
+CONFIG_BOARD_TYPES=y
CONFIG_BOARD_EARLY_INIT_F=y
CONFIG_HUSH_PARSER=y
CONFIG_SYS_PROMPT="AXS# "
diff --git a/configs/axs103_defconfig b/configs/axs103_defconfig
index f42b694ca7..2208bdb9be 100644
--- a/configs/axs103_defconfig
+++ b/configs/axs103_defconfig
@@ -8,6 +8,7 @@ CONFIG_DEBUG_UART=y
CONFIG_BOOTDELAY=3
CONFIG_USE_BOOTARGS=y
CONFIG_BOOTARGS="console=ttyS3,115200n8"
+CONFIG_BOARD_TYPES=y
CONFIG_BOARD_EARLY_INIT_F=y
CONFIG_HUSH_PARSER=y
CONFIG_SYS_PROMPT="AXS# "
diff --git a/configs/bcm963158_ram_defconfig b/configs/bcm963158_ram_defconfig
new file mode 100644
index 0000000000..9083f1dc9f
--- /dev/null
+++ b/configs/bcm963158_ram_defconfig
@@ -0,0 +1,42 @@
+CONFIG_ARM=y
+# CONFIG_ARM64_SUPPORT_AARCH32 is not set
+CONFIG_ARCH_BCM63158=y
+CONFIG_SYS_TEXT_BASE=0x10000000
+CONFIG_SYS_MALLOC_F_LEN=0x8000
+CONFIG_SPL_SYS_MALLOC_F_LEN=0x400
+CONFIG_TARGET_BCM963158=y
+CONFIG_ENV_VARS_UBOOT_CONFIG=y
+CONFIG_NR_DRAM_BANKS=1
+CONFIG_TPL_SYS_MALLOC_F_LEN=0x400
+CONFIG_FIT=y
+CONFIG_FIT_SIGNATURE=y
+CONFIG_FIT_ENABLE_RSASSA_PSS_SUPPORT=y
+CONFIG_FIT_VERBOSE=y
+CONFIG_IMAGE_FORMAT_LEGACY=y
+CONFIG_SUPPORT_RAW_INITRD=y
+CONFIG_DISPLAY_BOARDINFO_LATE=y
+CONFIG_HUSH_PARSER=y
+CONFIG_CMD_BOOTEFI_SELFTEST=y
+# CONFIG_CMD_LZMADEC is not set
+# CONFIG_CMD_UNZIP is not set
+# CONFIG_CMD_FLASH is not set
+CONFIG_CMD_CACHE=y
+CONFIG_DOS_PARTITION=y
+CONFIG_ISO_PARTITION=y
+CONFIG_EFI_PARTITION=y
+CONFIG_DEFAULT_DEVICE_TREE="bcm963158"
+# CONFIG_NET is not set
+CONFIG_BLK=y
+CONFIG_CLK=y
+# CONFIG_MMC is not set
+CONFIG_SPECIFY_CONSOLE_INDEX=y
+# CONFIG_SPL_SERIAL_PRESENT is not set
+CONFIG_CONS_INDEX=0
+CONFIG_DM_SERIAL=y
+CONFIG_SERIAL_SEARCH_ALL=y
+CONFIG_PL01X_SERIAL=y
+CONFIG_SYSRESET=y
+CONFIG_SYSRESET_WATCHDOG=y
+CONFIG_WDT_BCM6345=y
+CONFIG_REGEX=y
+# CONFIG_GENERATE_SMBIOS_TABLE is not set
diff --git a/configs/bcm968380gerg_ram_defconfig b/configs/bcm968380gerg_ram_defconfig
index 848d898ddf..61661bd756 100644
--- a/configs/bcm968380gerg_ram_defconfig
+++ b/configs/bcm968380gerg_ram_defconfig
@@ -44,4 +44,6 @@ CONFIG_RESET_BCM6345=y
# CONFIG_SPL_SERIAL_PRESENT is not set
CONFIG_DM_SERIAL=y
CONFIG_BCM6345_SERIAL=y
+CONFIG_SYSRESET_WATCHDOG=y
+CONFIG_WDT_BCM6345=y
CONFIG_LZO=y
diff --git a/configs/bcm968580_ram_defconfig b/configs/bcm968580xref_ram_defconfig
index 56e0a56028..1f433a3d39 100644
--- a/configs/bcm968580_ram_defconfig
+++ b/configs/bcm968580xref_ram_defconfig
@@ -18,7 +18,6 @@ CONFIG_CMD_BOOTEFI_SELFTEST=y
CONFIG_DOS_PARTITION=y
CONFIG_ISO_PARTITION=y
CONFIG_EFI_PARTITION=y
-CONFIG_OF_EMBED=y
CONFIG_DEFAULT_DEVICE_TREE="bcm968580xref"
# CONFIG_NET is not set
CONFIG_BLK=y
@@ -31,5 +30,7 @@ CONFIG_DM_SERIAL=y
CONFIG_SERIAL_SEARCH_ALL=y
CONFIG_BCM6345_SERIAL=y
CONFIG_SYSRESET=y
+CONFIG_SYSRESET_WATCHDOG=y
+CONFIG_WDT_BCM6345=y
CONFIG_REGEX=y
# CONFIG_GENERATE_SMBIOS_TABLE is not set
diff --git a/configs/brppt1_mmc_defconfig b/configs/brppt1_mmc_defconfig
index 083b5f7e5f..f2d8220126 100644
--- a/configs/brppt1_mmc_defconfig
+++ b/configs/brppt1_mmc_defconfig
@@ -71,7 +71,6 @@ CONFIG_SPL_DM_SEQ_ALIAS=y
CONFIG_BOOTCOUNT_LIMIT=y
CONFIG_DM_GPIO=y
CONFIG_DM_I2C=y
-CONFIG_DM_I2C_COMPAT=y
CONFIG_I2C_SET_DEFAULT_BUS_NUM=y
CONFIG_MISC=y
CONFIG_DM_MMC=y
diff --git a/configs/brppt1_nand_defconfig b/configs/brppt1_nand_defconfig
index 1cfd5fc709..275727d11f 100644
--- a/configs/brppt1_nand_defconfig
+++ b/configs/brppt1_nand_defconfig
@@ -73,7 +73,6 @@ CONFIG_BLK=y
CONFIG_BOOTCOUNT_LIMIT=y
CONFIG_DM_GPIO=y
CONFIG_DM_I2C=y
-CONFIG_DM_I2C_COMPAT=y
CONFIG_I2C_SET_DEFAULT_BUS_NUM=y
CONFIG_MISC=y
# CONFIG_MMC is not set
diff --git a/configs/brppt1_spi_defconfig b/configs/brppt1_spi_defconfig
index 37373967df..668c4c22c2 100644
--- a/configs/brppt1_spi_defconfig
+++ b/configs/brppt1_spi_defconfig
@@ -76,7 +76,6 @@ CONFIG_SPL_DM_SEQ_ALIAS=y
CONFIG_BOOTCOUNT_LIMIT=y
CONFIG_DM_GPIO=y
CONFIG_DM_I2C=y
-CONFIG_DM_I2C_COMPAT=y
CONFIG_I2C_SET_DEFAULT_BUS_NUM=y
CONFIG_MISC=y
CONFIG_DM_MMC=y
diff --git a/configs/chromebook_link64_defconfig b/configs/chromebook_link64_defconfig
index 074d333dd4..12f26570af 100644
--- a/configs/chromebook_link64_defconfig
+++ b/configs/chromebook_link64_defconfig
@@ -38,7 +38,6 @@ CONFIG_SPL_PCH_SUPPORT=y
CONFIG_SPL_RTC_SUPPORT=y
CONFIG_HUSH_PARSER=y
CONFIG_CMD_CPU=y
-# CONFIG_CMD_BOOTEFI_HELLO_COMPILE is not set
# CONFIG_CMD_FLASH is not set
CONFIG_CMD_GPIO=y
CONFIG_CMD_SF=y
diff --git a/configs/dra7xx_hs_evm_defconfig b/configs/dra7xx_hs_evm_defconfig
index f98ee470a9..3cf7659496 100644
--- a/configs/dra7xx_hs_evm_defconfig
+++ b/configs/dra7xx_hs_evm_defconfig
@@ -2,7 +2,7 @@ CONFIG_ARM=y
CONFIG_ARCH_OMAP2PLUS=y
CONFIG_TI_SECURE_DEVICE=y
CONFIG_TI_COMMON_CMD_OPTIONS=y
-CONFIG_SYS_MALLOC_F_LEN=0x2000
+CONFIG_SYS_MALLOC_F_LEN=0x18000
CONFIG_OMAP54XX=y
CONFIG_TI_SECURE_EMIF_REGION_START=0xbdb00000
CONFIG_TI_SECURE_EMIF_TOTAL_REGION_SIZE=0x02000000
@@ -37,13 +37,18 @@ CONFIG_OF_CONTROL=y
CONFIG_SPL_OF_CONTROL=y
CONFIG_DEFAULT_DEVICE_TREE="dra7-evm"
CONFIG_OF_LIST="dra7-evm dra72-evm dra72-evm-revc dra71-evm dra76-evm"
+CONFIG_SPL_MULTI_DTB_FIT=y
+CONFIG_SPL_MULTI_DTB_FIT_UNCOMPRESS_SZ=0x9000
+CONFIG_OF_SPL_REMOVE_PROPS="clocks clock-names interrupt-parent"
CONFIG_ENV_IS_IN_MMC=y
CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
CONFIG_DM=y
CONFIG_SPL_DM=y
+CONFIG_SPL_DM_DEVICE_REMOVE=y
CONFIG_SPL_DM_SEQ_ALIAS=y
CONFIG_SPL_REGMAP=y
CONFIG_SPL_SYSCON=y
+CONFIG_SPL_OF_TRANSLATE=y
CONFIG_DWC_AHCI=y
CONFIG_DFU_MMC=y
CONFIG_DFU_RAM=y
@@ -62,6 +67,7 @@ CONFIG_DM_MMC=y
CONFIG_MMC_IO_VOLTAGE=y
CONFIG_MMC_UHS_SUPPORT=y
CONFIG_MMC_HS200_SUPPORT=y
+CONFIG_SPL_MMC_HS200_SUPPORT=y
CONFIG_MMC_OMAP_HS=y
CONFIG_DM_SPI_FLASH=y
CONFIG_SPI_FLASH=y
diff --git a/configs/dra7xx_hs_evm_usb_defconfig b/configs/dra7xx_hs_evm_usb_defconfig
new file mode 100644
index 0000000000..378b3d791c
--- /dev/null
+++ b/configs/dra7xx_hs_evm_usb_defconfig
@@ -0,0 +1,113 @@
+CONFIG_ARM=y
+CONFIG_ARCH_OMAP2PLUS=y
+CONFIG_TI_SECURE_DEVICE=y
+CONFIG_TI_COMMON_CMD_OPTIONS=y
+CONFIG_SYS_MALLOC_F_LEN=0x18000
+CONFIG_OMAP54XX=y
+CONFIG_TI_SECURE_EMIF_REGION_START=0xbdb00000
+CONFIG_TI_SECURE_EMIF_TOTAL_REGION_SIZE=0x02000000
+CONFIG_TI_SECURE_EMIF_PROTECTED_REGION_SIZE=0x01c00000
+CONFIG_ISW_ENTRY_ADDR=0x40306d50
+CONFIG_TARGET_DRA7XX_EVM=y
+CONFIG_SPL=y
+CONFIG_SPL_SPI_FLASH_SUPPORT=y
+CONFIG_SPL_SPI_SUPPORT=y
+CONFIG_ARMV7_LPAE=y
+CONFIG_AHCI=y
+CONFIG_DISTRO_DEFAULTS=y
+CONFIG_NR_DRAM_BANKS=2
+CONFIG_FIT_IMAGE_POST_PROCESS=y
+CONFIG_SPL_LOAD_FIT=y
+CONFIG_SPL_FIT_IMAGE_POST_PROCESS=y
+CONFIG_OF_BOARD_SETUP=y
+CONFIG_USE_BOOTARGS=y
+CONFIG_BOOTARGS="androidboot.serialno=${serial#} console=ttyS0,115200 androidboot.console=ttyS0 androidboot.hardware=jacinto6evmboard"
+# CONFIG_USE_BOOTCOMMAND is not set
+CONFIG_SYS_CONSOLE_INFO_QUIET=y
+# CONFIG_MISC_INIT_R is not set
+CONFIG_VERSION_VARIABLE=y
+CONFIG_BOARD_EARLY_INIT_F=y
+CONFIG_SPL_SYS_MALLOC_SIMPLE=y
+CONFIG_SPL_SEPARATE_BSS=y
+CONFIG_SPL_DMA_SUPPORT=y
+# CONFIG_SPL_NAND_SUPPORT is not set
+CONFIG_SPL_RAM_SUPPORT=y
+CONFIG_SPL_SPI_LOAD=y
+CONFIG_SPL_USB_GADGET=y
+CONFIG_SPL_DFU=y
+CONFIG_SPL_YMODEM_SUPPORT=y
+# CONFIG_CMD_FLASH is not set
+# CONFIG_CMD_SETEXPR is not set
+CONFIG_OF_CONTROL=y
+CONFIG_SPL_OF_CONTROL=y
+CONFIG_DEFAULT_DEVICE_TREE="dra7-evm"
+CONFIG_OF_LIST="dra7-evm dra72-evm dra72-evm-revc dra71-evm dra76-evm"
+CONFIG_SPL_MULTI_DTB_FIT=y
+CONFIG_SPL_MULTI_DTB_FIT_UNCOMPRESS_SZ=0x9000
+CONFIG_OF_SPL_REMOVE_PROPS="clocks clock-names interrupt-parent"
+CONFIG_ENV_IS_IN_MMC=y
+CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
+CONFIG_DM=y
+CONFIG_SPL_DM=y
+CONFIG_SPL_DM_DEVICE_REMOVE=y
+CONFIG_SPL_DM_SEQ_ALIAS=y
+CONFIG_SPL_REGMAP=y
+CONFIG_SPL_SYSCON=y
+CONFIG_SPL_OF_TRANSLATE=y
+CONFIG_DWC_AHCI=y
+CONFIG_DFU_MMC=y
+CONFIG_DFU_RAM=y
+CONFIG_DFU_SF=y
+CONFIG_USB_FUNCTION_FASTBOOT=y
+CONFIG_FASTBOOT_BUF_ADDR=0x82000000
+CONFIG_FASTBOOT_BUF_SIZE=0x2F000000
+CONFIG_FASTBOOT_FLASH=y
+CONFIG_FASTBOOT_FLASH_MMC_DEV=1
+CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
+CONFIG_DM_GPIO=y
+CONFIG_PCF8575_GPIO=y
+CONFIG_DM_I2C=y
+CONFIG_MISC=y
+CONFIG_DM_MMC=y
+CONFIG_MMC_IO_VOLTAGE=y
+CONFIG_MMC_UHS_SUPPORT=y
+CONFIG_MMC_HS200_SUPPORT=y
+CONFIG_SPL_MMC_HS200_SUPPORT=y
+CONFIG_MMC_OMAP_HS=y
+CONFIG_DM_SPI_FLASH=y
+CONFIG_SPI_FLASH=y
+CONFIG_SPI_FLASH_BAR=y
+CONFIG_SPI_FLASH_SPANSION=y
+CONFIG_DM_ETH=y
+CONFIG_PHY_GIGE=y
+CONFIG_MII=y
+CONFIG_DRIVER_TI_CPSW=y
+CONFIG_SPL_PHY=y
+CONFIG_PIPE3_PHY=y
+CONFIG_OMAP_USB2_PHY=y
+CONFIG_PMIC_PALMAS=y
+CONFIG_PMIC_LP873X=y
+CONFIG_DM_REGULATOR_FIXED=y
+CONFIG_DM_REGULATOR_GPIO=y
+CONFIG_DM_REGULATOR_PALMAS=y
+CONFIG_DM_REGULATOR_LP873X=y
+CONFIG_DM_SCSI=y
+CONFIG_DM_SERIAL=y
+CONFIG_SPI=y
+CONFIG_DM_SPI=y
+CONFIG_TI_QSPI=y
+CONFIG_TIMER=y
+CONFIG_OMAP_TIMER=y
+CONFIG_USB=y
+CONFIG_DM_USB=y
+CONFIG_DM_USB_GADGET=y
+CONFIG_SPL_DM_USB_GADGET=y
+CONFIG_USB_XHCI_HCD=y
+CONFIG_USB_XHCI_DWC3=y
+CONFIG_USB_DWC3=y
+CONFIG_USB_DWC3_GADGET=y
+CONFIG_USB_DWC3_GENERIC=y
+CONFIG_USB_GADGET=y
+CONFIG_USB_GADGET_MANUFACTURER="Texas Instruments"
+CONFIG_USB_GADGET_VENDOR_NUM=0x0451
+CONFIG_USB_GADGET_PRODUCT_NUM=0xd022
diff --git a/configs/edison_defconfig b/configs/edison_defconfig
index 234dbac4e8..8b6df817ed 100644
--- a/configs/edison_defconfig
+++ b/configs/edison_defconfig
@@ -25,7 +25,7 @@ CONFIG_CMD_EXT4=y
CONFIG_CMD_EXT4_WRITE=y
CONFIG_CMD_FAT=y
CONFIG_CMD_FS_GENERIC=y
-CONFIG_OF_EMBED=y
+CONFIG_OF_SEPARATE=y
CONFIG_DEFAULT_DEVICE_TREE="edison"
CONFIG_ENV_IS_IN_MMC=y
CONFIG_CPU=y
diff --git a/configs/kp_imx6q_tpc_defconfig b/configs/kp_imx6q_tpc_defconfig
index da07d9c772..cb58ed6678 100644
--- a/configs/kp_imx6q_tpc_defconfig
+++ b/configs/kp_imx6q_tpc_defconfig
@@ -21,7 +21,6 @@ CONFIG_SPL_RAW_IMAGE_SUPPORT=y
CONFIG_SPL_WATCHDOG_SUPPORT=y
CONFIG_AUTOBOOT_KEYED=y
CONFIG_AUTOBOOT_STOP_STR="."
-# CONFIG_CMD_BOOTEFI_HELLO_COMPILE is not set
# CONFIG_CMD_ELF is not set
# CONFIG_CMD_FLASH is not set
CONFIG_CMD_GPIO=y
diff --git a/configs/odroid-xu3_defconfig b/configs/odroid-xu3_defconfig
index 11796e5bdf..f6f05b2948 100644
--- a/configs/odroid-xu3_defconfig
+++ b/configs/odroid-xu3_defconfig
@@ -2,6 +2,7 @@ CONFIG_ARM=y
CONFIG_ARCH_EXYNOS=y
CONFIG_SYS_TEXT_BASE=0x43E00000
CONFIG_ARCH_EXYNOS5=y
+CONFIG_BOARD_TYPES=y
CONFIG_IDENT_STRING=" for ODROID-XU3/XU4/HC1/HC2"
CONFIG_DISTRO_DEFAULTS=y
CONFIG_NR_DRAM_BANKS=8
diff --git a/configs/odroid_defconfig b/configs/odroid_defconfig
index cdb033ba78..184bb62c1c 100644
--- a/configs/odroid_defconfig
+++ b/configs/odroid_defconfig
@@ -3,6 +3,7 @@ CONFIG_ARCH_EXYNOS=y
CONFIG_SYS_TEXT_BASE=0x43e00000
CONFIG_ARCH_EXYNOS4=y
CONFIG_TARGET_ODROID=y
+CONFIG_BOARD_TYPES=y
CONFIG_DISTRO_DEFAULTS=y
CONFIG_NR_DRAM_BANKS=8
# CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
diff --git a/configs/orangepi_zero_plus_defconfig b/configs/orangepi_zero_plus_defconfig
index a2cfc7f59a..105d8f3251 100644
--- a/configs/orangepi_zero_plus_defconfig
+++ b/configs/orangepi_zero_plus_defconfig
@@ -4,8 +4,7 @@ CONFIG_SPL=y
CONFIG_MACH_SUN50I_H5=y
CONFIG_DRAM_CLK=624
CONFIG_DRAM_ZQ=3881977
-CONFIG_MMC0_CD_PIN="PH13"
-CONFIG_MMC_SUNXI_SLOT_EXTRA=2
+CONFIG_MMC0_CD_PIN="PF6"
CONFIG_NR_DRAM_BANKS=1
# CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
# CONFIG_CMD_FLASH is not set
diff --git a/configs/qemu-x86_64_defconfig b/configs/qemu-x86_64_defconfig
index 8d43acd480..34acc09317 100644
--- a/configs/qemu-x86_64_defconfig
+++ b/configs/qemu-x86_64_defconfig
@@ -36,7 +36,6 @@ CONFIG_SPL_PCH_SUPPORT=y
CONFIG_SPL_RTC_SUPPORT=y
CONFIG_HUSH_PARSER=y
CONFIG_CMD_CPU=y
-# CONFIG_CMD_BOOTEFI_HELLO_COMPILE is not set
CONFIG_CMD_BOOTEFI_SELFTEST=y
# CONFIG_CMD_FLASH is not set
CONFIG_CMD_IDE=y
diff --git a/configs/spring_defconfig b/configs/spring_defconfig
index 5c5569acd2..c0084289d9 100644
--- a/configs/spring_defconfig
+++ b/configs/spring_defconfig
@@ -62,6 +62,7 @@ CONFIG_DEBUG_UART_S5P=y
CONFIG_SOUND=y
CONFIG_I2S=y
CONFIG_I2S_SAMSUNG=y
+CONFIG_SOUND_MAX98088=y
CONFIG_SOUND_MAX98095=y
CONFIG_SOUND_WM8994=y
CONFIG_EXYNOS_SPI=y
diff --git a/configs/stm32f429-discovery_defconfig b/configs/stm32f429-discovery_defconfig
index 265b1ec068..fe3176cac0 100644
--- a/configs/stm32f429-discovery_defconfig
+++ b/configs/stm32f429-discovery_defconfig
@@ -15,7 +15,6 @@ CONFIG_MISC_INIT_R=y
CONFIG_BOARD_EARLY_INIT_F=y
CONFIG_HUSH_PARSER=y
CONFIG_SYS_PROMPT="U-Boot > "
-# CONFIG_CMD_BOOTEFI_HELLO_COMPILE is not set
CONFIG_CMD_IMLS=y
# CONFIG_CMD_SETEXPR is not set
CONFIG_CMD_TIMER=y
diff --git a/configs/stm32f429-evaluation_defconfig b/configs/stm32f429-evaluation_defconfig
index 9f1a7680ad..041f042383 100644
--- a/configs/stm32f429-evaluation_defconfig
+++ b/configs/stm32f429-evaluation_defconfig
@@ -12,7 +12,6 @@ CONFIG_MISC_INIT_R=y
# CONFIG_DISPLAY_CPUINFO is not set
CONFIG_BOARD_EARLY_INIT_F=y
CONFIG_SYS_PROMPT="U-Boot > "
-# CONFIG_CMD_BOOTEFI_HELLO_COMPILE is not set
CONFIG_CMD_IMLS=y
CONFIG_CMD_GPT=y
# CONFIG_RANDOM_UUID is not set
diff --git a/configs/stm32f469-discovery_defconfig b/configs/stm32f469-discovery_defconfig
index 801af6bb61..c2b600025e 100644
--- a/configs/stm32f469-discovery_defconfig
+++ b/configs/stm32f469-discovery_defconfig
@@ -12,7 +12,6 @@ CONFIG_MISC_INIT_R=y
# CONFIG_DISPLAY_CPUINFO is not set
CONFIG_BOARD_EARLY_INIT_F=y
CONFIG_SYS_PROMPT="U-Boot > "
-# CONFIG_CMD_BOOTEFI_HELLO_COMPILE is not set
CONFIG_CMD_IMLS=y
CONFIG_CMD_GPT=y
# CONFIG_RANDOM_UUID is not set
diff --git a/configs/stm32mp15_basic_defconfig b/configs/stm32mp15_basic_defconfig
index 304688e56f..d20b2ab350 100644
--- a/configs/stm32mp15_basic_defconfig
+++ b/configs/stm32mp15_basic_defconfig
@@ -19,6 +19,7 @@ CONFIG_SYS_PROMPT="STM32MP> "
# CONFIG_CMD_IMPORTENV is not set
CONFIG_CMD_MEMINFO=y
CONFIG_CMD_ADC=y
+CONFIG_CMD_CLK=y
CONFIG_CMD_FUSE=y
CONFIG_CMD_GPIO=y
CONFIG_CMD_GPT=y
diff --git a/configs/tbs_a711_defconfig b/configs/tbs_a711_defconfig
index 253ef5cce0..007ff89348 100644
--- a/configs/tbs_a711_defconfig
+++ b/configs/tbs_a711_defconfig
@@ -3,7 +3,7 @@ CONFIG_ARCH_SUNXI=y
CONFIG_SPL=y
CONFIG_MACH_SUN8I_A83T=y
CONFIG_DRAM_TYPE=7
-CONFIG_DRAM_CLK=648
+CONFIG_DRAM_CLK=552
CONFIG_DRAM_ZQ=15355
CONFIG_DRAM_ODT_EN=y
CONFIG_MMC_SUNXI_SLOT_EXTRA=2
diff --git a/doc/README.fdt-control b/doc/README.fdt-control
index 446401c9e9..e53cf51875 100644
--- a/doc/README.fdt-control
+++ b/doc/README.fdt-control
@@ -122,13 +122,14 @@ the U-Boot image (including u-boot.bin). This is suitable for debugging
and development only and is not recommended for production devices.
If CONFIG_OF_SEPARATE is defined, then it will be built and placed in
-a u-boot.dtb file alongside u-boot.bin. A common approach is then to
+a u-boot.dtb file alongside u-boot-nodtb.bin. A common approach is then to
join the two:
- cat u-boot.bin u-boot.dtb >image.bin
+ cat u-boot-nodtb.bin u-boot.dtb >image.bin
and then flash image.bin onto your board. Note that U-Boot creates
-u-boot-dtb.bin which does the above step for you also. If you are using
+u-boot-dtb.bin which does the above step for you also. Resulting
+u-boot.bin is a copy of u-boot-dtb.bin in this case. If you are using
CONFIG_SPL_FRAMEWORK, then u-boot.img will be built to include the device
tree binary.
diff --git a/doc/README.ti-secure b/doc/README.ti-secure
index 4b5380c0f3..76950253ac 100644
--- a/doc/README.ti-secure
+++ b/doc/README.ti-secure
@@ -108,7 +108,8 @@ Booting of U-Boot SPL
Invoking the script for DRA7xx/AM57xx Secure Devices
====================================================
- create-boot-image.sh <IMAGE_TYPE> <INPUT_FILE> <OUTPUT_FILE>
+ create-boot-image.sh \
+ <IMAGE_TYPE> <INPUT_FILE> <OUTPUT_FILE> <SPL_LOAD_ADDR>
<IMAGE_TYPE> is a value that specifies the type of the image to
generate OR the action the image generation tool will take. Valid
@@ -116,7 +117,6 @@ Booting of U-Boot SPL
X-LOADER - Generates an image for NOR or QSPI boot modes
MLO - Generates an image for SD/MMC/eMMC boot modes
ULO - Generates an image for USB/UART peripheral boot modes
- Note: ULO is not yet used by the u-boot build process
<INPUT_FILE> is the full path and filename of the public world boot
loader binary file (for this platform, this is always u-boot-spl.bin).
@@ -130,9 +130,13 @@ Booting of U-Boot SPL
the device ROM bootloader requires for loading from
the FAT partition of an SD card (same as on
non-secure devices)
+ u-boot-spl_HS_ULO - boot image for USB/UART peripheral boot modes
u-boot-spl_HS_X-LOADER - boot image for all other flash memories
including QSPI and NOR flash
+ <SPL_LOAD_ADDR> is the address at which SOC ROM should load the
+ <INPUT_FILE>
+
Invoking the script for Keystone2 Secure Devices
=============================================
diff --git a/doc/README.uefi b/doc/README.uefi
index 6b9759cfed..0982fad92e 100644
--- a/doc/README.uefi
+++ b/doc/README.uefi
@@ -14,7 +14,7 @@ and boot loaders like GRUB or the FreeBSD loader can be executed.
## Building for UEFI
-The UEFI standard supports only little endian systems. The UEFI support can be
+The UEFI standard supports only little-endian systems. The UEFI support can be
activated for ARM and x86 by specifying
CONFIG_CMD_BOOTEFI=y
@@ -53,7 +53,7 @@ arguments.
### Executing the boot manager
-The UEFI specfication foresees to define boot entries and boot sequence via UEFI
+The UEFI specification foresees to define boot entries and boot sequence via UEFI
variables. Booting according to these variables is possible via
bootefi bootmgr [fdt address]
@@ -90,14 +90,14 @@ Below you find the output of an example session.
The environment variable fdtcontroladdr points to U-Boot's internal device tree
(if available).
-### Executing the built-in selftest
+### Executing the built-in self-test
-An UEFI selftest suite can be embedded in U-Boot by building with
+An UEFI self-test suite can be embedded in U-Boot by building with
CONFIG_CMD_BOOTEFI_SELFTEST=y
For testing the UEFI implementation the bootefi command can be used to start the
-selftest.
+self-test.
bootefi selftest [fdt address]
diff --git a/doc/device-tree-bindings/clock/st,stm32mp1.txt b/doc/device-tree-bindings/clock/st,stm32mp1.txt
index 6a9397e105..ffcf8cd31d 100644
--- a/doc/device-tree-bindings/clock/st,stm32mp1.txt
+++ b/doc/device-tree-bindings/clock/st,stm32mp1.txt
@@ -132,15 +132,15 @@ Optional Properties:
frac = < 0x810 >;
};
st,pll@1 {
- cfg = < 1 43 1 0 0 PQR(0,1,1)>;
- csg = <10 20 1>;
+ cfg = < 1 43 1 0 0 PQR(0,1,1) >;
+ csg = < 10 20 1 >;
};
st,pll@2 {
- cfg = < 2 85 3 13 3 0>;
- csg = <10 20 SSCG_MODE_CENTER_SPREAD>;
+ cfg = < 2 85 3 13 3 0 >;
+ csg = < 10 20 SSCG_MODE_CENTER_SPREAD >;
};
st,pll@3 {
- cfg = < 2 78 4 7 9 3>;
+ cfg = < 2 78 4 7 9 3 >;
};
st,pkcs = <
CLK_STGEN_HSE
diff --git a/doc/driver-model/of-plat.txt b/doc/driver-model/of-plat.txt
index 732bc34f06..0109ec56c3 100644
--- a/doc/driver-model/of-plat.txt
+++ b/doc/driver-model/of-plat.txt
@@ -64,17 +64,24 @@ strictly necessary. Notable problems include:
normally also supports device tree it must use #ifdef to separate
out this code, since the structures are only available in SPL.
+ - Correct relations between nodes are not implemented. This means that
+ parent/child relations (like bus device iteration) do not work yet.
+ Some phandles (those that are recognised as such) are converted into
+ a pointer to platform data. This pointer can potentially be used to
+ access the referenced device (by searching for the pointer value).
+ This feature is not yet implemented, however.
+
How it works
------------
-The feature is enabled by CONFIG SPL_OF_PLATDATA. This is only available
-in SPL and should be tested with:
+The feature is enabled by CONFIG OF_PLATDATA. This is only available in
+SPL/TPL and should be tested with:
- #if CONFIG_IS_ENABLED(SPL_OF_PLATDATA)
+ #if CONFIG_IS_ENABLED(OF_PLATDATA)
A new tool called 'dtoc' converts a device tree file either into a set of
-struct declarations, one for each compatible node, or a set of
+struct declarations, one for each compatible node, and a set of
U_BOOT_DEVICE() declarations along with the actual platform data for each
device. As an example, consider this MMC node:
@@ -156,6 +163,13 @@ This avoids the code overhead of converting the device tree data to
platform data in the driver. The ofdata_to_platdata() method should
therefore do nothing in such a driver.
+Note that for the platform data to be matched with a driver, the 'name'
+property of the U_BOOT_DEVICE() declaration has to match a driver declared
+via U_BOOT_DRIVER(). This effectively means that a U_BOOT_DRIVER() with a
+'name' corresponding to the devicetree 'compatible' string (after converting
+it to a valid name for C) is needed, so a dedicated driver is required for
+each 'compatible' string.
+
Where a node has multiple compatible strings, a #define is used to make them
equivalent, e.g.:
@@ -165,8 +179,8 @@ equivalent, e.g.:
Converting of-platdata to a useful form
---------------------------------------
-Of course it would be possible use the of-platdata directly in your driver
-whenever configuration information is required. However this meands that the
+Of course it would be possible to use the of-platdata directly in your driver
+whenever configuration information is required. However this means that the
driver will not be able to support device tree, since the of-platdata
structure is not available when device tree is used. It would make no sense
to use this structure if device tree were available, since the structure has
@@ -282,11 +296,6 @@ prevents them being used inadvertently. All usage must be bracketed with
The dt-platdata.c file contains the device declarations and is is built in
spl/dt-platdata.c.
-Some phandles (thsoe that are recognised as such) are converted into
-points to platform data. This pointer can potentially be used to access the
-referenced device (by searching for the pointer value). This feature is not
-yet implemented, however.
-
The beginnings of a libfdt Python module are provided. So far this only
implements a subset of the features.
diff --git a/drivers/clk/clk_stm32mp1.c b/drivers/clk/clk_stm32mp1.c
index b7c5d34fe0..aebc6f0a34 100644
--- a/drivers/clk/clk_stm32mp1.c
+++ b/drivers/clk/clk_stm32mp1.c
@@ -165,6 +165,7 @@
/* used for ALL PLLNCR registers */
#define RCC_PLLNCR_PLLON BIT(0)
#define RCC_PLLNCR_PLLRDY BIT(1)
+#define RCC_PLLNCR_SSCG_CTRL BIT(2)
#define RCC_PLLNCR_DIVPEN BIT(4)
#define RCC_PLLNCR_DIVQEN BIT(5)
#define RCC_PLLNCR_DIVREN BIT(6)
@@ -241,7 +242,6 @@ enum stm32mp1_parent_id {
_LSI,
_LSE,
_I2S_CKIN,
- _USB_PHY_48,
NB_OSC,
/* other parent source */
@@ -273,6 +273,7 @@ enum stm32mp1_parent_id {
_CK_MPU,
_CK_MCU,
_DSI_PHY,
+ _USB_PHY_48,
_PARENT_NB,
_UNKNOWN_ID = 0xff,
};
@@ -536,6 +537,7 @@ static const struct stm32mp1_clk_gate stm32mp1_clk_gate[] = {
STM32MP1_CLK_SET_CLR(RCC_MP_AHB2ENSETR, 16, SDMMC3_K, _SDMMC3_SEL),
STM32MP1_CLK_SET_CLR(RCC_MP_AHB3ENSETR, 11, HSEM, _UNKNOWN_SEL),
+ STM32MP1_CLK_SET_CLR(RCC_MP_AHB3ENSETR, 12, IPCC, _UNKNOWN_SEL),
STM32MP1_CLK_SET_CLR(RCC_MP_AHB4ENSETR, 0, GPIOA, _UNKNOWN_SEL),
STM32MP1_CLK_SET_CLR(RCC_MP_AHB4ENSETR, 1, GPIOB, _UNKNOWN_SEL),
@@ -665,8 +667,8 @@ static const u8 stm32mp1_axi_div[8] = {
1, 2, 3, 4, 4, 4, 4, 4
};
-#ifdef DEBUG
-static const char * const stm32mp1_clk_parent_name[_PARENT_NB] = {
+static const __maybe_unused
+char * const stm32mp1_clk_parent_name[_PARENT_NB] = {
[_HSI] = "HSI",
[_HSE] = "HSE",
[_CSI] = "CSI",
@@ -704,7 +706,8 @@ static const char * const stm32mp1_clk_parent_name[_PARENT_NB] = {
[_DSI_PHY] = "DSI_PHY_PLL",
};
-static const char * const stm32mp1_clk_parent_sel_name[_PARENT_SEL_NB] = {
+static const __maybe_unused
+char * const stm32mp1_clk_parent_sel_name[_PARENT_SEL_NB] = {
[_I2C12_SEL] = "I2C12",
[_I2C35_SEL] = "I2C35",
[_I2C46_SEL] = "I2C46",
@@ -723,7 +726,6 @@ static const char * const stm32mp1_clk_parent_sel_name[_PARENT_SEL_NB] = {
[_DSI_SEL] = "DSI",
[_ADC12_SEL] = "ADC12",
};
-#endif
static const struct stm32mp1_clk_data stm32mp1_data = {
.gate = stm32mp1_clk_gate,
@@ -1079,7 +1081,7 @@ static ulong stm32mp1_clk_get(struct stm32mp1_clk_priv *priv, int p)
break;
/* other */
case _USB_PHY_48:
- clock = stm32mp1_clk_get_fixed(priv, _USB_PHY_48);
+ clock = 48000000;
break;
case _DSI_PHY:
{
@@ -1179,10 +1181,7 @@ static void stm32mp1_ls_osc_set(int enable, fdt_addr_t rcc, u32 offset,
static void stm32mp1_hs_ocs_set(int enable, fdt_addr_t rcc, u32 mask_on)
{
- if (enable)
- setbits_le32(rcc + RCC_OCENSETR, mask_on);
- else
- setbits_le32(rcc + RCC_OCENCLRR, mask_on);
+ writel(mask_on, rcc + (enable ? RCC_OCENSETR : RCC_OCENCLRR));
}
static int stm32mp1_osc_wait(int enable, fdt_addr_t rcc, u32 offset,
@@ -1253,20 +1252,20 @@ static void stm32mp1_lsi_set(fdt_addr_t rcc, int enable)
static void stm32mp1_hse_enable(fdt_addr_t rcc, int bypass, int digbyp, int css)
{
if (digbyp)
- setbits_le32(rcc + RCC_OCENSETR, RCC_OCENR_DIGBYP);
+ writel(RCC_OCENR_DIGBYP, rcc + RCC_OCENSETR);
if (bypass || digbyp)
- setbits_le32(rcc + RCC_OCENSETR, RCC_OCENR_HSEBYP);
+ writel(RCC_OCENR_HSEBYP, rcc + RCC_OCENSETR);
stm32mp1_hs_ocs_set(1, rcc, RCC_OCENR_HSEON);
stm32mp1_osc_wait(1, rcc, RCC_OCRDYR, RCC_OCRDYR_HSERDY);
if (css)
- setbits_le32(rcc + RCC_OCENSETR, RCC_OCENR_HSECSSON);
+ writel(RCC_OCENR_HSECSSON, rcc + RCC_OCENSETR);
}
static void stm32mp1_csi_set(fdt_addr_t rcc, int enable)
{
- stm32mp1_ls_osc_set(enable, rcc, RCC_OCENSETR, RCC_OCENR_CSION);
+ stm32mp1_hs_ocs_set(enable, rcc, RCC_OCENR_CSION);
stm32mp1_osc_wait(enable, rcc, RCC_OCRDYR, RCC_OCRDYR_CSIRDY);
}
@@ -1321,7 +1320,10 @@ static void pll_start(struct stm32mp1_clk_priv *priv, int pll_id)
{
const struct stm32mp1_clk_pll *pll = priv->data->pll;
- writel(RCC_PLLNCR_PLLON, priv->base + pll[pll_id].pllxcr);
+ clrsetbits_le32(priv->base + pll[pll_id].pllxcr,
+ RCC_PLLNCR_DIVPEN | RCC_PLLNCR_DIVQEN |
+ RCC_PLLNCR_DIVREN,
+ RCC_PLLNCR_PLLON);
}
static int pll_output(struct stm32mp1_clk_priv *priv, int pll_id, int output)
@@ -1440,6 +1442,8 @@ static void pll_csg(struct stm32mp1_clk_priv *priv, int pll_id, u32 *csg)
RCC_PLLNCSGR_SSCG_MODE_MASK);
writel(pllxcsg, priv->base + pll[pll_id].pllxcsgr);
+
+ setbits_le32(priv->base + pll[pll_id].pllxcr, RCC_PLLNCR_SSCG_CTRL);
}
static int set_clksrc(struct stm32mp1_clk_priv *priv, unsigned int clksrc)
@@ -1471,10 +1475,15 @@ static void stgen_config(struct stm32mp1_clk_priv *priv)
rate = stm32mp1_clk_get(priv, p);
if (cntfid0 != rate) {
+ u64 counter;
+
pr_debug("System Generic Counter (STGEN) update\n");
clrbits_le32(stgenc + STGENC_CNTCR, STGENC_CNTCR_EN);
- writel(0x0, stgenc + STGENC_CNTCVL);
- writel(0x0, stgenc + STGENC_CNTCVU);
+ counter = (u64)readl(stgenc + STGENC_CNTCVL);
+ counter |= ((u64)(readl(stgenc + STGENC_CNTCVU))) << 32;
+ counter = lldiv(counter * (u64)rate, cntfid0);
+ writel((u32)counter, stgenc + STGENC_CNTCVL);
+ writel((u32)(counter >> 32), stgenc + STGENC_CNTCVU);
writel(rate, stgenc + STGENC_CNTFID0);
setbits_le32(stgenc + STGENC_CNTCR, STGENC_CNTCR_EN);
@@ -1859,7 +1868,7 @@ static void stm32mp1_osc_init(struct udevice *dev)
[_HSE] = "clk-hse",
[_CSI] = "clk-csi",
[_I2S_CKIN] = "i2s_ckin",
- [_USB_PHY_48] = "ck_usbo_48m"};
+ };
for (i = 0; i < NB_OSC; i++) {
stm32mp1_osc_clk_init(name[i], priv, i);
@@ -1867,6 +1876,54 @@ static void stm32mp1_osc_init(struct udevice *dev)
}
}
+static void __maybe_unused stm32mp1_clk_dump(struct stm32mp1_clk_priv *priv)
+{
+ char buf[32];
+ int i, s, p;
+
+ printf("Clocks:\n");
+ for (i = 0; i < _PARENT_NB; i++) {
+ printf("- %s : %s MHz\n",
+ stm32mp1_clk_parent_name[i],
+ strmhz(buf, stm32mp1_clk_get(priv, i)));
+ }
+ printf("Source Clocks:\n");
+ for (i = 0; i < _PARENT_SEL_NB; i++) {
+ p = (readl(priv->base + priv->data->sel[i].offset) >>
+ priv->data->sel[i].src) & priv->data->sel[i].msk;
+ if (p < priv->data->sel[i].nb_parent) {
+ s = priv->data->sel[i].parent[p];
+ printf("- %s(%d) => parent %s(%d)\n",
+ stm32mp1_clk_parent_sel_name[i], i,
+ stm32mp1_clk_parent_name[s], s);
+ } else {
+ printf("- %s(%d) => parent index %d is invalid\n",
+ stm32mp1_clk_parent_sel_name[i], i, p);
+ }
+ }
+}
+
+#ifdef CONFIG_CMD_CLK
+int soc_clk_dump(void)
+{
+ struct udevice *dev;
+ struct stm32mp1_clk_priv *priv;
+ int ret;
+
+ ret = uclass_get_device_by_driver(UCLASS_CLK,
+ DM_GET_DRIVER(stm32mp1_clock),
+ &dev);
+ if (ret)
+ return ret;
+
+ priv = dev_get_priv(dev);
+
+ stm32mp1_clk_dump(priv);
+
+ return 0;
+}
+#endif
+
static int stm32mp1_clk_probe(struct udevice *dev)
{
int result = 0;
@@ -1890,6 +1947,33 @@ static int stm32mp1_clk_probe(struct udevice *dev)
result = stm32mp1_clktree(dev);
#endif
+#ifndef CONFIG_SPL_BUILD
+#if defined(DEBUG)
+ /* display debug information for probe after relocation */
+ if (gd->flags & GD_FLG_RELOC)
+ stm32mp1_clk_dump(priv);
+#endif
+
+#if defined(CONFIG_DISPLAY_CPUINFO)
+ if (gd->flags & GD_FLG_RELOC) {
+ char buf[32];
+
+ printf("Clocks:\n");
+ printf("- MPU : %s MHz\n",
+ strmhz(buf, stm32mp1_clk_get(priv, _CK_MPU)));
+ printf("- MCU : %s MHz\n",
+ strmhz(buf, stm32mp1_clk_get(priv, _CK_MCU)));
+ printf("- AXI : %s MHz\n",
+ strmhz(buf, stm32mp1_clk_get(priv, _ACLK)));
+ printf("- PER : %s MHz\n",
+ strmhz(buf, stm32mp1_clk_get(priv, _CK_PER)));
+ /* DDRPHYC father */
+ printf("- DDR : %s MHz\n",
+ strmhz(buf, stm32mp1_clk_get(priv, _PLL2_R)));
+ }
+#endif /* CONFIG_DISPLAY_CPUINFO */
+#endif
+
return result;
}
diff --git a/drivers/core/of_access.c b/drivers/core/of_access.c
index 14c020a687..945b81448c 100644
--- a/drivers/core/of_access.c
+++ b/drivers/core/of_access.c
@@ -812,6 +812,24 @@ int of_alias_get_id(const struct device_node *np, const char *stem)
return id;
}
+int of_alias_get_highest_id(const char *stem)
+{
+ struct alias_prop *app;
+ int id = -1;
+
+ mutex_lock(&of_mutex);
+ list_for_each_entry(app, &aliases_lookup, link) {
+ if (strcmp(app->stem, stem) != 0)
+ continue;
+
+ if (app->id > id)
+ id = app->id;
+ }
+ mutex_unlock(&of_mutex);
+
+ return id;
+}
+
struct device_node *of_get_stdout(void)
{
return of_stdout;
diff --git a/drivers/core/read.c b/drivers/core/read.c
index 3c46b3674e..6bda077a34 100644
--- a/drivers/core/read.c
+++ b/drivers/core/read.c
@@ -264,3 +264,11 @@ u64 dev_translate_address(struct udevice *dev, const fdt32_t *in_addr)
{
return ofnode_translate_address(dev_ofnode(dev), in_addr);
}
+
+int dev_read_alias_highest_id(const char *stem)
+{
+ if (of_live_active())
+ return of_alias_get_highest_id(stem);
+
+ return fdtdec_get_alias_highest_id(gd->fdt_blob, stem);
+}
diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c
index a622f07941..fc3157de39 100644
--- a/drivers/core/uclass.c
+++ b/drivers/core/uclass.c
@@ -225,7 +225,7 @@ int uclass_find_first_device(enum uclass_id id, struct udevice **devp)
if (ret)
return ret;
if (list_empty(&uc->dev_head))
- return 0;
+ return -ENODEV;
*devp = list_first_entry(&uc->dev_head, struct udevice, uclass_node);
diff --git a/drivers/i2c/i2c-uclass.c b/drivers/i2c/i2c-uclass.c
index 975318e5f2..49e23a0a4b 100644
--- a/drivers/i2c/i2c-uclass.c
+++ b/drivers/i2c/i2c-uclass.c
@@ -619,13 +619,61 @@ static int i2c_child_post_bind(struct udevice *dev)
#endif
}
+struct i2c_priv {
+ int max_id;
+};
+
+static int i2c_post_bind(struct udevice *dev)
+{
+ struct uclass *class = dev->uclass;
+ struct i2c_priv *priv = class->priv;
+ int ret = 0;
+
+ /* Just for sure */
+ if (!priv)
+ return -ENOMEM;
+
+ debug("%s: %s, req_seq=%d\n", __func__, dev->name, dev->req_seq);
+
+ /* if there is no alias ID, use the first free */
+ if (dev->req_seq == -1)
+ dev->req_seq = ++priv->max_id;
+
+ debug("%s: %s, new req_seq=%d\n", __func__, dev->name, dev->req_seq);
+
+#if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
+ ret = dm_scan_fdt_dev(dev);
+#endif
+ return ret;
+}
+
+int i2c_uclass_init(struct uclass *class)
+{
+ struct i2c_priv *priv = class->priv;
+
+ /* Just for sure */
+ if (!priv)
+ return -ENOMEM;
+
+ /* Get the last allocated alias. */
+#if CONFIG_IS_ENABLED(OF_CONTROL)
+ priv->max_id = dev_read_alias_highest_id("i2c");
+#else
+ priv->max_id = -1;
+#endif
+
+ debug("%s: highest alias id is %d\n", __func__, priv->max_id);
+
+ return 0;
+}
+
UCLASS_DRIVER(i2c) = {
.id = UCLASS_I2C,
.name = "i2c",
.flags = DM_UC_FLAG_SEQ_ALIAS,
-#if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
- .post_bind = dm_scan_fdt_dev,
-#endif
+ .post_bind = i2c_post_bind,
+ .init = i2c_uclass_init,
+ .priv_auto_alloc_size = sizeof(struct i2c_priv),
.post_probe = i2c_post_probe,
.per_device_auto_alloc_size = sizeof(struct dm_i2c_bus),
.per_child_platdata_auto_alloc_size = sizeof(struct dm_i2c_chip),
diff --git a/drivers/i2c/muxes/i2c-mux-uclass.c b/drivers/i2c/muxes/i2c-mux-uclass.c
index a680ee1762..8b1149997a 100644
--- a/drivers/i2c/muxes/i2c-mux-uclass.c
+++ b/drivers/i2c/muxes/i2c-mux-uclass.c
@@ -59,11 +59,34 @@ static int i2c_mux_post_bind(struct udevice *mux)
dev_for_each_subnode(node, mux) {
struct udevice *dev;
const char *name;
+ const char *arrow = "->";
+ char *full_name;
+ int parent_name_len, arrow_len, mux_name_len, name_len;
name = ofnode_get_name(node);
- ret = device_bind_driver_to_node(mux, "i2c_mux_bus_drv", name,
- node, &dev);
- debug(" - bind ret=%d, %s\n", ret, dev ? dev->name : NULL);
+
+ /* Calculate lenghts of strings */
+ parent_name_len = strlen(mux->parent->name);
+ arrow_len = strlen(arrow);
+ mux_name_len = strlen(mux->name);
+ name_len = strlen(name);
+
+ full_name = calloc(1, parent_name_len + arrow_len +
+ mux_name_len + arrow_len + name_len + 1);
+ if (!full_name)
+ return -ENOMEM;
+
+ /* Compose bus name */
+ strcat(full_name, mux->parent->name);
+ strcat(full_name, arrow);
+ strcat(full_name, mux->name);
+ strcat(full_name, arrow);
+ strcat(full_name, name);
+
+ ret = device_bind_driver_to_node(mux, "i2c_mux_bus_drv",
+ full_name, node, &dev);
+ debug(" - bind ret=%d, %s, req_seq %d\n", ret,
+ dev ? dev->name : NULL, dev->req_seq);
if (ret)
return ret;
}
diff --git a/drivers/misc/misc-uclass.c b/drivers/misc/misc-uclass.c
index f240cda5c0..55381edc98 100644
--- a/drivers/misc/misc-uclass.c
+++ b/drivers/misc/misc-uclass.c
@@ -68,4 +68,7 @@ int misc_set_enabled(struct udevice *dev, bool val)
UCLASS_DRIVER(misc) = {
.id = UCLASS_MISC,
.name = "misc",
+#if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
+ .post_bind = dm_scan_fdt_dev,
+#endif
};
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 84d157ff40..b04345a1e1 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -724,7 +724,8 @@ static int mmc_send_ext_csd(struct mmc *mmc, u8 *ext_csd)
return err;
}
-int mmc_switch(struct mmc *mmc, u8 set, u8 index, u8 value)
+static int __mmc_switch(struct mmc *mmc, u8 set, u8 index, u8 value,
+ bool send_status)
{
struct mmc_cmd cmd;
int timeout = 1000;
@@ -740,19 +741,29 @@ int mmc_switch(struct mmc *mmc, u8 set, u8 index, u8 value)
while (retries > 0) {
ret = mmc_send_cmd(mmc, &cmd, NULL);
- /* Waiting for the ready status */
- if (!ret) {
- ret = mmc_send_status(mmc, timeout);
- return ret;
+ if (ret) {
+ retries--;
+ continue;
+ }
+
+ if (!send_status) {
+ mdelay(50);
+ return 0;
}
- retries--;
+ /* Waiting for the ready status */
+ return mmc_send_status(mmc, timeout);
}
return ret;
}
+int mmc_switch(struct mmc *mmc, u8 set, u8 index, u8 value)
+{
+ return __mmc_switch(mmc, set, index, value, true);
+}
+
#if !CONFIG_IS_ENABLED(MMC_TINY)
static int mmc_set_card_speed(struct mmc *mmc, enum bus_mode mode,
bool hsdowngrade)
@@ -784,8 +795,9 @@ static int mmc_set_card_speed(struct mmc *mmc, enum bus_mode mode,
default:
return -EINVAL;
}
- err = mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_HS_TIMING,
- speed_bits);
+
+ err = __mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_HS_TIMING,
+ speed_bits, !hsdowngrade);
if (err)
return err;
diff --git a/drivers/mmc/omap_hsmmc.c b/drivers/mmc/omap_hsmmc.c
index 5cb97eb02a..826a39fad7 100644
--- a/drivers/mmc/omap_hsmmc.c
+++ b/drivers/mmc/omap_hsmmc.c
@@ -47,6 +47,7 @@
#endif
#include <dm.h>
#include <power/regulator.h>
+#include <thermal.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -470,21 +471,21 @@ static int omap_hsmmc_set_io_regulator(struct mmc *mmc, int mV)
return 0;
/* Disable PBIAS */
- ret = regulator_set_enable(priv->pbias_supply, false);
- if (ret && ret != -ENOSYS)
+ ret = regulator_set_enable_if_allowed(priv->pbias_supply, false);
+ if (ret)
return ret;
/* Turn off IO voltage */
- ret = regulator_set_enable(mmc->vqmmc_supply, false);
- if (ret && ret != -ENOSYS)
+ ret = regulator_set_enable_if_allowed(mmc->vqmmc_supply, false);
+ if (ret)
return ret;
/* Program a new IO voltage value */
ret = regulator_set_value(mmc->vqmmc_supply, uV);
if (ret)
return ret;
/* Turn on IO voltage */
- ret = regulator_set_enable(mmc->vqmmc_supply, true);
- if (ret && ret != -ENOSYS)
+ ret = regulator_set_enable_if_allowed(mmc->vqmmc_supply, true);
+ if (ret)
return ret;
/* Program PBIAS voltage*/
@@ -492,8 +493,8 @@ static int omap_hsmmc_set_io_regulator(struct mmc *mmc, int mV)
if (ret && ret != -ENOSYS)
return ret;
/* Enable PBIAS */
- ret = regulator_set_enable(priv->pbias_supply, true);
- if (ret && ret != -ENOSYS)
+ ret = regulator_set_enable_if_allowed(priv->pbias_supply, true);
+ if (ret)
return ret;
return 0;
@@ -622,6 +623,10 @@ static int omap_hsmmc_execute_tuning(struct udevice *dev, uint opcode)
u32 phase_delay = 0;
u32 start_window = 0, max_window = 0;
u32 length = 0, max_len = 0;
+ bool single_point_failure = false;
+ struct udevice *thermal_dev;
+ int temperature;
+ int i;
mmc_base = priv->base_addr;
val = readl(&mmc_base->capa2);
@@ -632,9 +637,25 @@ static int omap_hsmmc_execute_tuning(struct udevice *dev, uint opcode)
((mmc->selected_mode == UHS_SDR50) && (val & CAPA2_TSDR50))))
return 0;
+ ret = uclass_first_device(UCLASS_THERMAL, &thermal_dev);
+ if (ret) {
+ printf("Couldn't get thermal device for tuning\n");
+ return ret;
+ }
+ ret = thermal_get_temp(thermal_dev, &temperature);
+ if (ret) {
+ printf("Couldn't get temperature for tuning\n");
+ return ret;
+ }
val = readl(&mmc_base->dll);
val |= DLL_SWT;
writel(val, &mmc_base->dll);
+
+ /*
+ * Stage 1: Search for a maximum pass window ignoring any
+ * any single point failures. If the tuning value ends up
+ * near it, move away from it in stage 2 below
+ */
while (phase_delay <= MAX_PHASE_DELAY) {
omap_hsmmc_set_dll(mmc, phase_delay);
@@ -643,10 +664,16 @@ static int omap_hsmmc_execute_tuning(struct udevice *dev, uint opcode)
if (cur_match) {
if (prev_match) {
length++;
+ } else if (single_point_failure) {
+ /* ignore single point failure */
+ length++;
+ single_point_failure = false;
} else {
start_window = phase_delay;
length = 1;
}
+ } else {
+ single_point_failure = prev_match;
}
if (length > max_len) {
@@ -668,8 +695,71 @@ static int omap_hsmmc_execute_tuning(struct udevice *dev, uint opcode)
ret = -EIO;
goto tuning_error;
}
+ /*
+ * Assign tuning value as a ratio of maximum pass window based
+ * on temperature
+ */
+ if (temperature < -20000)
+ phase_delay = min(max_window + 4 * max_len - 24,
+ max_window +
+ DIV_ROUND_UP(13 * max_len, 16) * 4);
+ else if (temperature < 20000)
+ phase_delay = max_window + DIV_ROUND_UP(9 * max_len, 16) * 4;
+ else if (temperature < 40000)
+ phase_delay = max_window + DIV_ROUND_UP(8 * max_len, 16) * 4;
+ else if (temperature < 70000)
+ phase_delay = max_window + DIV_ROUND_UP(7 * max_len, 16) * 4;
+ else if (temperature < 90000)
+ phase_delay = max_window + DIV_ROUND_UP(5 * max_len, 16) * 4;
+ else if (temperature < 120000)
+ phase_delay = max_window + DIV_ROUND_UP(4 * max_len, 16) * 4;
+ else
+ phase_delay = max_window + DIV_ROUND_UP(3 * max_len, 16) * 4;
+
+ /*
+ * Stage 2: Search for a single point failure near the chosen tuning
+ * value in two steps. First in the +3 to +10 range and then in the
+ * +2 to -10 range. If found, move away from it in the appropriate
+ * direction by the appropriate amount depending on the temperature.
+ */
+ for (i = 3; i <= 10; i++) {
+ omap_hsmmc_set_dll(mmc, phase_delay + i);
+ if (mmc_send_tuning(mmc, opcode, NULL)) {
+ if (temperature < 10000)
+ phase_delay += i + 6;
+ else if (temperature < 20000)
+ phase_delay += i - 12;
+ else if (temperature < 70000)
+ phase_delay += i - 8;
+ else if (temperature < 90000)
+ phase_delay += i - 6;
+ else
+ phase_delay += i - 6;
+
+ goto single_failure_found;
+ }
+ }
+
+ for (i = 2; i >= -10; i--) {
+ omap_hsmmc_set_dll(mmc, phase_delay + i);
+ if (mmc_send_tuning(mmc, opcode, NULL)) {
+ if (temperature < 10000)
+ phase_delay += i + 12;
+ else if (temperature < 20000)
+ phase_delay += i + 8;
+ else if (temperature < 70000)
+ phase_delay += i + 8;
+ else if (temperature < 90000)
+ phase_delay += i + 10;
+ else
+ phase_delay += i + 12;
+
+ goto single_failure_found;
+ }
+ }
+
+single_failure_found:
- phase_delay = max_window + 4 * ((3 * max_len) >> 2);
omap_hsmmc_set_dll(mmc, phase_delay);
mmc_reset_controller_fsm(mmc_base, SYSCTL_SRD);
diff --git a/drivers/mmc/renesas-sdhi.c b/drivers/mmc/renesas-sdhi.c
index 733b6d62f5..a556acd5cb 100644
--- a/drivers/mmc/renesas-sdhi.c
+++ b/drivers/mmc/renesas-sdhi.c
@@ -462,6 +462,16 @@ static void renesas_sdhi_filter_caps(struct udevice *dev)
priv->nrtaps = 4;
else
priv->nrtaps = 8;
+
+ /* H3 ES1.x and M3W ES1.0 uses bit 17 for DTRAEND */
+ if (((rmobile_get_cpu_type() == RMOBILE_CPU_TYPE_R8A7795) &&
+ (rmobile_get_cpu_rev_integer() <= 1)) ||
+ ((rmobile_get_cpu_type() == RMOBILE_CPU_TYPE_R8A7796) &&
+ (rmobile_get_cpu_rev_integer() == 1) &&
+ (rmobile_get_cpu_rev_fraction() == 0)))
+ priv->read_poll_flag = TMIO_SD_DMA_INFO1_END_RD;
+ else
+ priv->read_poll_flag = TMIO_SD_DMA_INFO1_END_RD2;
}
static int renesas_sdhi_probe(struct udevice *dev)
diff --git a/drivers/mmc/s5p_sdhci.c b/drivers/mmc/s5p_sdhci.c
index 591a3bce08..9dd0b865eb 100644
--- a/drivers/mmc/s5p_sdhci.c
+++ b/drivers/mmc/s5p_sdhci.c
@@ -118,9 +118,6 @@ int s5p_sdhci_init(u32 regbase, int index, int bus_width)
return s5p_sdhci_core_init(host);
}
-#if CONFIG_IS_ENABLED(OF_CONTROL)
-struct sdhci_host sdhci_host[SDHCI_MAX_HOSTS];
-
static int do_sdhci_init(struct sdhci_host *host)
{
int dev_id, flag, ret;
@@ -191,53 +188,6 @@ static int sdhci_get_config(const void *blob, int node, struct sdhci_host *host)
return 0;
}
-static int process_nodes(const void *blob, int node_list[], int count)
-{
- struct sdhci_host *host;
- int i, node, ret;
- int failed = 0;
-
- debug("%s: count = %d\n", __func__, count);
-
- /* build sdhci_host[] for each controller */
- for (i = 0; i < count; i++) {
- node = node_list[i];
- if (node <= 0)
- continue;
-
- host = &sdhci_host[i];
-
- ret = sdhci_get_config(blob, node, host);
- if (ret) {
- printf("%s: failed to decode dev %d (%d)\n", __func__, i, ret);
- failed++;
- continue;
- }
-
- ret = do_sdhci_init(host);
- if (ret && ret != -ENODEV) {
- printf("%s: failed to initialize dev %d (%d)\n", __func__, i, ret);
- failed++;
- }
- }
-
- /* we only consider it an error when all nodes fail */
- return (failed == count ? -1 : 0);
-}
-
-int exynos_mmc_init(const void *blob)
-{
- int count;
- int node_list[SDHCI_MAX_HOSTS];
-
- count = fdtdec_find_aliases_for_id(blob, "mmc",
- COMPAT_SAMSUNG_EXYNOS_MMC, node_list,
- SDHCI_MAX_HOSTS);
-
- return process_nodes(blob, node_list, count);
-}
-#endif
-
#ifdef CONFIG_DM_MMC
static int s5p_sdhci_probe(struct udevice *dev)
{
diff --git a/drivers/mmc/tmio-common.c b/drivers/mmc/tmio-common.c
index 201492001f..2421915a07 100644
--- a/drivers/mmc/tmio-common.c
+++ b/drivers/mmc/tmio-common.c
@@ -347,12 +347,10 @@ static int tmio_sd_dma_xfer(struct udevice *dev, struct mmc_data *data)
/*
* The DMA READ completion flag position differs on Socionext
* and Renesas SoCs. It is bit 20 on Socionext SoCs and using
- * bit 17 is a hardware bug and forbidden. It is bit 17 on
- * Renesas SoCs and bit 20 does not work on them.
+ * bit 17 is a hardware bug and forbidden. It is either bit 17
+ * or bit 20 on Renesas SoCs, depending on SoC.
*/
- poll_flag = (priv->caps & TMIO_SD_CAP_RCAR) ?
- TMIO_SD_DMA_INFO1_END_RD :
- TMIO_SD_DMA_INFO1_END_RD2;
+ poll_flag = priv->read_poll_flag;
tmp |= TMIO_SD_DMA_MODE_DIR_RD;
} else {
buf = (void *)data->src;
@@ -369,6 +367,9 @@ static int tmio_sd_dma_xfer(struct udevice *dev, struct mmc_data *data)
ret = tmio_sd_dma_wait_for_irq(dev, poll_flag, data->blocks);
+ if (poll_flag == TMIO_SD_DMA_INFO1_END_RD)
+ udelay(1);
+
__dma_unmap_single(dma_addr, len, dir);
return ret;
diff --git a/drivers/mmc/tmio-common.h b/drivers/mmc/tmio-common.h
index 192026ce3e..58ce3d65b0 100644
--- a/drivers/mmc/tmio-common.h
+++ b/drivers/mmc/tmio-common.h
@@ -119,6 +119,7 @@ struct tmio_sd_priv {
void __iomem *regbase;
unsigned int version;
u32 caps;
+ u32 read_poll_flag;
#define TMIO_SD_CAP_NONREMOVABLE BIT(0) /* Nonremovable e.g. eMMC */
#define TMIO_SD_CAP_DMA_INTERNAL BIT(1) /* have internal DMA engine */
#define TMIO_SD_CAP_DIV1024 BIT(2) /* divisor 1024 is available */
diff --git a/drivers/mmc/uniphier-sd.c b/drivers/mmc/uniphier-sd.c
index 6539880ab5..8f89bda233 100644
--- a/drivers/mmc/uniphier-sd.c
+++ b/drivers/mmc/uniphier-sd.c
@@ -47,6 +47,7 @@ static int uniphier_sd_probe(struct udevice *dev)
struct tmio_sd_priv *priv = dev_get_priv(dev);
priv->clk_get_rate = uniphier_sd_clk_get_rate;
+ priv->read_poll_flag = TMIO_SD_DMA_INFO1_END_RD2;
#ifndef CONFIG_SPL_BUILD
int ret;
diff --git a/drivers/pci/pcie_dw_mvebu.c b/drivers/pci/pcie_dw_mvebu.c
index 8081005c27..95fb41966f 100644
--- a/drivers/pci/pcie_dw_mvebu.c
+++ b/drivers/pci/pcie_dw_mvebu.c
@@ -489,7 +489,9 @@ static int pcie_dw_mvebu_probe(struct udevice *dev)
* using this GPIO.
*/
if (dm_gpio_is_valid(&reset_gpio)) {
- dm_gpio_set_value(&reset_gpio, 1);
+ dm_gpio_set_value(&reset_gpio, 1); /* assert */
+ mdelay(200);
+ dm_gpio_set_value(&reset_gpio, 0); /* de-assert */
mdelay(200);
}
#else
diff --git a/drivers/power/regulator/regulator-uclass.c b/drivers/power/regulator/regulator-uclass.c
index 39e46279d5..6f355b969a 100644
--- a/drivers/power/regulator/regulator-uclass.c
+++ b/drivers/power/regulator/regulator-uclass.c
@@ -113,11 +113,22 @@ int regulator_set_enable(struct udevice *dev, bool enable)
uc_pdata = dev_get_uclass_platdata(dev);
if (!enable && uc_pdata->always_on)
- return 0;
+ return -EACCES;
return ops->set_enable(dev, enable);
}
+int regulator_set_enable_if_allowed(struct udevice *dev, bool enable)
+{
+ int ret;
+
+ ret = regulator_set_enable(dev, enable);
+ if (ret == -ENOSYS || ret == -EACCES)
+ return 0;
+
+ return ret;
+}
+
int regulator_get_mode(struct udevice *dev)
{
const struct dm_regulator_ops *ops = dev_get_driver_ops(dev);
diff --git a/drivers/serial/serial_pl01x.c b/drivers/serial/serial_pl01x.c
index 12512f6578..2a5f256184 100644
--- a/drivers/serial/serial_pl01x.c
+++ b/drivers/serial/serial_pl01x.c
@@ -363,9 +363,7 @@ U_BOOT_DRIVER(serial_pl01x) = {
.platdata_auto_alloc_size = sizeof(struct pl01x_serial_platdata),
.probe = pl01x_serial_probe,
.ops = &pl01x_serial_ops,
-#if !CONFIG_IS_ENABLED(OF_CONTROL)
.flags = DM_FLAG_PRE_RELOC,
-#endif
.priv_auto_alloc_size = sizeof(struct pl01x_priv),
};
diff --git a/drivers/sound/Kconfig b/drivers/sound/Kconfig
index 22e379681d..40f4f7598a 100644
--- a/drivers/sound/Kconfig
+++ b/drivers/sound/Kconfig
@@ -32,7 +32,7 @@ config I2S_ROCKCHIP
config I2S_SAMSUNG
bool "Enable I2C support for Samsung SoCs"
- depends on SOUND
+ depends on I2S
help
Samsung Exynos SoCs support an I2S interface for sending audio
data to an audio codec. This option enables support for this,
@@ -40,9 +40,17 @@ config I2S_SAMSUNG
option provides an implementation for sound_init() and
sound_play().
+config SOUND_MAX98088
+ bool "Support Maxim max98088 audio codec"
+ depends on I2S
+ help
+ Enable the max98088 audio codec. This is connected via I2S for
+ audio data and I2C for codec control. At present it only works
+ with the Samsung I2S driver.
+
config SOUND_MAX98090
bool "Support Maxim max98090 audio codec"
- depends on I2S_SAMSUNG
+ depends on I2S
help
Enable the max98090 audio codec. This is connected via I2S for
audio data and I2C for codec control. At present it only works
@@ -50,7 +58,7 @@ config SOUND_MAX98090
config SOUND_MAX98095
bool "Support Maxim max98095 audio codec"
- depends on I2S_SAMSUNG
+ depends on I2S
help
Enable the max98095 audio codec. This is connected via I2S for
audio data and I2C for codec control. At present it only works
diff --git a/drivers/sound/Makefile b/drivers/sound/Makefile
index d0bf51bab6..170e06ad53 100644
--- a/drivers/sound/Makefile
+++ b/drivers/sound/Makefile
@@ -12,5 +12,6 @@ obj-$(CONFIG_SOUND_SANDBOX) += sandbox.o
obj-$(CONFIG_I2S_ROCKCHIP) += rockchip_i2s.o rockchip_sound.o
obj-$(CONFIG_I2S_SAMSUNG) += samsung_sound.o
obj-$(CONFIG_SOUND_WM8994) += wm8994.o
+obj-$(CONFIG_SOUND_MAX98088) += max98088.o maxim_codec.o
obj-$(CONFIG_SOUND_MAX98090) += max98090.o maxim_codec.o
obj-$(CONFIG_SOUND_MAX98095) += max98095.o maxim_codec.o
diff --git a/drivers/sound/max98088.c b/drivers/sound/max98088.c
new file mode 100644
index 0000000000..332254d5aa
--- /dev/null
+++ b/drivers/sound/max98088.c
@@ -0,0 +1,424 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * max98088.c -- MAX98088 ALSA SoC Audio driver
+ *
+ * Copyright 2010 Maxim Integrated Products
+ *
+ * Modified for U-Boot by Chih-Chung Chang (chihchung@chromium.org),
+ * following the changes made in max98095.c
+ */
+
+#include <common.h>
+#include <audio_codec.h>
+#include <div64.h>
+#include <dm.h>
+#include <i2c.h>
+#include <i2s.h>
+#include <sound.h>
+#include <asm/gpio.h>
+#include "maxim_codec.h"
+#include "max98088.h"
+
+/* codec mclk clock divider coefficients. Index 0 is reserved. */
+static const int rate_table[] = {0, 8000, 11025, 16000, 22050, 24000, 32000,
+ 44100, 48000, 88200, 96000};
+
+/*
+ * codec mclk clock divider coefficients based on sampling rate
+ *
+ * @param rate sampling rate
+ * @param value address of indexvalue to be stored
+ *
+ * @return 0 for success or negative error code.
+ */
+static int rate_value(int rate, u8 *value)
+{
+ int i;
+
+ for (i = 1; i < ARRAY_SIZE(rate_table); i++) {
+ if (rate_table[i] >= rate) {
+ *value = i;
+ return 0;
+ }
+ }
+ *value = 1;
+
+ return -EINVAL;
+}
+
+/*
+ * Sets hw params for max98088
+ *
+ * @priv: max98088 information pointer
+ * @rate: Sampling rate
+ * @bits_per_sample: Bits per sample
+ *
+ * @return -EIO for error, 0 for success.
+ */
+int max98088_hw_params(struct maxim_priv *priv, unsigned int rate,
+ unsigned int bits_per_sample)
+{
+ int error;
+ u8 regval;
+
+ switch (bits_per_sample) {
+ case 16:
+ error = maxim_bic_or(priv, M98088_REG_DAI1_FORMAT,
+ M98088_DAI_WS, 0);
+ break;
+ case 24:
+ error = maxim_bic_or(priv, M98088_REG_DAI1_FORMAT,
+ M98088_DAI_WS, M98088_DAI_WS);
+ break;
+ default:
+ debug("%s: Illegal bits per sample %d.\n",
+ __func__, bits_per_sample);
+ return -EINVAL;
+ }
+
+ error |= maxim_bic_or(priv, M98088_REG_PWR_SYS, M98088_SHDNRUN, 0);
+
+ if (rate_value(rate, &regval)) {
+ debug("%s: Failed to set sample rate to %d.\n",
+ __func__, rate);
+ return -EIO;
+ }
+
+ error |= maxim_bic_or(priv, M98088_REG_DAI1_CLKMODE,
+ M98088_CLKMODE_MASK, regval << 4);
+ priv->rate = rate;
+
+ /* Update sample rate mode */
+ if (rate < 50000)
+ error |= maxim_bic_or(priv, M98088_REG_DAI1_FILTERS,
+ M98088_DAI_DHF, 0);
+ else
+ error |= maxim_bic_or(priv, M98088_REG_DAI1_FILTERS,
+ M98088_DAI_DHF, M98088_DAI_DHF);
+
+ error |= maxim_bic_or(priv, M98088_REG_PWR_SYS, M98088_SHDNRUN,
+ M98088_SHDNRUN);
+
+ if (error < 0) {
+ debug("%s: Error setting hardware params.\n", __func__);
+ return -EIO;
+ }
+ priv->rate = rate;
+
+ return 0;
+}
+
+/*
+ * Configures Audio interface system clock for the given frequency
+ *
+ * @priv: max98088 information
+ * @freq: Sampling frequency in Hz
+ *
+ * @return -EIO for error, 0 for success.
+ */
+int max98088_set_sysclk(struct maxim_priv *priv, unsigned int freq)
+{
+ int error = 0;
+ u8 pwr;
+
+ /* Requested clock frequency is already setup */
+ if (freq == priv->sysclk)
+ return 0;
+
+ /*
+ * Setup clocks for slave mode, and using the PLL
+ * PSCLK = 0x01 (when master clk is 10MHz to 20MHz)
+ * 0x02 (when master clk is 20MHz to 30MHz)..
+ */
+ if (freq >= 10000000 && freq < 20000000) {
+ error = maxim_i2c_write(priv, M98088_REG_SYS_CLK, 0x10);
+ } else if ((freq >= 20000000) && (freq < 30000000)) {
+ error = maxim_i2c_write(priv, M98088_REG_SYS_CLK, 0x20);
+ } else {
+ debug("%s: Invalid master clock frequency\n", __func__);
+ return -EIO;
+ }
+
+ error |= maxim_i2c_read(priv, M98088_REG_PWR_SYS, &pwr);
+ if (pwr & M98088_SHDNRUN) {
+ error |= maxim_bic_or(priv, M98088_REG_PWR_SYS,
+ M98088_SHDNRUN, 0);
+ error |= maxim_bic_or(priv, M98088_REG_PWR_SYS,
+ M98088_SHDNRUN, M98088_SHDNRUN);
+ }
+
+ debug("%s: Clock at %uHz\n", __func__, freq);
+ if (error < 0)
+ return -EIO;
+
+ priv->sysclk = freq;
+
+ return 0;
+}
+
+/*
+ * Sets Max98090 I2S format
+ *
+ * @priv: max98088 information
+ * @fmt: i2S format - supports a subset of the options defined in i2s.h.
+ *
+ * @return -EIO for error, 0 for success.
+ */
+int max98088_set_fmt(struct maxim_priv *priv, int fmt)
+{
+ u8 reg15val;
+ u8 reg14val = 0;
+ int error = 0;
+
+ if (fmt == priv->fmt)
+ return 0;
+
+ priv->fmt = fmt;
+
+ switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
+ case SND_SOC_DAIFMT_CBS_CFS:
+ /* Slave mode PLL */
+ error |= maxim_i2c_write(priv, M98088_REG_DAI1_CLKCFG_HI,
+ 0x80);
+ error |= maxim_i2c_write(priv, M98088_REG_DAI1_CLKCFG_LO,
+ 0x00);
+ break;
+ case SND_SOC_DAIFMT_CBM_CFM:
+ /* Set to master mode */
+ reg14val |= M98088_DAI_MAS;
+ break;
+ case SND_SOC_DAIFMT_CBS_CFM:
+ case SND_SOC_DAIFMT_CBM_CFS:
+ default:
+ debug("%s: Clock mode unsupported\n", __func__);
+ return -EINVAL;
+ }
+
+ switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
+ case SND_SOC_DAIFMT_I2S:
+ reg14val |= M98088_DAI_DLY;
+ break;
+ case SND_SOC_DAIFMT_LEFT_J:
+ break;
+ default:
+ debug("%s: Unrecognized format.\n", __func__);
+ return -EINVAL;
+ }
+
+ switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
+ case SND_SOC_DAIFMT_NB_NF:
+ break;
+ case SND_SOC_DAIFMT_NB_IF:
+ reg14val |= M98088_DAI_WCI;
+ break;
+ case SND_SOC_DAIFMT_IB_NF:
+ reg14val |= M98088_DAI_BCI;
+ break;
+ case SND_SOC_DAIFMT_IB_IF:
+ reg14val |= M98088_DAI_BCI | M98088_DAI_WCI;
+ break;
+ default:
+ debug("%s: Unrecognized inversion settings.\n", __func__);
+ return -EINVAL;
+ }
+
+ error |= maxim_bic_or(priv, M98088_REG_DAI1_FORMAT,
+ M98088_DAI_MAS | M98088_DAI_DLY | M98088_DAI_BCI |
+ M98088_DAI_WCI, reg14val);
+ reg15val = M98088_DAI_BSEL64;
+ error |= maxim_i2c_write(priv, M98088_REG_DAI1_CLOCK, reg15val);
+
+ if (error < 0) {
+ debug("%s: Error setting i2s format.\n", __func__);
+ return -EIO;
+ }
+
+ return 0;
+}
+
+/*
+ * max98088_reset() - reset the audio codec
+ *
+ * @priv: max98088 information
+ * @return -EIO for error, 0 for success.
+ */
+static int max98088_reset(struct maxim_priv *priv)
+{
+ int ret, i;
+ u8 val;
+
+ /*
+ * Reset to hardware default for registers, as there is not a soft
+ * reset hardware control register.
+ */
+ for (i = M98088_REG_IRQ_ENABLE; i <= M98088_REG_PWR_SYS; i++) {
+ switch (i) {
+ case M98088_REG_BIAS_CNTL:
+ val = 0xf0;
+ break;
+ case M98088_REG_DAC_BIAS2:
+ val = 0x0f;
+ break;
+ default:
+ val = 0;
+ }
+ ret = maxim_i2c_write(priv, i, val);
+ if (ret < 0) {
+ debug("%s: Failed to reset: %d\n", __func__, ret);
+ return ret;
+ }
+ }
+
+ return 0;
+}
+
+/**
+ * max98088_device_init() - Initialise max98088 codec device
+ *
+ * @priv: max98088 information
+ *
+ * @return -EIO for error, 0 for success.
+ */
+static int max98088_device_init(struct maxim_priv *priv)
+{
+ unsigned char id;
+ int error = 0;
+
+ /* reset the codec, the DSP core, and disable all interrupts */
+ error = max98088_reset(priv);
+ if (error != 0) {
+ debug("Reset\n");
+ return error;
+ }
+
+ /* initialize private data */
+ priv->sysclk = -1U;
+ priv->rate = -1U;
+ priv->fmt = -1U;
+
+ error = maxim_i2c_read(priv, M98088_REG_REV_ID, &id);
+ if (error < 0) {
+ debug("%s: Failure reading hardware revision: %d\n",
+ __func__, id);
+ return -EIO;
+ }
+ debug("%s: Hardware revision: %d\n", __func__, id);
+
+ return 0;
+}
+
+static int max98088_setup_interface(struct maxim_priv *priv)
+{
+ int error;
+
+ /* Reading interrupt status to clear them */
+ error = maxim_i2c_write(priv, M98088_REG_PWR_SYS, M98088_PWRSV);
+ error |= maxim_i2c_write(priv, M98088_REG_IRQ_ENABLE, 0x00);
+
+ /*
+ * initialize registers to hardware default configuring audio
+ * interface2 to DAI1
+ */
+ error |= maxim_i2c_write(priv, M98088_REG_MIX_DAC,
+ M98088_DAI1L_TO_DACL | M98088_DAI1R_TO_DACR);
+ error |= maxim_i2c_write(priv, M98088_REG_BIAS_CNTL, 0xF0);
+ error |= maxim_i2c_write(priv, M98088_REG_DAC_BIAS2, 0x0F);
+ error |= maxim_i2c_write(priv, M98088_REG_DAI1_IOCFG,
+ M98088_S2NORMAL | M98088_SDATA);
+
+ /*
+ * route DACL and DACR output to headphone and speakers
+ * Ordering: DACL, DACR, DACL, DACR
+ */
+ error |= maxim_i2c_write(priv, M98088_REG_MIX_SPK_LEFT, 1);
+ error |= maxim_i2c_write(priv, M98088_REG_MIX_SPK_RIGHT, 1);
+ error |= maxim_i2c_write(priv, M98088_REG_MIX_HP_LEFT, 1);
+ error |= maxim_i2c_write(priv, M98088_REG_MIX_HP_RIGHT, 1);
+
+ /* set volume: -12db */
+ error |= maxim_i2c_write(priv, M98088_REG_LVL_SPK_L, 0x0f);
+ error |= maxim_i2c_write(priv, M98088_REG_LVL_SPK_R, 0x0f);
+
+ /* set volume: -22db */
+ error |= maxim_i2c_write(priv, M98088_REG_LVL_HP_L, 0x0d);
+ error |= maxim_i2c_write(priv, M98088_REG_LVL_HP_R, 0x0d);
+
+ /* power enable */
+ error |= maxim_i2c_write(priv, M98088_REG_PWR_EN_OUT,
+ M98088_HPLEN | M98088_HPREN | M98088_SPLEN |
+ M98088_SPREN | M98088_DALEN | M98088_DAREN);
+ if (error < 0)
+ return -EIO;
+
+ return 0;
+}
+
+static int max98088_do_init(struct maxim_priv *priv, int sampling_rate,
+ int mclk_freq, int bits_per_sample)
+{
+ int ret = 0;
+
+ ret = max98088_setup_interface(priv);
+ if (ret < 0) {
+ debug("%s: max98088 setup interface failed\n", __func__);
+ return ret;
+ }
+
+ ret = max98088_set_sysclk(priv, mclk_freq);
+ if (ret < 0) {
+ debug("%s: max98088 codec set sys clock failed\n", __func__);
+ return ret;
+ }
+
+ ret = max98088_hw_params(priv, sampling_rate, bits_per_sample);
+
+ if (ret == 0) {
+ ret = max98088_set_fmt(priv, SND_SOC_DAIFMT_I2S |
+ SND_SOC_DAIFMT_NB_NF |
+ SND_SOC_DAIFMT_CBS_CFS);
+ }
+
+ return ret;
+}
+
+static int max98088_set_params(struct udevice *dev, int interface, int rate,
+ int mclk_freq, int bits_per_sample,
+ uint channels)
+{
+ struct maxim_priv *priv = dev_get_priv(dev);
+
+ return max98088_do_init(priv, rate, mclk_freq, bits_per_sample);
+}
+
+static int max98088_probe(struct udevice *dev)
+{
+ struct maxim_priv *priv = dev_get_priv(dev);
+ int ret;
+
+ priv->dev = dev;
+ ret = max98088_device_init(priv);
+ if (ret < 0) {
+ debug("%s: max98088 codec chip init failed\n", __func__);
+ return ret;
+ }
+
+ return 0;
+}
+
+static const struct audio_codec_ops max98088_ops = {
+ .set_params = max98088_set_params,
+};
+
+static const struct udevice_id max98088_ids[] = {
+ { .compatible = "maxim,max98088" },
+ { }
+};
+
+U_BOOT_DRIVER(max98088) = {
+ .name = "max98088",
+ .id = UCLASS_AUDIO_CODEC,
+ .of_match = max98088_ids,
+ .probe = max98088_probe,
+ .ops = &max98088_ops,
+ .priv_auto_alloc_size = sizeof(struct maxim_priv),
+};
diff --git a/drivers/sound/max98088.h b/drivers/sound/max98088.h
new file mode 100644
index 0000000000..127d2bda30
--- /dev/null
+++ b/drivers/sound/max98088.h
@@ -0,0 +1,192 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * max98088.h -- MAX98088 ALSA SoC Audio driver
+ *
+ * Copyright 2010 Maxim Integrated Products
+ */
+
+#ifndef _MAX98088_H
+#define _MAX98088_H
+
+/* MAX98088 Registers Definition */
+#define M98088_REG_IRQ_STATUS 0x00
+#define M98088_REG_MIC_STATUS 0x01
+#define M98088_REG_JACK_STAUS 0x02
+#define M98088_REG_BATTERY_VOLTAGE 0x03
+#define M98088_REG_IRQ_ENABLE 0x0f
+#define M98088_REG_SYS_CLK 0X10
+#define M98088_REG_DAI1_CLKMODE 0x11
+#define M98088_REG_DAI1_CLKCFG_HI 0x12
+#define M98088_REG_DAI1_CLKCFG_LO 0x13
+#define M98088_REG_DAI1_FORMAT 0x14
+#define M98088_REG_DAI1_CLOCK 0x15
+#define M98088_REG_DAI1_IOCFG 0x16
+#define M98088_REG_DAI1_TDM 0X17
+#define M98088_REG_DAI1_FILTERS 0x18
+#define M98088_REG_DAI2_CLKMODE 0x19
+#define M98088_REG_DAI2_CLKCFG_HI 0x1a
+#define M98088_REG_DAI2_CLKCFG_LO 0x1b
+#define M98088_REG_DAI2_FORMAT 0x1c
+#define M98088_REG_DAI2_CLOCK 0x1d
+#define M98088_REG_DAI2_IOCFG 0x1e
+#define M98088_REG_DAI2_TDM 0X1f
+#define M98088_REG_DAI2_FILTERS 0x20
+#define M98088_REG_SRC 0X21
+#define M98088_REG_MIX_DAC 0X22
+#define M98088_REG_MIX_ADC_LEFT 0x23
+#define M98088_REG_MIX_ADC_RIGHT 0x24
+#define M98088_REG_MIX_HP_LEFT 0x25
+#define M98088_REG_MIX_HP_RIGHT 0x26
+#define M98088_REG_MIX_HP_CNTL 0x27
+#define M98088_REG_MIX_REC_LEFT 0x28
+#define M98088_REG_MIX_REC_RIGHT 0x29
+#define M98088_REG_MIC_REC_CNTL 0x2a
+#define M98088_REG_MIX_SPK_LEFT 0x2b
+#define M98088_REG_MIX_SPK_RIGHT 0x2c
+#define M98088_REG_MIX_SPK_CNTL 0x2d
+#define M98088_REG_LVL_SIDETONE 0x2e
+#define M98088_REG_LVL_DAI1_PLAY 0x2f
+#define M98088_REG_LVL_DAI1_PLAY_EQ 0x30
+#define M98088_REG_LVL_DAI2_PLAY 0x31
+#define M98088_REG_LVL_DAI2_PLAY_EQ 0x32
+#define M98088_REG_LVL_ADC_L 0X33
+#define M98088_REG_LVL_ADC_R 0X34
+#define M98088_REG_LVL_MIC1 0X35
+#define M98088_REG_LVL_MIC2 0X36
+#define M98088_REG_LVL_INA 0X37
+#define M98088_REG_LVL_INB 0X38
+#define M98088_REG_LVL_HP_L 0X39
+#define M98088_REG_LVL_HP_R 0X3a
+#define M98088_REG_LVL_REC_L 0X3b
+#define M98088_REG_LVL_REC_R 0X3c
+#define M98088_REG_LVL_SPK_L 0X3d
+#define M98088_REG_LVL_SPK_R 0X3e
+#define M98088_REG_MICAGC_CFG 0x3f
+#define M98088_REG_MICAGC_THRESH 0x40
+#define M98088_REG_SPKDHP 0X41
+#define M98088_REG_SPKDHP_THRESH 0x42
+#define M98088_REG_SPKALC_COMP 0x43
+#define M98088_REG_PWRLMT_CFG 0x44
+#define M98088_REG_PWRLMT_TIME 0x45
+#define M98088_REG_THDLMT_CFG 0x46
+#define M98088_REG_CFG_AUDIO_IN 0x47
+#define M98088_REG_CFG_MIC 0X48
+#define M98088_REG_CFG_LEVEL 0X49
+#define M98088_REG_CFG_BYPASS 0x4a
+#define M98088_REG_CFG_JACKDET 0x4b
+#define M98088_REG_PWR_EN_IN 0X4c
+#define M98088_REG_PWR_EN_OUT 0x4d
+#define M98088_REG_BIAS_CNTL 0X4e
+#define M98088_REG_DAC_BIAS1 0X4f
+#define M98088_REG_DAC_BIAS2 0X50
+#define M98088_REG_PWR_SYS 0X51
+#define M98088_REG_DAI1_EQ_BASE 0x52
+#define M98088_REG_DAI2_EQ_BASE 0x84
+#define M98088_REG_DAI1_BIQUAD_BASE 0xb6
+#define M98088_REG_DAI2_BIQUAD_BASE 0xc0
+#define M98088_REG_REV_ID 0xff
+
+#define M98088_REG_CNT (0xff + 1)
+
+/* MAX98088 Registers Bit Fields */
+
+/* M98088_REG_11_DAI1_CLKMODE, M98088_REG_19_DAI2_CLKMODE */
+#define M98088_CLKMODE_MASK 0xFF
+
+/* M98088_REG_14_DAI1_FORMAT, M98088_REG_1C_DAI2_FORMAT */
+#define M98088_DAI_MAS BIT(7)
+#define M98088_DAI_WCI BIT(6)
+#define M98088_DAI_BCI BIT(5)
+#define M98088_DAI_DLY BIT(4)
+#define M98088_DAI_TDM BIT(2)
+#define M98088_DAI_FSW BIT(1)
+#define M98088_DAI_WS BIT(0)
+
+/* M98088_REG_15_DAI1_CLOCK, M98088_REG_1D_DAI2_CLOCK */
+#define M98088_DAI_BSEL64 BIT(0)
+#define M98088_DAI_OSR64 BIT(6)
+
+/* M98088_REG_16_DAI1_IOCFG, M98088_REG_1E_DAI2_IOCFG */
+#define M98088_S1NORMAL BIT(6)
+#define M98088_S2NORMAL (2 << 6)
+#define M98088_SDATA (3 << 0)
+
+/* M98088_REG_18_DAI1_FILTERS, M98088_REG_20_DAI2_FILTERS */
+#define M98088_DAI_DHF BIT(3)
+
+/* M98088_REG_22_MIX_DAC */
+#define M98088_DAI1L_TO_DACL BIT(7)
+#define M98088_DAI1R_TO_DACL BIT(6)
+#define M98088_DAI2L_TO_DACL BIT(5)
+#define M98088_DAI2R_TO_DACL BIT(4)
+#define M98088_DAI1L_TO_DACR BIT(3)
+#define M98088_DAI1R_TO_DACR BIT(2)
+#define M98088_DAI2L_TO_DACR BIT(1)
+#define M98088_DAI2R_TO_DACR BIT(0)
+
+/* M98088_REG_2A_MIC_REC_CNTL */
+#define M98088_REC_LINEMODE BIT(7)
+#define M98088_REC_LINEMODE_MASK BIT(7)
+
+/* M98088_REG_2D_MIX_SPK_CNTL */
+#define M98088_MIX_SPKR_GAIN_MASK (3 << 2)
+#define M98088_MIX_SPKR_GAIN_SHIFT 2
+#define M98088_MIX_SPKL_GAIN_MASK (3 << 0)
+#define M98088_MIX_SPKL_GAIN_SHIFT 0
+
+/* M98088_REG_2F_LVL_DAI1_PLAY, M98088_REG_31_LVL_DAI2_PLAY */
+#define M98088_DAI_MUTE BIT(7)
+#define M98088_DAI_MUTE_MASK BIT(7)
+#define M98088_DAI_VOICE_GAIN_MASK (3 << 4)
+#define M98088_DAI_ATTENUATION_MASK (0xf << 0)
+#define M98088_DAI_ATTENUATION_SHIFT 0
+
+/* M98088_REG_35_LVL_MIC1, M98088_REG_36_LVL_MIC2 */
+#define M98088_MICPRE_MASK (3 << 5)
+#define M98088_MICPRE_SHIFT 5
+
+/* M98088_REG_3A_LVL_HP_R */
+#define M98088_HP_MUTE BIT(7)
+
+/* M98088_REG_3C_LVL_REC_R */
+#define M98088_REC_MUTE BIT(7)
+
+/* M98088_REG_3E_LVL_SPK_R */
+#define M98088_SP_MUTE BIT(7)
+
+/* M98088_REG_48_CFG_MIC */
+#define M98088_EXTMIC_MASK (3 << 0)
+#define M98088_DIGMIC_L BIT(5)
+#define M98088_DIGMIC_R BIT(4)
+
+/* M98088_REG_49_CFG_LEVEL */
+#define M98088_VSEN BIT(6)
+#define M98088_ZDEN BIT(5)
+#define M98088_EQ2EN BIT(1)
+#define M98088_EQ1EN BIT(0)
+
+/* M98088_REG_4C_PWR_EN_IN */
+#define M98088_INAEN BIT(7)
+#define M98088_INBEN BIT(6)
+#define M98088_MBEN BIT(3)
+#define M98088_ADLEN BIT(1)
+#define M98088_ADREN BIT(0)
+
+/* M98088_REG_4D_PWR_EN_OUT */
+#define M98088_HPLEN BIT(7)
+#define M98088_HPREN BIT(6)
+#define M98088_HPEN (BIT(7) | BIT(6))
+#define M98088_SPLEN BIT(5)
+#define M98088_SPREN BIT(4)
+#define M98088_RECEN BIT(3)
+#define M98088_DALEN BIT(1)
+#define M98088_DAREN BIT(0)
+
+/* M98088_REG_51_PWR_SYS */
+#define M98088_SHDNRUN BIT(7)
+#define M98088_PERFMODE BIT(3)
+#define M98088_HPPLYBACK BIT(2)
+#define M98088_PWRSV8K BIT(1)
+#define M98088_PWRSV BIT(0)
+
+#endif
diff --git a/drivers/sound/max98090.c b/drivers/sound/max98090.c
index 346ff5ffbe..5505c35166 100644
--- a/drivers/sound/max98090.c
+++ b/drivers/sound/max98090.c
@@ -13,10 +13,6 @@
#include <i2s.h>
#include <sound.h>
#include <asm/gpio.h>
-#include <asm/io.h>
-#include <asm/arch/clk.h>
-#include <asm/arch/cpu.h>
-#include <asm/arch/power.h>
#include "maxim_codec.h"
#include "max98090.h"
@@ -240,9 +236,6 @@ int max98090_device_init(struct maxim_priv *priv)
unsigned char id;
int error = 0;
- /* Enable codec clock */
- set_xclkout();
-
/* reset the codec, the DSP core, and disable all interrupts */
error = max98090_reset(priv);
if (error != 0) {
diff --git a/drivers/sound/max98095.c b/drivers/sound/max98095.c
index 99c0e996b4..9e08e96670 100644
--- a/drivers/sound/max98095.c
+++ b/drivers/sound/max98095.c
@@ -15,10 +15,6 @@
#include <i2c.h>
#include <sound.h>
#include <asm/gpio.h>
-#include <asm/io.h>
-#include <asm/arch/clk.h>
-#include <asm/arch/cpu.h>
-#include <asm/arch/power.h>
#include "i2s.h"
#include "max98095.h"
@@ -306,9 +302,6 @@ static int max98095_device_init(struct maxim_priv *priv)
unsigned char id;
int ret;
- /* Enable codec clock */
- set_xclkout();
-
/* reset the codec, the DSP core, and disable all interrupts */
ret = max98095_reset(priv);
if (ret != 0) {
diff --git a/drivers/sound/maxim_codec.c b/drivers/sound/maxim_codec.c
index dcaf081988..5480dce108 100644
--- a/drivers/sound/maxim_codec.c
+++ b/drivers/sound/maxim_codec.c
@@ -12,9 +12,6 @@
#include <sound.h>
#include <asm/gpio.h>
#include <asm/io.h>
-#include <asm/arch/clk.h>
-#include <asm/arch/cpu.h>
-#include <asm/arch/power.h>
#include "maxim_codec.h"
/*
diff --git a/drivers/sound/samsung-i2s.c b/drivers/sound/samsung-i2s.c
index c19e08e7e3..104584073a 100644
--- a/drivers/sound/samsung-i2s.c
+++ b/drivers/sound/samsung-i2s.c
@@ -24,7 +24,7 @@
/*
* Sets the frame size for I2S LR clock
*
- * @param i2s_reg i2s regiter address
+ * @param i2s_reg i2s register address
* @param rfs Frame Size
*/
static void i2s_set_lr_framesize(struct i2s_reg *i2s_reg, unsigned int rfs)
@@ -54,7 +54,7 @@ static void i2s_set_lr_framesize(struct i2s_reg *i2s_reg, unsigned int rfs)
/*
* Sets the i2s transfer control
*
- * @param i2s_reg i2s regiter address
+ * @param i2s_reg i2s register address
* @param on 1 enable tx , 0 disable tx transfer
*/
static void i2s_txctrl(struct i2s_reg *i2s_reg, int on)
@@ -77,7 +77,7 @@ static void i2s_txctrl(struct i2s_reg *i2s_reg, int on)
/*
* set the bit clock frame size (in multiples of LRCLK)
*
- * @param i2s_reg i2s regiter address
+ * @param i2s_reg i2s register address
* @param bfs bit Frame Size
*/
static void i2s_set_bitclk_framesize(struct i2s_reg *i2s_reg, unsigned bfs)
@@ -108,7 +108,7 @@ static void i2s_set_bitclk_framesize(struct i2s_reg *i2s_reg, unsigned bfs)
/*
* flushes the i2stx fifo
*
- * @param i2s_reg i2s regiter address
+ * @param i2s_reg i2s register address
* @param flush Tx fifo flush command (0x00 - do not flush
* 0x80 - flush tx fifo)
*/
@@ -122,7 +122,7 @@ static void i2s_fifo(struct i2s_reg *i2s_reg, unsigned int flush)
/*
* Set System Clock direction
*
- * @param i2s_reg i2s regiter address
+ * @param i2s_reg i2s register address
* @param dir Clock direction
*
* @return int value 0 for success, -1 in case of error
@@ -145,7 +145,7 @@ static int i2s_set_sysclk_dir(struct i2s_reg *i2s_reg, int dir)
* Sets I2S Clcok format
*
* @param fmt i2s clock properties
- * @param i2s_reg i2s regiter address
+ * @param i2s_reg i2s register address
*
* @return int value 0 for success, -1 in case of error
*/
@@ -222,7 +222,7 @@ static int i2s_set_fmt(struct i2s_reg *i2s_reg, unsigned int fmt)
* Sets the sample width in bits
*
* @param blc samplewidth (size of sample in bits)
- * @param i2s_reg i2s regiter address
+ * @param i2s_reg i2s register address
*
* @return int value 0 for success, -1 in case of error
*/
@@ -294,7 +294,7 @@ int i2s_transfer_tx_data(struct i2s_uc_priv *pi2s_tx, void *data,
return 0;
}
-int i2s_tx_init(struct i2s_uc_priv *pi2s_tx)
+static int i2s_tx_init(struct i2s_uc_priv *pi2s_tx)
{
int ret;
struct i2s_reg *i2s_reg = (struct i2s_reg *)pi2s_tx->base_address;
diff --git a/drivers/sound/samsung_sound.c b/drivers/sound/samsung_sound.c
index 1d711c8732..b6952675bd 100644
--- a/drivers/sound/samsung_sound.c
+++ b/drivers/sound/samsung_sound.c
@@ -10,6 +10,7 @@
#include <i2s.h>
#include <sound.h>
#include <asm/gpio.h>
+#include <asm/arch/power.h>
static int samsung_sound_setup(struct udevice *dev)
{
@@ -79,6 +80,9 @@ static int samsung_sound_probe(struct udevice *dev)
debug("Probed sound '%s' with codec '%s' and i2s '%s'\n", dev->name,
uc_priv->codec->name, uc_priv->i2s->name);
+ /* Enable codec clock */
+ set_xclkout();
+
return 0;
}
@@ -89,7 +93,7 @@ static const struct sound_ops samsung_sound_ops = {
static const struct udevice_id samsung_sound_ids[] = {
{ .compatible = "google,snow-audio-max98095" },
- { .compatible = "google,spring-audio-max98095" },
+ { .compatible = "google,spring-audio-max98088" },
{ .compatible = "samsung,smdk5420-audio-wm8994" },
{ .compatible = "google,peach-audio-max98090" },
{ }
diff --git a/drivers/timer/tsc_timer.c b/drivers/timer/tsc_timer.c
index ba940ebf1c..919caba8a1 100644
--- a/drivers/timer/tsc_timer.c
+++ b/drivers/timer/tsc_timer.c
@@ -19,8 +19,59 @@
#define MAX_NUM_FREQS 9
+#define INTEL_FAM6_SKYLAKE_MOBILE 0x4E
+#define INTEL_FAM6_ATOM_GOLDMONT 0x5C /* Apollo Lake */
+#define INTEL_FAM6_SKYLAKE_DESKTOP 0x5E
+#define INTEL_FAM6_ATOM_GOLDMONT_X 0x5F /* Denverton */
+#define INTEL_FAM6_KABYLAKE_MOBILE 0x8E
+#define INTEL_FAM6_KABYLAKE_DESKTOP 0x9E
+
DECLARE_GLOBAL_DATA_PTR;
+/*
+ * native_calibrate_tsc
+ * Determine TSC frequency via CPUID, else return 0.
+ */
+static unsigned long native_calibrate_tsc(void)
+{
+ struct cpuid_result tsc_info;
+ unsigned int crystal_freq;
+
+ if (gd->arch.x86_vendor != X86_VENDOR_INTEL)
+ return 0;
+
+ if (cpuid_eax(0) < 0x15)
+ return 0;
+
+ tsc_info = cpuid(0x15);
+
+ if (tsc_info.ebx == 0 || tsc_info.eax == 0)
+ return 0;
+
+ crystal_freq = tsc_info.ecx / 1000;
+
+ if (!crystal_freq) {
+ switch (gd->arch.x86_model) {
+ case INTEL_FAM6_SKYLAKE_MOBILE:
+ case INTEL_FAM6_SKYLAKE_DESKTOP:
+ case INTEL_FAM6_KABYLAKE_MOBILE:
+ case INTEL_FAM6_KABYLAKE_DESKTOP:
+ crystal_freq = 24000; /* 24.0 MHz */
+ break;
+ case INTEL_FAM6_ATOM_GOLDMONT_X:
+ crystal_freq = 25000; /* 25.0 MHz */
+ break;
+ case INTEL_FAM6_ATOM_GOLDMONT:
+ crystal_freq = 19200; /* 19.2 MHz */
+ break;
+ default:
+ return 0;
+ }
+ }
+
+ return (crystal_freq * tsc_info.ebx / tsc_info.eax) / 1000;
+}
+
static unsigned long cpu_mhz_from_cpuid(void)
{
if (gd->arch.x86_vendor != X86_VENDOR_INTEL)
@@ -350,6 +401,10 @@ static void tsc_timer_ensure_setup(bool early)
if (!gd->arch.clock_rate) {
unsigned long fast_calibrate;
+ fast_calibrate = native_calibrate_tsc();
+ if (fast_calibrate)
+ goto done;
+
fast_calibrate = cpu_mhz_from_cpuid();
if (fast_calibrate)
goto done;
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index 10fd3039aa..115fc4551f 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -88,7 +88,7 @@ config WDT_ASPEED
config WDT_BCM6345
bool "BCM6345 watchdog timer support"
- depends on WDT && ARCH_BMIPS
+ depends on WDT && (ARCH_BMIPS || ARCH_BCM6858 || ARCH_BCM63158)
help
Select this to enable watchdog timer for BCM6345 SoCs.
The watchdog timer is stopped when initialized.
diff --git a/drivers/watchdog/bcm6345_wdt.c b/drivers/watchdog/bcm6345_wdt.c
index e1bd73dfd4..44f5662038 100644
--- a/drivers/watchdog/bcm6345_wdt.c
+++ b/drivers/watchdog/bcm6345_wdt.c
@@ -32,8 +32,8 @@ static int bcm6345_wdt_reset(struct udevice *dev)
{
struct bcm6345_wdt_priv *priv = dev_get_priv(dev);
- writel_be(WDT_CTL_START1_MASK, priv->regs + WDT_CTL_REG);
- writel_be(WDT_CTL_START2_MASK, priv->regs + WDT_CTL_REG);
+ writel(WDT_CTL_START1_MASK, priv->regs + WDT_CTL_REG);
+ writel(WDT_CTL_START2_MASK, priv->regs + WDT_CTL_REG);
return 0;
}
@@ -50,7 +50,7 @@ static int bcm6345_wdt_start(struct udevice *dev, u64 timeout, ulong flags)
timeout = WDT_VAL_MAX;
}
- writel_be(timeout, priv->regs + WDT_VAL_REG);
+ writel(timeout, priv->regs + WDT_VAL_REG);
return bcm6345_wdt_reset(dev);
}
@@ -64,8 +64,8 @@ static int bcm6345_wdt_stop(struct udevice *dev)
{
struct bcm6345_wdt_priv *priv = dev_get_priv(dev);
- writel_be(WDT_CTL_STOP1_MASK, priv->regs + WDT_CTL_REG);
- writel_be(WDT_CTL_STOP2_MASK, priv->regs + WDT_CTL_REG);
+ writel(WDT_CTL_STOP1_MASK, priv->regs + WDT_CTL_REG);
+ writel(WDT_CTL_STOP2_MASK, priv->regs + WDT_CTL_REG);
return 0;
}
diff --git a/dts/Kconfig b/dts/Kconfig
index 8917f42444..3e85914d11 100644
--- a/dts/Kconfig
+++ b/dts/Kconfig
@@ -265,8 +265,7 @@ config SPL_OF_PLATDATA
This option works by generating C structure declarations for each
compatible string, then adding platform data and U_BOOT_DEVICE
- declarations for each node. See README.platdata for more
- information.
+ declarations for each node. See of-plat.txt for more information.
config TPL_OF_PLATDATA
bool "Generate platform data for use in TPL"
@@ -287,8 +286,7 @@ config TPL_OF_PLATDATA
This option works by generating C structure declarations for each
compatible string, then adding platform data and U_BOOT_DEVICE
- declarations for each node. See README.platdata for more
- information.
+ declarations for each node. See of-plat.txt for more information.
endmenu
diff --git a/fs/fs.c b/fs/fs.c
index 0e9c2f1062..c5c35ebf5f 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -801,6 +801,8 @@ int do_fs_type(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
else
printf("%s\n", info->name);
+ fs_close();
+
return CMD_RET_SUCCESS;
}
diff --git a/include/bootm.h b/include/bootm.h
index dbd6f49c2d..e2cc6d4b99 100644
--- a/include/bootm.h
+++ b/include/bootm.h
@@ -82,4 +82,9 @@ int bootm_decomp_image(int comp, ulong load, ulong image_start, int type,
*/
void board_quiesce_devices(void);
+/**
+ * switch_to_non_secure_mode() - switch to non-secure mode
+ */
+void switch_to_non_secure_mode(void);
+
#endif
diff --git a/include/charset.h b/include/charset.h
index 4d45e246e5..65087f76d1 100644
--- a/include/charset.h
+++ b/include/charset.h
@@ -192,6 +192,29 @@ size_t u16_strlen(const u16 *in);
size_t u16_strnlen(const u16 *in, size_t count);
/**
+ * u16_strcpy() - copy u16 string
+ *
+ * Copy u16 string pointed to by src, including terminating null word, to
+ * the buffer pointed to by dest.
+ *
+ * @dest: destination buffer
+ * @src: source buffer (null terminated)
+ * Return: 'dest' address
+ */
+u16 *u16_strcpy(u16 *dest, const u16 *src);
+
+/**
+ * u16_strdup() - duplicate u16 string
+ *
+ * Copy u16 string pointed to by src, including terminating null word, to a
+ * newly allocated buffer.
+ *
+ * @src: source buffer (null terminated)
+ * Return: allocated new buffer on success, NULL on failure
+ */
+u16 *u16_strdup(const u16 *src);
+
+/**
* utf16_to_utf8() - Convert an utf16 string to utf8
*
* Converts 'size' characters of the utf16 string 'src' to utf8
diff --git a/include/config_distro_bootcmd.h b/include/config_distro_bootcmd.h
index 555efb7433..4993303f4d 100644
--- a/include/config_distro_bootcmd.h
+++ b/include/config_distro_bootcmd.h
@@ -27,7 +27,7 @@
#define BOOTENV_SHARED_BLKDEV_BODY(devtypel) \
"if " #devtypel " dev ${devnum}; then " \
- "setenv devtype " #devtypel "; " \
+ "devtype=" #devtypel "; " \
"run scan_dev_for_boot_part; " \
"fi\0"
@@ -37,7 +37,7 @@
#define BOOTENV_DEV_BLKDEV(devtypeu, devtypel, instance) \
"bootcmd_" #devtypel #instance "=" \
- "setenv devnum " #instance "; " \
+ "devnum=" #instance "; " \
"run " #devtypel "_boot\0"
#define BOOTENV_DEV_NAME_BLKDEV(devtypeu, devtypel, instance) \
@@ -77,7 +77,7 @@
"if ubi part ${bootubipart} && " \
"ubifsmount ubi${devnum}:${bootubivol}; " \
"then " \
- "setenv devtype ubi; " \
+ "devtype=ubi; " \
"run scan_dev_for_boot; " \
"fi\0"
#define BOOTENV_DEV_UBIFS BOOTENV_DEV_BLKDEV
@@ -178,13 +178,38 @@
BOOT_TARGET_DEVICES_references_SATA_without_CONFIG_SATA
#endif
+#ifdef CONFIG_NVME
+#define BOOTENV_RUN_NVME_INIT "run nvme_init; "
+#define BOOTENV_SET_NVME_NEED_INIT "setenv nvme_need_init; "
+#define BOOTENV_SHARED_NVME \
+ "nvme_init=" \
+ "if ${nvme_need_init}; then " \
+ "setenv nvme_need_init false; " \
+ "nvme scan; " \
+ "fi\0" \
+ \
+ "nvme_boot=" \
+ BOOTENV_RUN_NVME_INIT \
+ BOOTENV_SHARED_BLKDEV_BODY(nvme)
+#define BOOTENV_DEV_NVME BOOTENV_DEV_BLKDEV
+#define BOOTENV_DEV_NAME_NVME BOOTENV_DEV_NAME_BLKDEV
+#else
+#define BOOTENV_RUN_NVME_INIT
+#define BOOTENV_SET_NVME_NEED_INIT
+#define BOOTENV_SHARED_NVME
+#define BOOTENV_DEV_NVME \
+ BOOT_TARGET_DEVICES_references_NVME_without_CONFIG_NVME
+#define BOOTENV_DEV_NAME_NVME \
+ BOOT_TARGET_DEVICES_references_NVME_without_CONFIG_NVME
+#endif
+
#ifdef CONFIG_SCSI
#define BOOTENV_RUN_SCSI_INIT "run scsi_init; "
-#define BOOTENV_SET_SCSI_NEED_INIT "setenv scsi_need_init; "
+#define BOOTENV_SET_SCSI_NEED_INIT "scsi_need_init=; "
#define BOOTENV_SHARED_SCSI \
"scsi_init=" \
"if ${scsi_need_init}; then " \
- "setenv scsi_need_init false; " \
+ "scsi_need_init=false; " \
"scsi scan; " \
"fi\0" \
\
@@ -359,6 +384,7 @@
BOOTENV_SHARED_USB \
BOOTENV_SHARED_SATA \
BOOTENV_SHARED_SCSI \
+ BOOTENV_SHARED_NVME \
BOOTENV_SHARED_IDE \
BOOTENV_SHARED_UBIFS \
BOOTENV_SHARED_EFI \
@@ -418,11 +444,13 @@
"bootfstype; then " \
"run scan_dev_for_boot; " \
"fi; " \
- "done\0" \
+ "done; " \
+ "setenv devplist\0" \
\
BOOT_TARGET_DEVICES(BOOTENV_DEV) \
\
"distro_bootcmd=" BOOTENV_SET_SCSI_NEED_INIT \
+ BOOTENV_SET_NVME_NEED_INIT \
"for target in ${boot_targets}; do " \
"run bootcmd_${target}; " \
"done\0"
diff --git a/include/configs/am65x_evm.h b/include/configs/am65x_evm.h
index 31749c6d06..9ce5b6e824 100644
--- a/include/configs/am65x_evm.h
+++ b/include/configs/am65x_evm.h
@@ -37,6 +37,8 @@
#define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SPL_TEXT_BASE + \
CONFIG_SYS_K3_NON_SECURE_MSRAM_SIZE - 4)
+#define CONFIG_SYS_BOOTM_LEN SZ_64M
+
/* U-Boot general configuration */
#define EXTRA_ENV_AM65X_BOARD_SETTINGS \
"findfdt=" \
diff --git a/include/configs/axs10x.h b/include/configs/axs10x.h
index e128d1c08b..0f4d78a594 100644
--- a/include/configs/axs10x.h
+++ b/include/configs/axs10x.h
@@ -32,11 +32,6 @@
#define CONFIG_SYS_LOAD_ADDR 0x82000000
/*
- * This board might be of different versions so handle it
- */
-#define CONFIG_BOARD_TYPES
-
-/*
* NAND Flash configuration
*/
#define CONFIG_SYS_NAND_BASE (ARC_FPGA_PERIPHERAL_BASE + 0x16000)
diff --git a/include/configs/broadcom_bcm963158.h b/include/configs/broadcom_bcm963158.h
new file mode 100644
index 0000000000..5834e1e2a2
--- /dev/null
+++ b/include/configs/broadcom_bcm963158.h
@@ -0,0 +1,37 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (C) 2019 Philippe Reynes <philippe.reynes@softathome.com>
+ */
+
+#include <linux/sizes.h>
+
+/*
+ * common
+ */
+
+/* UART */
+#define CONFIG_SYS_BAUDRATE_TABLE { 9600, 19200, 38400, 57600, 115200, \
+ 230400, 500000, 1500000 }
+/* Memory usage */
+#define CONFIG_SYS_MAXARGS 24
+#define CONFIG_SYS_MALLOC_LEN (1024 * 1024)
+#define CONFIG_SYS_BOOTM_LEN (16 * 1024 * 1024)
+
+/*
+ * 63158
+ */
+
+/* RAM */
+#define CONFIG_SYS_SDRAM_BASE 0x00000000
+
+/* U-Boot */
+#define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_TEXT_BASE + SZ_16M)
+#define CONFIG_SYS_LOAD_ADDR CONFIG_SYS_TEXT_BASE
+
+#define CONFIG_SKIP_LOWLEVEL_INIT
+
+/*
+ * bcm963158
+ */
+
+#define CONFIG_ENV_SIZE (8 * 1024)
diff --git a/include/configs/hsdk.h b/include/configs/hsdk.h
index 9af1d12701..7735cc1720 100644
--- a/include/configs/hsdk.h
+++ b/include/configs/hsdk.h
@@ -33,11 +33,6 @@
#define CONFIG_SYS_LOAD_ADDR 0x82000000
/*
- * This board might be of different versions so handle it
- */
-#define CONFIG_BOARD_TYPES
-
-/*
* UART configuration
*/
#define CONFIG_SYS_NS16550_SERIAL
diff --git a/include/configs/odroid.h b/include/configs/odroid.h
index c3520bb15f..b8809c8dcc 100644
--- a/include/configs/odroid.h
+++ b/include/configs/odroid.h
@@ -186,7 +186,6 @@
* TODO: Add Odroid X support
*/
#define CONFIG_MISC_COMMON
-#define CONFIG_BOARD_TYPES
#undef CONFIG_REVISION_TAG
diff --git a/include/configs/odroid_xu3.h b/include/configs/odroid_xu3.h
index 0337c26475..f178549a72 100644
--- a/include/configs/odroid_xu3.h
+++ b/include/configs/odroid_xu3.h
@@ -87,7 +87,6 @@
/* Set soc_rev, soc_id, board_rev, boardname, fdtfile */
#define CONFIG_ODROID_REV_AIN 9
#define CONFIG_REVISION_TAG
-#define CONFIG_BOARD_TYPES
#undef CONFIG_SYS_BOARD
#define CONFIG_SYS_BOARD "odroid"
diff --git a/include/configs/omap3_cairo.h b/include/configs/omap3_cairo.h
index 04bce2f8b4..ef69b24dd0 100644
--- a/include/configs/omap3_cairo.h
+++ b/include/configs/omap3_cairo.h
@@ -190,16 +190,6 @@
/* env defaults */
#define CONFIG_BOOTFILE "uImage"
-/* Override OMAP3 common serial console configuration from UART3
- * to UART2.
- *
- * Attention: for UART2, special MUX settings (MUX_DEFAULT(), MCBSP3)
- * are needed and peripheral clocks for UART2 must be enabled in
- * function per_clocks_enable().
- */
-#ifdef CONFIG_SPL_BUILD
-#endif
-
/* Provide the MACH_TYPE value the vendor kernel requires */
#define CONFIG_MACH_TYPE 3063
diff --git a/include/dm/of_access.h b/include/dm/of_access.h
index 5ed1a0cdb4..13fedb7cf5 100644
--- a/include/dm/of_access.h
+++ b/include/dm/of_access.h
@@ -425,6 +425,16 @@ int of_alias_scan(void);
int of_alias_get_id(const struct device_node *np, const char *stem);
/**
+ * of_alias_get_highest_id - Get highest alias id for the given stem
+ * @stem: Alias stem to be examined
+ *
+ * The function travels the lookup table to get the highest alias id for the
+ * given alias stem.
+ * @return alias ID, if found, else -1
+ */
+int of_alias_get_highest_id(const char *stem);
+
+/**
* of_get_stdout() - Get node to use for stdout
*
* @return node referred to by stdout-path alias, or NULL if none
diff --git a/include/dm/read.h b/include/dm/read.h
index 389e30e7fb..60b727cbd8 100644
--- a/include/dm/read.h
+++ b/include/dm/read.h
@@ -510,6 +510,17 @@ int dev_read_resource_byname(struct udevice *dev, const char *name,
* @return the translated address; OF_BAD_ADDR on error
*/
u64 dev_translate_address(struct udevice *dev, const fdt32_t *in_addr);
+
+/**
+ * dev_read_alias_highest_id - Get highest alias id for the given stem
+ * @stem: Alias stem to be examined
+ *
+ * The function travels the lookup table to get the highest alias id for the
+ * given alias stem.
+ * @return alias ID, if found, else -1
+ */
+int dev_read_alias_highest_id(const char *stem);
+
#else /* CONFIG_DM_DEV_READ_INLINE is enabled */
static inline int dev_read_u32(struct udevice *dev,
@@ -740,6 +751,11 @@ static inline u64 dev_translate_address(struct udevice *dev, const fdt32_t *in_a
return ofnode_translate_address(dev_ofnode(dev), in_addr);
}
+static inline int dev_read_alias_highest_id(const char *stem)
+{
+ return fdtdec_get_alias_highest_id(gd->fdt_blob, stem);
+}
+
#endif /* CONFIG_DM_DEV_READ_INLINE */
/**
diff --git a/include/dt-bindings/clock/stm32mp1-clks.h b/include/dt-bindings/clock/stm32mp1-clks.h
index 90ec780bfc..4cdaf13582 100644
--- a/include/dt-bindings/clock/stm32mp1-clks.h
+++ b/include/dt-bindings/clock/stm32mp1-clks.h
@@ -248,7 +248,4 @@
#define STM32MP1_LAST_CLK 232
-#define LTDC_K LTDC_PX
-#define ETHMAC_K ETHCK_K
-
#endif /* _DT_BINDINGS_STM32MP1_CLKS_H_ */
diff --git a/include/efi.h b/include/efi.h
index b5e2c64f38..d98441ab19 100644
--- a/include/efi.h
+++ b/include/efi.h
@@ -49,7 +49,7 @@ struct efi_device_path;
typedef struct {
u8 b[16];
-} efi_guid_t;
+} efi_guid_t __attribute__((aligned(8)));
#define EFI_BITS_PER_LONG (sizeof(long) * 8)
diff --git a/include/efi_api.h b/include/efi_api.h
index aef77b6319..45ca05e8ac 100644
--- a/include/efi_api.h
+++ b/include/efi_api.h
@@ -17,6 +17,7 @@
#define _EFI_API_H
#include <efi.h>
+#include <charset.h>
#ifdef CONFIG_EFI_LOADER
#include <asm/setjmp.h>
@@ -34,7 +35,13 @@ enum efi_timer_delay {
#define efi_intn_t ssize_t
#define efi_uintn_t size_t
-typedef uint16_t *efi_string_t;
+typedef void *efi_hii_handle_t;
+typedef u16 *efi_string_t;
+typedef u16 efi_string_id_t;
+typedef u32 efi_hii_font_style_t;
+typedef u16 efi_question_id_t;
+typedef u16 efi_image_id_t;
+typedef u16 efi_form_id_t;
#define EVT_TIMER 0x80000000
#define EVT_RUNTIME 0x40000000
@@ -115,11 +122,11 @@ struct efi_boot_services {
struct efi_device_path *file_path, void *source_buffer,
efi_uintn_t source_size, efi_handle_t *image);
efi_status_t (EFIAPI *start_image)(efi_handle_t handle,
- unsigned long *exitdata_size,
- s16 **exitdata);
+ efi_uintn_t *exitdata_size,
+ u16 **exitdata);
efi_status_t (EFIAPI *exit)(efi_handle_t handle,
efi_status_t exit_status,
- unsigned long exitdata_size, s16 *exitdata);
+ efi_uintn_t exitdata_size, u16 *exitdata);
efi_status_t (EFIAPI *unload_image)(efi_handle_t image_handle);
efi_status_t (EFIAPI *exit_boot_services)(efi_handle_t, unsigned long);
@@ -221,14 +228,17 @@ struct efi_runtime_services {
struct efi_mem_desc *virtmap);
efi_status_t (*convert_pointer)(unsigned long dbg, void **address);
efi_status_t (EFIAPI *get_variable)(u16 *variable_name,
- efi_guid_t *vendor, u32 *attributes,
+ const efi_guid_t *vendor,
+ u32 *attributes,
efi_uintn_t *data_size, void *data);
efi_status_t (EFIAPI *get_next_variable_name)(
efi_uintn_t *variable_name_size,
- u16 *variable_name, efi_guid_t *vendor);
+ u16 *variable_name, const efi_guid_t *vendor);
efi_status_t (EFIAPI *set_variable)(u16 *variable_name,
- efi_guid_t *vendor, u32 attributes,
- efi_uintn_t data_size, void *data);
+ const efi_guid_t *vendor,
+ u32 attributes,
+ efi_uintn_t data_size,
+ const void *data);
efi_status_t (EFIAPI *get_next_high_mono_count)(
uint32_t *high_count);
void (EFIAPI *reset_system)(enum efi_reset_type reset_type,
@@ -299,7 +309,7 @@ struct efi_runtime_services {
struct efi_configuration_table {
efi_guid_t guid;
void *table;
-};
+} __packed;
#define EFI_SYSTEM_TABLE_SIGNATURE ((u64)0x5453595320494249ULL)
@@ -697,6 +707,418 @@ struct efi_device_path_utilities_protocol {
uint16_t node_length);
};
+/*
+ * Human Interface Infrastructure (HII)
+ */
+struct efi_hii_package_list_header {
+ efi_guid_t package_list_guid;
+ u32 package_length;
+} __packed;
+
+/**
+ * struct efi_hii_package_header - EFI HII package header
+ *
+ * @fields: 'fields' replaces the bit-fields defined in the EFI
+ * specification to to avoid possible compiler incompatibilities::
+ *
+ * u32 length:24;
+ * u32 type:8;
+ */
+struct efi_hii_package_header {
+ u32 fields;
+} __packed;
+
+#define __EFI_HII_PACKAGE_LEN_SHIFT 0
+#define __EFI_HII_PACKAGE_TYPE_SHIFT 24
+#define __EFI_HII_PACKAGE_LEN_MASK 0xffffff
+#define __EFI_HII_PACKAGE_TYPE_MASK 0xff
+
+#define EFI_HII_PACKAGE_TYPE_ALL 0x00
+#define EFI_HII_PACKAGE_TYPE_GUID 0x01
+#define EFI_HII_PACKAGE_FORMS 0x02
+#define EFI_HII_PACKAGE_STRINGS 0x04
+#define EFI_HII_PACKAGE_FONTS 0x05
+#define EFI_HII_PACKAGE_IMAGES 0x06
+#define EFI_HII_PACKAGE_SIMPLE_FONTS 0x07
+#define EFI_HII_PACKAGE_DEVICE_PATH 0x08
+#define EFI_HII_PACKAGE_KEYBOARD_LAYOUT 0x09
+#define EFI_HII_PACKAGE_ANIMATIONS 0x0A
+#define EFI_HII_PACKAGE_END 0xDF
+#define EFI_HII_PACKAGE_TYPE_SYSTEM_BEGIN 0xE0
+#define EFI_HII_PACKAGE_TYPE_SYSTEM_END 0xFF
+
+/*
+ * HII GUID package
+ */
+struct efi_hii_guid_package {
+ struct efi_hii_package_header header;
+ efi_guid_t guid;
+ char data[];
+} __packed;
+
+/*
+ * HII string package
+ */
+struct efi_hii_strings_package {
+ struct efi_hii_package_header header;
+ u32 header_size;
+ u32 string_info_offset;
+ u16 language_window[16];
+ efi_string_id_t language_name;
+ u8 language[];
+} __packed;
+
+struct efi_hii_string_block {
+ u8 block_type;
+ /* u8 block_body[]; */
+} __packed;
+
+#define EFI_HII_SIBT_END 0x00
+#define EFI_HII_SIBT_STRING_SCSU 0x10
+#define EFI_HII_SIBT_STRING_SCSU_FONT 0x11
+#define EFI_HII_SIBT_STRINGS_SCSU 0x12
+#define EFI_HII_SIBT_STRINGS_SCSU_FONT 0x13
+#define EFI_HII_SIBT_STRING_UCS2 0x14
+#define EFI_HII_SIBT_STRING_UCS2_FONT 0x15
+#define EFI_HII_SIBT_STRINGS_UCS2 0x16
+#define EFI_HII_SIBT_STRINGS_UCS2_FONT 0x17
+#define EFI_HII_SIBT_DUPLICATE 0x20
+#define EFI_HII_SIBT_SKIP2 0x21
+#define EFI_HII_SIBT_SKIP1 0x22
+#define EFI_HII_SIBT_EXT1 0x30
+#define EFI_HII_SIBT_EXT2 0x31
+#define EFI_HII_SIBT_EXT4 0x32
+#define EFI_HII_SIBT_FONT 0x40
+
+struct efi_hii_sibt_string_ucs2_block {
+ struct efi_hii_string_block header;
+ u16 string_text[];
+} __packed;
+
+static inline struct efi_hii_string_block *
+efi_hii_sibt_string_ucs2_block_next(struct efi_hii_sibt_string_ucs2_block *blk)
+{
+ return ((void *)blk) + sizeof(*blk) +
+ (u16_strlen(blk->string_text) + 1) * 2;
+}
+
+/*
+ * HII forms package
+ * TODO: full scope of definitions
+ */
+struct efi_hii_time {
+ u8 hour;
+ u8 minute;
+ u8 second;
+};
+
+struct efi_hii_date {
+ u16 year;
+ u8 month;
+ u8 day;
+};
+
+struct efi_hii_ref {
+ efi_question_id_t question_id;
+ efi_form_id_t form_id;
+ efi_guid_t form_set_guid;
+ efi_string_id_t device_path;
+};
+
+union efi_ifr_type_value {
+ u8 u8; // EFI_IFR_TYPE_NUM_SIZE_8
+ u16 u16; // EFI_IFR_TYPE_NUM_SIZE_16
+ u32 u32; // EFI_IFR_TYPE_NUM_SIZE_32
+ u64 u64; // EFI_IFR_TYPE_NUM_SIZE_64
+ bool b; // EFI_IFR_TYPE_BOOLEAN
+ struct efi_hii_time time; // EFI_IFR_TYPE_TIME
+ struct efi_hii_date date; // EFI_IFR_TYPE_DATE
+ efi_string_id_t string; // EFI_IFR_TYPE_STRING, EFI_IFR_TYPE_ACTION
+ struct efi_hii_ref ref; // EFI_IFR_TYPE_REF
+ // u8 buffer[]; // EFI_IFR_TYPE_BUFFER
+};
+
+#define EFI_IFR_TYPE_NUM_SIZE_8 0x00
+#define EFI_IFR_TYPE_NUM_SIZE_16 0x01
+#define EFI_IFR_TYPE_NUM_SIZE_32 0x02
+#define EFI_IFR_TYPE_NUM_SIZE_64 0x03
+#define EFI_IFR_TYPE_BOOLEAN 0x04
+#define EFI_IFR_TYPE_TIME 0x05
+#define EFI_IFR_TYPE_DATE 0x06
+#define EFI_IFR_TYPE_STRING 0x07
+#define EFI_IFR_TYPE_OTHER 0x08
+#define EFI_IFR_TYPE_UNDEFINED 0x09
+#define EFI_IFR_TYPE_ACTION 0x0A
+#define EFI_IFR_TYPE_BUFFER 0x0B
+#define EFI_IFR_TYPE_REF 0x0C
+#define EFI_IFR_OPTION_DEFAULT 0x10
+#define EFI_IFR_OPTION_DEFAULT_MFG 0x20
+
+#define EFI_IFR_ONE_OF_OPTION_OP 0x09
+
+struct efi_ifr_op_header {
+ u8 opCode;
+ u8 length:7;
+ u8 scope:1;
+};
+
+struct efi_ifr_one_of_option {
+ struct efi_ifr_op_header header;
+ efi_string_id_t option;
+ u8 flags;
+ u8 type;
+ union efi_ifr_type_value value;
+};
+
+typedef efi_uintn_t efi_browser_action_t;
+
+#define EFI_BROWSER_ACTION_REQUEST_NONE 0
+#define EFI_BROWSER_ACTION_REQUEST_RESET 1
+#define EFI_BROWSER_ACTION_REQUEST_SUBMIT 2
+#define EFI_BROWSER_ACTION_REQUEST_EXIT 3
+#define EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT 4
+#define EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD_EXIT 5
+#define EFI_BROWSER_ACTION_REQUEST_FORM_APPLY 6
+#define EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD 7
+#define EFI_BROWSER_ACTION_REQUEST_RECONNECT 8
+
+typedef efi_uintn_t efi_browser_action_request_t;
+
+#define EFI_BROWSER_ACTION_CHANGING 0
+#define EFI_BROWSER_ACTION_CHANGED 1
+#define EFI_BROWSER_ACTION_RETRIEVE 2
+#define EFI_BROWSER_ACTION_FORM_OPEN 3
+#define EFI_BROWSER_ACTION_FORM_CLOSE 4
+#define EFI_BROWSER_ACTION_SUBMITTED 5
+#define EFI_BROWSER_ACTION_DEFAULT_STANDARD 0x1000
+#define EFI_BROWSER_ACTION_DEFAULT_MANUFACTURING 0x1001
+#define EFI_BROWSER_ACTION_DEFAULT_SAFE 0x1002
+#define EFI_BROWSER_ACTION_DEFAULT_PLATFORM 0x2000
+#define EFI_BROWSER_ACTION_DEFAULT_HARDWARE 0x3000
+#define EFI_BROWSER_ACTION_DEFAULT_FIRMWARE 0x4000
+
+/*
+ * HII keyboard package
+ */
+typedef enum {
+ EFI_KEY_LCTRL, EFI_KEY_A0, EFI_KEY_LALT, EFI_KEY_SPACE_BAR,
+ EFI_KEY_A2, EFI_KEY_A3, EFI_KEY_A4, EFI_KEY_RCTRL, EFI_KEY_LEFT_ARROW,
+ EFI_KEY_DOWN_ARROW, EFI_KEY_RIGHT_ARROW, EFI_KEY_ZERO,
+ EFI_KEY_PERIOD, EFI_KEY_ENTER, EFI_KEY_LSHIFT, EFI_KEY_B0,
+ EFI_KEY_B1, EFI_KEY_B2, EFI_KEY_B3, EFI_KEY_B4, EFI_KEY_B5, EFI_KEY_B6,
+ EFI_KEY_B7, EFI_KEY_B8, EFI_KEY_B9, EFI_KEY_B10, EFI_KEY_RSHIFT,
+ EFI_KEY_UP_ARROW, EFI_KEY_ONE, EFI_KEY_TWO, EFI_KEY_THREE,
+ EFI_KEY_CAPS_LOCK, EFI_KEY_C1, EFI_KEY_C2, EFI_KEY_C3, EFI_KEY_C4,
+ EFI_KEY_C5, EFI_KEY_C6, EFI_KEY_C7, EFI_KEY_C8, EFI_KEY_C9,
+ EFI_KEY_C10, EFI_KEY_C11, EFI_KEY_C12, EFI_KEY_FOUR, EFI_KEY_FIVE,
+ EFI_KEY_SIX, EFI_KEY_PLUS, EFI_KEY_TAB, EFI_KEY_D1, EFI_KEY_D2,
+ EFI_KEY_D3, EFI_KEY_D4, EFI_KEY_D5, EFI_KEY_D6, EFI_KEY_D7, EFI_KEY_D8,
+ EFI_KEY_D9, EFI_KEY_D10, EFI_KEY_D11, EFI_KEY_D12, EFI_KEY_D13,
+ EFI_KEY_DEL, EFI_KEY_END, EFI_KEY_PG_DN, EFI_KEY_SEVEN, EFI_KEY_EIGHT,
+ EFI_KEY_NINE, EFI_KEY_E0, EFI_KEY_E1, EFI_KEY_E2, EFI_KEY_E3,
+ EFI_KEY_E4, EFI_KEY_E5, EFI_KEY_E6, EFI_KEY_E7, EFI_KEY_E8, EFI_KEY_E9,
+ EFI_KEY_E10, EFI_KEY_E11, EFI_KEY_E12, EFI_KEY_BACK_SPACE,
+ EFI_KEY_INS, EFI_KEY_HOME, EFI_KEY_PG_UP, EFI_KEY_NLCK, EFI_KEY_SLASH,
+ EFI_KEY_ASTERISK, EFI_KEY_MINUS, EFI_KEY_ESC, EFI_KEY_F1, EFI_KEY_F2,
+ EFI_KEY_F3, EFI_KEY_F4, EFI_KEY_F5, EFI_KEY_F6, EFI_KEY_F7, EFI_KEY_F8,
+ EFI_KEY_F9, EFI_KEY_F10, EFI_KEY_F11, EFI_KEY_F12, EFI_KEY_PRINT,
+ EFI_KEY_SLCK, EFI_KEY_PAUSE,
+} efi_key;
+
+struct efi_key_descriptor {
+ u32 key;
+ u16 unicode;
+ u16 shifted_unicode;
+ u16 alt_gr_unicode;
+ u16 shifted_alt_gr_unicode;
+ u16 modifier;
+ u16 affected_attribute;
+} __packed;
+
+struct efi_hii_keyboard_layout {
+ u16 layout_length;
+ efi_guid_t guid;
+ u32 layout_descriptor_string_offset;
+ u8 descriptor_count;
+ struct efi_key_descriptor descriptors[];
+} __packed;
+
+struct efi_hii_keyboard_package {
+ struct efi_hii_package_header header;
+ u16 layout_count;
+ struct efi_hii_keyboard_layout layout[];
+} __packed;
+
+/*
+ * HII protocols
+ */
+#define EFI_HII_STRING_PROTOCOL_GUID \
+ EFI_GUID(0x0fd96974, 0x23aa, 0x4cdc, \
+ 0xb9, 0xcb, 0x98, 0xd1, 0x77, 0x50, 0x32, 0x2a)
+
+struct efi_font_info {
+ efi_hii_font_style_t font_style;
+ u16 font_size;
+ u16 font_name[1];
+};
+
+struct efi_hii_string_protocol {
+ efi_status_t(EFIAPI *new_string)(
+ const struct efi_hii_string_protocol *this,
+ efi_hii_handle_t package_list,
+ efi_string_id_t *string_id,
+ const u8 *language,
+ const u16 *language_name,
+ const efi_string_t string,
+ const struct efi_font_info *string_font_info);
+ efi_status_t(EFIAPI *get_string)(
+ const struct efi_hii_string_protocol *this,
+ const u8 *language,
+ efi_hii_handle_t package_list,
+ efi_string_id_t string_id,
+ efi_string_t string,
+ efi_uintn_t *string_size,
+ struct efi_font_info **string_font_info);
+ efi_status_t(EFIAPI *set_string)(
+ const struct efi_hii_string_protocol *this,
+ efi_hii_handle_t package_list,
+ efi_string_id_t string_id,
+ const u8 *language,
+ const efi_string_t string,
+ const struct efi_font_info *string_font_info);
+ efi_status_t(EFIAPI *get_languages)(
+ const struct efi_hii_string_protocol *this,
+ efi_hii_handle_t package_list,
+ u8 *languages,
+ efi_uintn_t *languages_size);
+ efi_status_t(EFIAPI *get_secondary_languages)(
+ const struct efi_hii_string_protocol *this,
+ efi_hii_handle_t package_list,
+ const u8 *primary_language,
+ u8 *secondary_languages,
+ efi_uintn_t *secondary_languages_size);
+};
+
+#define EFI_HII_DATABASE_PROTOCOL_GUID \
+ EFI_GUID(0xef9fc172, 0xa1b2, 0x4693, \
+ 0xb3, 0x27, 0x6d, 0x32, 0xfc, 0x41, 0x60, 0x42)
+
+struct efi_hii_database_protocol {
+ efi_status_t(EFIAPI *new_package_list)(
+ const struct efi_hii_database_protocol *this,
+ const struct efi_hii_package_list_header *package_list,
+ const efi_handle_t driver_handle,
+ efi_hii_handle_t *handle);
+ efi_status_t(EFIAPI *remove_package_list)(
+ const struct efi_hii_database_protocol *this,
+ efi_hii_handle_t handle);
+ efi_status_t(EFIAPI *update_package_list)(
+ const struct efi_hii_database_protocol *this,
+ efi_hii_handle_t handle,
+ const struct efi_hii_package_list_header *package_list);
+ efi_status_t(EFIAPI *list_package_lists)(
+ const struct efi_hii_database_protocol *this,
+ u8 package_type,
+ const efi_guid_t *package_guid,
+ efi_uintn_t *handle_buffer_length,
+ efi_hii_handle_t *handle);
+ efi_status_t(EFIAPI *export_package_lists)(
+ const struct efi_hii_database_protocol *this,
+ efi_hii_handle_t handle,
+ efi_uintn_t *buffer_size,
+ struct efi_hii_package_list_header *buffer);
+ efi_status_t(EFIAPI *register_package_notify)(
+ const struct efi_hii_database_protocol *this,
+ u8 package_type,
+ const efi_guid_t *package_guid,
+ const void *package_notify_fn,
+ efi_uintn_t notify_type,
+ efi_handle_t *notify_handle);
+ efi_status_t(EFIAPI *unregister_package_notify)(
+ const struct efi_hii_database_protocol *this,
+ efi_handle_t notification_handle
+ );
+ efi_status_t(EFIAPI *find_keyboard_layouts)(
+ const struct efi_hii_database_protocol *this,
+ u16 *key_guid_buffer_length,
+ efi_guid_t *key_guid_buffer);
+ efi_status_t(EFIAPI *get_keyboard_layout)(
+ const struct efi_hii_database_protocol *this,
+ efi_guid_t *key_guid,
+ u16 *keyboard_layout_length,
+ struct efi_hii_keyboard_layout *keyboard_layout);
+ efi_status_t(EFIAPI *set_keyboard_layout)(
+ const struct efi_hii_database_protocol *this,
+ efi_guid_t *key_guid);
+ efi_status_t(EFIAPI *get_package_list_handle)(
+ const struct efi_hii_database_protocol *this,
+ efi_hii_handle_t package_list_handle,
+ efi_handle_t *driver_handle);
+};
+
+#define EFI_HII_CONFIG_ROUTING_PROTOCOL_GUID \
+ EFI_GUID(0x587e72d7, 0xcc50, 0x4f79, \
+ 0x82, 0x09, 0xca, 0x29, 0x1f, 0xc1, 0xa1, 0x0f)
+
+struct efi_hii_config_routing_protocol {
+ efi_status_t(EFIAPI *extract_config)(
+ const struct efi_hii_config_routing_protocol *this,
+ const efi_string_t request,
+ efi_string_t *progress,
+ efi_string_t *results);
+ efi_status_t(EFIAPI *export_config)(
+ const struct efi_hii_config_routing_protocol *this,
+ efi_string_t *results);
+ efi_status_t(EFIAPI *route_config)(
+ const struct efi_hii_config_routing_protocol *this,
+ const efi_string_t configuration,
+ efi_string_t *progress);
+ efi_status_t(EFIAPI *block_to_config)(
+ const struct efi_hii_config_routing_protocol *this,
+ const efi_string_t config_request,
+ const uint8_t *block,
+ const efi_uintn_t block_size,
+ efi_string_t *config,
+ efi_string_t *progress);
+ efi_status_t(EFIAPI *config_to_block)(
+ const struct efi_hii_config_routing_protocol *this,
+ const efi_string_t config_resp,
+ const uint8_t *block,
+ const efi_uintn_t *block_size,
+ efi_string_t *progress);
+ efi_status_t(EFIAPI *get_alt_config)(
+ const struct efi_hii_config_routing_protocol *this,
+ const efi_string_t config_resp,
+ const efi_guid_t *guid,
+ const efi_string_t name,
+ const struct efi_device_path *device_path,
+ const efi_string_t alt_cfg_id,
+ efi_string_t *alt_cfg_resp);
+};
+
+#define EFI_HII_CONFIG_ACCESS_PROTOCOL_GUID \
+ EFI_GUID(0x330d4706, 0xf2a0, 0x4e4f, \
+ 0xa3, 0x69, 0xb6, 0x6f, 0xa8, 0xd5, 0x43, 0x85)
+
+struct efi_hii_config_access_protocol {
+ efi_status_t(EFIAPI *extract_config_access)(
+ const struct efi_hii_config_access_protocol *this,
+ const efi_string_t request,
+ efi_string_t *progress,
+ efi_string_t *results);
+ efi_status_t(EFIAPI *route_config_access)(
+ const struct efi_hii_config_access_protocol *this,
+ const efi_string_t configuration,
+ efi_string_t *progress);
+ efi_status_t(EFIAPI *form_callback)(
+ const struct efi_hii_config_access_protocol *this,
+ efi_browser_action_t action,
+ efi_question_id_t question_id,
+ u8 type,
+ union efi_ifr_type_value *value,
+ efi_browser_action_request_t *action_request);
+};
+
#define EFI_GOP_GUID \
EFI_GUID(0x9042a9de, 0x23dc, 0x4a38, \
0x96, 0xfb, 0x7a, 0xde, 0xd0, 0x80, 0x51, 0x6a)
@@ -906,7 +1328,7 @@ struct efi_file_handle {
u64 rev;
efi_status_t (EFIAPI *open)(struct efi_file_handle *file,
struct efi_file_handle **new_handle,
- s16 *file_name, u64 open_mode, u64 attributes);
+ u16 *file_name, u64 open_mode, u64 attributes);
efi_status_t (EFIAPI *close)(struct efi_file_handle *file);
efi_status_t (EFIAPI *delete)(struct efi_file_handle *file);
efi_status_t (EFIAPI *read)(struct efi_file_handle *file,
@@ -926,9 +1348,6 @@ struct efi_file_handle {
efi_status_t (EFIAPI *flush)(struct efi_file_handle *file);
};
-#define EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID \
- EFI_GUID(0x964e5b22, 0x6459, 0x11d2, \
- 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
#define EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_REVISION 0x00010000
struct efi_simple_file_system_protocol {
diff --git a/include/efi_loader.h b/include/efi_loader.h
index 53f08161ab..9dd933dae7 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -106,6 +106,10 @@ extern const struct efi_device_path_utilities_protocol
/* Implementation of the EFI_UNICODE_COLLATION_PROTOCOL */
extern const struct efi_unicode_collation_protocol
efi_unicode_collation_protocol;
+extern const struct efi_hii_config_routing_protocol efi_hii_config_routing;
+extern const struct efi_hii_config_access_protocol efi_hii_config_access;
+extern const struct efi_hii_database_protocol efi_hii_database;
+extern const struct efi_hii_string_protocol efi_hii_string;
uint16_t *efi_dp_str(struct efi_device_path *dp);
@@ -139,6 +143,10 @@ extern const efi_guid_t efi_file_system_info_guid;
extern const efi_guid_t efi_guid_device_path_utilities_protocol;
/* GUID of the Unicode collation protocol */
extern const efi_guid_t efi_guid_unicode_collation_protocol;
+extern const efi_guid_t efi_guid_hii_config_routing_protocol;
+extern const efi_guid_t efi_guid_hii_config_access_protocol;
+extern const efi_guid_t efi_guid_hii_database_protocol;
+extern const efi_guid_t efi_guid_hii_string_protocol;
extern unsigned int __efi_runtime_start, __efi_runtime_stop;
extern unsigned int __efi_runtime_rel_start, __efi_runtime_rel_stop;
@@ -244,6 +252,8 @@ extern struct list_head efi_obj_list;
/* List of all events */
extern struct list_head efi_events;
+/* Initialize efi execution environment */
+efi_status_t efi_init_obj_list(void);
/* Called by bootefi to initialize root node */
efi_status_t efi_root_node_register(void);
/* Called by bootefi to initialize runtime */
@@ -508,15 +518,15 @@ efi_status_t EFIAPI efi_selftest(efi_handle_t image_handle,
struct efi_system_table *systab);
#endif
-efi_status_t EFIAPI efi_get_variable(u16 *variable_name, efi_guid_t *vendor,
- u32 *attributes, efi_uintn_t *data_size,
- void *data);
+efi_status_t EFIAPI efi_get_variable(u16 *variable_name,
+ const efi_guid_t *vendor, u32 *attributes,
+ efi_uintn_t *data_size, void *data);
efi_status_t EFIAPI efi_get_next_variable_name(efi_uintn_t *variable_name_size,
u16 *variable_name,
- efi_guid_t *vendor);
-efi_status_t EFIAPI efi_set_variable(u16 *variable_name, efi_guid_t *vendor,
- u32 attributes, efi_uintn_t data_size,
- void *data);
+ const efi_guid_t *vendor);
+efi_status_t EFIAPI efi_set_variable(u16 *variable_name,
+ const efi_guid_t *vendor, u32 attributes,
+ efi_uintn_t data_size, const void *data);
/*
* See section 3.1.3 in the v2.7 UEFI spec for more details on
diff --git a/include/fdtdec.h b/include/fdtdec.h
index f1bcbf837f..b7e35cd87c 100644
--- a/include/fdtdec.h
+++ b/include/fdtdec.h
@@ -133,21 +133,14 @@ enum fdt_compat_id {
/* Tegra210 XUSB pad controller */
COMPAT_SMSC_LAN9215, /* SMSC 10/100 Ethernet LAN9215 */
COMPAT_SAMSUNG_EXYNOS5_SROMC, /* Exynos5 SROMC */
- COMPAT_SAMSUNG_S3C2440_I2C, /* Exynos I2C Controller */
- COMPAT_SAMSUNG_EXYNOS5_SOUND, /* Exynos Sound */
- COMPAT_WOLFSON_WM8994_CODEC, /* Wolfson WM8994 Sound Codec */
COMPAT_SAMSUNG_EXYNOS_USB_PHY, /* Exynos phy controller for usb2.0 */
COMPAT_SAMSUNG_EXYNOS5_USB3_PHY,/* Exynos phy controller for usb3.0 */
COMPAT_SAMSUNG_EXYNOS_TMU, /* Exynos TMU */
COMPAT_SAMSUNG_EXYNOS_MIPI_DSI, /* Exynos mipi dsi */
COMPAT_SAMSUNG_EXYNOS_DWMMC, /* Exynos DWMMC controller */
- COMPAT_SAMSUNG_EXYNOS_MMC, /* Exynos MMC controller */
COMPAT_GENERIC_SPI_FLASH, /* Generic SPI Flash chip */
- COMPAT_MAXIM_98095_CODEC, /* MAX98095 Codec */
- COMPAT_SAMSUNG_EXYNOS5_I2C, /* Exynos5 High Speed I2C Controller */
COMPAT_SAMSUNG_EXYNOS_SYSMMU, /* Exynos sysmmu */
COMPAT_INTEL_MICROCODE, /* Intel microcode update */
- COMPAT_AMS_AS3722, /* AMS AS3722 PMIC */
COMPAT_INTEL_QRK_MRC, /* Intel Quark MRC */
COMPAT_ALTERA_SOCFPGA_DWMAC, /* SoCFPGA Ethernet controller */
COMPAT_ALTERA_SOCFPGA_DWMMC, /* SoCFPGA DWMMC controller */
@@ -626,6 +619,19 @@ int fdtdec_get_alias_seq(const void *blob, const char *base, int node,
int *seqp);
/**
+ * Get the highest alias number for susbystem.
+ *
+ * It parses all aliases and find out highest recorded alias for subsystem.
+ * Aliases are of the form <base><num> where <num> is the sequence number.
+ *
+ * @param blob Device tree blob (if NULL, then error is returned)
+ * @param base Base name for alias susbystem (before the number)
+ *
+ * @return 0 highest alias ID, -1 if not found
+ */
+int fdtdec_get_alias_highest_id(const void *blob, const char *base);
+
+/**
* Get a property from the /chosen node
*
* @param blob Device tree blob (if NULL, then NULL is returned)
diff --git a/include/i2s.h b/include/i2s.h
index 28f6184811..7760aab7c4 100644
--- a/include/i2s.h
+++ b/include/i2s.h
@@ -78,7 +78,7 @@ struct i2s_reg {
/* This structure stores the i2s related information */
struct i2s_uc_priv {
unsigned int rfs; /* LR clock frame size */
- unsigned int bfs; /* Bit slock frame size */
+ unsigned int bfs; /* Bit clock frame size */
unsigned int audio_pll_clk; /* Audio pll frequency in Hz */
unsigned int samplingrate; /* sampling rate */
unsigned int bitspersample; /* bits per sample */
@@ -123,13 +123,4 @@ int i2s_tx_data(struct udevice *dev, void *data, uint data_size);
int i2s_transfer_tx_data(struct i2s_uc_priv *pi2s_tx, void *data,
uint data_size);
-/*
- * Initialise i2s transmiter
- *
- * @param pi2s_tx pointer of i2s transmitter parameter structure.
- *
- * @return int value 0 for success, -1 in case of error
- */
-int i2s_tx_init(struct i2s_uc_priv *pi2s_tx);
-
#endif /* __I2S_H__ */
diff --git a/include/initcall.h b/include/initcall.h
index 01f3f2833f..3ac01aa2cd 100644
--- a/include/initcall.h
+++ b/include/initcall.h
@@ -8,6 +8,39 @@
typedef int (*init_fnc_t)(void);
-int initcall_run_list(const init_fnc_t init_sequence[]);
+#include <common.h>
+#include <initcall.h>
+#include <efi.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static inline int initcall_run_list(const init_fnc_t init_sequence[])
+{
+ const init_fnc_t *init_fnc_ptr;
+
+ for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
+ unsigned long reloc_ofs = 0;
+ int ret;
+
+ if (gd->flags & GD_FLG_RELOC)
+ reloc_ofs = gd->reloc_off;
+#ifdef CONFIG_EFI_APP
+ reloc_ofs = (unsigned long)image_base;
+#endif
+ debug("initcall: %p", (char *)*init_fnc_ptr - reloc_ofs);
+ if (gd->flags & GD_FLG_RELOC)
+ debug(" (relocated to %p)\n", (char *)*init_fnc_ptr);
+ else
+ debug("\n");
+ ret = (*init_fnc_ptr)();
+ if (ret) {
+ printf("initcall sequence %p failed at call %p (err=%d)\n",
+ init_sequence,
+ (char *)*init_fnc_ptr - reloc_ofs, ret);
+ return -1;
+ }
+ }
+ return 0;
+}
#endif
diff --git a/include/power/regulator.h b/include/power/regulator.h
index 5318ab3ace..314160a894 100644
--- a/include/power/regulator.h
+++ b/include/power/regulator.h
@@ -304,6 +304,17 @@ int regulator_get_enable(struct udevice *dev);
int regulator_set_enable(struct udevice *dev, bool enable);
/**
+ * regulator_set_enable_if_allowed: set regulator enable state if allowed by
+ * regulator
+ *
+ * @dev - pointer to the regulator device
+ * @enable - set true or false
+ * @return - 0 on success or if enabling is not supported
+ * -errno val if fails.
+ */
+int regulator_set_enable_if_allowed(struct udevice *dev, bool enable);
+
+/**
* regulator_get_mode: get active operation mode id of a given regulator
*
* @dev - pointer to the regulator device
diff --git a/include/samsung/misc.h b/include/samsung/misc.h
index 0f957dc367..017560c256 100644
--- a/include/samsung/misc.h
+++ b/include/samsung/misc.h
@@ -32,9 +32,7 @@ void draw_logo(void);
char *get_dfu_alt_system(char *interface, char *devstr);
char *get_dfu_alt_boot(char *interface, char *devstr);
#endif
-#ifdef CONFIG_BOARD_TYPES
void set_board_type(void);
const char *get_board_type(void);
-#endif
#endif /* __SAMSUNG_MISC_COMMON_H__ */
diff --git a/include/test/lib.h b/include/test/lib.h
new file mode 100644
index 0000000000..04b6241e54
--- /dev/null
+++ b/include/test/lib.h
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2019 Heinrich Schuchardt <xypron.glpk@gmx.de>
+ */
+
+#ifndef __TEST_LIB_H__
+#define __TEST_LIB_H__
+
+#include <test/test.h>
+
+/* Declare a new library function test */
+#define LIB_TEST(_name, _flags) UNIT_TEST(_name, _flags, lib_test)
+
+#endif /* __TEST_LIB_H__ */
diff --git a/include/test/suites.h b/include/test/suites.h
index 77d863b4a6..01bee09346 100644
--- a/include/test/suites.h
+++ b/include/test/suites.h
@@ -27,6 +27,7 @@ int do_ut_bloblist(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]);
int do_ut_compression(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]);
int do_ut_dm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
int do_ut_env(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
+int do_ut_lib(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
int do_ut_overlay(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
int do_ut_time(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
int do_ut_unicode(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
diff --git a/lib/Makefile b/lib/Makefile
index 61d7ff0678..47829bfed5 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -35,7 +35,6 @@ obj-$(CONFIG_TEST_FDTDEC) += fdtdec_test.o
obj-$(CONFIG_GZIP_COMPRESSED) += gzip.o
obj-$(CONFIG_GENERATE_SMBIOS_TABLE) += smbios.o
obj-$(CONFIG_IMAGE_SPARSE) += image-sparse.o
-obj-y += initcall.o
obj-y += ldiv.o
obj-$(CONFIG_MD5) += md5.o
obj-y += net_utils.o
diff --git a/lib/charset.c b/lib/charset.c
index 10557b9e75..5e349ed5ee 100644
--- a/lib/charset.c
+++ b/lib/charset.c
@@ -349,6 +349,35 @@ size_t u16_strnlen(const u16 *in, size_t count)
return i;
}
+u16 *u16_strcpy(u16 *dest, const u16 *src)
+{
+ u16 *tmp = dest;
+
+ for (;; dest++, src++) {
+ *dest = *src;
+ if (!*src)
+ break;
+ }
+
+ return tmp;
+}
+
+u16 *u16_strdup(const u16 *src)
+{
+ u16 *new;
+
+ if (!src)
+ return NULL;
+
+ new = malloc((u16_strlen(src) + 1) * sizeof(u16));
+ if (!new)
+ return NULL;
+
+ u16_strcpy(new, src);
+
+ return new;
+}
+
/* Convert UTF-16 to UTF-8. */
uint8_t *utf16_to_utf8(uint8_t *dest, const uint16_t *src, size_t size)
{
diff --git a/lib/efi_driver/efi_uclass.c b/lib/efi_driver/efi_uclass.c
index bb86ffd399..7cdf81f40c 100644
--- a/lib/efi_driver/efi_uclass.c
+++ b/lib/efi_driver/efi_uclass.c
@@ -233,8 +233,7 @@ static efi_status_t EFIAPI efi_uc_stop(
}
ret = EFI_CALL(systab.boottime->free_pool(entry_buffer));
if (ret != EFI_SUCCESS)
- printf("%s(%u) %s: ERROR: Cannot free pool\n",
- __FILE__, __LINE__, __func__);
+ printf("%s: ERROR: Cannot free pool\n", __func__);
/* Detach driver from controller */
ret = EFI_CALL(systab.boottime->close_protocol(
diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
index b921ea8821..23487b8130 100644
--- a/lib/efi_loader/Kconfig
+++ b/lib/efi_loader/Kconfig
@@ -8,6 +8,7 @@ config EFI_LOADER
default y
select LIB_UUID
select HAVE_BLOCK_DEVICE
+ select REGEX
imply CFB_CONSOLE_ANSI
help
Select this option if you want to run EFI applications (like grub2)
@@ -33,3 +34,18 @@ config EFI_LOADER_BOUNCE_BUFFER
Some hardware does not support DMA to full 64bit addresses. For this
hardware we can create a bounce buffer so that payloads don't have to
worry about platform details.
+
+config EFI_LOADER_HII
+ bool "Expose HII protocols to EFI applications"
+ depends on EFI_LOADER
+ default n
+ help
+ The Human Interface Infrastructure is a complicated framework that
+ allows UEFI applications to draw fancy menus and hook strings using
+ a translation framework.
+
+ U-Boot implements enough of its features to be able to run the UEFI
+ Shell, but not more than that. The code is experimental still, so
+ beware that your system might break with HII enabled.
+
+ If unsure, say n.
diff --git a/lib/efi_loader/Makefile b/lib/efi_loader/Makefile
index 6703435947..4e90a35896 100644
--- a/lib/efi_loader/Makefile
+++ b/lib/efi_loader/Makefile
@@ -10,7 +10,7 @@ CFLAGS_efi_boottime.o += \
-DFW_VERSION="0x$(VERSION)" \
-DFW_PATCHLEVEL="0x$(PATCHLEVEL)"
CFLAGS_helloworld.o := $(CFLAGS_EFI) -Os -ffreestanding
-CFLAGS_REMOVE_helloworld.o := $(CFLAGS_NON_EFI) -Os
+CFLAGS_REMOVE_helloworld.o := $(CFLAGS_NON_EFI)
ifneq ($(CONFIG_CMD_BOOTEFI_HELLO_COMPILE),)
always += helloworld.efi
@@ -24,10 +24,12 @@ obj-y += efi_device_path.o
obj-y += efi_device_path_to_text.o
obj-y += efi_device_path_utilities.o
obj-y += efi_file.o
+obj-y += efi_hii.o efi_hii_config.o
obj-y += efi_image_loader.o
obj-y += efi_memory.o
obj-y += efi_root_node.o
obj-y += efi_runtime.o
+obj-y += efi_setup.o
obj-y += efi_unicode_collation.o
obj-y += efi_variable.o
obj-y += efi_watchdog.o
diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index cc9efbb0cb..f74f989e0a 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -1558,6 +1558,26 @@ efi_status_t efi_setup_loaded_image(struct efi_device_path *device_path,
if (ret != EFI_SUCCESS)
goto failure;
+#if CONFIG_IS_ENABLED(EFI_LOADER_HII)
+ ret = efi_add_protocol(&obj->header,
+ &efi_guid_hii_string_protocol,
+ (void *)&efi_hii_string);
+ if (ret != EFI_SUCCESS)
+ goto failure;
+
+ ret = efi_add_protocol(&obj->header,
+ &efi_guid_hii_database_protocol,
+ (void *)&efi_hii_database);
+ if (ret != EFI_SUCCESS)
+ goto failure;
+
+ ret = efi_add_protocol(&obj->header,
+ &efi_guid_hii_config_routing_protocol,
+ (void *)&efi_hii_config_routing);
+ if (ret != EFI_SUCCESS)
+ goto failure;
+#endif
+
return ret;
failure:
printf("ERROR: Failure to install protocols for loaded image\n");
@@ -1706,8 +1726,8 @@ error:
* Return: status code
*/
static efi_status_t EFIAPI efi_start_image(efi_handle_t image_handle,
- unsigned long *exit_data_size,
- s16 **exit_data)
+ efi_uintn_t *exit_data_size,
+ u16 **exit_data)
{
struct efi_loaded_image_obj *image_obj =
(struct efi_loaded_image_obj *)image_handle;
@@ -1773,8 +1793,8 @@ static efi_status_t EFIAPI efi_start_image(efi_handle_t image_handle,
*/
static efi_status_t EFIAPI efi_exit(efi_handle_t image_handle,
efi_status_t exit_status,
- unsigned long exit_data_size,
- int16_t *exit_data)
+ efi_uintn_t exit_data_size,
+ u16 *exit_data)
{
/*
* TODO: We should call the unload procedure of the loaded
@@ -1783,7 +1803,7 @@ static efi_status_t EFIAPI efi_exit(efi_handle_t image_handle,
struct efi_loaded_image_obj *image_obj =
(struct efi_loaded_image_obj *)image_handle;
- EFI_ENTRY("%p, %ld, %ld, %p", image_handle, exit_status,
+ EFI_ENTRY("%p, %ld, %zu, %p", image_handle, exit_status,
exit_data_size, exit_data);
/* Make sure entry/exit counts for EFI world cross-overs match */
@@ -2483,7 +2503,7 @@ static void EFIAPI efi_copy_mem(void *destination, const void *source,
size_t length)
{
EFI_ENTRY("%p, %p, %ld", destination, source, (unsigned long)length);
- memcpy(destination, source, length);
+ memmove(destination, source, length);
EFI_EXIT(EFI_SUCCESS);
}
@@ -2825,7 +2845,7 @@ static efi_status_t EFIAPI efi_connect_controller(
efi_status_t ret = EFI_NOT_FOUND;
struct efi_object *efiobj;
- EFI_ENTRY("%p, %p, %p, %d", controller_handle, driver_image_handle,
+ EFI_ENTRY("%p, %p, %pD, %d", controller_handle, driver_image_handle,
remain_device_path, recursive);
efiobj = efi_search_obj(controller_handle);
diff --git a/lib/efi_loader/efi_file.c b/lib/efi_loader/efi_file.c
index 8a4f3a9f40..4b4422205d 100644
--- a/lib/efi_loader/efi_file.c
+++ b/lib/efi_loader/efi_file.c
@@ -148,7 +148,7 @@ static int sanitize_path(char *path)
* Returns: handle to the opened file or NULL
*/
static struct efi_file_handle *file_open(struct file_system *fs,
- struct file_handle *parent, s16 *file_name, u64 mode,
+ struct file_handle *parent, u16 *file_name, u64 mode,
u64 attributes)
{
struct file_handle *fh;
@@ -157,8 +157,8 @@ static struct efi_file_handle *file_open(struct file_system *fs,
int flen = 0;
if (file_name) {
- utf16_to_utf8((u8 *)f0, (u16 *)file_name, 1);
- flen = u16_strlen((u16 *)file_name);
+ utf16_to_utf8((u8 *)f0, file_name, 1);
+ flen = u16_strlen(file_name);
}
/* we could have a parent, but also an absolute path: */
@@ -183,7 +183,7 @@ static struct efi_file_handle *file_open(struct file_system *fs,
*p++ = '/';
}
- utf16_to_utf8((u8 *)p, (u16 *)file_name, flen);
+ utf16_to_utf8((u8 *)p, file_name, flen);
if (sanitize_path(fh->path))
goto error;
@@ -200,6 +200,10 @@ static struct efi_file_handle *file_open(struct file_system *fs,
fs_exists(fh->path)))
goto error;
+ /* fs_exists() calls fs_close(), so open file system again */
+ if (set_blk_dev(fh))
+ goto error;
+
/* figure out if file is a directory: */
fh->isdir = is_dir(fh);
} else {
@@ -216,7 +220,7 @@ error:
static efi_status_t EFIAPI efi_file_open(struct efi_file_handle *file,
struct efi_file_handle **new_handle,
- s16 *file_name, u64 open_mode, u64 attributes)
+ u16 *file_name, u64 open_mode, u64 attributes)
{
struct file_handle *fh = to_fh(file);
efi_status_t ret;
@@ -375,7 +379,7 @@ static efi_status_t dir_read(struct file_handle *fh, u64 *buffer_size,
if (dent->type == FS_DT_DIR)
info->attribute |= EFI_FILE_DIRECTORY;
- ascii2unicode((u16 *)info->file_name, dent->name);
+ ascii2unicode(info->file_name, dent->name);
fh->offset++;
@@ -666,7 +670,7 @@ struct efi_file_handle *efi_file_from_path(struct efi_device_path *fp)
return NULL;
}
- EFI_CALL(ret = f->open(f, &f2, (s16 *)fdp->str,
+ EFI_CALL(ret = f->open(f, &f2, fdp->str,
EFI_FILE_MODE_READ, 0));
if (ret != EFI_SUCCESS)
return NULL;
diff --git a/lib/efi_loader/efi_freestanding.c b/lib/efi_loader/efi_freestanding.c
new file mode 100644
index 0000000000..bd9da5bbc8
--- /dev/null
+++ b/lib/efi_loader/efi_freestanding.c
@@ -0,0 +1,90 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Library for freestanding binary
+ *
+ * Copyright 2019, Heinrich Schuchardt <xypron.glpk@gmx.de>
+ *
+ * GCC requires that freestanding programs provide memcpy(), memmove(),
+ * memset(), and memcmp().
+ */
+
+#include <common.h>
+
+/**
+ * memcmp() - compare memory areas
+ *
+ * @s1: pointer to first area
+ * @s2: pointer to second area
+ * @n: number of bytes to compare
+ * Return: 0 if both memory areas are the same, otherwise the sign of the
+ * result value is the same as the sign of the difference between
+ * the first differing pair of bytes taken as u8.
+ */
+int memcmp(const void *s1, const void *s2, size_t n)
+{
+ const u8 *pos1 = s1;
+ const u8 *pos2 = s2;
+
+ for (; n; --n) {
+ if (*pos1 != *pos2)
+ return *pos1 - *pos2;
+ ++pos1;
+ ++pos2;
+ }
+ return 0;
+}
+
+/**
+ * memcpy() - copy memory area
+ *
+ * @dest: destination buffer
+ * @src: source buffer
+ * @n: number of bytes to copy
+ * Return: pointer to destination buffer
+ */
+void *memmove(void *dest, const void *src, size_t n)
+{
+ u8 *d = dest;
+ const u8 *s = src;
+
+ if (d >= s) {
+ for (; n; --n)
+ *d++ = *s++;
+ } else {
+ d += n;
+ s += n;
+ for (; n; --n)
+ *--d = *--s;
+ }
+ return dest;
+}
+
+/**
+ * memcpy() - copy memory area
+ *
+ * @dest: destination buffer
+ * @src: source buffer
+ * @n: number of bytes to copy
+ * Return: pointer to destination buffer
+ */
+void *memcpy(void *dest, const void *src, size_t n)
+{
+ return memmove(dest, src, n);
+}
+
+/**
+ * memset() - fill memory with a constant byte
+ *
+ * @s: destination buffer
+ * @c: byte value
+ * @n: number of bytes to set
+ * Return: pointer to destination buffer
+ */
+void *memset(void *s, int c, size_t n)
+{
+ u8 *d = s;
+
+ for (; n; --n)
+ *d++ = c;
+ return s;
+}
diff --git a/lib/efi_loader/efi_hii.c b/lib/efi_loader/efi_hii.c
new file mode 100644
index 0000000000..d63d2d8418
--- /dev/null
+++ b/lib/efi_loader/efi_hii.c
@@ -0,0 +1,1095 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * EFI Human Interface Infrastructure ... database and packages
+ *
+ * Copyright (c) 2017 Leif Lindholm
+ * Copyright (c) 2018 AKASHI Takahiro, Linaro Limited
+ */
+
+#include <common.h>
+#include <efi_loader.h>
+#include <malloc.h>
+#include <asm/unaligned.h>
+
+const efi_guid_t efi_guid_hii_database_protocol
+ = EFI_HII_DATABASE_PROTOCOL_GUID;
+const efi_guid_t efi_guid_hii_string_protocol = EFI_HII_STRING_PROTOCOL_GUID;
+
+static LIST_HEAD(efi_package_lists);
+static LIST_HEAD(efi_keyboard_layout_list);
+
+struct efi_hii_packagelist {
+ struct list_head link;
+ // TODO should there be an associated efi_object?
+ efi_handle_t driver_handle;
+ u32 max_string_id;
+ struct list_head string_tables; /* list of efi_string_table */
+ struct list_head guid_list;
+ struct list_head keyboard_packages;
+
+ /* we could also track fonts, images, etc */
+};
+
+static int efi_hii_packagelist_exists(efi_hii_handle_t package_list)
+{
+ struct efi_hii_packagelist *hii;
+ int found = 0;
+
+ list_for_each_entry(hii, &efi_package_lists, link) {
+ if (hii == package_list) {
+ found = 1;
+ break;
+ }
+ }
+
+ return found;
+}
+
+static u32 efi_hii_package_type(struct efi_hii_package_header *header)
+{
+ u32 fields;
+
+ fields = get_unaligned_le32(&header->fields);
+
+ return (fields >> __EFI_HII_PACKAGE_TYPE_SHIFT)
+ & __EFI_HII_PACKAGE_TYPE_MASK;
+}
+
+static u32 efi_hii_package_len(struct efi_hii_package_header *header)
+{
+ u32 fields;
+
+ fields = get_unaligned_le32(&header->fields);
+
+ return (fields >> __EFI_HII_PACKAGE_LEN_SHIFT)
+ & __EFI_HII_PACKAGE_LEN_MASK;
+}
+
+struct efi_string_info {
+ efi_string_t string;
+ /* we could also track font info, etc */
+};
+
+struct efi_string_table {
+ struct list_head link;
+ efi_string_id_t language_name;
+ char *language;
+ u32 nstrings;
+ /*
+ * NOTE:
+ * string id starts at 1 so value is stbl->strings[id-1],
+ * and strings[] is a array of stbl->nstrings elements
+ */
+ struct efi_string_info *strings;
+};
+
+struct efi_guid_data {
+ struct list_head link;
+ struct efi_hii_guid_package package;
+};
+
+struct efi_keyboard_layout_data {
+ struct list_head link; /* in package */
+ struct list_head link_sys; /* in global list */
+ struct efi_hii_keyboard_layout keyboard_layout;
+};
+
+struct efi_keyboard_package_data {
+ struct list_head link; /* in package_list */
+ struct list_head keyboard_layout_list;
+};
+
+static void free_strings_table(struct efi_string_table *stbl)
+{
+ int i;
+
+ for (i = 0; i < stbl->nstrings; i++)
+ free(stbl->strings[i].string);
+ free(stbl->strings);
+ free(stbl->language);
+ free(stbl);
+}
+
+static void remove_strings_package(struct efi_hii_packagelist *hii)
+{
+ while (!list_empty(&hii->string_tables)) {
+ struct efi_string_table *stbl;
+
+ stbl = list_first_entry(&hii->string_tables,
+ struct efi_string_table, link);
+ list_del(&stbl->link);
+ free_strings_table(stbl);
+ }
+}
+
+static efi_status_t
+add_strings_package(struct efi_hii_packagelist *hii,
+ struct efi_hii_strings_package *strings_package)
+{
+ struct efi_hii_string_block *block;
+ void *end;
+ u32 nstrings = 0, idx = 0;
+ struct efi_string_table *stbl = NULL;
+ efi_status_t ret;
+
+ EFI_PRINT("header_size: %08x\n",
+ get_unaligned_le32(&strings_package->header_size));
+ EFI_PRINT("string_info_offset: %08x\n",
+ get_unaligned_le32(&strings_package->string_info_offset));
+ EFI_PRINT("language_name: %u\n",
+ get_unaligned_le16(&strings_package->language_name));
+ EFI_PRINT("language: %s\n", strings_package->language);
+
+ /* count # of string entries: */
+ end = ((void *)strings_package)
+ + efi_hii_package_len(&strings_package->header);
+ block = ((void *)strings_package)
+ + get_unaligned_le32(&strings_package->string_info_offset);
+
+ while ((void *)block < end) {
+ switch (block->block_type) {
+ case EFI_HII_SIBT_STRING_UCS2: {
+ struct efi_hii_sibt_string_ucs2_block *ucs2;
+
+ ucs2 = (void *)block;
+ nstrings++;
+ block = efi_hii_sibt_string_ucs2_block_next(ucs2);
+ break;
+ }
+ case EFI_HII_SIBT_END:
+ block = end;
+ break;
+ default:
+ EFI_PRINT("unknown HII string block type: %02x\n",
+ block->block_type);
+ return EFI_INVALID_PARAMETER;
+ }
+ }
+
+ stbl = calloc(sizeof(*stbl), 1);
+ if (!stbl) {
+ ret = EFI_OUT_OF_RESOURCES;
+ goto error;
+ }
+ stbl->strings = calloc(sizeof(stbl->strings[0]), nstrings);
+ if (!stbl->strings) {
+ ret = EFI_OUT_OF_RESOURCES;
+ goto error;
+ }
+ stbl->language_name =
+ get_unaligned_le16(&strings_package->language_name);
+ stbl->language = strdup((char *)strings_package->language);
+ if (!stbl->language) {
+ ret = EFI_OUT_OF_RESOURCES;
+ goto error;
+ }
+ stbl->nstrings = nstrings;
+
+ /* and now parse string entries and populate efi_string_table */
+ block = ((void *)strings_package)
+ + get_unaligned_le32(&strings_package->string_info_offset);
+
+ while ((void *)block < end) {
+ switch (block->block_type) {
+ case EFI_HII_SIBT_STRING_UCS2: {
+ struct efi_hii_sibt_string_ucs2_block *ucs2;
+
+ ucs2 = (void *)block;
+ EFI_PRINT("%4u: \"%ls\"\n", idx + 1, ucs2->string_text);
+ stbl->strings[idx].string =
+ u16_strdup(ucs2->string_text);
+ if (!stbl->strings[idx].string) {
+ ret = EFI_OUT_OF_RESOURCES;
+ goto error;
+ }
+ idx++;
+ /* FIXME: accessing u16 * here */
+ block = efi_hii_sibt_string_ucs2_block_next(ucs2);
+ break;
+ }
+ case EFI_HII_SIBT_END:
+ goto out;
+ default:
+ EFI_PRINT("unknown HII string block type: %02x\n",
+ block->block_type);
+ ret = EFI_INVALID_PARAMETER;
+ goto error;
+ }
+ }
+
+out:
+ list_add(&stbl->link, &hii->string_tables);
+ if (hii->max_string_id < nstrings)
+ hii->max_string_id = nstrings;
+
+ return EFI_SUCCESS;
+
+error:
+ if (stbl) {
+ free(stbl->language);
+ if (idx > 0)
+ while (--idx >= 0)
+ free(stbl->strings[idx].string);
+ free(stbl->strings);
+ }
+ free(stbl);
+
+ return ret;
+}
+
+static void remove_guid_package(struct efi_hii_packagelist *hii)
+{
+ struct efi_guid_data *data;
+
+ while (!list_empty(&hii->guid_list)) {
+ data = list_first_entry(&hii->guid_list,
+ struct efi_guid_data, link);
+ list_del(&data->link);
+ free(data);
+ }
+}
+
+static efi_status_t
+add_guid_package(struct efi_hii_packagelist *hii,
+ struct efi_hii_guid_package *package)
+{
+ struct efi_guid_data *data;
+
+ data = calloc(sizeof(*data), 1);
+ if (!data)
+ return EFI_OUT_OF_RESOURCES;
+
+ /* TODO: we don't know any about data field */
+ memcpy(&data->package, package, sizeof(*package));
+ list_add_tail(&data->link, &hii->guid_list);
+
+ return EFI_SUCCESS;
+}
+
+static void free_keyboard_layouts(struct efi_keyboard_package_data *package)
+{
+ struct efi_keyboard_layout_data *layout_data;
+
+ while (!list_empty(&package->keyboard_layout_list)) {
+ layout_data = list_first_entry(&package->keyboard_layout_list,
+ struct efi_keyboard_layout_data,
+ link);
+ list_del(&layout_data->link);
+ list_del(&layout_data->link_sys);
+ free(layout_data);
+ }
+}
+
+static void remove_keyboard_package(struct efi_hii_packagelist *hii)
+{
+ struct efi_keyboard_package_data *package;
+
+ while (!list_empty(&hii->keyboard_packages)) {
+ package = list_first_entry(&hii->keyboard_packages,
+ struct efi_keyboard_package_data,
+ link);
+ free_keyboard_layouts(package);
+ list_del(&package->link);
+ free(package);
+ }
+}
+
+static efi_status_t
+add_keyboard_package(struct efi_hii_packagelist *hii,
+ struct efi_hii_keyboard_package *keyboard_package)
+{
+ struct efi_keyboard_package_data *package_data;
+ struct efi_hii_keyboard_layout *layout;
+ struct efi_keyboard_layout_data *layout_data;
+ u16 layout_count, layout_length;
+ int i;
+
+ package_data = malloc(sizeof(*package_data));
+ if (!package_data)
+ return EFI_OUT_OF_RESOURCES;
+ INIT_LIST_HEAD(&package_data->link);
+ INIT_LIST_HEAD(&package_data->keyboard_layout_list);
+
+ layout = &keyboard_package->layout[0];
+ layout_count = get_unaligned_le16(&keyboard_package->layout_count);
+ for (i = 0; i < layout_count; i++) {
+ layout_length = get_unaligned_le16(&layout->layout_length);
+ layout_data = malloc(sizeof(*layout_data) + layout_length);
+ if (!layout_data)
+ goto out;
+
+ memcpy(&layout_data->keyboard_layout, layout, layout_length);
+ list_add_tail(&layout_data->link,
+ &package_data->keyboard_layout_list);
+ list_add_tail(&layout_data->link_sys,
+ &efi_keyboard_layout_list);
+
+ layout += layout_length;
+ }
+
+ list_add_tail(&package_data->link, &hii->keyboard_packages);
+
+ return EFI_SUCCESS;
+
+out:
+ free_keyboard_layouts(package_data);
+ free(package_data);
+
+ return EFI_OUT_OF_RESOURCES;
+}
+
+static struct efi_hii_packagelist *new_packagelist(void)
+{
+ struct efi_hii_packagelist *hii;
+
+ hii = malloc(sizeof(*hii));
+ hii->max_string_id = 0;
+ INIT_LIST_HEAD(&hii->string_tables);
+ INIT_LIST_HEAD(&hii->guid_list);
+ INIT_LIST_HEAD(&hii->keyboard_packages);
+
+ return hii;
+}
+
+static void free_packagelist(struct efi_hii_packagelist *hii)
+{
+ remove_strings_package(hii);
+ remove_guid_package(hii);
+ remove_keyboard_package(hii);
+
+ list_del(&hii->link);
+ free(hii);
+}
+
+static efi_status_t
+add_packages(struct efi_hii_packagelist *hii,
+ const struct efi_hii_package_list_header *package_list)
+{
+ struct efi_hii_package_header *package;
+ void *end;
+ efi_status_t ret = EFI_SUCCESS;
+
+ end = ((void *)package_list)
+ + get_unaligned_le32(&package_list->package_length);
+
+ EFI_PRINT("package_list: %pUl (%u)\n", &package_list->package_list_guid,
+ get_unaligned_le32(&package_list->package_length));
+
+ package = ((void *)package_list) + sizeof(*package_list);
+ while ((void *)package < end) {
+ EFI_PRINT("package=%p, package type=%x, length=%u\n", package,
+ efi_hii_package_type(package),
+ efi_hii_package_len(package));
+
+ switch (efi_hii_package_type(package)) {
+ case EFI_HII_PACKAGE_TYPE_GUID:
+ ret = add_guid_package(hii,
+ (struct efi_hii_guid_package *)package);
+ break;
+ case EFI_HII_PACKAGE_FORMS:
+ printf("\tForm package not supported\n");
+ ret = EFI_INVALID_PARAMETER;
+ break;
+ case EFI_HII_PACKAGE_STRINGS:
+ ret = add_strings_package(hii,
+ (struct efi_hii_strings_package *)package);
+ break;
+ case EFI_HII_PACKAGE_FONTS:
+ printf("\tFont package not supported\n");
+ ret = EFI_INVALID_PARAMETER;
+ break;
+ case EFI_HII_PACKAGE_IMAGES:
+ printf("\tImage package not supported\n");
+ ret = EFI_INVALID_PARAMETER;
+ break;
+ case EFI_HII_PACKAGE_SIMPLE_FONTS:
+ printf("\tSimple font package not supported\n");
+ ret = EFI_INVALID_PARAMETER;
+ break;
+ case EFI_HII_PACKAGE_DEVICE_PATH:
+ printf("\tDevice path package not supported\n");
+ ret = EFI_INVALID_PARAMETER;
+ break;
+ case EFI_HII_PACKAGE_KEYBOARD_LAYOUT:
+ ret = add_keyboard_package(hii,
+ (struct efi_hii_keyboard_package *)package);
+ break;
+ case EFI_HII_PACKAGE_ANIMATIONS:
+ printf("\tAnimation package not supported\n");
+ ret = EFI_INVALID_PARAMETER;
+ break;
+ case EFI_HII_PACKAGE_END:
+ goto out;
+ case EFI_HII_PACKAGE_TYPE_SYSTEM_BEGIN:
+ case EFI_HII_PACKAGE_TYPE_SYSTEM_END:
+ default:
+ break;
+ }
+
+ if (ret != EFI_SUCCESS)
+ return ret;
+
+ package = (void *)package + efi_hii_package_len(package);
+ }
+out:
+ // TODO in theory there is some notifications that should be sent..
+ return EFI_SUCCESS;
+}
+
+/*
+ * EFI_HII_DATABASE_PROTOCOL
+ */
+
+static efi_status_t EFIAPI
+new_package_list(const struct efi_hii_database_protocol *this,
+ const struct efi_hii_package_list_header *package_list,
+ const efi_handle_t driver_handle,
+ efi_hii_handle_t *handle)
+{
+ struct efi_hii_packagelist *hii;
+ efi_status_t ret;
+
+ EFI_ENTRY("%p, %p, %p, %p", this, package_list, driver_handle, handle);
+
+ if (!package_list || !handle)
+ return EFI_EXIT(EFI_INVALID_PARAMETER);
+
+ hii = new_packagelist();
+ if (!hii)
+ return EFI_EXIT(EFI_OUT_OF_RESOURCES);
+
+ ret = add_packages(hii, package_list);
+ if (ret != EFI_SUCCESS) {
+ free_packagelist(hii);
+ return EFI_EXIT(ret);
+ }
+
+ hii->driver_handle = driver_handle;
+ list_add_tail(&hii->link, &efi_package_lists);
+ *handle = hii;
+
+ return EFI_EXIT(EFI_SUCCESS);
+}
+
+static efi_status_t EFIAPI
+remove_package_list(const struct efi_hii_database_protocol *this,
+ efi_hii_handle_t handle)
+{
+ struct efi_hii_packagelist *hii = handle;
+
+ EFI_ENTRY("%p, %p", this, handle);
+
+ if (!handle || !efi_hii_packagelist_exists(handle))
+ return EFI_EXIT(EFI_NOT_FOUND);
+
+ free_packagelist(hii);
+
+ return EFI_EXIT(EFI_SUCCESS);
+}
+
+static efi_status_t EFIAPI
+update_package_list(const struct efi_hii_database_protocol *this,
+ efi_hii_handle_t handle,
+ const struct efi_hii_package_list_header *package_list)
+{
+ struct efi_hii_packagelist *hii = handle;
+ struct efi_hii_package_header *package;
+ void *end;
+ efi_status_t ret = EFI_SUCCESS;
+
+ EFI_ENTRY("%p, %p, %p", this, handle, package_list);
+
+ if (!handle || !efi_hii_packagelist_exists(handle))
+ return EFI_EXIT(EFI_NOT_FOUND);
+
+ if (!package_list)
+ return EFI_EXIT(EFI_INVALID_PARAMETER);
+
+ EFI_PRINT("package_list: %pUl (%u)\n", &package_list->package_list_guid,
+ get_unaligned_le32(&package_list->package_length));
+
+ package = ((void *)package_list) + sizeof(*package_list);
+ end = ((void *)package_list)
+ + get_unaligned_le32(&package_list->package_length);
+
+ while ((void *)package < end) {
+ EFI_PRINT("package=%p, package type=%x, length=%u\n", package,
+ efi_hii_package_type(package),
+ efi_hii_package_len(package));
+
+ switch (efi_hii_package_type(package)) {
+ case EFI_HII_PACKAGE_TYPE_GUID:
+ remove_guid_package(hii);
+ break;
+ case EFI_HII_PACKAGE_FORMS:
+ printf("\tForm package not supported\n");
+ ret = EFI_INVALID_PARAMETER;
+ break;
+ case EFI_HII_PACKAGE_STRINGS:
+ remove_strings_package(hii);
+ break;
+ case EFI_HII_PACKAGE_FONTS:
+ printf("\tFont package not supported\n");
+ ret = EFI_INVALID_PARAMETER;
+ break;
+ case EFI_HII_PACKAGE_IMAGES:
+ printf("\tImage package not supported\n");
+ ret = EFI_INVALID_PARAMETER;
+ break;
+ case EFI_HII_PACKAGE_SIMPLE_FONTS:
+ printf("\tSimple font package not supported\n");
+ ret = EFI_INVALID_PARAMETER;
+ break;
+ case EFI_HII_PACKAGE_DEVICE_PATH:
+ printf("\tDevice path package not supported\n");
+ ret = EFI_INVALID_PARAMETER;
+ break;
+ case EFI_HII_PACKAGE_KEYBOARD_LAYOUT:
+ remove_keyboard_package(hii);
+ break;
+ case EFI_HII_PACKAGE_ANIMATIONS:
+ printf("\tAnimation package not supported\n");
+ ret = EFI_INVALID_PARAMETER;
+ break;
+ case EFI_HII_PACKAGE_END:
+ goto out;
+ case EFI_HII_PACKAGE_TYPE_SYSTEM_BEGIN:
+ case EFI_HII_PACKAGE_TYPE_SYSTEM_END:
+ default:
+ break;
+ }
+
+ /* TODO: already removed some packages */
+ if (ret != EFI_SUCCESS)
+ return EFI_EXIT(ret);
+
+ package = ((void *)package)
+ + efi_hii_package_len(package);
+ }
+out:
+ ret = add_packages(hii, package_list);
+
+ return EFI_EXIT(ret);
+}
+
+static efi_status_t EFIAPI
+list_package_lists(const struct efi_hii_database_protocol *this,
+ u8 package_type,
+ const efi_guid_t *package_guid,
+ efi_uintn_t *handle_buffer_length,
+ efi_hii_handle_t *handle)
+{
+ struct efi_hii_packagelist *hii =
+ (struct efi_hii_packagelist *)handle;
+ int package_cnt, package_max;
+ efi_status_t ret = EFI_SUCCESS;
+
+ EFI_ENTRY("%p, %u, %pUl, %p, %p", this, package_type, package_guid,
+ handle_buffer_length, handle);
+
+ if (!handle_buffer_length ||
+ (*handle_buffer_length && !handle))
+ return EFI_EXIT(EFI_INVALID_PARAMETER);
+
+ if ((package_type != EFI_HII_PACKAGE_TYPE_GUID && package_guid) ||
+ (package_type == EFI_HII_PACKAGE_TYPE_GUID && !package_guid))
+ return EFI_EXIT(EFI_INVALID_PARAMETER);
+
+ EFI_PRINT("package type=%x, guid=%pUl, length=%zu\n", (int)package_type,
+ package_guid, *handle_buffer_length);
+
+ package_cnt = 0;
+ package_max = *handle_buffer_length / sizeof(*handle);
+ list_for_each_entry(hii, &efi_package_lists, link) {
+ switch (package_type) {
+ case EFI_HII_PACKAGE_TYPE_ALL:
+ break;
+ case EFI_HII_PACKAGE_TYPE_GUID:
+ if (!list_empty(&hii->guid_list))
+ break;
+ continue;
+ case EFI_HII_PACKAGE_FORMS:
+ printf("\tForm package not supported\n");
+ ret = EFI_INVALID_PARAMETER;
+ continue;
+ case EFI_HII_PACKAGE_STRINGS:
+ if (!list_empty(&hii->string_tables))
+ break;
+ continue;
+ case EFI_HII_PACKAGE_FONTS:
+ printf("\tFont package not supported\n");
+ ret = EFI_INVALID_PARAMETER;
+ continue;
+ case EFI_HII_PACKAGE_IMAGES:
+ printf("\tImage package not supported\n");
+ ret = EFI_INVALID_PARAMETER;
+ continue;
+ case EFI_HII_PACKAGE_SIMPLE_FONTS:
+ printf("\tSimple font package not supported\n");
+ ret = EFI_INVALID_PARAMETER;
+ continue;
+ case EFI_HII_PACKAGE_DEVICE_PATH:
+ printf("\tDevice path package not supported\n");
+ ret = EFI_INVALID_PARAMETER;
+ continue;
+ case EFI_HII_PACKAGE_KEYBOARD_LAYOUT:
+ if (!list_empty(&hii->keyboard_packages))
+ break;
+ continue;
+ case EFI_HII_PACKAGE_ANIMATIONS:
+ printf("\tAnimation package not supported\n");
+ ret = EFI_INVALID_PARAMETER;
+ continue;
+ case EFI_HII_PACKAGE_END:
+ case EFI_HII_PACKAGE_TYPE_SYSTEM_BEGIN:
+ case EFI_HII_PACKAGE_TYPE_SYSTEM_END:
+ default:
+ continue;
+ }
+
+ package_cnt++;
+ if (package_cnt <= package_max)
+ *handle++ = hii;
+ else
+ ret = EFI_BUFFER_TOO_SMALL;
+ }
+ *handle_buffer_length = package_cnt * sizeof(*handle);
+
+ return EFI_EXIT(ret);
+}
+
+static efi_status_t EFIAPI
+export_package_lists(const struct efi_hii_database_protocol *this,
+ efi_hii_handle_t handle,
+ efi_uintn_t *buffer_size,
+ struct efi_hii_package_list_header *buffer)
+{
+ EFI_ENTRY("%p, %p, %p, %p", this, handle, buffer_size, buffer);
+
+ if (!buffer_size || !buffer)
+ return EFI_EXIT(EFI_INVALID_PARAMETER);
+
+ return EFI_EXIT(EFI_NOT_FOUND);
+}
+
+static efi_status_t EFIAPI
+register_package_notify(const struct efi_hii_database_protocol *this,
+ u8 package_type,
+ const efi_guid_t *package_guid,
+ const void *package_notify_fn,
+ efi_uintn_t notify_type,
+ efi_handle_t *notify_handle)
+{
+ EFI_ENTRY("%p, %u, %pUl, %p, %zu, %p", this, package_type,
+ package_guid, package_notify_fn, notify_type,
+ notify_handle);
+
+ if (!notify_handle)
+ return EFI_EXIT(EFI_INVALID_PARAMETER);
+
+ if ((package_type != EFI_HII_PACKAGE_TYPE_GUID && package_guid) ||
+ (package_type == EFI_HII_PACKAGE_TYPE_GUID && !package_guid))
+ return EFI_EXIT(EFI_INVALID_PARAMETER);
+
+ return EFI_EXIT(EFI_OUT_OF_RESOURCES);
+}
+
+static efi_status_t EFIAPI
+unregister_package_notify(const struct efi_hii_database_protocol *this,
+ efi_handle_t notification_handle)
+{
+ EFI_ENTRY("%p, %p", this, notification_handle);
+
+ return EFI_EXIT(EFI_NOT_FOUND);
+}
+
+static efi_status_t EFIAPI
+find_keyboard_layouts(const struct efi_hii_database_protocol *this,
+ u16 *key_guid_buffer_length,
+ efi_guid_t *key_guid_buffer)
+{
+ struct efi_keyboard_layout_data *layout_data;
+ int package_cnt, package_max;
+ efi_status_t ret = EFI_SUCCESS;
+
+ EFI_ENTRY("%p, %p, %p", this, key_guid_buffer_length, key_guid_buffer);
+
+ if (!key_guid_buffer_length ||
+ (*key_guid_buffer_length && !key_guid_buffer))
+ return EFI_EXIT(EFI_INVALID_PARAMETER);
+
+ package_cnt = 0;
+ package_max = *key_guid_buffer_length / sizeof(*key_guid_buffer);
+ list_for_each_entry(layout_data, &efi_keyboard_layout_list, link_sys) {
+ package_cnt++;
+ if (package_cnt <= package_max)
+ memcpy(key_guid_buffer++,
+ &layout_data->keyboard_layout.guid,
+ sizeof(*key_guid_buffer));
+ else
+ ret = EFI_BUFFER_TOO_SMALL;
+ }
+ *key_guid_buffer_length = package_cnt * sizeof(*key_guid_buffer);
+
+ return EFI_EXIT(ret);
+}
+
+static efi_status_t EFIAPI
+get_keyboard_layout(const struct efi_hii_database_protocol *this,
+ efi_guid_t *key_guid,
+ u16 *keyboard_layout_length,
+ struct efi_hii_keyboard_layout *keyboard_layout)
+{
+ struct efi_keyboard_layout_data *layout_data;
+ u16 layout_length;
+
+ EFI_ENTRY("%p, %pUl, %p, %p", this, key_guid, keyboard_layout_length,
+ keyboard_layout);
+
+ if (!keyboard_layout_length ||
+ (*keyboard_layout_length && !keyboard_layout))
+ return EFI_EXIT(EFI_INVALID_PARAMETER);
+
+ /* TODO: no notion of current keyboard layout */
+ if (!key_guid)
+ return EFI_EXIT(EFI_INVALID_PARAMETER);
+
+ list_for_each_entry(layout_data, &efi_keyboard_layout_list, link_sys) {
+ if (!guidcmp(&layout_data->keyboard_layout.guid, key_guid))
+ goto found;
+ }
+
+ return EFI_EXIT(EFI_NOT_FOUND);
+
+found:
+ layout_length =
+ get_unaligned_le16(&layout_data->keyboard_layout.layout_length);
+ if (*keyboard_layout_length < layout_length) {
+ *keyboard_layout_length = layout_length;
+ return EFI_EXIT(EFI_BUFFER_TOO_SMALL);
+ }
+
+ memcpy(keyboard_layout, &layout_data->keyboard_layout, layout_length);
+
+ return EFI_EXIT(EFI_SUCCESS);
+}
+
+static efi_status_t EFIAPI
+set_keyboard_layout(const struct efi_hii_database_protocol *this,
+ efi_guid_t *key_guid)
+{
+ EFI_ENTRY("%p, %pUl", this, key_guid);
+
+ return EFI_EXIT(EFI_NOT_FOUND);
+}
+
+static efi_status_t EFIAPI
+get_package_list_handle(const struct efi_hii_database_protocol *this,
+ efi_hii_handle_t package_list_handle,
+ efi_handle_t *driver_handle)
+{
+ struct efi_hii_packagelist *hii;
+
+ EFI_ENTRY("%p, %p, %p", this, package_list_handle, driver_handle);
+
+ if (!driver_handle)
+ return EFI_EXIT(EFI_INVALID_PARAMETER);
+
+ list_for_each_entry(hii, &efi_package_lists, link) {
+ if (hii == package_list_handle) {
+ *driver_handle = hii->driver_handle;
+ return EFI_EXIT(EFI_SUCCESS);
+ }
+ }
+
+ return EFI_EXIT(EFI_NOT_FOUND);
+}
+
+const struct efi_hii_database_protocol efi_hii_database = {
+ .new_package_list = new_package_list,
+ .remove_package_list = remove_package_list,
+ .update_package_list = update_package_list,
+ .list_package_lists = list_package_lists,
+ .export_package_lists = export_package_lists,
+ .register_package_notify = register_package_notify,
+ .unregister_package_notify = unregister_package_notify,
+ .find_keyboard_layouts = find_keyboard_layouts,
+ .get_keyboard_layout = get_keyboard_layout,
+ .set_keyboard_layout = set_keyboard_layout,
+ .get_package_list_handle = get_package_list_handle
+};
+
+/*
+ * EFI_HII_STRING_PROTOCOL
+ */
+
+static bool language_match(char *language, char *languages)
+{
+ size_t n;
+
+ n = strlen(language);
+ /* match primary language? */
+ if (!strncasecmp(language, languages, n) &&
+ (languages[n] == ';' || languages[n] == '\0'))
+ return true;
+
+ return false;
+}
+
+static efi_status_t EFIAPI
+new_string(const struct efi_hii_string_protocol *this,
+ efi_hii_handle_t package_list,
+ efi_string_id_t *string_id,
+ const u8 *language,
+ const u16 *language_name,
+ const efi_string_t string,
+ const struct efi_font_info *string_font_info)
+{
+ struct efi_hii_packagelist *hii = package_list;
+ struct efi_string_table *stbl;
+
+ EFI_ENTRY("%p, %p, %p, \"%s\", %p, \"%ls\", %p", this, package_list,
+ string_id, language, language_name, string,
+ string_font_info);
+
+ if (!package_list || !efi_hii_packagelist_exists(package_list))
+ return EFI_EXIT(EFI_NOT_FOUND);
+
+ if (!string_id || !language || !string)
+ return EFI_EXIT(EFI_INVALID_PARAMETER);
+
+ list_for_each_entry(stbl, &hii->string_tables, link) {
+ if (language_match((char *)language, stbl->language)) {
+ efi_string_id_t new_id;
+ void *buf;
+ efi_string_t str;
+
+ new_id = ++hii->max_string_id;
+ if (stbl->nstrings < new_id) {
+ buf = realloc(stbl->strings,
+ sizeof(stbl->strings[0])
+ * new_id);
+ if (!buf)
+ return EFI_EXIT(EFI_OUT_OF_RESOURCES);
+
+ memset(&stbl->strings[stbl->nstrings], 0,
+ (new_id - stbl->nstrings)
+ * sizeof(stbl->strings[0]));
+ stbl->strings = buf;
+ stbl->nstrings = new_id;
+ }
+
+ str = u16_strdup(string);
+ if (!str)
+ return EFI_EXIT(EFI_OUT_OF_RESOURCES);
+
+ stbl->strings[new_id - 1].string = str;
+ *string_id = new_id;
+
+ return EFI_EXIT(EFI_SUCCESS);
+ }
+ }
+
+ return EFI_EXIT(EFI_NOT_FOUND);
+}
+
+static efi_status_t EFIAPI
+get_string(const struct efi_hii_string_protocol *this,
+ const u8 *language,
+ efi_hii_handle_t package_list,
+ efi_string_id_t string_id,
+ efi_string_t string,
+ efi_uintn_t *string_size,
+ struct efi_font_info **string_font_info)
+{
+ struct efi_hii_packagelist *hii = package_list;
+ struct efi_string_table *stbl;
+
+ EFI_ENTRY("%p, \"%s\", %p, %u, %p, %p, %p", this, language,
+ package_list, string_id, string, string_size,
+ string_font_info);
+
+ if (!package_list || !efi_hii_packagelist_exists(package_list))
+ return EFI_EXIT(EFI_NOT_FOUND);
+
+ list_for_each_entry(stbl, &hii->string_tables, link) {
+ if (language_match((char *)language, stbl->language)) {
+ efi_string_t str;
+ size_t len;
+
+ if (stbl->nstrings < string_id)
+ return EFI_EXIT(EFI_NOT_FOUND);
+
+ str = stbl->strings[string_id - 1].string;
+ if (str) {
+ len = (u16_strlen(str) + 1) * sizeof(u16);
+ if (*string_size < len) {
+ *string_size = len;
+
+ return EFI_EXIT(EFI_BUFFER_TOO_SMALL);
+ }
+ memcpy(string, str, len);
+ *string_size = len;
+ } else {
+ return EFI_EXIT(EFI_NOT_FOUND);
+ }
+
+ return EFI_EXIT(EFI_SUCCESS);
+ }
+ }
+
+ return EFI_EXIT(EFI_NOT_FOUND);
+}
+
+static efi_status_t EFIAPI
+set_string(const struct efi_hii_string_protocol *this,
+ efi_hii_handle_t package_list,
+ efi_string_id_t string_id,
+ const u8 *language,
+ const efi_string_t string,
+ const struct efi_font_info *string_font_info)
+{
+ struct efi_hii_packagelist *hii = package_list;
+ struct efi_string_table *stbl;
+
+ EFI_ENTRY("%p, %p, %u, \"%s\", \"%ls\", %p", this, package_list,
+ string_id, language, string, string_font_info);
+
+ if (!package_list || !efi_hii_packagelist_exists(package_list))
+ return EFI_EXIT(EFI_NOT_FOUND);
+
+ if (string_id > hii->max_string_id)
+ return EFI_EXIT(EFI_NOT_FOUND);
+
+ if (!string || !language)
+ return EFI_EXIT(EFI_INVALID_PARAMETER);
+
+ list_for_each_entry(stbl, &hii->string_tables, link) {
+ if (language_match((char *)language, stbl->language)) {
+ efi_string_t str;
+
+ if (hii->max_string_id < string_id)
+ return EFI_EXIT(EFI_NOT_FOUND);
+
+ if (stbl->nstrings < string_id) {
+ void *buf;
+
+ buf = realloc(stbl->strings,
+ string_id
+ * sizeof(stbl->strings[0]));
+ if (!buf)
+ return EFI_EXIT(EFI_OUT_OF_RESOURCES);
+
+ memset(&stbl->strings[string_id - 1], 0,
+ (string_id - stbl->nstrings)
+ * sizeof(stbl->strings[0]));
+ stbl->strings = buf;
+ }
+
+ str = u16_strdup(string);
+ if (!str)
+ return EFI_EXIT(EFI_OUT_OF_RESOURCES);
+
+ free(stbl->strings[string_id - 1].string);
+ stbl->strings[string_id - 1].string = str;
+
+ return EFI_EXIT(EFI_SUCCESS);
+ }
+ }
+
+ return EFI_EXIT(EFI_NOT_FOUND);
+}
+
+static efi_status_t EFIAPI
+get_languages(const struct efi_hii_string_protocol *this,
+ efi_hii_handle_t package_list,
+ u8 *languages,
+ efi_uintn_t *languages_size)
+{
+ struct efi_hii_packagelist *hii = package_list;
+ struct efi_string_table *stbl;
+ size_t len = 0;
+ char *p;
+
+ EFI_ENTRY("%p, %p, %p, %p", this, package_list, languages,
+ languages_size);
+
+ if (!package_list || !efi_hii_packagelist_exists(package_list))
+ return EFI_EXIT(EFI_NOT_FOUND);
+
+ if (!languages_size ||
+ (*languages_size && !languages))
+ return EFI_EXIT(EFI_INVALID_PARAMETER);
+
+ /* figure out required size: */
+ list_for_each_entry(stbl, &hii->string_tables, link) {
+ len += strlen((char *)stbl->language) + 1;
+ }
+
+ if (*languages_size < len) {
+ *languages_size = len;
+
+ return EFI_EXIT(EFI_BUFFER_TOO_SMALL);
+ }
+
+ p = (char *)languages;
+ list_for_each_entry(stbl, &hii->string_tables, link) {
+ if (p != (char *)languages)
+ *p++ = ';';
+ strcpy(p, stbl->language);
+ p += strlen((char *)stbl->language);
+ }
+ *p = '\0';
+
+ EFI_PRINT("languages: %s\n", languages);
+
+ return EFI_EXIT(EFI_SUCCESS);
+}
+
+static efi_status_t EFIAPI
+get_secondary_languages(const struct efi_hii_string_protocol *this,
+ efi_hii_handle_t package_list,
+ const u8 *primary_language,
+ u8 *secondary_languages,
+ efi_uintn_t *secondary_languages_size)
+{
+ struct efi_hii_packagelist *hii = package_list;
+ struct efi_string_table *stbl;
+ bool found = false;
+
+ EFI_ENTRY("%p, %p, \"%s\", %p, %p", this, package_list,
+ primary_language, secondary_languages,
+ secondary_languages_size);
+
+ if (!package_list || !efi_hii_packagelist_exists(package_list))
+ return EFI_EXIT(EFI_NOT_FOUND);
+
+ if (!secondary_languages_size ||
+ (*secondary_languages_size && !secondary_languages))
+ return EFI_EXIT(EFI_INVALID_PARAMETER);
+
+ list_for_each_entry(stbl, &hii->string_tables, link) {
+ if (language_match((char *)primary_language, stbl->language)) {
+ found = true;
+ break;
+ }
+ }
+ if (!found)
+ return EFI_EXIT(EFI_INVALID_LANGUAGE);
+
+ /*
+ * TODO: What is secondary language?
+ * *secondary_languages = '\0';
+ * *secondary_languages_size = 0;
+ */
+
+ return EFI_EXIT(EFI_NOT_FOUND);
+}
+
+const struct efi_hii_string_protocol efi_hii_string = {
+ .new_string = new_string,
+ .get_string = get_string,
+ .set_string = set_string,
+ .get_languages = get_languages,
+ .get_secondary_languages = get_secondary_languages
+};
diff --git a/lib/efi_loader/efi_hii_config.c b/lib/efi_loader/efi_hii_config.c
new file mode 100644
index 0000000000..26ea4b9bc0
--- /dev/null
+++ b/lib/efi_loader/efi_hii_config.c
@@ -0,0 +1,146 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * EFI Human Interface Infrastructure ... Configuration
+ *
+ * Copyright (c) 2017 Leif Lindholm
+ * Copyright (c) 2018 AKASHI Takahiro, Linaro Limited
+ */
+
+#include <common.h>
+#include <efi_loader.h>
+
+const efi_guid_t efi_guid_hii_config_routing_protocol
+ = EFI_HII_CONFIG_ROUTING_PROTOCOL_GUID;
+const efi_guid_t efi_guid_hii_config_access_protocol
+ = EFI_HII_CONFIG_ACCESS_PROTOCOL_GUID;
+
+/*
+ * EFI_HII_CONFIG_ROUTING_PROTOCOL
+ */
+
+static efi_status_t EFIAPI
+extract_config(const struct efi_hii_config_routing_protocol *this,
+ const efi_string_t request,
+ efi_string_t *progress,
+ efi_string_t *results)
+{
+ EFI_ENTRY("%p, \"%ls\", %p, %p", this, request, progress, results);
+
+ return EFI_EXIT(EFI_OUT_OF_RESOURCES);
+}
+
+static efi_status_t EFIAPI
+export_config(const struct efi_hii_config_routing_protocol *this,
+ efi_string_t *results)
+{
+ EFI_ENTRY("%p, %p", this, results);
+
+ return EFI_EXIT(EFI_OUT_OF_RESOURCES);
+}
+
+static efi_status_t EFIAPI
+route_config(const struct efi_hii_config_routing_protocol *this,
+ const efi_string_t configuration,
+ efi_string_t *progress)
+{
+ EFI_ENTRY("%p, \"%ls\", %p", this, configuration, progress);
+
+ return EFI_EXIT(EFI_OUT_OF_RESOURCES);
+}
+
+static efi_status_t EFIAPI
+block_to_config(const struct efi_hii_config_routing_protocol *this,
+ const efi_string_t config_request,
+ const u8 *block,
+ const efi_uintn_t block_size,
+ efi_string_t *config,
+ efi_string_t *progress)
+{
+ EFI_ENTRY("%p, \"%ls\", %p, %zu, %p, %p", this, config_request,
+ block, block_size, config, progress);
+
+ return EFI_EXIT(EFI_OUT_OF_RESOURCES);
+}
+
+static efi_status_t EFIAPI
+config_to_block(const struct efi_hii_config_routing_protocol *this,
+ const efi_string_t config_resp,
+ const u8 *block,
+ const efi_uintn_t *block_size,
+ efi_string_t *progress)
+{
+ EFI_ENTRY("%p, \"%ls\", %p, %p, %p", this, config_resp,
+ block, block_size, progress);
+
+ return EFI_EXIT(EFI_OUT_OF_RESOURCES);
+}
+
+static efi_status_t EFIAPI
+get_alt_config(const struct efi_hii_config_routing_protocol *this,
+ const efi_string_t config_resp,
+ const efi_guid_t *guid,
+ const efi_string_t name,
+ const struct efi_device_path *device_path,
+ const efi_string_t alt_cfg_id,
+ efi_string_t *alt_cfg_resp)
+{
+ EFI_ENTRY("%p, \"%ls\", %pUl, \"%ls\", %p, \"%ls\", %p",
+ this, config_resp, guid, name, device_path,
+ alt_cfg_id, alt_cfg_resp);
+
+ return EFI_EXIT(EFI_OUT_OF_RESOURCES);
+}
+
+/*
+ * EFI_HII_ACCESS_PROTOCOL
+ */
+
+efi_status_t EFIAPI
+extract_config_access(const struct efi_hii_config_access_protocol *this,
+ const efi_string_t request,
+ efi_string_t *progress,
+ efi_string_t *results)
+{
+ EFI_ENTRY("%p, \"%ls\", %p, %p", this, request, progress, results);
+
+ return EFI_EXIT(EFI_OUT_OF_RESOURCES);
+};
+
+efi_status_t EFIAPI
+route_config_access(const struct efi_hii_config_access_protocol *this,
+ const efi_string_t configuration,
+ efi_string_t *progress)
+{
+ EFI_ENTRY("%p, \"%ls\", %p", this, configuration, progress);
+
+ return EFI_EXIT(EFI_OUT_OF_RESOURCES);
+};
+
+efi_status_t EFIAPI
+form_callback(const struct efi_hii_config_access_protocol *this,
+ efi_browser_action_t action,
+ efi_question_id_t question_id,
+ u8 type,
+ union efi_ifr_type_value *value,
+ efi_browser_action_request_t *action_request)
+{
+ EFI_ENTRY("%p, 0x%zx, 0x%x, 0x%x, %p, %p", this, action,
+ question_id, type, value, action_request);
+
+ return EFI_EXIT(EFI_DEVICE_ERROR);
+};
+
+const struct efi_hii_config_routing_protocol efi_hii_config_routing = {
+ .extract_config = extract_config,
+ .export_config = export_config,
+ .route_config = route_config,
+ .block_to_config = block_to_config,
+ .config_to_block = config_to_block,
+ .get_alt_config = get_alt_config
+};
+
+const struct efi_hii_config_access_protocol efi_hii_config_access = {
+ .extract_config_access = extract_config_access,
+ .route_config_access = route_config_access,
+ .form_callback = form_callback
+};
diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
index 4bb517473e..ebd2b36c03 100644
--- a/lib/efi_loader/efi_memory.c
+++ b/lib/efi_loader/efi_memory.c
@@ -554,6 +554,12 @@ __weak void efi_add_known_memory(void)
u64 ram_top = board_get_usable_ram_top(0) & ~EFI_PAGE_MASK;
int i;
+ /*
+ * ram_top is just outside mapped memory. So use an offset of one for
+ * mapping the sandbox address.
+ */
+ ram_top = (uintptr_t)map_sysmem(ram_top - 1, 0) + 1;
+
/* Fix for 32bit targets with ram_top at 4G */
if (!ram_top)
ram_top = 0x100000000ULL;
diff --git a/lib/efi_loader/efi_runtime.c b/lib/efi_loader/efi_runtime.c
index fff93f0960..636dfdab39 100644
--- a/lib/efi_loader/efi_runtime.c
+++ b/lib/efi_loader/efi_runtime.c
@@ -530,7 +530,8 @@ static efi_status_t EFIAPI efi_set_virtual_address_map(
* This function adds a memory-mapped IO region to the memory map to make it
* available at runtime.
*
- * @mmio_ptr: address of the memory-mapped IO region
+ * @mmio_ptr: pointer to a pointer to the start of the memory-mapped
+ * IO region
* @len: size of the memory-mapped IO region
* Returns: status code
*/
diff --git a/lib/efi_loader/efi_setup.c b/lib/efi_loader/efi_setup.c
new file mode 100644
index 0000000000..8266d06c2e
--- /dev/null
+++ b/lib/efi_loader/efi_setup.c
@@ -0,0 +1,86 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * EFI setup code
+ *
+ * Copyright (c) 2016-2018 Alexander Graf et al.
+ */
+
+#include <common.h>
+#include <efi_loader.h>
+
+#define OBJ_LIST_NOT_INITIALIZED 1
+
+static efi_status_t efi_obj_list_initialized = OBJ_LIST_NOT_INITIALIZED;
+
+/* Initialize and populate EFI object list */
+efi_status_t efi_init_obj_list(void)
+{
+ efi_status_t ret = EFI_SUCCESS;
+
+ /*
+ * On the ARM architecture gd is mapped to a fixed register (r9 or x18).
+ * As this register may be overwritten by an EFI payload we save it here
+ * and restore it on every callback entered.
+ */
+ efi_save_gd();
+
+ /* Initialize once only */
+ if (efi_obj_list_initialized != OBJ_LIST_NOT_INITIALIZED)
+ return efi_obj_list_initialized;
+
+ /* Initialize system table */
+ ret = efi_initialize_system_table();
+ if (ret != EFI_SUCCESS)
+ goto out;
+
+ /* Initialize root node */
+ ret = efi_root_node_register();
+ if (ret != EFI_SUCCESS)
+ goto out;
+
+ /* Initialize EFI driver uclass */
+ ret = efi_driver_init();
+ if (ret != EFI_SUCCESS)
+ goto out;
+
+ ret = efi_console_register();
+ if (ret != EFI_SUCCESS)
+ goto out;
+#ifdef CONFIG_PARTITIONS
+ ret = efi_disk_register();
+ if (ret != EFI_SUCCESS)
+ goto out;
+#endif
+#if defined(CONFIG_LCD) || defined(CONFIG_DM_VIDEO)
+ ret = efi_gop_register();
+ if (ret != EFI_SUCCESS)
+ goto out;
+#endif
+#ifdef CONFIG_NET
+ ret = efi_net_register();
+ if (ret != EFI_SUCCESS)
+ goto out;
+#endif
+#ifdef CONFIG_GENERATE_ACPI_TABLE
+ ret = efi_acpi_register();
+ if (ret != EFI_SUCCESS)
+ goto out;
+#endif
+#ifdef CONFIG_GENERATE_SMBIOS_TABLE
+ ret = efi_smbios_register();
+ if (ret != EFI_SUCCESS)
+ goto out;
+#endif
+ ret = efi_watchdog_register();
+ if (ret != EFI_SUCCESS)
+ goto out;
+
+ /* Initialize EFI runtime services */
+ ret = efi_reset_system_init();
+ if (ret != EFI_SUCCESS)
+ goto out;
+
+out:
+ efi_obj_list_initialized = ret;
+ return ret;
+}
diff --git a/lib/efi_loader/efi_variable.c b/lib/efi_loader/efi_variable.c
index 19d9cb865f..e0d7f5736d 100644
--- a/lib/efi_loader/efi_variable.c
+++ b/lib/efi_loader/efi_variable.c
@@ -8,6 +8,10 @@
#include <malloc.h>
#include <charset.h>
#include <efi_loader.h>
+#include <hexdump.h>
+#include <environment.h>
+#include <search.h>
+#include <uuid.h>
#define READ_ONLY BIT(31)
@@ -46,60 +50,21 @@
#define PREFIX_LEN (strlen("efi_xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_"))
-static int hex(int ch)
-{
- if (ch >= 'a' && ch <= 'f')
- return ch-'a'+10;
- if (ch >= '0' && ch <= '9')
- return ch-'0';
- if (ch >= 'A' && ch <= 'F')
- return ch-'A'+10;
- return -1;
-}
-
-static int hex2mem(u8 *mem, const char *hexstr, int size)
-{
- int nibble;
- int i;
-
- for (i = 0; i < size; i++) {
- if (*hexstr == '\0')
- break;
-
- nibble = hex(*hexstr);
- if (nibble < 0)
- return -1;
-
- *mem = nibble;
- hexstr++;
-
- nibble = hex(*hexstr);
- if (nibble < 0)
- return -1;
-
- *mem = (*mem << 4) | nibble;
- hexstr++;
- mem++;
- }
-
- return i;
-}
-
-static char *mem2hex(char *hexstr, const u8 *mem, int count)
-{
- static const char hexchars[] = "0123456789abcdef";
-
- while (count-- > 0) {
- u8 ch = *mem++;
- *hexstr++ = hexchars[ch >> 4];
- *hexstr++ = hexchars[ch & 0xf];
- }
-
- return hexstr;
-}
-
+/**
+ * efi_to_native() - convert the UEFI variable name and vendor GUID to U-Boot
+ * variable name
+ *
+ * The U-Boot variable name is a concatenation of prefix 'efi', the hexstring
+ * encoded vendor GUID, and the UTF-8 encoded UEFI variable name separated by
+ * underscores, e.g. 'efi_8be4df61-93ca-11d2-aa0d-00e098032b8c_BootOrder'.
+ *
+ * @native: pointer to pointer to U-Boot variable name
+ * @variable_name: UEFI variable name
+ * @vendor: vendor GUID
+ * Return: status code
+ */
static efi_status_t efi_to_native(char **native, const u16 *variable_name,
- efi_guid_t *vendor)
+ const efi_guid_t *vendor)
{
size_t len;
char *pos;
@@ -116,6 +81,15 @@ static efi_status_t efi_to_native(char **native, const u16 *variable_name,
return EFI_SUCCESS;
}
+/**
+ * prefix() - skip over prefix
+ *
+ * Skip over a prefix string.
+ *
+ * @str: string with prefix
+ * @prefix: prefix string
+ * Return: string without prefix, or NULL if prefix not found
+ */
static const char *prefix(const char *str, const char *prefix)
{
size_t n = strlen(prefix);
@@ -124,7 +98,16 @@ static const char *prefix(const char *str, const char *prefix)
return NULL;
}
-/* parse attributes part of variable value, if present: */
+/**
+ * parse_attr() - decode attributes part of variable value
+ *
+ * Convert the string encoded attributes of a UEFI variable to a bit mask.
+ * TODO: Several attributes are not supported.
+ *
+ * @str: value of U-Boot variable
+ * @attrp: pointer to UEFI attributes
+ * Return: pointer to remainder of U-Boot variable value
+ */
static const char *parse_attr(const char *str, u32 *attrp)
{
u32 attr = 0;
@@ -162,10 +145,24 @@ static const char *parse_attr(const char *str, u32 *attrp)
return str;
}
-/* http://wiki.phoenix.com/wiki/index.php/EFI_RUNTIME_SERVICES#GetVariable.28.29 */
-efi_status_t EFIAPI efi_get_variable(u16 *variable_name, efi_guid_t *vendor,
- u32 *attributes, efi_uintn_t *data_size,
- void *data)
+/**
+ * efi_efi_get_variable() - retrieve value of a UEFI variable
+ *
+ * This function implements the GetVariable runtime service.
+ *
+ * See the Unified Extensible Firmware Interface (UEFI) specification for
+ * details.
+ *
+ * @variable_name: name of the variable
+ * @vendor: vendor GUID
+ * @attributes: attributes of the variable
+ * @data_size: size of the buffer to which the variable value is copied
+ * @data: buffer to which the variable value is copied
+ * Return: status code
+ */
+efi_status_t EFIAPI efi_get_variable(u16 *variable_name,
+ const efi_guid_t *vendor, u32 *attributes,
+ efi_uintn_t *data_size, void *data)
{
char *native_name;
efi_status_t ret;
@@ -195,7 +192,7 @@ efi_status_t EFIAPI efi_get_variable(u16 *variable_name, efi_guid_t *vendor,
in_size = *data_size;
if ((s = prefix(val, "(blob)"))) {
- unsigned len = strlen(s);
+ size_t len = strlen(s);
/* number of hexadecimal digits must be even */
if (len & 1)
@@ -211,7 +208,7 @@ efi_status_t EFIAPI efi_get_variable(u16 *variable_name, efi_guid_t *vendor,
if (!data)
return EFI_EXIT(EFI_INVALID_PARAMETER);
- if (hex2mem(data, s, len) != len)
+ if (hex2bin(data, s, len))
return EFI_EXIT(EFI_DEVICE_ERROR);
debug("%s: got value: \"%s\"\n", __func__, s);
@@ -241,20 +238,182 @@ efi_status_t EFIAPI efi_get_variable(u16 *variable_name, efi_guid_t *vendor,
return EFI_EXIT(EFI_SUCCESS);
}
-/* http://wiki.phoenix.com/wiki/index.php/EFI_RUNTIME_SERVICES#GetNextVariableName.28.29 */
+static char *efi_variables_list;
+static char *efi_cur_variable;
+
+/**
+ * parse_uboot_variable() - parse a u-boot variable and get uefi-related
+ * information
+ * @variable: whole data of u-boot variable (ie. name=value)
+ * @variable_name_size: size of variable_name buffer in byte
+ * @variable_name: name of uefi variable in u16, null-terminated
+ * @vendor: vendor's guid
+ * @attributes: attributes
+ *
+ * A uefi variable is encoded into a u-boot variable as described above.
+ * This function parses such a u-boot variable and retrieve uefi-related
+ * information into respective parameters. In return, variable_name_size
+ * is the size of variable name including NULL.
+ *
+ * Return: EFI_SUCCESS if parsing is OK, EFI_NOT_FOUND when
+ the entire variable list has been returned,
+ otherwise non-zero status code
+ */
+static efi_status_t parse_uboot_variable(char *variable,
+ efi_uintn_t *variable_name_size,
+ u16 *variable_name,
+ const efi_guid_t *vendor,
+ u32 *attributes)
+{
+ char *guid, *name, *end, c;
+ unsigned long name_len;
+ u16 *p;
+
+ guid = strchr(variable, '_');
+ if (!guid)
+ return EFI_INVALID_PARAMETER;
+ guid++;
+ name = strchr(guid, '_');
+ if (!name)
+ return EFI_INVALID_PARAMETER;
+ name++;
+ end = strchr(name, '=');
+ if (!end)
+ return EFI_INVALID_PARAMETER;
+
+ name_len = end - name;
+ if (*variable_name_size < (name_len + 1)) {
+ *variable_name_size = name_len + 1;
+ return EFI_BUFFER_TOO_SMALL;
+ }
+ end++; /* point to value */
+
+ /* variable name */
+ p = variable_name;
+ utf8_utf16_strncpy(&p, name, name_len);
+ variable_name[name_len] = 0;
+ *variable_name_size = name_len + 1;
+
+ /* guid */
+ c = *(name - 1);
+ *(name - 1) = '\0'; /* guid need be null-terminated here */
+ uuid_str_to_bin(guid, (unsigned char *)vendor, UUID_STR_FORMAT_GUID);
+ *(name - 1) = c;
+
+ /* attributes */
+ parse_attr(end, attributes);
+
+ return EFI_SUCCESS;
+}
+
+/**
+ * efi_get_next_variable_name() - enumerate the current variable names
+ * @variable_name_size: size of variable_name buffer in byte
+ * @variable_name: name of uefi variable's name in u16
+ * @vendor: vendor's guid
+ *
+ * This function implements the GetNextVariableName service.
+ *
+ * See the Unified Extensible Firmware Interface (UEFI) specification for
+ * details: http://wiki.phoenix.com/wiki/index.php/
+ * EFI_RUNTIME_SERVICES#GetNextVariableName.28.29
+ *
+ * Return: status code
+ */
efi_status_t EFIAPI efi_get_next_variable_name(efi_uintn_t *variable_name_size,
u16 *variable_name,
- efi_guid_t *vendor)
+ const efi_guid_t *vendor)
{
+ char *native_name, *variable;
+ ssize_t name_len, list_len;
+ char regex[256];
+ char * const regexlist[] = {regex};
+ u32 attributes;
+ int i;
+ efi_status_t ret;
+
EFI_ENTRY("%p \"%ls\" %pUl", variable_name_size, variable_name, vendor);
- return EFI_EXIT(EFI_DEVICE_ERROR);
+ if (!variable_name_size || !variable_name || !vendor)
+ EFI_EXIT(EFI_INVALID_PARAMETER);
+
+ if (variable_name[0]) {
+ /* check null-terminated string */
+ for (i = 0; i < *variable_name_size; i++)
+ if (!variable_name[i])
+ break;
+ if (i >= *variable_name_size)
+ return EFI_EXIT(EFI_INVALID_PARAMETER);
+
+ /* search for the last-returned variable */
+ ret = efi_to_native(&native_name, variable_name, vendor);
+ if (ret)
+ return EFI_EXIT(ret);
+
+ name_len = strlen(native_name);
+ for (variable = efi_variables_list; variable && *variable;) {
+ if (!strncmp(variable, native_name, name_len) &&
+ variable[name_len] == '=')
+ break;
+
+ variable = strchr(variable, '\n');
+ if (variable)
+ variable++;
+ }
+
+ free(native_name);
+ if (!(variable && *variable))
+ return EFI_EXIT(EFI_INVALID_PARAMETER);
+
+ /* next variable */
+ variable = strchr(variable, '\n');
+ if (variable)
+ variable++;
+ if (!(variable && *variable))
+ return EFI_EXIT(EFI_NOT_FOUND);
+ } else {
+ /*
+ *new search: free a list used in the previous search
+ */
+ free(efi_variables_list);
+ efi_variables_list = NULL;
+ efi_cur_variable = NULL;
+
+ snprintf(regex, 256, "efi_.*-.*-.*-.*-.*_.*");
+ list_len = hexport_r(&env_htab, '\n',
+ H_MATCH_REGEX | H_MATCH_KEY,
+ &efi_variables_list, 0, 1, regexlist);
+ /* 1 indicates that no match was found */
+ if (list_len <= 1)
+ return EFI_EXIT(EFI_NOT_FOUND);
+
+ variable = efi_variables_list;
+ }
+
+ ret = parse_uboot_variable(variable, variable_name_size, variable_name,
+ vendor, &attributes);
+
+ return EFI_EXIT(ret);
}
-/* http://wiki.phoenix.com/wiki/index.php/EFI_RUNTIME_SERVICES#SetVariable.28.29 */
-efi_status_t EFIAPI efi_set_variable(u16 *variable_name, efi_guid_t *vendor,
- u32 attributes, efi_uintn_t data_size,
- void *data)
+/**
+ * efi_efi_set_variable() - set value of a UEFI variable
+ *
+ * This function implements the SetVariable runtime service.
+ *
+ * See the Unified Extensible Firmware Interface (UEFI) specification for
+ * details.
+ *
+ * @variable_name: name of the variable
+ * @vendor: vendor GUID
+ * @attributes: attributes of the variable
+ * @data_size: size of the buffer with the variable value
+ * @data: buffer with the variable value
+ * Return: status code
+ */
+efi_status_t EFIAPI efi_set_variable(u16 *variable_name,
+ const efi_guid_t *vendor, u32 attributes,
+ efi_uintn_t data_size, const void *data)
{
char *native_name = NULL, *val = NULL, *s;
efi_status_t ret = EFI_SUCCESS;
@@ -301,7 +460,10 @@ efi_status_t EFIAPI efi_set_variable(u16 *variable_name, efi_guid_t *vendor,
s = val;
- /* store attributes: */
+ /*
+ * store attributes
+ * TODO: several attributes are not supported
+ */
attributes &= (EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS);
s += sprintf(s, "{");
while (attributes) {
@@ -320,7 +482,7 @@ efi_status_t EFIAPI efi_set_variable(u16 *variable_name, efi_guid_t *vendor,
/* store payload: */
s += sprintf(s, "(blob)");
- s = mem2hex(s, data, data_size);
+ s = bin2hex(s, data, data_size);
*s = '\0';
debug("%s: setting: %s=%s\n", __func__, native_name, val);
diff --git a/lib/efi_loader/helloworld.c b/lib/efi_loader/helloworld.c
index 2905479e65..426f276361 100644
--- a/lib/efi_loader/helloworld.c
+++ b/lib/efi_loader/helloworld.c
@@ -18,30 +18,6 @@ static const efi_guid_t acpi_guid = EFI_ACPI_TABLE_GUID;
static const efi_guid_t smbios_guid = SMBIOS_TABLE_GUID;
/**
- * hw_memcmp() - compare memory areas
- *
- * @buf1: pointer to first area
- * @buf2: pointer to second area
- * @length: number of bytes to compare
- * Return: 0 if both memory areas are the same, otherwise the sign of the
- * result value is the same as the sign of ghe difference between
- * the first differing pair of bytes taken as u8.
- */
-static int hw_memcmp(const void *buf1, const void *buf2, size_t length)
-{
- const u8 *pos1 = buf1;
- const u8 *pos2 = buf2;
-
- for (; length; --length) {
- if (*pos1 != *pos2)
- return *pos1 - *pos2;
- ++pos1;
- ++pos2;
- }
- return 0;
-}
-
-/**
* efi_main() - entry point of the EFI application.
*
* @handle: handle of the loaded image
@@ -88,16 +64,16 @@ efi_status_t EFIAPI efi_main(efi_handle_t handle,
}
/* Find configuration tables */
for (i = 0; i < systable->nr_tables; ++i) {
- if (!hw_memcmp(&systable->tables[i].guid, &fdt_guid,
- sizeof(efi_guid_t)))
+ if (!memcmp(&systable->tables[i].guid, &fdt_guid,
+ sizeof(efi_guid_t)))
con_out->output_string
(con_out, L"Have device tree\r\n");
- if (!hw_memcmp(&systable->tables[i].guid, &acpi_guid,
- sizeof(efi_guid_t)))
+ if (!memcmp(&systable->tables[i].guid, &acpi_guid,
+ sizeof(efi_guid_t)))
con_out->output_string
(con_out, L"Have ACPI 2.0 table\r\n");
- if (!hw_memcmp(&systable->tables[i].guid, &smbios_guid,
- sizeof(efi_guid_t)))
+ if (!memcmp(&systable->tables[i].guid, &smbios_guid,
+ sizeof(efi_guid_t)))
con_out->output_string
(con_out, L"Have SMBIOS table\r\n");
}
diff --git a/lib/efi_selftest/Makefile b/lib/efi_selftest/Makefile
index 743b482044..7f4eafb2fe 100644
--- a/lib/efi_selftest/Makefile
+++ b/lib/efi_selftest/Makefile
@@ -6,9 +6,9 @@
# object inclusion implicitly depends on it
CFLAGS_efi_selftest_miniapp_exit.o := $(CFLAGS_EFI) -Os -ffreestanding
-CFLAGS_REMOVE_efi_selftest_miniapp_exit.o := $(CFLAGS_NON_EFI) -Os
+CFLAGS_REMOVE_efi_selftest_miniapp_exit.o := $(CFLAGS_NON_EFI)
CFLAGS_efi_selftest_miniapp_return.o := $(CFLAGS_EFI) -Os -ffreestanding
-CFLAGS_REMOVE_efi_selftest_miniapp_return.o := $(CFLAGS_NON_EFI) -Os
+CFLAGS_REMOVE_efi_selftest_miniapp_return.o := $(CFLAGS_NON_EFI)
obj-y += \
efi_selftest.o \
@@ -40,14 +40,15 @@ efi_selftest_variables.o \
efi_selftest_watchdog.o
obj-$(CONFIG_CPU_V7) += efi_selftest_unaligned.o
+obj-$(CONFIG_EFI_LOADER_HII) += efi_selftest_hii.o
ifeq ($(CONFIG_BLK)$(CONFIG_PARTITIONS),yy)
obj-y += efi_selftest_block_device.o
endif
-# TODO: As of v2018.01 the relocation code for the EFI application cannot
-# be built on x86_64.
-ifeq ($(CONFIG_X86_64)$(CONFIG_SANDBOX),)
+# TODO: As of v2019.01 the relocation code for the EFI application cannot
+# be built on ARMv7-M, Sandbox, and x86_64.
+ifeq ($(CONFIG_SANDBOX)$(CONFIG_CPU_V7M)$(CONFIG_X86_64),)
obj-y += \
efi_selftest_startimage_exit.o \
diff --git a/lib/efi_selftest/efi_selftest_block_device.c b/lib/efi_selftest/efi_selftest_block_device.c
index f038da9f19..1cdd8307f4 100644
--- a/lib/efi_selftest/efi_selftest_block_device.c
+++ b/lib/efi_selftest/efi_selftest_block_device.c
@@ -387,7 +387,7 @@ static int execute(void)
}
/* Read file */
- ret = root->open(root, &file, (s16 *)L"hello.txt", EFI_FILE_MODE_READ,
+ ret = root->open(root, &file, L"hello.txt", EFI_FILE_MODE_READ,
0);
if (ret != EFI_SUCCESS) {
efi_st_error("Failed to open file\n");
@@ -431,7 +431,7 @@ static int execute(void)
#ifdef CONFIG_FAT_WRITE
/* Write file */
- ret = root->open(root, &file, (s16 *)L"u-boot.txt", EFI_FILE_MODE_READ |
+ ret = root->open(root, &file, L"u-boot.txt", EFI_FILE_MODE_READ |
EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE, 0);
if (ret != EFI_SUCCESS) {
efi_st_error("Failed to open file\n");
@@ -463,7 +463,7 @@ static int execute(void)
/* Verify file */
boottime->set_mem(buf, sizeof(buf), 0);
- ret = root->open(root, &file, (s16 *)L"u-boot.txt", EFI_FILE_MODE_READ,
+ ret = root->open(root, &file, L"u-boot.txt", EFI_FILE_MODE_READ,
0);
if (ret != EFI_SUCCESS) {
efi_st_error("Failed to open file\n");
diff --git a/lib/efi_selftest/efi_selftest_events.c b/lib/efi_selftest/efi_selftest_events.c
index ed99a53804..1077cbdf9e 100644
--- a/lib/efi_selftest/efi_selftest_events.c
+++ b/lib/efi_selftest/efi_selftest_events.c
@@ -147,20 +147,20 @@ static int execute(void)
return EFI_ST_FAILURE;
}
ret = boottime->set_timer(event_notify, EFI_TIMER_STOP, 0);
- if (index != 0) {
+ if (ret != EFI_SUCCESS) {
efi_st_error("Could not cancel timer\n");
return EFI_ST_FAILURE;
}
/* Set 10 ms timer */
timer_ticks = 0;
ret = boottime->set_timer(event_notify, EFI_TIMER_RELATIVE, 100000);
- if (index != 0) {
+ if (ret != EFI_SUCCESS) {
efi_st_error("Could not set timer\n");
return EFI_ST_FAILURE;
}
/* Set 100 ms timer */
ret = boottime->set_timer(event_wait, EFI_TIMER_PERIODIC, 1000000);
- if (index != 0) {
+ if (ret != EFI_SUCCESS) {
efi_st_error("Could not set timer\n");
return EFI_ST_FAILURE;
}
diff --git a/lib/efi_selftest/efi_selftest_hii.c b/lib/efi_selftest/efi_selftest_hii.c
new file mode 100644
index 0000000000..e38af7dbf8
--- /dev/null
+++ b/lib/efi_selftest/efi_selftest_hii.c
@@ -0,0 +1,1035 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * efi_selftest_hii
+ *
+ * Copyright (c) 2018 AKASHI Takahiro, Linaro Limited
+ *
+ * Test HII database protocols
+ */
+
+#include <efi_selftest.h>
+#include <malloc.h>
+#include "efi_selftest_hii_data.c"
+
+#define PRINT_TESTNAME efi_st_printf("%s:\n", __func__)
+
+static struct efi_boot_services *boottime;
+
+static const efi_guid_t hii_database_protocol_guid =
+ EFI_HII_DATABASE_PROTOCOL_GUID;
+static const efi_guid_t hii_string_protocol_guid =
+ EFI_HII_STRING_PROTOCOL_GUID;
+
+static struct efi_hii_database_protocol *hii_database_protocol;
+static struct efi_hii_string_protocol *hii_string_protocol;
+
+/*
+ * Setup unit test.
+ *
+ * @handle: handle of the loaded image
+ * @systable: system table
+ *
+ * @return: EFI_ST_SUCCESS for success
+ */
+static int setup(const efi_handle_t handle,
+ const struct efi_system_table *systable)
+{
+ efi_status_t ret;
+
+ boottime = systable->boottime;
+
+ /* HII database protocol */
+ ret = boottime->locate_protocol(&hii_database_protocol_guid, NULL,
+ (void **)&hii_database_protocol);
+ if (ret != EFI_SUCCESS) {
+ hii_database_protocol = NULL;
+ efi_st_error("HII database protocol is not available.\n");
+ return EFI_ST_FAILURE;
+ }
+
+ /* HII string protocol */
+ ret = boottime->locate_protocol(&hii_string_protocol_guid, NULL,
+ (void **)&hii_string_protocol);
+ if (ret != EFI_SUCCESS) {
+ hii_string_protocol = NULL;
+ efi_st_error("HII string protocol is not available.\n");
+ return EFI_ST_FAILURE;
+ }
+
+ return EFI_ST_SUCCESS;
+}
+
+/*
+ * HII database protocol tests
+ */
+
+/**
+ * test_hii_database_new_package_list() - test creation and removal of
+ * package list
+ *
+ * This test adds a new package list and then tries to remove it using
+ * the provided handle.
+ *
+ * @Return: status code
+ */
+static int test_hii_database_new_package_list(void)
+{
+ efi_hii_handle_t handle;
+ efi_status_t ret;
+
+ PRINT_TESTNAME;
+ ret = hii_database_protocol->new_package_list(hii_database_protocol,
+ (struct efi_hii_package_list_header *)packagelist1,
+ NULL, &handle);
+ if (ret != EFI_SUCCESS || !handle) {
+ efi_st_error("new_package_list returned %u\n",
+ (unsigned int)ret);
+ return EFI_ST_FAILURE;
+ }
+
+ ret = hii_database_protocol->remove_package_list(hii_database_protocol,
+ handle);
+ if (ret != EFI_SUCCESS) {
+ efi_st_error("remove_package_list returned %u\n",
+ (unsigned int)ret);
+ return EFI_ST_FAILURE;
+ }
+
+ return EFI_ST_SUCCESS;
+}
+
+/**
+ * test_hii_database_update_package_list() - test update of package list
+ *
+ * This test adds a new package list and then tries to update it using
+ * another package list.
+ *
+ * @Return: status code
+ */
+static int test_hii_database_update_package_list(void)
+{
+ efi_hii_handle_t handle = NULL;
+ efi_status_t ret;
+ int result = EFI_ST_FAILURE;
+
+ PRINT_TESTNAME;
+ ret = hii_database_protocol->new_package_list(hii_database_protocol,
+ (struct efi_hii_package_list_header *)packagelist1,
+ NULL, &handle);
+ if (ret != EFI_SUCCESS || !handle) {
+ efi_st_error("new_package_list returned %u\n",
+ (unsigned int)ret);
+ return EFI_ST_FAILURE;
+ }
+
+ ret = hii_database_protocol->update_package_list(hii_database_protocol,
+ handle,
+ (struct efi_hii_package_list_header *)packagelist2);
+ if (ret != EFI_SUCCESS || !handle) {
+ efi_st_error("new_package_list returned %u\n",
+ (unsigned int)ret);
+ goto out;
+ }
+
+ result = EFI_ST_SUCCESS;
+
+out:
+ if (handle) {
+ ret = hii_database_protocol->remove_package_list(
+ hii_database_protocol, handle);
+ if (ret != EFI_SUCCESS) {
+ efi_st_error("remove_package_list returned %u\n",
+ (unsigned int)ret);
+ return EFI_ST_FAILURE;
+ }
+ }
+
+ return result;
+}
+
+/**
+ * test_hii_database_list_package_lists() - test listing of package lists
+ *
+ * This test adds two package lists and then tries to enumerate them
+ * against different package types. We will get an array of handles.
+ *
+ * @Return: status code
+ */
+static int test_hii_database_list_package_lists(void)
+{
+ efi_hii_handle_t handle1 = NULL, handle2 = NULL, *handles;
+ efi_uintn_t handles_size;
+ efi_status_t ret;
+ int result = EFI_ST_FAILURE;
+
+ PRINT_TESTNAME;
+ ret = hii_database_protocol->new_package_list(hii_database_protocol,
+ (struct efi_hii_package_list_header *)packagelist1,
+ NULL, &handle1);
+ if (ret != EFI_SUCCESS || !handle1) {
+ efi_st_error("new_package_list returned %u\n",
+ (unsigned int)ret);
+ goto out;
+ }
+
+ ret = hii_database_protocol->new_package_list(hii_database_protocol,
+ (struct efi_hii_package_list_header *)packagelist2,
+ NULL, &handle2);
+ if (ret != EFI_SUCCESS || !handle2) {
+ efi_st_error("new_package_list returned %u\n",
+ (unsigned int)ret);
+ goto out;
+ }
+
+ /* TYPE_ALL */
+ handles = NULL;
+ handles_size = 0;
+ ret = hii_database_protocol->list_package_lists(hii_database_protocol,
+ EFI_HII_PACKAGE_TYPE_ALL, NULL,
+ &handles_size, handles);
+ if (ret != EFI_BUFFER_TOO_SMALL) {
+ efi_st_error("list_package_lists returned %u\n",
+ (unsigned int)ret);
+ goto out;
+ }
+ handles = malloc(handles_size);
+ if (!handles) {
+ efi_st_error("malloc failed\n");
+ goto out;
+ }
+ ret = hii_database_protocol->list_package_lists(hii_database_protocol,
+ EFI_HII_PACKAGE_TYPE_ALL, NULL,
+ &handles_size, handles);
+ if (ret != EFI_SUCCESS) {
+ efi_st_error("list_package_lists returned %u\n",
+ (unsigned int)ret);
+ goto out;
+ }
+ free(handles);
+
+ /* STRINGS */
+ handles = NULL;
+ handles_size = 0;
+ ret = hii_database_protocol->list_package_lists(hii_database_protocol,
+ EFI_HII_PACKAGE_STRINGS, NULL,
+ &handles_size, handles);
+ if (ret != EFI_BUFFER_TOO_SMALL) {
+ efi_st_error("list_package_lists returned %u\n",
+ (unsigned int)ret);
+ ret = EFI_ST_FAILURE;
+ goto out;
+ }
+ handles = malloc(handles_size);
+ if (!handles) {
+ efi_st_error("malloc failed\n");
+ ret = EFI_ST_FAILURE;
+ goto out;
+ }
+ ret = hii_database_protocol->list_package_lists(hii_database_protocol,
+ EFI_HII_PACKAGE_STRINGS, NULL,
+ &handles_size, handles);
+ if (ret != EFI_SUCCESS) {
+ efi_st_error("list_package_lists returned %u\n",
+ (unsigned int)ret);
+ ret = EFI_ST_FAILURE;
+ goto out;
+ }
+ free(handles);
+
+ /* GUID */
+ handles = NULL;
+ handles_size = 0;
+ ret = hii_database_protocol->list_package_lists(hii_database_protocol,
+ EFI_HII_PACKAGE_TYPE_GUID, &package_guid,
+ &handles_size, handles);
+ if (ret != EFI_BUFFER_TOO_SMALL) {
+ efi_st_error("list_package_lists returned %u\n",
+ (unsigned int)ret);
+ ret = EFI_ST_FAILURE;
+ goto out;
+ }
+ handles = malloc(handles_size);
+ if (!handles) {
+ efi_st_error("malloc failed\n");
+ ret = EFI_ST_FAILURE;
+ goto out;
+ }
+ ret = hii_database_protocol->list_package_lists(hii_database_protocol,
+ EFI_HII_PACKAGE_TYPE_GUID, &package_guid,
+ &handles_size, handles);
+ if (ret != EFI_SUCCESS) {
+ efi_st_error("list_package_lists returned %u\n",
+ (unsigned int)ret);
+ ret = EFI_ST_FAILURE;
+ goto out;
+ }
+ free(handles);
+
+ /* KEYBOARD_LAYOUT */
+ handles = NULL;
+ handles_size = 0;
+ ret = hii_database_protocol->list_package_lists(hii_database_protocol,
+ EFI_HII_PACKAGE_KEYBOARD_LAYOUT, NULL,
+ &handles_size, handles);
+ if (ret != EFI_BUFFER_TOO_SMALL) {
+ efi_st_error("list_package_lists returned %u\n",
+ (unsigned int)ret);
+ ret = EFI_ST_FAILURE;
+ goto out;
+ }
+ handles = malloc(handles_size);
+ if (!handles) {
+ efi_st_error("malloc failed\n");
+ ret = EFI_ST_FAILURE;
+ goto out;
+ }
+ ret = hii_database_protocol->list_package_lists(hii_database_protocol,
+ EFI_HII_PACKAGE_KEYBOARD_LAYOUT, NULL,
+ &handles_size, handles);
+ if (ret != EFI_SUCCESS) {
+ efi_st_error("list_package_lists returned %u\n",
+ (unsigned int)ret);
+ ret = EFI_ST_FAILURE;
+ goto out;
+ }
+ free(handles);
+
+ result = EFI_ST_SUCCESS;
+
+out:
+ if (handle1) {
+ ret = hii_database_protocol->remove_package_list(
+ hii_database_protocol, handle1);
+ if (ret != EFI_SUCCESS)
+ efi_st_error("remove_package_list returned %u\n",
+ (unsigned int)ret);
+ }
+ if (handle2) {
+ ret = hii_database_protocol->remove_package_list(
+ hii_database_protocol, handle2);
+ if (ret != EFI_SUCCESS)
+ efi_st_error("remove_package_list returned %u\n",
+ (unsigned int)ret);
+ }
+
+ return result;
+}
+
+/**
+ * test_hii_database_export_package_lists() - test export of package lists
+ *
+ * @Return: status code
+ */
+static int test_hii_database_export_package_lists(void)
+{
+ PRINT_TESTNAME;
+ /* export_package_lists() not implemented yet */
+ return EFI_ST_SUCCESS;
+}
+
+/**
+ * test_hii_database_register_package_notify() - test registration of
+ * notification function
+ *
+ * @Return: status code
+ */
+static int test_hii_database_register_package_notify(void)
+{
+ PRINT_TESTNAME;
+ /* register_package_notify() not implemented yet */
+ return EFI_ST_SUCCESS;
+}
+
+/**
+ * test_hii_database_unregister_package_notify() - test removal of
+ * notification function
+ *
+ * @Return: status code
+ */
+static int test_hii_database_unregister_package_notify(void)
+{
+ PRINT_TESTNAME;
+ /* unregsiter_package_notify() not implemented yet */
+ return EFI_ST_SUCCESS;
+}
+
+/**
+ * test_hii_database_find_keyboard_layouts() - test listing of
+ * all the keyboard layouts in the system
+ *
+ * This test adds two package lists, each of which has two keyboard layouts
+ * and then tries to enumerate them. We will get an array of handles.
+ *
+ * @Return: status code
+ */
+static int test_hii_database_find_keyboard_layouts(void)
+{
+ efi_hii_handle_t handle1 = NULL, handle2 = NULL;
+ efi_guid_t *guids;
+ u16 guids_size;
+ efi_status_t ret;
+ int result = EFI_ST_FAILURE;
+
+ PRINT_TESTNAME;
+ ret = hii_database_protocol->new_package_list(hii_database_protocol,
+ (struct efi_hii_package_list_header *)packagelist1,
+ NULL, &handle1);
+ if (ret != EFI_SUCCESS || !handle1) {
+ efi_st_error("new_package_list returned %u\n",
+ (unsigned int)ret);
+ goto out;
+ }
+
+ ret = hii_database_protocol->new_package_list(hii_database_protocol,
+ (struct efi_hii_package_list_header *)packagelist2,
+ NULL, &handle2);
+ if (ret != EFI_SUCCESS || !handle2) {
+ efi_st_error("new_package_list returned %u\n",
+ (unsigned int)ret);
+ goto out;
+ }
+
+ guids = NULL;
+ guids_size = 0;
+ ret = hii_database_protocol->find_keyboard_layouts(
+ hii_database_protocol, &guids_size, guids);
+ if (ret != EFI_BUFFER_TOO_SMALL) {
+ efi_st_error("find_keyboard_layouts returned %u\n",
+ (unsigned int)ret);
+ goto out;
+ }
+ guids = malloc(guids_size);
+ if (!guids) {
+ efi_st_error("malloc failed\n");
+ goto out;
+ }
+ ret = hii_database_protocol->find_keyboard_layouts(
+ hii_database_protocol, &guids_size, guids);
+ if (ret != EFI_SUCCESS) {
+ efi_st_error("find_keyboard_layouts returned %u\n",
+ (unsigned int)ret);
+ goto out;
+ }
+ free(guids);
+
+ result = EFI_ST_SUCCESS;
+
+out:
+ if (handle1) {
+ ret = hii_database_protocol->remove_package_list(
+ hii_database_protocol, handle1);
+ if (ret != EFI_SUCCESS)
+ efi_st_error("remove_package_list returned %u\n",
+ (unsigned int)ret);
+ }
+ if (handle2) {
+ ret = hii_database_protocol->remove_package_list(
+ hii_database_protocol, handle2);
+ if (ret != EFI_SUCCESS)
+ efi_st_error("remove_package_list returned %u\n",
+ (unsigned int)ret);
+ }
+
+ return result;
+}
+
+/**
+ * test_hii_database_get_keyboard_layout() - test retrieval of keyboard layout
+ *
+ * This test adds two package lists, each of which has two keyboard layouts
+ * and then tries to get a handle to keyboard layout with a specific guid
+ * and the current one.
+ *
+ * @Return: status code
+ */
+static int test_hii_database_get_keyboard_layout(void)
+{
+ efi_hii_handle_t handle1 = NULL, handle2 = NULL;
+ struct efi_hii_keyboard_layout *kb_layout;
+ u16 kb_layout_size;
+ efi_status_t ret;
+ int result = EFI_ST_FAILURE;
+
+ PRINT_TESTNAME;
+ ret = hii_database_protocol->new_package_list(hii_database_protocol,
+ (struct efi_hii_package_list_header *)packagelist1,
+ NULL, &handle1);
+ if (ret != EFI_SUCCESS || !handle1) {
+ efi_st_error("new_package_list returned %u\n",
+ (unsigned int)ret);
+ goto out;
+ }
+
+ ret = hii_database_protocol->new_package_list(hii_database_protocol,
+ (struct efi_hii_package_list_header *)packagelist2,
+ NULL, &handle2);
+ if (ret != EFI_SUCCESS || !handle2) {
+ efi_st_error("new_package_list returned %u\n",
+ (unsigned int)ret);
+ goto out;
+ }
+
+ /* specific keyboard_layout(guid11) */
+ kb_layout = NULL;
+ kb_layout_size = 0;
+ ret = hii_database_protocol->get_keyboard_layout(hii_database_protocol,
+ &kb_layout_guid11, &kb_layout_size, kb_layout);
+ if (ret != EFI_BUFFER_TOO_SMALL) {
+ efi_st_error("get_keyboard_layout returned %u\n",
+ (unsigned int)ret);
+ goto out;
+ }
+ kb_layout = malloc(kb_layout_size);
+ if (!kb_layout) {
+ efi_st_error("malloc failed\n");
+ goto out;
+ }
+ ret = hii_database_protocol->get_keyboard_layout(hii_database_protocol,
+ &kb_layout_guid11, &kb_layout_size, kb_layout);
+ if (ret != EFI_SUCCESS) {
+ efi_st_error("get_keyboard_layout returned %u\n",
+ (unsigned int)ret);
+ goto out;
+ }
+ free(kb_layout);
+
+ /* current */
+ kb_layout = NULL;
+ kb_layout_size = 0;
+ ret = hii_database_protocol->get_keyboard_layout(hii_database_protocol,
+ NULL, &kb_layout_size, kb_layout);
+ if (ret != EFI_INVALID_PARAMETER) {
+ efi_st_error("get_keyboard_layout returned %u\n",
+ (unsigned int)ret);
+ goto out;
+ }
+
+ result = EFI_ST_SUCCESS;
+
+out:
+ if (handle1) {
+ ret = hii_database_protocol->remove_package_list(
+ hii_database_protocol, handle1);
+ if (ret != EFI_SUCCESS)
+ efi_st_error("remove_package_list returned %u\n",
+ (unsigned int)ret);
+ }
+ if (handle2) {
+ ret = hii_database_protocol->remove_package_list(
+ hii_database_protocol, handle2);
+ if (ret != EFI_SUCCESS)
+ efi_st_error("remove_package_list returned %u\n",
+ (unsigned int)ret);
+ }
+
+ return result;
+}
+
+/**
+ * test_hii_database_set_keyboard_layout() - test change of
+ * current keyboard layout
+ *
+ * @Return: status code
+ */
+static int test_hii_database_set_keyboard_layout(void)
+{
+ PRINT_TESTNAME;
+ /* set_keyboard_layout() not implemented yet */
+ return EFI_ST_SUCCESS;
+}
+
+/**
+ * test_hii_database_get_package_list_handle() - test retrieval of
+ * driver associated with a package list
+ *
+ * This test adds a package list, and then tries to get a handle to driver
+ * which is associated with a package list.
+ *
+ * @Return: status code
+ */
+static int test_hii_database_get_package_list_handle(void)
+{
+ efi_hii_handle_t handle = NULL;
+ efi_handle_t driver_handle;
+ efi_status_t ret;
+ int result = EFI_ST_FAILURE;
+
+ PRINT_TESTNAME;
+ driver_handle = (efi_handle_t)0x12345678; /* dummy */
+ ret = hii_database_protocol->new_package_list(hii_database_protocol,
+ (struct efi_hii_package_list_header *)packagelist1,
+ driver_handle, &handle);
+ if (ret != EFI_SUCCESS || !handle) {
+ efi_st_error("new_package_list returned %u\n",
+ (unsigned int)ret);
+ return EFI_ST_FAILURE;
+ }
+
+ driver_handle = NULL;
+ ret = hii_database_protocol->get_package_list_handle(
+ hii_database_protocol, handle, &driver_handle);
+ if (ret != EFI_SUCCESS || driver_handle != (efi_handle_t)0x12345678) {
+ efi_st_error("get_package_list_handle returned %u, driver:%p\n",
+ (unsigned int)ret, driver_handle);
+ goto out;
+ }
+
+ result = EFI_ST_SUCCESS;
+
+out:
+ if (handle) {
+ ret = hii_database_protocol->remove_package_list(
+ hii_database_protocol, handle);
+ if (ret != EFI_SUCCESS) {
+ efi_st_error("remove_package_list returned %u\n",
+ (unsigned int)ret);
+ return EFI_ST_FAILURE;
+ }
+ }
+
+ return result;
+}
+
+static int test_hii_database_protocol(void)
+{
+ int ret;
+
+ ret = test_hii_database_new_package_list();
+ if (ret != EFI_ST_SUCCESS)
+ return EFI_ST_FAILURE;
+
+ ret = test_hii_database_update_package_list();
+ if (ret != EFI_ST_SUCCESS)
+ return EFI_ST_FAILURE;
+
+ ret = test_hii_database_list_package_lists();
+ if (ret != EFI_ST_SUCCESS)
+ return EFI_ST_FAILURE;
+
+ ret = test_hii_database_export_package_lists();
+ if (ret != EFI_ST_SUCCESS)
+ return EFI_ST_FAILURE;
+
+ ret = test_hii_database_register_package_notify();
+ if (ret != EFI_ST_SUCCESS)
+ return EFI_ST_FAILURE;
+
+ ret = test_hii_database_unregister_package_notify();
+ if (ret != EFI_ST_SUCCESS)
+ return EFI_ST_FAILURE;
+
+ ret = test_hii_database_find_keyboard_layouts();
+ if (ret != EFI_ST_SUCCESS)
+ return EFI_ST_FAILURE;
+
+ ret = test_hii_database_get_keyboard_layout();
+ if (ret != EFI_ST_SUCCESS)
+ return EFI_ST_FAILURE;
+
+ ret = test_hii_database_set_keyboard_layout();
+ if (ret != EFI_ST_SUCCESS)
+ return EFI_ST_FAILURE;
+
+ ret = test_hii_database_get_package_list_handle();
+ if (ret != EFI_ST_SUCCESS)
+ return EFI_ST_FAILURE;
+
+ return EFI_ST_SUCCESS;
+}
+
+/*
+ * HII string protocol tests
+ */
+
+/**
+ * test_hii_string_new_string() - test creation of a new string entry
+ *
+ * This test adds a package list, and then tries to add a new string
+ * entry for a specific language.
+ *
+ * @Return: status code
+ */
+static int test_hii_string_new_string(void)
+{
+ efi_hii_handle_t handle = NULL;
+ efi_string_id_t id;
+ efi_status_t ret;
+ int result = EFI_ST_FAILURE;
+
+ PRINT_TESTNAME;
+ ret = hii_database_protocol->new_package_list(hii_database_protocol,
+ (struct efi_hii_package_list_header *)packagelist1,
+ NULL, &handle);
+ if (ret != EFI_SUCCESS || !handle) {
+ efi_st_error("new_package_list returned %u\n",
+ (unsigned int)ret);
+ return EFI_ST_FAILURE;
+ }
+
+ ret = hii_string_protocol->new_string(hii_string_protocol, handle,
+ &id, (u8 *)"en-US",
+ L"Japanese", L"Japanese", NULL);
+ if (ret != EFI_SUCCESS) {
+ efi_st_error("new_string returned %u\n",
+ (unsigned int)ret);
+ goto out;
+ }
+ efi_st_printf("new string id is %u\n", id);
+
+ result = EFI_ST_SUCCESS;
+
+out:
+ if (handle) {
+ ret = hii_database_protocol->remove_package_list(
+ hii_database_protocol, handle);
+ if (ret != EFI_SUCCESS) {
+ efi_st_error("remove_package_list returned %u\n",
+ (unsigned int)ret);
+ return EFI_ST_FAILURE;
+ }
+ }
+
+ return result;
+}
+
+/**
+ * test_hii_string_get_string() - test retrieval of a string entry
+ *
+ * This test adds a package list, create a new string entry and then tries
+ * to get it with its string id.
+ *
+ * @Return: status code
+ */
+static int test_hii_string_get_string(void)
+{
+ efi_hii_handle_t handle = NULL;
+ efi_string_id_t id;
+ efi_string_t string;
+ efi_uintn_t string_len;
+ efi_status_t ret;
+ int result = EFI_ST_FAILURE;
+
+ PRINT_TESTNAME;
+ ret = hii_database_protocol->new_package_list(hii_database_protocol,
+ (struct efi_hii_package_list_header *)packagelist1,
+ NULL, &handle);
+ if (ret != EFI_SUCCESS || !handle) {
+ efi_st_error("new_package_list returned %u\n",
+ (unsigned int)ret);
+ return EFI_ST_FAILURE;
+ }
+
+ ret = hii_string_protocol->new_string(hii_string_protocol, handle,
+ &id, (u8 *)"en-US",
+ L"Japanese", L"Japanese", NULL);
+ if (ret != EFI_SUCCESS) {
+ efi_st_error("new_string returned %u\n",
+ (unsigned int)ret);
+ goto out;
+ }
+
+ string = NULL;
+ string_len = 0;
+ ret = hii_string_protocol->get_string(hii_string_protocol,
+ (u8 *)"en-US", handle, id, string, &string_len, NULL);
+ if (ret != EFI_BUFFER_TOO_SMALL) {
+ efi_st_error("get_string returned %u\n",
+ (unsigned int)ret);
+ goto out;
+ }
+ string_len += sizeof(u16);
+ string = malloc(string_len);
+ if (!string) {
+ efi_st_error("malloc failed\n");
+ goto out;
+ }
+ ret = hii_string_protocol->get_string(hii_string_protocol,
+ (u8 *)"en-US", handle, id, string, &string_len, NULL);
+ if (ret != EFI_SUCCESS) {
+ efi_st_error("get_string returned %u\n",
+ (unsigned int)ret);
+ goto out;
+ }
+
+#if 1
+ u16 *c1, *c2;
+
+ for (c1 = string, c2 = L"Japanese"; *c1 == *c2; c1++, c2++)
+ ;
+ if (!*c1 && !*c2)
+ result = EFI_ST_SUCCESS;
+ else
+ result = EFI_ST_FAILURE;
+#else
+ /* TODO: %ls */
+ efi_st_printf("got string is %s (can be wrong)\n", string);
+#endif
+
+ result = EFI_ST_SUCCESS;
+
+out:
+ if (handle) {
+ ret = hii_database_protocol->remove_package_list(
+ hii_database_protocol, handle);
+ if (ret != EFI_SUCCESS) {
+ efi_st_error("remove_package_list returned %u\n",
+ (unsigned int)ret);
+ return EFI_ST_FAILURE;
+ }
+ }
+
+ return result;
+}
+
+/**
+ * test_hii_string_set_string() - test change of a string entry
+ *
+ * This test adds a package list, create a new string entry and then tries
+ * to modify it.
+ *
+ * @Return: status code
+ */
+static int test_hii_string_set_string(void)
+{
+ efi_hii_handle_t handle = NULL;
+ efi_string_id_t id;
+ efi_status_t ret;
+ int result = EFI_ST_FAILURE;
+
+ PRINT_TESTNAME;
+ ret = hii_database_protocol->new_package_list(hii_database_protocol,
+ (struct efi_hii_package_list_header *)packagelist1,
+ NULL, &handle);
+ if (ret != EFI_SUCCESS || !handle) {
+ efi_st_error("new_package_list returned %u\n",
+ (unsigned int)ret);
+ return EFI_ST_FAILURE;
+ }
+
+ ret = hii_string_protocol->new_string(hii_string_protocol, handle,
+ &id, (u8 *)"en-US",
+ L"Japanese", L"Japanese", NULL);
+ if (ret != EFI_SUCCESS) {
+ efi_st_error("new_string returned %u\n",
+ (unsigned int)ret);
+ goto out;
+ }
+
+ ret = hii_string_protocol->set_string(hii_string_protocol, handle,
+ id, (u8 *)"en-US",
+ L"Nihongo", NULL);
+ if (ret != EFI_SUCCESS) {
+ efi_st_error("set_string returned %u\n",
+ (unsigned int)ret);
+ goto out;
+ }
+
+ result = EFI_ST_SUCCESS;
+
+out:
+ if (handle) {
+ ret = hii_database_protocol->remove_package_list(
+ hii_database_protocol, handle);
+ if (ret != EFI_SUCCESS) {
+ efi_st_error("remove_package_list returned %u\n",
+ (unsigned int)ret);
+ return EFI_ST_FAILURE;
+ }
+ }
+
+ return result;
+}
+
+/**
+ * test_hii_string_get_languages() - test listing of languages
+ *
+ * This test adds a package list, and then tries to enumerate languages
+ * in it. We will get an string of language names.
+ *
+ * @Return: status code
+ */
+static int test_hii_string_get_languages(void)
+{
+ efi_hii_handle_t handle = NULL;
+ u8 *languages;
+ efi_uintn_t languages_len;
+ efi_status_t ret;
+ int result = EFI_ST_FAILURE;
+
+ PRINT_TESTNAME;
+ ret = hii_database_protocol->new_package_list(hii_database_protocol,
+ (struct efi_hii_package_list_header *)packagelist1,
+ NULL, &handle);
+ if (ret != EFI_SUCCESS || !handle) {
+ efi_st_error("new_package_list returned %u\n",
+ (unsigned int)ret);
+ return EFI_ST_FAILURE;
+ }
+
+ languages = NULL;
+ languages_len = 0;
+ ret = hii_string_protocol->get_languages(hii_string_protocol, handle,
+ languages, &languages_len);
+ if (ret != EFI_BUFFER_TOO_SMALL) {
+ efi_st_error("get_languages returned %u\n",
+ (unsigned int)ret);
+ goto out;
+ }
+ languages = malloc(languages_len);
+ if (!languages) {
+ efi_st_error("malloc failed\n");
+ goto out;
+ }
+ ret = hii_string_protocol->get_languages(hii_string_protocol, handle,
+ languages, &languages_len);
+ if (ret != EFI_SUCCESS) {
+ efi_st_error("get_languages returned %u\n",
+ (unsigned int)ret);
+ goto out;
+ }
+
+ efi_st_printf("got languages are %s\n", languages);
+
+ result = EFI_ST_SUCCESS;
+
+out:
+ if (handle) {
+ ret = hii_database_protocol->remove_package_list(
+ hii_database_protocol, handle);
+ if (ret != EFI_SUCCESS) {
+ efi_st_error("remove_package_list returned %u\n",
+ (unsigned int)ret);
+ return EFI_ST_FAILURE;
+ }
+ }
+
+ return result;
+}
+
+/**
+ * test_hii_string_get_secondary_languages() - test listing of secondary
+ * languages
+ *
+ * This test adds a package list, and then tries to enumerate secondary
+ * languages with a specific language. We will get an string of language names.
+ *
+ * @Return: status code
+ */
+static int test_hii_string_get_secondary_languages(void)
+{
+ efi_hii_handle_t handle = NULL;
+ u8 *languages;
+ efi_uintn_t languages_len;
+ efi_status_t ret;
+ int result = EFI_ST_FAILURE;
+
+ PRINT_TESTNAME;
+ ret = hii_database_protocol->new_package_list(hii_database_protocol,
+ (struct efi_hii_package_list_header *)packagelist1,
+ NULL, &handle);
+ if (ret != EFI_SUCCESS || !handle) {
+ efi_st_error("new_package_list returned %u\n",
+ (unsigned int)ret);
+ return EFI_ST_FAILURE;
+ }
+
+ languages = NULL;
+ languages_len = 0;
+ ret = hii_string_protocol->get_secondary_languages(hii_string_protocol,
+ handle, (u8 *)"en-US", languages, &languages_len);
+ if (ret == EFI_NOT_FOUND) {
+ efi_st_printf("no secondary languages\n");
+ result = EFI_ST_SUCCESS;
+ goto out;
+ }
+ if (ret != EFI_BUFFER_TOO_SMALL) {
+ efi_st_error("get_secondary_languages returned %u\n",
+ (unsigned int)ret);
+ goto out;
+ }
+ languages = malloc(languages_len);
+ if (!languages) {
+ efi_st_error("malloc failed\n");
+ goto out;
+ }
+ ret = hii_string_protocol->get_secondary_languages(hii_string_protocol,
+ handle, (u8 *)"en-US", languages, &languages_len);
+ if (ret != EFI_SUCCESS) {
+ efi_st_error("get_secondary_languages returned %u\n",
+ (unsigned int)ret);
+ goto out;
+ }
+
+ efi_st_printf("got secondary languages are %s\n", languages);
+
+ result = EFI_ST_SUCCESS;
+
+out:
+ if (handle) {
+ ret = hii_database_protocol->remove_package_list(
+ hii_database_protocol, handle);
+ if (ret != EFI_SUCCESS) {
+ efi_st_error("remove_package_list returned %u\n",
+ (unsigned int)ret);
+ return EFI_ST_FAILURE;
+ }
+ }
+
+ return result;
+}
+
+static int test_hii_string_protocol(void)
+{
+ int ret;
+
+ ret = test_hii_string_new_string();
+ if (ret != EFI_ST_SUCCESS)
+ return EFI_ST_FAILURE;
+
+ ret = test_hii_string_get_string();
+ if (ret != EFI_ST_SUCCESS)
+ return EFI_ST_FAILURE;
+
+ ret = test_hii_string_set_string();
+ if (ret != EFI_ST_SUCCESS)
+ return EFI_ST_FAILURE;
+
+ ret = test_hii_string_get_languages();
+ if (ret != EFI_ST_SUCCESS)
+ return EFI_ST_FAILURE;
+
+ ret = test_hii_string_get_secondary_languages();
+ if (ret != EFI_ST_SUCCESS)
+ return EFI_ST_FAILURE;
+
+ return EFI_ST_SUCCESS;
+}
+
+/*
+ * Execute unit test.
+ *
+ * @return: EFI_ST_SUCCESS for success, EFI_ST_FAILURE for failure
+ */
+static int execute(void)
+{
+ int ret;
+
+ /* HII database protocol */
+ ret = test_hii_database_protocol();
+ if (ret != EFI_ST_SUCCESS)
+ return EFI_ST_FAILURE;
+
+ /* HII string protocol */
+ ret = test_hii_string_protocol();
+ if (ret != EFI_ST_SUCCESS)
+ return EFI_ST_FAILURE;
+
+ return EFI_ST_SUCCESS;
+}
+
+EFI_UNIT_TEST(hii) = {
+ .name = "HII database protocols",
+ .phase = EFI_EXECUTE_BEFORE_BOOTTIME_EXIT,
+ .setup = setup,
+ .execute = execute,
+};
diff --git a/lib/efi_selftest/efi_selftest_hii_data.c b/lib/efi_selftest/efi_selftest_hii_data.c
new file mode 100644
index 0000000000..d19f0682af
--- /dev/null
+++ b/lib/efi_selftest/efi_selftest_hii_data.c
@@ -0,0 +1,453 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * This file's test data is derived from UEFI SCT.
+ * The original copyright is attached below.
+ */
+
+/*
+ * Copyright 2006 - 2016 Unified EFI, Inc.<BR>
+ * Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR>
+ *
+ * This program and the accompanying materials
+ * are licensed and made available under the terms and conditions of the BSD
+ * License which accompanies this distribution. The full text of the license
+ * may be found at
+ * http://opensource.org/licenses/bsd-license.php
+ *
+ * THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ */
+
+#include <efi.h>
+
+#ifdef NOT_USED
+/*
+ * TODO: These macro's are not used as they appear only in
+ * "#ifdef NOT_USED" clauses. In the future, define them elsewhere.
+ */
+
+/* HII form */
+#define EFI_IFR_AND_OP 0x15
+#define EFI_IFR_END_OP 0x29
+#define EFI_IFR_BITWISE_AND_OP 0x35
+
+/* HII image */
+#define EFI_HII_IIBT_END 0x00
+#define EFI_HII_IIBT_IMAGE_1BIT 0x10
+#endif
+
+/* HII keyboard layout */
+#define EFI_NULL_MODIFIER 0x0000
+
+u8 packagelist1[] = {
+ // EFI_HII_PACKAGE_LIST_HEADER, length = 20
+ // SimpleFont, Font, GUID, Form, String, Image, DevicePath,
+ // (74) (110) 20 (8) 78 (67) (8)
+ // KeyboardLayout, End
+ // 192 4
+
+ 0x89, 0xcd, 0xab, 0x03, 0xf4, 0x03, 0x44, 0x70,
+ 0x81, 0xde, 0x99, 0xb1, 0x81, 0x20, 0xf7, 0x68, //16: guid
+ 0x3a, 0x01, 0x00, 0x00, // 4: total 314(0x13a)
+#ifdef NOT_USED /* TODO: simple font package not implemented yet */
+ //
+ // Simple Font Package 1, length = 74
+ //
+ 0x4A, 0x00, 0x00,
+ EFI_HII_PACKAGE_SIMPLE_FONTS,
+ 1, 0,
+ 1, 0,
+ 0x55, 0x0, 0x1,
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
+ 0x77, 0x0, 0x2,
+ 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
+ 3, 4, 5,
+ 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 0, 0, 0,
+ //
+ // Font Package 1, length = 110
+ //
+ 0x6e, 0x00, 0x00, // 3
+ EFI_HII_PACKAGE_FONTS, // 1
+ 0x5c, 0x00, 0x00, 0x00, // 4: size of header
+ 0x5c, 0x00, 0x00, 0x00, // 4: offset
+ 0xf1, 0x00, 0xf2, 0x00, 0xf3, 0x00, 0xf4, 0x00,
+ 0xf5, 0x00, 0xec, 0xec, //10+2(pads)
+ 0xff, 0x33, 0xff, 0x44, // 4: font style
+ 0x77, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x52, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, //64
+ //
+ // Glyph block 1, length = 18
+ //
+ EFI_HII_GIBT_GLYPH_DEFAULT, // 1
+ 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x99,
+ 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, //16: BitMapData
+ EFI_HII_GIBT_END, // 1
+#endif
+ //
+ // Guid Package 1, length = 20
+ //
+ 0x14, 0x00, 0x00, // 3
+ EFI_HII_PACKAGE_TYPE_GUID, // 1
+ 0x5a, 0xc9, 0x87, 0x03, 0x3, 0xd7, 0x46, 0x23,
+ 0xb2, 0xab, 0xd0, 0xc7, 0xdd, 0x90, 0x44, 0xf8, //16: guid
+#ifdef NOT_USED /* TODO: form package not implemented yet */
+ //
+ // EFI_HII_PACKAGE_FORMS, length = 8
+ //
+ 0x08, 0x00, 0x00, // 3
+ EFI_HII_PACKAGE_FORMS, // 1
+ //
+ // Opcode 1, length = 4
+ //
+ EFI_IFR_AND_OP,
+ 0x82,
+ EFI_IFR_END_OP,
+ 0x02,
+ //
+#endif
+ // EFI_HII_PACKAGE_STRINGS, length = 78
+ //
+ 0x4e, 0x00, 0x00, // 3: length(header)
+ EFI_HII_PACKAGE_STRINGS, // 1: type(header)
+ 0x3c, 0x00, 0x00, 0x00, // 4: header_size
+ 0x3c, 0x00, 0x00, 0x00, // 4: string_offset
+ 0x00, 0x00, 0x11, 0x22, 0x44, 0x55, 0x77, 0x89, //32: language_window
+ 0x11, 0x00, 0x11, 0x22, 0x44, 0x55, 0x87, 0x89,
+ 0x22, 0x00, 0x11, 0x22, 0x44, 0x55, 0x77, 0x89,
+ 0x33, 0x00, 0x11, 0x22, 0x44, 0x55, 0x77, 0x89,
+ 0x01, 0x00, // 2: language name
+ 0x65, 0x6e, 0x2d, 0x55, 0x53, 0x3b, 0x7a, 0x68, //14: language
+ 0x2d, 0x48, 0x61, 0x6e, 0x74, 0x00, // "en-US;zh-Hant"
+ EFI_HII_SIBT_STRING_UCS2, // 1
+ 0x45, 0x00, 0x6E, 0x00, 0x67, 0x00, 0x6C, 0x00,
+ 0x69, 0x00, 0x73, 0x00, 0x68, 0x00, 0x00, 0x00, //16: "English"
+ EFI_HII_SIBT_END, // 1
+#ifdef NOT_USED /* TODO: image package not implemented yet */
+ //
+ // EFI_HII_PACKAGE_IMAGES, length = 67
+ //
+ 0x43, 0x00, 0x00, // 3
+ EFI_HII_PACKAGE_IMAGES, // 1
+ 0x0c, 0x00, 0x00, 0x00, // 4: image info offset
+ 0x39, 0x00, 0x00, 0x00, // 4: palette info offset
+ EFI_HII_IIBT_IMAGE_1BIT, // 1
+ 0x01,
+ 0x0b, 0x00,
+ 0x13, 0x00,
+ 0x80, 0x00,
+ 0xc0, 0x00,
+ 0xe0, 0x00,
+ 0xf0, 0x00,
+ 0xf8, 0x00,
+ 0xfc, 0x00,
+ 0xfe, 0x00,
+ 0xff, 0x00,
+ 0xff, 0x80,
+ 0xff, 0xc0,
+ 0xff, 0xe0,
+ 0xfe, 0x00,
+ 0xef, 0x00,
+ 0xcf, 0x00,
+ 0x87, 0x80,
+ 0x07, 0x80,
+ 0x03, 0xc0,
+ 0x03, 0xc0,
+ 0x01, 0x80, //43
+ EFI_HII_IIBT_END, // 1
+ 0x01, 0x00,
+ 0x06, 0x00,
+ 0x00, 0x00, 0x00,
+ 0xFF, 0xFF, 0xFF, //10
+ //
+ // EFI_HII_PACKAGE_DEVICE_PATH, length = 8
+ //
+ 0x08, 0x00, 0x00, // 3
+ EFI_HII_PACKAGE_DEVICE_PATH, // 1
+ 0x01, 0x23, 0x45, 0x66, // 4: dummy device path protocol
+ // instance address
+#endif
+ //
+ // Keyboard layout package 1, length = 192
+ 0xc0, 0x00, 0x00, // 3: length(header)
+ EFI_HII_PACKAGE_KEYBOARD_LAYOUT, // 1: type(header)
+ 0x02, 0x00, // 2: LayoutCount
+ //
+ // Layout 1, length = 93
+ //
+ 0x5d, 0x00, // 2: layout_length
+ 0x95, 0xe4, 0x40, 0x8d, 0xaa, 0xe2, 0x6f, 0x4c,
+ 0x89, 0x70, 0x68, 0x85, 0x09, 0xee, 0xc7, 0xd2, //16: guid
+ 0x37, 0x00, 0x00, 0x00, // 4: layout_descriptor_
+ // string_offset
+ 0x02, // 1: descriptor_count
+ //
+ // Descriptor 1, length = 16
+ //
+ 49, 0x00, 0x00, 0x00, // 4: key (EfiKeyD1)
+ 'q', 0x00, // 2: unicode
+ 'Q', 0x00, // 2: shifted_unicode
+ 0x00, 0x00, // 2: alt_gr_unicode
+ 0x00, 0x00, // 2: shifted_alt_gr_unicode
+ EFI_NULL_MODIFIER, 0x00, // 2: modifier
+ 0x03, 0x00, // 2: affected_attribute
+ //
+ // Descriptor 2, length = 16
+ //
+ 50, 0x00, 0x00, 0x00, // 4: key (EfiKeyD2)
+ 'w', 0x00, // 2: unicode
+ 'W', 0x00, // 2: shifted_unicode
+ 0x00, 0x00, // 2: alt_gr_unicode
+ 0x00, 0x00, // 2: shifted_alt_gr_unicode
+ EFI_NULL_MODIFIER, 0x00, // 2: modifier
+ 0x3, 0x0, // 2: affected_attribute
+ //
+ // EFI_DESCRIPTOR_STRING_BUNDLE, length = 38
+ //
+ 0x01, 0x00, // 2: DescriptionCount
+ 'e', 0x0, 'n', 0x0, '-', 0x0, 'U', 0x0, 'S', 0x0,
+ //10: RFC3066 language code
+ ' ', 0x0, // 2: Space
+ 'S', 0x0, 'i', 0x0, 'm', 0x0, 'p', 0x0, 'l', 0x0, 'e', 0x0,
+ '1', 0x0, 'o', 0x0, 'n', 0x0, 'l', 0x0, 'y', 0x0, '\0', 0x0,
+ //24: DescriptionString
+ //
+ // Layout 2, length = 93
+ //
+ 0x5d, 0x00, // 2: layout_length
+ 0x3e, 0x0b, 0xe6, 0x2a, 0xd6, 0xb9, 0xd8, 0x49,
+ 0x9a, 0x16, 0xc2, 0x48, 0xf1, 0xeb, 0xa8, 0xdb, //16: guid
+ 0x37, 0x00, 0x00, 0x00, // 4: layout_descriptor_
+ // string_offset
+ 0x02, // 1 Descriptor count
+ //
+ // Descriptor 1, length = 16
+ //
+ 51, 0x0, 0x0, 0x0, // 4: key (EfiKeyD3)
+ 'e', 0x00, // 2: unicode
+ 'E', 0x00, // 2: shifted_unicode
+ 0x00, 0x00, // 2: alt_gr_unicode
+ 0x00, 0x00, // 2: shifted_alt_gr_unicode
+ EFI_NULL_MODIFIER, 0x0, // 2: modifier
+ 0x3, 0x0, // 2: affected_attribute
+ //
+ // Descriptor 2, length = 16
+ //
+ 52, 0x0, 0x0, 0x0, // 4: key (EfiKeyD4)
+ 'r', 0x00, // 2: unicode
+ 'R', 0x00, // 2: shifted_unicode
+ 0x00, 0x00, // 2: alt_gr_unicode
+ 0x00, 0x00, // 2: shifted_alt_gr_unicode
+ EFI_NULL_MODIFIER, 0x0, // 2: modifier
+ 0x3, 0x0, // 2: affected_attribute
+ //
+ // EFI_DESCRIPTOR_STRING_BUNDLE, length = 38
+ //
+ 0x01, 0x00, // 2: DescriptionCount
+ 'e', 0x0, 'n', 0x0, '-', 0x0, 'U', 0x0, 'S', 0x0,
+ //10: RFC3066 language code
+ ' ', 0x0, // 2: Space
+ 'S', 0x0, 'i', 0x0, 'm', 0x0, 'p', 0x0, 'l', 0x0, 'e', 0x0,
+ '2', 0x0, 'o', 0x0, 'n', 0x0, 'l', 0x0, 'y', 0x0, '\0', 0x0,
+ //24: DescriptionString
+ //
+ // End of package list, length = 4
+ //
+ 0x4, 0x00, 0x00,
+ EFI_HII_PACKAGE_END
+};
+
+u8 packagelist2[] = {
+ // EFI_HII_PACKAGE_LIST_HEADER, length = 20
+ // SimpleFont, Font, GUID, KeyboardLayout, Form, End
+ // (74) (122) 20 192 (8) 4
+ 0xd3, 0xde, 0x85, 0x86, 0xce, 0x1b, 0xf3, 0x43,
+ 0xa2, 0x0c, 0xa3, 0x06, 0xec, 0x69, 0x72, 0xdd, //16
+ 0xec, 0x00, 0x00, 0x00, // 4: total 236(0xec)
+
+#ifdef NOT_USED /* TODO: simple font package not implemented yet */
+ //
+ // Simple Font Package 2, length = 74
+ //
+ 0x4A, 0x00, 0x00, // 3
+ EFI_HII_PACKAGE_SIMPLE_FONTS, // 1
+ 1, 0, // 2
+ 1, 0, // 2
+ 0x33, 0x0, 0, 1, 2, 3, 4, 5, 0, 7, 8, 9,
+ 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, //22
+ 0x44, 0x0, 0x2, 2, 3, 4, 5, 6, 0, 8, 9,
+ 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, //22
+ 3, 4, 5, 6, 7, 8, 9, 10, 11, 9, 13,
+ 14, 15, 16, 17, 18, 19, 20, 21, 0, 0, 0, //22
+ //
+ // Font Package 2, length = 122
+ //
+ 0x7A, 0x00, 0x00, // 3
+ EFI_HII_PACKAGE_FONTS, // 1
+ 0x5C, 0x00, 0x00, 0x00, // 4: size of header
+ 0x5C, 0x00, 0x00, 0x00, // 4: dummy offset
+ 0xf1, 0x00, 0xf2, 0x00, 0xf3, 0x00, 0xf4, 0x00,
+ 0xf5, 0x00, 0xec, 0xec, //10+2(pads)
+ 0xff, 0x11, 0xff, 0x22, // 4: font style
+ 0x99, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x52, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, //64
+ //
+ // Glyph block 1, length = 30
+ //
+ EFI_HII_GIBT_GLYPH, // 1
+ 0xf1, 0x00, 0xf2, 0x00, 0xf3, 0x00, 0xf4, 0x00,
+ 0xf5, 0x00, //10
+ 0xff, 0x01, // 2
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, //16: BitMapData
+ EFI_HII_GIBT_END, // 1
+#endif
+ //
+ // Guid Package 1, length = 20
+ //
+ 0x14, 0x00, 0x00, // 3
+ EFI_HII_PACKAGE_TYPE_GUID, // 1
+ 0x5a, 0xc9, 0x87, 0x03, 0x3, 0xd7, 0x46, 0x23,
+ 0xb2, 0xab, 0xd0, 0xc7, 0xdd, 0x90, 0x44, 0xf8, //16: guid
+ //
+ // Keyboard layout package 2, length = 192
+ 0xc0, 0x00, 0x00, // 3
+ EFI_HII_PACKAGE_KEYBOARD_LAYOUT, // 1
+ 0x02, 0x00, //0xec, 0xec, // 2: LayoutCount
+ //
+ // Layout 1, length = 93
+ //
+ 0x5d, 0x00, // 2: layout_length
+ 0x1f, 0x6a, 0xf5, 0xe0, 0x6b, 0xdf, 0x7e, 0x4a,
+ 0xa3, 0x9a, 0xe7, 0xa5, 0x19, 0x15, 0x45, 0xd6,//16: guid
+ 0x37, 0x00, 0x00, 0x00, // 4: layout_descriptor
+ // string offset
+ 0x02, // 1: descriptor_count
+ //
+ // Descriptor 1, length = 16
+ //
+ 32, 0x00, 0x00, 0x00, // 4: key (EfiKeyC1)
+ 'a', 0x00, // 2: unicode
+ 'A', 0x00, // 2: shifted_unicode
+ 0x00, 0x00, // 2: alt_gr_unicode
+ 0x00, 0x00, // 2: shifted_alt_gr_unic
+ EFI_NULL_MODIFIER, 0x00, // 2: modifier
+ 0x03, 0x00, // 2: affected_attribute
+ //
+ // Descriptor 2, length = 16
+ //
+ 33 /*EfiKeyC2*/, 0x00, 0x00, 0x00,
+ 's', 0x00,
+ 'S', 0x00,
+ 0x00, 0x00,
+ 0x00, 0x00,
+ EFI_NULL_MODIFIER, 0x00,
+ 0x3, 0x0,
+ //
+ // EFI_DESCRIPTOR_STRING_BUNDLE, length = 38
+ //
+ 0x01, 0x00, // 2: DescriptionCount
+ 'e', 0x0, 'n', 0x0, '-', 0x0, 'U', 0x0, 'S', 0x0,
+ //10: RFC3066 language code
+ ' ', 0x0, // 2: Space
+ 'S', 0x0, 'i', 0x0, 'm', 0x0, 'p', 0x0, 'l', 0x0, 'e', 0x0,
+ '3', 0x0, 'o', 0x0, 'n', 0x0, 'l', 0x0, 'y', 0x0, '\0', 0x0,
+ //24: DescriptionString
+ //
+ // Layout 2, length = 93
+ //
+ 0x5d, 0x00, // 2: layout_length
+ 0xc9, 0x6a, 0xbe, 0x47, 0xcc, 0x54, 0xf9, 0x46,
+ 0xa2, 0x62, 0xd5, 0x3b, 0x25, 0x6a, 0xc, 0x34, //16: guid
+ 0x37, 0x00, 0x00, 0x00, // 4: layout_descriptor
+ // string_offset
+ 0x02, // 1: descriptor_count
+ //
+ // Descriptor 1, length = 16
+ //
+ 34 /*EfiKeyC3*/, 0x0, 0x0, 0x0,
+ 'd', 0x00,
+ 'D', 0x00,
+ 0x00, 0x00,
+ 0x00, 0x00,
+ EFI_NULL_MODIFIER, 0x0,
+ 0x3, 0x0,
+ //
+ // Descriptor 2, length = 16
+ //
+ 35 /*EfiKeyC4*/, 0x0, 0x0, 0x0,
+ 'e', 0x00,
+ 'E', 0x00,
+ 0x00, 0x00,
+ 0x00, 0x00,
+ EFI_NULL_MODIFIER, 0x0,
+ 0x3, 0x0,
+ //
+ // EFI_DESCRIPTOR_STRING_BUNDLE, length = 38
+ //
+ 0x01, 0x00, // 2: DescriptionCount
+ 'e', 0x0, 'n', 0x0, '-', 0x0, 'U', 0x0, 'S', 0x0,
+ //10: RFC3066 language code
+ ' ', 0x0, // 2: Space
+ 'S', 0x0, 'i', 0x0, 'm', 0x0, 'p', 0x0, 'l', 0x0, 'e', 0x0,
+ '4', 0x0, 'o', 0x0, 'n', 0x0, 'l', 0x0, 'y', 0x0, '\0', 0x0,
+ //24: DescriptionString
+#ifdef NOT_USED /* TODO: form package not implemented yet */
+ //
+ // EFI_HII_PACKAGE_FORMS, length = 8
+ //
+ 0x08, 0x00, 0x00, // 3
+ EFI_HII_PACKAGE_FORMS, // 1
+ //
+ // Opcode 1
+ //
+ EFI_IFR_BITWISE_AND_OP, // 1
+ 0x02, // 1
+ EFI_IFR_END_OP, // 1
+ 0x02, // 1
+#endif
+ //
+ // End of package list, length = 4
+ //
+ 0x4, 0x00, 0x00, // 3
+ EFI_HII_PACKAGE_END // 1
+};
+
+efi_guid_t packagelist_guid1 =
+ EFI_GUID(0x03abcd89, 0x03f4, 0x7044,
+ 0x81, 0xde, 0x99, 0xb1, 0x81, 0x20, 0xf7, 0x68);
+
+efi_guid_t packagelist_guid2 =
+ EFI_GUID(0x8685ded3, 0x1bce, 0x43f3,
+ 0xa2, 0x0c, 0xa3, 0x06, 0xec, 0x69, 0x72, 0xdd);
+
+efi_guid_t kb_layout_guid11 =
+ EFI_GUID(0x8d40e495, 0xe2aa, 0x4c6f,
+ 0x89, 0x70, 0x68, 0x85, 0x09, 0xee, 0xc7, 0xd2);
+
+efi_guid_t kb_layout_guid12 =
+ EFI_GUID(0x2ae60b3e, 0xb9d6, 0x49d8,
+ 0x9a, 0x16, 0xc2, 0x48, 0xf1, 0xeb, 0xa8, 0xdb);
+
+efi_guid_t kb_layout_guid21 =
+ EFI_GUID(0xe0f56a1f, 0xdf6b, 0x4a7e,
+ 0xa3, 0x9a, 0xe7, 0xa5, 0x19, 0x15, 0x45, 0xd6);
+
+efi_guid_t kb_layout_guid22 =
+ EFI_GUID(0x47be6ac9, 0x54cc, 0x46f9,
+ 0xa2, 0x62, 0xd5, 0x3b, 0x25, 0x6a, 0x0c, 0x34);
+
+efi_guid_t package_guid =
+ EFI_GUID(0x0387c95a, 0xd703, 0x2346,
+ 0xb2, 0xab, 0xd0, 0xc7, 0xdd, 0x90, 0x44, 0xf8);
diff --git a/lib/efi_selftest/efi_selftest_snp.c b/lib/efi_selftest/efi_selftest_snp.c
index e10a34ba64..f1e23c4921 100644
--- a/lib/efi_selftest/efi_selftest_snp.c
+++ b/lib/efi_selftest/efi_selftest_snp.c
@@ -427,4 +427,12 @@ EFI_UNIT_TEST(snp) = {
.setup = setup,
.execute = execute,
.teardown = teardown,
+#ifdef CONFIG_SANDBOX
+ /*
+ * Running this test on the sandbox requires setting environment
+ * variable ethact to a network interface connected to a DHCP server and
+ * ethrotate to 'no'.
+ */
+ .on_request = true,
+#endif
};
diff --git a/lib/efi_selftest/efi_selftest_tpl.c b/lib/efi_selftest/efi_selftest_tpl.c
index 97d256abe4..70a355eae6 100644
--- a/lib/efi_selftest/efi_selftest_tpl.c
+++ b/lib/efi_selftest/efi_selftest_tpl.c
@@ -151,7 +151,7 @@ static int execute(void)
return EFI_ST_FAILURE;
}
ret = boottime->set_timer(event_notify, EFI_TIMER_STOP, 0);
- if (index != 0) {
+ if (ret != EFI_SUCCESS) {
efi_st_error("Could not cancel timer\n");
return EFI_ST_FAILURE;
}
@@ -164,7 +164,7 @@ static int execute(void)
/* Set 10 ms timer */
notification_count = 0;
ret = boottime->set_timer(event_notify, EFI_TIMER_PERIODIC, 100000);
- if (index != 0) {
+ if (ret != EFI_SUCCESS) {
efi_st_error("Could not set timer\n");
return EFI_ST_FAILURE;
}
diff --git a/lib/efi_selftest/efi_selftest_variables.c b/lib/efi_selftest/efi_selftest_variables.c
index e4c389a872..47a8e7fb95 100644
--- a/lib/efi_selftest/efi_selftest_variables.c
+++ b/lib/efi_selftest/efi_selftest_variables.c
@@ -15,10 +15,10 @@
static struct efi_boot_services *boottime;
static struct efi_runtime_services *runtime;
-static efi_guid_t guid_vendor0 =
+static const efi_guid_t guid_vendor0 =
EFI_GUID(0x67029eb5, 0x0af2, 0xf6b1,
0xda, 0x53, 0xfc, 0xb5, 0x66, 0xdd, 0x1c, 0xe6);
-static efi_guid_t guid_vendor1 =
+static const efi_guid_t guid_vendor1 =
EFI_GUID(0xff629290, 0x1fc1, 0xd73f,
0x8f, 0xb1, 0x32, 0xf9, 0x0c, 0xa0, 0x42, 0xea);
@@ -141,19 +141,22 @@ static int execute(void)
if (ret == EFI_NOT_FOUND)
break;
if (ret != EFI_SUCCESS) {
- efi_st_todo("GetNextVariableName failed\n");
- break;
+ efi_st_error("GetNextVariableName failed (%u)\n",
+ (unsigned int)ret);
+ return EFI_ST_FAILURE;
}
if (!efi_st_memcmp(&guid, &guid_vendor0, sizeof(efi_guid_t)) &&
!efi_st_strcmp_16_8(varname, "efi_st_var0"))
- flag |= 2;
+ flag |= 1;
if (!efi_st_memcmp(&guid, &guid_vendor1, sizeof(efi_guid_t)) &&
!efi_st_strcmp_16_8(varname, "efi_st_var1"))
flag |= 2;
}
- if (flag != 3)
- efi_st_todo(
+ if (flag != 3) {
+ efi_st_error(
"GetNextVariableName did not return all variables\n");
+ return EFI_ST_FAILURE;
+ }
/* Delete variable 1 */
ret = runtime->set_variable(L"efi_st_var1", &guid_vendor1,
0, 0, NULL);
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index 18663ce6bd..09a7e133a5 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -40,21 +40,14 @@ static const char * const compat_names[COMPAT_COUNT] = {
COMPAT(NVIDIA_TEGRA210_XUSB_PADCTL, "nvidia,tegra210-xusb-padctl"),
COMPAT(SMSC_LAN9215, "smsc,lan9215"),
COMPAT(SAMSUNG_EXYNOS5_SROMC, "samsung,exynos-sromc"),
- COMPAT(SAMSUNG_S3C2440_I2C, "samsung,s3c2440-i2c"),
- COMPAT(SAMSUNG_EXYNOS5_SOUND, "samsung,exynos-sound"),
- COMPAT(WOLFSON_WM8994_CODEC, "wolfson,wm8994-codec"),
COMPAT(SAMSUNG_EXYNOS_USB_PHY, "samsung,exynos-usb-phy"),
COMPAT(SAMSUNG_EXYNOS5_USB3_PHY, "samsung,exynos5250-usb3-phy"),
COMPAT(SAMSUNG_EXYNOS_TMU, "samsung,exynos-tmu"),
COMPAT(SAMSUNG_EXYNOS_MIPI_DSI, "samsung,exynos-mipi-dsi"),
COMPAT(SAMSUNG_EXYNOS_DWMMC, "samsung,exynos-dwmmc"),
- COMPAT(SAMSUNG_EXYNOS_MMC, "samsung,exynos-mmc"),
COMPAT(GENERIC_SPI_FLASH, "spi-flash"),
- COMPAT(MAXIM_98095_CODEC, "maxim,max98095-codec"),
- COMPAT(SAMSUNG_EXYNOS5_I2C, "samsung,exynos5-hsi2c"),
COMPAT(SAMSUNG_EXYNOS_SYSMMU, "samsung,sysmmu-v3.3"),
COMPAT(INTEL_MICROCODE, "intel,microcode"),
- COMPAT(AMS_AS3722, "ams,as3722"),
COMPAT(INTEL_QRK_MRC, "intel,quark-mrc"),
COMPAT(ALTERA_SOCFPGA_DWMAC, "altr,socfpga-stmmac"),
COMPAT(ALTERA_SOCFPGA_DWMMC, "altr,socfpga-dw-mshc"),
@@ -549,6 +542,39 @@ int fdtdec_get_alias_seq(const void *blob, const char *base, int offset,
return -ENOENT;
}
+int fdtdec_get_alias_highest_id(const void *blob, const char *base)
+{
+ int base_len = strlen(base);
+ int prop_offset;
+ int aliases;
+ int max = -1;
+
+ debug("Looking for highest alias id for '%s'\n", base);
+
+ aliases = fdt_path_offset(blob, "/aliases");
+ for (prop_offset = fdt_first_property_offset(blob, aliases);
+ prop_offset > 0;
+ prop_offset = fdt_next_property_offset(blob, prop_offset)) {
+ const char *prop;
+ const char *name;
+ int len, val;
+
+ prop = fdt_getprop_by_offset(blob, prop_offset, &name, &len);
+ debug(" - %s, %s\n", name, prop);
+ if (*prop != '/' || prop[len - 1] ||
+ strncmp(name, base, base_len))
+ continue;
+
+ val = trailing_strtol(name);
+ if (val > max) {
+ debug("Found seq %d\n", val);
+ max = val;
+ }
+ }
+
+ return max;
+}
+
const char *fdtdec_get_chosen_prop(const void *blob, const char *name)
{
int chosen_node;
diff --git a/lib/hashtable.c b/lib/hashtable.c
index 50ff40a397..0d288d12d9 100644
--- a/lib/hashtable.c
+++ b/lib/hashtable.c
@@ -40,6 +40,9 @@
#define CONFIG_ENV_MAX_ENTRIES 512
#endif
+#define USED_FREE 0
+#define USED_DELETED -1
+
#include <env_callback.h>
#include <env_flags.h>
#include <search.h>
@@ -303,7 +306,7 @@ int hsearch_r(ENTRY item, ACTION action, ENTRY ** retval,
*/
unsigned hval2;
- if (htab->table[idx].used == -1
+ if (htab->table[idx].used == USED_DELETED
&& !first_deleted)
first_deleted = idx;
@@ -335,13 +338,17 @@ int hsearch_r(ENTRY item, ACTION action, ENTRY ** retval,
if (idx == hval)
break;
+ if (htab->table[idx].used == USED_DELETED
+ && !first_deleted)
+ first_deleted = idx;
+
/* If entry is found use it. */
ret = _compare_and_overwrite_entry(item, action, retval,
htab, flag, hval, idx);
if (ret != -1)
return ret;
}
- while (htab->table[idx].used);
+ while (htab->table[idx].used != USED_FREE);
}
/* An empty bucket has been found. */
@@ -433,7 +440,7 @@ static void _hdelete(const char *key, struct hsearch_data *htab, ENTRY *ep,
free(ep->data);
ep->callback = NULL;
ep->flags = 0;
- htab->table[idx].used = -1;
+ htab->table[idx].used = USED_DELETED;
--htab->filled;
}
diff --git a/lib/initcall.c b/lib/initcall.c
deleted file mode 100644
index 8f1dac68e4..0000000000
--- a/lib/initcall.c
+++ /dev/null
@@ -1,39 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Copyright (c) 2013 The Chromium OS Authors.
- */
-
-#include <common.h>
-#include <initcall.h>
-#include <efi.h>
-
-DECLARE_GLOBAL_DATA_PTR;
-
-int initcall_run_list(const init_fnc_t init_sequence[])
-{
- const init_fnc_t *init_fnc_ptr;
-
- for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
- unsigned long reloc_ofs = 0;
- int ret;
-
- if (gd->flags & GD_FLG_RELOC)
- reloc_ofs = gd->reloc_off;
-#ifdef CONFIG_EFI_APP
- reloc_ofs = (unsigned long)image_base;
-#endif
- debug("initcall: %p", (char *)*init_fnc_ptr - reloc_ofs);
- if (gd->flags & GD_FLG_RELOC)
- debug(" (relocated to %p)\n", (char *)*init_fnc_ptr);
- else
- debug("\n");
- ret = (*init_fnc_ptr)();
- if (ret) {
- printf("initcall sequence %p failed at call %p (err=%d)\n",
- init_sequence,
- (char *)*init_fnc_ptr - reloc_ofs, ret);
- return -1;
- }
- }
- return 0;
-}
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 4213441fbf..de5db1aa5c 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -279,13 +279,17 @@ static char *string(char *buf, char *end, char *s, int field_width,
static char *string16(char *buf, char *end, u16 *s, int field_width,
int precision, int flags)
{
- u16 *str = s ? s : L"<NULL>";
- ssize_t len = utf16_strnlen(str, precision);
+ const u16 *str = s ? s : L"<NULL>";
+ ssize_t i, len = utf16_strnlen(str, precision);
if (!(flags & LEFT))
for (; len < field_width; --field_width)
ADDCH(buf, ' ');
- utf16_utf8_strncpy(&buf, str, len);
+ for (i = 0; i < len && buf + utf16_utf8_strnlen(str, 1) <= end; ++i) {
+ s32 s = utf16_get(&str);
+
+ utf8_put(s, &buf);
+ }
for (; len < field_width; --field_width)
ADDCH(buf, ' ');
return buf;
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index a5b57fc6b9..66e5015d8d 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -389,7 +389,7 @@ $(obj)/efi_reloc.o: $(srctree)/arch/$(ARCH)/lib/$(EFI_RELOC:.o=.c) $(recordmcoun
$(call cmd,force_checksrc)
$(call if_changed_rule,cc_o_c)
-$(obj)/%_efi.so: $(obj)/%.o $(obj)/efi_crt0.o $(obj)/efi_reloc.o
+$(obj)/%_efi.so: $(obj)/%.o $(obj)/efi_crt0.o $(obj)/efi_reloc.o $(obj)/../efi_loader/efi_freestanding.o
$(call cmd,efi_ld)
# ACPI
diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt
index 38c7f01fad..2b3572568b 100644
--- a/scripts/config_whitelist.txt
+++ b/scripts/config_whitelist.txt
@@ -129,7 +129,6 @@ CONFIG_BOARD_POSTCLK_INIT
CONFIG_BOARD_REVISION_TAG
CONFIG_BOARD_SIZE_LIMIT
CONFIG_BOARD_TAURUS
-CONFIG_BOARD_TYPES
CONFIG_BOOGER
CONFIG_BOOTBLOCK
CONFIG_BOOTFILE
diff --git a/test/Kconfig b/test/Kconfig
index de16d179d0..48a0e501f8 100644
--- a/test/Kconfig
+++ b/test/Kconfig
@@ -6,6 +6,14 @@ menuconfig UNIT_TEST
This does not require sandbox to be included, but it is most
often used there.
+config UT_LIB
+ bool "Unit tests for library functions"
+ depends on UNIT_TEST
+ default y
+ help
+ Enables the 'ut lib' command which tests library functions like
+ memcat(), memcyp(), memmove().
+
config UT_TIME
bool "Unit tests for time functions"
depends on UNIT_TEST
diff --git a/test/cmd_ut.c b/test/cmd_ut.c
index 56924a5272..e3b89504e7 100644
--- a/test/cmd_ut.c
+++ b/test/cmd_ut.c
@@ -46,6 +46,9 @@ static cmd_tbl_t cmd_ut_sub[] = {
#ifdef CONFIG_UT_OVERLAY
U_BOOT_CMD_MKENT(overlay, CONFIG_SYS_MAXARGS, 1, do_ut_overlay, "", ""),
#endif
+#ifdef CONFIG_UT_LIB
+ U_BOOT_CMD_MKENT(lib, CONFIG_SYS_MAXARGS, 1, do_ut_lib, "", ""),
+#endif
#ifdef CONFIG_UT_TIME
U_BOOT_CMD_MKENT(time, CONFIG_SYS_MAXARGS, 1, do_ut_time, "", ""),
#endif
@@ -108,6 +111,9 @@ static char ut_help_text[] =
#ifdef CONFIG_UT_ENV
"ut env [test-name]\n"
#endif
+#ifdef CONFIG_UT_LIB
+ "ut lib [test-name] - test library functions\n"
+#endif
#ifdef CONFIG_UT_OVERLAY
"ut overlay [test-name]\n"
#endif
diff --git a/test/dm/core.c b/test/dm/core.c
index 260f6494a2..edd55b05d6 100644
--- a/test/dm/core.c
+++ b/test/dm/core.c
@@ -749,6 +749,10 @@ static int dm_test_uclass_devices_find(struct unit_test_state *uts)
ut_assert(dev);
}
+ ret = uclass_find_first_device(UCLASS_TEST_DUMMY, &dev);
+ ut_assert(ret == -ENODEV);
+ ut_assert(!dev);
+
return 0;
}
DM_TEST(dm_test_uclass_devices_find, DM_TESTF_SCAN_PDATA);
diff --git a/test/dm/regulator.c b/test/dm/regulator.c
index 5d11e946b2..e510539542 100644
--- a/test/dm/regulator.c
+++ b/test/dm/regulator.c
@@ -175,6 +175,27 @@ static int dm_test_power_regulator_set_get_enable(struct unit_test_state *uts)
}
DM_TEST(dm_test_power_regulator_set_get_enable, DM_TESTF_SCAN_FDT);
+/* Test regulator set and get enable if allowed method */
+static
+int dm_test_power_regulator_set_enable_if_allowed(struct unit_test_state *uts)
+{
+ const char *platname;
+ struct udevice *dev, *dev_autoset;
+ bool val_set = false;
+
+ /* Get BUCK1 - always on regulator */
+ platname = regulator_names[BUCK1][PLATNAME];
+ ut_assertok(regulator_autoset_by_name(platname, &dev_autoset));
+ ut_assertok(regulator_get_by_platname(platname, &dev));
+
+ /* Try disabling always-on regulator */
+ ut_assertok(regulator_set_enable_if_allowed(dev, val_set));
+ ut_asserteq(regulator_get_enable(dev), !val_set);
+
+ return 0;
+}
+DM_TEST(dm_test_power_regulator_set_enable_if_allowed, DM_TESTF_SCAN_FDT);
+
/* Test regulator set and get mode method */
static int dm_test_power_regulator_set_get_mode(struct unit_test_state *uts)
{
diff --git a/test/dm/test-fdt.c b/test/dm/test-fdt.c
index 984b80c02c..be16c99e17 100644
--- a/test/dm/test-fdt.c
+++ b/test/dm/test-fdt.c
@@ -219,6 +219,29 @@ static int dm_test_fdt(struct unit_test_state *uts)
}
DM_TEST(dm_test_fdt, 0);
+static int dm_test_alias_highest_id(struct unit_test_state *uts)
+{
+ int ret;
+
+ ret = dev_read_alias_highest_id("eth");
+ ut_asserteq(5, ret);
+
+ ret = dev_read_alias_highest_id("gpio");
+ ut_asserteq(2, ret);
+
+ ret = dev_read_alias_highest_id("pci");
+ ut_asserteq(2, ret);
+
+ ret = dev_read_alias_highest_id("i2c");
+ ut_asserteq(0, ret);
+
+ ret = dev_read_alias_highest_id("deadbeef");
+ ut_asserteq(-1, ret);
+
+ return 0;
+}
+DM_TEST(dm_test_alias_highest_id, 0);
+
static int dm_test_fdt_pre_reloc(struct unit_test_state *uts)
{
struct uclass *uc;
diff --git a/test/env/Makefile b/test/env/Makefile
index d71a11b6e2..5c8eae31b0 100644
--- a/test/env/Makefile
+++ b/test/env/Makefile
@@ -4,3 +4,4 @@
obj-y += cmd_ut_env.o
obj-y += attr.o
+obj-y += hashtable.o
diff --git a/test/env/hashtable.c b/test/env/hashtable.c
new file mode 100644
index 0000000000..8c87e65457
--- /dev/null
+++ b/test/env/hashtable.c
@@ -0,0 +1,125 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * (C) Copyright 2019
+ * Roman Kapl, SYSGO, rka@sysgo.com
+ */
+
+#include <common.h>
+#include <command.h>
+#include <search.h>
+#include <stdio.h>
+#include <test/env.h>
+#include <test/ut.h>
+
+#define SIZE 32
+#define ITERATIONS 10000
+
+static int htab_fill(struct unit_test_state *uts,
+ struct hsearch_data *htab, size_t size)
+{
+ size_t i;
+ ENTRY item;
+ ENTRY *ritem;
+ char key[20];
+
+ for (i = 0; i < size; i++) {
+ sprintf(key, "%d", (int)i);
+ item.callback = NULL;
+ item.data = key;
+ item.flags = 0;
+ item.key = key;
+ ut_asserteq(1, hsearch_r(item, ENTER, &ritem, htab, 0));
+ }
+
+ return 0;
+}
+
+static int htab_check_fill(struct unit_test_state *uts,
+ struct hsearch_data *htab, size_t size)
+{
+ size_t i;
+ ENTRY item;
+ ENTRY *ritem;
+ char key[20];
+
+ for (i = 0; i < size; i++) {
+ sprintf(key, "%d", (int)i);
+ item.callback = NULL;
+ item.flags = 0;
+ item.data = key;
+ item.key = key;
+ hsearch_r(item, FIND, &ritem, htab, 0);
+ ut_assert(ritem);
+ ut_asserteq_str(key, ritem->key);
+ ut_asserteq_str(key, ritem->data);
+ }
+
+ return 0;
+}
+
+static int htab_create_delete(struct unit_test_state *uts,
+ struct hsearch_data *htab, size_t iterations)
+{
+ size_t i;
+ ENTRY item;
+ ENTRY *ritem;
+ char key[20];
+
+ for (i = 0; i < iterations; i++) {
+ sprintf(key, "cd-%d", (int)i);
+ item.callback = NULL;
+ item.flags = 0;
+ item.data = key;
+ item.key = key;
+ hsearch_r(item, ENTER, &ritem, htab, 0);
+ ritem = NULL;
+
+ hsearch_r(item, FIND, &ritem, htab, 0);
+ ut_assert(ritem);
+ ut_asserteq_str(key, ritem->key);
+ ut_asserteq_str(key, ritem->data);
+
+ ut_asserteq(1, hdelete_r(key, htab, 0));
+ }
+
+ return 0;
+}
+
+/* Completely fill up the hash table */
+static int env_test_htab_fill(struct unit_test_state *uts)
+{
+ struct hsearch_data htab;
+
+ memset(&htab, 0, sizeof(htab));
+ ut_asserteq(1, hcreate_r(SIZE, &htab));
+
+ ut_assertok(htab_fill(uts, &htab, SIZE));
+ ut_assertok(htab_check_fill(uts, &htab, SIZE));
+ ut_asserteq(SIZE, htab.filled);
+
+ hdestroy_r(&htab);
+ return 0;
+}
+
+ENV_TEST(env_test_htab_fill, 0);
+
+/* Fill the hashtable up halfway an repeateadly delete/create elements
+ * and check for corruption
+ */
+static int env_test_htab_deletes(struct unit_test_state *uts)
+{
+ struct hsearch_data htab;
+
+ memset(&htab, 0, sizeof(htab));
+ ut_asserteq(1, hcreate_r(SIZE, &htab));
+
+ ut_assertok(htab_fill(uts, &htab, SIZE / 2));
+ ut_assertok(htab_create_delete(uts, &htab, ITERATIONS));
+ ut_assertok(htab_check_fill(uts, &htab, SIZE / 2));
+ ut_asserteq(SIZE / 2, htab.filled);
+
+ hdestroy_r(&htab);
+ return 0;
+}
+
+ENV_TEST(env_test_htab_deletes, 0);
diff --git a/test/lib/Makefile b/test/lib/Makefile
index 5a636aac74..308c61708e 100644
--- a/test/lib/Makefile
+++ b/test/lib/Makefile
@@ -2,5 +2,7 @@
#
# (C) Copyright 2018
# Mario Six, Guntermann & Drunck GmbH, mario.six@gdsys.cc
+obj-y += cmd_ut_lib.o
obj-y += hexdump.o
obj-y += lmb.o
+obj-y += string.o
diff --git a/test/lib/cmd_ut_lib.c b/test/lib/cmd_ut_lib.c
new file mode 100644
index 0000000000..eb90e53914
--- /dev/null
+++ b/test/lib/cmd_ut_lib.c
@@ -0,0 +1,20 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2019 Heinrich Schuchardt <xypron.glpk@gmx.de>
+ *
+ * Unit tests for library functions
+ */
+
+#include <common.h>
+#include <command.h>
+#include <test/lib.h>
+#include <test/suites.h>
+#include <test/ut.h>
+
+int do_ut_lib(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+ struct unit_test *tests = ll_entry_start(struct unit_test, lib_test);
+ const int n_ents = ll_entry_count(struct unit_test, lib_test);
+
+ return cmd_ut_category("lib", tests, n_ents, argc, argv);
+}
diff --git a/test/lib/string.c b/test/lib/string.c
new file mode 100644
index 0000000000..8e246ab4ed
--- /dev/null
+++ b/test/lib/string.c
@@ -0,0 +1,194 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2019 Heinrich Schuchardt <xypron.glpk@gmx.de>
+ *
+ * Unit tests for memory functions
+ *
+ * The architecture dependent implementations run through different lines of
+ * code depending on the alignment and length of memory regions copied or set.
+ * This has to be considered in testing.
+ */
+
+#include <common.h>
+#include <command.h>
+#include <test/lib.h>
+#include <test/test.h>
+#include <test/ut.h>
+
+/* Xor mask used for marking memory regions */
+#define MASK 0xA5
+/* Number of different alignment values */
+#define SWEEP 16
+/* Allow for copying up to 32 bytes */
+#define BUFLEN (SWEEP + 33)
+
+/**
+ * init_buffer() - initialize buffer
+ *
+ * The buffer is filled with incrementing values xor'ed with the mask.
+ *
+ * @buf: buffer
+ * @mask: xor mask
+ */
+static void init_buffer(u8 buf[], u8 mask)
+{
+ int i;
+
+ for (i = 0; i < BUFLEN; ++i)
+ buf[i] = i ^ mask;
+}
+
+/**
+ * test_memset() - test result of memset()
+ *
+ * @uts: unit test state
+ * @buf: buffer
+ * @mask: value set by memset()
+ * @offset: relative start of region changed by memset() in buffer
+ * @len: length of region changed by memset()
+ * Return: 0 = success, 1 = failure
+ */
+static int test_memset(struct unit_test_state *uts, u8 buf[], u8 mask,
+ int offset, int len)
+{
+ int i;
+
+ for (i = 0; i < BUFLEN; ++i) {
+ if (i < offset || i >= offset + len) {
+ ut_asserteq(i, buf[i]);
+ } else {
+ ut_asserteq(mask, buf[i]);
+ }
+ }
+ return 0;
+}
+
+/**
+ * lib_memset() - unit test for memset()
+ *
+ * Test memset() with varied alignment and length of the changed buffer.
+ *
+ * @uts: unit test state
+ * Return: 0 = success, 1 = failure
+ */
+static int lib_memset(struct unit_test_state *uts)
+{
+ u8 buf[BUFLEN];
+ int offset, len;
+ void *ptr;
+
+ for (offset = 0; offset <= SWEEP; ++offset) {
+ for (len = 1; len < BUFLEN - SWEEP; ++len) {
+ init_buffer(buf, 0);
+ ptr = memset(buf + offset, MASK, len);
+ ut_asserteq_ptr(buf + offset, (u8 *)ptr);
+ if (test_memset(uts, buf, MASK, offset, len)) {
+ debug("%s: failure %d, %d\n",
+ __func__, offset, len);
+ return CMD_RET_FAILURE;
+ }
+ }
+ }
+ return 0;
+}
+
+LIB_TEST(lib_memset, 0);
+
+/**
+ * test_memmove() - test result of memcpy() or memmove()
+ *
+ * @uts: unit test state
+ * @buf: buffer
+ * @mask: xor mask used to initialize source buffer
+ * @offset1: relative start of copied region in source buffer
+ * @offset2: relative start of copied region in destination buffer
+ * @len: length of region changed by memset()
+ * Return: 0 = success, 1 = failure
+ */
+static int test_memmove(struct unit_test_state *uts, u8 buf[], u8 mask,
+ int offset1, int offset2, int len)
+{
+ int i;
+
+ for (i = 0; i < BUFLEN; ++i) {
+ if (i < offset2 || i >= offset2 + len) {
+ ut_asserteq(i, buf[i]);
+ } else {
+ ut_asserteq((i + offset1 - offset2) ^ mask, buf[i]);
+ }
+ }
+ return 0;
+}
+
+/**
+ * lib_memcpy() - unit test for memcpy()
+ *
+ * Test memcpy() with varied alignment and length of the copied buffer.
+ *
+ * @uts: unit test state
+ * Return: 0 = success, 1 = failure
+ */
+static int lib_memcpy(struct unit_test_state *uts)
+{
+ u8 buf1[BUFLEN];
+ u8 buf2[BUFLEN];
+ int offset1, offset2, len;
+ void *ptr;
+
+ init_buffer(buf1, MASK);
+
+ for (offset1 = 0; offset1 <= SWEEP; ++offset1) {
+ for (offset2 = 0; offset2 <= SWEEP; ++offset2) {
+ for (len = 1; len < BUFLEN - SWEEP; ++len) {
+ init_buffer(buf2, 0);
+ ptr = memcpy(buf2 + offset2, buf1 + offset1,
+ len);
+ ut_asserteq_ptr(buf2 + offset2, (u8 *)ptr);
+ if (test_memmove(uts, buf2, MASK, offset1,
+ offset2, len)) {
+ debug("%s: failure %d, %d, %d\n",
+ __func__, offset1, offset2, len);
+ return CMD_RET_FAILURE;
+ }
+ }
+ }
+ }
+ return 0;
+}
+
+LIB_TEST(lib_memcpy, 0);
+
+/**
+ * lib_memmove() - unit test for memmove()
+ *
+ * Test memmove() with varied alignment and length of the copied buffer.
+ *
+ * @uts: unit test state
+ * Return: 0 = success, 1 = failure
+ */
+static int lib_memmove(struct unit_test_state *uts)
+{
+ u8 buf[BUFLEN];
+ int offset1, offset2, len;
+ void *ptr;
+
+ for (offset1 = 0; offset1 <= SWEEP; ++offset1) {
+ for (offset2 = 0; offset2 <= SWEEP; ++offset2) {
+ for (len = 1; len < BUFLEN - SWEEP; ++len) {
+ init_buffer(buf, 0);
+ ptr = memmove(buf + offset2, buf + offset1,
+ len);
+ ut_asserteq_ptr(buf + offset2, (u8 *)ptr);
+ if (test_memmove(uts, buf, 0, offset1, offset2,
+ len)) {
+ debug("%s: failure %d, %d, %d\n",
+ __func__, offset1, offset2, len);
+ return CMD_RET_FAILURE;
+ }
+ }
+ }
+ }
+ return 0;
+}
+
+LIB_TEST(lib_memmove, 0);
diff --git a/test/py/tests/test_net.py b/test/py/tests/test_net.py
index 9c395e69fa..9ca6743afd 100644
--- a/test/py/tests/test_net.py
+++ b/test/py/tests/test_net.py
@@ -145,11 +145,12 @@ def test_net_tftpboot(u_boot_console):
pytest.skip('No TFTP readable file to read')
addr = f.get('addr', None)
- if not addr:
- addr = u_boot_utils.find_ram_base(u_boot_console)
fn = f['fn']
- output = u_boot_console.run_command('tftpboot %x %s' % (addr, fn))
+ if not addr:
+ output = u_boot_console.run_command('tftpboot %s' % (fn))
+ else:
+ output = u_boot_console.run_command('tftpboot %x %s' % (addr, fn))
expected_text = 'Bytes transferred = '
sz = f.get('size', None)
if sz:
@@ -163,7 +164,7 @@ def test_net_tftpboot(u_boot_console):
if u_boot_console.config.buildconfig.get('config_cmd_crc32', 'n') != 'y':
return
- output = u_boot_console.run_command('crc32 %x $filesize' % addr)
+ output = u_boot_console.run_command('crc32 $fileaddr $filesize')
assert expected_crc in output
@pytest.mark.buildconfigspec('cmd_nfs')
diff --git a/test/unicode_ut.c b/test/unicode_ut.c
index b115d18afd..84fc9a3b53 100644
--- a/test/unicode_ut.c
+++ b/test/unicode_ut.c
@@ -50,6 +50,29 @@ static const char j1[] = {0x6a, 0x31, 0xa1, 0x6c, 0x00};
static const char j2[] = {0x6a, 0x32, 0xc3, 0xc3, 0x6c, 0x00};
static const char j3[] = {0x6a, 0x33, 0xf0, 0x90, 0xf0, 0x00};
+static int ut_u16_strdup(struct unit_test_state *uts)
+{
+ u16 *copy = u16_strdup(c4);
+
+ ut_assert(copy != c4);
+ ut_assert(!memcmp(copy, c4, sizeof(c4)));
+ free(copy);
+ return 0;
+}
+UNICODE_TEST(ut_u16_strdup);
+
+static int ut_u16_strcpy(struct unit_test_state *uts)
+{
+ u16 *r;
+ u16 copy[10];
+
+ r = u16_strcpy(copy, c1);
+ ut_assert(r == copy);
+ ut_assert(!memcmp(copy, c1, sizeof(c1)));
+ return 0;
+}
+UNICODE_TEST(ut_u16_strcpy);
+
/* U-Boot uses UTF-16 strings in the EFI context only. */
#if CONFIG_IS_ENABLED(EFI_LOADER) && !defined(API_BUILD)
static int ut_string16(struct unit_test_state *uts)
diff --git a/tools/buildman/builderthread.py b/tools/buildman/builderthread.py
index 6b156f152d..8a9d47cd5e 100644
--- a/tools/buildman/builderthread.py
+++ b/tools/buildman/builderthread.py
@@ -322,6 +322,9 @@ class BuilderThread(threading.Thread):
# Write out the image and function size information and an objdump
env = result.toolchain.MakeEnvironment(self.builder.full_path)
+ with open(os.path.join(build_dir, 'env'), 'w') as fd:
+ for var in sorted(env.keys()):
+ print >>fd, '%s="%s"' % (var, env[var])
lines = []
for fname in ['u-boot', 'spl/u-boot-spl']:
cmd = ['%snm' % self.toolchain.cross, '--size-sort', fname]
diff --git a/tools/buildman/control.py b/tools/buildman/control.py
index 27916d3c35..fcf531c5f1 100644
--- a/tools/buildman/control.py
+++ b/tools/buildman/control.py
@@ -99,7 +99,7 @@ def CheckOutputDir(output_dir):
cwd_path = os.path.realpath('.')
while True:
if os.path.realpath(path) == cwd_path:
- Print("Cannot use output directory '%s' since it is within the current directtory '%s'" %
+ Print("Cannot use output directory '%s' since it is within the current directory '%s'" %
(path, cwd_path))
sys.exit(1)
parent = os.path.dirname(path)
diff --git a/tools/k3_x509template.txt b/tools/k3_x509template.txt
index bd3a9ab056..f176ff3ad2 100644
--- a/tools/k3_x509template.txt
+++ b/tools/k3_x509template.txt
@@ -42,7 +42,7 @@
# salt = FORMAT:HEX,OCT:TEST_IMAGE_KEY_DERIVE_SALT
[ debug ]
+ debugUID = FORMAT:HEX,OCT:0000000000000000000000000000000000000000000000000000000000000000
debugType = INTEGER:4
coreDbgEn = INTEGER:0
coreDbgSecEn = INTEGER:0
- debugUID = FORMAT:HEX,OCT:0000000000000000000000000000000000000000000000000000000000000000
diff --git a/tools/moveconfig.py b/tools/moveconfig.py
index caa81ac2ed..1a214c5605 100755
--- a/tools/moveconfig.py
+++ b/tools/moveconfig.py
@@ -545,6 +545,28 @@ def confirm(options, prompt):
return True
+def cleanup_empty_blocks(header_path, options):
+ """Clean up empty conditional blocks
+
+ Arguments:
+ header_path: path to the cleaned file.
+ options: option flags.
+ """
+ pattern = re.compile(r'^\s*#\s*if.*$\n^\s*#\s*endif.*$\n*', flags=re.M)
+ with open(header_path) as f:
+ data = f.read()
+
+ new_data = pattern.sub('\n', data)
+
+ show_diff(data.splitlines(True), new_data.splitlines(True), header_path,
+ options.color)
+
+ if options.dry_run:
+ return
+
+ with open(header_path, 'w') as f:
+ f.write(new_data)
+
def cleanup_one_header(header_path, patterns, options):
"""Clean regex-matched lines away from a file.
@@ -626,8 +648,9 @@ def cleanup_headers(configs, options):
continue
for filename in filenames:
if not fnmatch.fnmatch(filename, '*~'):
- cleanup_one_header(os.path.join(dirpath, filename),
- patterns, options)
+ header_path = os.path.join(dirpath, filename)
+ cleanup_one_header(header_path, patterns, options)
+ cleanup_empty_blocks(header_path, options)
def cleanup_one_extra_option(defconfig_path, configs, options):
"""Delete config defines in CONFIG_SYS_EXTRA_OPTIONS in one defconfig file.