Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Kever Yang | aa89b55 | 2016-08-12 17:58:12 +0800 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2016 Rockchip Electronics Co., Ltd |
Kever Yang | aa89b55 | 2016-08-12 17:58:12 +0800 | [diff] [blame] | 4 | */ |
Kever Yang | 1e7d2be | 2019-07-22 20:02:10 +0800 | [diff] [blame] | 5 | #include <common.h> |
Kever Yang | 25c6173 | 2019-07-09 21:58:44 +0800 | [diff] [blame] | 6 | #include <asm/armv7.h> |
Kever Yang | aa89b55 | 2016-08-12 17:58:12 +0800 | [diff] [blame] | 7 | #include <asm/io.h> |
Kever Yang | 8af6caf | 2019-07-22 19:59:30 +0800 | [diff] [blame] | 8 | #include <asm/arch-rockchip/bootrom.h> |
Kever Yang | 15f09a1 | 2019-03-28 11:01:23 +0800 | [diff] [blame] | 9 | #include <asm/arch-rockchip/hardware.h> |
Kever Yang | 070e48b | 2019-03-29 09:09:03 +0800 | [diff] [blame] | 10 | #include <asm/arch-rockchip/grf_rk3288.h> |
Kever Yang | f35c417 | 2019-07-22 19:59:26 +0800 | [diff] [blame] | 11 | #include <asm/arch-rockchip/pmu_rk3288.h> |
Kever Yang | 1e7d2be | 2019-07-22 20:02:10 +0800 | [diff] [blame] | 12 | #include <asm/arch-rockchip/qos_rk3288.h> |
Kever Yang | f35c417 | 2019-07-22 19:59:26 +0800 | [diff] [blame] | 13 | #include <asm/arch-rockchip/sdram_common.h> |
| 14 | |
| 15 | DECLARE_GLOBAL_DATA_PTR; |
Kever Yang | aa89b55 | 2016-08-12 17:58:12 +0800 | [diff] [blame] | 16 | |
Kever Yang | 070e48b | 2019-03-29 09:09:03 +0800 | [diff] [blame] | 17 | #define GRF_BASE 0xff770000 |
Kever Yang | aa89b55 | 2016-08-12 17:58:12 +0800 | [diff] [blame] | 18 | |
Kever Yang | 8af6caf | 2019-07-22 19:59:30 +0800 | [diff] [blame] | 19 | const char * const boot_devices[BROM_LAST_BOOTSOURCE + 1] = { |
| 20 | [BROM_BOOTSOURCE_EMMC] = "dwmmc@ff0f0000", |
| 21 | [BROM_BOOTSOURCE_SD] = "dwmmc@ff0c0000", |
| 22 | }; |
| 23 | |
Kever Yang | 25c6173 | 2019-07-09 21:58:44 +0800 | [diff] [blame] | 24 | #ifdef CONFIG_SPL_BUILD |
| 25 | static void configure_l2ctlr(void) |
| 26 | { |
| 27 | u32 l2ctlr; |
| 28 | |
| 29 | l2ctlr = read_l2ctlr(); |
| 30 | l2ctlr &= 0xfffc0000; /* clear bit0~bit17 */ |
| 31 | |
| 32 | /* |
| 33 | * Data RAM write latency: 2 cycles |
| 34 | * Data RAM read latency: 2 cycles |
| 35 | * Data RAM setup latency: 1 cycle |
| 36 | * Tag RAM write latency: 1 cycle |
| 37 | * Tag RAM read latency: 1 cycle |
| 38 | * Tag RAM setup latency: 1 cycle |
| 39 | */ |
| 40 | l2ctlr |= (1 << 3 | 1 << 0); |
| 41 | write_l2ctlr(l2ctlr); |
| 42 | } |
| 43 | #endif |
| 44 | |
Kever Yang | 1e7d2be | 2019-07-22 20:02:10 +0800 | [diff] [blame] | 45 | int rk3288_qos_init(void) |
| 46 | { |
| 47 | int val = 2 << PRIORITY_HIGH_SHIFT | 2 << PRIORITY_LOW_SHIFT; |
| 48 | /* set vop qos to higher priority */ |
| 49 | writel(val, CPU_AXI_QOS_PRIORITY + VIO0_VOP_QOS); |
| 50 | writel(val, CPU_AXI_QOS_PRIORITY + VIO1_VOP_QOS); |
| 51 | |
| 52 | if (!fdt_node_check_compatible(gd->fdt_blob, 0, |
| 53 | "rockchip,rk3288-tinker")) { |
| 54 | /* set isp qos to higher priority */ |
| 55 | writel(val, CPU_AXI_QOS_PRIORITY + VIO1_ISP_R_QOS); |
| 56 | writel(val, CPU_AXI_QOS_PRIORITY + VIO1_ISP_W0_QOS); |
| 57 | writel(val, CPU_AXI_QOS_PRIORITY + VIO1_ISP_W1_QOS); |
| 58 | } |
| 59 | |
| 60 | return 0; |
| 61 | } |
| 62 | |
Kever Yang | aa89b55 | 2016-08-12 17:58:12 +0800 | [diff] [blame] | 63 | int arch_cpu_init(void) |
| 64 | { |
Kever Yang | ccab9e7 | 2019-07-09 21:58:43 +0800 | [diff] [blame] | 65 | #ifdef CONFIG_SPL_BUILD |
| 66 | configure_l2ctlr(); |
| 67 | #else |
Kever Yang | aa89b55 | 2016-08-12 17:58:12 +0800 | [diff] [blame] | 68 | /* We do some SoC one time setting here. */ |
Kever Yang | 070e48b | 2019-03-29 09:09:03 +0800 | [diff] [blame] | 69 | struct rk3288_grf * const grf = (void *)GRF_BASE; |
Kever Yang | aa89b55 | 2016-08-12 17:58:12 +0800 | [diff] [blame] | 70 | |
| 71 | /* Use rkpwm by default */ |
Kever Yang | 070e48b | 2019-03-29 09:09:03 +0800 | [diff] [blame] | 72 | rk_setreg(&grf->soc_con2, 1 << 0); |
Kever Yang | 1e7d2be | 2019-07-22 20:02:10 +0800 | [diff] [blame] | 73 | |
| 74 | /* |
| 75 | * Disable JTAG on sdmmc0 IO. The SDMMC won't work until this bit is |
| 76 | * cleared |
| 77 | */ |
| 78 | rk_clrreg(&grf->soc_con0, 1 << 12); |
| 79 | |
| 80 | rk3288_qos_init(); |
Kever Yang | ccab9e7 | 2019-07-09 21:58:43 +0800 | [diff] [blame] | 81 | #endif |
Kever Yang | aa89b55 | 2016-08-12 17:58:12 +0800 | [diff] [blame] | 82 | |
| 83 | return 0; |
| 84 | } |
Kever Yang | e83e885 | 2019-03-29 09:09:04 +0800 | [diff] [blame] | 85 | |
| 86 | #ifdef CONFIG_DEBUG_UART_BOARD_INIT |
| 87 | void board_debug_uart_init(void) |
| 88 | { |
| 89 | /* Enable early UART on the RK3288 */ |
| 90 | struct rk3288_grf * const grf = (void *)GRF_BASE; |
| 91 | |
| 92 | rk_clrsetreg(&grf->gpio7ch_iomux, GPIO7C7_MASK << GPIO7C7_SHIFT | |
| 93 | GPIO7C6_MASK << GPIO7C6_SHIFT, |
| 94 | GPIO7C7_UART2DBG_SOUT << GPIO7C7_SHIFT | |
| 95 | GPIO7C6_UART2DBG_SIN << GPIO7C6_SHIFT); |
| 96 | } |
| 97 | #endif |