diff options
author | Heiko Stübner <heiko@sntech.de> | 2017-02-18 18:46:38 (GMT) |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2017-03-16 22:03:45 (GMT) |
commit | df9041ec727d7e9ecc1a2b33f93f7e41d3aa6f1b (patch) | |
tree | 5d34a90541548db97e8e3ebdfe5ad9226a286927 /arch/arm/mach-rockchip/rk3188-board-tpl.c | |
parent | 3e747197b19c6a567408c57701eeb05e8694474b (diff) | |
download | u-boot-fsl-qoriq-df9041ec727d7e9ecc1a2b33f93f7e41d3aa6f1b.tar.xz |
rockchip: rk3188: Add main, spl and tpl boards
The rk3188 needs 3 U-Boot stages: a tpl living in 1KB of sram, a spl
the resides in the rest of the sram and loads the regular U-Boot living
in regular ram.
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
Tested-by: Kever Yang <kever.yang@rock-chips.com>
Diffstat (limited to 'arch/arm/mach-rockchip/rk3188-board-tpl.c')
-rw-r--r-- | arch/arm/mach-rockchip/rk3188-board-tpl.c | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/arch/arm/mach-rockchip/rk3188-board-tpl.c b/arch/arm/mach-rockchip/rk3188-board-tpl.c new file mode 100644 index 0000000..442bfe7 --- /dev/null +++ b/arch/arm/mach-rockchip/rk3188-board-tpl.c @@ -0,0 +1,86 @@ +/* + * (C) Copyright 2015 Google, Inc + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include <common.h> +#include <debug_uart.h> +#include <spl.h> +#include <asm/io.h> +#include <asm/arch/bootrom.h> +#include <asm/arch/pmu_rk3188.h> + +DECLARE_GLOBAL_DATA_PTR; + +/* track how often we were entered */ +static int rk3188_num_entries __attribute__ ((section(".data"))); + +#define PMU_BASE 0x20004000 +#define TPL_ENTRY 0x10080C00 + +static void jump_to_spl(void) +{ + typedef void __noreturn (*image_entry_noargs_t)(void); + + struct rk3188_pmu * const pmu = (void *)PMU_BASE; + image_entry_noargs_t tpl_entry = + (image_entry_noargs_t)(unsigned long)TPL_ENTRY; + + /* Store the SAVE_SP_ADDR in a location shared with TPL. */ + writel(SAVE_SP_ADDR, &pmu->sys_reg[2]); + tpl_entry(); +} + +void board_init_f(ulong dummy) +{ + /* Example code showing how to enable the debug UART on RK3188 */ +#ifdef EARLY_UART +#include <asm/arch/grf_rk3188.h> + /* Enable early UART on the RK3188 */ +#define GRF_BASE 0x20008000 + struct rk3188_grf * const grf = (void *)GRF_BASE; + + rk_clrsetreg(&grf->gpio1b_iomux, + GPIO1B1_MASK << GPIO1B1_SHIFT | + GPIO1B0_MASK << GPIO1B0_SHIFT, + GPIO1B1_UART2_SOUT << GPIO1B1_SHIFT | + GPIO1B0_UART2_SIN << GPIO1B0_SHIFT); + /* + * Debug UART can be used from here if required: + * + * debug_uart_init(); + * printch('a'); + * printhex8(0x1234); + * printascii("string"); + */ + debug_uart_init(); + + printch('t'); + printch('p'); + printch('l'); + printch('-'); + printch(rk3188_num_entries + 1 + '0'); + printch('\n'); +#endif + + rk3188_num_entries++; + + if (rk3188_num_entries == 1) { + /* + * The original loader did some very basic integrity + * checking at this point, but the remaining few bytes + * could be used for any improvement making sense + * really early on. + */ + + back_to_bootrom(); + } else { + /* + * TPL part of the loader should now wait for us + * at offset 0xC00 in the sram. Should never return + * from there. + */ + jump_to_spl(); + } +} |