Jagan Teki | 249a238 | 2022-12-14 23:21:05 +0530 | [diff] [blame] | 1 | // 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 | |
| 7 | #include <common.h> |
Jagan Teki | 249a238 | 2022-12-14 23:21:05 +0530 | [diff] [blame] | 8 | #include <asm/arch-rockchip/bootrom.h> |
| 9 | #include <asm/arch-rockchip/hardware.h> |
| 10 | #include <asm/arch-rockchip/grf_rv1126.h> |
| 11 | |
Jagan Teki | 142730b | 2022-12-14 23:21:06 +0530 | [diff] [blame] | 12 | #define FIREWALL_APB_BASE 0xffa60000 |
| 13 | #define FW_DDR_CON_REG 0x80 |
Jagan Teki | 249a238 | 2022-12-14 23:21:05 +0530 | [diff] [blame] | 14 | #define GRF_BASE 0xFE000000 |
| 15 | |
| 16 | const char * const boot_devices[BROM_LAST_BOOTSOURCE + 1] = { |
| 17 | [BROM_BOOTSOURCE_EMMC] = "/mmc@ffc50000", |
| 18 | [BROM_BOOTSOURCE_SD] = "/mmc@ffc60000", |
| 19 | }; |
| 20 | |
| 21 | /* GRF_GPIO3A_IOMUX_L */ |
| 22 | enum { |
| 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 */ |
| 37 | enum { |
| 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 | |
| 44 | void 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 |
| 60 | int arch_cpu_init(void) |
| 61 | { |
Jagan Teki | 142730b | 2022-12-14 23:21:06 +0530 | [diff] [blame] | 62 | /** |
| 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 Teki | 249a238 | 2022-12-14 23:21:05 +0530 | [diff] [blame] | 72 | return 0; |
| 73 | } |
| 74 | #endif |