1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (c) 2016 Rockchip Electronics Co., Ltd
8 #include <asm/arch-rockchip/bootrom.h>
9 #include <asm/arch-rockchip/hardware.h>
10 #include <asm/arch-rockchip/grf_rk3328.h>
11 #include <asm/arch-rockchip/uart.h>
12 #include <asm/armv8/mmu.h>
13 #include <asm/global_data.h>
16 DECLARE_GLOBAL_DATA_PTR;
18 #define CRU_BASE 0xFF440000
19 #define GRF_BASE 0xFF100000
20 #define UART2_BASE 0xFF130000
21 #define FW_DDR_CON_REG 0xFF7C0040
23 const char * const boot_devices[BROM_LAST_BOOTSOURCE + 1] = {
24 [BROM_BOOTSOURCE_EMMC] = "/mmc@ff520000",
25 [BROM_BOOTSOURCE_SD] = "/mmc@ff500000",
28 static struct mm_region rk3328_mem_map[] = {
33 .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
39 .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
41 PTE_BLOCK_PXN | PTE_BLOCK_UXN
48 struct mm_region *mem_map = rk3328_mem_map;
50 int arch_cpu_init(void)
52 #ifdef CONFIG_SPL_BUILD
53 /* We do some SoC one time setting here. */
55 /* Disable the ddr secure region setting to make it non-secure */
56 rk_setreg(FW_DDR_CON_REG, 0x200);
61 void board_debug_uart_init(void)
63 struct rk3328_grf_regs * const grf = (void *)GRF_BASE;
64 struct rk_uart * const uart = (void *)UART2_BASE;
66 GPIO2A0_SEL_SHIFT = 0,
67 GPIO2A0_SEL_MASK = 3 << GPIO2A0_SEL_SHIFT,
68 GPIO2A0_UART2_TX_M1 = 1,
70 GPIO2A1_SEL_SHIFT = 2,
71 GPIO2A1_SEL_MASK = 3 << GPIO2A1_SEL_SHIFT,
72 GPIO2A1_UART2_RX_M1 = 1,
75 IOMUX_SEL_UART2_SHIFT = 0,
76 IOMUX_SEL_UART2_MASK = 3 << IOMUX_SEL_UART2_SHIFT,
77 IOMUX_SEL_UART2_M0 = 0,
81 /* uart_sel_clk default select 24MHz */
82 writel((3 << (8 + 16)) | (2 << 8), CRU_BASE + 0x148);
84 /* init uart baud rate 1500000 */
85 writel(0x83, &uart->lcr);
86 writel(0x1, &uart->rbr);
87 writel(0x3, &uart->lcr);
89 /* Enable early UART2 */
90 rk_clrsetreg(&grf->com_iomux,
92 IOMUX_SEL_UART2_M1 << IOMUX_SEL_UART2_SHIFT);
93 rk_clrsetreg(&grf->gpio2a_iomux,
95 GPIO2A0_UART2_TX_M1 << GPIO2A0_SEL_SHIFT);
96 rk_clrsetreg(&grf->gpio2a_iomux,
98 GPIO2A1_UART2_RX_M1 << GPIO2A1_SEL_SHIFT);
101 writel(0x1, &uart->sfe);