Joseph Chen | 72cd879 | 2021-06-02 15:58:25 +0800 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * (C) Copyright 2021 Rockchip Electronics Co., Ltd |
| 4 | */ |
| 5 | |
| 6 | #include <common.h> |
| 7 | #include <dm.h> |
| 8 | #include <asm/armv8/mmu.h> |
| 9 | #include <asm/io.h> |
| 10 | #include <asm/arch-rockchip/grf_rk3568.h> |
| 11 | #include <asm/arch-rockchip/hardware.h> |
| 12 | #include <dt-bindings/clock/rk3568-cru.h> |
| 13 | |
| 14 | #define PMUGRF_BASE 0xfdc20000 |
| 15 | #define GRF_BASE 0xfdc60000 |
| 16 | |
| 17 | /* PMU_GRF_GPIO0D_IOMUX_L */ |
| 18 | enum { |
| 19 | GPIO0D1_SHIFT = 4, |
| 20 | GPIO0D1_MASK = GENMASK(6, 4), |
| 21 | GPIO0D1_GPIO = 0, |
| 22 | GPIO0D1_UART2_TXM0, |
| 23 | |
| 24 | GPIO0D0_SHIFT = 0, |
| 25 | GPIO0D0_MASK = GENMASK(2, 0), |
| 26 | GPIO0D0_GPIO = 0, |
| 27 | GPIO0D0_UART2_RXM0, |
| 28 | }; |
| 29 | |
| 30 | /* GRF_IOFUNC_SEL3 */ |
| 31 | enum { |
| 32 | UART2_IO_SEL_SHIFT = 10, |
| 33 | UART2_IO_SEL_MASK = GENMASK(11, 10), |
| 34 | UART2_IO_SEL_M0 = 0, |
| 35 | }; |
| 36 | |
| 37 | static struct mm_region rk3568_mem_map[] = { |
| 38 | { |
| 39 | .virt = 0x0UL, |
| 40 | .phys = 0x0UL, |
| 41 | .size = 0xf0000000UL, |
| 42 | .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | |
| 43 | PTE_BLOCK_INNER_SHARE |
| 44 | }, { |
| 45 | .virt = 0xf0000000UL, |
| 46 | .phys = 0xf0000000UL, |
| 47 | .size = 0x10000000UL, |
| 48 | .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) | |
| 49 | PTE_BLOCK_NON_SHARE | |
| 50 | PTE_BLOCK_PXN | PTE_BLOCK_UXN |
| 51 | }, { |
| 52 | .virt = 0x300000000, |
| 53 | .phys = 0x300000000, |
| 54 | .size = 0x0c0c00000, |
| 55 | .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) | |
| 56 | PTE_BLOCK_NON_SHARE | |
| 57 | PTE_BLOCK_PXN | PTE_BLOCK_UXN |
| 58 | }, { |
| 59 | /* List terminator */ |
| 60 | 0, |
| 61 | } |
| 62 | }; |
| 63 | |
| 64 | struct mm_region *mem_map = rk3568_mem_map; |
| 65 | |
| 66 | void board_debug_uart_init(void) |
| 67 | { |
| 68 | static struct rk3568_pmugrf * const pmugrf = (void *)PMUGRF_BASE; |
| 69 | static struct rk3568_grf * const grf = (void *)GRF_BASE; |
| 70 | |
| 71 | /* UART2 M0 */ |
| 72 | rk_clrsetreg(&grf->iofunc_sel3, UART2_IO_SEL_MASK, |
| 73 | UART2_IO_SEL_M0 << UART2_IO_SEL_SHIFT); |
| 74 | |
| 75 | /* Switch iomux */ |
| 76 | rk_clrsetreg(&pmugrf->pmu_gpio0d_iomux_l, |
| 77 | GPIO0D1_MASK | GPIO0D0_MASK, |
| 78 | GPIO0D1_UART2_TXM0 << GPIO0D1_SHIFT | |
| 79 | GPIO0D0_UART2_RXM0 << GPIO0D0_SHIFT); |
| 80 | } |
| 81 | |
| 82 | int arch_cpu_init(void) |
| 83 | { |
| 84 | return 0; |
| 85 | } |