From 862e2e75e8f317ff8bd660550d7da3fede2ead09 Mon Sep 17 00:00:00 2001 From: Lukas Auer Date: Thu, 22 Nov 2018 11:26:12 +0100 Subject: riscv: rename CPU_RISCV_32/64 to match architecture names ARCH_RV32I/64I RISC-V defines the base integer instruction sets as RV32I and RV64I. Rename CPU_RISCV_32 and CPU_RISCV_64 to ARCH_RV32I and ARCH_RV64I to match this convention. Signed-off-by: Lukas Auer Reviewed-by: Bin Meng Reviewed-by: Rick Chen --- include/config_distro_bootcmd.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/config_distro_bootcmd.h b/include/config_distro_bootcmd.h index 5838eb34779..d06974c58cf 100644 --- a/include/config_distro_bootcmd.h +++ b/include/config_distro_bootcmd.h @@ -99,9 +99,9 @@ #define BOOTEFI_NAME "bootia32.efi" #elif defined(CONFIG_X86_RUN_64BIT) #define BOOTEFI_NAME "bootx64.efi" -#elif defined(CONFIG_CPU_RISCV_32) +#elif defined(CONFIG_ARCH_RV32I) #define BOOTEFI_NAME "bootriscv32.efi" -#elif defined(CONFIG_CPU_RISCV_64) +#elif defined(CONFIG_ARCH_RV64I) #define BOOTEFI_NAME "bootriscv64.efi" #endif #endif @@ -257,10 +257,10 @@ #elif defined(__i386__) #define BOOTENV_EFI_PXE_ARCH "0x6" #define BOOTENV_EFI_PXE_VCI "PXEClient:Arch:00006:UNDI:003000" -#elif defined(CONFIG_CPU_RISCV_32) || ((defined(__riscv) && __riscv_xlen == 32)) +#elif defined(CONFIG_ARCH_RV32I) || ((defined(__riscv) && __riscv_xlen == 32)) #define BOOTENV_EFI_PXE_ARCH "0x19" #define BOOTENV_EFI_PXE_VCI "PXEClient:Arch:00025:UNDI:003000" -#elif defined(CONFIG_CPU_RISCV_64) || ((defined(__riscv) && __riscv_xlen == 64)) +#elif defined(CONFIG_ARCH_RV64I) || ((defined(__riscv) && __riscv_xlen == 64)) #define BOOTENV_EFI_PXE_ARCH "0x1b" #define BOOTENV_EFI_PXE_VCI "PXEClient:Arch:00027:UNDI:003000" #elif defined(CONFIG_SANDBOX) -- cgit v1.3.1 From c95cafd0b1ca984e0dbd8e1335c947d715ce0fb2 Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Thu, 22 Nov 2018 11:26:26 +0100 Subject: Drop CONFIG_INIT_CRITICAL This is now deprecated and no board is using it. Drop it. Signed-off-by: Bin Meng Signed-off-by: Lukas Auer --- arch/nds32/cpu/n1213/start.S | 51 ------------------------------------------ arch/riscv/cpu/start.S | 13 ----------- board/armltd/integrator/README | 4 +--- include/common.h | 5 ----- scripts/config_whitelist.txt | 1 - 5 files changed, 1 insertion(+), 73 deletions(-) (limited to 'include') diff --git a/arch/nds32/cpu/n1213/start.S b/arch/nds32/cpu/n1213/start.S index aa9457f5e4f..cf966e2132e 100644 --- a/arch/nds32/cpu/n1213/start.S +++ b/arch/nds32/cpu/n1213/start.S @@ -200,14 +200,6 @@ update_gp: jal turnoff_watchdog #endif -/* - * Do CPU critical regs init only at reboot, - * not when booting from ram - */ -#ifdef CONFIG_INIT_CRITICAL - jal cpu_init_crit ! Do CPU critical regs init -#endif - /* * Set stackpointer in internal RAM to call board_init_f * $sp must be 8-byte alignment for ABI compliance. @@ -318,49 +310,6 @@ call_board_init_r: /* jump to it ... */ jr $lp /* jump to board_init_r() */ -/* - * Initialize CPU critical registers - * - * 1. Setup control registers - * 1.1 Mask all IRQs - * 1.2 Flush cache and TLB - * 1.3 Disable MMU and cache - * 2. Setup memory timing - */ - -cpu_init_crit: - - move $r0, $lp /* push ra */ - - /* Disable Interrupts by clear GIE in $PSW reg */ - setgie.d - - /* Flush caches and TLB */ - /* Invalidate caches */ - jal invalidate_icac - jal invalidate_dcac - - /* Flush TLB */ - mfsr $p0, $MMU_CFG - andi $p0, $p0, 0x3 ! MMPS - li $p1, 0x2 ! TLB MMU - bne $p0, $p1, 1f - tlbop flushall ! Flush TLB - -1: - ! Disable MMU, Dcache - ! Whitiger is MMU disabled when reset - ! Disable the D$ - mfsr $p0, MR_CAC_CTL ! Get the $CACHE_CTL reg - li $p1, DIS_DCAC - and $p0, $p0, $p1 ! Set DC_EN bit - mtsr $p0, MR_CAC_CTL ! write back the $CACHE_CTL reg - isb - - move $lp, $r0 -2: - ret - /* * Invalidate I$ */ diff --git a/arch/riscv/cpu/start.S b/arch/riscv/cpu/start.S index 88b4aaa1c0e..9804a8ac441 100644 --- a/arch/riscv/cpu/start.S +++ b/arch/riscv/cpu/start.S @@ -50,14 +50,6 @@ handle_reset: csrwi mstatus, 0 csrwi mie, 0 -/* - * Do CPU critical regs init only at reboot, - * not when booting from ram - */ -#ifdef CONFIG_INIT_CRITICAL - jal cpu_init_crit /* Do CPU critical regs init */ -#endif - /* * Set stackpointer in internal/ex RAM to call board_init_f */ @@ -285,8 +277,3 @@ trap_entry: LREG x31, 31*REGBYTES(sp) addi sp, sp, 32*REGBYTES mret - -#ifdef CONFIG_INIT_CRITICAL -cpu_init_crit: - ret -#endif diff --git a/board/armltd/integrator/README b/board/armltd/integrator/README index 5a0e9349248..af9dcc1f4fc 100644 --- a/board/armltd/integrator/README +++ b/board/armltd/integrator/README @@ -36,9 +36,7 @@ In case c) it may be necessary for U-Boot to perform CM dependent initialization Configuring U-Boot : ------------------ The makefile contains targets for Integrator platforms of both types -fitted with all current variants of CM. If these targets are to be used with -boot process c) above then CONFIG_INIT_CRITICAL may need to be defined to ensure -that the CM is correctly configured. +fitted with all current variants of CM. There are also targets independent of CM. These may not be suitable for boot process c) above. They have been preserved for backward compatibility with diff --git a/include/common.h b/include/common.h index 3f699438875..8b561370326 100644 --- a/include/common.h +++ b/include/common.h @@ -549,11 +549,6 @@ int cpu_release(u32 nr, int argc, char * const argv[]); #endif #endif -#ifdef CONFIG_INIT_CRITICAL -#error CONFIG_INIT_CRITICAL is deprecated! -#error Read section CONFIG_SKIP_LOWLEVEL_INIT in README. -#endif - #define ROUND(a,b) (((a) + (b) - 1) & ~((b) - 1)) /* diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt index abfb0ff89fa..7dd9d605414 100644 --- a/scripts/config_whitelist.txt +++ b/scripts/config_whitelist.txt @@ -961,7 +961,6 @@ CONFIG_IMX_OTP CONFIG_IMX_VIDEO_SKIP CONFIG_INETSPACE_V2 CONFIG_INITRD_TAG -CONFIG_INIT_CRITICAL CONFIG_INIT_IGNORE_ERROR CONFIG_INI_ALLOW_MULTILINE CONFIG_INI_CASE_INSENSITIVE -- cgit v1.3.1 From 52b984369fde8296c735575848075462e9112b69 Mon Sep 17 00:00:00 2001 From: Lukas Auer Date: Thu, 22 Nov 2018 11:26:31 +0100 Subject: riscv: qemu: support booting Linux Support booting Linux (as payload of BBL) from FIT images. For this, the default CONFIG_SYS_BOOTM_LEN is increased to 16 MB, and the environment variables fdt_high and initrd_high are set to mark the device tree and initrd as in-place. Signed-off-by: Lukas Auer Reviewed-by: Bin Meng --- configs/qemu-riscv32_defconfig | 1 + configs/qemu-riscv64_defconfig | 1 + include/configs/qemu-riscv.h | 6 ++++++ 3 files changed, 8 insertions(+) (limited to 'include') diff --git a/configs/qemu-riscv32_defconfig b/configs/qemu-riscv32_defconfig index 72c54a3dd5c..b55644378a0 100644 --- a/configs/qemu-riscv32_defconfig +++ b/configs/qemu-riscv32_defconfig @@ -1,6 +1,7 @@ CONFIG_RISCV=y CONFIG_TARGET_QEMU_VIRT=y CONFIG_NR_DRAM_BANKS=1 +CONFIG_FIT=y CONFIG_DISPLAY_CPUINFO=y CONFIG_DISPLAY_BOARDINFO=y CONFIG_OF_PRIOR_STAGE=y diff --git a/configs/qemu-riscv64_defconfig b/configs/qemu-riscv64_defconfig index 44766c38f60..a542ac48939 100644 --- a/configs/qemu-riscv64_defconfig +++ b/configs/qemu-riscv64_defconfig @@ -2,6 +2,7 @@ CONFIG_RISCV=y CONFIG_TARGET_QEMU_VIRT=y CONFIG_ARCH_RV64I=y CONFIG_NR_DRAM_BANKS=1 +CONFIG_FIT=y CONFIG_DISPLAY_CPUINFO=y CONFIG_DISPLAY_BOARDINFO=y CONFIG_OF_PRIOR_STAGE=y diff --git a/include/configs/qemu-riscv.h b/include/configs/qemu-riscv.h index d279c233b2c..ba6a18f2e66 100644 --- a/include/configs/qemu-riscv.h +++ b/include/configs/qemu-riscv.h @@ -15,7 +15,13 @@ #define CONFIG_SYS_MALLOC_LEN SZ_8M +#define CONFIG_SYS_BOOTM_LEN SZ_16M + /* Environment options */ #define CONFIG_ENV_SIZE SZ_4K +#define CONFIG_EXTRA_ENV_SETTINGS \ + "fdt_high=0xffffffffffffffff\0" \ + "initrd_high=0xffffffffffffffff\0" + #endif /* __CONFIG_H */ -- cgit v1.3.1 From a8da9ff46623acee32b7fe9a5b08a0e88e71166e Mon Sep 17 00:00:00 2001 From: Lukas Auer Date: Thu, 22 Nov 2018 11:26:33 +0100 Subject: distro_bootcmd: add VirtIO distro boot command Add a boot command to distro boot to support disks connected over the VirtIO bus. The boot command uses the shared block environment. Signed-off-by: Lukas Auer Reviewed-by: Bin Meng Reviewed-by: Alexander Graf --- doc/README.distro | 3 ++- include/config_distro_bootcmd.h | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/doc/README.distro b/doc/README.distro index f8e9752a0fa..ab6e6f4e74b 100644 --- a/doc/README.distro +++ b/doc/README.distro @@ -292,7 +292,7 @@ Each entry in the macro defines a single boot device (e.g. a specific eMMC device or SD card) or type of boot device (e.g. USB disk). The parameters to the func macro (passed in by the internal implementation of the header) are: -- Upper-case disk type (MMC, SATA, SCSI, IDE, USB, DHCP, PXE). +- Upper-case disk type (MMC, SATA, SCSI, IDE, USB, DHCP, PXE, VIRTIO). - Lower-case disk type (same options as above). - ID of the specific disk (MMC only) or ignored for other types. @@ -398,6 +398,7 @@ The list of possible targets consists of: * scsi * ide * usb + * virtio Other *boot* variables than the ones defined above are only for internal use of the boot environment and are not guaranteed to exist or work in the same diff --git a/include/config_distro_bootcmd.h b/include/config_distro_bootcmd.h index d06974c58cf..555efb7433f 100644 --- a/include/config_distro_bootcmd.h +++ b/include/config_distro_bootcmd.h @@ -242,6 +242,18 @@ BOOT_TARGET_DEVICES_references_USB_without_CONFIG_CMD_USB #endif +#ifdef CONFIG_CMD_VIRTIO +#define BOOTENV_SHARED_VIRTIO BOOTENV_SHARED_BLKDEV(virtio) +#define BOOTENV_DEV_VIRTIO BOOTENV_DEV_BLKDEV +#define BOOTENV_DEV_NAME_VIRTIO BOOTENV_DEV_NAME_BLKDEV +#else +#define BOOTENV_SHARED_VIRTIO +#define BOOTENV_DEV_VIRTIO \ + BOOT_TARGET_DEVICES_references_VIRTIO_without_CONFIG_CMD_VIRTIO +#define BOOTENV_DEV_NAME_VIRTIO \ + BOOT_TARGET_DEVICES_references_VIRTIO_without_CONFIG_CMD_VIRTIO +#endif + #if defined(CONFIG_CMD_DHCP) #if defined(CONFIG_EFI_LOADER) /* http://www.iana.org/assignments/dhcpv6-parameters/dhcpv6-parameters.xml */ @@ -350,6 +362,7 @@ BOOTENV_SHARED_IDE \ BOOTENV_SHARED_UBIFS \ BOOTENV_SHARED_EFI \ + BOOTENV_SHARED_VIRTIO \ "boot_prefixes=/ /boot/\0" \ "boot_scripts=boot.scr.uimg boot.scr\0" \ "boot_script_dhcp=boot.scr.uimg\0" \ -- cgit v1.3.1 From 111ab36fb66f3de92d2c12c5c1cfef30ef7a507c Mon Sep 17 00:00:00 2001 From: Lukas Auer Date: Thu, 22 Nov 2018 11:26:34 +0100 Subject: riscv: qemu: enable distro boot Enable distro boot on the qemu-riscv32/64 boards. Supported boot target devices are VirtIO and DHCP. Signed-off-by: Lukas Auer Reviewed-by: Bin Meng Reviewed-by: Alexander Graf --- configs/qemu-riscv32_defconfig | 2 ++ configs/qemu-riscv64_defconfig | 2 ++ include/configs/qemu-riscv.h | 14 +++++++++++++- 3 files changed, 17 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/configs/qemu-riscv32_defconfig b/configs/qemu-riscv32_defconfig index b55644378a0..6334d8c0fc7 100644 --- a/configs/qemu-riscv32_defconfig +++ b/configs/qemu-riscv32_defconfig @@ -1,7 +1,9 @@ CONFIG_RISCV=y CONFIG_TARGET_QEMU_VIRT=y +CONFIG_DISTRO_DEFAULTS=y CONFIG_NR_DRAM_BANKS=1 CONFIG_FIT=y CONFIG_DISPLAY_CPUINFO=y CONFIG_DISPLAY_BOARDINFO=y +# CONFIG_CMD_MII is not set CONFIG_OF_PRIOR_STAGE=y diff --git a/configs/qemu-riscv64_defconfig b/configs/qemu-riscv64_defconfig index a542ac48939..2d9ead93a28 100644 --- a/configs/qemu-riscv64_defconfig +++ b/configs/qemu-riscv64_defconfig @@ -1,8 +1,10 @@ CONFIG_RISCV=y CONFIG_TARGET_QEMU_VIRT=y CONFIG_ARCH_RV64I=y +CONFIG_DISTRO_DEFAULTS=y CONFIG_NR_DRAM_BANKS=1 CONFIG_FIT=y CONFIG_DISPLAY_CPUINFO=y CONFIG_DISPLAY_BOARDINFO=y +# CONFIG_CMD_MII is not set CONFIG_OF_PRIOR_STAGE=y diff --git a/include/configs/qemu-riscv.h b/include/configs/qemu-riscv.h index ba6a18f2e66..66d61bd896d 100644 --- a/include/configs/qemu-riscv.h +++ b/include/configs/qemu-riscv.h @@ -20,8 +20,20 @@ /* Environment options */ #define CONFIG_ENV_SIZE SZ_4K +#define BOOT_TARGET_DEVICES(func) \ + func(VIRTIO, virtio, 0) \ + func(DHCP, dhcp, na) + +#include + #define CONFIG_EXTRA_ENV_SETTINGS \ "fdt_high=0xffffffffffffffff\0" \ - "initrd_high=0xffffffffffffffff\0" + "initrd_high=0xffffffffffffffff\0" \ + "kernel_addr_r=0x81000000\0" \ + "fdt_addr_r=0x82000000\0" \ + "scriptaddr=0x82100000\0" \ + "pxefile_addr_r=0x82200000\0" \ + "ramdisk_addr_r=0x82300000\0" \ + BOOTENV #endif /* __CONFIG_H */ -- cgit v1.3.1 From afb301295363391f588f37696c27795cd7c0ffc4 Mon Sep 17 00:00:00 2001 From: Lukas Auer Date: Thu, 22 Nov 2018 11:26:35 +0100 Subject: dm: core: add missing prototype for ofnode_read_u64 Signed-off-by: Lukas Auer Reviewed-by: Bin Meng Reviewed-by: Simon Glass --- include/dm/ofnode.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'include') diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h index 2fc9fa39a35..92539b8b5f2 100644 --- a/include/dm/ofnode.h +++ b/include/dm/ofnode.h @@ -236,6 +236,16 @@ int ofnode_read_u32_default(ofnode ref, const char *propname, u32 def); */ int ofnode_read_s32_default(ofnode node, const char *propname, s32 def); +/** + * ofnode_read_u64() - Read a 64-bit integer from a property + * + * @node: valid node reference to read property from + * @propname: name of the property to read from + * @outp: place to put value (if found) + * @return 0 if OK, -ve on error + */ +int ofnode_read_u64(ofnode node, const char *propname, u64 *outp); + /** * ofnode_read_u64_default() - Read a 64-bit integer from a property * -- cgit v1.3.1 From 66ffe5783b6340977ead5782cce9b63edfc0e348 Mon Sep 17 00:00:00 2001 From: Lukas Auer Date: Thu, 22 Nov 2018 11:26:36 +0100 Subject: riscv: qemu: detect and boot the kernel passed by QEMU QEMU embeds the location of the kernel image in the device tree. Store this address in the environment as variable kernel_start. It is used in the board-local distro boot command QEMU to boot the kernel with the U-Boot device tree. The QEMU boot command is added as the first boot target device. Signed-off-by: Lukas Auer Reviewed-by: Bin Meng Reviewed-by: Alexander Graf --- board/emulation/qemu-riscv/Kconfig | 1 + board/emulation/qemu-riscv/qemu-riscv.c | 29 +++++++++++++++++++++++++++++ include/configs/qemu-riscv.h | 10 ++++++++++ 3 files changed, 40 insertions(+) (limited to 'include') diff --git a/board/emulation/qemu-riscv/Kconfig b/board/emulation/qemu-riscv/Kconfig index 37a80db6a94..be5839b7dba 100644 --- a/board/emulation/qemu-riscv/Kconfig +++ b/board/emulation/qemu-riscv/Kconfig @@ -29,5 +29,6 @@ config BOARD_SPECIFIC_OPTIONS # dummy imply CMD_EXT2 imply CMD_EXT4 imply CMD_FAT + imply BOARD_LATE_INIT endif diff --git a/board/emulation/qemu-riscv/qemu-riscv.c b/board/emulation/qemu-riscv/qemu-riscv.c index 2ce093e19a9..587f2c49094 100644 --- a/board/emulation/qemu-riscv/qemu-riscv.c +++ b/board/emulation/qemu-riscv/qemu-riscv.c @@ -19,3 +19,32 @@ int board_init(void) return 0; } + +int board_late_init(void) +{ + ulong kernel_start; + ofnode chosen_node; + int ret; + + chosen_node = ofnode_path("/chosen"); + if (!ofnode_valid(chosen_node)) { + debug("No chosen node found, can't get kernel start address\n"); + return 0; + } + +#ifdef CONFIG_ARCH_RV64I + ret = ofnode_read_u64(chosen_node, "riscv,kernel-start", + (u64 *)&kernel_start); +#else + ret = ofnode_read_u32(chosen_node, "riscv,kernel-start", + (u32 *)&kernel_start); +#endif + if (ret) { + debug("Can't find kernel start address in device tree\n"); + return 0; + } + + env_set_hex("kernel_start", kernel_start); + + return 0; +} diff --git a/include/configs/qemu-riscv.h b/include/configs/qemu-riscv.h index 66d61bd896d..b29d155d095 100644 --- a/include/configs/qemu-riscv.h +++ b/include/configs/qemu-riscv.h @@ -21,11 +21,21 @@ #define CONFIG_ENV_SIZE SZ_4K #define BOOT_TARGET_DEVICES(func) \ + func(QEMU, qemu, na) \ func(VIRTIO, virtio, 0) \ func(DHCP, dhcp, na) #include +#define BOOTENV_DEV_QEMU(devtypeu, devtypel, instance) \ + "bootcmd_qemu=" \ + "if env exists kernel_start; then " \ + "bootm ${kernel_start} - ${fdtcontroladdr};" \ + "fi;\0" + +#define BOOTENV_DEV_NAME_QEMU(devtypeu, devtypel, instance) \ + "qemu " + #define CONFIG_EXTRA_ENV_SETTINGS \ "fdt_high=0xffffffffffffffff\0" \ "initrd_high=0xffffffffffffffff\0" \ -- cgit v1.3.1