From 6bc50a8f69920b2d2b0c5890e2133748b62656c3 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Wed, 19 Dec 2018 20:03:13 +0900 Subject: ARM: uniphier: do not modify bootcmd environment variable at run-time Some users might want to modify 'bootcmd' at compile-time by editing include/configs/uniphier.h, but overwriting it at run-time makes it impossible. Instead, set 'bootdev' at run-time, which contains the boot device the system is booting from, then indirectly reference it from 'bootcmd'. It is up to users whether to override 'bootcmd'. Signed-off-by: Masahiro Yamada --- include/configs/uniphier.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include') diff --git a/include/configs/uniphier.h b/include/configs/uniphier.h index 70f8712b60c..7d14c31e0f0 100644 --- a/include/configs/uniphier.h +++ b/include/configs/uniphier.h @@ -171,6 +171,10 @@ "initrd_high=0xffffffffffffffff\0" \ "scriptaddr=0x85000000\0" \ "nor_base=0x42000000\0" \ + "emmcboot=mmcsetn && run bootcmd_mmc${mmc_first_dev}\0" \ + "nandboot=run bootcmd_ubifs0\0" \ + "norboot=run tftpboot\0" \ + "usbboot=run bootcmd_usb0\0" \ "sramupdate=setexpr tmp_addr $nor_base + 0x50000 &&" \ "tftpboot $tmp_addr $second_image && " \ "setexpr tmp_addr $nor_base + 0x70000 && " \ -- cgit v1.3.1 From 9f9edb6fe37bbcf8471389f4942a21b9633ef99d Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Wed, 19 Dec 2018 20:03:14 +0900 Subject: ARM: uniphier: allow to source boot script before distro-boot Some users might need additional setups before booting the kernel. If there is found a file 'boot.scr', run it before invoking the distro boot command. Signed-off-by: Masahiro Yamada --- configs/uniphier_ld4_sld8_defconfig | 2 +- configs/uniphier_v7_defconfig | 2 +- configs/uniphier_v8_defconfig | 2 +- include/configs/uniphier.h | 20 ++++++++++++++++++++ 4 files changed, 23 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/configs/uniphier_ld4_sld8_defconfig b/configs/uniphier_ld4_sld8_defconfig index bede166efa7..98a00170702 100644 --- a/configs/uniphier_ld4_sld8_defconfig +++ b/configs/uniphier_ld4_sld8_defconfig @@ -9,7 +9,7 @@ CONFIG_ARCH_UNIPHIER_LD4_SLD8=y CONFIG_MICRO_SUPPORT_CARD=y CONFIG_NR_DRAM_BANKS=3 # CONFIG_ARCH_FIXUP_FDT_MEMORY is not set -CONFIG_BOOTCOMMAND="run ${bootdev}boot" +CONFIG_BOOTCOMMAND="run ${bootdev}script; run ${bootdev}boot" CONFIG_LOGLEVEL=6 CONFIG_SPL_NAND_SUPPORT=y CONFIG_SPL_NOR_SUPPORT=y diff --git a/configs/uniphier_v7_defconfig b/configs/uniphier_v7_defconfig index be4ab7c0cf2..bba8e180a5c 100644 --- a/configs/uniphier_v7_defconfig +++ b/configs/uniphier_v7_defconfig @@ -8,7 +8,7 @@ CONFIG_SPL=y CONFIG_MICRO_SUPPORT_CARD=y CONFIG_NR_DRAM_BANKS=3 # CONFIG_ARCH_FIXUP_FDT_MEMORY is not set -CONFIG_BOOTCOMMAND="run ${bootdev}boot" +CONFIG_BOOTCOMMAND="run ${bootdev}script; run ${bootdev}boot" CONFIG_LOGLEVEL=6 CONFIG_SPL_NAND_SUPPORT=y CONFIG_SPL_NOR_SUPPORT=y diff --git a/configs/uniphier_v8_defconfig b/configs/uniphier_v8_defconfig index 6f7c269f849..df6c5119b05 100644 --- a/configs/uniphier_v8_defconfig +++ b/configs/uniphier_v8_defconfig @@ -7,7 +7,7 @@ CONFIG_ARCH_UNIPHIER_V8_MULTI=y CONFIG_MICRO_SUPPORT_CARD=y CONFIG_NR_DRAM_BANKS=3 # CONFIG_ARCH_FIXUP_FDT_MEMORY is not set -CONFIG_BOOTCOMMAND="run ${bootdev}boot" +CONFIG_BOOTCOMMAND="run ${bootdev}script; run ${bootdev}boot" CONFIG_LOGLEVEL=6 CONFIG_CMD_CONFIG=y CONFIG_CMD_IMLS=y diff --git a/include/configs/uniphier.h b/include/configs/uniphier.h index 7d14c31e0f0..1e509ce9ad7 100644 --- a/include/configs/uniphier.h +++ b/include/configs/uniphier.h @@ -169,12 +169,32 @@ #define CONFIG_EXTRA_ENV_SETTINGS \ "netdev=eth0\0" \ "initrd_high=0xffffffffffffffff\0" \ + "script=boot.scr\0" \ "scriptaddr=0x85000000\0" \ "nor_base=0x42000000\0" \ "emmcboot=mmcsetn && run bootcmd_mmc${mmc_first_dev}\0" \ "nandboot=run bootcmd_ubifs0\0" \ "norboot=run tftpboot\0" \ "usbboot=run bootcmd_usb0\0" \ + "emmcscript=setenv devtype mmc && " \ + "mmcsetn && " \ + "setenv devnum ${mmc_first_dev} && " \ + "run loadscript_fat\0" \ + "nandscript=echo Running ${script} from ubi ... && " \ + "ubi part UBI && " \ + "ubifsmount ubi0:boot && " \ + "ubifsload ${loadaddr} ${script} && " \ + "source\0" \ + "norscript=echo Running ${script} from tftp ... && " \ + "tftpboot ${script} &&" \ + "source\0" \ + "usbscript=usb start && " \ + "setenv devtype usb && " \ + "setenv devnum 0 && " \ + "run loadscript_fat\0" \ + "loadscript_fat=echo Running ${script} from ${devtype}${devnum} ... && " \ + "load ${devtype} ${devnum}:1 ${loadaddr} ${script} && " \ + "source\0" \ "sramupdate=setexpr tmp_addr $nor_base + 0x50000 &&" \ "tftpboot $tmp_addr $second_image && " \ "setexpr tmp_addr $nor_base + 0x70000 && " \ -- cgit v1.3.1 From ce480791f74859b6bac9327ee8083cb3c698d0e9 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Wed, 19 Dec 2018 20:03:15 +0900 Subject: ARM: uniphier: add CONFIG_PREBOOT For more boot-flow flexibility, Signed-off-by: Masahiro Yamada --- include/configs/uniphier.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/configs/uniphier.h b/include/configs/uniphier.h index 1e509ce9ad7..95d64525535 100644 --- a/include/configs/uniphier.h +++ b/include/configs/uniphier.h @@ -124,6 +124,8 @@ "third_image=u-boot.bin\0" #endif +#define CONFIG_PREBOOT "env exist ${bootdev}preboot && run ${bootdev}preboot" + #define CONFIG_ROOTPATH "/nfs/root/path" #define CONFIG_NFSBOOTCOMMAND \ "setenv bootargs $bootargs root=/dev/nfs rw " \ -- cgit v1.3.1 From b32aa9ebc57b8db5052e3b97dc5a3349cd91636b Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Wed, 19 Dec 2018 20:03:16 +0900 Subject: linux/kernel.h: import DIV_ROUND_CLOSEST_ULL from Linux Copied from Linux v4.20-rc7. Signed-off-by: Masahiro Yamada --- include/linux/kernel.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'include') diff --git a/include/linux/kernel.h b/include/linux/kernel.h index bd88483b9f6..a85c15d8dc2 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -102,6 +102,18 @@ (((__x) - ((__d) / 2)) / (__d)); \ } \ ) +/* + * Same as above but for u64 dividends. divisor must be a 32-bit + * number. + */ +#define DIV_ROUND_CLOSEST_ULL(x, divisor)( \ +{ \ + typeof(divisor) __d = divisor; \ + unsigned long long _tmp = (x) + (__d) / 2; \ + do_div(_tmp, __d); \ + _tmp; \ +} \ +) /* * Multiplies an integer by a fraction, while avoiding unnecessary -- cgit v1.3.1