| // SPDX-License-Identifier: GPL-2.0+ |
| /* |
| * (C) Copyright 2021 Rockchip Electronics Co., Ltd |
| */ |
| |
| #include <common.h> |
| #include <dm.h> |
| #include <asm/armv8/mmu.h> |
| #include <asm/io.h> |
| #include <asm/arch-rockchip/grf_rk3568.h> |
| #include <asm/arch-rockchip/hardware.h> |
| #include <dt-bindings/clock/rk3568-cru.h> |
| |
| #define PMUGRF_BASE 0xfdc20000 |
| #define GRF_BASE 0xfdc60000 |
| #define GRF_GPIO1B_DS_2 0x218 |
| #define GRF_GPIO1B_DS_3 0x21c |
| #define GRF_GPIO1C_DS_0 0x220 |
| #define GRF_GPIO1C_DS_1 0x224 |
| #define GRF_GPIO1C_DS_2 0x228 |
| #define GRF_GPIO1C_DS_3 0x22c |
| #define SGRF_BASE 0xFDD18000 |
| #define SGRF_SOC_CON4 0x10 |
| #define EMMC_HPROT_SECURE_CTRL 0x03 |
| #define SDMMC0_HPROT_SECURE_CTRL 0x01 |
| /* PMU_GRF_GPIO0D_IOMUX_L */ |
| enum { |
| GPIO0D1_SHIFT = 4, |
| GPIO0D1_MASK = GENMASK(6, 4), |
| GPIO0D1_GPIO = 0, |
| GPIO0D1_UART2_TXM0, |
| |
| GPIO0D0_SHIFT = 0, |
| GPIO0D0_MASK = GENMASK(2, 0), |
| GPIO0D0_GPIO = 0, |
| GPIO0D0_UART2_RXM0, |
| }; |
| |
| /* GRF_IOFUNC_SEL3 */ |
| enum { |
| UART2_IO_SEL_SHIFT = 10, |
| UART2_IO_SEL_MASK = GENMASK(11, 10), |
| UART2_IO_SEL_M0 = 0, |
| }; |
| |
| static struct mm_region rk3568_mem_map[] = { |
| { |
| .virt = 0x0UL, |
| .phys = 0x0UL, |
| .size = 0xf0000000UL, |
| .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | |
| PTE_BLOCK_INNER_SHARE |
| }, { |
| .virt = 0xf0000000UL, |
| .phys = 0xf0000000UL, |
| .size = 0x10000000UL, |
| .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) | |
| PTE_BLOCK_NON_SHARE | |
| PTE_BLOCK_PXN | PTE_BLOCK_UXN |
| }, { |
| .virt = 0x300000000, |
| .phys = 0x300000000, |
| .size = 0x0c0c00000, |
| .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) | |
| PTE_BLOCK_NON_SHARE | |
| PTE_BLOCK_PXN | PTE_BLOCK_UXN |
| }, { |
| /* List terminator */ |
| 0, |
| } |
| }; |
| |
| struct mm_region *mem_map = rk3568_mem_map; |
| |
| void board_debug_uart_init(void) |
| { |
| static struct rk3568_pmugrf * const pmugrf = (void *)PMUGRF_BASE; |
| static struct rk3568_grf * const grf = (void *)GRF_BASE; |
| |
| /* UART2 M0 */ |
| rk_clrsetreg(&grf->iofunc_sel3, UART2_IO_SEL_MASK, |
| UART2_IO_SEL_M0 << UART2_IO_SEL_SHIFT); |
| |
| /* Switch iomux */ |
| rk_clrsetreg(&pmugrf->pmu_gpio0d_iomux_l, |
| GPIO0D1_MASK | GPIO0D0_MASK, |
| GPIO0D1_UART2_TXM0 << GPIO0D1_SHIFT | |
| GPIO0D0_UART2_RXM0 << GPIO0D0_SHIFT); |
| } |
| |
| int arch_cpu_init(void) |
| { |
| #ifdef CONFIG_SPL_BUILD |
| /* Set the emmc sdmmc0 to secure */ |
| rk_clrreg(SGRF_BASE + SGRF_SOC_CON4, (EMMC_HPROT_SECURE_CTRL << 11 |
| | SDMMC0_HPROT_SECURE_CTRL << 4)); |
| /* set the emmc driver strength to level 2 */ |
| writel(0x3f3f0707, GRF_BASE + GRF_GPIO1B_DS_2); |
| writel(0x3f3f0707, GRF_BASE + GRF_GPIO1B_DS_3); |
| writel(0x3f3f0707, GRF_BASE + GRF_GPIO1C_DS_0); |
| writel(0x3f3f0707, GRF_BASE + GRF_GPIO1C_DS_1); |
| writel(0x3f3f0707, GRF_BASE + GRF_GPIO1C_DS_2); |
| writel(0x3f3f0707, GRF_BASE + GRF_GPIO1C_DS_3); |
| #endif |
| return 0; |
| } |