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 | 25c6173 | 2019-07-09 21:58:44 +0800 | [diff] [blame^] | 5 | #include <asm/armv7.h> |
Kever Yang | aa89b55 | 2016-08-12 17:58:12 +0800 | [diff] [blame] | 6 | #include <asm/io.h> |
Kever Yang | 15f09a1 | 2019-03-28 11:01:23 +0800 | [diff] [blame] | 7 | #include <asm/arch-rockchip/hardware.h> |
Kever Yang | 070e48b | 2019-03-29 09:09:03 +0800 | [diff] [blame] | 8 | #include <asm/arch-rockchip/grf_rk3288.h> |
Kever Yang | aa89b55 | 2016-08-12 17:58:12 +0800 | [diff] [blame] | 9 | |
Kever Yang | 070e48b | 2019-03-29 09:09:03 +0800 | [diff] [blame] | 10 | #define GRF_BASE 0xff770000 |
Kever Yang | aa89b55 | 2016-08-12 17:58:12 +0800 | [diff] [blame] | 11 | |
Kever Yang | 25c6173 | 2019-07-09 21:58:44 +0800 | [diff] [blame^] | 12 | #ifdef CONFIG_SPL_BUILD |
| 13 | static void configure_l2ctlr(void) |
| 14 | { |
| 15 | u32 l2ctlr; |
| 16 | |
| 17 | l2ctlr = read_l2ctlr(); |
| 18 | l2ctlr &= 0xfffc0000; /* clear bit0~bit17 */ |
| 19 | |
| 20 | /* |
| 21 | * Data RAM write latency: 2 cycles |
| 22 | * Data RAM read latency: 2 cycles |
| 23 | * Data RAM setup latency: 1 cycle |
| 24 | * Tag RAM write latency: 1 cycle |
| 25 | * Tag RAM read latency: 1 cycle |
| 26 | * Tag RAM setup latency: 1 cycle |
| 27 | */ |
| 28 | l2ctlr |= (1 << 3 | 1 << 0); |
| 29 | write_l2ctlr(l2ctlr); |
| 30 | } |
| 31 | #endif |
| 32 | |
Kever Yang | aa89b55 | 2016-08-12 17:58:12 +0800 | [diff] [blame] | 33 | int arch_cpu_init(void) |
| 34 | { |
Kever Yang | ccab9e7 | 2019-07-09 21:58:43 +0800 | [diff] [blame] | 35 | #ifdef CONFIG_SPL_BUILD |
| 36 | configure_l2ctlr(); |
| 37 | #else |
Kever Yang | aa89b55 | 2016-08-12 17:58:12 +0800 | [diff] [blame] | 38 | /* We do some SoC one time setting here. */ |
Kever Yang | 070e48b | 2019-03-29 09:09:03 +0800 | [diff] [blame] | 39 | struct rk3288_grf * const grf = (void *)GRF_BASE; |
Kever Yang | aa89b55 | 2016-08-12 17:58:12 +0800 | [diff] [blame] | 40 | |
| 41 | /* Use rkpwm by default */ |
Kever Yang | 070e48b | 2019-03-29 09:09:03 +0800 | [diff] [blame] | 42 | rk_setreg(&grf->soc_con2, 1 << 0); |
Kever Yang | ccab9e7 | 2019-07-09 21:58:43 +0800 | [diff] [blame] | 43 | #endif |
Kever Yang | aa89b55 | 2016-08-12 17:58:12 +0800 | [diff] [blame] | 44 | |
| 45 | return 0; |
| 46 | } |
Kever Yang | e83e885 | 2019-03-29 09:09:04 +0800 | [diff] [blame] | 47 | |
| 48 | #ifdef CONFIG_DEBUG_UART_BOARD_INIT |
| 49 | void board_debug_uart_init(void) |
| 50 | { |
| 51 | /* Enable early UART on the RK3288 */ |
| 52 | struct rk3288_grf * const grf = (void *)GRF_BASE; |
| 53 | |
| 54 | rk_clrsetreg(&grf->gpio7ch_iomux, GPIO7C7_MASK << GPIO7C7_SHIFT | |
| 55 | GPIO7C6_MASK << GPIO7C6_SHIFT, |
| 56 | GPIO7C7_UART2DBG_SOUT << GPIO7C7_SHIFT | |
| 57 | GPIO7C6_UART2DBG_SIN << GPIO7C6_SHIFT); |
| 58 | } |
| 59 | #endif |