Merge branch 'next' of git://git.denx.de/u-boot-usb into next
authorTom Rini <trini@konsulko.com>
Tue, 31 Mar 2020 21:24:19 +0000 (17:24 -0400)
committerTom Rini <trini@konsulko.com>
Tue, 31 Mar 2020 21:24:19 +0000 (17:24 -0400)
68 files changed:
MAINTAINERS
Makefile
arch/arm/cpu/armv7/sunxi/psci.c
arch/arm/dts/rv1108-elgin-r1.dts
arch/arm/dts/rv1108-u-boot.dtsi [new file with mode: 0644]
arch/arm/mach-stm32mp/Kconfig
arch/riscv/Kconfig
arch/riscv/include/asm/sbi.h
arch/riscv/lib/Makefile
arch/riscv/lib/sbi.c [new file with mode: 0644]
arch/riscv/lib/sbi_ipi.c
board/elgin/elgin_rv1108/elgin_rv1108.c
board/rockchip/evb_rv1108/evb_rv1108.c
cmd/bootefi.c
cmd/efidebug.c
cmd/gpio.c
common/image-fit.c
configs/elgin-rv1108_defconfig
configs/miqi-rk3288_defconfig
configs/roc-pc-rk3399_defconfig
configs/rock2_defconfig
configs/sandbox64_defconfig
configs/sandbox_defconfig
configs/tinker-rk3288_defconfig
configs/tinker-s-rk3288_defconfig
drivers/rng/Kconfig
drivers/rng/Makefile
drivers/rng/meson-rng.c [new file with mode: 0644]
drivers/serial/Makefile
drivers/serial/mcfuart.c [deleted file]
drivers/serial/serial_mcf.c [new file with mode: 0644]
drivers/usb/cdns3/core.c
drivers/usb/cdns3/gadget.c
drivers/usb/common/common.c
drivers/usb/dwc3/dwc3-generic.c
drivers/usb/dwc3/dwc3-meson-g12a.c
drivers/usb/gadget/dwc2_udc_otg.c
drivers/usb/host/dwc3-of-simple.c
drivers/usb/host/dwc3-sti-glue.c
drivers/usb/host/ehci-msm.c
drivers/usb/host/ehci-mx6.c
drivers/usb/host/xhci-dwc3.c
drivers/usb/musb-new/ti-musb.c
drivers/watchdog/Kconfig
drivers/watchdog/wdt-uclass.c
fs/ext4/ext4fs.c
include/configs/miqi_rk3288.h
include/configs/roc-pc-rk3399.h
include/configs/rock2.h
include/configs/tinker_rk3288.h
include/configs/vyasa-rk3288.h
include/efi_api.h
include/efi_loader.h
include/linux/usb/otg.h
include/wdt.h
lib/efi_loader/efi_boottime.c
lib/efi_loader/efi_disk.c
lib/efi_loader/efi_freestanding.c
lib/efi_loader/efi_memory.c
lib/efi_loader/efi_runtime.c
lib/efi_loader/efi_variable.c
lib/efi_selftest/Makefile
lib/efi_selftest/efi_selftest_mem.c [new file with mode: 0644]
lib/efi_selftest/efi_selftest_variables.c
test/compression.c
test/py/tests/test_gpio.py [new file with mode: 0644]
test/py/tests/test_mmc_rd.py
tools/rkcommon.c

index 2c43573ff58f715be6b255eeb69ad0d6fcae2c45..b50652bd85d06adcdb0017b39d3757bc4eb2ad29 100644 (file)
@@ -329,8 +329,21 @@ F: drivers/usb/host/ehci-msm.c
 ARM STI
 M:     Patrice Chotard <patrice.chotard@st.com>
 S:     Maintained
+T:     git https://gitlab.denx.de/u-boot/custodians/u-boot-stm.git
 F:     arch/arm/mach-sti/
 F:     arch/arm/include/asm/arch-sti*/
+F:     drivers/phy/sti_usb_phy.c
+F:     drivers/pinctrl/pinctrl-sti.c
+F:     drivers/mmc/sti_sdhci.c
+F:     drivers/reset/sti-reset.c
+F:     drivers/serial/serial_sti_asc.c
+F:     drivers/sysreset/sysreset_sti.c
+F:     drivers/timer/sti-timer.c
+F:     drivers/usb/host/dwc3-sti-glue.c
+F:     include/dwc3-sti-glue.h
+F:     include/dt-bindings/clock/stih407-clks.h
+F:     include/dt-bindings/clock/stih410-clks.h
+F:     include/dt-bindings/reset/stih407-resets.h
 
 ARM STM SPEAR
 #M:    Vipin Kumar <vipin.kumar@st.com>
@@ -514,6 +527,13 @@ M: Simon Glass <sjg@chromium.org>
 S:     Maintained
 F:     tools/binman/
 
+BTRFS
+M:     Marek Behun <marek.behun@nic.cz>
+S:     Maintained
+F:     cmd/btrfs.c
+F:     fs/btrfs/
+F:     include/btrfs.h
+
 BUILDMAN
 M:     Simon Glass <sjg@chromium.org>
 S:     Maintained
@@ -924,6 +944,7 @@ T:  git https://gitlab.denx.de/u-boot/custodians/u-boot-usb.git
 F:     drivers/usb/
 F:     common/usb.c
 F:     common/usb_kbd.c
+F:     include/usb.h
 
 USB xHCI
 M:     Bin Meng <bmeng.cn@gmail.com>
index 84ab6803c93ff17090af156e85355fca22457c76..e5c05028dc87dec63d4ab36caf327200e112bbe9 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -904,7 +904,7 @@ ifneq ($(CONFIG_BUILD_TARGET),)
 ALL-y += $(CONFIG_BUILD_TARGET:"%"=%)
 endif
 
-ifdef CONFIG_INIT_SP_RELATIVE
+ifeq ($(CONFIG_INIT_SP_RELATIVE)$(CONFIG_OF_SEPARATE),yy)
 ALL-y += init_sp_bss_offset_check
 endif
 
@@ -1215,7 +1215,7 @@ binary_size_check: u-boot-nodtb.bin FORCE
                fi \
        fi
 
-ifdef CONFIG_INIT_SP_RELATIVE
+ifeq ($(CONFIG_INIT_SP_RELATIVE)$(CONFIG_OF_SEPARATE),yy)
 ifneq ($(CONFIG_SYS_MALLOC_F_LEN),)
 subtract_sys_malloc_f_len = space=$$(($${space} - $(CONFIG_SYS_MALLOC_F_LEN)))
 else
index 5b689004e89c9bafdc71eccb2228740ac53091d4..2c5d99e9acda4bab5c29ad680299106a28a6b571 100644 (file)
@@ -75,7 +75,7 @@ static void __secure __mdelay(u32 ms)
        isb();
 }
 
-static void __secure clamp_release(void __maybe_unused *clamp)
+static void __secure clamp_release(u32 __maybe_unused *clamp)
 {
 #if defined(CONFIG_MACH_SUN6I) || defined(CONFIG_MACH_SUN7I) || \
        defined(CONFIG_MACH_SUN8I_H3) || \
@@ -90,7 +90,7 @@ static void __secure clamp_release(void __maybe_unused *clamp)
 #endif
 }
 
-static void __secure clamp_set(void __maybe_unused *clamp)
+static void __secure clamp_set(u32 __maybe_unused *clamp)
 {
 #if defined(CONFIG_MACH_SUN6I) || defined(CONFIG_MACH_SUN7I) || \
        defined(CONFIG_MACH_SUN8I_H3) || \
@@ -99,28 +99,22 @@ static void __secure clamp_set(void __maybe_unused *clamp)
 #endif
 }
 
-static void __secure sunxi_power_switch(void *clamp, void *pwroff_ptr, bool on,
+static void __secure sunxi_power_switch(u32 *clamp, u32 *pwroff, bool on,
                                        int cpu)
 {
-       u32 pwroff;
-
-       memcpy(&pwroff, pwroff_ptr, sizeof(u32));
-
        if (on) {
                /* Release power clamp */
                clamp_release(clamp);
 
                /* Clear power gating */
-               clrbits_le32(&pwroff, BIT(cpu));
+               clrbits_le32(pwroff, BIT(cpu));
        } else {
                /* Set power gating */
-               setbits_le32(&pwroff, BIT(cpu));
+               setbits_le32(pwroff, BIT(cpu));
 
                /* Activate power clamp */
                clamp_set(clamp);
        }
-
-       memcpy(pwroff_ptr, &pwroff, sizeof(u32));
 }
 
 #ifdef CONFIG_MACH_SUN8I_R40
index 32b95940b071e7c82a466c3104dbd59588a839b7..83e8b3183847cdb9b7cb608b4aaca0be95466c8d 100644 (file)
 };
 
 &uart2 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&uart2m0_xfer_pullup>;
        status = "okay";
 };
 
 &usb20_otg {
        status = "okay";
 };
+
+&pinctrl {
+       uart2m0 {
+               uart2m0_xfer_pullup: uart2m0-xfer-pullup {
+                       rockchip,pins = <2 RK_PD2 RK_FUNC_1 &pcfg_pull_up_drv_8ma>,
+                                       <2 RK_PD1 RK_FUNC_1 &pcfg_pull_up_drv_8ma>;
+               };
+       };
+};
diff --git a/arch/arm/dts/rv1108-u-boot.dtsi b/arch/arm/dts/rv1108-u-boot.dtsi
new file mode 100644 (file)
index 0000000..41ac054
--- /dev/null
@@ -0,0 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2019 Jagan Teki <jagan@amarulasolutions.com>
+ */
+
+#include "rockchip-u-boot.dtsi"
index e4d621dee884a32de3c04703cc803209217da4db..96153693a7e2c203db8a6f3a986c97df6088ec73 100644 (file)
@@ -119,7 +119,7 @@ config SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION_MMC2
 
 config STM32_ETZPC
        bool "STM32 Extended TrustZone Protection"
-       depends on TARGET_STM32MP1
+       depends on STM32MP15x
        default y
        help
          Say y to enable STM32 Extended TrustZone Protection
index f49618d24d2675e91b21598150bbb40a3ae3160f..3061bf886302ba1c71fec336cfdd3a641973efc7 100644 (file)
@@ -210,8 +210,21 @@ config NR_CPUS
          Stack memory is pre-allocated. U-Boot must therefore know the
          maximum number of CPUs that may be present.
 
+config SBI
+       bool
+       default y if RISCV_SMODE || SPL_RISCV_SMODE
+
+config SBI_V01
+       bool "SBI v0.1 support"
+       default y
+       depends on SBI
+       help
+         This config allows kernel to use SBI v0.1 APIs. This will be
+         deprecated in future once legacy M-mode software are no longer in use.
+
 config SBI_IPI
        bool
+       depends on SBI
        default y if RISCV_SMODE || SPL_RISCV_SMODE
        depends on SMP
 
index ced57defdd38e9f14e2261af303f02ba9d8bea7a..3595ee8bf7ee8b0789ee3e55bd2798aae4c2a4c4 100644 (file)
@@ -1,6 +1,7 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 /*
  * Copyright (C) 2015 Regents of the University of California
+ * Copyright (c) 2020 Western Digital Corporation or its affiliates.
  *
  * Taken from Linux arch/riscv/include/asm/sbi.h
  */
 
 #include <linux/types.h>
 
-#define SBI_SET_TIMER 0
-#define SBI_CONSOLE_PUTCHAR 1
-#define SBI_CONSOLE_GETCHAR 2
-#define SBI_CLEAR_IPI 3
-#define SBI_SEND_IPI 4
-#define SBI_REMOTE_FENCE_I 5
-#define SBI_REMOTE_SFENCE_VMA 6
-#define SBI_REMOTE_SFENCE_VMA_ASID 7
-#define SBI_SHUTDOWN 8
+enum sbi_ext_id {
+#ifdef CONFIG_SBI_V01
+       SBI_EXT_0_1_SET_TIMER = 0x0,
+       SBI_EXT_0_1_CONSOLE_PUTCHAR = 0x1,
+       SBI_EXT_0_1_CONSOLE_GETCHAR = 0x2,
+       SBI_EXT_0_1_CLEAR_IPI = 0x3,
+       SBI_EXT_0_1_SEND_IPI = 0x4,
+       SBI_EXT_0_1_REMOTE_FENCE_I = 0x5,
+       SBI_EXT_0_1_REMOTE_SFENCE_VMA = 0x6,
+       SBI_EXT_0_1_REMOTE_SFENCE_VMA_ASID = 0x7,
+       SBI_EXT_0_1_SHUTDOWN = 0x8,
+#endif
+       SBI_EXT_BASE = 0x10,
+       SBI_EXT_TIME = 0x54494D45,
+       SBI_EXT_IPI = 0x735049,
+       SBI_EXT_RFENCE = 0x52464E43,
+};
 
-#define SBI_CALL(which, arg0, arg1, arg2) ({                   \
-       register uintptr_t a0 asm ("a0") = (uintptr_t)(arg0);   \
-       register uintptr_t a1 asm ("a1") = (uintptr_t)(arg1);   \
-       register uintptr_t a2 asm ("a2") = (uintptr_t)(arg2);   \
-       register uintptr_t a7 asm ("a7") = (uintptr_t)(which);  \
-       asm volatile ("ecall"                                   \
-                     : "+r" (a0)                               \
-                     : "r" (a1), "r" (a2), "r" (a7)            \
-                     : "memory");                              \
-       a0;                                                     \
-})
+enum sbi_ext_base_fid {
+       SBI_EXT_BASE_GET_SPEC_VERSION = 0,
+       SBI_EXT_BASE_GET_IMP_ID,
+       SBI_EXT_BASE_GET_IMP_VERSION,
+       SBI_EXT_BASE_PROBE_EXT,
+       SBI_EXT_BASE_GET_MVENDORID,
+       SBI_EXT_BASE_GET_MARCHID,
+       SBI_EXT_BASE_GET_MIMPID,
+};
 
-/* Lazy implementations until SBI is finalized */
-#define SBI_CALL_0(which) SBI_CALL(which, 0, 0, 0)
-#define SBI_CALL_1(which, arg0) SBI_CALL(which, arg0, 0, 0)
-#define SBI_CALL_2(which, arg0, arg1) SBI_CALL(which, arg0, arg1, 0)
+enum sbi_ext_time_fid {
+       SBI_EXT_TIME_SET_TIMER = 0,
+};
 
-static inline void sbi_console_putchar(int ch)
-{
-       SBI_CALL_1(SBI_CONSOLE_PUTCHAR, ch);
-}
+enum sbi_ext_ipi_fid {
+       SBI_EXT_IPI_SEND_IPI = 0,
+};
 
-static inline int sbi_console_getchar(void)
-{
-       return SBI_CALL_0(SBI_CONSOLE_GETCHAR);
-}
+enum sbi_ext_rfence_fid {
+       SBI_EXT_RFENCE_REMOTE_FENCE_I = 0,
+       SBI_EXT_RFENCE_REMOTE_SFENCE_VMA,
+       SBI_EXT_RFENCE_REMOTE_SFENCE_VMA_ASID,
+};
 
-static inline void sbi_set_timer(uint64_t stime_value)
-{
-#if __riscv_xlen == 32
-       SBI_CALL_2(SBI_SET_TIMER, stime_value, stime_value >> 32);
+#ifdef CONFIG_SBI_V01
+#define SBI_EXT_SET_TIMER              SBI_EXT_0_1_SET_TIMER
+#define SBI_FID_SET_TIMER              0
+#define SBI_EXT_SEND_IPI               SBI_EXT_0_1_SEND_IPI
+#define SBI_FID_SEND_IPI               0
+#define SBI_EXT_REMOTE_FENCE_I         SBI_EXT_0_1_REMOTE_FENCE_I
+#define SBI_FID_REMOTE_FENCE_I         0
+#define SBI_EXT_REMOTE_SFENCE_VMA      SBI_EXT_0_1_REMOTE_SFENCE_VMA
+#define SBI_FID_REMOTE_SFENCE_VMA      0
+#define SBI_EXT_REMOTE_SFENCE_VMA_ASID SBI_EXT_0_1_REMOTE_SFENCE_VMA_ASID
+#define SBI_FID_REMOTE_SFENCE_VMA_ASID 0
 #else
-       SBI_CALL_1(SBI_SET_TIMER, stime_value);
+#define SBI_EXT_SET_TIMER              SBI_EXT_TIME
+#define SBI_FID_SET_TIMER              SBI_EXT_TIME_SET_TIMER
+#define SBI_EXT_SEND_IPI               SBI_EXT_IPI
+#define SBI_FID_SEND_IPI               SBI_EXT_IPI_SEND_IPI
+#define SBI_EXT_REMOTE_FENCE_I         SBI_EXT_RFENCE
+#define SBI_FID_REMOTE_FENCE_I         SBI_EXT_RFENCE_REMOTE_FENCE_I
+#define SBI_EXT_REMOTE_SFENCE_VMA      SBI_EXT_RFENCE
+#define SBI_FID_REMOTE_SFENCE_VMA      SBI_EXT_RFENCE_REMOTE_SFENCE_VMA
+#define SBI_EXT_REMOTE_SFENCE_VMA_ASID SBI_EXT_RFENCE
+#define SBI_FID_REMOTE_SFENCE_VMA_ASID SBI_EXT_RFENCE_REMOTE_SFENCE_VMA_ASID
 #endif
-}
 
-static inline void sbi_shutdown(void)
-{
-       SBI_CALL_0(SBI_SHUTDOWN);
-}
+#define SBI_SPEC_VERSION_DEFAULT       0x1
+#define SBI_SPEC_VERSION_MAJOR_SHIFT   24
+#define SBI_SPEC_VERSION_MAJOR_MASK    0x7f
+#define SBI_SPEC_VERSION_MINOR_MASK    0xffffff
 
-static inline void sbi_clear_ipi(void)
-{
-       SBI_CALL_0(SBI_CLEAR_IPI);
-}
+/* SBI return error codes */
+#define SBI_SUCCESS                    0
+#define SBI_ERR_FAILURE                        -1
+#define SBI_ERR_NOT_SUPPORTED          -2
+#define SBI_ERR_INVALID_PARAM          -3
+#define SBI_ERR_DENIED                 -4
+#define SBI_ERR_INVALID_ADDRESS                -5
 
-static inline void sbi_send_ipi(const unsigned long *hart_mask)
-{
-       SBI_CALL_1(SBI_SEND_IPI, hart_mask);
-}
+extern unsigned long sbi_spec_version;
+struct sbiret {
+       long error;
+       long value;
+};
 
-static inline void sbi_remote_fence_i(const unsigned long *hart_mask)
-{
-       SBI_CALL_1(SBI_REMOTE_FENCE_I, hart_mask);
-}
+struct sbiret sbi_ecall(int ext, int fid, unsigned long arg0,
+                       unsigned long arg1, unsigned long arg2,
+                       unsigned long arg3, unsigned long arg4,
+                       unsigned long arg5);
 
-static inline void sbi_remote_sfence_vma(const unsigned long *hart_mask,
-                                        unsigned long start,
-                                        unsigned long size)
-{
-       SBI_CALL_1(SBI_REMOTE_SFENCE_VMA, hart_mask);
-}
+#ifdef CONFIG_SBI_V01
+void sbi_console_putchar(int ch);
+int sbi_console_getchar(void);
+void sbi_clear_ipi(void);
+void sbi_shutdown(void);
+#endif
+void sbi_set_timer(uint64_t stime_value);
+void sbi_send_ipi(const unsigned long *hart_mask);
+void sbi_remote_fence_i(const unsigned long *hart_mask);
+void sbi_remote_sfence_vma(const unsigned long *hart_mask,
+                          unsigned long start,
+                          unsigned long size);
+void sbi_remote_sfence_vma_asid(const unsigned long *hart_mask,
+                               unsigned long start,
+                               unsigned long size,
+                               unsigned long asid);
 
-static inline void sbi_remote_sfence_vma_asid(const unsigned long *hart_mask,
-                                             unsigned long start,
-                                             unsigned long size,
-                                             unsigned long asid)
-{
-       SBI_CALL_1(SBI_REMOTE_SFENCE_VMA_ASID, hart_mask);
-}
+int sbi_probe_extension(int ext);
 
 #endif
index c9179a5ff86d69854ca034ceae0ad25bb25eed3f..adadbf4bcbef1d5dd60994f546e2fd4eb0066af3 100644 (file)
@@ -16,6 +16,7 @@ obj-$(CONFIG_ANDES_PLIC) += andes_plic.o
 obj-$(CONFIG_ANDES_PLMT) += andes_plmt.o
 else
 obj-$(CONFIG_RISCV_RDTIME) += rdtime.o
+obj-$(CONFIG_SBI) += sbi.o
 obj-$(CONFIG_SBI_IPI) += sbi_ipi.o
 endif
 obj-y  += interrupts.o
diff --git a/arch/riscv/lib/sbi.c b/arch/riscv/lib/sbi.c
new file mode 100644 (file)
index 0000000..7bdf071
--- /dev/null
@@ -0,0 +1,187 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * SBI initialilization and all extension implementation.
+ *
+ * Copyright (c) 2020 Western Digital Corporation or its affiliates.
+ *
+ * Taken from Linux arch/riscv/kernel/sbi.c
+ */
+
+#include <common.h>
+#include <asm/encoding.h>
+#include <asm/sbi.h>
+
+/* default SBI version is 0.1 */
+unsigned long sbi_spec_version = SBI_SPEC_VERSION_DEFAULT;
+
+struct sbiret sbi_ecall(int ext, int fid, unsigned long arg0,
+                       unsigned long arg1, unsigned long arg2,
+                       unsigned long arg3, unsigned long arg4,
+                       unsigned long arg5)
+{
+       struct sbiret ret;
+
+       register uintptr_t a0 asm ("a0") = (uintptr_t)(arg0);
+       register uintptr_t a1 asm ("a1") = (uintptr_t)(arg1);
+       register uintptr_t a2 asm ("a2") = (uintptr_t)(arg2);
+       register uintptr_t a3 asm ("a3") = (uintptr_t)(arg3);
+       register uintptr_t a4 asm ("a4") = (uintptr_t)(arg4);
+       register uintptr_t a5 asm ("a5") = (uintptr_t)(arg5);
+       register uintptr_t a6 asm ("a6") = (uintptr_t)(fid);
+       register uintptr_t a7 asm ("a7") = (uintptr_t)(ext);
+       asm volatile ("ecall"
+                     : "+r" (a0), "+r" (a1)
+                     : "r" (a2), "r" (a3), "r" (a4), "r" (a5), "r" (a6), "r" (a7)
+                     : "memory");
+       ret.error = a0;
+       ret.value = a1;
+
+       return ret;
+}
+
+#ifdef CONFIG_SBI_V01
+
+/**
+ * sbi_console_putchar() - Writes given character to the console device.
+ * @ch: The data to be written to the console.
+ *
+ * Return: None
+ */
+void sbi_console_putchar(int ch)
+{
+       sbi_ecall(SBI_EXT_0_1_CONSOLE_PUTCHAR, 0, ch, 0, 0, 0, 0, 0);
+}
+
+/**
+ * sbi_console_getchar() - Reads a byte from console device.
+ *
+ * Returns the value read from console.
+ */
+int sbi_console_getchar(void)
+{
+       struct sbiret ret;
+
+       ret = sbi_ecall(SBI_EXT_0_1_CONSOLE_GETCHAR, 0, 0, 0, 0, 0, 0, 0);
+
+       return ret.error;
+}
+
+/**
+ * sbi_clear_ipi() - Clear any pending IPIs for the calling hart.
+ *
+ * Return: None
+ */
+void sbi_clear_ipi(void)
+{
+       sbi_ecall(SBI_EXT_0_1_CLEAR_IPI, 0, 0, 0, 0, 0, 0, 0);
+}
+
+/**
+ * sbi_shutdown() - Remove all the harts from executing supervisor code.
+ *
+ * Return: None
+ */
+void sbi_shutdown(void)
+{
+       sbi_ecall(SBI_EXT_0_1_SHUTDOWN, 0, 0, 0, 0, 0, 0, 0);
+}
+
+#endif /* CONFIG_SBI_V01 */
+
+/**
+ * sbi_set_timer() - Program the timer for next timer event.
+ * @stime_value: The value after which next timer event should fire.
+ *
+ * Return: None
+ */
+void sbi_set_timer(uint64_t stime_value)
+{
+#if __riscv_xlen == 32
+       sbi_ecall(SBI_EXT_SET_TIMER, SBI_FID_SET_TIMER, stime_value,
+                 stime_value >> 32, 0, 0, 0, 0);
+#else
+       sbi_ecall(SBI_EXT_SET_TIMER, SBI_FID_SET_TIMER, stime_value,
+                 0, 0, 0, 0, 0);
+#endif
+}
+
+/**
+ * sbi_send_ipi() - Send an IPI to any hart.
+ * @hart_mask: A cpu mask containing all the target harts.
+ *
+ * Return: None
+ */
+void sbi_send_ipi(const unsigned long *hart_mask)
+{
+       sbi_ecall(SBI_EXT_SEND_IPI, SBI_FID_SEND_IPI, (unsigned long)hart_mask,
+                 0, 0, 0, 0, 0);
+}
+
+/**
+ * sbi_remote_fence_i() - Execute FENCE.I instruction on given remote harts.
+ * @hart_mask: A cpu mask containing all the target harts.
+ *
+ * Return: None
+ */
+void sbi_remote_fence_i(const unsigned long *hart_mask)
+{
+       sbi_ecall(SBI_EXT_REMOTE_FENCE_I, SBI_FID_REMOTE_FENCE_I,
+                 (unsigned long)hart_mask, 0, 0, 0, 0, 0);
+}
+
+/**
+ * sbi_remote_sfence_vma() - Execute SFENCE.VMA instructions on given remote
+ *                          harts for the specified virtual address range.
+ * @hart_mask: A cpu mask containing all the target harts.
+ * @start: Start of the virtual address
+ * @size: Total size of the virtual address range.
+ *
+ * Return: None
+ */
+void sbi_remote_sfence_vma(const unsigned long *hart_mask,
+                          unsigned long start,
+                          unsigned long size)
+{
+       sbi_ecall(SBI_EXT_REMOTE_SFENCE_VMA, SBI_FID_REMOTE_SFENCE_VMA,
+                 (unsigned long)hart_mask, start, size, 0, 0, 0);
+}
+
+/**
+ * sbi_remote_sfence_vma_asid() - Execute SFENCE.VMA instructions on given
+ * remote harts for a virtual address range belonging to a specific ASID.
+ *
+ * @hart_mask: A cpu mask containing all the target harts.
+ * @start: Start of the virtual address
+ * @size: Total size of the virtual address range.
+ * @asid: The value of address space identifier (ASID).
+ *
+ * Return: None
+ */
+void sbi_remote_sfence_vma_asid(const unsigned long *hart_mask,
+                               unsigned long start,
+                               unsigned long size,
+                               unsigned long asid)
+{
+       sbi_ecall(SBI_EXT_REMOTE_SFENCE_VMA_ASID,
+                 SBI_FID_REMOTE_SFENCE_VMA_ASID,
+                 (unsigned long)hart_mask, start, size, asid, 0, 0);
+}
+
+/**
+ * sbi_probe_extension() - Check if an SBI extension ID is supported or not.
+ * @extid: The extension ID to be probed.
+ *
+ * Return: Extension specific nonzero value f yes, -ENOTSUPP otherwise.
+ */
+int sbi_probe_extension(int extid)
+{
+       struct sbiret ret;
+
+       ret = sbi_ecall(SBI_EXT_BASE, SBI_EXT_BASE_PROBE_EXT, extid,
+                       0, 0, 0, 0, 0);
+       if (!ret.error)
+               if (ret.value)
+                       return ret.value;
+
+       return -ENOTSUPP;
+}
index 9a698ce74e67127209c46cec82fbee9e2e907f19..abafca9e5c1366d18608272f328d1cc79560dd02 100644 (file)
@@ -5,6 +5,7 @@
  */
 
 #include <common.h>
+#include <asm/encoding.h>
 #include <asm/sbi.h>
 
 int riscv_send_ipi(int hart)
@@ -19,7 +20,7 @@ int riscv_send_ipi(int hart)
 
 int riscv_clear_ipi(int hart)
 {
-       sbi_clear_ipi();
+       csr_clear(CSR_SIP, SIP_SSIP);
 
        return 0;
 }
index 607667ac63a738e1e5b7c0d57a6b181aca547625..c5a1cc95e4a602b39cd1daaeade2949b3b2f7098 100644 (file)
@@ -5,8 +5,9 @@
  */
 
 #include <common.h>
+#include <syscon.h>
 #include <asm/io.h>
-#include <fdtdec.h>
+#include <asm/arch-rockchip/clock.h>
 #include <asm/arch-rockchip/grf_rv1108.h>
 #include <asm/arch-rockchip/hardware.h>
 #include <asm/gpio.h>
@@ -15,7 +16,6 @@ DECLARE_GLOBAL_DATA_PTR;
 
 int mach_cpu_init(void)
 {
-       int node;
        struct rv1108_grf *grf;
        enum {
                GPIO3C3_SHIFT           = 6,
@@ -35,8 +35,7 @@ int mach_cpu_init(void)
                GPIO2D1_UART2_SIN_M0,
        };
 
-       node = fdt_node_offset_by_compatible(gd->fdt_blob, -1, "rockchip,rv1108-grf");
-       grf = (struct rv1108_grf *)fdtdec_get_addr(gd->fdt_blob, node, "reg");
+       grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
 
        /* Elgin board use UART2 m0 for debug*/
        rk_clrsetreg(&grf->gpio2d_iomux,
@@ -50,7 +49,7 @@ int mach_cpu_init(void)
 
 #define MODEM_ENABLE_GPIO 111
 
-int board_early_init_f(void)
+int rk_board_late_init(void)
 {
        gpio_request(MODEM_ENABLE_GPIO, "modem_enable");
        gpio_direction_output(MODEM_ENABLE_GPIO, 0);
index 733f29376e387838fa6fd51cd5d4f3e4028e695c..5d622c3737ac71fee7949fba661ceeed98c8b14b 100644 (file)
@@ -5,8 +5,9 @@
  */
 
 #include <common.h>
+#include <syscon.h>
 #include <asm/io.h>
-#include <fdtdec.h>
+#include <asm/arch-rockchip/clock.h>
 #include <asm/arch-rockchip/grf_rv1108.h>
 #include <asm/arch-rockchip/hardware.h>
 
@@ -14,7 +15,6 @@ DECLARE_GLOBAL_DATA_PTR;
 
 int mach_cpu_init(void)
 {
-       int node;
        struct rv1108_grf *grf;
        enum {
                GPIO3C3_SHIFT           = 6,
@@ -34,8 +34,7 @@ int mach_cpu_init(void)
                GPIO2D1_UART2_SIN_M0,
        };
 
-       node = fdt_node_offset_by_compatible(gd->fdt_blob, -1, "rockchip,rv1108-grf");
-       grf = (struct rv1108_grf *)fdtdec_get_addr(gd->fdt_blob, node, "reg");
+       grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
 
        /*evb board use UART2 m0 for debug*/
        rk_clrsetreg(&grf->gpio2d_iomux,
index 24fc42ae898ed3d3ed2173ff7fccf04dbfe5ddc7..3bbe2d6a1a40ca344e4ca5c7ccc8f68ecda612fe 100644 (file)
@@ -149,6 +149,20 @@ done:
        return ret;
 }
 
+static void efi_reserve_memory(u64 addr, u64 size)
+{
+       u64 pages;
+
+       /* Convert from sandbox address space. */
+       addr = (uintptr_t)map_sysmem(addr, 0);
+       pages = efi_size_in_pages(size + (addr & EFI_PAGE_MASK));
+       addr &= ~EFI_PAGE_MASK;
+       if (efi_add_memory_map(addr, pages, EFI_RESERVED_MEMORY_TYPE,
+                              false) != EFI_SUCCESS)
+               printf("Reserved memory mapping failed addr %llx size %llx\n",
+                      addr, size);
+}
+
 /**
  * efi_carve_out_dt_rsv() - Carve out DT reserved memory ranges
  *
@@ -161,7 +175,8 @@ done:
 static void efi_carve_out_dt_rsv(void *fdt)
 {
        int nr_rsv, i;
-       uint64_t addr, size, pages;
+       u64 addr, size;
+       int nodeoffset, subnode;
 
        nr_rsv = fdt_num_mem_rsv(fdt);
 
@@ -169,15 +184,25 @@ static void efi_carve_out_dt_rsv(void *fdt)
        for (i = 0; i < nr_rsv; i++) {
                if (fdt_get_mem_rsv(fdt, i, &addr, &size) != 0)
                        continue;
+               efi_reserve_memory(addr, size);
+       }
 
-               /* Convert from sandbox address space. */
-               addr = (uintptr_t)map_sysmem(addr, 0);
-
-               pages = efi_size_in_pages(size + (addr & EFI_PAGE_MASK));
-               addr &= ~EFI_PAGE_MASK;
-               if (efi_add_memory_map(addr, pages, EFI_RESERVED_MEMORY_TYPE,
-                                      false) != EFI_SUCCESS)
-                       printf("FDT memrsv map %d: Failed to add to map\n", i);
+       /* process reserved-memory */
+       nodeoffset = fdt_subnode_offset(fdt, 0, "reserved-memory");
+       if (nodeoffset >= 0) {
+               subnode = fdt_first_subnode(fdt, nodeoffset);
+               while (subnode >= 0) {
+                       /* check if this subnode has a reg property */
+                       addr = fdtdec_get_addr_size(fdt, subnode, "reg",
+                                                   (fdt_size_t *)&size);
+                       /*
+                        * The /reserved-memory node may have children with
+                        * a size instead of a reg property.
+                        */
+                       if (addr != FDT_ADDR_T_NONE)
+                               efi_reserve_memory(addr, size);
+                       subnode = fdt_next_subnode(fdt, subnode);
+               }
        }
 }
 
@@ -263,9 +288,6 @@ efi_status_t efi_install_fdt(void *fdt)
                return EFI_LOAD_ERROR;
        }
 
-       /* Create memory reservations as indicated by the device tree */
-       efi_carve_out_dt_rsv(fdt);
-
        /* Prepare device tree for payload */
        ret = copy_fdt(&fdt);
        if (ret) {
@@ -278,6 +300,9 @@ efi_status_t efi_install_fdt(void *fdt)
                return EFI_LOAD_ERROR;
        }
 
+       /* Create memory reservations as indicated by the device tree */
+       efi_carve_out_dt_rsv(fdt);
+
        /* Install device tree as UEFI table */
        ret = efi_install_configuration_table(&efi_guid_fdt, fdt);
        if (ret != EFI_SUCCESS) {
index 21dfd44fcc94f9b2a67af660aadb9e1890b21bb6..bb7c13d6a1ce7e636548aff1b64268a986b72b9d 100644 (file)
@@ -12,6 +12,7 @@
 #include <exports.h>
 #include <hexdump.h>
 #include <malloc.h>
+#include <mapmem.h>
 #include <search.h>
 #include <linux/ctype.h>
 
@@ -488,9 +489,10 @@ static int do_efi_show_memmap(cmd_tbl_t *cmdtp, int flag,
 
                printf("%-16s %.*llx-%.*llx", type,
                       EFI_PHYS_ADDR_WIDTH,
-                      map->physical_start,
+                      (u64)map_to_sysmem((void *)map->physical_start),
                       EFI_PHYS_ADDR_WIDTH,
-                      map->physical_start + map->num_pages * EFI_PAGE_SIZE);
+                      (u64)map_to_sysmem((void *)map->physical_start +
+                                         map->num_pages * EFI_PAGE_SIZE));
 
                print_memory_attributes(map->attribute);
                putc('\n');
@@ -649,7 +651,7 @@ static int do_efi_boot_rm(cmd_tbl_t *cmdtp, int flag,
        int id, i;
        char *endp;
        char var_name[9];
-       u16 var_name16[9];
+       u16 var_name16[9], *p;
        efi_status_t ret;
 
        if (argc == 1)
@@ -662,11 +664,12 @@ static int do_efi_boot_rm(cmd_tbl_t *cmdtp, int flag,
                        return CMD_RET_FAILURE;
 
                sprintf(var_name, "Boot%04X", id);
-               utf8_utf16_strncpy((u16 **)&var_name16, var_name, 9);
+               p = var_name16;
+               utf8_utf16_strncpy(&p, var_name, 9);
 
                ret = EFI_CALL(RT->set_variable(var_name16, &guid, 0, 0, NULL));
                if (ret) {
-                       printf("Cannot remove Boot%04X", id);
+                       printf("Cannot remove %ls\n", var_name16);
                        return CMD_RET_FAILURE;
                }
        }
index 16c2cebb3d4bf6a125e452de7b852f718d681acf..408a942455b58627a81107f3145fe08e33fbeb9f 100644 (file)
@@ -248,7 +248,12 @@ static int do_gpio(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
        if (ret != -EBUSY)
                gpio_free(gpio);
 
-       return CMD_RET_SUCCESS;
+       /*
+        * Whilst wrong, the legacy gpio input command returns the pin
+        * value, or CMD_RET_FAILURE (which is indistinguishable from a
+        * valid pin value).
+        */
+       return (sub_cmd == GPIOC_INPUT) ? value : CMD_RET_SUCCESS;
 
 err:
        if (ret != -EBUSY)
index 9357e66e1f9e648ac3f8c03d0ab2ef040ad3318e..6fc2799b14ea61a2814cef20606bb33012fed429 100644 (file)
@@ -1011,8 +1011,10 @@ int fit_image_get_data_and_size(const void *fit, int noffset,
        if (external_data) {
                debug("External Data\n");
                ret = fit_image_get_data_size(fit, noffset, &len);
-               *data = fit + offset;
-               *size = len;
+               if (!ret) {
+                       *data = fit + offset;
+                       *size = len;
+               }
        } else {
                ret = fit_image_get_data(fit, noffset, data, size);
        }
index 62af7634a302a0e6f66d85ae98a514d609cc2532..b6682994f50c4d00577d6637ba86a66e89914d61 100644 (file)
@@ -4,12 +4,14 @@ CONFIG_SYS_TEXT_BASE=0x60000000
 CONFIG_ENV_OFFSET=0x3F8000
 CONFIG_ROCKCHIP_RV1108=y
 CONFIG_TARGET_ELGIN_RV1108=y
+CONFIG_ROCKCHIP_BOOT_MODE_REG=0
 CONFIG_NR_DRAM_BANKS=1
 CONFIG_DEBUG_UART_BASE=0x10210000
 CONFIG_DEBUG_UART_CLOCK=24000000
 CONFIG_DEBUG_UART=y
 # CONFIG_USE_BOOTCOMMAND is not set
 CONFIG_DEFAULT_FDT_FILE="rv1108-elgin-r1.dtb"
+CONFIG_BOARD_LATE_INIT=y
 # CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_CMD_GPIO=y
index edba9da31b2c27b3f65fb025201b3d73bc0da3ca..e3e205fd54ac6f70e921785d9dd5df83d306c38b 100644 (file)
@@ -75,6 +75,7 @@ CONFIG_USB_GADGET_DWC2_OTG=y
 CONFIG_USB_HOST_ETHER=y
 CONFIG_USB_ETHER_ASIX=y
 CONFIG_USB_ETHER_SMSC95XX=y
+CONFIG_USB_KEYBOARD=y
 CONFIG_DM_VIDEO=y
 # CONFIG_VIDEO_BPP8 is not set
 CONFIG_DISPLAY=y
index 659c67a0336889635a73cd5de16aab63902e76d0..d540a17aebe7794bd67d8e791ae08968e5c6628e 100644 (file)
@@ -56,5 +56,6 @@ CONFIG_USB_ETHER_ASIX88179=y
 CONFIG_USB_ETHER_MCS7830=y
 CONFIG_USB_ETHER_RTL8152=y
 CONFIG_USB_ETHER_SMSC95XX=y
+CONFIG_USB_KEYBOARD=y
 CONFIG_SPL_TINY_MEMSET=y
 CONFIG_ERRNO_STR=y
index bb12b32a215b6da3f7fb6d1b623aced744b1a051..cf71c8592794f3fa8906d484ad5e98008f70642a 100644 (file)
@@ -74,6 +74,7 @@ CONFIG_USB_DWC2=y
 CONFIG_ROCKCHIP_USB2_PHY=y
 CONFIG_USB_GADGET=y
 CONFIG_USB_GADGET_DWC2_OTG=y
+CONFIG_USB_KEYBOARD=y
 CONFIG_DM_VIDEO=y
 # CONFIG_VIDEO_BPP8 is not set
 CONFIG_DISPLAY=y
index fe84cb3b3684b4983839bedd6a49d5452ba3e9e8..8ca17d621bbfba8f5dae29e9d07aa4a7d1ee3636 100644 (file)
@@ -169,7 +169,6 @@ CONFIG_REMOTEPROC_SANDBOX=y
 CONFIG_DM_RESET=y
 CONFIG_SANDBOX_RESET=y
 CONFIG_DM_RNG=y
-CONFIG_RNG_SANDBOX=y
 CONFIG_DM_RTC=y
 CONFIG_RTC_RV8803=y
 CONFIG_SANDBOX_SERIAL=y
index d9a201d386bf81dedda631145261b9be8088244d..cc90f0006e248197e9945befd78756f435be795e 100644 (file)
@@ -189,7 +189,6 @@ CONFIG_REMOTEPROC_SANDBOX=y
 CONFIG_DM_RESET=y
 CONFIG_SANDBOX_RESET=y
 CONFIG_DM_RNG=y
-CONFIG_RNG_SANDBOX=y
 CONFIG_DM_RTC=y
 CONFIG_RTC_RV8803=y
 CONFIG_DEBUG_UART_SANDBOX=y
index 50820ba08ea63ab689821da376909e966ec8ffff..034d28ea2d8df662dcb139a3dff55884ef3a1693 100644 (file)
@@ -80,6 +80,7 @@ CONFIG_USB_GADGET_DWC2_OTG=y
 CONFIG_USB_HOST_ETHER=y
 CONFIG_USB_ETHER_ASIX=y
 CONFIG_USB_ETHER_SMSC95XX=y
+CONFIG_USB_KEYBOARD=y
 CONFIG_DM_VIDEO=y
 CONFIG_DISPLAY=y
 CONFIG_VIDEO_ROCKCHIP=y
index ab192cf4e4c75cc48cac3ce3874d333ad959edac..06c5d9b507044a75b3d9ea59ec300ed3df0b7685 100644 (file)
@@ -80,6 +80,7 @@ CONFIG_USB_GADGET_DWC2_OTG=y
 CONFIG_USB_HOST_ETHER=y
 CONFIG_USB_ETHER_ASIX=y
 CONFIG_USB_ETHER_SMSC95XX=y
+CONFIG_USB_KEYBOARD=y
 CONFIG_DM_VIDEO=y
 # CONFIG_VIDEO_BPP8 is not set
 CONFIG_DISPLAY=y
index 893b89d49b1dc8f6e47dd80b1ee10e9bf39b061f..edb6152bb9d43ee8ef95d379a76d0a9b1af595de 100644 (file)
@@ -6,16 +6,29 @@ config DM_RNG
          This interface is used to initialise the rng device and to
          read the random seed from the device.
 
+if DM_RNG
+
+config RNG_MESON
+       bool "Amlogic Meson Random Number Generator support"
+       depends on ARCH_MESON
+       default y
+       help
+         Enable support for hardware random number generator
+         of Amlogic Meson SoCs.
+
 config RNG_SANDBOX
        bool "Sandbox random number generator"
-       depends on SANDBOX && DM_RNG
+       depends on SANDBOX
+       default y
        help
          Enable random number generator for sandbox. This is an
          emulation of a rng device.
 
 config RNG_STM32MP1
        bool "Enable random number generator for STM32MP1"
-       depends on ARCH_STM32MP && DM_RNG
+       depends on ARCH_STM32MP
        default n
        help
          Enable STM32MP1 rng driver.
+
+endif
index 35170055415846a59239d46cce93d790a2ad70e7..6a8a66779b5b30e4a077612d10e7eb6578d30a0a 100644 (file)
@@ -4,5 +4,6 @@
 #
 
 obj-$(CONFIG_DM_RNG) += rng-uclass.o
+obj-$(CONFIG_RNG_MESON) += meson-rng.o
 obj-$(CONFIG_RNG_SANDBOX) += sandbox_rng.o
 obj-$(CONFIG_RNG_STM32MP1) += stm32mp1_rng.o
diff --git a/drivers/rng/meson-rng.c b/drivers/rng/meson-rng.c
new file mode 100644 (file)
index 0000000..4b81a62
--- /dev/null
@@ -0,0 +1,120 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright 2020, Heinrich Schuchardt <xypron.glpk@gmx.de>
+ *
+ * Driver for Amlogic hardware random number generator
+ */
+
+#include <common.h>
+#include <clk.h>
+#include <dm.h>
+#include <rng.h>
+#include <asm/io.h>
+
+struct meson_rng_platdata {
+       fdt_addr_t base;
+       struct clk clk;
+};
+
+/**
+ * meson_rng_read() - fill buffer with random bytes
+ *
+ * @buffer:    buffer to receive data
+ * @size:      size of buffer
+ *
+ * Return:     0
+ */
+static int meson_rng_read(struct udevice *dev, void *data, size_t len)
+{
+       struct meson_rng_platdata *pdata = dev_get_platdata(dev);
+       char *buffer = (char *)data;
+
+       while (len) {
+               u32 rand = readl(pdata->base);
+               size_t step;
+
+               if (len >= 4)
+                       step = 4;
+               else
+                       step = len;
+               memcpy(buffer, &rand, step);
+               buffer += step;
+               len -= step;
+       }
+       return 0;
+}
+
+/**
+ * meson_rng_probe() - probe rng device
+ *
+ * @dev:       device
+ * Return:     0 if ok
+ */
+static int meson_rng_probe(struct udevice *dev)
+{
+       struct meson_rng_platdata *pdata = dev_get_platdata(dev);
+       int err;
+
+       err = clk_enable(&pdata->clk);
+       if (err)
+               return err;
+
+       return 0;
+}
+
+/**
+ * meson_rng_remove() - deinitialize rng device
+ *
+ * @dev:       device
+ * Return:     0 if ok
+ */
+static int meson_rng_remove(struct udevice *dev)
+{
+       struct meson_rng_platdata *pdata = dev_get_platdata(dev);
+
+       return clk_disable(&pdata->clk);
+}
+
+/**
+ * meson_rng_ofdata_to_platdata() - transfer device tree data to plaform data
+ *
+ * @dev:       device
+ * Return:     0 if ok
+ */
+static int meson_rng_ofdata_to_platdata(struct udevice *dev)
+{
+       struct meson_rng_platdata *pdata = dev_get_platdata(dev);
+       int err;
+
+       pdata->base = dev_read_addr(dev);
+       if (!pdata->base)
+               return -ENODEV;
+
+       err = clk_get_by_name(dev, "core", &pdata->clk);
+       if (err)
+               return err;
+
+       return 0;
+}
+
+static const struct dm_rng_ops meson_rng_ops = {
+       .read = meson_rng_read,
+};
+
+static const struct udevice_id meson_rng_match[] = {
+       {
+               .compatible = "amlogic,meson-rng",
+       },
+       {},
+};
+
+U_BOOT_DRIVER(meson_rng) = {
+       .name = "meson-rng",
+       .id = UCLASS_RNG,
+       .of_match = meson_rng_match,
+       .ops = &meson_rng_ops,
+       .probe = meson_rng_probe,
+       .remove = meson_rng_remove,
+       .platdata_auto_alloc_size = sizeof(struct meson_rng_platdata),
+       .ofdata_to_platdata = meson_rng_ofdata_to_platdata,
+};
index e26b64494e5d73db027f10d4ca334d603346ab1c..e4a92bbbb7173a2f5b75df8dbed306d7dc27a41e 100644 (file)
@@ -39,7 +39,7 @@ obj-$(CONFIG_COREBOOT_SERIAL) += serial_coreboot.o
 obj-$(CONFIG_CORTINA_UART) += serial_cortina.o
 obj-$(CONFIG_EFI_APP) += serial_efi.o
 obj-$(CONFIG_LPC32XX_HSUART) += lpc32xx_hsuart.o
-obj-$(CONFIG_MCFUART) += mcfuart.o
+obj-$(CONFIG_MCFUART) += serial_mcf.o
 obj-$(CONFIG_SYS_NS16550) += ns16550.o
 obj-$(CONFIG_S5P) += serial_s5p.o
 obj-$(CONFIG_MXC_UART) += serial_mxc.o
diff --git a/drivers/serial/mcfuart.c b/drivers/serial/mcfuart.c
deleted file mode 100644 (file)
index 066e5a1..0000000
+++ /dev/null
@@ -1,179 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * (C) Copyright 2004-2007 Freescale Semiconductor, Inc.
- * TsiChung Liew, Tsi-Chung.Liew@freescale.com.
- *
- * Modified to add device model (DM) support
- * (C) Copyright 2015  Angelo Dureghello <angelo@sysam.it>
- *
- * Modified to add DM and fdt support, removed non DM code
- * (C) Copyright 2018  Angelo Dureghello <angelo@sysam.it>
- */
-
-/*
- * Minimal serial functions needed to use one of the uart ports
- * as serial console interface.
- */
-
-#include <common.h>
-#include <dm.h>
-#include <dm/platform_data/serial_coldfire.h>
-#include <serial.h>
-#include <linux/compiler.h>
-#include <asm/immap.h>
-#include <asm/uart.h>
-
-DECLARE_GLOBAL_DATA_PTR;
-
-extern void uart_port_conf(int port);
-
-static int mcf_serial_init_common(uart_t *uart, int port_idx, int baudrate)
-{
-       u32 counter;
-
-       uart_port_conf(port_idx);
-
-       /* write to SICR: SIM2 = uart mode,dcd does not affect rx */
-       writeb(UART_UCR_RESET_RX, &uart->ucr);
-       writeb(UART_UCR_RESET_TX, &uart->ucr);
-       writeb(UART_UCR_RESET_ERROR, &uart->ucr);
-       writeb(UART_UCR_RESET_MR, &uart->ucr);
-       __asm__("nop");
-
-       writeb(0, &uart->uimr);
-
-       /* write to CSR: RX/TX baud rate from timers */
-       writeb(UART_UCSR_RCS_SYS_CLK | UART_UCSR_TCS_SYS_CLK, &uart->ucsr);
-
-       writeb(UART_UMR_BC_8 | UART_UMR_PM_NONE, &uart->umr);
-       writeb(UART_UMR_SB_STOP_BITS_1, &uart->umr);
-
-       /* Setting up BaudRate */
-       counter = (u32) ((gd->bus_clk / 32) + (baudrate / 2));
-       counter = counter / baudrate;
-
-       /* write to CTUR: divide counter upper byte */
-       writeb((u8)((counter & 0xff00) >> 8), &uart->ubg1);
-       /* write to CTLR: divide counter lower byte */
-       writeb((u8)(counter & 0x00ff), &uart->ubg2);
-
-       writeb(UART_UCR_RX_ENABLED | UART_UCR_TX_ENABLED, &uart->ucr);
-
-       return (0);
-}
-
-static void mcf_serial_setbrg_common(uart_t *uart, int baudrate)
-{
-       u32 counter;
-
-       /* Setting up BaudRate */
-       counter = (u32) ((gd->bus_clk / 32) + (baudrate / 2));
-       counter = counter / baudrate;
-
-       /* write to CTUR: divide counter upper byte */
-       writeb(((counter & 0xff00) >> 8), &uart->ubg1);
-       /* write to CTLR: divide counter lower byte */
-       writeb((counter & 0x00ff), &uart->ubg2);
-
-       writeb(UART_UCR_RESET_RX, &uart->ucr);
-       writeb(UART_UCR_RESET_TX, &uart->ucr);
-
-       writeb(UART_UCR_RX_ENABLED | UART_UCR_TX_ENABLED, &uart->ucr);
-}
-
-static int coldfire_serial_probe(struct udevice *dev)
-{
-       struct coldfire_serial_platdata *plat = dev->platdata;
-
-       return mcf_serial_init_common((uart_t *)plat->base,
-                                               plat->port, plat->baudrate);
-}
-
-static int coldfire_serial_putc(struct udevice *dev, const char ch)
-{
-       struct coldfire_serial_platdata *plat = dev->platdata;
-       uart_t *uart = (uart_t *)plat->base;
-
-       /* Wait for last character to go. */
-       if (!(readb(&uart->usr) & UART_USR_TXRDY))
-               return -EAGAIN;
-
-       writeb(ch, &uart->utb);
-
-       return 0;
-}
-
-static int coldfire_serial_getc(struct udevice *dev)
-{
-       struct coldfire_serial_platdata *plat = dev->platdata;
-       uart_t *uart = (uart_t *)(plat->base);
-
-       /* Wait for a character to arrive. */
-       if (!(readb(&uart->usr) & UART_USR_RXRDY))
-               return -EAGAIN;
-
-       return readb(&uart->urb);
-}
-
-int coldfire_serial_setbrg(struct udevice *dev, int baudrate)
-{
-       struct coldfire_serial_platdata *plat = dev->platdata;
-       uart_t *uart = (uart_t *)(plat->base);
-
-       mcf_serial_setbrg_common(uart, baudrate);
-
-       return 0;
-}
-
-static int coldfire_serial_pending(struct udevice *dev, bool input)
-{
-       struct coldfire_serial_platdata *plat = dev->platdata;
-       uart_t *uart = (uart_t *)(plat->base);
-
-       if (input)
-               return readb(&uart->usr) & UART_USR_RXRDY ? 1 : 0;
-       else
-               return readb(&uart->usr) & UART_USR_TXRDY ? 0 : 1;
-
-       return 0;
-}
-
-static int coldfire_ofdata_to_platdata(struct udevice *dev)
-{
-       struct coldfire_serial_platdata *plat = dev_get_platdata(dev);
-       fdt_addr_t addr_base;
-
-       addr_base = devfdt_get_addr(dev);
-       if (addr_base == FDT_ADDR_T_NONE)
-               return -ENODEV;
-
-       plat->base = (uint32_t)addr_base;
-
-       plat->port = dev->seq;
-       plat->baudrate = gd->baudrate;
-
-       return 0;
-}
-
-static const struct dm_serial_ops coldfire_serial_ops = {
-       .putc = coldfire_serial_putc,
-       .pending = coldfire_serial_pending,
-       .getc = coldfire_serial_getc,
-       .setbrg = coldfire_serial_setbrg,
-};
-
-static const struct udevice_id coldfire_serial_ids[] = {
-       { .compatible = "fsl,mcf-uart" },
-       { }
-};
-
-U_BOOT_DRIVER(serial_coldfire) = {
-       .name = "serial_coldfire",
-       .id = UCLASS_SERIAL,
-       .of_match = coldfire_serial_ids,
-       .ofdata_to_platdata = coldfire_ofdata_to_platdata,
-       .platdata_auto_alloc_size = sizeof(struct coldfire_serial_platdata),
-       .probe = coldfire_serial_probe,
-       .ops = &coldfire_serial_ops,
-       .flags = DM_FLAG_PRE_RELOC,
-};
diff --git a/drivers/serial/serial_mcf.c b/drivers/serial/serial_mcf.c
new file mode 100644 (file)
index 0000000..b599064
--- /dev/null
@@ -0,0 +1,179 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2004-2007 Freescale Semiconductor, Inc.
+ * TsiChung Liew, Tsi-Chung.Liew@freescale.com.
+ *
+ * Modified to add device model (DM) support
+ * (C) Copyright 2015  Angelo Dureghello <angelo@sysam.it>
+ *
+ * Modified to add DM and fdt support, removed non DM code
+ * (C) Copyright 2018  Angelo Dureghello <angelo@sysam.it>
+ */
+
+/*
+ * Minimal serial functions needed to use one of the uart ports
+ * as serial console interface.
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <dm/platform_data/serial_coldfire.h>
+#include <serial.h>
+#include <linux/compiler.h>
+#include <asm/immap.h>
+#include <asm/uart.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+extern void uart_port_conf(int port);
+
+static int mcf_serial_init_common(uart_t *uart, int port_idx, int baudrate)
+{
+       u32 counter;
+
+       uart_port_conf(port_idx);
+
+       /* write to SICR: SIM2 = uart mode,dcd does not affect rx */
+       writeb(UART_UCR_RESET_RX, &uart->ucr);
+       writeb(UART_UCR_RESET_TX, &uart->ucr);
+       writeb(UART_UCR_RESET_ERROR, &uart->ucr);
+       writeb(UART_UCR_RESET_MR, &uart->ucr);
+       __asm__("nop");
+
+       writeb(0, &uart->uimr);
+
+       /* write to CSR: RX/TX baud rate from timers */
+       writeb(UART_UCSR_RCS_SYS_CLK | UART_UCSR_TCS_SYS_CLK, &uart->ucsr);
+
+       writeb(UART_UMR_BC_8 | UART_UMR_PM_NONE, &uart->umr);
+       writeb(UART_UMR_SB_STOP_BITS_1, &uart->umr);
+
+       /* Setting up BaudRate */
+       counter = (u32) ((gd->bus_clk / 32) + (baudrate / 2));
+       counter = counter / baudrate;
+
+       /* write to CTUR: divide counter upper byte */
+       writeb((u8)((counter & 0xff00) >> 8), &uart->ubg1);
+       /* write to CTLR: divide counter lower byte */
+       writeb((u8)(counter & 0x00ff), &uart->ubg2);
+
+       writeb(UART_UCR_RX_ENABLED | UART_UCR_TX_ENABLED, &uart->ucr);
+
+       return (0);
+}
+
+static void mcf_serial_setbrg_common(uart_t *uart, int baudrate)
+{
+       u32 counter;
+
+       /* Setting up BaudRate */
+       counter = (u32) ((gd->bus_clk / 32) + (baudrate / 2));
+       counter = counter / baudrate;
+
+       /* write to CTUR: divide counter upper byte */
+       writeb(((counter & 0xff00) >> 8), &uart->ubg1);
+       /* write to CTLR: divide counter lower byte */
+       writeb((counter & 0x00ff), &uart->ubg2);
+
+       writeb(UART_UCR_RESET_RX, &uart->ucr);
+       writeb(UART_UCR_RESET_TX, &uart->ucr);
+
+       writeb(UART_UCR_RX_ENABLED | UART_UCR_TX_ENABLED, &uart->ucr);
+}
+
+static int coldfire_serial_probe(struct udevice *dev)
+{
+       struct coldfire_serial_platdata *plat = dev->platdata;
+
+       plat->port = dev->seq;
+
+       return mcf_serial_init_common((uart_t *)plat->base,
+                                               plat->port, plat->baudrate);
+}
+
+static int coldfire_serial_putc(struct udevice *dev, const char ch)
+{
+       struct coldfire_serial_platdata *plat = dev->platdata;
+       uart_t *uart = (uart_t *)plat->base;
+
+       /* Wait for last character to go. */
+       if (!(readb(&uart->usr) & UART_USR_TXRDY))
+               return -EAGAIN;
+
+       writeb(ch, &uart->utb);
+
+       return 0;
+}
+
+static int coldfire_serial_getc(struct udevice *dev)
+{
+       struct coldfire_serial_platdata *plat = dev->platdata;
+       uart_t *uart = (uart_t *)(plat->base);
+
+       /* Wait for a character to arrive. */
+       if (!(readb(&uart->usr) & UART_USR_RXRDY))
+               return -EAGAIN;
+
+       return readb(&uart->urb);
+}
+
+int coldfire_serial_setbrg(struct udevice *dev, int baudrate)
+{
+       struct coldfire_serial_platdata *plat = dev->platdata;
+       uart_t *uart = (uart_t *)(plat->base);
+
+       mcf_serial_setbrg_common(uart, baudrate);
+
+       return 0;
+}
+
+static int coldfire_serial_pending(struct udevice *dev, bool input)
+{
+       struct coldfire_serial_platdata *plat = dev->platdata;
+       uart_t *uart = (uart_t *)(plat->base);
+
+       if (input)
+               return readb(&uart->usr) & UART_USR_RXRDY ? 1 : 0;
+       else
+               return readb(&uart->usr) & UART_USR_TXRDY ? 0 : 1;
+
+       return 0;
+}
+
+static int coldfire_ofdata_to_platdata(struct udevice *dev)
+{
+       struct coldfire_serial_platdata *plat = dev_get_platdata(dev);
+       fdt_addr_t addr_base;
+
+       addr_base = devfdt_get_addr(dev);
+       if (addr_base == FDT_ADDR_T_NONE)
+               return -ENODEV;
+
+       plat->base = (uint32_t)addr_base;
+       plat->baudrate = gd->baudrate;
+
+       return 0;
+}
+
+static const struct dm_serial_ops coldfire_serial_ops = {
+       .putc = coldfire_serial_putc,
+       .pending = coldfire_serial_pending,
+       .getc = coldfire_serial_getc,
+       .setbrg = coldfire_serial_setbrg,
+};
+
+static const struct udevice_id coldfire_serial_ids[] = {
+       { .compatible = "fsl,mcf-uart" },
+       { }
+};
+
+U_BOOT_DRIVER(serial_coldfire) = {
+       .name = "serial_coldfire",
+       .id = UCLASS_SERIAL,
+       .of_match = coldfire_serial_ids,
+       .ofdata_to_platdata = coldfire_ofdata_to_platdata,
+       .platdata_auto_alloc_size = sizeof(struct coldfire_serial_platdata),
+       .probe = coldfire_serial_probe,
+       .ops = &coldfire_serial_ops,
+       .flags = DM_FLAG_PRE_RELOC,
+};
index f947e6983c05d956e97d8d4405ca40be979005cc..ce846488a89c8725ea3eb10b15b16e9f9fee39d2 100644 (file)
@@ -108,7 +108,7 @@ static int cdns3_core_init_role(struct cdns3 *cdns)
        enum usb_dr_mode dr_mode;
        int ret = 0;
 
-       dr_mode = usb_get_dr_mode(dev_of_offset(dev));
+       dr_mode = usb_get_dr_mode(dev->node);
        cdns->role = USB_ROLE_NONE;
 
        /*
@@ -384,22 +384,20 @@ static const struct udevice_id cdns3_ids[] = {
 
 int cdns3_bind(struct udevice *parent)
 {
-       int from = dev_of_offset(parent);
-       const void *fdt = gd->fdt_blob;
        enum usb_dr_mode dr_mode;
        struct udevice *dev;
        const char *driver;
        const char *name;
-       int node;
+       ofnode node;
        int ret;
 
-       node = fdt_node_offset_by_compatible(fdt, from, "cdns,usb3");
-       if (node < 0) {
+       node = ofnode_by_compatible(parent->node, "cdns,usb3");
+       if (!ofnode_valid(node)) {
                ret = -ENODEV;
                goto fail;
        }
 
-       name = fdt_get_name(fdt, node, NULL);
+       name = ofnode_get_name(node);
        dr_mode = usb_get_dr_mode(node);
 
        switch (dr_mode) {
@@ -422,8 +420,7 @@ int cdns3_bind(struct udevice *parent)
                goto fail;
        };
 
-       ret = device_bind_driver_to_node(parent, driver, name,
-                                        offset_to_ofnode(node), &dev);
+       ret = device_bind_driver_to_node(parent, driver, name, node, &dev);
        if (ret) {
                printf("%s: not able to bind usb device mode\n",
                       __func__);
index 8377eb458b6a8eeabff02d0e80eb34e018a4c880..caed27c32f9216aeba9f27f895a898cfd4a1b595 100644 (file)
@@ -2579,7 +2579,7 @@ static int cdns3_gadget_start(struct cdns3 *cdns)
        if (!priv_dev->onchip_buffers)
                priv_dev->onchip_buffers = 256;
 
-       max_speed = usb_get_maximum_speed(dev_of_offset(cdns->dev));
+       max_speed = usb_get_maximum_speed(dev_ofnode(cdns->dev));
 
        /* Check the maximum_speed parameter */
        switch (max_speed) {
index a55def5aba67466d83d829af88e8c657a886d752..0db281b970ef6913694c778868a5428d59c08156 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 #include <common.h>
-#include <linux/libfdt.h>
+#include <dm.h>
 #include <linux/usb/otg.h>
 #include <linux/usb/ch9.h>
 
@@ -20,13 +20,12 @@ static const char *const usb_dr_modes[] = {
        [USB_DR_MODE_OTG]               = "otg",
 };
 
-enum usb_dr_mode usb_get_dr_mode(int node)
+enum usb_dr_mode usb_get_dr_mode(ofnode node)
 {
-       const void *fdt = gd->fdt_blob;
        const char *dr_mode;
        int i;
 
-       dr_mode = fdt_getprop(fdt, node, "dr_mode", NULL);
+       dr_mode = ofnode_read_string(node, "dr_mode");
        if (!dr_mode) {
                pr_err("usb dr_mode not found\n");
                return USB_DR_MODE_UNKNOWN;
@@ -48,13 +47,12 @@ static const char *const speed_names[] = {
        [USB_SPEED_SUPER] = "super-speed",
 };
 
-enum usb_device_speed usb_get_maximum_speed(int node)
+enum usb_device_speed usb_get_maximum_speed(ofnode node)
 {
-       const void *fdt = gd->fdt_blob;
        const char *max_speed;
        int i;
 
-       max_speed = fdt_getprop(fdt, node, "maximum-speed", NULL);
+       max_speed = ofnode_read_string(node, "maximum-speed");
        if (!max_speed) {
                pr_err("usb maximum-speed not found\n");
                return USB_SPEED_UNKNOWN;
index 3e116b2c5cc412c0b0e60612c65baf0823746af4..febcfc0f54c48e80ba932c351de1565ab3d7b60f 100644 (file)
@@ -88,9 +88,9 @@ static int dwc3_generic_remove(struct udevice *dev,
 static int dwc3_generic_ofdata_to_platdata(struct udevice *dev)
 {
        struct dwc3_generic_plat *plat = dev_get_platdata(dev);
-       int node = dev_of_offset(dev);
+       ofnode node = dev->node;
 
-       plat->base = devfdt_get_addr(dev);
+       plat->base = dev_read_addr(dev);
 
        plat->maximum_speed = usb_get_maximum_speed(node);
        if (plat->maximum_speed == USB_SPEED_UNKNOWN) {
@@ -284,13 +284,11 @@ struct dwc3_glue_ops ti_ops = {
 
 static int dwc3_glue_bind(struct udevice *parent)
 {
-       const void *fdt = gd->fdt_blob;
-       int node;
+       ofnode node;
        int ret;
 
-       for (node = fdt_first_subnode(fdt, dev_of_offset(parent)); node > 0;
-            node = fdt_next_subnode(fdt, node)) {
-               const char *name = fdt_get_name(fdt, node, NULL);
+       ofnode_for_each_subnode(node, parent->node) {
+               const char *name = ofnode_get_name(node);
                enum usb_dr_mode dr_mode;
                struct udevice *dev;
                const char *driver = NULL;
@@ -322,7 +320,7 @@ static int dwc3_glue_bind(struct udevice *parent)
                        continue;
 
                ret = device_bind_driver_to_node(parent, driver, name,
-                                                offset_to_ofnode(node), &dev);
+                                                node, &dev);
                if (ret) {
                        debug("%s: not able to bind usb device mode\n",
                              __func__);
@@ -400,7 +398,7 @@ static int dwc3_glue_probe(struct udevice *dev)
        while (child) {
                enum usb_dr_mode dr_mode;
 
-               dr_mode = usb_get_dr_mode(dev_of_offset(child));
+               dr_mode = usb_get_dr_mode(child->node);
                device_find_next_child(&child);
                if (ops && ops->select_dr_mode)
                        ops->select_dr_mode(dev, index, dr_mode);
index 832bcd70ff0f24847865e7a4833d93814da6695e..d4453f8784cbfdaa38196d57b6dc0bce7674c4ef 100644 (file)
@@ -393,7 +393,7 @@ static int dwc3_meson_g12a_probe(struct udevice *dev)
        }
 #endif
 
-       priv->otg_mode = usb_get_dr_mode(dev_of_offset(dev));
+       priv->otg_mode = usb_get_dr_mode(dev->node);
 
        ret = dwc3_meson_g12a_usb_init(priv);
        if (ret)
index 496abf38e7217d285d70a2d6e180220a7ddbb0f2..b9c814cf73e22832194c8f75b305a54179d62511 100644 (file)
@@ -1039,13 +1039,12 @@ void dwc2_phy_shutdown(struct udevice *dev, struct phy *usb_phys, int num_phys)
 static int dwc2_udc_otg_ofdata_to_platdata(struct udevice *dev)
 {
        struct dwc2_plat_otg_data *platdata = dev_get_platdata(dev);
-       int node = dev_of_offset(dev);
        ulong drvdata;
        void (*set_params)(struct dwc2_plat_otg_data *data);
        int ret;
 
-       if (usb_get_dr_mode(node) != USB_DR_MODE_PERIPHERAL &&
-           usb_get_dr_mode(node) != USB_DR_MODE_OTG) {
+       if (usb_get_dr_mode(dev->node) != USB_DR_MODE_PERIPHERAL &&
+           usb_get_dr_mode(dev->node) != USB_DR_MODE_OTG) {
                dev_dbg(dev, "Invalid mode\n");
                return -ENODEV;
        }
index 45df614b0949f9781033f4185c35b67db847a614..e4abc6f3b9beed8c41e7d4f05ceb9965a8ec5175 100644 (file)
@@ -12,7 +12,6 @@
 
 #include <common.h>
 #include <dm.h>
-#include <fdtdec.h>
 #include <reset.h>
 #include <clk.h>
 
index ad7cf6e6b53d12d61928e9393feef2b317d2f396..c99a1985cca56dd49036ff3c36dae239aa165e91 100644 (file)
@@ -10,8 +10,6 @@
 #include <asm/io.h>
 #include <dm.h>
 #include <errno.h>
-#include <fdtdec.h>
-#include <linux/libfdt.h>
 #include <dm/lists.h>
 #include <regmap.h>
 #include <reset-uclass.h>
@@ -109,8 +107,7 @@ static int sti_dwc3_glue_ofdata_to_platdata(struct udevice *dev)
        int ret;
        u32 reg[4];
 
-       ret = fdtdec_get_int_array(gd->fdt_blob, dev_of_offset(dev),
-                                  "reg", reg, ARRAY_SIZE(reg));
+       ret = ofnode_read_u32_array(dev->node, "reg", reg, ARRAY_SIZE(reg));
        if (ret) {
                pr_err("unable to find st,stih407-dwc3 reg property(%d)\n", ret);
                return ret;
@@ -153,18 +150,15 @@ static int sti_dwc3_glue_ofdata_to_platdata(struct udevice *dev)
 static int sti_dwc3_glue_bind(struct udevice *dev)
 {
        struct sti_dwc3_glue_platdata *plat = dev_get_platdata(dev);
-       int dwc3_node;
+       ofnode node, dwc3_node;
 
-       /* check if one subnode is present */
-       dwc3_node = fdt_first_subnode(gd->fdt_blob, dev_of_offset(dev));
-       if (dwc3_node <= 0) {
-               pr_err("Can't find subnode for %s\n", dev->name);
-               return -ENODEV;
+       /* Find snps,dwc3 node from subnode */
+       ofnode_for_each_subnode(node, dev->node) {
+               if (ofnode_device_is_compatible(node, "snps,dwc3"))
+                       dwc3_node = node;
        }
 
-       /* check if the subnode compatible string is the dwc3 one*/
-       if (fdt_node_check_compatible(gd->fdt_blob, dwc3_node,
-                                     "snps,dwc3") != 0) {
+       if (!ofnode_valid(node)) {
                pr_err("Can't find dwc3 subnode for %s\n", dev->name);
                return -ENODEV;
        }
index 5c257ccf4d226b04772f34601b65e673f2810cd5..dd92808ff7b37a19c5c4b9b980c164378d4960ef 100644 (file)
@@ -10,8 +10,6 @@
 #include <common.h>
 #include <dm.h>
 #include <errno.h>
-#include <fdtdec.h>
-#include <linux/libfdt.h>
 #include <usb.h>
 #include <usb/ehci-ci.h>
 #include <usb/ulpi.h>
@@ -108,7 +106,7 @@ static int ehci_usb_ofdata_to_platdata(struct udevice *dev)
        struct msm_ehci_priv *priv = dev_get_priv(dev);
 
        priv->ulpi_vp.port_num = 0;
-       priv->ehci = (void *)devfdt_get_addr(dev);
+       priv->ehci = dev_read_addr_ptr(dev);
 
        if (priv->ehci == (void *)FDT_ADDR_T_NONE)
                return -EINVAL;
index 1993ad620a8cc3b573f9d3e4a2e3d5b4d7ab1ad1..f2ceb5131010d36e1f1632a92b5d390917a63da7 100644 (file)
@@ -513,7 +513,7 @@ static int ehci_usb_ofdata_to_platdata(struct udevice *dev)
        struct usb_platdata *plat = dev_get_platdata(dev);
        enum usb_dr_mode dr_mode;
 
-       dr_mode = usb_get_dr_mode(dev_of_offset(dev));
+       dr_mode = usb_get_dr_mode(dev->node);
 
        switch (dr_mode) {
        case USB_DR_MODE_HOST:
index c1c681ca6cf159a77ab80560d3b1aa4a03537dc2..9fcfa39d4b5afdac9be67d91172e6b838f8b4913 100644 (file)
@@ -9,7 +9,6 @@
 
 #include <common.h>
 #include <dm.h>
-#include <fdtdec.h>
 #include <generic-phy.h>
 #include <usb.h>
 #include <dwc3-uboot.h>
@@ -155,7 +154,7 @@ static int xhci_dwc3_probe(struct udevice *dev)
 
        writel(reg, &dwc3_reg->g_usb2phycfg[0]);
 
-       dr_mode = usb_get_dr_mode(dev_of_offset(dev));
+       dr_mode = usb_get_dr_mode(dev->node);
        if (dr_mode == USB_DR_MODE_UNKNOWN)
                /* by default set dual role mode to HOST */
                dr_mode = USB_DR_MODE_HOST;
index 00759f3e832e70879819b83c70de5464b6ba90fd..608facefa3de72584aa9013e80d1542248010df3 100644 (file)
@@ -285,14 +285,12 @@ U_BOOT_DRIVER(ti_musb_peripheral) = {
 #if CONFIG_IS_ENABLED(OF_CONTROL)
 static int ti_musb_wrapper_bind(struct udevice *parent)
 {
-       const void *fdt = gd->fdt_blob;
-       int node;
+       ofnode node;
        int ret;
 
-       for (node = fdt_first_subnode(fdt, dev_of_offset(parent)); node > 0;
-            node = fdt_next_subnode(fdt, node)) {
+       ofnode_for_each_subnode(node, parent->node) {
                struct udevice *dev;
-               const char *name = fdt_get_name(fdt, node, NULL);
+               const char *name = ofnode_get_name(node);
                enum usb_dr_mode dr_mode;
                struct driver *drv;
 
@@ -306,7 +304,7 @@ static int ti_musb_wrapper_bind(struct udevice *parent)
                        ret = device_bind_driver_to_node(parent,
                                                         "ti-musb-peripheral",
                                                         name,
-                                                        offset_to_ofnode(node),
+                                                        node,
                                                         &dev);
                        if (ret)
                                pr_err("musb - not able to bind usb peripheral node\n");
@@ -316,7 +314,7 @@ static int ti_musb_wrapper_bind(struct udevice *parent)
                        ret = device_bind_driver_to_node(parent,
                                                         "ti-musb-host",
                                                         name,
-                                                        offset_to_ofnode(node),
+                                                        node,
                                                         &dev);
                        if (ret)
                                pr_err("musb - not able to bind usb host node\n");
index d24c1e48353f420f71b87b35d352ab8715413000..cb4da2e3cf8804ac0b38a4e8b022084ed8c4c7b3 100644 (file)
@@ -24,15 +24,15 @@ config HW_WATCHDOG
 config WATCHDOG_RESET_DISABLE
        bool "Disable reset watchdog"
        help
-          Disable reset watchdog, which can let WATCHDOG_RESET invalid, so
-          that the watchdog will not be fed in u-boot.
+         Disable reset watchdog, which can let WATCHDOG_RESET invalid, so
+         that the watchdog will not be fed in u-boot.
 
 config IMX_WATCHDOG
        bool "Enable Watchdog Timer support for IMX and LSCH2 of NXP"
        select HW_WATCHDOG if !WDT
        help
-          Select this to enable the IMX and LSCH2 of Layerscape watchdog
-          driver.
+         Select this to enable the IMX and LSCH2 of Layerscape watchdog
+         driver.
 
 config OMAP_WATCHDOG
        bool "TI OMAP watchdog driver"
@@ -50,8 +50,8 @@ config DESIGNWARE_WATCHDOG
        bool "Designware watchdog timer support"
        select HW_WATCHDOG if !WDT
        help
-          Enable this to support Designware Watchdog Timer IP, present e.g.
-          on Altera SoCFPGA SoCs.
+         Enable this to support Designware Watchdog Timer IP, present e.g.
+         on Altera SoCFPGA SoCs.
 
 config WDT
        bool "Enable driver model for watchdog timer drivers"
@@ -68,10 +68,10 @@ config WDT_ARMADA_37XX
        bool "Marvell Armada 37xx watchdog timer support"
        depends on WDT && ARMADA_3700
        help
-          Enable this to support Watchdog Timer on Marvell Armada 37xx SoC.
-          There are 4 possible clocks which can be used on these SoCs. This
-          driver uses the second clock (ID 1), assuming that so will also
-          Linux's driver.
+         Enable this to support Watchdog Timer on Marvell Armada 37xx SoC.
+         There are 4 possible clocks which can be used on these SoCs. This
+         driver uses the second clock (ID 1), assuming that so will also
+         Linux's driver.
 
 config WDT_ASPEED
        bool "Aspeed ast2400/ast2500 watchdog timer support"
@@ -88,8 +88,8 @@ config WDT_AT91
        bool "AT91 watchdog timer support"
        depends on WDT
        help
-          Select this to enable Microchip watchdog timer, which can be found on
-          some AT91 devices.
+         Select this to enable Microchip watchdog timer, which can be found on
+         some AT91 devices.
 
 config WDT_BCM6345
        bool "BCM6345 watchdog timer support"
@@ -105,8 +105,8 @@ config WDT_CDNS
        depends on WDT
        imply WATCHDOG
        help
-          Select this to enable Cadence watchdog timer, which can be found on some
-          Xilinx Microzed Platform.
+         Select this to enable Cadence watchdog timer, which can be found on some
+         Xilinx Microzed Platform.
 
 config WDT_CORTINA
        bool "Cortina Access CAxxxx watchdog timer support"
@@ -114,21 +114,21 @@ config WDT_CORTINA
        help
          Cortina Access CAxxxx watchdog timer support.
          This driver support all CPU ISAs supported by Cortina
-          Access CAxxxx SoCs.
+         Access CAxxxx SoCs.
 
 config WDT_MPC8xx
        bool "MPC8xx watchdog timer support"
        depends on WDT && MPC8xx
        select HW_WATCHDOG
        help
-          Select this to enable mpc8xx watchdog timer
+         Select this to enable mpc8xx watchdog timer
 
 config WDT_MT7621
        bool "MediaTek MT7621 watchdog timer support"
        depends on WDT && SOC_MT7628
        help
-          Select this to enable Ralink / Mediatek watchdog timer,
-          which can be found on some MediaTek chips.
+         Select this to enable Ralink / Mediatek watchdog timer,
+         which can be found on some MediaTek chips.
 
 config WDT_MTK
        bool "MediaTek watchdog timer support"
@@ -139,10 +139,10 @@ config WDT_MTK
          It performs full SoC reset.
 
 config WDT_OMAP3
-        bool "TI OMAP watchdog timer support"
-        depends on WDT && ARCH_OMAP2PLUS
-        default y if AM33XX
-        help
+       bool "TI OMAP watchdog timer support"
+       depends on WDT && ARCH_OMAP2PLUS
+       default y if AM33XX
+       help
          This enables OMAP3+ watchdog timer driver, which can be
          found on some TI chipsets and inline with driver model.
 
@@ -151,8 +151,8 @@ config WDT_ORION
        depends on WDT
        select CLK
        help
-          Select this to enable Orion watchdog timer, which can be found on some
-          Marvell Armada chips.
+         Select this to enable Orion watchdog timer, which can be found on some
+         Marvell Armada chips.
 
 config WDT_SANDBOX
        bool "Enable Watchdog Timer support for Sandbox"
@@ -166,8 +166,8 @@ config WDT_SP805
        bool "SP805 watchdog timer support"
        depends on WDT
        help
-          Select this to enable SP805 watchdog timer, which can be found on some
-          nxp layerscape chips.
+         Select this to enable SP805 watchdog timer, which can be found on some
+         nxp layerscape chips.
 
 config WDT_STM32MP
        bool "IWDG watchdog driver for STM32 MP's family"
@@ -182,8 +182,8 @@ config XILINX_TB_WATCHDOG
        depends on WDT
        imply WATCHDOG
        help
-          Select this to enable Xilinx Axi watchdog timer, which can be found on some
-          Xilinx Microblaze Platforms.
+         Select this to enable Xilinx Axi watchdog timer, which can be found on some
+         Xilinx Microblaze Platforms.
 
 config WDT_TANGIER
        bool "Intel Tangier watchdog timer support"
index cf1c52747397ff9e3f253caf1a7a89b2ae55e2d7..d9e4dc7cb8a4efeb251ce92238033bec98fe3265 100644 (file)
@@ -7,6 +7,7 @@
 #include <dm.h>
 #include <errno.h>
 #include <hang.h>
+#include <time.h>
 #include <wdt.h>
 #include <dm/device-internal.h>
 #include <dm/lists.h>
@@ -83,7 +84,7 @@ void watchdog_reset(void)
 
        /* Do not reset the watchdog too often */
        now = get_timer(0);
-       if (now > next_reset) {
+       if (time_after(now, next_reset)) {
                next_reset = now + 1000;        /* reset every 1000ms */
                wdt_reset(gd->watchdog_dev);
        }
index 1c616a26a272ba7c15736b317bbd9f50a2524dbe..966b427a974ec7e45aea0c90ae0d8c4849c241ca 100644 (file)
@@ -288,7 +288,7 @@ int ext_cache_read(struct ext_block_cache *cache, lbaint_t block, int size)
        if (cache->buf && cache->block == block && cache->size == size)
                return 1;
        ext_cache_fini(cache);
-       cache->buf = malloc(size);
+       cache->buf = memalign(ARCH_DMA_MINALIGN, size);
        if (!cache->buf)
                return 0;
        if (!ext4fs_devread(block, 0, size, cache->buf)) {
index c9691a0392def2ac3698503628c8230c3edc41ae..e19fa90212839f96809f34f47c0edd7ebcf0db34 100644 (file)
@@ -7,7 +7,7 @@
 #define __CONFIG_H
 
 #define ROCKCHIP_DEVICE_SETTINGS \
-               "stdin=serial,cros-ec-keyb\0" \
+               "stdin=serial,usbkbd\0" \
                "stdout=serial,vidconsole\0" \
                "stderr=serial,vidconsole\0"
 
index 3fd10625426b34a1d6f8dd194008ccd33fbeb7dd..d4cbc3532e1eac3d0e960e4117683cfdb9fe1593 100644 (file)
@@ -7,7 +7,7 @@
 #define __ROC_PC_RK3399_H
 
 #define ROCKCHIP_DEVICE_SETTINGS \
-               "stdin=serial,cros-ec-keyb\0" \
+               "stdin=serial,usbkbd\0" \
                "stdout=serial,vidconsole\0" \
                "stderr=serial,vidconsole\0"
 
index 917caf4d53a502879b1732e7a1709192e3c7eb81..9e4a66902b50f9a28ccabce9e79b211511adbb7c 100644 (file)
@@ -7,7 +7,7 @@
 #define __CONFIG_H
 
 #define ROCKCHIP_DEVICE_SETTINGS \
-               "stdin=serial,cros-ec-keyb\0" \
+               "stdin=serial,usbkbd\0" \
                "stdout=serial,vidconsole\0" \
                "stderr=serial,vidconsole\0"
 
index f1095ccd0e17a2f56455a801d6a43b2eef46c6d0..d239e3beb1cfa6aefbf1b0bb889b4b194f2f5998 100644 (file)
@@ -7,7 +7,7 @@
 #define __CONFIG_H
 
 #define ROCKCHIP_DEVICE_SETTINGS \
-               "stdin=serial,cros-ec-keyb\0" \
+               "stdin=serial,usbkbd\0" \
                "stdout=serial,vidconsole\0" \
                "stderr=serial,vidconsole\0"
 
index e31dc777200c9c72819bf5467b371676fd1b1a5a..c3521cac419417657d01c5250d208ec0d05f867f 100644 (file)
@@ -9,7 +9,7 @@
 #define __CONFIG_H
 
 #define ROCKCHIP_DEVICE_SETTINGS \
-               "stdin=serial,cros-ec-keyb\0" \
+               "stdin=serial,usbkbd\0" \
                "stdout=serial,vidconsole\0" \
                "stderr=serial,vidconsole\0"
 
index 3d1a6beeeaca4c0a2a6f429de52a4515f35c51a2..1c40ffc4f56c02cf661fd8d5757c34788416e47a 100644 (file)
@@ -57,6 +57,16 @@ typedef u16 efi_form_id_t;
 
 struct efi_event;
 
+/* OsIndicationsSupported flags */
+#define EFI_OS_INDICATIONS_BOOT_TO_FW_UI                   0x0000000000000001
+#define EFI_OS_INDICATIONS_TIMESTAMP_REVOCATION                    0x0000000000000002
+#define EFI_OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED  0x0000000000000004
+#define EFI_OS_INDICATIONS_FMP_CAPSULE_SUPPORTED           0x0000000000000008
+#define EFI_OS_INDICATIONS_CAPSULE_RESULT_VAR_SUPPORTED            0x0000000000000010
+#define EFI_OS_INDICATIONS_START_OS_RECOVERY               0x0000000000000020
+#define EFI_OS_INDICATIONS_START_PLATFORM_RECOVERY         0x0000000000000040
+#define EFI_OS_INDICATIONS_JSON_CONFIG_DATA_REFRESH        0x0000000000000080
+
 /* EFI Boot Services table */
 #define EFI_BOOT_SERVICES_SIGNATURE 0x56524553544f4f42
 struct efi_boot_services {
@@ -207,11 +217,11 @@ enum efi_reset_type {
 #define CAPSULE_FLAGS_INITIATE_RESET           0x00040000
 
 struct efi_capsule_header {
-       efi_guid_t *capsule_guid;
+       efi_guid_t capsule_guid;
        u32 header_size;
        u32 flags;
        u32 capsule_image_size;
-};
+} __packed;
 
 #define EFI_RT_SUPPORTED_GET_TIME                      0x0001
 #define EFI_RT_SUPPORTED_SET_TIME                      0x0002
@@ -262,7 +272,7 @@ struct efi_runtime_services {
                                            efi_uintn_t *data_size, void *data);
        efi_status_t (EFIAPI *get_next_variable_name)(
                        efi_uintn_t *variable_name_size,
-                       u16 *variable_name, const efi_guid_t *vendor);
+                       u16 *variable_name, efi_guid_t *vendor);
        efi_status_t (EFIAPI *set_variable)(u16 *variable_name,
                                            const efi_guid_t *vendor,
                                            u32 attributes,
@@ -1645,4 +1655,31 @@ struct efi_load_file_protocol {
 #define LOAD_OPTION_CATEGORY_BOOT      0x00000000
 #define LOAD_OPTION_CATEGORY_APP       0x00000100
 
+/*
+ * System Resource Table
+ */
+/* Firmware Type Definitions */
+#define ESRT_FW_TYPE_UNKNOWN           0x00000000
+#define ESRT_FW_TYPE_SYSTEMFIRMWARE    0x00000001
+#define ESRT_FW_TYPE_DEVICEFIRMWARE    0x00000002
+#define ESRT_FW_TYPE_UEFIDRIVER                0x00000003
+
+/* Last Attempt Status Values */
+#define LAST_ATTEMPT_STATUS_SUCCESS                    0x00000000
+#define LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL         0x00000001
+#define LAST_ATTEMPT_STATUS_ERROR_INSUFFICIENT_RESOURCES 0x00000002
+#define LAST_ATTEMPT_STATUS_ERROR_INCORRECT_VERSION    0x00000003
+#define LAST_ATTEMPT_STATUS_ERROR_INVALID_FORMAT       0x00000004
+#define LAST_ATTEMPT_STATUS_ERROR_AUTH_ERROR           0x00000005
+#define LAST_ATTEMPT_STATUS_ERROR_PWR_EVT_AC           0x00000006
+#define LAST_ATTEMPT_STATUS_ERROR_PWR_EVT_BATT         0x00000007
+#define LAST_ATTEMPT_STATUS_ERROR_UNSATISFIED_DEPENDENCIES 0x00000008
+
+/*
+ * The LastAttemptStatus values of 0x1000 - 0x4000 are reserved for vendor
+ * usage.
+ */
+#define LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL_VENDOR_RANGE_MIN 0x00001000
+#define LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL_VENDOR_RANGE_MAX 0x00004000
+
 #endif
index 8e343798339110469eabcfdf6deaf931d4131006..3f2792892f34c72208df7795d8e03afa93ce4c72 100644 (file)
@@ -457,6 +457,20 @@ efi_status_t efi_remove_all_protocols(const efi_handle_t handle);
 /* Install multiple protocol interfaces */
 efi_status_t EFIAPI efi_install_multiple_protocol_interfaces
                                (efi_handle_t *handle, ...);
+/* Get handles that support a given protocol */
+efi_status_t EFIAPI efi_locate_handle_buffer(
+                       enum efi_locate_search_type search_type,
+                       const efi_guid_t *protocol, void *search_key,
+                       efi_uintn_t *no_handles, efi_handle_t **buffer);
+/* Close an previously opened protocol interface */
+efi_status_t EFIAPI efi_close_protocol(efi_handle_t handle,
+                                      const efi_guid_t *protocol,
+                                      efi_handle_t agent_handle,
+                                      efi_handle_t controller_handle);
+/* Open a protocol interface */
+efi_status_t EFIAPI efi_handle_protocol(efi_handle_t handle,
+                                       const efi_guid_t *protocol,
+                                       void **protocol_interface);
 /* Call this to create an event */
 efi_status_t efi_create_event(uint32_t type, efi_uintn_t notify_tpl,
                              void (EFIAPI *notify_function) (
@@ -631,7 +645,7 @@ efi_status_t EFIAPI efi_get_variable(u16 *variable_name,
                                     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,
-                                              const efi_guid_t *vendor);
+                                              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);
index d2604c5cafba5f3ef03d8ec216082ea09e354284..c19b916be9d4b48ac66a6e93f66663fc409318f8 100644 (file)
@@ -9,6 +9,8 @@
 #ifndef __LINUX_USB_OTG_H
 #define __LINUX_USB_OTG_H
 
+#include <dm/ofnode.h>
+
 enum usb_dr_mode {
        USB_DR_MODE_UNKNOWN,
        USB_DR_MODE_HOST,
@@ -18,20 +20,20 @@ enum usb_dr_mode {
 
 /**
  * usb_get_dr_mode() - Get dual role mode for given device
- * @node: Node offset to the given device
+ * @node: ofnode of the given device
  *
  * The function gets phy interface string from property 'dr_mode',
  * and returns the correspondig enum usb_dr_mode
  */
-enum usb_dr_mode usb_get_dr_mode(int node);
+enum usb_dr_mode usb_get_dr_mode(ofnode node);
 
 /**
  * usb_get_maximum_speed() - Get maximum speed for given device
- * @node: Node offset to the given device
+ * @node: ofnode of the given device
  *
  * The function gets phy interface string from property 'maximum-speed',
  * and returns the correspondig enum usb_device_speed
  */
-enum usb_device_speed usb_get_maximum_speed(int node);
+enum usb_device_speed usb_get_maximum_speed(ofnode node);
 
 #endif /* __LINUX_USB_OTG_H */
index 5bcff24ab310020a19b053e22e85db7345a62b64..dd83dfdd32083c94182104612000c9c744cfe484 100644 (file)
@@ -130,11 +130,10 @@ static inline int initr_watchdog(void)
                }
        }
 
-       if (CONFIG_IS_ENABLED(OF_CONTROL)) {
+       if (CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)) {
                timeout = dev_read_u32_default(gd->watchdog_dev, "timeout-sec",
                                               WATCHDOG_TIMEOUT_SECS);
        }
-
        wdt_start(gd->watchdog_dev, timeout * 1000, 0);
        gd->flags |= GD_FLG_WDT_READY;
        printf("WDT:   Started with%s servicing (%ds timeout)\n",
index 1f598b357a5c97e4b0dfa134ad9b7190231008b7..3b79a88a480f6a7e294c2b1a65beff0b23fa0f4e 100644 (file)
@@ -208,7 +208,7 @@ static void efi_process_event_queue(void)
  */
 static void efi_queue_event(struct efi_event *event)
 {
-       struct efi_event *item = NULL;
+       struct efi_event *item;
 
        if (!event->notify_function)
                return;
@@ -2106,10 +2106,10 @@ static efi_status_t EFIAPI efi_set_watchdog_timer(unsigned long timeout,
  *
  * Return: status code
  */
-static efi_status_t EFIAPI efi_close_protocol(efi_handle_t handle,
-                                             const efi_guid_t *protocol,
-                                             efi_handle_t agent_handle,
-                                             efi_handle_t controller_handle)
+efi_status_t EFIAPI efi_close_protocol(efi_handle_t handle,
+                                      const efi_guid_t *protocol,
+                                      efi_handle_t agent_handle,
+                                      efi_handle_t controller_handle)
 {
        struct efi_handler *handler;
        struct efi_open_protocol_info_item *item;
@@ -2282,7 +2282,7 @@ static efi_status_t EFIAPI efi_protocols_per_handle(
  *
  * Return: status code
  */
-static efi_status_t EFIAPI efi_locate_handle_buffer(
+efi_status_t EFIAPI efi_locate_handle_buffer(
                        enum efi_locate_search_type search_type,
                        const efi_guid_t *protocol, void *search_key,
                        efi_uintn_t *no_handles, efi_handle_t **buffer)
@@ -3182,9 +3182,9 @@ out:
  *
  * Return: status code
  */
-static efi_status_t EFIAPI efi_handle_protocol(efi_handle_t handle,
-                                              const efi_guid_t *protocol,
-                                              void **protocol_interface)
+efi_status_t EFIAPI efi_handle_protocol(efi_handle_t handle,
+                                       const efi_guid_t *protocol,
+                                       void **protocol_interface)
 {
        return efi_open_protocol(handle, protocol, protocol_interface, efi_root,
                                 NULL, EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL);
index ed7fb3f7d339e305b5f3ec561c7d407fdbe7d71c..fc0682bc48ca5f2da348e1edf4376d674fb10f43 100644 (file)
@@ -222,15 +222,17 @@ static const struct efi_block_io block_io_disk_template = {
        .flush_blocks = &efi_disk_flush_blocks,
 };
 
-/*
- * Get the simple file system protocol for a file device path.
+/**
+ * efi_fs_from_path() - retrieve simple file system protocol
+ *
+ * Gets the simple file system protocol for a file device path.
  *
  * The full path provided is split into device part and into a file
  * part. The device part is used to find the handle on which the
  * simple file system protocol is installed.
  *
- * @full_path  device path including device and file
- * @return     simple file system protocol
+ * @full_path: device path including device and file
+ * Return:     simple file system protocol
  */
 struct efi_simple_file_system_protocol *
 efi_fs_from_path(struct efi_device_path *full_path)
@@ -285,15 +287,15 @@ static int efi_fs_exists(struct blk_desc *desc, int part)
 }
 
 /*
- * Create a handle for a partition or disk
+ * efi_disk_add_dev() - create a handle for a partition or disk
  *
- * @parent     parent handle
- * @dp_parent  parent device path
- * @if_typename interface name for block device
- * @desc       internal block device
- * @dev_index   device index for block device
- * @offset     offset into disk for simple partitions
- * @return     disk object
+ * @parent:            parent handle
+ * @dp_parent:         parent device path
+ * @if_typename:       interface name for block device
+ * @desc:              internal block device
+ * @dev_index:         device index for block device
+ * @offset:            offset into disk for simple partitions
+ * Return:             disk object
  */
 static efi_status_t efi_disk_add_dev(
                                efi_handle_t parent,
@@ -365,7 +367,7 @@ static efi_status_t efi_disk_add_dev(
        diskobj->media.block_size = desc->blksz;
        diskobj->media.io_align = desc->blksz;
        diskobj->media.last_block = desc->lba - offset;
-       if (part != 0)
+       if (part)
                diskobj->media.logical_partition = 1;
        diskobj->ops.media = &diskobj->media;
        if (disk)
@@ -373,15 +375,17 @@ static efi_status_t efi_disk_add_dev(
        return EFI_SUCCESS;
 }
 
-/*
- * Create handles and protocols for the partitions of a block device
+/**
+ * efi_disk_create_partitions() - create handles and protocols for partitions
  *
- * @parent             handle of the parent disk
- * @blk_desc           block device
- * @if_typename                interface type
- * @diskid             device number
- * @pdevname           device name
- * @return             number of partitions created
+ * Create handles and protocols for the partitions of a block device.
+ *
+ * @parent:            handle of the parent disk
+ * @blk_desc:          block device
+ * @if_typename:       interface type
+ * @diskid:            device number
+ * @pdevname:          device name
+ * Return:             number of partitions created
  */
 int efi_disk_create_partitions(efi_handle_t parent, struct blk_desc *desc,
                               const char *if_typename, int diskid,
@@ -418,16 +422,20 @@ int efi_disk_create_partitions(efi_handle_t parent, struct blk_desc *desc,
        return disks;
 }
 
-/*
+/**
+ * efi_disk_register() - register block devices
+ *
  * U-Boot doesn't have a list of all online disk devices. So when running our
  * EFI payload, we scan through all of the potentially available ones and
  * store them in our object pool.
  *
+ * This function is called in efi_init_obj_list().
+ *
  * TODO(sjg@chromium.org): Actually with CONFIG_BLK, U-Boot does have this.
  * Consider converting the code to look up devices as needed. The EFI device
  * could be a child of the UCLASS_BLK block device, perhaps.
  *
- * This gets called from do_bootefi_exec().
+ * Return:     status code
  */
 efi_status_t efi_disk_register(void)
 {
index dcf5d1c49a2d4433d27762c58eecb279db01c6bb..bd0dff162f6b8f129f381273f8d2500509e33640 100644 (file)
@@ -47,7 +47,7 @@ void *memmove(void *dest, const void *src, size_t n)
        u8 *d = dest;
        const u8 *s = src;
 
-       if (d >= s) {
+       if (d <= s) {
                for (; n; --n)
                        *d++ = *s++;
        } else {
index 89adf2031024cd189ff00d52a7d732a513240fb3..97d90f069a63617ac0ba5fa7e6b5cc09548d8053 100644 (file)
@@ -627,18 +627,18 @@ efi_status_t efi_get_memory_map(efi_uintn_t *memory_map_size,
 
        *memory_map_size = map_size;
 
-       if (provided_map_size < map_size)
-               return EFI_BUFFER_TOO_SMALL;
-
-       if (!memory_map)
-               return EFI_INVALID_PARAMETER;
-
        if (descriptor_size)
                *descriptor_size = sizeof(struct efi_mem_desc);
 
        if (descriptor_version)
                *descriptor_version = EFI_MEMORY_DESCRIPTOR_VERSION;
 
+       if (provided_map_size < map_size)
+               return EFI_BUFFER_TOO_SMALL;
+
+       if (!memory_map)
+               return EFI_INVALID_PARAMETER;
+
        /* Copy list into array */
        /* Return the list in ascending order */
        memory_map = &memory_map[map_entries - 1];
index 4be51335bcb6e8263dc91a4476ed89443cf5ff4c..6a25acbbcdf556d2174ac4eb8e5ce4afe5cdcb1d 100644 (file)
@@ -483,7 +483,7 @@ static __efi_runtime efi_status_t EFIAPI efi_convert_pointer_runtime(
 }
 
 /**
- * efi_convert_pointer_runtime() - convert from physical to virtual pointer
+ * efi_convert_pointer() - convert from physical to virtual pointer
  *
  * This function implements the ConvertPointer() runtime service until
  * the first call to SetVirtualAddressMap().
@@ -493,7 +493,7 @@ static __efi_runtime efi_status_t EFIAPI efi_convert_pointer_runtime(
  *
  * @debug_disposition: indicates if pointer may be converted to NULL
  * @address:           pointer to be converted
- * Return:             status code EFI_UNSUPPORTED
+ * Return:             status code
  */
 static __efi_runtime efi_status_t EFIAPI efi_convert_pointer(
                        efi_uintn_t debug_disposition, void **address)
index c316bdfec0e40120a7a20ee55533667b25a0faa2..fe2f26459136befd6190879b5b6416aa91610375 100644 (file)
@@ -1,8 +1,8 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
- *  EFI utils
+ * UEFI runtime variable services
  *
- *  Copyright (c) 2017 Rob Clark
+ * Copyright (c) 2017 Rob Clark
  */
 
 #include <common.h>
@@ -273,7 +273,8 @@ static efi_status_t parse_uboot_variable(char *variable,
                                         u32 *attributes)
 {
        char *guid, *name, *end, c;
-       unsigned long name_len;
+       size_t name_len;
+       efi_uintn_t old_variable_name_size;
        u16 *p;
 
        guid = strchr(variable, '_');
@@ -289,17 +290,17 @@ static efi_status_t parse_uboot_variable(char *variable,
                return EFI_INVALID_PARAMETER;
 
        name_len = end - name;
-       if (*variable_name_size < (name_len + 1)) {
-               *variable_name_size = name_len + 1;
+       old_variable_name_size = *variable_name_size;
+       *variable_name_size = sizeof(u16) * (name_len + 1);
+       if (old_variable_name_size < *variable_name_size)
                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);
@@ -329,7 +330,7 @@ static efi_status_t parse_uboot_variable(char *variable,
  */
 efi_status_t EFIAPI efi_get_next_variable_name(efi_uintn_t *variable_name_size,
                                               u16 *variable_name,
-                                              const efi_guid_t *vendor)
+                                              efi_guid_t *vendor)
 {
        char *native_name, *variable;
        ssize_t name_len, list_len;
@@ -597,7 +598,7 @@ efi_get_variable_runtime(u16 *variable_name, const efi_guid_t *vendor,
  */
 static efi_status_t __efi_runtime EFIAPI
 efi_get_next_variable_name_runtime(efi_uintn_t *variable_name_size,
-                                  u16 *variable_name, const efi_guid_t *vendor)
+                                  u16 *variable_name, efi_guid_t *vendor)
 {
        return EFI_UNSUPPORTED;
 }
index cf132c372e17cd3c94a68742f15b5d2fd46b452b..e9baa641350c92e5afdd24996481c268e1d37594 100644 (file)
@@ -27,6 +27,7 @@ efi_selftest_exitbootservices.o \
 efi_selftest_gop.o \
 efi_selftest_loaded_image.o \
 efi_selftest_manageprotocols.o \
+efi_selftest_mem.o \
 efi_selftest_memory.o \
 efi_selftest_open_protocol.o \
 efi_selftest_register_notify.o \
diff --git a/lib/efi_selftest/efi_selftest_mem.c b/lib/efi_selftest/efi_selftest_mem.c
new file mode 100644 (file)
index 0000000..51f0fec
--- /dev/null
@@ -0,0 +1,77 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * efi_selftest_memory
+ *
+ * Copyright (c) 2018 Heinrich Schuchardt <xypron.glpk@gmx.de>
+ *
+ * This unit test checks the following boottime services:
+ * CopyMem, SetMem, CalculateCrc32
+ *
+ * The memory type used for the device tree is checked.
+ */
+
+#include <efi_selftest.h>
+
+static struct efi_boot_services *boottime;
+
+/**
+ * setup() - 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)
+{
+       boottime = systable->boottime;
+
+       return EFI_ST_SUCCESS;
+}
+
+/*
+ * execute() - execute unit test
+ *
+ * Return:     EFI_ST_SUCCESS for success
+ */
+static int execute(void)
+{
+       u8 c1[] = "abcdefghijklmnop";
+       u8 c2[] = "abcdefghijklmnop";
+       u32 crc32;
+       efi_status_t ret;
+
+       ret = boottime->calculate_crc32(c1, 16, &crc32);
+       if (ret != EFI_SUCCESS) {
+               efi_st_error("CalculateCrc32 failed\n");
+               return EFI_ST_FAILURE;
+       }
+       if (crc32 != 0x943ac093) {
+               efi_st_error("CalculateCrc32 returned wrong value\n");
+               return EFI_ST_FAILURE;
+       }
+       boottime->copy_mem(&c1[5], &c1[3], 8);
+       if (memcmp(c1, "abcdedefghijknop", 16)) {
+               efi_st_error("CopyMem forward copy failed: %s\n", c1);
+               return EFI_ST_FAILURE;
+       }
+       boottime->copy_mem(&c2[3], &c2[5], 8);
+       if (memcmp(c2, "abcfghijklmlmnop", 16)) {
+               efi_st_error("CopyMem backward copy failed: %s\n", c2);
+               return EFI_ST_FAILURE;
+       }
+       boottime->set_mem(&c1[3], 8, 'x');
+       if (memcmp(c1, "abcxxxxxxxxjknop", 16)) {
+               efi_st_error("SetMem failed: %s\n", c1);
+               return EFI_ST_FAILURE;
+       }
+
+       return EFI_ST_SUCCESS;
+}
+
+EFI_UNIT_TEST(mem) = {
+       .name = "mem",
+       .phase = EFI_EXECUTE_BEFORE_BOOTTIME_EXIT,
+       .setup = setup,
+       .execute = execute,
+};
index 5d98c029b8690daf29e4225d712368171969cf62..2c16f3db6cc3270d906e7bf82157cc431e8b723a 100644 (file)
@@ -11,7 +11,7 @@
 #include <efi_selftest.h>
 
 #define EFI_ST_MAX_DATA_SIZE 16
-#define EFI_ST_MAX_VARNAME_SIZE 40
+#define EFI_ST_MAX_VARNAME_SIZE 80
 
 static struct efi_boot_services *boottime;
 static struct efi_runtime_services *runtime;
@@ -155,8 +155,14 @@ static int execute(void)
                        return EFI_ST_FAILURE;
                }
                if (!memcmp(&guid, &guid_vendor0, sizeof(efi_guid_t)) &&
-                   !efi_st_strcmp_16_8(varname, "efi_st_var0"))
+                   !efi_st_strcmp_16_8(varname, "efi_st_var0")) {
                        flag |= 1;
+                       if (len != 24) {
+                               efi_st_error("GetNextVariableName report wrong length %u, expected 24\n",
+                                            (unsigned int)len);
+                               return EFI_ST_FAILURE;
+                       }
+               }
                if (!memcmp(&guid, &guid_vendor1, sizeof(efi_guid_t)) &&
                    !efi_st_strcmp_16_8(varname, "efi_st_var1"))
                        flag |= 2;
index cf040d7c8612eba2c8ebf96b1c8fc5bf8f1409f1..63f929fa4bd44cb1a8089dc14457e8ded7f36e8d 100644 (file)
@@ -451,7 +451,7 @@ static int compress_using_none(struct unit_test_state *uts,
 }
 
 /**
- * run_bootm_test() - Run tests on the bootm decopmression function
+ * run_bootm_test() - Run tests on the bootm decompression function
  *
  * @comp_type: Compression type to test
  * @compress:  Our function to compress data
diff --git a/test/py/tests/test_gpio.py b/test/py/tests/test_gpio.py
new file mode 100644 (file)
index 0000000..8c64f68
--- /dev/null
@@ -0,0 +1,37 @@
+# SPDX-License-Identifier: GPL-2.0+
+
+import pytest
+
+@pytest.mark.boardspec('sandbox')
+@pytest.mark.buildconfigspec('cmd_gpio')
+def test_gpio_input(u_boot_console):
+    """Test that gpio input correctly returns the value of a gpio pin."""
+
+    response = u_boot_console.run_command('gpio input 0; echo rc:$?')
+    expected_response = 'rc:0'
+    assert(expected_response in response)
+    response = u_boot_console.run_command('gpio toggle 0; gpio input 0; echo rc:$?')
+    expected_response = 'rc:1'
+    assert(expected_response in response)
+
+@pytest.mark.boardspec('sandbox')
+@pytest.mark.buildconfigspec('cmd_gpio')
+def test_gpio_exit_statuses(u_boot_console):
+    """Test that non-input gpio commands correctly return the command
+    success/failure status."""
+
+    expected_response = 'rc:0'
+    response = u_boot_console.run_command('gpio clear 0; echo rc:$?')
+    assert(expected_response in response)
+    response = u_boot_console.run_command('gpio set 0; echo rc:$?')
+    assert(expected_response in response)
+    response = u_boot_console.run_command('gpio toggle 0; echo rc:$?')
+    assert(expected_response in response)
+    response = u_boot_console.run_command('gpio status -a; echo rc:$?')
+    assert(expected_response in response)
+
+    expected_response = 'rc:1'
+    response = u_boot_console.run_command('gpio nonexistent-command; echo rc:$?')
+    assert(expected_response in response)
+    response = u_boot_console.run_command('gpio input 200; echo rc:$?')
+    assert(expected_response in response)
index a25aa5f6f78e13639a08625b9cf5e8c5a908ec65..ea652f9136188d42c04991d2c768b19cf69e30d0 100644 (file)
@@ -56,7 +56,7 @@ env__mmc_dev_configs = (
         'info_mode': ???,
         'info_buswidth': ???.
     },
-}
+)
 
 # Configuration data for test_mmc_rd; defines regions of the MMC (entire
 # devices, or ranges of sectors) which can be read:
@@ -210,7 +210,7 @@ def test_mmc_info(u_boot_console, env__mmc_dev_config):
     assert good_response in response
     good_response = "Bus Speed: %s" % info_speed
     assert good_response in response
-    good_response = "Mode : %s" % info_mode
+    good_response = "Mode: %s" % info_mode
     assert good_response in response
     good_response = "Bus Width: %s" % info_buswidth
     assert good_response in response
index c2382dfe5a1d02ead750a2b866aecaba8375916b..8f281f5901a4ab52c2b7f62d689eafdc6fc7b847 100644 (file)
@@ -307,11 +307,13 @@ static int rkcommon_parse_header(const void *buf, struct header0_info *header0,
                                           rkcommon_offset_to_spi(hdr1_offset));
 
        for (i = 0; i < ARRAY_SIZE(spl_infos); i++) {
-               if (!memcmp(&hdr1_sdmmc->magic, spl_infos[i].spl_hdr, 4)) {
+               if (!memcmp(&hdr1_sdmmc->magic, spl_infos[i].spl_hdr,
+                           RK_SPL_HDR_SIZE)) {
                        if (spl_info)
                                *spl_info = &spl_infos[i];
                        return IH_TYPE_RKSD;
-               } else if (!memcmp(&hdr1_spi->magic, spl_infos[i].spl_hdr, 4)) {
+               } else if (!memcmp(&hdr1_spi->magic, spl_infos[i].spl_hdr,
+                                  RK_SPL_HDR_SIZE)) {
                        if (spl_info)
                                *spl_info = &spl_infos[i];
                        return IH_TYPE_RKSPI;