1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (c) 2016 Rockchip Electronics Co., Ltd
10 #include <asm/arch-rockchip/bootrom.h>
11 #include <asm/arch-rockchip/clock.h>
12 #include <asm/arch-rockchip/cru_rk3288.h>
13 #include <asm/arch-rockchip/hardware.h>
14 #include <asm/arch-rockchip/grf_rk3288.h>
15 #include <asm/arch-rockchip/pmu_rk3288.h>
16 #include <asm/arch-rockchip/qos_rk3288.h>
17 #include <asm/arch-rockchip/sdram_common.h>
19 DECLARE_GLOBAL_DATA_PTR;
21 #define GRF_BASE 0xff770000
23 const char * const boot_devices[BROM_LAST_BOOTSOURCE + 1] = {
24 [BROM_BOOTSOURCE_EMMC] = "dwmmc@ff0f0000",
25 [BROM_BOOTSOURCE_SD] = "dwmmc@ff0c0000",
28 #ifdef CONFIG_SPL_BUILD
29 static void configure_l2ctlr(void)
33 l2ctlr = read_l2ctlr();
34 l2ctlr &= 0xfffc0000; /* clear bit0~bit17 */
37 * Data RAM write latency: 2 cycles
38 * Data RAM read latency: 2 cycles
39 * Data RAM setup latency: 1 cycle
40 * Tag RAM write latency: 1 cycle
41 * Tag RAM read latency: 1 cycle
42 * Tag RAM setup latency: 1 cycle
44 l2ctlr |= (1 << 3 | 1 << 0);
49 int rk3288_qos_init(void)
51 int val = 2 << PRIORITY_HIGH_SHIFT | 2 << PRIORITY_LOW_SHIFT;
52 /* set vop qos to higher priority */
53 writel(val, CPU_AXI_QOS_PRIORITY + VIO0_VOP_QOS);
54 writel(val, CPU_AXI_QOS_PRIORITY + VIO1_VOP_QOS);
56 if (!fdt_node_check_compatible(gd->fdt_blob, 0,
57 "rockchip,rk3288-tinker")) {
58 /* set isp qos to higher priority */
59 writel(val, CPU_AXI_QOS_PRIORITY + VIO1_ISP_R_QOS);
60 writel(val, CPU_AXI_QOS_PRIORITY + VIO1_ISP_W0_QOS);
61 writel(val, CPU_AXI_QOS_PRIORITY + VIO1_ISP_W1_QOS);
67 int arch_cpu_init(void)
69 #ifdef CONFIG_SPL_BUILD
72 /* We do some SoC one time setting here. */
73 struct rk3288_grf * const grf = (void *)GRF_BASE;
75 /* Use rkpwm by default */
76 rk_setreg(&grf->soc_con2, 1 << 0);
79 * Disable JTAG on sdmmc0 IO. The SDMMC won't work until this bit is
82 rk_clrreg(&grf->soc_con0, 1 << 12);
90 #ifdef CONFIG_DEBUG_UART_BOARD_INIT
91 void board_debug_uart_init(void)
93 /* Enable early UART on the RK3288 */
94 struct rk3288_grf * const grf = (void *)GRF_BASE;
96 rk_clrsetreg(&grf->gpio7ch_iomux, GPIO7C7_MASK << GPIO7C7_SHIFT |
97 GPIO7C6_MASK << GPIO7C6_SHIFT,
98 GPIO7C7_UART2DBG_SOUT << GPIO7C7_SHIFT |
99 GPIO7C6_UART2DBG_SIN << GPIO7C6_SHIFT);
103 static void rk3288_detect_reset_reason(void)
105 struct rk3288_cru *cru = rockchip_get_cru();
111 switch (cru->cru_glb_rst_st) {
119 case FST_GLB_TSADC_RST_ST:
120 case SND_GLB_TSADC_RST_ST:
123 case FST_GLB_WDT_RST_ST:
124 case SND_GLB_WDT_RST_ST:
128 reason = "unknown reset";
131 env_set("reset_reason", reason);
134 * Clear cru_glb_rst_st, so we can determine the last reset cause
135 * for following resets.
137 rk_clrreg(&cru->cru_glb_rst_st, GLB_RST_ST_MASK);
140 __weak int rk3288_board_late_init(void)
145 int rk_board_late_init(void)
147 rk3288_detect_reset_reason();
149 return rk3288_board_late_init();
152 static int do_clock(cmd_tbl_t *cmdtp, int flag, int argc,
155 static const struct {
162 { "cpll", CLK_CODEC },
163 { "gpll", CLK_GENERAL },
164 #ifdef CONFIG_ROCKCHIP_RK3036
173 ret = rockchip_get_clk(&dev);
175 printf("clk-uclass not found\n");
179 for (i = 0; i < ARRAY_SIZE(clks); i++) {
184 ret = clk_request(dev, &clk);
188 rate = clk_get_rate(&clk);
189 printf("%s: %lu\n", clks[i].name, rate);
198 clock, 2, 1, do_clock,
199 "display information about clocks",