Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 2 | /* |
Jianpeng Bu | f9648b6 | 2022-01-31 18:42:36 +0530 | [diff] [blame] | 3 | * Copyright 2017-2022 NXP |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 4 | */ |
Tom Rini | dec7ea0 | 2024-05-20 13:35:03 -0600 | [diff] [blame^] | 5 | #include <config.h> |
Tom Rini | 8c70baa | 2021-12-14 13:36:40 -0500 | [diff] [blame] | 6 | #include <clock_legacy.h> |
Simon Glass | 1ab1692 | 2022-07-31 12:28:48 -0600 | [diff] [blame] | 7 | #include <display_options.h> |
Simon Glass | 0af6e2d | 2019-08-01 09:46:52 -0600 | [diff] [blame] | 8 | #include <env.h> |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 9 | #include <i2c.h> |
Simon Glass | 9758973 | 2020-05-10 11:40:02 -0600 | [diff] [blame] | 10 | #include <init.h> |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 11 | #include <log.h> |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 12 | #include <malloc.h> |
| 13 | #include <errno.h> |
| 14 | #include <netdev.h> |
| 15 | #include <fsl_ifc.h> |
| 16 | #include <fsl_ddr.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 17 | #include <asm/global_data.h> |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 18 | #include <asm/io.h> |
| 19 | #include <fdt_support.h> |
Simon Glass | dbd7954 | 2020-05-10 11:40:11 -0600 | [diff] [blame] | 20 | #include <linux/delay.h> |
Masahiro Yamada | 75f82d0 | 2018-03-05 01:20:11 +0900 | [diff] [blame] | 21 | #include <linux/libfdt.h> |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 22 | #include <fsl-mc/fsl_mc.h> |
Simon Glass | 9d1f619 | 2019-08-02 09:44:25 -0600 | [diff] [blame] | 23 | #include <env_internal.h> |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 24 | #include <asm/arch-fsl-layerscape/soc.h> |
Yangbo Lu | 1d87953 | 2017-11-27 15:40:17 +0800 | [diff] [blame] | 25 | #include <hwconfig.h> |
Rajesh Bhagat | a421625 | 2018-01-17 16:13:09 +0530 | [diff] [blame] | 26 | #include <asm/arch/fsl_serdes.h> |
| 27 | #include <asm/arch/soc.h> |
Laurentiu Tudor | 7690ea7 | 2019-07-30 17:29:58 +0300 | [diff] [blame] | 28 | #include <asm/arch-fsl-layerscape/fsl_icid.h> |
Stephen Carlson | 267ddcc | 2021-06-22 16:41:38 -0700 | [diff] [blame] | 29 | #include "../common/i2c_mux.h" |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 30 | |
| 31 | #include "../common/qixis.h" |
| 32 | #include "ls1088a_qixis.h" |
Rajesh Bhagat | a421625 | 2018-01-17 16:13:09 +0530 | [diff] [blame] | 33 | #include "../common/vid.h" |
| 34 | #include <fsl_immap.h> |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 35 | |
| 36 | DECLARE_GLOBAL_DATA_PTR; |
| 37 | |
Pankit Garg | 112aeba | 2018-12-27 04:37:57 +0000 | [diff] [blame] | 38 | #ifdef CONFIG_TARGET_LS1088AQDS |
| 39 | #ifdef CONFIG_TFABOOT |
| 40 | struct ifc_regs ifc_cfg_ifc_nor_boot[CONFIG_SYS_FSL_IFC_BANK_COUNT] = { |
| 41 | { |
| 42 | "nor0", |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 43 | CFG_SYS_NOR0_CSPR_EARLY, |
| 44 | CFG_SYS_NOR0_CSPR_EXT, |
Tom Rini | 7b577ba | 2022-11-16 13:10:25 -0500 | [diff] [blame] | 45 | CFG_SYS_NOR_AMASK, |
| 46 | CFG_SYS_NOR_CSOR, |
Pankit Garg | 112aeba | 2018-12-27 04:37:57 +0000 | [diff] [blame] | 47 | { |
Tom Rini | 7b577ba | 2022-11-16 13:10:25 -0500 | [diff] [blame] | 48 | CFG_SYS_NOR_FTIM0, |
| 49 | CFG_SYS_NOR_FTIM1, |
| 50 | CFG_SYS_NOR_FTIM2, |
| 51 | CFG_SYS_NOR_FTIM3 |
Pankit Garg | 112aeba | 2018-12-27 04:37:57 +0000 | [diff] [blame] | 52 | }, |
| 53 | 0, |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 54 | CFG_SYS_NOR0_CSPR, |
Pankit Garg | 112aeba | 2018-12-27 04:37:57 +0000 | [diff] [blame] | 55 | 0, |
| 56 | }, |
| 57 | { |
| 58 | "nor1", |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 59 | CFG_SYS_NOR1_CSPR_EARLY, |
| 60 | CFG_SYS_NOR0_CSPR_EXT, |
Tom Rini | 7b577ba | 2022-11-16 13:10:25 -0500 | [diff] [blame] | 61 | CFG_SYS_NOR_AMASK_EARLY, |
| 62 | CFG_SYS_NOR_CSOR, |
Pankit Garg | 112aeba | 2018-12-27 04:37:57 +0000 | [diff] [blame] | 63 | { |
Tom Rini | 7b577ba | 2022-11-16 13:10:25 -0500 | [diff] [blame] | 64 | CFG_SYS_NOR_FTIM0, |
| 65 | CFG_SYS_NOR_FTIM1, |
| 66 | CFG_SYS_NOR_FTIM2, |
| 67 | CFG_SYS_NOR_FTIM3 |
Pankit Garg | 112aeba | 2018-12-27 04:37:57 +0000 | [diff] [blame] | 68 | }, |
| 69 | 0, |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 70 | CFG_SYS_NOR1_CSPR, |
Tom Rini | 7b577ba | 2022-11-16 13:10:25 -0500 | [diff] [blame] | 71 | CFG_SYS_NOR_AMASK, |
Pankit Garg | 112aeba | 2018-12-27 04:37:57 +0000 | [diff] [blame] | 72 | }, |
| 73 | { |
| 74 | "nand", |
Tom Rini | b421349 | 2022-11-12 17:36:51 -0500 | [diff] [blame] | 75 | CFG_SYS_NAND_CSPR, |
| 76 | CFG_SYS_NAND_CSPR_EXT, |
| 77 | CFG_SYS_NAND_AMASK, |
| 78 | CFG_SYS_NAND_CSOR, |
Pankit Garg | 112aeba | 2018-12-27 04:37:57 +0000 | [diff] [blame] | 79 | { |
Tom Rini | b421349 | 2022-11-12 17:36:51 -0500 | [diff] [blame] | 80 | CFG_SYS_NAND_FTIM0, |
| 81 | CFG_SYS_NAND_FTIM1, |
| 82 | CFG_SYS_NAND_FTIM2, |
| 83 | CFG_SYS_NAND_FTIM3 |
Pankit Garg | 112aeba | 2018-12-27 04:37:57 +0000 | [diff] [blame] | 84 | }, |
| 85 | }, |
| 86 | { |
| 87 | "fpga", |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 88 | CFG_SYS_FPGA_CSPR, |
| 89 | CFG_SYS_FPGA_CSPR_EXT, |
Pankit Garg | 112aeba | 2018-12-27 04:37:57 +0000 | [diff] [blame] | 90 | SYS_FPGA_AMASK, |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 91 | CFG_SYS_FPGA_CSOR, |
Pankit Garg | 112aeba | 2018-12-27 04:37:57 +0000 | [diff] [blame] | 92 | { |
| 93 | SYS_FPGA_CS_FTIM0, |
| 94 | SYS_FPGA_CS_FTIM1, |
| 95 | SYS_FPGA_CS_FTIM2, |
| 96 | SYS_FPGA_CS_FTIM3 |
| 97 | }, |
| 98 | 0, |
| 99 | SYS_FPGA_CSPR_FINAL, |
| 100 | 0, |
| 101 | } |
| 102 | }; |
| 103 | |
| 104 | struct ifc_regs ifc_cfg_qspi_nor_boot[CONFIG_SYS_FSL_IFC_BANK_COUNT] = { |
| 105 | { |
| 106 | "nand", |
Tom Rini | b421349 | 2022-11-12 17:36:51 -0500 | [diff] [blame] | 107 | CFG_SYS_NAND_CSPR, |
| 108 | CFG_SYS_NAND_CSPR_EXT, |
| 109 | CFG_SYS_NAND_AMASK, |
| 110 | CFG_SYS_NAND_CSOR, |
Pankit Garg | 112aeba | 2018-12-27 04:37:57 +0000 | [diff] [blame] | 111 | { |
Tom Rini | b421349 | 2022-11-12 17:36:51 -0500 | [diff] [blame] | 112 | CFG_SYS_NAND_FTIM0, |
| 113 | CFG_SYS_NAND_FTIM1, |
| 114 | CFG_SYS_NAND_FTIM2, |
| 115 | CFG_SYS_NAND_FTIM3 |
Pankit Garg | 112aeba | 2018-12-27 04:37:57 +0000 | [diff] [blame] | 116 | }, |
| 117 | }, |
| 118 | { |
| 119 | "reserved", |
| 120 | }, |
| 121 | { |
| 122 | "fpga", |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 123 | CFG_SYS_FPGA_CSPR, |
| 124 | CFG_SYS_FPGA_CSPR_EXT, |
Pankit Garg | 112aeba | 2018-12-27 04:37:57 +0000 | [diff] [blame] | 125 | SYS_FPGA_AMASK, |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 126 | CFG_SYS_FPGA_CSOR, |
Pankit Garg | 112aeba | 2018-12-27 04:37:57 +0000 | [diff] [blame] | 127 | { |
| 128 | SYS_FPGA_CS_FTIM0, |
| 129 | SYS_FPGA_CS_FTIM1, |
| 130 | SYS_FPGA_CS_FTIM2, |
| 131 | SYS_FPGA_CS_FTIM3 |
| 132 | }, |
| 133 | 0, |
| 134 | SYS_FPGA_CSPR_FINAL, |
| 135 | 0, |
| 136 | } |
| 137 | }; |
| 138 | |
| 139 | void ifc_cfg_boot_info(struct ifc_regs_info *regs_info) |
| 140 | { |
| 141 | enum boot_src src = get_boot_src(); |
| 142 | |
| 143 | if (src == BOOT_SOURCE_QSPI_NOR) |
| 144 | regs_info->regs = ifc_cfg_qspi_nor_boot; |
| 145 | else |
| 146 | regs_info->regs = ifc_cfg_ifc_nor_boot; |
| 147 | |
| 148 | regs_info->cs_size = CONFIG_SYS_FSL_IFC_BANK_COUNT; |
| 149 | } |
| 150 | #endif /* CONFIG_TFABOOT */ |
| 151 | #endif /* CONFIG_TARGET_LS1088AQDS */ |
| 152 | |
Sumit Garg | 08da8b2 | 2018-01-06 09:04:24 +0530 | [diff] [blame] | 153 | int board_early_init_f(void) |
| 154 | { |
Ashish Kumar | f719b19 | 2018-02-19 14:14:53 +0530 | [diff] [blame] | 155 | #if defined(CONFIG_SYS_I2C_EARLY_INIT) && defined(CONFIG_TARGET_LS1088AQDS) |
| 156 | i2c_early_init_f(); |
| 157 | #endif |
Sumit Garg | 08da8b2 | 2018-01-06 09:04:24 +0530 | [diff] [blame] | 158 | fsl_lsch3_early_init_f(); |
| 159 | return 0; |
| 160 | } |
| 161 | |
| 162 | #ifdef CONFIG_FSL_QIXIS |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 163 | unsigned long long get_qixis_addr(void) |
| 164 | { |
| 165 | unsigned long long addr; |
| 166 | |
| 167 | if (gd->flags & GD_FLG_RELOC) |
| 168 | addr = QIXIS_BASE_PHYS; |
| 169 | else |
| 170 | addr = QIXIS_BASE_PHYS_EARLY; |
| 171 | |
| 172 | /* |
| 173 | * IFC address under 256MB is mapped to 0x30000000, any address above |
| 174 | * is mapped to 0x5_10000000 up to 4GB. |
| 175 | */ |
| 176 | addr = addr > 0x10000000 ? addr + 0x500000000ULL : addr + 0x30000000; |
| 177 | |
| 178 | return addr; |
| 179 | } |
Sumit Garg | 08da8b2 | 2018-01-06 09:04:24 +0530 | [diff] [blame] | 180 | #endif |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 181 | |
Rajesh Bhagat | a421625 | 2018-01-17 16:13:09 +0530 | [diff] [blame] | 182 | #if defined(CONFIG_VID) |
Simon Glass | 14f1d29 | 2023-08-21 21:17:00 -0600 | [diff] [blame] | 183 | static int setup_core_voltage(void) |
Rajesh Bhagat | a421625 | 2018-01-17 16:13:09 +0530 | [diff] [blame] | 184 | { |
| 185 | if (adjust_vdd(0) < 0) |
| 186 | printf("core voltage not adjusted\n"); |
| 187 | |
| 188 | return 0; |
| 189 | } |
Simon Glass | 14f1d29 | 2023-08-21 21:17:00 -0600 | [diff] [blame] | 190 | EVENT_SPY_SIMPLE(EVT_MISC_INIT_F, setup_core_voltage); |
Stephen Carlson | c3301a2 | 2021-02-08 11:11:29 +0100 | [diff] [blame] | 191 | |
| 192 | u16 soc_get_fuse_vid(int vid_index) |
| 193 | { |
| 194 | static const u16 vdd[32] = { |
| 195 | 10250, |
| 196 | 9875, |
| 197 | 9750, |
| 198 | 0, /* reserved */ |
| 199 | 0, /* reserved */ |
| 200 | 0, /* reserved */ |
| 201 | 0, /* reserved */ |
| 202 | 0, /* reserved */ |
| 203 | 9000, |
| 204 | 0, /* reserved */ |
| 205 | 0, /* reserved */ |
| 206 | 0, /* reserved */ |
| 207 | 0, /* reserved */ |
| 208 | 0, /* reserved */ |
| 209 | 0, /* reserved */ |
| 210 | 0, /* reserved */ |
| 211 | 10000, /* 1.0000V */ |
| 212 | 10125, |
| 213 | 10250, |
| 214 | 0, /* reserved */ |
| 215 | 0, /* reserved */ |
| 216 | 0, /* reserved */ |
| 217 | 0, /* reserved */ |
| 218 | 0, /* reserved */ |
| 219 | 0, /* reserved */ |
| 220 | 0, /* reserved */ |
| 221 | 0, /* reserved */ |
| 222 | 0, /* reserved */ |
| 223 | 0, /* reserved */ |
| 224 | 0, /* reserved */ |
| 225 | 0, /* reserved */ |
| 226 | 0, /* reserved */ |
| 227 | }; |
| 228 | |
| 229 | return vdd[vid_index]; |
| 230 | }; |
Rajesh Bhagat | a421625 | 2018-01-17 16:13:09 +0530 | [diff] [blame] | 231 | #endif |
| 232 | |
Pramod Kumar | a053182 | 2018-10-12 14:04:27 +0000 | [diff] [blame] | 233 | int is_pb_board(void) |
| 234 | { |
| 235 | u8 board_id; |
| 236 | |
| 237 | board_id = QIXIS_READ(id); |
| 238 | if (board_id == LS1088ARDB_PB_BOARD) |
| 239 | return 1; |
| 240 | else |
| 241 | return 0; |
| 242 | } |
| 243 | |
| 244 | int fixup_ls1088ardb_pb_banner(void *fdt) |
| 245 | { |
| 246 | fdt_setprop_string(fdt, 0, "model", "LS1088ARDB-PB Board"); |
| 247 | |
| 248 | return 0; |
| 249 | } |
| 250 | |
Sumit Garg | 08da8b2 | 2018-01-06 09:04:24 +0530 | [diff] [blame] | 251 | #if !defined(CONFIG_SPL_BUILD) |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 252 | int checkboard(void) |
| 253 | { |
Pankit Garg | f5c2a83 | 2018-12-27 04:37:55 +0000 | [diff] [blame] | 254 | #ifdef CONFIG_TFABOOT |
| 255 | enum boot_src src = get_boot_src(); |
| 256 | #endif |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 257 | char buf[64]; |
| 258 | u8 sw; |
| 259 | static const char *const freq[] = {"100", "125", "156.25", |
| 260 | "100 separate SSCG"}; |
| 261 | int clock; |
| 262 | |
Ashish Kumar | 1ef4c77 | 2017-08-31 16:12:55 +0530 | [diff] [blame] | 263 | #ifdef CONFIG_TARGET_LS1088AQDS |
| 264 | printf("Board: LS1088A-QDS, "); |
| 265 | #else |
Pramod Kumar | a053182 | 2018-10-12 14:04:27 +0000 | [diff] [blame] | 266 | if (is_pb_board()) |
| 267 | printf("Board: LS1088ARDB-PB, "); |
| 268 | else |
| 269 | printf("Board: LS1088A-RDB, "); |
Ashish Kumar | 1ef4c77 | 2017-08-31 16:12:55 +0530 | [diff] [blame] | 270 | #endif |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 271 | |
| 272 | sw = QIXIS_READ(arch); |
| 273 | printf("Board Arch: V%d, ", sw >> 4); |
| 274 | |
Ashish Kumar | 1ef4c77 | 2017-08-31 16:12:55 +0530 | [diff] [blame] | 275 | #ifdef CONFIG_TARGET_LS1088AQDS |
| 276 | printf("Board version: %c, boot from ", (sw & 0xf) + 'A' - 1); |
| 277 | #else |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 278 | printf("Board version: %c, boot from ", (sw & 0xf) + 'A'); |
Ashish Kumar | 1ef4c77 | 2017-08-31 16:12:55 +0530 | [diff] [blame] | 279 | #endif |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 280 | |
| 281 | memset((u8 *)buf, 0x00, ARRAY_SIZE(buf)); |
| 282 | |
| 283 | sw = QIXIS_READ(brdcfg[0]); |
| 284 | sw = (sw & QIXIS_LBMAP_MASK) >> QIXIS_LBMAP_SHIFT; |
| 285 | |
Pankit Garg | f5c2a83 | 2018-12-27 04:37:55 +0000 | [diff] [blame] | 286 | #ifdef CONFIG_TFABOOT |
| 287 | if (src == BOOT_SOURCE_SD_MMC) |
| 288 | puts("SD card\n"); |
| 289 | #else |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 290 | #ifdef CONFIG_SD_BOOT |
| 291 | puts("SD card\n"); |
| 292 | #endif |
Pankit Garg | f5c2a83 | 2018-12-27 04:37:55 +0000 | [diff] [blame] | 293 | #endif /* CONFIG_TFABOOT */ |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 294 | switch (sw) { |
Ashish Kumar | 1ef4c77 | 2017-08-31 16:12:55 +0530 | [diff] [blame] | 295 | #ifdef CONFIG_TARGET_LS1088AQDS |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 296 | case 0: |
Ashish Kumar | 1ef4c77 | 2017-08-31 16:12:55 +0530 | [diff] [blame] | 297 | case 1: |
| 298 | case 2: |
| 299 | case 3: |
| 300 | case 4: |
| 301 | case 5: |
| 302 | case 6: |
| 303 | case 7: |
| 304 | printf("vBank: %d\n", sw); |
| 305 | break; |
| 306 | case 8: |
| 307 | puts("PromJet\n"); |
| 308 | break; |
| 309 | case 15: |
| 310 | puts("IFCCard\n"); |
| 311 | break; |
| 312 | case 14: |
| 313 | #else |
| 314 | case 0: |
| 315 | #endif |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 316 | puts("QSPI:"); |
| 317 | sw = QIXIS_READ(brdcfg[0]); |
| 318 | sw = (sw & QIXIS_QMAP_MASK) >> QIXIS_QMAP_SHIFT; |
| 319 | if (sw == 0 || sw == 4) |
| 320 | puts("0\n"); |
| 321 | else if (sw == 1) |
| 322 | puts("1\n"); |
| 323 | else |
| 324 | puts("EMU\n"); |
| 325 | break; |
| 326 | |
| 327 | default: |
| 328 | printf("invalid setting of SW%u\n", QIXIS_LBMAP_SWITCH); |
| 329 | break; |
| 330 | } |
| 331 | |
Ashish Kumar | 1ef4c77 | 2017-08-31 16:12:55 +0530 | [diff] [blame] | 332 | #ifdef CONFIG_TARGET_LS1088AQDS |
| 333 | printf("FPGA: v%d (%s), build %d", |
| 334 | (int)QIXIS_READ(scver), qixis_read_tag(buf), |
| 335 | (int)qixis_read_minor()); |
| 336 | /* the timestamp string contains "\n" at the end */ |
| 337 | printf(" on %s", qixis_read_time(buf)); |
| 338 | #else |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 339 | printf("CPLD: v%d.%d\n", QIXIS_READ(scver), QIXIS_READ(tagdata)); |
Ashish Kumar | 1ef4c77 | 2017-08-31 16:12:55 +0530 | [diff] [blame] | 340 | #endif |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 341 | |
| 342 | /* |
| 343 | * Display the actual SERDES reference clocks as configured by the |
| 344 | * dip switches on the board. Note that the SWx registers could |
| 345 | * technically be set to force the reference clocks to match the |
| 346 | * values that the SERDES expects (or vice versa). For now, however, |
| 347 | * we just display both values and hope the user notices when they |
| 348 | * don't match. |
| 349 | */ |
| 350 | puts("SERDES1 Reference : "); |
| 351 | sw = QIXIS_READ(brdcfg[2]); |
| 352 | clock = (sw >> 6) & 3; |
| 353 | printf("Clock1 = %sMHz ", freq[clock]); |
| 354 | clock = (sw >> 4) & 3; |
| 355 | printf("Clock2 = %sMHz", freq[clock]); |
| 356 | |
| 357 | puts("\nSERDES2 Reference : "); |
| 358 | clock = (sw >> 2) & 3; |
| 359 | printf("Clock1 = %sMHz ", freq[clock]); |
| 360 | clock = (sw >> 0) & 3; |
| 361 | printf("Clock2 = %sMHz\n", freq[clock]); |
| 362 | |
| 363 | return 0; |
| 364 | } |
Ashish Kumar | d029b27 | 2018-02-19 14:14:52 +0530 | [diff] [blame] | 365 | #endif |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 366 | |
| 367 | bool if_board_diff_clk(void) |
| 368 | { |
Ashish Kumar | 1ef4c77 | 2017-08-31 16:12:55 +0530 | [diff] [blame] | 369 | #ifdef CONFIG_TARGET_LS1088AQDS |
| 370 | u8 diff_conf = QIXIS_READ(brdcfg[11]); |
| 371 | return diff_conf & 0x40; |
| 372 | #else |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 373 | u8 diff_conf = QIXIS_READ(dutcfg[11]); |
| 374 | return diff_conf & 0x80; |
Ashish Kumar | 1ef4c77 | 2017-08-31 16:12:55 +0530 | [diff] [blame] | 375 | #endif |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 376 | } |
| 377 | |
Tom Rini | aea2a99 | 2021-12-14 13:36:39 -0500 | [diff] [blame] | 378 | #ifdef CONFIG_DYNAMIC_SYS_CLK_FREQ |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 379 | unsigned long get_board_sys_clk(void) |
| 380 | { |
| 381 | u8 sysclk_conf = QIXIS_READ(brdcfg[1]); |
| 382 | |
| 383 | switch (sysclk_conf & 0x0f) { |
| 384 | case QIXIS_SYSCLK_83: |
| 385 | return 83333333; |
| 386 | case QIXIS_SYSCLK_100: |
| 387 | return 100000000; |
| 388 | case QIXIS_SYSCLK_125: |
| 389 | return 125000000; |
| 390 | case QIXIS_SYSCLK_133: |
| 391 | return 133333333; |
| 392 | case QIXIS_SYSCLK_150: |
| 393 | return 150000000; |
| 394 | case QIXIS_SYSCLK_160: |
| 395 | return 160000000; |
| 396 | case QIXIS_SYSCLK_166: |
| 397 | return 166666666; |
| 398 | } |
| 399 | |
| 400 | return 66666666; |
| 401 | } |
Tom Rini | aea2a99 | 2021-12-14 13:36:39 -0500 | [diff] [blame] | 402 | #endif |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 403 | |
Tom Rini | 8fa9125 | 2021-12-14 13:36:37 -0500 | [diff] [blame] | 404 | #ifdef CONFIG_DYNAMIC_DDR_CLK_FREQ |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 405 | unsigned long get_board_ddr_clk(void) |
| 406 | { |
| 407 | u8 ddrclk_conf = QIXIS_READ(brdcfg[1]); |
| 408 | |
| 409 | if (if_board_diff_clk()) |
| 410 | return get_board_sys_clk(); |
| 411 | switch ((ddrclk_conf & 0x30) >> 4) { |
| 412 | case QIXIS_DDRCLK_100: |
| 413 | return 100000000; |
| 414 | case QIXIS_DDRCLK_125: |
| 415 | return 125000000; |
| 416 | case QIXIS_DDRCLK_133: |
| 417 | return 133333333; |
| 418 | } |
| 419 | |
| 420 | return 66666666; |
| 421 | } |
Tom Rini | 8fa9125 | 2021-12-14 13:36:37 -0500 | [diff] [blame] | 422 | #endif |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 423 | |
Rajesh Bhagat | 6d809b8 | 2018-01-17 16:13:10 +0530 | [diff] [blame] | 424 | #if !defined(CONFIG_SPL_BUILD) |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 425 | void board_retimer_init(void) |
| 426 | { |
| 427 | u8 reg; |
| 428 | |
| 429 | /* Retimer is connected to I2C1_CH5 */ |
Stephen Carlson | 267ddcc | 2021-06-22 16:41:38 -0700 | [diff] [blame] | 430 | select_i2c_ch_pca9547(I2C_MUX_CH5, 0); |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 431 | |
| 432 | /* Access to Control/Shared register */ |
| 433 | reg = 0x0; |
Igor Opaniuk | f7c9176 | 2021-02-09 13:52:45 +0200 | [diff] [blame] | 434 | #if !CONFIG_IS_ENABLED(DM_I2C) |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 435 | i2c_write(I2C_RETIMER_ADDR, 0xff, 1, ®, 1); |
Chuanhua Han | 8a89846 | 2019-07-23 18:43:11 +0800 | [diff] [blame] | 436 | #else |
| 437 | struct udevice *dev; |
| 438 | |
| 439 | i2c_get_chip_for_busnum(0, I2C_RETIMER_ADDR, 1, &dev); |
| 440 | dm_i2c_write(dev, 0xff, ®, 1); |
| 441 | #endif |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 442 | |
| 443 | /* Read device revision and ID */ |
Igor Opaniuk | f7c9176 | 2021-02-09 13:52:45 +0200 | [diff] [blame] | 444 | #if !CONFIG_IS_ENABLED(DM_I2C) |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 445 | i2c_read(I2C_RETIMER_ADDR, 1, 1, ®, 1); |
Chuanhua Han | 8a89846 | 2019-07-23 18:43:11 +0800 | [diff] [blame] | 446 | #else |
| 447 | dm_i2c_read(dev, 1, ®, 1); |
| 448 | #endif |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 449 | debug("Retimer version id = 0x%x\n", reg); |
| 450 | |
| 451 | /* Enable Broadcast. All writes target all channel register sets */ |
| 452 | reg = 0x0c; |
Igor Opaniuk | f7c9176 | 2021-02-09 13:52:45 +0200 | [diff] [blame] | 453 | #if !CONFIG_IS_ENABLED(DM_I2C) |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 454 | i2c_write(I2C_RETIMER_ADDR, 0xff, 1, ®, 1); |
Chuanhua Han | 8a89846 | 2019-07-23 18:43:11 +0800 | [diff] [blame] | 455 | #else |
| 456 | dm_i2c_write(dev, 0xff, ®, 1); |
| 457 | #endif |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 458 | |
| 459 | /* Reset Channel Registers */ |
Igor Opaniuk | f7c9176 | 2021-02-09 13:52:45 +0200 | [diff] [blame] | 460 | #if !CONFIG_IS_ENABLED(DM_I2C) |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 461 | i2c_read(I2C_RETIMER_ADDR, 0, 1, ®, 1); |
Chuanhua Han | 8a89846 | 2019-07-23 18:43:11 +0800 | [diff] [blame] | 462 | #else |
| 463 | dm_i2c_read(dev, 0, ®, 1); |
| 464 | #endif |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 465 | reg |= 0x4; |
Igor Opaniuk | f7c9176 | 2021-02-09 13:52:45 +0200 | [diff] [blame] | 466 | #if !CONFIG_IS_ENABLED(DM_I2C) |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 467 | i2c_write(I2C_RETIMER_ADDR, 0, 1, ®, 1); |
Chuanhua Han | 8a89846 | 2019-07-23 18:43:11 +0800 | [diff] [blame] | 468 | #else |
| 469 | dm_i2c_write(dev, 0, ®, 1); |
| 470 | #endif |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 471 | |
| 472 | /* Set data rate as 10.3125 Gbps */ |
| 473 | reg = 0x90; |
Igor Opaniuk | f7c9176 | 2021-02-09 13:52:45 +0200 | [diff] [blame] | 474 | #if !CONFIG_IS_ENABLED(DM_I2C) |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 475 | i2c_write(I2C_RETIMER_ADDR, 0x60, 1, ®, 1); |
Chuanhua Han | 8a89846 | 2019-07-23 18:43:11 +0800 | [diff] [blame] | 476 | #else |
| 477 | dm_i2c_write(dev, 0x60, ®, 1); |
| 478 | #endif |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 479 | reg = 0xb3; |
Igor Opaniuk | f7c9176 | 2021-02-09 13:52:45 +0200 | [diff] [blame] | 480 | #if !CONFIG_IS_ENABLED(DM_I2C) |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 481 | i2c_write(I2C_RETIMER_ADDR, 0x61, 1, ®, 1); |
Chuanhua Han | 8a89846 | 2019-07-23 18:43:11 +0800 | [diff] [blame] | 482 | #else |
| 483 | dm_i2c_write(dev, 0x61, ®, 1); |
| 484 | #endif |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 485 | reg = 0x90; |
Igor Opaniuk | f7c9176 | 2021-02-09 13:52:45 +0200 | [diff] [blame] | 486 | #if !CONFIG_IS_ENABLED(DM_I2C) |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 487 | i2c_write(I2C_RETIMER_ADDR, 0x62, 1, ®, 1); |
Chuanhua Han | 8a89846 | 2019-07-23 18:43:11 +0800 | [diff] [blame] | 488 | #else |
| 489 | dm_i2c_write(dev, 0x62, ®, 1); |
| 490 | #endif |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 491 | reg = 0xb3; |
Igor Opaniuk | f7c9176 | 2021-02-09 13:52:45 +0200 | [diff] [blame] | 492 | #if !CONFIG_IS_ENABLED(DM_I2C) |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 493 | i2c_write(I2C_RETIMER_ADDR, 0x63, 1, ®, 1); |
Chuanhua Han | 8a89846 | 2019-07-23 18:43:11 +0800 | [diff] [blame] | 494 | #else |
| 495 | dm_i2c_write(dev, 0x63, ®, 1); |
| 496 | #endif |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 497 | reg = 0xcd; |
Igor Opaniuk | f7c9176 | 2021-02-09 13:52:45 +0200 | [diff] [blame] | 498 | #if !CONFIG_IS_ENABLED(DM_I2C) |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 499 | i2c_write(I2C_RETIMER_ADDR, 0x64, 1, ®, 1); |
Chuanhua Han | 8a89846 | 2019-07-23 18:43:11 +0800 | [diff] [blame] | 500 | #else |
| 501 | dm_i2c_write(dev, 0x64, ®, 1); |
| 502 | #endif |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 503 | |
| 504 | /* Select VCO Divider to full rate (000) */ |
Igor Opaniuk | f7c9176 | 2021-02-09 13:52:45 +0200 | [diff] [blame] | 505 | #if !CONFIG_IS_ENABLED(DM_I2C) |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 506 | i2c_read(I2C_RETIMER_ADDR, 0x2F, 1, ®, 1); |
Chuanhua Han | 8a89846 | 2019-07-23 18:43:11 +0800 | [diff] [blame] | 507 | #else |
| 508 | dm_i2c_read(dev, 0x2F, ®, 1); |
| 509 | #endif |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 510 | reg &= 0x0f; |
| 511 | reg |= 0x70; |
Igor Opaniuk | f7c9176 | 2021-02-09 13:52:45 +0200 | [diff] [blame] | 512 | #if !CONFIG_IS_ENABLED(DM_I2C) |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 513 | i2c_write(I2C_RETIMER_ADDR, 0x2F, 1, ®, 1); |
Chuanhua Han | 8a89846 | 2019-07-23 18:43:11 +0800 | [diff] [blame] | 514 | #else |
| 515 | dm_i2c_write(dev, 0x2F, ®, 1); |
| 516 | #endif |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 517 | |
Ashish Kumar | 1ef4c77 | 2017-08-31 16:12:55 +0530 | [diff] [blame] | 518 | #ifdef CONFIG_TARGET_LS1088AQDS |
| 519 | /* Retimer is connected to I2C1_CH5 */ |
Stephen Carlson | 267ddcc | 2021-06-22 16:41:38 -0700 | [diff] [blame] | 520 | select_i2c_ch_pca9547(I2C_MUX_CH5, 0); |
Ashish Kumar | 1ef4c77 | 2017-08-31 16:12:55 +0530 | [diff] [blame] | 521 | |
| 522 | /* Access to Control/Shared register */ |
| 523 | reg = 0x0; |
Igor Opaniuk | f7c9176 | 2021-02-09 13:52:45 +0200 | [diff] [blame] | 524 | #if !CONFIG_IS_ENABLED(DM_I2C) |
Ashish Kumar | 1ef4c77 | 2017-08-31 16:12:55 +0530 | [diff] [blame] | 525 | i2c_write(I2C_RETIMER_ADDR2, 0xff, 1, ®, 1); |
Chuanhua Han | 8a89846 | 2019-07-23 18:43:11 +0800 | [diff] [blame] | 526 | #else |
| 527 | i2c_get_chip_for_busnum(0, I2C_RETIMER_ADDR2, 1, &dev); |
| 528 | dm_i2c_write(dev, 0xff, ®, 1); |
| 529 | #endif |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 530 | |
Ashish Kumar | 1ef4c77 | 2017-08-31 16:12:55 +0530 | [diff] [blame] | 531 | /* Read device revision and ID */ |
Igor Opaniuk | f7c9176 | 2021-02-09 13:52:45 +0200 | [diff] [blame] | 532 | #if !CONFIG_IS_ENABLED(DM_I2C) |
Ashish Kumar | 1ef4c77 | 2017-08-31 16:12:55 +0530 | [diff] [blame] | 533 | i2c_read(I2C_RETIMER_ADDR2, 1, 1, ®, 1); |
Chuanhua Han | 8a89846 | 2019-07-23 18:43:11 +0800 | [diff] [blame] | 534 | #else |
| 535 | dm_i2c_read(dev, 1, ®, 1); |
| 536 | #endif |
Ashish Kumar | 1ef4c77 | 2017-08-31 16:12:55 +0530 | [diff] [blame] | 537 | debug("Retimer version id = 0x%x\n", reg); |
| 538 | |
| 539 | /* Enable Broadcast. All writes target all channel register sets */ |
| 540 | reg = 0x0c; |
Igor Opaniuk | f7c9176 | 2021-02-09 13:52:45 +0200 | [diff] [blame] | 541 | #if !CONFIG_IS_ENABLED(DM_I2C) |
Ashish Kumar | 1ef4c77 | 2017-08-31 16:12:55 +0530 | [diff] [blame] | 542 | i2c_write(I2C_RETIMER_ADDR2, 0xff, 1, ®, 1); |
Chuanhua Han | 8a89846 | 2019-07-23 18:43:11 +0800 | [diff] [blame] | 543 | #else |
| 544 | dm_i2c_write(dev, 0xff, ®, 1); |
| 545 | #endif |
Ashish Kumar | 1ef4c77 | 2017-08-31 16:12:55 +0530 | [diff] [blame] | 546 | |
| 547 | /* Reset Channel Registers */ |
Igor Opaniuk | f7c9176 | 2021-02-09 13:52:45 +0200 | [diff] [blame] | 548 | #if !CONFIG_IS_ENABLED(DM_I2C) |
Ashish Kumar | 1ef4c77 | 2017-08-31 16:12:55 +0530 | [diff] [blame] | 549 | i2c_read(I2C_RETIMER_ADDR2, 0, 1, ®, 1); |
Chuanhua Han | 8a89846 | 2019-07-23 18:43:11 +0800 | [diff] [blame] | 550 | #else |
| 551 | dm_i2c_read(dev, 0, ®, 1); |
| 552 | #endif |
Ashish Kumar | 1ef4c77 | 2017-08-31 16:12:55 +0530 | [diff] [blame] | 553 | reg |= 0x4; |
Igor Opaniuk | f7c9176 | 2021-02-09 13:52:45 +0200 | [diff] [blame] | 554 | #if !CONFIG_IS_ENABLED(DM_I2C) |
Ashish Kumar | 1ef4c77 | 2017-08-31 16:12:55 +0530 | [diff] [blame] | 555 | i2c_write(I2C_RETIMER_ADDR2, 0, 1, ®, 1); |
Chuanhua Han | 8a89846 | 2019-07-23 18:43:11 +0800 | [diff] [blame] | 556 | #else |
| 557 | dm_i2c_write(dev, 0, ®, 1); |
| 558 | #endif |
Ashish Kumar | 1ef4c77 | 2017-08-31 16:12:55 +0530 | [diff] [blame] | 559 | |
| 560 | /* Set data rate as 10.3125 Gbps */ |
| 561 | reg = 0x90; |
Igor Opaniuk | f7c9176 | 2021-02-09 13:52:45 +0200 | [diff] [blame] | 562 | #if !CONFIG_IS_ENABLED(DM_I2C) |
Ashish Kumar | 1ef4c77 | 2017-08-31 16:12:55 +0530 | [diff] [blame] | 563 | i2c_write(I2C_RETIMER_ADDR2, 0x60, 1, ®, 1); |
Chuanhua Han | 8a89846 | 2019-07-23 18:43:11 +0800 | [diff] [blame] | 564 | #else |
| 565 | dm_i2c_write(dev, 0x60, ®, 1); |
| 566 | #endif |
Ashish Kumar | 1ef4c77 | 2017-08-31 16:12:55 +0530 | [diff] [blame] | 567 | reg = 0xb3; |
Igor Opaniuk | f7c9176 | 2021-02-09 13:52:45 +0200 | [diff] [blame] | 568 | #if !CONFIG_IS_ENABLED(DM_I2C) |
Ashish Kumar | 1ef4c77 | 2017-08-31 16:12:55 +0530 | [diff] [blame] | 569 | i2c_write(I2C_RETIMER_ADDR2, 0x61, 1, ®, 1); |
Chuanhua Han | 8a89846 | 2019-07-23 18:43:11 +0800 | [diff] [blame] | 570 | #else |
| 571 | dm_i2c_write(dev, 0x61, ®, 1); |
| 572 | #endif |
Ashish Kumar | 1ef4c77 | 2017-08-31 16:12:55 +0530 | [diff] [blame] | 573 | reg = 0x90; |
Igor Opaniuk | f7c9176 | 2021-02-09 13:52:45 +0200 | [diff] [blame] | 574 | #if !CONFIG_IS_ENABLED(DM_I2C) |
Ashish Kumar | 1ef4c77 | 2017-08-31 16:12:55 +0530 | [diff] [blame] | 575 | i2c_write(I2C_RETIMER_ADDR2, 0x62, 1, ®, 1); |
Chuanhua Han | 8a89846 | 2019-07-23 18:43:11 +0800 | [diff] [blame] | 576 | #else |
| 577 | dm_i2c_write(dev, 0x62, ®, 1); |
| 578 | #endif |
Ashish Kumar | 1ef4c77 | 2017-08-31 16:12:55 +0530 | [diff] [blame] | 579 | reg = 0xb3; |
Igor Opaniuk | f7c9176 | 2021-02-09 13:52:45 +0200 | [diff] [blame] | 580 | #if !CONFIG_IS_ENABLED(DM_I2C) |
Ashish Kumar | 1ef4c77 | 2017-08-31 16:12:55 +0530 | [diff] [blame] | 581 | i2c_write(I2C_RETIMER_ADDR2, 0x63, 1, ®, 1); |
Chuanhua Han | 8a89846 | 2019-07-23 18:43:11 +0800 | [diff] [blame] | 582 | #else |
| 583 | dm_i2c_write(dev, 0x63, ®, 1); |
| 584 | #endif |
Ashish Kumar | 1ef4c77 | 2017-08-31 16:12:55 +0530 | [diff] [blame] | 585 | reg = 0xcd; |
Igor Opaniuk | f7c9176 | 2021-02-09 13:52:45 +0200 | [diff] [blame] | 586 | #if !CONFIG_IS_ENABLED(DM_I2C) |
Ashish Kumar | 1ef4c77 | 2017-08-31 16:12:55 +0530 | [diff] [blame] | 587 | i2c_write(I2C_RETIMER_ADDR2, 0x64, 1, ®, 1); |
Chuanhua Han | 8a89846 | 2019-07-23 18:43:11 +0800 | [diff] [blame] | 588 | #else |
| 589 | dm_i2c_write(dev, 0x64, ®, 1); |
| 590 | #endif |
Ashish Kumar | 1ef4c77 | 2017-08-31 16:12:55 +0530 | [diff] [blame] | 591 | |
| 592 | /* Select VCO Divider to full rate (000) */ |
Igor Opaniuk | f7c9176 | 2021-02-09 13:52:45 +0200 | [diff] [blame] | 593 | #if !CONFIG_IS_ENABLED(DM_I2C) |
Ashish Kumar | 1ef4c77 | 2017-08-31 16:12:55 +0530 | [diff] [blame] | 594 | i2c_read(I2C_RETIMER_ADDR2, 0x2F, 1, ®, 1); |
Chuanhua Han | 8a89846 | 2019-07-23 18:43:11 +0800 | [diff] [blame] | 595 | #else |
| 596 | dm_i2c_read(dev, 0x2F, ®, 1); |
| 597 | #endif |
Ashish Kumar | 1ef4c77 | 2017-08-31 16:12:55 +0530 | [diff] [blame] | 598 | reg &= 0x0f; |
| 599 | reg |= 0x70; |
Igor Opaniuk | f7c9176 | 2021-02-09 13:52:45 +0200 | [diff] [blame] | 600 | #if !CONFIG_IS_ENABLED(DM_I2C) |
Ashish Kumar | 1ef4c77 | 2017-08-31 16:12:55 +0530 | [diff] [blame] | 601 | i2c_write(I2C_RETIMER_ADDR2, 0x2F, 1, ®, 1); |
Chuanhua Han | 8a89846 | 2019-07-23 18:43:11 +0800 | [diff] [blame] | 602 | #else |
| 603 | dm_i2c_write(dev, 0x2F, ®, 1); |
| 604 | #endif |
| 605 | |
Ashish Kumar | 1ef4c77 | 2017-08-31 16:12:55 +0530 | [diff] [blame] | 606 | #endif |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 607 | /*return the default channel*/ |
Stephen Carlson | 267ddcc | 2021-06-22 16:41:38 -0700 | [diff] [blame] | 608 | select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT, 0); |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 609 | } |
| 610 | |
Yangbo Lu | 1d87953 | 2017-11-27 15:40:17 +0800 | [diff] [blame] | 611 | #ifdef CONFIG_MISC_INIT_R |
| 612 | int misc_init_r(void) |
| 613 | { |
| 614 | #ifdef CONFIG_TARGET_LS1088ARDB |
| 615 | u8 brdcfg5; |
| 616 | |
| 617 | if (hwconfig("esdhc-force-sd")) { |
| 618 | brdcfg5 = QIXIS_READ(brdcfg[5]); |
| 619 | brdcfg5 &= ~BRDCFG5_SPISDHC_MASK; |
| 620 | brdcfg5 |= BRDCFG5_FORCE_SD; |
| 621 | QIXIS_WRITE(brdcfg[5], brdcfg5); |
| 622 | } |
| 623 | #endif |
Chuanhua Han | 26b39ef | 2019-08-01 16:36:57 +0800 | [diff] [blame] | 624 | |
| 625 | #ifdef CONFIG_TARGET_LS1088AQDS |
| 626 | u8 brdcfg4, brdcfg5; |
| 627 | |
| 628 | if (hwconfig("dspi-on-board")) { |
| 629 | brdcfg4 = QIXIS_READ(brdcfg[4]); |
| 630 | brdcfg4 &= ~BRDCFG4_USBOSC_MASK; |
| 631 | brdcfg4 |= BRDCFG4_SPI; |
| 632 | QIXIS_WRITE(brdcfg[4], brdcfg4); |
| 633 | |
| 634 | brdcfg5 = QIXIS_READ(brdcfg[5]); |
| 635 | brdcfg5 &= ~BRDCFG5_SPR_MASK; |
| 636 | brdcfg5 |= BRDCFG5_SPI_ON_BOARD; |
| 637 | QIXIS_WRITE(brdcfg[5], brdcfg5); |
| 638 | } else if (hwconfig("dspi-off-board")) { |
| 639 | brdcfg4 = QIXIS_READ(brdcfg[4]); |
| 640 | brdcfg4 &= ~BRDCFG4_USBOSC_MASK; |
| 641 | brdcfg4 |= BRDCFG4_SPI; |
| 642 | QIXIS_WRITE(brdcfg[4], brdcfg4); |
| 643 | |
| 644 | brdcfg5 = QIXIS_READ(brdcfg[5]); |
| 645 | brdcfg5 &= ~BRDCFG5_SPR_MASK; |
| 646 | brdcfg5 |= BRDCFG5_SPI_OFF_BOARD; |
| 647 | QIXIS_WRITE(brdcfg[5], brdcfg5); |
| 648 | } |
| 649 | #endif |
Yangbo Lu | 1d87953 | 2017-11-27 15:40:17 +0800 | [diff] [blame] | 650 | return 0; |
| 651 | } |
| 652 | #endif |
Rajesh Bhagat | 6d809b8 | 2018-01-17 16:13:10 +0530 | [diff] [blame] | 653 | #endif |
Yangbo Lu | 1d87953 | 2017-11-27 15:40:17 +0800 | [diff] [blame] | 654 | |
Rajesh Bhagat | a421625 | 2018-01-17 16:13:09 +0530 | [diff] [blame] | 655 | int i2c_multiplexer_select_vid_channel(u8 channel) |
| 656 | { |
Stephen Carlson | 267ddcc | 2021-06-22 16:41:38 -0700 | [diff] [blame] | 657 | return select_i2c_ch_pca9547(channel, 0); |
Rajesh Bhagat | a421625 | 2018-01-17 16:13:09 +0530 | [diff] [blame] | 658 | } |
| 659 | |
| 660 | #ifdef CONFIG_TARGET_LS1088AQDS |
| 661 | /* read the current value(SVDD) of the LTM Regulator Voltage */ |
| 662 | int get_serdes_volt(void) |
| 663 | { |
| 664 | int ret, vcode = 0; |
| 665 | u8 chan = PWM_CHANNEL0; |
| 666 | |
| 667 | /* Select the PAGE 0 using PMBus commands PAGE for VDD */ |
Igor Opaniuk | f7c9176 | 2021-02-09 13:52:45 +0200 | [diff] [blame] | 668 | #if !CONFIG_IS_ENABLED(DM_I2C) |
Rajesh Bhagat | a421625 | 2018-01-17 16:13:09 +0530 | [diff] [blame] | 669 | ret = i2c_write(I2C_SVDD_MONITOR_ADDR, |
| 670 | PMBUS_CMD_PAGE, 1, &chan, 1); |
Chuanhua Han | 8a89846 | 2019-07-23 18:43:11 +0800 | [diff] [blame] | 671 | #else |
| 672 | struct udevice *dev; |
| 673 | |
| 674 | ret = i2c_get_chip_for_busnum(0, I2C_SVDD_MONITOR_ADDR, 1, &dev); |
| 675 | if (!ret) |
| 676 | ret = dm_i2c_write(dev, PMBUS_CMD_PAGE, |
| 677 | &chan, 1); |
| 678 | #endif |
| 679 | |
Rajesh Bhagat | a421625 | 2018-01-17 16:13:09 +0530 | [diff] [blame] | 680 | if (ret) { |
| 681 | printf("VID: failed to select VDD Page 0\n"); |
| 682 | return ret; |
| 683 | } |
| 684 | |
| 685 | /* Read the output voltage using PMBus command READ_VOUT */ |
Igor Opaniuk | f7c9176 | 2021-02-09 13:52:45 +0200 | [diff] [blame] | 686 | #if !CONFIG_IS_ENABLED(DM_I2C) |
Rajesh Bhagat | a421625 | 2018-01-17 16:13:09 +0530 | [diff] [blame] | 687 | ret = i2c_read(I2C_SVDD_MONITOR_ADDR, |
| 688 | PMBUS_CMD_READ_VOUT, 1, (void *)&vcode, 2); |
Chuanhua Han | 8a89846 | 2019-07-23 18:43:11 +0800 | [diff] [blame] | 689 | #else |
| 690 | dm_i2c_read(dev, PMBUS_CMD_READ_VOUT, (void *)&vcode, 2); |
| 691 | #endif |
Rajesh Bhagat | a421625 | 2018-01-17 16:13:09 +0530 | [diff] [blame] | 692 | if (ret) { |
| 693 | printf("VID: failed to read the volatge\n"); |
| 694 | return ret; |
| 695 | } |
| 696 | |
| 697 | return vcode; |
| 698 | } |
| 699 | |
| 700 | int set_serdes_volt(int svdd) |
| 701 | { |
| 702 | int ret, vdd_last; |
| 703 | u8 buff[5] = {0x04, PWM_CHANNEL0, PMBUS_CMD_VOUT_COMMAND, |
| 704 | svdd & 0xFF, (svdd & 0xFF00) >> 8}; |
| 705 | |
| 706 | /* Write the desired voltage code to the SVDD regulator */ |
Igor Opaniuk | f7c9176 | 2021-02-09 13:52:45 +0200 | [diff] [blame] | 707 | #if !CONFIG_IS_ENABLED(DM_I2C) |
Rajesh Bhagat | a421625 | 2018-01-17 16:13:09 +0530 | [diff] [blame] | 708 | ret = i2c_write(I2C_SVDD_MONITOR_ADDR, |
| 709 | PMBUS_CMD_PAGE_PLUS_WRITE, 1, (void *)&buff, 5); |
Chuanhua Han | 8a89846 | 2019-07-23 18:43:11 +0800 | [diff] [blame] | 710 | #else |
| 711 | struct udevice *dev; |
| 712 | |
| 713 | ret = i2c_get_chip_for_busnum(0, I2C_SVDD_MONITOR_ADDR, 1, &dev); |
| 714 | if (!ret) |
| 715 | ret = dm_i2c_write(dev, PMBUS_CMD_PAGE_PLUS_WRITE, |
| 716 | (void *)&buff, 5); |
| 717 | #endif |
Rajesh Bhagat | a421625 | 2018-01-17 16:13:09 +0530 | [diff] [blame] | 718 | if (ret) { |
| 719 | printf("VID: I2C failed to write to the volatge regulator\n"); |
| 720 | return -1; |
| 721 | } |
| 722 | |
| 723 | /* Wait for the volatge to get to the desired value */ |
| 724 | do { |
| 725 | vdd_last = get_serdes_volt(); |
| 726 | if (vdd_last < 0) { |
| 727 | printf("VID: Couldn't read sensor abort VID adjust\n"); |
| 728 | return -1; |
| 729 | } |
| 730 | } while (vdd_last != svdd); |
| 731 | |
| 732 | return 1; |
| 733 | } |
| 734 | #else |
| 735 | int get_serdes_volt(void) |
| 736 | { |
| 737 | return 0; |
| 738 | } |
| 739 | |
| 740 | int set_serdes_volt(int svdd) |
| 741 | { |
| 742 | int ret; |
| 743 | u8 brdcfg4; |
| 744 | |
| 745 | printf("SVDD changing of RDB\n"); |
| 746 | |
| 747 | /* Read the BRDCFG54 via CLPD */ |
Igor Opaniuk | f7c9176 | 2021-02-09 13:52:45 +0200 | [diff] [blame] | 748 | #if !CONFIG_IS_ENABLED(DM_I2C) |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 749 | ret = i2c_read(CFG_SYS_I2C_FPGA_ADDR, |
Rajesh Bhagat | a421625 | 2018-01-17 16:13:09 +0530 | [diff] [blame] | 750 | QIXIS_BRDCFG4_OFFSET, 1, (void *)&brdcfg4, 1); |
Chuanhua Han | 8a89846 | 2019-07-23 18:43:11 +0800 | [diff] [blame] | 751 | #else |
| 752 | struct udevice *dev; |
| 753 | |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 754 | ret = i2c_get_chip_for_busnum(0, CFG_SYS_I2C_FPGA_ADDR, 1, &dev); |
Chuanhua Han | 8a89846 | 2019-07-23 18:43:11 +0800 | [diff] [blame] | 755 | if (!ret) |
| 756 | ret = dm_i2c_read(dev, QIXIS_BRDCFG4_OFFSET, |
| 757 | (void *)&brdcfg4, 1); |
| 758 | #endif |
| 759 | |
Rajesh Bhagat | a421625 | 2018-01-17 16:13:09 +0530 | [diff] [blame] | 760 | if (ret) { |
| 761 | printf("VID: I2C failed to read the CPLD BRDCFG4\n"); |
| 762 | return -1; |
| 763 | } |
| 764 | |
| 765 | brdcfg4 = brdcfg4 | 0x08; |
| 766 | |
| 767 | /* Write to the BRDCFG4 */ |
Igor Opaniuk | f7c9176 | 2021-02-09 13:52:45 +0200 | [diff] [blame] | 768 | #if !CONFIG_IS_ENABLED(DM_I2C) |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 769 | ret = i2c_write(CFG_SYS_I2C_FPGA_ADDR, |
Rajesh Bhagat | a421625 | 2018-01-17 16:13:09 +0530 | [diff] [blame] | 770 | QIXIS_BRDCFG4_OFFSET, 1, (void *)&brdcfg4, 1); |
Chuanhua Han | 8a89846 | 2019-07-23 18:43:11 +0800 | [diff] [blame] | 771 | #else |
| 772 | ret = dm_i2c_write(dev, QIXIS_BRDCFG4_OFFSET, |
| 773 | (void *)&brdcfg4, 1); |
| 774 | #endif |
| 775 | |
Rajesh Bhagat | a421625 | 2018-01-17 16:13:09 +0530 | [diff] [blame] | 776 | if (ret) { |
| 777 | debug("VID: I2C failed to set the SVDD CPLD BRDCFG4\n"); |
| 778 | return -1; |
| 779 | } |
| 780 | |
| 781 | /* Wait for the volatge to get to the desired value */ |
| 782 | udelay(10000); |
| 783 | |
| 784 | return 1; |
| 785 | } |
| 786 | #endif |
| 787 | |
| 788 | /* this function disables the SERDES, changes the SVDD Voltage and enables it*/ |
| 789 | int board_adjust_vdd(int vdd) |
| 790 | { |
| 791 | int ret = 0; |
| 792 | |
| 793 | debug("%s: vdd = %d\n", __func__, vdd); |
| 794 | |
| 795 | /* Special settings to be performed when voltage is 900mV */ |
| 796 | if (vdd == 900) { |
| 797 | ret = setup_serdes_volt(vdd); |
| 798 | if (ret < 0) { |
| 799 | ret = -1; |
| 800 | goto exit; |
| 801 | } |
| 802 | } |
| 803 | exit: |
| 804 | return ret; |
| 805 | } |
| 806 | |
Rajesh Bhagat | 6d809b8 | 2018-01-17 16:13:10 +0530 | [diff] [blame] | 807 | #if !defined(CONFIG_SPL_BUILD) |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 808 | int board_init(void) |
| 809 | { |
| 810 | init_final_memctl_regs(); |
| 811 | #if defined(CONFIG_TARGET_LS1088ARDB) && defined(CONFIG_FSL_MC_ENET) |
| 812 | u32 __iomem *irq_ccsr = (u32 __iomem *)ISC_BASE; |
| 813 | #endif |
| 814 | |
Stephen Carlson | 267ddcc | 2021-06-22 16:41:38 -0700 | [diff] [blame] | 815 | select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT, 0); |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 816 | board_retimer_init(); |
| 817 | |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 818 | #if defined(CONFIG_TARGET_LS1088ARDB) && defined(CONFIG_FSL_MC_ENET) |
| 819 | /* invert AQR105 IRQ pins polarity */ |
| 820 | out_le32(irq_ccsr + IRQCR_OFFSET / 4, AQR105_IRQ_MASK); |
| 821 | #endif |
| 822 | |
Ioana Ciornei | 2ead443 | 2023-02-15 17:31:19 +0200 | [diff] [blame] | 823 | #if !defined(CONFIG_SYS_EARLY_PCI_INIT) |
Ioana Ciornei | 5d955a6 | 2020-03-18 16:47:39 +0200 | [diff] [blame] | 824 | pci_init(); |
| 825 | #endif |
| 826 | |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 827 | return 0; |
| 828 | } |
| 829 | |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 830 | void detail_board_ddr_info(void) |
| 831 | { |
| 832 | puts("\nDDR "); |
| 833 | print_size(gd->bd->bi_dram[0].size + gd->bd->bi_dram[1].size, ""); |
| 834 | print_ddr_info(0); |
| 835 | } |
| 836 | |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 837 | #ifdef CONFIG_FSL_MC_ENET |
Mian Yousaf Kaukab | e1dabf0 | 2019-01-29 16:38:30 +0100 | [diff] [blame] | 838 | void board_quiesce_devices(void) |
| 839 | { |
| 840 | fsl_mc_ldpaa_exit(gd->bd); |
| 841 | } |
| 842 | |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 843 | void fdt_fixup_board_enet(void *fdt) |
| 844 | { |
| 845 | int offset; |
| 846 | |
| 847 | offset = fdt_path_offset(fdt, "/fsl-mc"); |
| 848 | |
| 849 | if (offset < 0) |
Mian Yousaf Kaukab | 775c091 | 2019-01-29 16:38:31 +0100 | [diff] [blame] | 850 | offset = fdt_path_offset(fdt, "/soc/fsl-mc"); |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 851 | |
| 852 | if (offset < 0) { |
| 853 | printf("%s: ERROR: fsl-mc node not found in device tree (error %d)\n", |
| 854 | __func__, offset); |
| 855 | return; |
| 856 | } |
| 857 | |
Mian Yousaf Kaukab | 9712465 | 2018-12-18 14:01:17 +0100 | [diff] [blame] | 858 | if (get_mc_boot_status() == 0 && |
| 859 | (is_lazy_dpl_addr_valid() || get_dpl_apply_status() == 0)) |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 860 | fdt_status_okay(fdt, offset); |
| 861 | else |
| 862 | fdt_status_fail(fdt, offset); |
| 863 | } |
| 864 | #endif |
| 865 | |
| 866 | #ifdef CONFIG_OF_BOARD_SETUP |
Ashish Kumar | ff12b8a | 2017-11-09 11:14:24 +0530 | [diff] [blame] | 867 | void fsl_fdt_fixup_flash(void *fdt) |
| 868 | { |
| 869 | int offset; |
Pankit Garg | f5c2a83 | 2018-12-27 04:37:55 +0000 | [diff] [blame] | 870 | #ifdef CONFIG_TFABOOT |
| 871 | u32 __iomem *dcfg_ccsr = (u32 __iomem *)DCFG_BASE; |
| 872 | u32 val; |
| 873 | #endif |
Ashish Kumar | ff12b8a | 2017-11-09 11:14:24 +0530 | [diff] [blame] | 874 | |
| 875 | /* |
| 876 | * IFC-NOR and QSPI are muxed on SoC. |
| 877 | * So disable IFC node in dts if QSPI is enabled or |
| 878 | * disable QSPI node in dts in case QSPI is not enabled. |
| 879 | */ |
| 880 | |
Pankit Garg | f5c2a83 | 2018-12-27 04:37:55 +0000 | [diff] [blame] | 881 | #ifdef CONFIG_TFABOOT |
| 882 | enum boot_src src = get_boot_src(); |
| 883 | bool disable_ifc = false; |
| 884 | |
| 885 | switch (src) { |
| 886 | case BOOT_SOURCE_IFC_NOR: |
| 887 | disable_ifc = false; |
| 888 | break; |
| 889 | case BOOT_SOURCE_QSPI_NOR: |
| 890 | disable_ifc = true; |
| 891 | break; |
| 892 | default: |
| 893 | val = in_le32(dcfg_ccsr + DCFG_RCWSR15 / 4); |
| 894 | if (DCFG_RCWSR15_IFCGRPABASE_QSPI == (val & (u32)0x3)) |
| 895 | disable_ifc = true; |
| 896 | break; |
| 897 | } |
| 898 | |
| 899 | if (disable_ifc) { |
Jianpeng Bu | f9648b6 | 2022-01-31 18:42:36 +0530 | [diff] [blame] | 900 | offset = fdt_path_offset(fdt, "/soc/memory-controller/nor"); |
Pankit Garg | f5c2a83 | 2018-12-27 04:37:55 +0000 | [diff] [blame] | 901 | |
| 902 | if (offset < 0) |
Jianpeng Bu | f9648b6 | 2022-01-31 18:42:36 +0530 | [diff] [blame] | 903 | offset = fdt_path_offset(fdt, "/memory-controller/nor"); |
Pankit Garg | f5c2a83 | 2018-12-27 04:37:55 +0000 | [diff] [blame] | 904 | } else { |
| 905 | offset = fdt_path_offset(fdt, "/soc/quadspi"); |
| 906 | |
| 907 | if (offset < 0) |
| 908 | offset = fdt_path_offset(fdt, "/quadspi"); |
| 909 | } |
| 910 | |
| 911 | #else |
Ashish Kumar | ff12b8a | 2017-11-09 11:14:24 +0530 | [diff] [blame] | 912 | #ifdef CONFIG_FSL_QSPI |
Jianpeng Bu | f9648b6 | 2022-01-31 18:42:36 +0530 | [diff] [blame] | 913 | offset = fdt_path_offset(fdt, "/soc/memory-controller/nor"); |
Ashish Kumar | ff12b8a | 2017-11-09 11:14:24 +0530 | [diff] [blame] | 914 | |
| 915 | if (offset < 0) |
Jianpeng Bu | f9648b6 | 2022-01-31 18:42:36 +0530 | [diff] [blame] | 916 | offset = fdt_path_offset(fdt, "/memory-controller/nor"); |
Ashish Kumar | ff12b8a | 2017-11-09 11:14:24 +0530 | [diff] [blame] | 917 | #else |
| 918 | offset = fdt_path_offset(fdt, "/soc/quadspi"); |
| 919 | |
| 920 | if (offset < 0) |
| 921 | offset = fdt_path_offset(fdt, "/quadspi"); |
| 922 | #endif |
Pankit Garg | f5c2a83 | 2018-12-27 04:37:55 +0000 | [diff] [blame] | 923 | #endif |
Ashish Kumar | ff12b8a | 2017-11-09 11:14:24 +0530 | [diff] [blame] | 924 | if (offset < 0) |
| 925 | return; |
| 926 | |
| 927 | fdt_status_disabled(fdt, offset); |
| 928 | } |
| 929 | |
Masahiro Yamada | f7ed78b | 2020-06-26 15:13:33 +0900 | [diff] [blame] | 930 | int ft_board_setup(void *blob, struct bd_info *bd) |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 931 | { |
Mian Yousaf Kaukab | e1dabf0 | 2019-01-29 16:38:30 +0100 | [diff] [blame] | 932 | int i; |
Meenakshi Aggarwal | d67ae48 | 2019-05-23 15:13:43 +0530 | [diff] [blame] | 933 | u16 mc_memory_bank = 0; |
| 934 | |
| 935 | u64 *base; |
| 936 | u64 *size; |
| 937 | u64 mc_memory_base = 0; |
| 938 | u64 mc_memory_size = 0; |
| 939 | u16 total_memory_banks; |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 940 | |
| 941 | ft_cpu_setup(blob, bd); |
| 942 | |
Meenakshi Aggarwal | d67ae48 | 2019-05-23 15:13:43 +0530 | [diff] [blame] | 943 | fdt_fixup_mc_ddr(&mc_memory_base, &mc_memory_size); |
| 944 | |
| 945 | if (mc_memory_base != 0) |
| 946 | mc_memory_bank++; |
| 947 | |
| 948 | total_memory_banks = CONFIG_NR_DRAM_BANKS + mc_memory_bank; |
| 949 | |
| 950 | base = calloc(total_memory_banks, sizeof(u64)); |
| 951 | size = calloc(total_memory_banks, sizeof(u64)); |
| 952 | |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 953 | /* fixup DT for the two GPP DDR banks */ |
| 954 | for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) { |
| 955 | base[i] = gd->bd->bi_dram[i].start; |
| 956 | size[i] = gd->bd->bi_dram[i].size; |
| 957 | } |
| 958 | |
| 959 | #ifdef CONFIG_RESV_RAM |
| 960 | /* reduce size if reserved memory is within this bank */ |
| 961 | if (gd->arch.resv_ram >= base[0] && |
| 962 | gd->arch.resv_ram < base[0] + size[0]) |
| 963 | size[0] = gd->arch.resv_ram - base[0]; |
| 964 | else if (gd->arch.resv_ram >= base[1] && |
| 965 | gd->arch.resv_ram < base[1] + size[1]) |
| 966 | size[1] = gd->arch.resv_ram - base[1]; |
| 967 | #endif |
| 968 | |
Meenakshi Aggarwal | d67ae48 | 2019-05-23 15:13:43 +0530 | [diff] [blame] | 969 | if (mc_memory_base != 0) { |
| 970 | for (i = 0; i <= total_memory_banks; i++) { |
| 971 | if (base[i] == 0 && size[i] == 0) { |
| 972 | base[i] = mc_memory_base; |
| 973 | size[i] = mc_memory_size; |
| 974 | break; |
| 975 | } |
| 976 | } |
| 977 | } |
| 978 | |
| 979 | fdt_fixup_memory_banks(blob, base, size, total_memory_banks); |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 980 | |
Nipun Gupta | d691264 | 2018-08-20 16:01:14 +0530 | [diff] [blame] | 981 | fdt_fsl_mc_fixup_iommu_map_entry(blob); |
| 982 | |
Ashish Kumar | ff12b8a | 2017-11-09 11:14:24 +0530 | [diff] [blame] | 983 | fsl_fdt_fixup_flash(blob); |
| 984 | |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 985 | #ifdef CONFIG_FSL_MC_ENET |
| 986 | fdt_fixup_board_enet(blob); |
Laurentiu Tudor | 43c04a7 | 2023-09-27 18:30:49 +0300 | [diff] [blame] | 987 | fdt_reserve_mc_mem(blob, 0x300); |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 988 | #endif |
Laurentiu Tudor | 7690ea7 | 2019-07-30 17:29:58 +0300 | [diff] [blame] | 989 | |
| 990 | fdt_fixup_icid(blob); |
| 991 | |
Pramod Kumar | a053182 | 2018-10-12 14:04:27 +0000 | [diff] [blame] | 992 | if (is_pb_board()) |
| 993 | fixup_ls1088ardb_pb_banner(blob); |
Ashish Kumar | 227b4bc | 2017-08-31 16:12:54 +0530 | [diff] [blame] | 994 | |
| 995 | return 0; |
| 996 | } |
| 997 | #endif |
Sumit Garg | 08da8b2 | 2018-01-06 09:04:24 +0530 | [diff] [blame] | 998 | #endif /* defined(CONFIG_SPL_BUILD) */ |
Pankit Garg | f5c2a83 | 2018-12-27 04:37:55 +0000 | [diff] [blame] | 999 | |
| 1000 | #ifdef CONFIG_TFABOOT |
| 1001 | #ifdef CONFIG_MTD_NOR_FLASH |
| 1002 | int is_flash_available(void) |
| 1003 | { |
| 1004 | char *env_hwconfig = env_get("hwconfig"); |
| 1005 | enum boot_src src = get_boot_src(); |
| 1006 | int is_nor_flash_available = 1; |
| 1007 | |
| 1008 | switch (src) { |
| 1009 | case BOOT_SOURCE_IFC_NOR: |
| 1010 | is_nor_flash_available = 1; |
| 1011 | break; |
| 1012 | case BOOT_SOURCE_QSPI_NOR: |
| 1013 | is_nor_flash_available = 0; |
| 1014 | break; |
| 1015 | /* |
| 1016 | * In Case of SD boot,if qspi is defined in env_hwconfig |
| 1017 | * disable nor flash probe. |
| 1018 | */ |
| 1019 | default: |
| 1020 | if (hwconfig_f("qspi", env_hwconfig)) |
| 1021 | is_nor_flash_available = 0; |
| 1022 | break; |
| 1023 | } |
| 1024 | return is_nor_flash_available; |
| 1025 | } |
| 1026 | #endif |
| 1027 | |
Tom Rini | 0543c43 | 2019-11-18 20:02:08 -0500 | [diff] [blame] | 1028 | #ifdef CONFIG_ENV_IS_IN_SPI_FLASH |
Pankit Garg | f5c2a83 | 2018-12-27 04:37:55 +0000 | [diff] [blame] | 1029 | void *env_sf_get_env_addr(void) |
| 1030 | { |
Tom Rini | 376b88a | 2022-10-28 20:27:13 -0400 | [diff] [blame] | 1031 | return (void *)(CFG_SYS_FSL_QSPI_BASE + CONFIG_ENV_OFFSET); |
Pankit Garg | f5c2a83 | 2018-12-27 04:37:55 +0000 | [diff] [blame] | 1032 | } |
| 1033 | #endif |
Tom Rini | 0543c43 | 2019-11-18 20:02:08 -0500 | [diff] [blame] | 1034 | #endif |