Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Shaohui Xie | 085ac1c | 2016-09-07 17:56:14 +0800 | [diff] [blame] | 2 | /* |
| 3 | * Copyright 2016 Freescale Semiconductor, Inc. |
Gaurav Jain | 476c639 | 2022-03-24 11:50:35 +0530 | [diff] [blame] | 4 | * Copyright 2019-2021 NXP |
Shaohui Xie | 085ac1c | 2016-09-07 17:56:14 +0800 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <common.h> |
Tom Rini | 8c70baa | 2021-12-14 13:36:40 -0500 | [diff] [blame] | 8 | #include <clock_legacy.h> |
Shaohui Xie | 085ac1c | 2016-09-07 17:56:14 +0800 | [diff] [blame] | 9 | #include <i2c.h> |
| 10 | #include <fdt_support.h> |
Simon Glass | 0e0ac20 | 2017-04-06 12:47:04 -0600 | [diff] [blame] | 11 | #include <fsl_ddr_sdram.h> |
Simon Glass | 9758973 | 2020-05-10 11:40:02 -0600 | [diff] [blame] | 12 | #include <init.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 13 | #include <asm/global_data.h> |
Shaohui Xie | 085ac1c | 2016-09-07 17:56:14 +0800 | [diff] [blame] | 14 | #include <asm/io.h> |
| 15 | #include <asm/arch/clock.h> |
| 16 | #include <asm/arch/fsl_serdes.h> |
Hou Zhiqiang | 7e03fee | 2017-04-14 14:48:23 +0800 | [diff] [blame] | 17 | #include <asm/arch/ppa.h> |
Shaohui Xie | 085ac1c | 2016-09-07 17:56:14 +0800 | [diff] [blame] | 18 | #include <asm/arch/fdt.h> |
York Sun | 729f2d1 | 2017-03-06 09:02:34 -0800 | [diff] [blame] | 19 | #include <asm/arch/mmu.h> |
Rajesh Bhagat | 9af0a0b | 2018-11-05 18:02:40 +0000 | [diff] [blame] | 20 | #include <asm/arch/cpu.h> |
Shaohui Xie | 085ac1c | 2016-09-07 17:56:14 +0800 | [diff] [blame] | 21 | #include <asm/arch/soc.h> |
Laurentiu Tudor | 512d13e | 2018-08-09 15:19:46 +0300 | [diff] [blame] | 22 | #include <asm/arch-fsl-layerscape/fsl_icid.h> |
Shaohui Xie | 085ac1c | 2016-09-07 17:56:14 +0800 | [diff] [blame] | 23 | #include <ahci.h> |
| 24 | #include <hwconfig.h> |
| 25 | #include <mmc.h> |
| 26 | #include <scsi.h> |
| 27 | #include <fm_eth.h> |
| 28 | #include <fsl_csu.h> |
| 29 | #include <fsl_esdhc.h> |
| 30 | #include <fsl_ifc.h> |
| 31 | #include <spl.h> |
Stephen Carlson | 6fa0388 | 2021-06-22 16:40:27 -0700 | [diff] [blame] | 32 | #include "../common/i2c_mux.h" |
Shaohui Xie | 085ac1c | 2016-09-07 17:56:14 +0800 | [diff] [blame] | 33 | |
| 34 | #include "../common/vid.h" |
| 35 | #include "../common/qixis.h" |
| 36 | #include "ls1046aqds_qixis.h" |
| 37 | |
| 38 | DECLARE_GLOBAL_DATA_PTR; |
| 39 | |
Rajesh Bhagat | 9af0a0b | 2018-11-05 18:02:40 +0000 | [diff] [blame] | 40 | #ifdef CONFIG_TFABOOT |
| 41 | struct ifc_regs ifc_cfg_nor_boot[CONFIG_SYS_FSL_IFC_BANK_COUNT] = { |
| 42 | { |
| 43 | "nor0", |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 44 | CFG_SYS_NOR0_CSPR, |
| 45 | CFG_SYS_NOR0_CSPR_EXT, |
Tom Rini | 7b577ba | 2022-11-16 13:10:25 -0500 | [diff] [blame] | 46 | CFG_SYS_NOR_AMASK, |
| 47 | CFG_SYS_NOR_CSOR, |
Rajesh Bhagat | 9af0a0b | 2018-11-05 18:02:40 +0000 | [diff] [blame] | 48 | { |
Tom Rini | 7b577ba | 2022-11-16 13:10:25 -0500 | [diff] [blame] | 49 | CFG_SYS_NOR_FTIM0, |
| 50 | CFG_SYS_NOR_FTIM1, |
| 51 | CFG_SYS_NOR_FTIM2, |
| 52 | CFG_SYS_NOR_FTIM3 |
Rajesh Bhagat | 9af0a0b | 2018-11-05 18:02:40 +0000 | [diff] [blame] | 53 | }, |
| 54 | |
| 55 | }, |
| 56 | { |
| 57 | "nor1", |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 58 | CFG_SYS_NOR1_CSPR, |
| 59 | CFG_SYS_NOR1_CSPR_EXT, |
Tom Rini | 7b577ba | 2022-11-16 13:10:25 -0500 | [diff] [blame] | 60 | CFG_SYS_NOR_AMASK, |
| 61 | CFG_SYS_NOR_CSOR, |
Rajesh Bhagat | 9af0a0b | 2018-11-05 18:02:40 +0000 | [diff] [blame] | 62 | { |
Tom Rini | 7b577ba | 2022-11-16 13:10:25 -0500 | [diff] [blame] | 63 | CFG_SYS_NOR_FTIM0, |
| 64 | CFG_SYS_NOR_FTIM1, |
| 65 | CFG_SYS_NOR_FTIM2, |
| 66 | CFG_SYS_NOR_FTIM3 |
Rajesh Bhagat | 9af0a0b | 2018-11-05 18:02:40 +0000 | [diff] [blame] | 67 | }, |
| 68 | }, |
| 69 | { |
| 70 | "nand", |
Tom Rini | b421349 | 2022-11-12 17:36:51 -0500 | [diff] [blame] | 71 | CFG_SYS_NAND_CSPR, |
| 72 | CFG_SYS_NAND_CSPR_EXT, |
| 73 | CFG_SYS_NAND_AMASK, |
| 74 | CFG_SYS_NAND_CSOR, |
Rajesh Bhagat | 9af0a0b | 2018-11-05 18:02:40 +0000 | [diff] [blame] | 75 | { |
Tom Rini | b421349 | 2022-11-12 17:36:51 -0500 | [diff] [blame] | 76 | CFG_SYS_NAND_FTIM0, |
| 77 | CFG_SYS_NAND_FTIM1, |
| 78 | CFG_SYS_NAND_FTIM2, |
| 79 | CFG_SYS_NAND_FTIM3 |
Rajesh Bhagat | 9af0a0b | 2018-11-05 18:02:40 +0000 | [diff] [blame] | 80 | }, |
| 81 | }, |
| 82 | { |
| 83 | "fpga", |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 84 | CFG_SYS_FPGA_CSPR, |
| 85 | CFG_SYS_FPGA_CSPR_EXT, |
| 86 | CFG_SYS_FPGA_AMASK, |
| 87 | CFG_SYS_FPGA_CSOR, |
Rajesh Bhagat | 9af0a0b | 2018-11-05 18:02:40 +0000 | [diff] [blame] | 88 | { |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 89 | CFG_SYS_FPGA_FTIM0, |
| 90 | CFG_SYS_FPGA_FTIM1, |
| 91 | CFG_SYS_FPGA_FTIM2, |
| 92 | CFG_SYS_FPGA_FTIM3 |
Rajesh Bhagat | 9af0a0b | 2018-11-05 18:02:40 +0000 | [diff] [blame] | 93 | }, |
| 94 | } |
| 95 | }; |
| 96 | |
| 97 | struct ifc_regs ifc_cfg_nand_boot[CONFIG_SYS_FSL_IFC_BANK_COUNT] = { |
| 98 | { |
| 99 | "nand", |
Tom Rini | b421349 | 2022-11-12 17:36:51 -0500 | [diff] [blame] | 100 | CFG_SYS_NAND_CSPR, |
| 101 | CFG_SYS_NAND_CSPR_EXT, |
| 102 | CFG_SYS_NAND_AMASK, |
| 103 | CFG_SYS_NAND_CSOR, |
Rajesh Bhagat | 9af0a0b | 2018-11-05 18:02:40 +0000 | [diff] [blame] | 104 | { |
Tom Rini | b421349 | 2022-11-12 17:36:51 -0500 | [diff] [blame] | 105 | CFG_SYS_NAND_FTIM0, |
| 106 | CFG_SYS_NAND_FTIM1, |
| 107 | CFG_SYS_NAND_FTIM2, |
| 108 | CFG_SYS_NAND_FTIM3 |
Rajesh Bhagat | 9af0a0b | 2018-11-05 18:02:40 +0000 | [diff] [blame] | 109 | }, |
| 110 | }, |
| 111 | { |
| 112 | "nor0", |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 113 | CFG_SYS_NOR0_CSPR, |
| 114 | CFG_SYS_NOR0_CSPR_EXT, |
Tom Rini | 7b577ba | 2022-11-16 13:10:25 -0500 | [diff] [blame] | 115 | CFG_SYS_NOR_AMASK, |
| 116 | CFG_SYS_NOR_CSOR, |
Rajesh Bhagat | 9af0a0b | 2018-11-05 18:02:40 +0000 | [diff] [blame] | 117 | { |
Tom Rini | 7b577ba | 2022-11-16 13:10:25 -0500 | [diff] [blame] | 118 | CFG_SYS_NOR_FTIM0, |
| 119 | CFG_SYS_NOR_FTIM1, |
| 120 | CFG_SYS_NOR_FTIM2, |
| 121 | CFG_SYS_NOR_FTIM3 |
Rajesh Bhagat | 9af0a0b | 2018-11-05 18:02:40 +0000 | [diff] [blame] | 122 | }, |
| 123 | }, |
| 124 | { |
| 125 | "nor1", |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 126 | CFG_SYS_NOR1_CSPR, |
| 127 | CFG_SYS_NOR1_CSPR_EXT, |
Tom Rini | 7b577ba | 2022-11-16 13:10:25 -0500 | [diff] [blame] | 128 | CFG_SYS_NOR_AMASK, |
| 129 | CFG_SYS_NOR_CSOR, |
Rajesh Bhagat | 9af0a0b | 2018-11-05 18:02:40 +0000 | [diff] [blame] | 130 | { |
Tom Rini | 7b577ba | 2022-11-16 13:10:25 -0500 | [diff] [blame] | 131 | CFG_SYS_NOR_FTIM0, |
| 132 | CFG_SYS_NOR_FTIM1, |
| 133 | CFG_SYS_NOR_FTIM2, |
| 134 | CFG_SYS_NOR_FTIM3 |
Rajesh Bhagat | 9af0a0b | 2018-11-05 18:02:40 +0000 | [diff] [blame] | 135 | }, |
| 136 | }, |
| 137 | { |
| 138 | "fpga", |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 139 | CFG_SYS_FPGA_CSPR, |
| 140 | CFG_SYS_FPGA_CSPR_EXT, |
| 141 | CFG_SYS_FPGA_AMASK, |
| 142 | CFG_SYS_FPGA_CSOR, |
Rajesh Bhagat | 9af0a0b | 2018-11-05 18:02:40 +0000 | [diff] [blame] | 143 | { |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 144 | CFG_SYS_FPGA_FTIM0, |
| 145 | CFG_SYS_FPGA_FTIM1, |
| 146 | CFG_SYS_FPGA_FTIM2, |
| 147 | CFG_SYS_FPGA_FTIM3 |
Rajesh Bhagat | 9af0a0b | 2018-11-05 18:02:40 +0000 | [diff] [blame] | 148 | }, |
| 149 | } |
| 150 | }; |
| 151 | |
| 152 | void ifc_cfg_boot_info(struct ifc_regs_info *regs_info) |
| 153 | { |
| 154 | enum boot_src src = get_boot_src(); |
| 155 | |
| 156 | if (src == BOOT_SOURCE_IFC_NAND) |
| 157 | regs_info->regs = ifc_cfg_nand_boot; |
| 158 | else |
| 159 | regs_info->regs = ifc_cfg_nor_boot; |
| 160 | regs_info->cs_size = CONFIG_SYS_FSL_IFC_BANK_COUNT; |
| 161 | } |
| 162 | |
| 163 | #endif |
| 164 | |
Shaohui Xie | 085ac1c | 2016-09-07 17:56:14 +0800 | [diff] [blame] | 165 | enum { |
| 166 | MUX_TYPE_GPIO, |
| 167 | }; |
| 168 | |
| 169 | int checkboard(void) |
| 170 | { |
Rajesh Bhagat | 9af0a0b | 2018-11-05 18:02:40 +0000 | [diff] [blame] | 171 | #ifdef CONFIG_TFABOOT |
| 172 | enum boot_src src = get_boot_src(); |
| 173 | #endif |
Shaohui Xie | 085ac1c | 2016-09-07 17:56:14 +0800 | [diff] [blame] | 174 | char buf[64]; |
| 175 | #ifndef CONFIG_SD_BOOT |
| 176 | u8 sw; |
| 177 | #endif |
| 178 | |
| 179 | puts("Board: LS1046AQDS, boot from "); |
| 180 | |
Rajesh Bhagat | 9af0a0b | 2018-11-05 18:02:40 +0000 | [diff] [blame] | 181 | #ifdef CONFIG_TFABOOT |
| 182 | if (src == BOOT_SOURCE_SD_MMC) |
| 183 | puts("SD\n"); |
| 184 | else { |
| 185 | #endif |
| 186 | |
Shaohui Xie | 085ac1c | 2016-09-07 17:56:14 +0800 | [diff] [blame] | 187 | #ifdef CONFIG_SD_BOOT |
| 188 | puts("SD\n"); |
| 189 | #else |
| 190 | sw = QIXIS_READ(brdcfg[0]); |
| 191 | sw = (sw & QIXIS_LBMAP_MASK) >> QIXIS_LBMAP_SHIFT; |
| 192 | |
| 193 | if (sw < 0x8) |
| 194 | printf("vBank: %d\n", sw); |
| 195 | else if (sw == 0x8) |
| 196 | puts("PromJet\n"); |
| 197 | else if (sw == 0x9) |
| 198 | puts("NAND\n"); |
| 199 | else if (sw == 0xF) |
| 200 | printf("QSPI\n"); |
| 201 | else |
| 202 | printf("invalid setting of SW%u\n", QIXIS_LBMAP_SWITCH); |
| 203 | #endif |
| 204 | |
Rajesh Bhagat | 9af0a0b | 2018-11-05 18:02:40 +0000 | [diff] [blame] | 205 | #ifdef CONFIG_TFABOOT |
| 206 | } |
| 207 | #endif |
Shaohui Xie | 085ac1c | 2016-09-07 17:56:14 +0800 | [diff] [blame] | 208 | printf("Sys ID: 0x%02x, Sys Ver: 0x%02x\n", |
| 209 | QIXIS_READ(id), QIXIS_READ(arch)); |
| 210 | |
| 211 | printf("FPGA: v%d (%s), build %d\n", |
| 212 | (int)QIXIS_READ(scver), qixis_read_tag(buf), |
| 213 | (int)qixis_read_minor()); |
| 214 | |
| 215 | return 0; |
| 216 | } |
| 217 | |
| 218 | bool if_board_diff_clk(void) |
| 219 | { |
| 220 | u8 diff_conf = QIXIS_READ(brdcfg[11]); |
| 221 | |
| 222 | return diff_conf & 0x40; |
| 223 | } |
| 224 | |
| 225 | unsigned long get_board_sys_clk(void) |
| 226 | { |
| 227 | u8 sysclk_conf = QIXIS_READ(brdcfg[1]); |
| 228 | |
| 229 | switch (sysclk_conf & 0x0f) { |
| 230 | case QIXIS_SYSCLK_64: |
| 231 | return 64000000; |
| 232 | case QIXIS_SYSCLK_83: |
| 233 | return 83333333; |
| 234 | case QIXIS_SYSCLK_100: |
| 235 | return 100000000; |
| 236 | case QIXIS_SYSCLK_125: |
| 237 | return 125000000; |
| 238 | case QIXIS_SYSCLK_133: |
| 239 | return 133333333; |
| 240 | case QIXIS_SYSCLK_150: |
| 241 | return 150000000; |
| 242 | case QIXIS_SYSCLK_160: |
| 243 | return 160000000; |
| 244 | case QIXIS_SYSCLK_166: |
| 245 | return 166666666; |
| 246 | } |
| 247 | |
| 248 | return 66666666; |
| 249 | } |
| 250 | |
| 251 | unsigned long get_board_ddr_clk(void) |
| 252 | { |
| 253 | u8 ddrclk_conf = QIXIS_READ(brdcfg[1]); |
| 254 | |
| 255 | if (if_board_diff_clk()) |
| 256 | return get_board_sys_clk(); |
| 257 | switch ((ddrclk_conf & 0x30) >> 4) { |
| 258 | case QIXIS_DDRCLK_100: |
| 259 | return 100000000; |
| 260 | case QIXIS_DDRCLK_125: |
| 261 | return 125000000; |
| 262 | case QIXIS_DDRCLK_133: |
| 263 | return 133333333; |
| 264 | } |
| 265 | |
| 266 | return 66666666; |
| 267 | } |
| 268 | |
Shaohui Xie | 56007a0 | 2016-10-28 14:24:02 +0800 | [diff] [blame] | 269 | #ifdef CONFIG_LPUART |
| 270 | u32 get_lpuart_clk(void) |
| 271 | { |
| 272 | return gd->bus_clk; |
| 273 | } |
| 274 | #endif |
| 275 | |
Shaohui Xie | 085ac1c | 2016-09-07 17:56:14 +0800 | [diff] [blame] | 276 | int dram_init(void) |
| 277 | { |
| 278 | /* |
| 279 | * When resuming from deep sleep, the I2C channel may not be |
| 280 | * in the default channel. So, switch to the default channel |
| 281 | * before accessing DDR SPD. |
Biwen Li | f0018f5 | 2020-02-05 22:02:17 +0800 | [diff] [blame] | 282 | * |
| 283 | * PCA9547 mount on I2C1 bus |
Shaohui Xie | 085ac1c | 2016-09-07 17:56:14 +0800 | [diff] [blame] | 284 | */ |
Biwen Li | f0018f5 | 2020-02-05 22:02:17 +0800 | [diff] [blame] | 285 | select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT, 0); |
Simon Glass | 0e0ac20 | 2017-04-06 12:47:04 -0600 | [diff] [blame] | 286 | fsl_initdram(); |
Rajesh Bhagat | 9af0a0b | 2018-11-05 18:02:40 +0000 | [diff] [blame] | 287 | #if (!defined(CONFIG_SPL) && !defined(CONFIG_TFABOOT)) || \ |
| 288 | defined(CONFIG_SPL_BUILD) |
York Sun | 729f2d1 | 2017-03-06 09:02:34 -0800 | [diff] [blame] | 289 | /* This will break-before-make MMU for DDR */ |
| 290 | update_early_mmu_table(); |
| 291 | #endif |
Shaohui Xie | 085ac1c | 2016-09-07 17:56:14 +0800 | [diff] [blame] | 292 | |
| 293 | return 0; |
| 294 | } |
| 295 | |
| 296 | int i2c_multiplexer_select_vid_channel(u8 channel) |
| 297 | { |
Biwen Li | f0018f5 | 2020-02-05 22:02:17 +0800 | [diff] [blame] | 298 | return select_i2c_ch_pca9547(channel, 0); |
Shaohui Xie | 085ac1c | 2016-09-07 17:56:14 +0800 | [diff] [blame] | 299 | } |
| 300 | |
| 301 | int board_early_init_f(void) |
| 302 | { |
Tom Rini | 376b88a | 2022-10-28 20:27:13 -0400 | [diff] [blame] | 303 | u32 __iomem *cntcr = (u32 *)CFG_SYS_FSL_TIMER_ADDR; |
Shaohui Xie | 085ac1c | 2016-09-07 17:56:14 +0800 | [diff] [blame] | 304 | #ifdef CONFIG_HAS_FSL_XHCI_USB |
Tom Rini | 376b88a | 2022-10-28 20:27:13 -0400 | [diff] [blame] | 305 | struct ccsr_scfg *scfg = (struct ccsr_scfg *)CFG_SYS_FSL_SCFG_ADDR; |
Shaohui Xie | 085ac1c | 2016-09-07 17:56:14 +0800 | [diff] [blame] | 306 | u32 usb_pwrfault; |
| 307 | #endif |
Shaohui Xie | 56007a0 | 2016-10-28 14:24:02 +0800 | [diff] [blame] | 308 | #ifdef CONFIG_LPUART |
| 309 | u8 uart; |
| 310 | #endif |
Shaohui Xie | 085ac1c | 2016-09-07 17:56:14 +0800 | [diff] [blame] | 311 | |
Biwen Li | ffd5a3c | 2020-07-02 11:13:01 +0800 | [diff] [blame] | 312 | /* |
| 313 | * Enable secure system counter for timer |
| 314 | */ |
| 315 | out_le32(cntcr, 0x1); |
| 316 | |
Tom Rini | 714482a | 2021-08-18 23:12:25 -0400 | [diff] [blame] | 317 | #if defined(CONFIG_SYS_I2C_EARLY_INIT) |
Shaohui Xie | 085ac1c | 2016-09-07 17:56:14 +0800 | [diff] [blame] | 318 | i2c_early_init_f(); |
| 319 | #endif |
| 320 | fsl_lsch2_early_init_f(); |
| 321 | |
| 322 | #ifdef CONFIG_HAS_FSL_XHCI_USB |
| 323 | out_be32(&scfg->rcwpmuxcr0, 0x3333); |
| 324 | out_be32(&scfg->usbdrvvbus_selcr, SCFG_USBDRVVBUS_SELCR_USB1); |
| 325 | usb_pwrfault = (SCFG_USBPWRFAULT_DEDICATED << |
| 326 | SCFG_USBPWRFAULT_USB3_SHIFT) | |
| 327 | (SCFG_USBPWRFAULT_DEDICATED << |
| 328 | SCFG_USBPWRFAULT_USB2_SHIFT) | |
| 329 | (SCFG_USBPWRFAULT_SHARED << |
| 330 | SCFG_USBPWRFAULT_USB1_SHIFT); |
| 331 | out_be32(&scfg->usbpwrfault_selcr, usb_pwrfault); |
| 332 | #endif |
| 333 | |
Shaohui Xie | 56007a0 | 2016-10-28 14:24:02 +0800 | [diff] [blame] | 334 | #ifdef CONFIG_LPUART |
| 335 | /* We use lpuart0 as system console */ |
| 336 | uart = QIXIS_READ(brdcfg[14]); |
| 337 | uart &= ~CFG_UART_MUX_MASK; |
| 338 | uart |= CFG_LPUART_EN << CFG_UART_MUX_SHIFT; |
| 339 | QIXIS_WRITE(brdcfg[14], uart); |
| 340 | #endif |
| 341 | |
Shaohui Xie | 085ac1c | 2016-09-07 17:56:14 +0800 | [diff] [blame] | 342 | return 0; |
| 343 | } |
| 344 | |
| 345 | #ifdef CONFIG_FSL_DEEP_SLEEP |
| 346 | /* determine if it is a warm boot */ |
| 347 | bool is_warm_boot(void) |
| 348 | { |
| 349 | #define DCFG_CCSR_CRSTSR_WDRFR (1 << 3) |
Tom Rini | 376b88a | 2022-10-28 20:27:13 -0400 | [diff] [blame] | 350 | struct ccsr_gur __iomem *gur = (void *)CFG_SYS_FSL_GUTS_ADDR; |
Shaohui Xie | 085ac1c | 2016-09-07 17:56:14 +0800 | [diff] [blame] | 351 | |
| 352 | if (in_be32(&gur->crstsr) & DCFG_CCSR_CRSTSR_WDRFR) |
| 353 | return 1; |
| 354 | |
| 355 | return 0; |
| 356 | } |
| 357 | #endif |
| 358 | |
| 359 | int config_board_mux(int ctrl_type) |
| 360 | { |
| 361 | u8 reg14; |
| 362 | |
| 363 | reg14 = QIXIS_READ(brdcfg[14]); |
| 364 | |
| 365 | switch (ctrl_type) { |
| 366 | case MUX_TYPE_GPIO: |
| 367 | reg14 = (reg14 & (~0x6)) | 0x2; |
| 368 | break; |
| 369 | default: |
| 370 | puts("Unsupported mux interface type\n"); |
| 371 | return -1; |
| 372 | } |
| 373 | |
| 374 | QIXIS_WRITE(brdcfg[14], reg14); |
| 375 | |
| 376 | return 0; |
| 377 | } |
| 378 | |
| 379 | int config_serdes_mux(void) |
| 380 | { |
| 381 | return 0; |
| 382 | } |
| 383 | |
| 384 | #ifdef CONFIG_MISC_INIT_R |
| 385 | int misc_init_r(void) |
| 386 | { |
| 387 | if (hwconfig("gpio")) |
| 388 | config_board_mux(MUX_TYPE_GPIO); |
| 389 | |
| 390 | return 0; |
| 391 | } |
| 392 | #endif |
| 393 | |
| 394 | int board_init(void) |
| 395 | { |
Biwen Li | f0018f5 | 2020-02-05 22:02:17 +0800 | [diff] [blame] | 396 | select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT, 0); |
Shaohui Xie | 085ac1c | 2016-09-07 17:56:14 +0800 | [diff] [blame] | 397 | |
Tom Rini | 376b88a | 2022-10-28 20:27:13 -0400 | [diff] [blame] | 398 | #ifdef CFG_SYS_FSL_SERDES |
Shaohui Xie | 085ac1c | 2016-09-07 17:56:14 +0800 | [diff] [blame] | 399 | config_serdes_mux(); |
| 400 | #endif |
| 401 | |
Shaohui Xie | 085ac1c | 2016-09-07 17:56:14 +0800 | [diff] [blame] | 402 | if (adjust_vdd(0)) |
| 403 | printf("Warning: Adjusting core voltage failed.\n"); |
| 404 | |
Hou Zhiqiang | 7e03fee | 2017-04-14 14:48:23 +0800 | [diff] [blame] | 405 | #ifdef CONFIG_FSL_LS_PPA |
| 406 | ppa_init(); |
| 407 | #endif |
| 408 | |
Udit Agarwal | 22ec238 | 2019-11-07 16:11:32 +0000 | [diff] [blame] | 409 | #ifdef CONFIG_NXP_ESBC |
Sumit Garg | ca69701 | 2017-03-23 13:48:17 +0530 | [diff] [blame] | 410 | /* |
| 411 | * In case of Secure Boot, the IBR configures the SMMU |
| 412 | * to allow only Secure transactions. |
| 413 | * SMMU must be reset in bypass mode. |
| 414 | * Set the ClientPD bit and Clear the USFCFG Bit |
| 415 | */ |
| 416 | u32 val; |
| 417 | val = (in_le32(SMMU_SCR0) | SCR0_CLIENTPD_MASK) & ~(SCR0_USFCFG_MASK); |
| 418 | out_le32(SMMU_SCR0, val); |
| 419 | val = (in_le32(SMMU_NSCR0) | SCR0_CLIENTPD_MASK) & ~(SCR0_USFCFG_MASK); |
| 420 | out_le32(SMMU_NSCR0, val); |
| 421 | #endif |
| 422 | |
Shaohui Xie | 085ac1c | 2016-09-07 17:56:14 +0800 | [diff] [blame] | 423 | return 0; |
| 424 | } |
| 425 | |
| 426 | #ifdef CONFIG_OF_BOARD_SETUP |
Masahiro Yamada | f7ed78b | 2020-06-26 15:13:33 +0900 | [diff] [blame] | 427 | int ft_board_setup(void *blob, struct bd_info *bd) |
Shaohui Xie | 085ac1c | 2016-09-07 17:56:14 +0800 | [diff] [blame] | 428 | { |
| 429 | u64 base[CONFIG_NR_DRAM_BANKS]; |
| 430 | u64 size[CONFIG_NR_DRAM_BANKS]; |
| 431 | u8 reg; |
| 432 | |
| 433 | /* fixup DT for the two DDR banks */ |
| 434 | base[0] = gd->bd->bi_dram[0].start; |
| 435 | size[0] = gd->bd->bi_dram[0].size; |
| 436 | base[1] = gd->bd->bi_dram[1].start; |
| 437 | size[1] = gd->bd->bi_dram[1].size; |
| 438 | |
| 439 | fdt_fixup_memory_banks(blob, base, size, 2); |
| 440 | ft_cpu_setup(blob, bd); |
| 441 | |
Tom Rini | 7806407 | 2022-08-09 10:16:22 -0400 | [diff] [blame] | 442 | #ifdef CONFIG_FMAN_ENET |
Shaohui Xie | 085ac1c | 2016-09-07 17:56:14 +0800 | [diff] [blame] | 443 | fdt_fixup_board_enet(blob); |
| 444 | #endif |
| 445 | |
Laurentiu Tudor | 512d13e | 2018-08-09 15:19:46 +0300 | [diff] [blame] | 446 | fdt_fixup_icid(blob); |
| 447 | |
Shaohui Xie | 085ac1c | 2016-09-07 17:56:14 +0800 | [diff] [blame] | 448 | reg = QIXIS_READ(brdcfg[0]); |
| 449 | reg = (reg & QIXIS_LBMAP_MASK) >> QIXIS_LBMAP_SHIFT; |
| 450 | |
| 451 | /* Disable IFC if QSPI is enabled */ |
| 452 | if (reg == 0xF) |
| 453 | do_fixup_by_compat(blob, "fsl,ifc", |
| 454 | "status", "disabled", 8 + 1, 1); |
| 455 | |
| 456 | return 0; |
| 457 | } |
| 458 | #endif |
| 459 | |
| 460 | u8 flash_read8(void *addr) |
| 461 | { |
| 462 | return __raw_readb(addr + 1); |
| 463 | } |
| 464 | |
| 465 | void flash_write16(u16 val, void *addr) |
| 466 | { |
| 467 | u16 shftval = (((val >> 8) & 0xff) | ((val << 8) & 0xff00)); |
| 468 | |
| 469 | __raw_writew(shftval, addr); |
| 470 | } |
| 471 | |
| 472 | u16 flash_read16(void *addr) |
| 473 | { |
| 474 | u16 val = __raw_readw(addr); |
| 475 | |
| 476 | return (((val) >> 8) & 0x00ff) | (((val) << 8) & 0xff00); |
| 477 | } |
Rajesh Bhagat | 9af0a0b | 2018-11-05 18:02:40 +0000 | [diff] [blame] | 478 | |
Tom Rini | 0543c43 | 2019-11-18 20:02:08 -0500 | [diff] [blame] | 479 | #if defined(CONFIG_TFABOOT) && defined(CONFIG_ENV_IS_IN_SPI_FLASH) |
Rajesh Bhagat | 9af0a0b | 2018-11-05 18:02:40 +0000 | [diff] [blame] | 480 | void *env_sf_get_env_addr(void) |
| 481 | { |
Tom Rini | 376b88a | 2022-10-28 20:27:13 -0400 | [diff] [blame] | 482 | return (void *)(CFG_SYS_FSL_QSPI_BASE + CONFIG_ENV_OFFSET); |
Rajesh Bhagat | 9af0a0b | 2018-11-05 18:02:40 +0000 | [diff] [blame] | 483 | } |
| 484 | #endif |