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