Heiko Stuebner | fc36785 | 2019-07-16 22:18:21 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | /* |
| 3 | * Copyright (c) 2017 Rockchip Electronics Co., Ltd |
| 4 | */ |
Heiko Stuebner | fc36785 | 2019-07-16 22:18:21 +0200 | [diff] [blame] | 5 | #include <clk.h> |
| 6 | #include <dm.h> |
Quentin Schulz | c2592c0 | 2023-01-09 11:36:43 +0100 | [diff] [blame] | 7 | #include <fdt_support.h> |
Simon Glass | 9758973 | 2020-05-10 11:40:02 -0600 | [diff] [blame] | 8 | #include <init.h> |
Quentin Schulz | c2592c0 | 2023-01-09 11:36:43 +0100 | [diff] [blame] | 9 | #include <spl.h> |
Heiko Stuebner | fc36785 | 2019-07-16 22:18:21 +0200 | [diff] [blame] | 10 | #include <asm/armv8/mmu.h> |
Quentin Schulz | a5a60e8 | 2023-01-09 11:36:42 +0100 | [diff] [blame] | 11 | #include <asm/arch-rockchip/bootrom.h> |
Heiko Stuebner | fc36785 | 2019-07-16 22:18:21 +0200 | [diff] [blame] | 12 | #include <asm/arch-rockchip/grf_px30.h> |
| 13 | #include <asm/arch-rockchip/hardware.h> |
| 14 | #include <asm/arch-rockchip/uart.h> |
| 15 | #include <asm/arch-rockchip/clock.h> |
| 16 | #include <asm/arch-rockchip/cru_px30.h> |
| 17 | #include <dt-bindings/clock/px30-cru.h> |
| 18 | |
Quentin Schulz | a5a60e8 | 2023-01-09 11:36:42 +0100 | [diff] [blame] | 19 | const char * const boot_devices[BROM_LAST_BOOTSOURCE + 1] = { |
| 20 | [BROM_BOOTSOURCE_EMMC] = "/mmc@ff390000", |
Jonas Karlman | 746a77e | 2024-03-22 20:50:22 +0000 | [diff] [blame] | 21 | [BROM_BOOTSOURCE_SPINOR] = "/spi@ff3a0000/flash@0", |
Quentin Schulz | a5a60e8 | 2023-01-09 11:36:42 +0100 | [diff] [blame] | 22 | [BROM_BOOTSOURCE_SD] = "/mmc@ff370000", |
| 23 | }; |
| 24 | |
Heiko Stuebner | fc36785 | 2019-07-16 22:18:21 +0200 | [diff] [blame] | 25 | static struct mm_region px30_mem_map[] = { |
| 26 | { |
| 27 | .virt = 0x0UL, |
| 28 | .phys = 0x0UL, |
| 29 | .size = 0xff000000UL, |
| 30 | .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | |
| 31 | PTE_BLOCK_INNER_SHARE |
| 32 | }, { |
| 33 | .virt = 0xff000000UL, |
| 34 | .phys = 0xff000000UL, |
| 35 | .size = 0x01000000UL, |
| 36 | .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) | |
| 37 | PTE_BLOCK_NON_SHARE | |
| 38 | PTE_BLOCK_PXN | PTE_BLOCK_UXN |
| 39 | }, { |
| 40 | /* List terminator */ |
| 41 | 0, |
| 42 | } |
| 43 | }; |
| 44 | |
| 45 | struct mm_region *mem_map = px30_mem_map; |
| 46 | |
| 47 | #define PMU_PWRDN_CON 0xff000018 |
Paul Kocialkowski | 4a7180d | 2019-11-28 15:27:52 +0100 | [diff] [blame] | 48 | #define PMUGRF_BASE 0xff010000 |
Heiko Stuebner | fc36785 | 2019-07-16 22:18:21 +0200 | [diff] [blame] | 49 | #define GRF_BASE 0xff140000 |
| 50 | #define CRU_BASE 0xff2b0000 |
Quentin Schulz | 5875175 | 2022-09-15 12:12:47 +0200 | [diff] [blame] | 51 | #define PMUCRU_BASE 0xff2bc000 |
Heiko Stuebner | fc36785 | 2019-07-16 22:18:21 +0200 | [diff] [blame] | 52 | #define VIDEO_PHY_BASE 0xff2e0000 |
| 53 | #define SERVICE_CORE_ADDR 0xff508000 |
| 54 | #define DDR_FW_BASE 0xff534000 |
| 55 | |
| 56 | #define FW_DDR_CON 0x40 |
| 57 | |
| 58 | #define QOS_PRIORITY 0x08 |
| 59 | |
| 60 | #define QOS_PRIORITY_LEVEL(h, l) ((((h) & 3) << 8) | ((l) & 3)) |
| 61 | |
Chris Morgan | 0f412e4 | 2021-08-05 16:26:39 +0800 | [diff] [blame] | 62 | /* GRF_GPIO1AL_IOMUX */ |
| 63 | enum { |
| 64 | GPIO1A3_SHIFT = 12, |
| 65 | GPIO1A3_MASK = 0xf << GPIO1A3_SHIFT, |
| 66 | GPIO1A3_GPIO = 0, |
| 67 | GPIO1A3_FLASH_D3, |
| 68 | GPIO1A3_EMMC_D3, |
| 69 | GPIO1A3_SFC_SIO3, |
| 70 | |
| 71 | GPIO1A2_SHIFT = 8, |
| 72 | GPIO1A2_MASK = 0xf << GPIO1A2_SHIFT, |
| 73 | GPIO1A2_GPIO = 0, |
| 74 | GPIO1A2_FLASH_D2, |
| 75 | GPIO1A2_EMMC_D2, |
| 76 | GPIO1A2_SFC_SIO2, |
| 77 | |
| 78 | GPIO1A1_SHIFT = 4, |
| 79 | GPIO1A1_MASK = 0xf << GPIO1A1_SHIFT, |
| 80 | GPIO1A1_GPIO = 0, |
| 81 | GPIO1A1_FLASH_D1, |
| 82 | GPIO1A1_EMMC_D1, |
| 83 | GPIO1A1_SFC_SIO1, |
| 84 | |
| 85 | GPIO1A0_SHIFT = 0, |
| 86 | GPIO1A0_MASK = 0xf << GPIO1A0_SHIFT, |
| 87 | GPIO1A0_GPIO = 0, |
| 88 | GPIO1A0_FLASH_D0, |
| 89 | GPIO1A0_EMMC_D0, |
| 90 | GPIO1A0_SFC_SIO0, |
| 91 | }; |
| 92 | |
| 93 | /* GRF_GPIO1AH_IOMUX */ |
| 94 | enum { |
| 95 | GPIO1A4_SHIFT = 0, |
| 96 | GPIO1A4_MASK = 0xf << GPIO1A4_SHIFT, |
| 97 | GPIO1A4_GPIO = 0, |
| 98 | GPIO1A4_FLASH_D4, |
| 99 | GPIO1A4_EMMC_D4, |
| 100 | GPIO1A4_SFC_CSN0, |
| 101 | }; |
| 102 | |
| 103 | /* GRF_GPIO1BL_IOMUX */ |
| 104 | enum { |
| 105 | GPIO1B1_SHIFT = 4, |
| 106 | GPIO1B1_MASK = 0xf << GPIO1B1_SHIFT, |
| 107 | GPIO1B1_GPIO = 0, |
| 108 | GPIO1B1_FLASH_RDY, |
| 109 | GPIO1B1_EMMC_CLKOUT, |
| 110 | GPIO1B1_SFC_CLK, |
| 111 | }; |
| 112 | |
Paul Kocialkowski | 4a7180d | 2019-11-28 15:27:52 +0100 | [diff] [blame] | 113 | /* GRF_GPIO1BH_IOMUX */ |
| 114 | enum { |
| 115 | GPIO1B7_SHIFT = 12, |
| 116 | GPIO1B7_MASK = 0xf << GPIO1B7_SHIFT, |
| 117 | GPIO1B7_GPIO = 0, |
| 118 | GPIO1B7_FLASH_RDN, |
| 119 | GPIO1B7_UART3_RXM1, |
| 120 | GPIO1B7_SPI0_CLK, |
| 121 | |
| 122 | GPIO1B6_SHIFT = 8, |
| 123 | GPIO1B6_MASK = 0xf << GPIO1B6_SHIFT, |
| 124 | GPIO1B6_GPIO = 0, |
| 125 | GPIO1B6_FLASH_CS1, |
| 126 | GPIO1B6_UART3_TXM1, |
| 127 | GPIO1B6_SPI0_CSN, |
| 128 | }; |
| 129 | |
Heiko Stuebner | fc36785 | 2019-07-16 22:18:21 +0200 | [diff] [blame] | 130 | /* GRF_GPIO1CL_IOMUX */ |
| 131 | enum { |
| 132 | GPIO1C1_SHIFT = 4, |
| 133 | GPIO1C1_MASK = 0xf << GPIO1C1_SHIFT, |
| 134 | GPIO1C1_GPIO = 0, |
| 135 | GPIO1C1_UART1_TX, |
| 136 | |
| 137 | GPIO1C0_SHIFT = 0, |
| 138 | GPIO1C0_MASK = 0xf << GPIO1C0_SHIFT, |
| 139 | GPIO1C0_GPIO = 0, |
| 140 | GPIO1C0_UART1_RX, |
| 141 | }; |
| 142 | |
| 143 | /* GRF_GPIO1DL_IOMUX */ |
| 144 | enum { |
| 145 | GPIO1D3_SHIFT = 12, |
| 146 | GPIO1D3_MASK = 0xf << GPIO1D3_SHIFT, |
| 147 | GPIO1D3_GPIO = 0, |
| 148 | GPIO1D3_SDMMC_D1, |
| 149 | GPIO1D3_UART2_RXM0, |
| 150 | |
| 151 | GPIO1D2_SHIFT = 8, |
| 152 | GPIO1D2_MASK = 0xf << GPIO1D2_SHIFT, |
| 153 | GPIO1D2_GPIO = 0, |
| 154 | GPIO1D2_SDMMC_D0, |
| 155 | GPIO1D2_UART2_TXM0, |
| 156 | }; |
| 157 | |
| 158 | /* GRF_GPIO1DH_IOMUX */ |
| 159 | enum { |
| 160 | GPIO1D7_SHIFT = 12, |
| 161 | GPIO1D7_MASK = 0xf << GPIO1D7_SHIFT, |
| 162 | GPIO1D7_GPIO = 0, |
| 163 | GPIO1D7_SDMMC_CMD, |
| 164 | |
| 165 | GPIO1D6_SHIFT = 8, |
| 166 | GPIO1D6_MASK = 0xf << GPIO1D6_SHIFT, |
| 167 | GPIO1D6_GPIO = 0, |
| 168 | GPIO1D6_SDMMC_CLK, |
| 169 | |
| 170 | GPIO1D5_SHIFT = 4, |
| 171 | GPIO1D5_MASK = 0xf << GPIO1D5_SHIFT, |
| 172 | GPIO1D5_GPIO = 0, |
| 173 | GPIO1D5_SDMMC_D3, |
| 174 | |
| 175 | GPIO1D4_SHIFT = 0, |
| 176 | GPIO1D4_MASK = 0xf << GPIO1D4_SHIFT, |
| 177 | GPIO1D4_GPIO = 0, |
| 178 | GPIO1D4_SDMMC_D2, |
| 179 | }; |
| 180 | |
| 181 | /* GRF_GPIO2BH_IOMUX */ |
| 182 | enum { |
| 183 | GPIO2B6_SHIFT = 8, |
| 184 | GPIO2B6_MASK = 0xf << GPIO2B6_SHIFT, |
| 185 | GPIO2B6_GPIO = 0, |
| 186 | GPIO2B6_CIF_D1M0, |
| 187 | GPIO2B6_UART2_RXM1, |
| 188 | |
| 189 | GPIO2B4_SHIFT = 0, |
| 190 | GPIO2B4_MASK = 0xf << GPIO2B4_SHIFT, |
| 191 | GPIO2B4_GPIO = 0, |
| 192 | GPIO2B4_CIF_D0M0, |
| 193 | GPIO2B4_UART2_TXM1, |
| 194 | }; |
| 195 | |
| 196 | /* GRF_GPIO3AL_IOMUX */ |
| 197 | enum { |
| 198 | GPIO3A2_SHIFT = 8, |
| 199 | GPIO3A2_MASK = 0xf << GPIO3A2_SHIFT, |
| 200 | GPIO3A2_GPIO = 0, |
| 201 | GPIO3A2_UART5_TX = 4, |
| 202 | |
| 203 | GPIO3A1_SHIFT = 4, |
| 204 | GPIO3A1_MASK = 0xf << GPIO3A1_SHIFT, |
| 205 | GPIO3A1_GPIO = 0, |
| 206 | GPIO3A1_UART5_RX = 4, |
| 207 | }; |
| 208 | |
Quentin Schulz | 5875175 | 2022-09-15 12:12:47 +0200 | [diff] [blame] | 209 | /* PMUGRF_GPIO0BL_IOMUX */ |
| 210 | enum { |
| 211 | GPIO0B3_SHIFT = 6, |
| 212 | GPIO0B3_MASK = 0x3 << GPIO0B3_SHIFT, |
| 213 | GPIO0B3_GPIO = 0, |
| 214 | GPIO0B3_UART0_RX, |
| 215 | GPIO0B3_PMU_DEBUG1, |
| 216 | |
| 217 | GPIO0B2_SHIFT = 4, |
| 218 | GPIO0B2_MASK = 0x3 << GPIO0B2_SHIFT, |
| 219 | GPIO0B2_GPIO = 0, |
| 220 | GPIO0B2_UART0_TX, |
| 221 | GPIO0B2_PMU_DEBUG0, |
| 222 | }; |
| 223 | |
Paul Kocialkowski | 4a7180d | 2019-11-28 15:27:52 +0100 | [diff] [blame] | 224 | /* PMUGRF_GPIO0CL_IOMUX */ |
| 225 | enum { |
| 226 | GPIO0C1_SHIFT = 2, |
| 227 | GPIO0C1_MASK = 0x3 << GPIO0C1_SHIFT, |
| 228 | GPIO0C1_GPIO = 0, |
| 229 | GPIO0C1_PWM_3, |
| 230 | GPIO0C1_UART3_RXM0, |
| 231 | GPIO0C1_PMU_DEBUG4, |
| 232 | |
| 233 | GPIO0C0_SHIFT = 0, |
| 234 | GPIO0C0_MASK = 0x3 << GPIO0C0_SHIFT, |
| 235 | GPIO0C0_GPIO = 0, |
| 236 | GPIO0C0_PWM_1, |
| 237 | GPIO0C0_UART3_TXM0, |
| 238 | GPIO0C0_PMU_DEBUG3, |
| 239 | }; |
| 240 | |
Heiko Stuebner | fc36785 | 2019-07-16 22:18:21 +0200 | [diff] [blame] | 241 | int arch_cpu_init(void) |
| 242 | { |
| 243 | static struct px30_grf * const grf = (void *)GRF_BASE; |
Quentin Schulz | cddecd3 | 2022-11-11 12:25:48 +0100 | [diff] [blame] | 244 | static struct px30_cru * const cru = (void *)CRU_BASE; |
Heiko Stuebner | fc36785 | 2019-07-16 22:18:21 +0200 | [diff] [blame] | 245 | u32 __maybe_unused val; |
| 246 | |
| 247 | #ifdef CONFIG_SPL_BUILD |
| 248 | /* We do some SoC one time setting here. */ |
| 249 | /* Disable the ddr secure region setting to make it non-secure */ |
| 250 | writel(0x0, DDR_FW_BASE + FW_DDR_CON); |
| 251 | |
| 252 | /* Set cpu qos priority */ |
| 253 | writel(QOS_PRIORITY_LEVEL(1, 1), SERVICE_CORE_ADDR + QOS_PRIORITY); |
| 254 | |
| 255 | #if !defined(CONFIG_DEBUG_UART_BOARD_INIT) || \ |
| 256 | (CONFIG_DEBUG_UART_BASE != 0xff160000) || \ |
| 257 | (CONFIG_DEBUG_UART_CHANNEL != 0) |
| 258 | /* fix sdmmc pinmux if not using uart2-channel0 as debug uart */ |
| 259 | rk_clrsetreg(&grf->gpio1dl_iomux, |
| 260 | GPIO1D3_MASK | GPIO1D2_MASK, |
| 261 | GPIO1D3_SDMMC_D1 << GPIO1D3_SHIFT | |
| 262 | GPIO1D2_SDMMC_D0 << GPIO1D2_SHIFT); |
| 263 | rk_clrsetreg(&grf->gpio1dh_iomux, |
| 264 | GPIO1D7_MASK | GPIO1D6_MASK | GPIO1D5_MASK | GPIO1D4_MASK, |
| 265 | GPIO1D7_SDMMC_CMD << GPIO1D7_SHIFT | |
| 266 | GPIO1D6_SDMMC_CLK << GPIO1D6_SHIFT | |
| 267 | GPIO1D5_SDMMC_D3 << GPIO1D5_SHIFT | |
| 268 | GPIO1D4_SDMMC_D2 << GPIO1D4_SHIFT); |
| 269 | #endif |
| 270 | |
Chris Morgan | 0f412e4 | 2021-08-05 16:26:39 +0800 | [diff] [blame] | 271 | #ifdef CONFIG_ROCKCHIP_SFC |
| 272 | rk_clrsetreg(&grf->gpio1al_iomux, |
| 273 | GPIO1A3_MASK | GPIO1A2_MASK | GPIO1A1_MASK | GPIO1A0_MASK, |
| 274 | GPIO1A3_SFC_SIO3 << GPIO1A3_SHIFT | |
| 275 | GPIO1A2_SFC_SIO2 << GPIO1A2_SHIFT | |
| 276 | GPIO1A1_SFC_SIO1 << GPIO1A1_SHIFT | |
| 277 | GPIO1A0_SFC_SIO0 << GPIO1A0_SHIFT); |
| 278 | rk_clrsetreg(&grf->gpio1ah_iomux, GPIO1A4_MASK, |
| 279 | GPIO1A4_SFC_CSN0 << GPIO1A4_SHIFT); |
| 280 | rk_clrsetreg(&grf->gpio1bl_iomux, GPIO1B1_MASK, |
| 281 | GPIO1B1_SFC_CLK << GPIO1B1_SHIFT); |
| 282 | #endif |
| 283 | |
Heiko Stuebner | fc36785 | 2019-07-16 22:18:21 +0200 | [diff] [blame] | 284 | #endif |
| 285 | |
| 286 | /* Enable PD_VO (default disable at reset) */ |
| 287 | rk_clrreg(PMU_PWRDN_CON, 1 << 13); |
| 288 | |
| 289 | /* Disable video phy bandgap by default */ |
| 290 | writel(0x82, VIDEO_PHY_BASE + 0x0000); |
| 291 | writel(0x05, VIDEO_PHY_BASE + 0x03ac); |
| 292 | |
| 293 | /* Clear the force_jtag */ |
| 294 | rk_clrreg(&grf->cpu_con[1], 1 << 7); |
| 295 | |
Quentin Schulz | cddecd3 | 2022-11-11 12:25:48 +0100 | [diff] [blame] | 296 | /* Make TSADC and WDT trigger a first global reset */ |
| 297 | clrsetbits_le32(&cru->glb_rst_con, 0x3, 0x3); |
| 298 | |
Heiko Stuebner | fc36785 | 2019-07-16 22:18:21 +0200 | [diff] [blame] | 299 | return 0; |
| 300 | } |
| 301 | |
| 302 | #ifdef CONFIG_DEBUG_UART_BOARD_INIT |
| 303 | void board_debug_uart_init(void) |
| 304 | { |
Paul Kocialkowski | 4a7180d | 2019-11-28 15:27:52 +0100 | [diff] [blame] | 305 | #if defined(CONFIG_DEBUG_UART_BASE) && \ |
Quentin Schulz | 5875175 | 2022-09-15 12:12:47 +0200 | [diff] [blame] | 306 | (((CONFIG_DEBUG_UART_BASE == 0xff168000) && \ |
| 307 | (CONFIG_DEBUG_UART_CHANNEL != 1)) || \ |
| 308 | CONFIG_DEBUG_UART_BASE == 0xff030000) |
Paul Kocialkowski | 4a7180d | 2019-11-28 15:27:52 +0100 | [diff] [blame] | 309 | static struct px30_pmugrf * const pmugrf = (void *)PMUGRF_BASE; |
| 310 | #endif |
Quentin Schulz | 613d6f2 | 2023-01-09 11:36:40 +0100 | [diff] [blame] | 311 | #if !defined(CONFIG_DEBUG_UART_BASE) || \ |
| 312 | (CONFIG_DEBUG_UART_BASE != 0xff158000 && \ |
| 313 | CONFIG_DEBUG_UART_BASE != 0xff168000 && \ |
| 314 | CONFIG_DEBUG_UART_BASE != 0xff178000 && \ |
| 315 | CONFIG_DEBUG_UART_BASE != 0xff030000) || \ |
| 316 | (defined(CONFIG_DEBUG_UART_BASE) && \ |
| 317 | (CONFIG_DEBUG_UART_BASE == 0xff158000 || \ |
| 318 | CONFIG_DEBUG_UART_BASE == 0xff168000 || \ |
| 319 | CONFIG_DEBUG_UART_BASE == 0xff178000)) |
Heiko Stuebner | fc36785 | 2019-07-16 22:18:21 +0200 | [diff] [blame] | 320 | static struct px30_grf * const grf = (void *)GRF_BASE; |
| 321 | static struct px30_cru * const cru = (void *)CRU_BASE; |
Quentin Schulz | 613d6f2 | 2023-01-09 11:36:40 +0100 | [diff] [blame] | 322 | #endif |
Quentin Schulz | 5875175 | 2022-09-15 12:12:47 +0200 | [diff] [blame] | 323 | #if defined(CONFIG_DEBUG_UART_BASE) && CONFIG_DEBUG_UART_BASE == 0xff030000 |
| 324 | static struct px30_pmucru * const pmucru = (void *)PMUCRU_BASE; |
| 325 | #endif |
Heiko Stuebner | fc36785 | 2019-07-16 22:18:21 +0200 | [diff] [blame] | 326 | |
| 327 | #if defined(CONFIG_DEBUG_UART_BASE) && (CONFIG_DEBUG_UART_BASE == 0xff158000) |
| 328 | /* uart_sel_clk default select 24MHz */ |
| 329 | rk_clrsetreg(&cru->clksel_con[34], |
| 330 | UART1_PLL_SEL_MASK | UART1_DIV_CON_MASK, |
| 331 | UART1_PLL_SEL_24M << UART1_PLL_SEL_SHIFT | 0); |
| 332 | rk_clrsetreg(&cru->clksel_con[35], |
| 333 | UART1_CLK_SEL_MASK, |
| 334 | UART1_CLK_SEL_UART1 << UART1_CLK_SEL_SHIFT); |
| 335 | |
| 336 | rk_clrsetreg(&grf->gpio1cl_iomux, |
| 337 | GPIO1C1_MASK | GPIO1C0_MASK, |
| 338 | GPIO1C1_UART1_TX << GPIO1C1_SHIFT | |
| 339 | GPIO1C0_UART1_RX << GPIO1C0_SHIFT); |
Paul Kocialkowski | 4a7180d | 2019-11-28 15:27:52 +0100 | [diff] [blame] | 340 | #elif defined(CONFIG_DEBUG_UART_BASE) && (CONFIG_DEBUG_UART_BASE == 0xff168000) |
| 341 | /* GRF_IOFUNC_CON0 */ |
| 342 | enum { |
| 343 | CON_IOMUX_UART3SEL_SHIFT = 9, |
| 344 | CON_IOMUX_UART3SEL_MASK = 1 << CON_IOMUX_UART3SEL_SHIFT, |
| 345 | CON_IOMUX_UART3SEL_M0 = 0, |
| 346 | CON_IOMUX_UART3SEL_M1, |
| 347 | }; |
| 348 | |
| 349 | /* uart_sel_clk default select 24MHz */ |
| 350 | rk_clrsetreg(&cru->clksel_con[40], |
| 351 | UART3_PLL_SEL_MASK | UART3_DIV_CON_MASK, |
| 352 | UART3_PLL_SEL_24M << UART3_PLL_SEL_SHIFT | 0); |
| 353 | rk_clrsetreg(&cru->clksel_con[41], |
| 354 | UART3_CLK_SEL_MASK, |
| 355 | UART3_CLK_SEL_UART3 << UART3_CLK_SEL_SHIFT); |
| 356 | |
| 357 | #if (CONFIG_DEBUG_UART_CHANNEL == 1) |
| 358 | rk_clrsetreg(&grf->iofunc_con0, |
| 359 | CON_IOMUX_UART3SEL_MASK, |
| 360 | CON_IOMUX_UART3SEL_M1 << CON_IOMUX_UART3SEL_SHIFT); |
| 361 | |
| 362 | rk_clrsetreg(&grf->gpio1bh_iomux, |
| 363 | GPIO1B7_MASK | GPIO1B6_MASK, |
| 364 | GPIO1B7_UART3_RXM1 << GPIO1B7_SHIFT | |
| 365 | GPIO1B6_UART3_TXM1 << GPIO1B6_SHIFT); |
| 366 | #else |
| 367 | rk_clrsetreg(&grf->iofunc_con0, |
| 368 | CON_IOMUX_UART3SEL_MASK, |
| 369 | CON_IOMUX_UART3SEL_M0 << CON_IOMUX_UART3SEL_SHIFT); |
| 370 | |
| 371 | rk_clrsetreg(&pmugrf->gpio0cl_iomux, |
| 372 | GPIO0C1_MASK | GPIO0C0_MASK, |
| 373 | GPIO0C1_UART3_RXM0 << GPIO0C1_SHIFT | |
| 374 | GPIO0C0_UART3_TXM0 << GPIO0C0_SHIFT); |
| 375 | #endif /* CONFIG_DEBUG_UART_CHANNEL == 1 */ |
| 376 | |
Heiko Stuebner | fc36785 | 2019-07-16 22:18:21 +0200 | [diff] [blame] | 377 | #elif defined(CONFIG_DEBUG_UART_BASE) && (CONFIG_DEBUG_UART_BASE == 0xff178000) |
| 378 | /* uart_sel_clk default select 24MHz */ |
| 379 | rk_clrsetreg(&cru->clksel_con[46], |
| 380 | UART5_PLL_SEL_MASK | UART5_DIV_CON_MASK, |
| 381 | UART5_PLL_SEL_24M << UART5_PLL_SEL_SHIFT | 0); |
| 382 | rk_clrsetreg(&cru->clksel_con[47], |
| 383 | UART5_CLK_SEL_MASK, |
| 384 | UART5_CLK_SEL_UART5 << UART5_CLK_SEL_SHIFT); |
| 385 | |
| 386 | rk_clrsetreg(&grf->gpio3al_iomux, |
| 387 | GPIO3A2_MASK | GPIO3A1_MASK, |
| 388 | GPIO3A2_UART5_TX << GPIO3A2_SHIFT | |
| 389 | GPIO3A1_UART5_RX << GPIO3A1_SHIFT); |
Quentin Schulz | 5875175 | 2022-09-15 12:12:47 +0200 | [diff] [blame] | 390 | #elif defined(CONFIG_DEBUG_UART_BASE) && (CONFIG_DEBUG_UART_BASE == 0xff030000) |
| 391 | /* uart_sel_clk default select 24MHz */ |
| 392 | rk_clrsetreg(&pmucru->pmu_clksel_con[3], |
| 393 | UART0_PLL_SEL_MASK | UART0_DIV_CON_MASK, |
| 394 | UART0_PLL_SEL_24M << UART0_PLL_SEL_SHIFT | 0); |
| 395 | rk_clrsetreg(&pmucru->pmu_clksel_con[4], |
| 396 | UART0_CLK_SEL_MASK, |
| 397 | UART0_CLK_SEL_UART0 << UART0_CLK_SEL_SHIFT); |
| 398 | |
| 399 | rk_clrsetreg(&pmugrf->gpio0bl_iomux, |
| 400 | GPIO0B3_MASK | GPIO0B2_MASK, |
| 401 | GPIO0B3_UART0_RX << GPIO0B3_SHIFT | |
| 402 | GPIO0B2_UART0_TX << GPIO0B2_SHIFT); |
Heiko Stuebner | fc36785 | 2019-07-16 22:18:21 +0200 | [diff] [blame] | 403 | #else |
| 404 | /* GRF_IOFUNC_CON0 */ |
| 405 | enum { |
| 406 | CON_IOMUX_UART2SEL_SHIFT = 10, |
| 407 | CON_IOMUX_UART2SEL_MASK = 3 << CON_IOMUX_UART2SEL_SHIFT, |
| 408 | CON_IOMUX_UART2SEL_M0 = 0, |
| 409 | CON_IOMUX_UART2SEL_M1, |
| 410 | CON_IOMUX_UART2SEL_USBPHY, |
| 411 | }; |
| 412 | |
| 413 | /* uart_sel_clk default select 24MHz */ |
| 414 | rk_clrsetreg(&cru->clksel_con[37], |
| 415 | UART2_PLL_SEL_MASK | UART2_DIV_CON_MASK, |
| 416 | UART2_PLL_SEL_24M << UART2_PLL_SEL_SHIFT | 0); |
| 417 | rk_clrsetreg(&cru->clksel_con[38], |
| 418 | UART2_CLK_SEL_MASK, |
| 419 | UART2_CLK_SEL_UART2 << UART2_CLK_SEL_SHIFT); |
| 420 | |
Paul Kocialkowski | 7250b23 | 2019-11-28 15:27:51 +0100 | [diff] [blame] | 421 | #if (CONFIG_DEBUG_UART_CHANNEL == 1) |
Heiko Stuebner | fc36785 | 2019-07-16 22:18:21 +0200 | [diff] [blame] | 422 | /* Enable early UART2 */ |
| 423 | rk_clrsetreg(&grf->iofunc_con0, |
| 424 | CON_IOMUX_UART2SEL_MASK, |
| 425 | CON_IOMUX_UART2SEL_M1 << CON_IOMUX_UART2SEL_SHIFT); |
| 426 | |
| 427 | rk_clrsetreg(&grf->gpio2bh_iomux, |
| 428 | GPIO2B6_MASK | GPIO2B4_MASK, |
| 429 | GPIO2B6_UART2_RXM1 << GPIO2B6_SHIFT | |
| 430 | GPIO2B4_UART2_TXM1 << GPIO2B4_SHIFT); |
| 431 | #else |
| 432 | rk_clrsetreg(&grf->iofunc_con0, |
| 433 | CON_IOMUX_UART2SEL_MASK, |
| 434 | CON_IOMUX_UART2SEL_M0 << CON_IOMUX_UART2SEL_SHIFT); |
| 435 | |
| 436 | rk_clrsetreg(&grf->gpio1dl_iomux, |
| 437 | GPIO1D3_MASK | GPIO1D2_MASK, |
| 438 | GPIO1D3_UART2_RXM0 << GPIO1D3_SHIFT | |
| 439 | GPIO1D2_UART2_TXM0 << GPIO1D2_SHIFT); |
Paul Kocialkowski | 7250b23 | 2019-11-28 15:27:51 +0100 | [diff] [blame] | 440 | #endif /* CONFIG_DEBUG_UART_CHANNEL == 1 */ |
Heiko Stuebner | fc36785 | 2019-07-16 22:18:21 +0200 | [diff] [blame] | 441 | |
| 442 | #endif /* CONFIG_DEBUG_UART_BASE && CONFIG_DEBUG_UART_BASE == ... */ |
| 443 | } |
| 444 | #endif /* CONFIG_DEBUG_UART_BOARD_INIT */ |