Skip to content

Commit 6b5409b

Browse files
committed
rockchip: rk3328: add tpl board file support
rk3328 tpl suppose to init ddr sdram and then back to bootrom. Change-Id: I05ec83e32650b5aca88940d725586ffabf28322e Signed-off-by: Kever Yang <[email protected]>
1 parent 4eb5686 commit 6b5409b

File tree

2 files changed

+115
-0
lines changed

2 files changed

+115
-0
lines changed

arch/arm/mach-rockchip/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ obj-tpl-$(CONFIG_ROCKCHIP_BROM_HELPER) += bootrom.o save_boot_param.o
1414
obj-tpl-$(CONFIG_ROCKCHIP_RK3188) += rk3188-board-tpl.o
1515
obj-tpl-$(CONFIG_ROCKCHIP_RK3368) += rk3368-board-tpl.o
1616
obj-tpl-$(CONFIG_ROCKCHIP_RK322X) += rk322x-board-tpl.o
17+
obj-tpl-$(CONFIG_ROCKCHIP_RK3328) += rk3328-board-tpl.o
1718

1819
obj-spl-$(CONFIG_ROCKCHIP_RK3036) += rk3036-board-spl.o
1920
obj-spl-$(CONFIG_ROCKCHIP_RK3188) += rk3188-board-spl.o
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
/*
2+
* (C) Copyright 2016 Rockchip Electronics Co., Ltd
3+
*
4+
* SPDX-License-Identifier: GPL-2.0+
5+
*/
6+
7+
#include <common.h>
8+
#include <debug_uart.h>
9+
#include <dm.h>
10+
#include <fdtdec.h>
11+
#include <led.h>
12+
#include <malloc.h>
13+
#include <mmc.h>
14+
#include <ram.h>
15+
#include <spl.h>
16+
#include <asm/gpio.h>
17+
#include <asm/io.h>
18+
#include <asm/arch/bootrom.h>
19+
#include <asm/arch/clock.h>
20+
#include <asm/arch/hardware.h>
21+
#include <asm/arch/periph.h>
22+
#include <asm/arch/sdram.h>
23+
#include <asm/arch/timer.h>
24+
#include <dm/pinctrl.h>
25+
#include <dm/root.h>
26+
#include <dm/test.h>
27+
#include <dm/util.h>
28+
#include <power/regulator.h>
29+
#include <asm/arch/grf_rk3328.h>
30+
#include <asm/arch/uart.h>
31+
32+
#define CRU_BASE 0xFF440000
33+
#define GRF_BASE 0xFF100000
34+
#define UART2_BASE 0xFF130000
35+
#define STIMER_BASE_ADDR 0xFF1d0000
36+
#define CPU_TIMER_BASE (STIMER_BASE_ADDR + 0x20)
37+
38+
void board_timer_init(void)
39+
{
40+
/* Initialize CNTFRQ */
41+
__asm__ volatile ("LDR x0,=24000000");
42+
__asm__ volatile ("MSR CNTFRQ_EL0, x0");
43+
44+
/* Enable STimer1 for core */
45+
writel(0x0, CPU_TIMER_BASE + 0x0010);
46+
writel(0xffffffff, CPU_TIMER_BASE + 0x0000);
47+
writel(0xffffffff, CPU_TIMER_BASE + 0x0004);
48+
writel(0x1, CPU_TIMER_BASE + 0x0010);
49+
}
50+
51+
void board_debug_uart_init(void)
52+
{
53+
struct rk3328_grf_regs * const grf = (void *)GRF_BASE;
54+
struct rk_uart * const uart = (void *)UART2_BASE;
55+
56+
/* uart_sel_clk default select 24MHz */
57+
writel((3 << (8 + 16)) | (2 << 8), CRU_BASE + 0x148);
58+
59+
/* init uart baud rate 1500000 */
60+
writel(0x83, &uart->lcr);
61+
writel(0x1, &uart->rbr);
62+
writel(0x3, &uart->lcr);
63+
64+
/* Enable early UART2 */
65+
rk_clrsetreg(&grf->com_iomux,
66+
IOMUX_SEL_UART2_MASK,
67+
IOMUX_SEL_UART2_M1 << IOMUX_SEL_UART2_SHIFT);
68+
rk_clrsetreg(&grf->gpio2a_iomux,
69+
GPIO2A0_SEL_MASK,
70+
GPIO2A0_UART2_TX_M1 << GPIO2A0_SEL_SHIFT);
71+
rk_clrsetreg(&grf->gpio2a_iomux,
72+
GPIO2A1_SEL_MASK,
73+
GPIO2A1_UART2_RX_M1 << GPIO2A1_SEL_SHIFT);
74+
75+
/* enable FIFO */
76+
writel(0x1, &uart->sfe);
77+
}
78+
79+
void board_return_to_bootrom(void)
80+
{
81+
back_to_bootrom();
82+
}
83+
84+
u32 spl_boot_device(void)
85+
{
86+
return BOOT_DEVICE_BOOTROM;
87+
}
88+
89+
90+
void board_init_f(ulong dummy)
91+
{
92+
struct udevice *dev;
93+
int ret;
94+
95+
#define EARLY_UART
96+
#ifdef EARLY_UART
97+
debug_uart_init();
98+
printascii("U-Boot TPL board init\n");
99+
#endif
100+
101+
board_timer_init();
102+
103+
ret = spl_early_init();
104+
if (ret) {
105+
printf("spl_early_init() failed: %d\n", ret);
106+
hang();
107+
}
108+
109+
ret = uclass_get_device(UCLASS_RAM, 0, &dev);
110+
if (ret) {
111+
printf("DRAM init failed: %d\n", ret);
112+
return;
113+
}
114+
}

0 commit comments

Comments
 (0)