From 3e9952be23e1fdc8b576dfeed80e442d3045cd87 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Sat, 28 Jan 2017 06:53:43 +0900 Subject: ARM: uniphier: detect RAM size by decoding HW register instead of DT U-Boot needs to set up available memory area(s) in dram_init() and dram_init_banksize(). It is platform-dependent how to detect the memory banks. Currently, UniPhier adopts the memory banks _alleged_ by DT. This is based on the assumption that users bind a correct DT in their build process. Come to think of it, the DRAM controller has already been set up before U-Boot is entered (because U-Boot runs on DRAM). So, the DRAM controller setup register seems a more reliable source of any information about DRAM stuff. The DRAM banks are initialized by preliminary firmware (SPL, ARM Trusted Firmware BL2, or whatever), so this means the source of the reliability is shifted from Device Tree to such early-stage firmware. However, if the DRAM controller is wrongly configured, the system will crash. If your system is running, the DRAM setup register is very likely to provide the correct DRAM mapping. Decode the SG_MEMCONF register to get the available DRAM banks. The dram_init() and dram_init_banksize() need similar decoding. It would be nice if dram_init_banksize() could reuse the outcome of dram_init(), but global variables are unavailable at this stage because the .bss section is available only after the relocation. As a result, SG_MEMCONF must be checked twice, but a new helper uniphier_memconf_decode() will help to avoid code duplication. Signed-off-by: Masahiro Yamada --- include/configs/uniphier.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/configs/uniphier.h') diff --git a/include/configs/uniphier.h b/include/configs/uniphier.h index c991b2d..a6deda8 100644 --- a/include/configs/uniphier.h +++ b/include/configs/uniphier.h @@ -236,7 +236,7 @@ #define CONFIG_SYS_BOOTMAPSZ 0x20000000 #define CONFIG_SYS_SDRAM_BASE 0x80000000 -#define CONFIG_NR_DRAM_BANKS 2 +#define CONFIG_NR_DRAM_BANKS 3 /* for LD20; the last 64 byte is used for dynamic DDR PHY training */ #define CONFIG_SYS_MEM_TOP_HIDE 64 -- cgit v1.1 From 3e0cfaa05d38779a0118756b3cbf9bf7a5412eb5 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Sat, 28 Jan 2017 06:53:49 +0900 Subject: ARM: uniphier: collect SPL CONFIG symbols to the bottom of header For clarification, move CONFIG symbols that affect SPL building into a single place. Drop #ifdef CONFIG_SPL ... #endif since it is harmless to define CONFIG_SPL_... during U-Boot proper building. Signed-off-by: Masahiro Yamada --- include/configs/uniphier.h | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'include/configs/uniphier.h') diff --git a/include/configs/uniphier.h b/include/configs/uniphier.h index a6deda8..90876e3 100644 --- a/include/configs/uniphier.h +++ b/include/configs/uniphier.h @@ -98,7 +98,6 @@ #define CONFIG_SYS_TIMER_RATE 1000000 #endif - #define CONFIG_SYS_MAX_NAND_DEVICE 1 #define CONFIG_SYS_NAND_MAX_CHIPS 2 #define CONFIG_SYS_NAND_ONFI_DETECTION @@ -240,6 +239,11 @@ /* for LD20; the last 64 byte is used for dynamic DDR PHY training */ #define CONFIG_SYS_MEM_TOP_HIDE 64 +#define CONFIG_PANIC_HANG + +#define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_TEXT_BASE) + +/* only for SPL */ #if defined(CONFIG_ARM64) #define CONFIG_SPL_TEXT_BASE 0x30000000 #elif defined(CONFIG_ARCH_UNIPHIER_SLD3) || \ @@ -257,9 +261,6 @@ #else #define CONFIG_SPL_STACK (0x00100000) #endif -#define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_TEXT_BASE) - -#define CONFIG_PANIC_HANG #define CONFIG_SPL_FRAMEWORK #ifdef CONFIG_ARM64 @@ -273,7 +274,6 @@ /* subtract sizeof(struct image_header) */ #define CONFIG_SYS_UBOOT_BASE (0x60000 - 0x40) -#ifdef CONFIG_SPL #define CONFIG_SPL_TARGET "u-boot-with-spl.bin" #define CONFIG_SPL_MAX_FOOTPRINT 0x10000 #define CONFIG_SPL_MAX_SIZE 0x10000 @@ -283,6 +283,5 @@ #define CONFIG_SPL_BSS_START_ADDR 0x30016000 #endif #define CONFIG_SPL_BSS_MAX_SIZE 0x2000 -#endif #endif /* __CONFIG_UNIPHIER_COMMON_H__ */ -- cgit v1.1 From 99b8517037f212a3cf4bf75ed99fa877fe4e6d9d Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Sat, 28 Jan 2017 06:53:50 +0900 Subject: ARM: uniphier: use Image.gz instead Image for booting ARM64 Linux The ARM64 Linux raw image now amounts to 15MB and it is getting bigger and bigger. Using Image.gz saves about 8MB. The cost of unzip is smaller than what we get by saving the kernel loading from non-volatile devices. The ARM32 Linux still uses zImage, a self-decompressor image, so it should not be affected. Signed-off-by: Masahiro Yamada --- include/configs/uniphier.h | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) (limited to 'include/configs/uniphier.h') diff --git a/include/configs/uniphier.h b/include/configs/uniphier.h index 90876e3..5507f84 100644 --- a/include/configs/uniphier.h +++ b/include/configs/uniphier.h @@ -15,6 +15,10 @@ #define CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS 10 +#ifdef CONFIG_ARM64 +#define CONFIG_CMD_UNZIP +#endif + /*----------------------------------------------------------------------- * MMU and Cache Setting *----------------------------------------------------------------------*/ @@ -166,46 +170,50 @@ "__nfsboot=run tftpboot\0" #else #ifdef CONFIG_ARM64 -#define CONFIG_BOOTFILE "Image" +#define CONFIG_BOOTFILE "Image.gz" #define LINUXBOOT_CMD "booti" +#define KERNEL_ADDR_LOAD "kernel_addr_load=0x84200000\0" #define KERNEL_ADDR_R "kernel_addr_r=0x80080000\0" -#define KERNEL_SIZE "kernel_size=0x00c00000\0" -#define RAMDISK_ADDR "ramdisk_addr=0x00e00000\0" #else #define CONFIG_BOOTFILE "zImage" #define LINUXBOOT_CMD "bootz" +#define KERNEL_ADDR_LOAD "kernel_addr_load=0x80208000\0" #define KERNEL_ADDR_R "kernel_addr_r=0x80208000\0" -#define KERNEL_SIZE "kernel_size=0x00800000\0" -#define RAMDISK_ADDR "ramdisk_addr=0x00a00000\0" #endif #define LINUXBOOT_ENV_SETTINGS \ "fdt_addr=0x00100000\0" \ "fdt_addr_r=0x84100000\0" \ "fdt_size=0x00008000\0" \ "kernel_addr=0x00200000\0" \ + KERNEL_ADDR_LOAD \ KERNEL_ADDR_R \ - KERNEL_SIZE \ - RAMDISK_ADDR \ + "kernel_size=0x00800000\0" \ + "ramdisk_addr=0x00a00000\0" \ "ramdisk_addr_r=0x84a00000\0" \ "ramdisk_size=0x00600000\0" \ "ramdisk_file=rootfs.cpio.uboot\0" \ - "boot_common=setexpr bootm_low $kernel_addr_r '&' fe000000 &&" \ + "boot_common=setexpr bootm_low $kernel_addr_r '&' fe000000 && " \ + "if test $kernel_addr_load = $kernel_addr_r; then " \ + "true; " \ + "else " \ + "unzip $kernel_addr_load $kernel_addr_r; " \ + "fi && " \ LINUXBOOT_CMD " $kernel_addr_r $ramdisk_addr_r $fdt_addr_r\0" \ - "norboot=setexpr kernel_addr $nor_base + $kernel_addr &&" \ - "setexpr kernel_size $kernel_size / 4 &&" \ - "cp $kernel_addr $kernel_addr_r $kernel_size &&" \ + "norboot=setexpr kernel_addr_nor $nor_base + $kernel_addr && " \ + "setexpr kernel_size_div4 $kernel_size / 4 && " \ + "cp $kernel_addr_nor $kernel_addr_load $kernel_size_div4 && " \ "setexpr ramdisk_addr_r $nor_base + $ramdisk_addr &&" \ "setexpr fdt_addr_r $nor_base + $fdt_addr &&" \ "run boot_common\0" \ - "nandboot=nand read $kernel_addr_r $kernel_addr $kernel_size &&" \ + "nandboot=nand read $kernel_addr_load $kernel_addr $kernel_size && " \ "nand read $ramdisk_addr_r $ramdisk_addr $ramdisk_size &&" \ "nand read $fdt_addr_r $fdt_addr $fdt_size &&" \ "run boot_common\0" \ - "tftpboot=tftpboot $kernel_addr_r $bootfile &&" \ + "tftpboot=tftpboot $kernel_addr_load $bootfile && " \ "tftpboot $ramdisk_addr_r $ramdisk_file &&" \ "tftpboot $fdt_addr_r $fdt_file &&" \ "run boot_common\0" \ - "__nfsboot=tftpboot $kernel_addr_r $bootfile &&" \ + "__nfsboot=tftpboot $kernel_addr_load $bootfile && " \ "tftpboot $fdt_addr_r $fdt_file &&" \ "setenv ramdisk_addr_r - &&" \ "run boot_common\0" -- cgit v1.1 From c0df1fafd764aa41e1b5762af377c7dea296e600 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Sat, 28 Jan 2017 06:53:51 +0900 Subject: ARM: uniphier: set initrd_high environment to skip initrd relocation The boot_ramdisk_high() checks the environment "initrd_high" and, if it is set to (ulong)-1, skip the initrd relocation. This is useful for faster booting when we know the initrd is already located within the reach of the kernel. Change "norboot" to copy images in order to make it work without depending on the automatic relocation. Signed-off-by: Masahiro Yamada --- include/configs/uniphier.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'include/configs/uniphier.h') diff --git a/include/configs/uniphier.h b/include/configs/uniphier.h index 5507f84..d6dd5ec 100644 --- a/include/configs/uniphier.h +++ b/include/configs/uniphier.h @@ -202,8 +202,12 @@ "norboot=setexpr kernel_addr_nor $nor_base + $kernel_addr && " \ "setexpr kernel_size_div4 $kernel_size / 4 && " \ "cp $kernel_addr_nor $kernel_addr_load $kernel_size_div4 && " \ - "setexpr ramdisk_addr_r $nor_base + $ramdisk_addr &&" \ - "setexpr fdt_addr_r $nor_base + $fdt_addr &&" \ + "setexpr ramdisk_addr_nor $nor_base + $ramdisk_addr && " \ + "setexpr ramdisk_size_div4 $ramdisk_size / 4 && " \ + "cp $ramdisk_addr_nor $ramdisk_addr_r $ramdisk_size_div4 && " \ + "setexpr fdt_addr_nor $nor_base + $fdt_addr && " \ + "setexpr fdt_size_div4 $fdt_size / 4 && " \ + "cp $fdt_addr_nor $fdt_addr_r $fdt_size_div4 && " \ "run boot_common\0" \ "nandboot=nand read $kernel_addr_load $kernel_addr $kernel_size && " \ "nand read $ramdisk_addr_r $ramdisk_addr $ramdisk_size &&" \ @@ -222,6 +226,7 @@ #define CONFIG_EXTRA_ENV_SETTINGS \ "netdev=eth0\0" \ "verify=n\0" \ + "initrd_high=0xffffffffffffffff\0" \ "nor_base=0x42000000\0" \ "sramupdate=setexpr tmp_addr $nor_base + 0x50000 &&" \ "tftpboot $tmp_addr u-boot-spl.bin &&" \ -- cgit v1.1 From 0b93e3de1e5ec9c7db7ffcf33bc9dcaddff91109 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Sat, 28 Jan 2017 06:53:52 +0900 Subject: ARM: uniphier: change the offset to environment storage area When ARM Trusted Firmware is used, bl1.bin + fip.bin exceeds 512KB, so the boot image and the current environment area will overlap. Move the environment storage to 1MB offset. Signed-off-by: Masahiro Yamada --- include/configs/uniphier.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/configs/uniphier.h') diff --git a/include/configs/uniphier.h b/include/configs/uniphier.h index d6dd5ec..817bf45 100644 --- a/include/configs/uniphier.h +++ b/include/configs/uniphier.h @@ -80,7 +80,7 @@ /* #define CONFIG_ENV_IS_NOWHERE */ /* #define CONFIG_ENV_IS_IN_NAND */ #define CONFIG_ENV_IS_IN_MMC -#define CONFIG_ENV_OFFSET 0x80000 +#define CONFIG_ENV_OFFSET 0x100000 #define CONFIG_ENV_SIZE 0x2000 /* #define CONFIG_ENV_OFFSET_REDUND (CONFIG_ENV_OFFSET + CONFIG_ENV_SIZE) */ -- cgit v1.1 From c0efc3140e75e3ffd6127a5aec97b75347ec7417 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Sat, 28 Jan 2017 06:53:53 +0900 Subject: ARM: uniphier: change CONFIG_SPL_PAD_TO to 128KB The Boot ROM supports authentication feature to prevent malformed software from being run on products. The signature is added at the tail of the second stage loader (= SPL in U-boot terminology). The size of the second stage loader was 64KB, and it was consistent across SoCs. The situation changed when LD20 SoC appeared; it loads 80KB second stage loader, and it is the only exception. Currently, CONFIG_SPL_PAD_TO is set to 64KB and U-Boot proper is loaded from the 64KB offset of non-volatile devices. This means the signature of LD20 SoC (located at 80KB offset) corrupts the U-Boot proper image. Let's move the U-Boot proper image to 128KB offset. It uses 48KB for nothing but padding, and we could actually locate the U-Boot proper at 80KB offset. However, the power of 2 generally seems a better choice for the offset address. Signed-off-by: Masahiro Yamada --- include/configs/uniphier.h | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'include/configs/uniphier.h') diff --git a/include/configs/uniphier.h b/include/configs/uniphier.h index 817bf45..49309c9 100644 --- a/include/configs/uniphier.h +++ b/include/configs/uniphier.h @@ -230,19 +230,19 @@ "nor_base=0x42000000\0" \ "sramupdate=setexpr tmp_addr $nor_base + 0x50000 &&" \ "tftpboot $tmp_addr u-boot-spl.bin &&" \ - "setexpr tmp_addr $nor_base + 0x60000 &&" \ + "setexpr tmp_addr $nor_base + 0x70000 && " \ "tftpboot $tmp_addr u-boot.bin\0" \ "emmcupdate=mmcsetn &&" \ "mmc partconf $mmc_first_dev 0 1 1 &&" \ "tftpboot u-boot-spl.bin &&" \ - "mmc write $loadaddr 0 80 &&" \ + "mmc write $loadaddr 0 100 && " \ "tftpboot u-boot.bin &&" \ - "mmc write $loadaddr 80 780\0" \ + "mmc write $loadaddr 100 700\0" \ "nandupdate=nand erase 0 0x00100000 &&" \ "tftpboot u-boot-spl.bin &&" \ - "nand write $loadaddr 0 0x00010000 &&" \ + "nand write $loadaddr 0 0x00020000 && " \ "tftpboot u-boot.bin &&" \ - "nand write $loadaddr 0x00010000 0x000f0000\0" \ + "nand write $loadaddr 0x00020000 0x000e0000\0" \ LINUXBOOT_ENV_SETTINGS #define CONFIG_SYS_BOOTMAPSZ 0x20000000 @@ -282,14 +282,18 @@ #define CONFIG_SPL_BOARD_INIT -#define CONFIG_SYS_NAND_U_BOOT_OFFS 0x10000 +#define CONFIG_SYS_NAND_U_BOOT_OFFS 0x20000 /* subtract sizeof(struct image_header) */ -#define CONFIG_SYS_UBOOT_BASE (0x60000 - 0x40) +#define CONFIG_SYS_UBOOT_BASE (0x70000 - 0x40) #define CONFIG_SPL_TARGET "u-boot-with-spl.bin" #define CONFIG_SPL_MAX_FOOTPRINT 0x10000 +#if defined(CONFIG_ARCH_UNIPHIER_LD20) +#define CONFIG_SPL_MAX_SIZE 0x14000 +#else #define CONFIG_SPL_MAX_SIZE 0x10000 +#endif #if defined(CONFIG_ARCH_UNIPHIER_LD11) #define CONFIG_SPL_BSS_START_ADDR 0x30012000 #elif defined(CONFIG_ARCH_UNIPHIER_LD20) @@ -297,4 +301,6 @@ #endif #define CONFIG_SPL_BSS_MAX_SIZE 0x2000 +#define CONFIG_SPL_PAD_TO 0x20000 + #endif /* __CONFIG_UNIPHIER_COMMON_H__ */ -- cgit v1.1 From b7b4303642af1cf3a2c58befaa8e8944b9fbb3c9 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Sat, 28 Jan 2017 06:53:54 +0900 Subject: ARM: uniphier: make update commands more flexible for ATF Currently, SPL (u-boot-spl.bin) and U-Boot (u-boot.bin) are stored in non-volatile devices, and some environments are defined to update the images easily. When ARM Trusted Firmware is fully used, SPL is not used. U-Boot proper is contained as BL33 into FIP (Firmware Image Package), which is standard container used by ATF. Allow to use it. Signed-off-by: Masahiro Yamada --- include/configs/uniphier.h | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'include/configs/uniphier.h') diff --git a/include/configs/uniphier.h b/include/configs/uniphier.h index 49309c9..62c3daf 100644 --- a/include/configs/uniphier.h +++ b/include/configs/uniphier.h @@ -146,6 +146,17 @@ #define CONFIG_CMDLINE_EDITING /* add command line history */ +#if defined(CONFIG_ARM64) && !defined(CONFIG_ARMV8_MULTIENTRY) +/* ARM Trusted Firmware */ +#define BOOT_IMAGES \ + "second_image=bl1.bin\0" \ + "third_image=fip.bin\0" +#else +#define BOOT_IMAGES \ + "second_image=u-boot-spl.bin\0" \ + "third_image=u-boot.bin\0" +#endif + #define CONFIG_BOOTCOMMAND "run $bootmode" #define CONFIG_ROOTPATH "/nfs/root/path" @@ -229,20 +240,21 @@ "initrd_high=0xffffffffffffffff\0" \ "nor_base=0x42000000\0" \ "sramupdate=setexpr tmp_addr $nor_base + 0x50000 &&" \ - "tftpboot $tmp_addr u-boot-spl.bin &&" \ + "tftpboot $tmp_addr $second_image && " \ "setexpr tmp_addr $nor_base + 0x70000 && " \ - "tftpboot $tmp_addr u-boot.bin\0" \ + "tftpboot $tmp_addr $third_image\0" \ "emmcupdate=mmcsetn &&" \ "mmc partconf $mmc_first_dev 0 1 1 &&" \ - "tftpboot u-boot-spl.bin &&" \ + "tftpboot $second_image && " \ "mmc write $loadaddr 0 100 && " \ - "tftpboot u-boot.bin &&" \ + "tftpboot $third_image && " \ "mmc write $loadaddr 100 700\0" \ "nandupdate=nand erase 0 0x00100000 &&" \ - "tftpboot u-boot-spl.bin &&" \ + "tftpboot $second_image && " \ "nand write $loadaddr 0 0x00020000 && " \ - "tftpboot u-boot.bin &&" \ + "tftpboot $third_image && " \ "nand write $loadaddr 0x00020000 0x000e0000\0" \ + BOOT_IMAGES \ LINUXBOOT_ENV_SETTINGS #define CONFIG_SYS_BOOTMAPSZ 0x20000000 -- cgit v1.1