blob: 1c10e9b9f2335ee77c77ab679f62426959894473 [file] [log] [blame]
Jagan Teki249a2382022-12-14 23:21:05 +05301// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (c) 2019 Rockchip Electronics Co., Ltd
4 * Copyright (c) 2022 Edgeble AI Technologies Pvt. Ltd.
5 */
6
Jagan Teki249a2382022-12-14 23:21:05 +05307#include <asm/arch-rockchip/bootrom.h>
8#include <asm/arch-rockchip/hardware.h>
9#include <asm/arch-rockchip/grf_rv1126.h>
10
Jagan Teki142730b2022-12-14 23:21:06 +053011#define FIREWALL_APB_BASE 0xffa60000
12#define FW_DDR_CON_REG 0x80
Jagan Teki249a2382022-12-14 23:21:05 +053013#define GRF_BASE 0xFE000000
14
15const char * const boot_devices[BROM_LAST_BOOTSOURCE + 1] = {
16 [BROM_BOOTSOURCE_EMMC] = "/mmc@ffc50000",
Jonas Karlman746a77e2024-03-22 20:50:22 +000017 [BROM_BOOTSOURCE_SPINOR] = "/spi@ffc90000/flash@0",
Jagan Teki249a2382022-12-14 23:21:05 +053018 [BROM_BOOTSOURCE_SD] = "/mmc@ffc60000",
19};
20
21/* GRF_GPIO3A_IOMUX_L */
22enum {
23 GPIO3A3_SHIFT = 12,
24 GPIO3A3_MASK = GENMASK(14, 12),
25 GPIO3A3_GPIO = 0,
26 GPIO3A3_UART2_RX_M1,
27 GPIO3A3_A7_JTAG_TMS_M1,
28
29 GPIO3A2_SHIFT = 8,
30 GPIO3A2_MASK = GENMASK(10, 8),
31 GPIO3A2_GPIO = 0,
32 GPIO3A2_UART2_TX_M1,
33 GPIO3A2_A7_JTAG_TCK_M1,
34};
35
36/* GRF_IOFUNC_CON2 */
37enum {
38 UART2_IO_SEL_SHIFT = 8,
39 UART2_IO_SEL_MASK = GENMASK(8, 8),
40 UART2_IO_SEL_M0 = 0,
41 UART2_IO_SEL_M1,
42};
43
44void board_debug_uart_init(void)
45{
46 static struct rv1126_grf * const grf = (void *)GRF_BASE;
47
48 /* Enable early UART2 channel m1 on the rv1126 */
49 rk_clrsetreg(&grf->iofunc_con2, UART2_IO_SEL_MASK,
50 UART2_IO_SEL_M1 << UART2_IO_SEL_SHIFT);
51
52 /* Switch iomux */
53 rk_clrsetreg(&grf->gpio3a_iomux_l,
54 GPIO3A3_MASK | GPIO3A2_MASK,
55 GPIO3A3_UART2_RX_M1 << GPIO3A3_SHIFT |
56 GPIO3A2_UART2_TX_M1 << GPIO3A2_SHIFT);
57}
58
59#ifndef CONFIG_TPL_BUILD
60int arch_cpu_init(void)
61{
Jagan Teki142730b2022-12-14 23:21:06 +053062 /**
63 * Set dram area unsecure in spl
64 *
65 * usb & mmc & sfc controllers can read data to dram
66 * since they are unsecure.
67 * (Note: only secure-world can access this register)
68 */
69 if (IS_ENABLED(CONFIG_SPL_BUILD))
70 writel(0, FIREWALL_APB_BASE + FW_DDR_CON_REG);
71
Jagan Teki249a2382022-12-14 23:21:05 +053072 return 0;
73}
74#endif