[U-Boot] [PATCH 0/4] boot-mode support in rockchip platform

This patch add boot-mode support for rk3036,rk3288 (fastboot, ums) The corresponding commit in the kernel: https://git.kernel.org/cgit/linux/kernel/git/mmind/linux-rockchip.git/commit...
This patch also make some work to let rk3036 and rk3288 more same , so easy to maintain
Jacob Chen (4): rockchip: move partitons define from 3036-kylin to 3036-commn rockchip: rename board.c to rk3288-board.c rockchip: move common function from board-file to rk3036-board.c rockchip: add boot-mode support for rk3288,rk3036
arch/arm/include/asm/arch-rockchip/boot_mode.h | 19 ++++ arch/arm/mach-rockchip/Makefile | 3 +- arch/arm/mach-rockchip/rk3036-board.c | 122 +++++++++++++++++++++ arch/arm/mach-rockchip/{board.c => rk3288-board.c} | 50 ++++++++- board/rockchip/evb_rk3036/evb_rk3036.c | 66 ----------- board/rockchip/kylin_rk3036/kylin_rk3036.c | 80 +------------- include/configs/kylin_rk3036.h | 27 ----- include/configs/rk3036_common.h | 13 +++ include/configs/rk3288_common.h | 3 + 9 files changed, 206 insertions(+), 177 deletions(-) create mode 100644 arch/arm/include/asm/arch-rockchip/boot_mode.h create mode 100644 arch/arm/mach-rockchip/rk3036-board.c rename arch/arm/mach-rockchip/{board.c => rk3288-board.c} (80%)

To keep it same with 3288.
Signed-off-by: Jacob Chen jacob2.chen@rock-chips.com ---
include/configs/kylin_rk3036.h | 24 ------------------------ include/configs/rk3036_common.h | 10 ++++++++++ 2 files changed, 10 insertions(+), 24 deletions(-)
diff --git a/include/configs/kylin_rk3036.h b/include/configs/kylin_rk3036.h index e8ca76d..39fb239 100644 --- a/include/configs/kylin_rk3036.h +++ b/include/configs/kylin_rk3036.h @@ -23,30 +23,6 @@ #define CONFIG_ENV_OFFSET_REDUND (CONFIG_ENV_OFFSET + CONFIG_ENV_SIZE) #define CONFIG_SYS_REDUNDAND_ENVIRONMENT
-/* Enable gpt partition table */ -#define CONFIG_CMD_GPT -#define CONFIG_RANDOM_UUID -#define PARTS_DEFAULT \ - "uuid_disk=${uuid_gpt_disk};" \ - "name=loader,start=32K,size=4000K,uuid=${uuid_gpt_loader};" \ - "name=reserved,size=64K,uuid=${uuid_gpt_reserved};" \ - "name=misc,size=4M,uuid=${uuid_gpt_misc};" \ - "name=recovery,size=32M,uuid=${uuid_gpt_recovery};" \ - "name=boot_a,size=32M,uuid=${uuid_gpt_boot_a};" \ - "name=boot_b,size=32M,uuid=${uuid_gpt_boot_b};" \ - "name=system_a,size=818M,uuid=${uuid_gpt_system_a};" \ - "name=system_b,size=818M,uuid=${uuid_gpt_system_b};" \ - "name=vendor_a,size=50M,uuid=${uuid_gpt_vendor_a};" \ - "name=vendor_b,size=50M,uuid=${uuid_gpt_vendor_b};" \ - "name=cache,size=100M,uuid=${uuid_gpt_cache};" \ - "name=metadata,size=16M,uuid=${uuid_gpt_metadata};" \ - "name=persist,size=4M,uuid=${uuid_gpt_persist};" \ - "name=userdata,size=-,uuid=${uuid_gpt_userdata};\0" \ - -#undef CONFIG_EXTRA_ENV_SETTINGS -#define CONFIG_EXTRA_ENV_SETTINGS \ - "partitions=" PARTS_DEFAULT \ - #endif
#define CONFIG_BOARD_LATE_INIT diff --git a/include/configs/rk3036_common.h b/include/configs/rk3036_common.h index 101a3ed..22fc55c 100644 --- a/include/configs/rk3036_common.h +++ b/include/configs/rk3036_common.h @@ -77,6 +77,9 @@ #define CONFIG_G_DNL_VENDOR_NUM 0x2207 #define CONFIG_G_DNL_PRODUCT_NUM 0x310a
+/* Enable gpt partition table */ +#define CONFIG_CMD_GPT + #include <config_distro_defaults.h>
#define ENV_MEM_LAYOUT_SETTINGS \ @@ -86,6 +89,12 @@ "kernel_addr_r=0x62000000\0" \ "ramdisk_addr_r=0x64000000\0"
+#define CONFIG_RANDOM_UUID +#define PARTS_DEFAULT \ + "uuid_disk=${uuid_gpt_disk};" \ + "name=boot,start=8M,size=64M,bootable,uuid=${uuid_gpt_boot};" \ + "name=rootfs,size=-,uuid=${uuid_gpt_rootfs};\0" \ + /* First try to boot from SD (index 0), then eMMC (index 1 */ #define BOOT_TARGET_DEVICES(func) \ func(MMC, mmc, 0) \ @@ -97,6 +106,7 @@ * so limit the fdt reallocation to that */ #define CONFIG_EXTRA_ENV_SETTINGS \ "fdt_high=0x7fffffff\0" \ + "partitions=" PARTS_DEFAULT \ ENV_MEM_LAYOUT_SETTINGS \ BOOTENV #endif

On 19 September 2016 at 04:46, Jacob Chen jacob2.chen@rock-chips.com wrote:
To keep it same with 3288.
Signed-off-by: Jacob Chen jacob2.chen@rock-chips.com
include/configs/kylin_rk3036.h | 24 ------------------------ include/configs/rk3036_common.h | 10 ++++++++++ 2 files changed, 10 insertions(+), 24 deletions(-)
Acked-by: Simon Glass sjg@chromium.org

On 22 September 2016 at 20:58, Simon Glass sjg@chromium.org wrote:
On 19 September 2016 at 04:46, Jacob Chen jacob2.chen@rock-chips.com wrote:
To keep it same with 3288.
Signed-off-by: Jacob Chen jacob2.chen@rock-chips.com
include/configs/kylin_rk3036.h | 24 ------------------------ include/configs/rk3036_common.h | 10 ++++++++++ 2 files changed, 10 insertions(+), 24 deletions(-)
Acked-by: Simon Glass sjg@chromium.org
Applied to u-boot-rockchip, thanks!

Signed-off-by: Jacob Chen jacob2.chen@rock-chips.com ---
arch/arm/mach-rockchip/Makefile | 2 +- arch/arm/mach-rockchip/{board.c => rk3288-board.c} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename arch/arm/mach-rockchip/{board.c => rk3288-board.c} (100%)
diff --git a/arch/arm/mach-rockchip/Makefile b/arch/arm/mach-rockchip/Makefile index 157d42f..e31b8de 100644 --- a/arch/arm/mach-rockchip/Makefile +++ b/arch/arm/mach-rockchip/Makefile @@ -9,7 +9,7 @@ obj-$(CONFIG_ROCKCHIP_RK3036) += rk3036-board-spl.o obj-$(CONFIG_ROCKCHIP_RK3288) += rk3288-board-spl.o obj-$(CONFIG_ROCKCHIP_SPL_BACK_TO_BROM) += save_boot_param.o else -obj-$(CONFIG_ROCKCHIP_RK3288) += board.o +obj-$(CONFIG_ROCKCHIP_RK3288) += rk3288-board.o endif ifndef CONFIG_ARM64 obj-y += rk_timer.o diff --git a/arch/arm/mach-rockchip/board.c b/arch/arm/mach-rockchip/rk3288-board.c similarity index 100% rename from arch/arm/mach-rockchip/board.c rename to arch/arm/mach-rockchip/rk3288-board.c

On 19 September 2016 at 04:46, Jacob Chen jacob2.chen@rock-chips.com wrote:
Signed-off-by: Jacob Chen jacob2.chen@rock-chips.com
arch/arm/mach-rockchip/Makefile | 2 +- arch/arm/mach-rockchip/{board.c => rk3288-board.c} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename arch/arm/mach-rockchip/{board.c => rk3288-board.c} (100%)
Acked-by: Simon Glass sjg@chromium.org

On 22 September 2016 at 20:58, Simon Glass sjg@chromium.org wrote:
On 19 September 2016 at 04:46, Jacob Chen jacob2.chen@rock-chips.com wrote:
Signed-off-by: Jacob Chen jacob2.chen@rock-chips.com
arch/arm/mach-rockchip/Makefile | 2 +- arch/arm/mach-rockchip/{board.c => rk3288-board.c} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename arch/arm/mach-rockchip/{board.c => rk3288-board.c} (100%)
Acked-by: Simon Glass sjg@chromium.org
Applied to u-boot-rockchip, thanks!

To keep it same with 3288
Signed-off-by: Jacob Chen jacob2.chen@rock-chips.com ---
arch/arm/mach-rockchip/Makefile | 1 + arch/arm/mach-rockchip/rk3036-board.c | 83 ++++++++++++++++++++++++++++++ board/rockchip/evb_rk3036/evb_rk3036.c | 66 ------------------------ board/rockchip/kylin_rk3036/kylin_rk3036.c | 66 ------------------------ 4 files changed, 84 insertions(+), 132 deletions(-) create mode 100644 arch/arm/mach-rockchip/rk3036-board.c
diff --git a/arch/arm/mach-rockchip/Makefile b/arch/arm/mach-rockchip/Makefile index e31b8de..6e79fed 100644 --- a/arch/arm/mach-rockchip/Makefile +++ b/arch/arm/mach-rockchip/Makefile @@ -10,6 +10,7 @@ obj-$(CONFIG_ROCKCHIP_RK3288) += rk3288-board-spl.o obj-$(CONFIG_ROCKCHIP_SPL_BACK_TO_BROM) += save_boot_param.o else obj-$(CONFIG_ROCKCHIP_RK3288) += rk3288-board.o +obj-$(CONFIG_ROCKCHIP_RK3036) += rk3036-board.o endif ifndef CONFIG_ARM64 obj-y += rk_timer.o diff --git a/arch/arm/mach-rockchip/rk3036-board.c b/arch/arm/mach-rockchip/rk3036-board.c new file mode 100644 index 0000000..b63f9c0 --- /dev/null +++ b/arch/arm/mach-rockchip/rk3036-board.c @@ -0,0 +1,83 @@ +/* + * (C) Copyright 2015 Rockchip Electronics Co., Ltd + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include <common.h> +#include <clk.h> +#include <dm.h> +#include <ram.h> +#include <asm/io.h> +#include <asm/arch/clock.h> +#include <asm/arch/periph.h> +#include <asm/gpio.h> +#include <dm/pinctrl.h> + +DECLARE_GLOBAL_DATA_PTR; + +int board_init(void) +{ + return 0; +} + +int dram_init(void) +{ + gd->ram_size = sdram_size(); + + return 0; +} + +#ifndef CONFIG_SYS_DCACHE_OFF +void enable_caches(void) +{ + /* Enable D-cache. I-cache is already enabled in start.S */ + dcache_enable(); +} +#endif + +#if defined(CONFIG_USB_GADGET) && defined(CONFIG_USB_GADGET_DWC2_OTG) +#include <usb.h> +#include <usb/dwc2_udc.h> + +static struct dwc2_plat_otg_data rk3036_otg_data = { + .rx_fifo_sz = 512, + .np_tx_fifo_sz = 16, + .tx_fifo_sz = 128, +}; + +int board_usb_init(int index, enum usb_init_type init) +{ + int node; + const char *mode; + bool matched = false; + const void *blob = gd->fdt_blob; + + /* find the usb_otg node */ + node = fdt_node_offset_by_compatible(blob, -1, + "rockchip,rk3288-usb"); + + while (node > 0) { + mode = fdt_getprop(blob, node, "dr_mode", NULL); + if (mode && strcmp(mode, "otg") == 0) { + matched = true; + break; + } + + node = fdt_node_offset_by_compatible(blob, node, + "rockchip,rk3288-usb"); + } + if (!matched) { + debug("Not found usb_otg device\n"); + return -ENODEV; + } + rk3036_otg_data.regs_otg = fdtdec_get_addr(blob, node, "reg"); + + return dwc2_udc_probe(&rk3036_otg_data); +} + +int board_usb_cleanup(int index, enum usb_init_type init) +{ + return 0; +} +#endif diff --git a/board/rockchip/evb_rk3036/evb_rk3036.c b/board/rockchip/evb_rk3036/evb_rk3036.c index e5582b4..288370a 100644 --- a/board/rockchip/evb_rk3036/evb_rk3036.c +++ b/board/rockchip/evb_rk3036/evb_rk3036.c @@ -27,69 +27,3 @@ void get_ddr_config(struct rk3036_ddr_config *config) /* 16bit bw */ config->bw = 1; } - -int board_init(void) -{ - return 0; -} - -int dram_init(void) -{ - gd->ram_size = sdram_size(); - - return 0; -} - -#ifndef CONFIG_SYS_DCACHE_OFF -void enable_caches(void) -{ - /* Enable D-cache. I-cache is already enabled in start.S */ - dcache_enable(); -} -#endif - -#if defined(CONFIG_USB_GADGET) && defined(CONFIG_USB_GADGET_DWC2_OTG) -#include <usb.h> -#include <usb/dwc2_udc.h> - -static struct dwc2_plat_otg_data rk3036_otg_data = { - .rx_fifo_sz = 512, - .np_tx_fifo_sz = 16, - .tx_fifo_sz = 128, -}; - -int board_usb_init(int index, enum usb_init_type init) -{ - int node; - const char *mode; - bool matched = false; - const void *blob = gd->fdt_blob; - - /* find the usb_otg node */ - node = fdt_node_offset_by_compatible(blob, -1, - "rockchip,rk3288-usb"); - - while (node > 0) { - mode = fdt_getprop(blob, node, "dr_mode", NULL); - if (mode && strcmp(mode, "otg") == 0) { - matched = true; - break; - } - - node = fdt_node_offset_by_compatible(blob, node, - "rockchip,rk3288-usb"); - } - if (!matched) { - debug("Not found usb_otg device\n"); - return -ENODEV; - } - rk3036_otg_data.regs_otg = fdtdec_get_addr(blob, node, "reg"); - - return dwc2_udc_probe(&rk3036_otg_data); -} - -int board_usb_cleanup(int index, enum usb_init_type init) -{ - return 0; -} -#endif diff --git a/board/rockchip/kylin_rk3036/kylin_rk3036.c b/board/rockchip/kylin_rk3036/kylin_rk3036.c index 5ade695..848f23d 100644 --- a/board/rockchip/kylin_rk3036/kylin_rk3036.c +++ b/board/rockchip/kylin_rk3036/kylin_rk3036.c @@ -59,69 +59,3 @@ int board_late_init(void)
return 0; } - -int board_init(void) -{ - return 0; -} - -int dram_init(void) -{ - gd->ram_size = sdram_size(); - - return 0; -} - -#ifndef CONFIG_SYS_DCACHE_OFF -void enable_caches(void) -{ - /* Enable D-cache. I-cache is already enabled in start.S */ - dcache_enable(); -} -#endif - -#if defined(CONFIG_USB_GADGET) && defined(CONFIG_USB_GADGET_DWC2_OTG) -#include <usb.h> -#include <usb/dwc2_udc.h> - -static struct dwc2_plat_otg_data rk3036_otg_data = { - .rx_fifo_sz = 512, - .np_tx_fifo_sz = 16, - .tx_fifo_sz = 128, -}; - -int board_usb_init(int index, enum usb_init_type init) -{ - int node; - const char *mode; - bool matched = false; - const void *blob = gd->fdt_blob; - - /* find the usb_otg node */ - node = fdt_node_offset_by_compatible(blob, -1, - "rockchip,rk3288-usb"); - - while (node > 0) { - mode = fdt_getprop(blob, node, "dr_mode", NULL); - if (mode && strcmp(mode, "otg") == 0) { - matched = true; - break; - } - - node = fdt_node_offset_by_compatible(blob, node, - "rockchip,rk3288-usb"); - } - if (!matched) { - debug("Not found usb_otg device\n"); - return -ENODEV; - } - rk3036_otg_data.regs_otg = fdtdec_get_addr(blob, node, "reg"); - - return dwc2_udc_probe(&rk3036_otg_data); -} - -int board_usb_cleanup(int index, enum usb_init_type init) -{ - return 0; -} -#endif

On 19 September 2016 at 04:46, Jacob Chen jacob2.chen@rock-chips.com wrote:
To keep it same with 3288
Signed-off-by: Jacob Chen jacob2.chen@rock-chips.com
arch/arm/mach-rockchip/Makefile | 1 + arch/arm/mach-rockchip/rk3036-board.c | 83 ++++++++++++++++++++++++++++++ board/rockchip/evb_rk3036/evb_rk3036.c | 66 ------------------------ board/rockchip/kylin_rk3036/kylin_rk3036.c | 66 ------------------------ 4 files changed, 84 insertions(+), 132 deletions(-) create mode 100644 arch/arm/mach-rockchip/rk3036-board.c
Acked-by: Simon Glass sjg@chromium.org

On 22 September 2016 at 20:58, Simon Glass sjg@chromium.org wrote:
On 19 September 2016 at 04:46, Jacob Chen jacob2.chen@rock-chips.com wrote:
To keep it same with 3288
Signed-off-by: Jacob Chen jacob2.chen@rock-chips.com
arch/arm/mach-rockchip/Makefile | 1 + arch/arm/mach-rockchip/rk3036-board.c | 83 ++++++++++++++++++++++++++++++ board/rockchip/evb_rk3036/evb_rk3036.c | 66 ------------------------ board/rockchip/kylin_rk3036/kylin_rk3036.c | 66 ------------------------ 4 files changed, 84 insertions(+), 132 deletions(-) create mode 100644 arch/arm/mach-rockchip/rk3036-board.c
Acked-by: Simon Glass sjg@chromium.org
Applied to u-boot-rockchip, thanks!

rockchip platform have a protocol to pass the the kernel reboot mode to bootloader by some special registers when system reboot. In bootloader we should read it and take action.
We can only setup boot_mode in board_late_init becasue "setenv" need env setuped. So add CONFIG_BOARD_LATE_INIT to common header and use a entry "rk_board_late_init" to replace "board_late_init" in board file.
Signed-off-by: Jacob Chen jacob2.chen@rock-chips.com ---
arch/arm/include/asm/arch-rockchip/boot_mode.h | 19 ++++++++++ arch/arm/mach-rockchip/rk3036-board.c | 39 ++++++++++++++++++++ arch/arm/mach-rockchip/rk3288-board.c | 50 +++++++++++++++++++++++--- board/rockchip/kylin_rk3036/kylin_rk3036.c | 14 ++------ include/configs/kylin_rk3036.h | 3 -- include/configs/rk3036_common.h | 3 ++ include/configs/rk3288_common.h | 3 ++ 7 files changed, 111 insertions(+), 20 deletions(-) create mode 100644 arch/arm/include/asm/arch-rockchip/boot_mode.h
diff --git a/arch/arm/include/asm/arch-rockchip/boot_mode.h b/arch/arm/include/asm/arch-rockchip/boot_mode.h new file mode 100644 index 0000000..bd65f60 --- /dev/null +++ b/arch/arm/include/asm/arch-rockchip/boot_mode.h @@ -0,0 +1,19 @@ +#ifndef __REBOOT_MODE_H +#define __REBOOT_MODE_H + +/* high 24 bits is tag, low 8 bits is type */ +#define REBOOT_FLAG 0x5242C300 +/* normal boot */ +#define BOOT_NORMAL (REBOOT_FLAG + 0) +/* enter loader rockusb mode */ +#define BOOT_LOADER (REBOOT_FLAG + 1) +/* enter recovery */ +#define BOOT_RECOVERY (REBOOT_FLAG + 3) +/* enter fastboot mode */ +#define BOOT_FASTBOOT (REBOOT_FLAG + 9) +/* enter charging mode */ +#define BOOT_CHARGING (REBOOT_FLAG + 11) +/* enter usb mass storage mode */ +#define BOOT_UMS (REBOOT_FLAG + 12) + +#endif diff --git a/arch/arm/mach-rockchip/rk3036-board.c b/arch/arm/mach-rockchip/rk3036-board.c index b63f9c0..bf2b268 100644 --- a/arch/arm/mach-rockchip/rk3036-board.c +++ b/arch/arm/mach-rockchip/rk3036-board.c @@ -11,11 +11,50 @@ #include <asm/io.h> #include <asm/arch/clock.h> #include <asm/arch/periph.h> +#include <asm/arch/grf_rk3036.h> +#include <asm/arch/boot_mode.h> +#include <asm/arch/sdram_rk3036.h> #include <asm/gpio.h> #include <dm/pinctrl.h>
DECLARE_GLOBAL_DATA_PTR;
+#define GRF_BASE 0x20008000 + +static void setup_boot_mode(void) +{ + struct rk3036_grf *const grf = (void *)GRF_BASE; + int boot_mode = readl(&grf->os_reg[4]); + + debug("boot mode %x.\n", boot_mode); + + /* Clear boot mode */ + writel(BOOT_NORMAL, &grf->os_reg[4]); + + switch (boot_mode) { + case BOOT_FASTBOOT: + printf("enter fastboot!\n"); + setenv("preboot", "setenv preboot; fastboot usb0"); + break; + case BOOT_UMS: + printf("enter UMS!\n"); + setenv("preboot", "setenv preboot; ums mmc 0"); + break; + } +} + +__weak int rk_board_late_init(void) +{ + return 0; +} + +int board_late_init(void) +{ + setup_boot_mode(); + + return rk_board_late_init(); +} + int board_init(void) { return 0; diff --git a/arch/arm/mach-rockchip/rk3288-board.c b/arch/arm/mach-rockchip/rk3288-board.c index bec756d..d24c090 100644 --- a/arch/arm/mach-rockchip/rk3288-board.c +++ b/arch/arm/mach-rockchip/rk3288-board.c @@ -8,25 +8,65 @@ #include <clk.h> #include <dm.h> #include <ram.h> +#include <syscon.h> #include <asm/io.h> #include <asm/arch/clock.h> #include <asm/arch/periph.h> +#include <asm/arch/pmu_rk3288.h> +#include <asm/arch/boot_mode.h> #include <asm/gpio.h> #include <dm/pinctrl.h>
DECLARE_GLOBAL_DATA_PTR;
+#define PMU_BASE 0xff730000 + +static void setup_boot_mode(void) +{ + struct rk3288_pmu *const pmu = (void *)PMU_BASE; + int boot_mode = readl(&pmu->sys_reg[0]); + + debug("boot mode %x.\n", boot_mode); + + /* Clear boot mode */ + writel(BOOT_NORMAL, &pmu->sys_reg[0]); + + switch (boot_mode) { + case BOOT_FASTBOOT: + printf("enter fastboot!\n"); + setenv("preboot", "setenv preboot; fastboot usb0"); + break; + case BOOT_UMS: + printf("enter UMS!\n"); + setenv("preboot", "setenv preboot; if mmc dev 0;" + "then ums mmc 0; else ums mmc 1;fi"); + break; + } +} + +__weak int rk_board_late_init(void) +{ + return 0; +} + +int board_late_init(void) +{ + setup_boot_mode(); + + return rk_board_late_init(); +} + int board_init(void) { #ifdef CONFIG_ROCKCHIP_SPL_BACK_TO_BROM struct udevice *pinctrl; int ret;
- /* - * We need to implement sdcard iomux here for the further - * initlization, otherwise, it'll hit sdcard command sending - * timeout exception. - */ + /* + * We need to implement sdcard iomux here for the further + * initlization, otherwise, it'll hit sdcard command sending + * timeout exception. + */ ret = uclass_get_device(UCLASS_PINCTRL, 0, &pinctrl); if (ret) { debug("%s: Cannot find pinctrl device\n", __func__); diff --git a/board/rockchip/kylin_rk3036/kylin_rk3036.c b/board/rockchip/kylin_rk3036/kylin_rk3036.c index 848f23d..7e2edf4 100644 --- a/board/rockchip/kylin_rk3036/kylin_rk3036.c +++ b/board/rockchip/kylin_rk3036/kylin_rk3036.c @@ -8,14 +8,11 @@ #include <dm.h> #include <asm/io.h> #include <asm/arch/uart.h> -#include <asm/arch-rockchip/grf_rk3036.h> #include <asm/arch/sdram_rk3036.h> #include <asm/gpio.h>
DECLARE_GLOBAL_DATA_PTR;
-#define GRF_BASE 0x20008000 - void get_ddr_config(struct rk3036_ddr_config *config) { /* K4B4G1646Q config */ @@ -43,16 +40,9 @@ int fastboot_key_pressed(void)
#define ROCKCHIP_BOOT_MODE_FASTBOOT 0x5242C309
-int board_late_init(void) +int rk_board_late_init(void) { - struct rk3036_grf * const grf = (void *)GRF_BASE; - int boot_mode = readl(&grf->os_reg[4]); - - /* Clear boot mode */ - writel(0, &grf->os_reg[4]); - - if (boot_mode == ROCKCHIP_BOOT_MODE_FASTBOOT || - fastboot_key_pressed()) { + if (fastboot_key_pressed()) { printf("enter fastboot!\n"); setenv("preboot", "setenv preboot; fastboot usb0"); } diff --git a/include/configs/kylin_rk3036.h b/include/configs/kylin_rk3036.h index 39fb239..4f0bd84 100644 --- a/include/configs/kylin_rk3036.h +++ b/include/configs/kylin_rk3036.h @@ -25,7 +25,4 @@
#endif
-#define CONFIG_BOARD_LATE_INIT -#define CONFIG_PREBOOT - #endif diff --git a/include/configs/rk3036_common.h b/include/configs/rk3036_common.h index 22fc55c..66c8c37 100644 --- a/include/configs/rk3036_common.h +++ b/include/configs/rk3036_common.h @@ -111,4 +111,7 @@ BOOTENV #endif
+#define CONFIG_BOARD_LATE_INIT +#define CONFIG_PREBOOT + #endif diff --git a/include/configs/rk3288_common.h b/include/configs/rk3288_common.h index 601186c..60459bc 100644 --- a/include/configs/rk3288_common.h +++ b/include/configs/rk3288_common.h @@ -139,4 +139,7 @@ BOOTENV #endif
+#define CONFIG_BOARD_LATE_INIT +#define CONFIG_PREBOOT + #endif

On 19 September 2016 at 04:46, Jacob Chen jacob2.chen@rock-chips.com wrote:
rockchip platform have a protocol to pass the the kernel reboot mode to bootloader by some special registers when system reboot. In bootloader we should read it and take action.
We can only setup boot_mode in board_late_init becasue "setenv" need env setuped. So add CONFIG_BOARD_LATE_INIT to common header and use a entry "rk_board_late_init" to replace "board_late_init" in board file.
Signed-off-by: Jacob Chen jacob2.chen@rock-chips.com
arch/arm/include/asm/arch-rockchip/boot_mode.h | 19 ++++++++++ arch/arm/mach-rockchip/rk3036-board.c | 39 ++++++++++++++++++++ arch/arm/mach-rockchip/rk3288-board.c | 50 +++++++++++++++++++++++--- board/rockchip/kylin_rk3036/kylin_rk3036.c | 14 ++------ include/configs/kylin_rk3036.h | 3 -- include/configs/rk3036_common.h | 3 ++ include/configs/rk3288_common.h | 3 ++ 7 files changed, 111 insertions(+), 20 deletions(-) create mode 100644 arch/arm/include/asm/arch-rockchip/boot_mode.h
Acked-by: Simon Glass sjg@chromium.org

On 22 September 2016 at 20:58, Simon Glass sjg@chromium.org wrote:
On 19 September 2016 at 04:46, Jacob Chen jacob2.chen@rock-chips.com wrote:
rockchip platform have a protocol to pass the the kernel reboot mode to bootloader by some special registers when system reboot. In bootloader we should read it and take action.
We can only setup boot_mode in board_late_init becasue "setenv" need env setuped. So add CONFIG_BOARD_LATE_INIT to common header and use a entry "rk_board_late_init" to replace "board_late_init" in board file.
Signed-off-by: Jacob Chen jacob2.chen@rock-chips.com
arch/arm/include/asm/arch-rockchip/boot_mode.h | 19 ++++++++++ arch/arm/mach-rockchip/rk3036-board.c | 39 ++++++++++++++++++++ arch/arm/mach-rockchip/rk3288-board.c | 50 +++++++++++++++++++++++--- board/rockchip/kylin_rk3036/kylin_rk3036.c | 14 ++------ include/configs/kylin_rk3036.h | 3 -- include/configs/rk3036_common.h | 3 ++ include/configs/rk3288_common.h | 3 ++ 7 files changed, 111 insertions(+), 20 deletions(-) create mode 100644 arch/arm/include/asm/arch-rockchip/boot_mode.h
Acked-by: Simon Glass sjg@chromium.org
Applied to u-boot-rockchip, thanks!
participants (2)
-
Jacob Chen
-
Simon Glass