Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Mingkai Hu | eee86ff | 2015-10-26 19:47:52 +0800 | [diff] [blame] | 2 | /* |
| 3 | * Copyright 2015 Freescale Semiconductor, Inc. |
Camelia Groza | a1c4699 | 2022-07-28 17:28:11 +0300 | [diff] [blame] | 4 | * Copyright 2021-2022 NXP |
Mingkai Hu | eee86ff | 2015-10-26 19:47:52 +0800 | [diff] [blame] | 5 | */ |
| 6 | |
Mingkai Hu | eee86ff | 2015-10-26 19:47:52 +0800 | [diff] [blame] | 7 | #include <i2c.h> |
Simon Glass | 9758973 | 2020-05-10 11:40:02 -0600 | [diff] [blame] | 8 | #include <init.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 9 | #include <asm/global_data.h> |
Mingkai Hu | eee86ff | 2015-10-26 19:47:52 +0800 | [diff] [blame] | 10 | #include <asm/io.h> |
| 11 | #include <asm/arch/clock.h> |
| 12 | #include <asm/arch/fsl_serdes.h> |
| 13 | #include <asm/arch/soc.h> |
Laurentiu Tudor | 22012d5 | 2018-08-27 17:33:59 +0300 | [diff] [blame] | 14 | #include <asm/arch-fsl-layerscape/fsl_icid.h> |
Simon Glass | e3ee2fb | 2016-02-22 22:55:43 -0700 | [diff] [blame] | 15 | #include <fdt_support.h> |
Mingkai Hu | eee86ff | 2015-10-26 19:47:52 +0800 | [diff] [blame] | 16 | #include <hwconfig.h> |
| 17 | #include <ahci.h> |
Yangbo Lu | da6121b | 2015-10-26 19:47:55 +0800 | [diff] [blame] | 18 | #include <mmc.h> |
Mingkai Hu | eee86ff | 2015-10-26 19:47:52 +0800 | [diff] [blame] | 19 | #include <scsi.h> |
Shaohui Xie | 0464326 | 2015-10-26 19:47:54 +0800 | [diff] [blame] | 20 | #include <fm_eth.h> |
Mingkai Hu | eee86ff | 2015-10-26 19:47:52 +0800 | [diff] [blame] | 21 | #include <fsl_esdhc.h> |
| 22 | #include <fsl_ifc.h> |
| 23 | #include "cpld.h" |
Zhao Qiang | 0be9be8 | 2016-02-05 10:04:17 +0800 | [diff] [blame] | 24 | #ifdef CONFIG_U_QE |
| 25 | #include <fsl_qe.h> |
| 26 | #endif |
Mingkai Hu | eee86ff | 2015-10-26 19:47:52 +0800 | [diff] [blame] | 27 | |
| 28 | DECLARE_GLOBAL_DATA_PTR; |
| 29 | |
Rajesh Bhagat | b89aed4 | 2018-11-05 18:02:44 +0000 | [diff] [blame] | 30 | #ifdef CONFIG_TFABOOT |
| 31 | struct ifc_regs ifc_cfg_nor_boot[CONFIG_SYS_FSL_IFC_BANK_COUNT] = { |
| 32 | { |
| 33 | "nor", |
Tom Rini | 7b577ba | 2022-11-16 13:10:25 -0500 | [diff] [blame] | 34 | CFG_SYS_NOR_CSPR, |
| 35 | CFG_SYS_NOR_CSPR_EXT, |
| 36 | CFG_SYS_NOR_AMASK, |
| 37 | CFG_SYS_NOR_CSOR, |
Rajesh Bhagat | b89aed4 | 2018-11-05 18:02:44 +0000 | [diff] [blame] | 38 | { |
Tom Rini | 7b577ba | 2022-11-16 13:10:25 -0500 | [diff] [blame] | 39 | CFG_SYS_NOR_FTIM0, |
| 40 | CFG_SYS_NOR_FTIM1, |
| 41 | CFG_SYS_NOR_FTIM2, |
| 42 | CFG_SYS_NOR_FTIM3 |
Rajesh Bhagat | b89aed4 | 2018-11-05 18:02:44 +0000 | [diff] [blame] | 43 | }, |
| 44 | |
| 45 | }, |
| 46 | { |
| 47 | "nand", |
Tom Rini | b421349 | 2022-11-12 17:36:51 -0500 | [diff] [blame] | 48 | CFG_SYS_NAND_CSPR, |
| 49 | CFG_SYS_NAND_CSPR_EXT, |
| 50 | CFG_SYS_NAND_AMASK, |
| 51 | CFG_SYS_NAND_CSOR, |
Rajesh Bhagat | b89aed4 | 2018-11-05 18:02:44 +0000 | [diff] [blame] | 52 | { |
Tom Rini | b421349 | 2022-11-12 17:36:51 -0500 | [diff] [blame] | 53 | CFG_SYS_NAND_FTIM0, |
| 54 | CFG_SYS_NAND_FTIM1, |
| 55 | CFG_SYS_NAND_FTIM2, |
| 56 | CFG_SYS_NAND_FTIM3 |
Rajesh Bhagat | b89aed4 | 2018-11-05 18:02:44 +0000 | [diff] [blame] | 57 | }, |
| 58 | }, |
| 59 | { |
| 60 | "cpld", |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 61 | CFG_SYS_CPLD_CSPR, |
| 62 | CFG_SYS_CPLD_CSPR_EXT, |
| 63 | CFG_SYS_CPLD_AMASK, |
| 64 | CFG_SYS_CPLD_CSOR, |
Rajesh Bhagat | b89aed4 | 2018-11-05 18:02:44 +0000 | [diff] [blame] | 65 | { |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 66 | CFG_SYS_CPLD_FTIM0, |
| 67 | CFG_SYS_CPLD_FTIM1, |
| 68 | CFG_SYS_CPLD_FTIM2, |
| 69 | CFG_SYS_CPLD_FTIM3 |
Rajesh Bhagat | b89aed4 | 2018-11-05 18:02:44 +0000 | [diff] [blame] | 70 | }, |
| 71 | } |
| 72 | }; |
| 73 | |
| 74 | struct ifc_regs ifc_cfg_nand_boot[CONFIG_SYS_FSL_IFC_BANK_COUNT] = { |
| 75 | { |
| 76 | "nand", |
Tom Rini | b421349 | 2022-11-12 17:36:51 -0500 | [diff] [blame] | 77 | CFG_SYS_NAND_CSPR, |
| 78 | CFG_SYS_NAND_CSPR_EXT, |
| 79 | CFG_SYS_NAND_AMASK, |
| 80 | CFG_SYS_NAND_CSOR, |
Rajesh Bhagat | b89aed4 | 2018-11-05 18:02:44 +0000 | [diff] [blame] | 81 | { |
Tom Rini | b421349 | 2022-11-12 17:36:51 -0500 | [diff] [blame] | 82 | CFG_SYS_NAND_FTIM0, |
| 83 | CFG_SYS_NAND_FTIM1, |
| 84 | CFG_SYS_NAND_FTIM2, |
| 85 | CFG_SYS_NAND_FTIM3 |
Rajesh Bhagat | b89aed4 | 2018-11-05 18:02:44 +0000 | [diff] [blame] | 86 | }, |
| 87 | }, |
| 88 | { |
| 89 | "nor", |
Tom Rini | 7b577ba | 2022-11-16 13:10:25 -0500 | [diff] [blame] | 90 | CFG_SYS_NOR_CSPR, |
| 91 | CFG_SYS_NOR_CSPR_EXT, |
| 92 | CFG_SYS_NOR_AMASK, |
| 93 | CFG_SYS_NOR_CSOR, |
Rajesh Bhagat | b89aed4 | 2018-11-05 18:02:44 +0000 | [diff] [blame] | 94 | { |
Tom Rini | 7b577ba | 2022-11-16 13:10:25 -0500 | [diff] [blame] | 95 | CFG_SYS_NOR_FTIM0, |
| 96 | CFG_SYS_NOR_FTIM1, |
| 97 | CFG_SYS_NOR_FTIM2, |
| 98 | CFG_SYS_NOR_FTIM3 |
Rajesh Bhagat | b89aed4 | 2018-11-05 18:02:44 +0000 | [diff] [blame] | 99 | }, |
| 100 | }, |
| 101 | { |
| 102 | "cpld", |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 103 | CFG_SYS_CPLD_CSPR, |
| 104 | CFG_SYS_CPLD_CSPR_EXT, |
| 105 | CFG_SYS_CPLD_AMASK, |
| 106 | CFG_SYS_CPLD_CSOR, |
Rajesh Bhagat | b89aed4 | 2018-11-05 18:02:44 +0000 | [diff] [blame] | 107 | { |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 108 | CFG_SYS_CPLD_FTIM0, |
| 109 | CFG_SYS_CPLD_FTIM1, |
| 110 | CFG_SYS_CPLD_FTIM2, |
| 111 | CFG_SYS_CPLD_FTIM3 |
Rajesh Bhagat | b89aed4 | 2018-11-05 18:02:44 +0000 | [diff] [blame] | 112 | }, |
| 113 | } |
| 114 | }; |
| 115 | |
| 116 | void ifc_cfg_boot_info(struct ifc_regs_info *regs_info) |
| 117 | { |
| 118 | enum boot_src src = get_boot_src(); |
| 119 | |
| 120 | if (src == BOOT_SOURCE_IFC_NAND) |
| 121 | regs_info->regs = ifc_cfg_nand_boot; |
| 122 | else |
| 123 | regs_info->regs = ifc_cfg_nor_boot; |
| 124 | regs_info->cs_size = CONFIG_SYS_FSL_IFC_BANK_COUNT; |
| 125 | } |
| 126 | |
| 127 | #endif |
Sumit Garg | 2a2857b | 2017-03-30 09:52:38 +0530 | [diff] [blame] | 128 | int board_early_init_f(void) |
| 129 | { |
| 130 | fsl_lsch2_early_init_f(); |
| 131 | |
| 132 | return 0; |
| 133 | } |
| 134 | |
Simon Glass | 49c24a8 | 2024-09-29 19:49:47 -0600 | [diff] [blame] | 135 | #ifndef CONFIG_XPL_BUILD |
Sumit Garg | 2a2857b | 2017-03-30 09:52:38 +0530 | [diff] [blame] | 136 | |
Mingkai Hu | eee86ff | 2015-10-26 19:47:52 +0800 | [diff] [blame] | 137 | int checkboard(void) |
| 138 | { |
Rajesh Bhagat | b89aed4 | 2018-11-05 18:02:44 +0000 | [diff] [blame] | 139 | #ifdef CONFIG_TFABOOT |
| 140 | enum boot_src src = get_boot_src(); |
| 141 | #endif |
Qianyu Gong | e54d134 | 2016-04-26 12:51:43 +0800 | [diff] [blame] | 142 | static const char *freq[2] = {"100.00MHZ", "156.25MHZ"}; |
Gong Qianyu | f671f6c | 2015-10-26 19:47:56 +0800 | [diff] [blame] | 143 | #ifndef CONFIG_SD_BOOT |
Mingkai Hu | eee86ff | 2015-10-26 19:47:52 +0800 | [diff] [blame] | 144 | u8 cfg_rcw_src1, cfg_rcw_src2; |
Qianyu Gong | e54d134 | 2016-04-26 12:51:43 +0800 | [diff] [blame] | 145 | u16 cfg_rcw_src; |
Gong Qianyu | f671f6c | 2015-10-26 19:47:56 +0800 | [diff] [blame] | 146 | #endif |
Qianyu Gong | e54d134 | 2016-04-26 12:51:43 +0800 | [diff] [blame] | 147 | u8 sd1refclk_sel; |
Mingkai Hu | eee86ff | 2015-10-26 19:47:52 +0800 | [diff] [blame] | 148 | |
| 149 | printf("Board: LS1043ARDB, boot from "); |
| 150 | |
Rajesh Bhagat | b89aed4 | 2018-11-05 18:02:44 +0000 | [diff] [blame] | 151 | #ifdef CONFIG_TFABOOT |
| 152 | if (src == BOOT_SOURCE_SD_MMC) |
| 153 | puts("SD\n"); |
| 154 | else { |
| 155 | #endif |
| 156 | |
Gong Qianyu | f671f6c | 2015-10-26 19:47:56 +0800 | [diff] [blame] | 157 | #ifdef CONFIG_SD_BOOT |
| 158 | puts("SD\n"); |
| 159 | #else |
Mingkai Hu | eee86ff | 2015-10-26 19:47:52 +0800 | [diff] [blame] | 160 | cfg_rcw_src1 = CPLD_READ(cfg_rcw_src1); |
| 161 | cfg_rcw_src2 = CPLD_READ(cfg_rcw_src2); |
| 162 | cpld_rev_bit(&cfg_rcw_src1); |
| 163 | cfg_rcw_src = cfg_rcw_src1; |
| 164 | cfg_rcw_src = (cfg_rcw_src << 1) | cfg_rcw_src2; |
| 165 | |
| 166 | if (cfg_rcw_src == 0x25) |
| 167 | printf("vBank %d\n", CPLD_READ(vbank)); |
Wei Lu | 795e806 | 2022-09-26 16:18:49 +0800 | [diff] [blame] | 168 | else if ((cfg_rcw_src == 0x106) || (cfg_rcw_src == 0x118)) |
Mingkai Hu | eee86ff | 2015-10-26 19:47:52 +0800 | [diff] [blame] | 169 | puts("NAND\n"); |
| 170 | else |
| 171 | printf("Invalid setting of SW4\n"); |
Gong Qianyu | f671f6c | 2015-10-26 19:47:56 +0800 | [diff] [blame] | 172 | #endif |
Mingkai Hu | eee86ff | 2015-10-26 19:47:52 +0800 | [diff] [blame] | 173 | |
Rajesh Bhagat | b89aed4 | 2018-11-05 18:02:44 +0000 | [diff] [blame] | 174 | #ifdef CONFIG_TFABOOT |
| 175 | } |
| 176 | #endif |
Mingkai Hu | eee86ff | 2015-10-26 19:47:52 +0800 | [diff] [blame] | 177 | printf("CPLD: V%x.%x\nPCBA: V%x.0\n", CPLD_READ(cpld_ver), |
| 178 | CPLD_READ(cpld_ver_sub), CPLD_READ(pcba_ver)); |
| 179 | |
| 180 | puts("SERDES Reference Clocks:\n"); |
| 181 | sd1refclk_sel = CPLD_READ(sd1refclk_sel); |
| 182 | printf("SD1_CLK1 = %s, SD1_CLK2 = %s\n", freq[sd1refclk_sel], freq[0]); |
| 183 | |
| 184 | return 0; |
| 185 | } |
| 186 | |
Mingkai Hu | eee86ff | 2015-10-26 19:47:52 +0800 | [diff] [blame] | 187 | int board_init(void) |
| 188 | { |
Tom Rini | 376b88a | 2022-10-28 20:27:13 -0400 | [diff] [blame] | 189 | struct ccsr_scfg *scfg = (struct ccsr_scfg *)CFG_SYS_FSL_SCFG_ADDR; |
Shaohui Xie | 9f4d011 | 2016-04-29 22:07:21 +0800 | [diff] [blame] | 190 | |
Hou Zhiqiang | 4b23ca8 | 2016-08-02 19:03:27 +0800 | [diff] [blame] | 191 | #ifdef CONFIG_SYS_FSL_ERRATUM_A010315 |
| 192 | erratum_a010315(); |
| 193 | #endif |
| 194 | |
Mingkai Hu | eee86ff | 2015-10-26 19:47:52 +0800 | [diff] [blame] | 195 | #ifdef CONFIG_FSL_IFC |
| 196 | init_final_memctl_regs(); |
| 197 | #endif |
| 198 | |
Udit Agarwal | 22ec238 | 2019-11-07 16:11:32 +0000 | [diff] [blame] | 199 | #ifdef CONFIG_NXP_ESBC |
Sumit Garg | f469d27 | 2016-09-01 12:56:43 -0400 | [diff] [blame] | 200 | /* In case of Secure Boot, the IBR configures the SMMU |
| 201 | * to allow only Secure transactions. |
| 202 | * SMMU must be reset in bypass mode. |
| 203 | * Set the ClientPD bit and Clear the USFCFG Bit |
| 204 | */ |
| 205 | u32 val; |
| 206 | val = (in_le32(SMMU_SCR0) | SCR0_CLIENTPD_MASK) & ~(SCR0_USFCFG_MASK); |
| 207 | out_le32(SMMU_SCR0, val); |
| 208 | val = (in_le32(SMMU_NSCR0) | SCR0_CLIENTPD_MASK) & ~(SCR0_USFCFG_MASK); |
| 209 | out_le32(SMMU_NSCR0, val); |
| 210 | #endif |
| 211 | |
Martin Schiller | 532d321 | 2021-11-23 07:28:00 +0100 | [diff] [blame] | 212 | #if !defined(CONFIG_SYS_EARLY_PCI_INIT) && defined(CONFIG_DM_ETH) |
| 213 | pci_init(); |
| 214 | #endif |
| 215 | |
Zhao Qiang | 0be9be8 | 2016-02-05 10:04:17 +0800 | [diff] [blame] | 216 | #ifdef CONFIG_U_QE |
| 217 | u_qe_init(); |
| 218 | #endif |
Shaohui Xie | 9f4d011 | 2016-04-29 22:07:21 +0800 | [diff] [blame] | 219 | /* invert AQR105 IRQ pins polarity */ |
| 220 | out_be32(&scfg->intpcr, AQR105_IRQ_MASK); |
Zhao Qiang | 0be9be8 | 2016-02-05 10:04:17 +0800 | [diff] [blame] | 221 | |
Mingkai Hu | eee86ff | 2015-10-26 19:47:52 +0800 | [diff] [blame] | 222 | return 0; |
| 223 | } |
| 224 | |
| 225 | int config_board_mux(void) |
| 226 | { |
Tom Rini | 376b88a | 2022-10-28 20:27:13 -0400 | [diff] [blame] | 227 | struct ccsr_scfg *scfg = (struct ccsr_scfg *)CFG_SYS_FSL_SCFG_ADDR; |
Zhao Qiang | 085d267 | 2016-02-05 10:04:18 +0800 | [diff] [blame] | 228 | u32 usb_pwrfault; |
| 229 | |
Zhao Qiang | 510e792 | 2016-02-05 10:04:19 +0800 | [diff] [blame] | 230 | if (hwconfig("qe-hdlc")) { |
| 231 | out_be32(&scfg->rcwpmuxcr0, |
| 232 | (in_be32(&scfg->rcwpmuxcr0) & ~0xff00) | 0x6600); |
| 233 | printf("Assign to qe-hdlc clk, rcwpmuxcr0=%x\n", |
| 234 | in_be32(&scfg->rcwpmuxcr0)); |
| 235 | } else { |
Zhao Qiang | 085d267 | 2016-02-05 10:04:18 +0800 | [diff] [blame] | 236 | #ifdef CONFIG_HAS_FSL_XHCI_USB |
Zhao Qiang | 510e792 | 2016-02-05 10:04:19 +0800 | [diff] [blame] | 237 | out_be32(&scfg->rcwpmuxcr0, 0x3333); |
| 238 | out_be32(&scfg->usbdrvvbus_selcr, SCFG_USBDRVVBUS_SELCR_USB1); |
| 239 | usb_pwrfault = (SCFG_USBPWRFAULT_DEDICATED << |
| 240 | SCFG_USBPWRFAULT_USB3_SHIFT) | |
| 241 | (SCFG_USBPWRFAULT_DEDICATED << |
| 242 | SCFG_USBPWRFAULT_USB2_SHIFT) | |
| 243 | (SCFG_USBPWRFAULT_SHARED << |
| 244 | SCFG_USBPWRFAULT_USB1_SHIFT); |
| 245 | out_be32(&scfg->usbpwrfault_selcr, usb_pwrfault); |
Zhao Qiang | 085d267 | 2016-02-05 10:04:18 +0800 | [diff] [blame] | 246 | #endif |
Zhao Qiang | 510e792 | 2016-02-05 10:04:19 +0800 | [diff] [blame] | 247 | } |
Mingkai Hu | eee86ff | 2015-10-26 19:47:52 +0800 | [diff] [blame] | 248 | return 0; |
| 249 | } |
| 250 | |
| 251 | #if defined(CONFIG_MISC_INIT_R) |
| 252 | int misc_init_r(void) |
| 253 | { |
| 254 | config_board_mux(); |
Mingkai Hu | eee86ff | 2015-10-26 19:47:52 +0800 | [diff] [blame] | 255 | return 0; |
| 256 | } |
| 257 | #endif |
| 258 | |
Zhao Qiang | 510e792 | 2016-02-05 10:04:19 +0800 | [diff] [blame] | 259 | void fdt_del_qe(void *blob) |
| 260 | { |
| 261 | int nodeoff = 0; |
| 262 | |
| 263 | while ((nodeoff = fdt_node_offset_by_compatible(blob, 0, |
| 264 | "fsl,qe")) >= 0) { |
| 265 | fdt_del_node(blob, nodeoff); |
| 266 | } |
| 267 | } |
| 268 | |
Camelia Groza | a1c4699 | 2022-07-28 17:28:11 +0300 | [diff] [blame] | 269 | /* Update the address of the Aquantia PHY on the MDIO bus for boards revision |
| 270 | * v7.0 and up. Also rename the PHY node to align with the address change. |
| 271 | */ |
| 272 | void fdt_fixup_phy_addr(void *blob) |
| 273 | { |
| 274 | const char phy_path[] = |
| 275 | "/soc/fman@1a00000/mdio@fd000/ethernet-phy@1"; |
| 276 | int ret, offset, new_addr = AQR113C_PHY_ADDR; |
| 277 | char new_name[] = "ethernet-phy@00"; |
| 278 | |
| 279 | if (CPLD_READ(pcba_ver) < 0x7) |
| 280 | return; |
| 281 | |
| 282 | offset = fdt_path_offset(blob, phy_path); |
| 283 | if (offset < 0) { |
| 284 | printf("ethernet-phy@1 node not found in the dts\n"); |
| 285 | return; |
| 286 | } |
| 287 | |
| 288 | ret = fdt_setprop_u32(blob, offset, "reg", new_addr); |
| 289 | if (ret < 0) { |
| 290 | printf("Unable to set 'reg' for node ethernet-phy@1: %s\n", |
| 291 | fdt_strerror(ret)); |
| 292 | return; |
| 293 | } |
| 294 | |
| 295 | sprintf(new_name, "ethernet-phy@%x", new_addr); |
| 296 | ret = fdt_set_name(blob, offset, new_name); |
| 297 | if (ret < 0) |
| 298 | printf("Unable to rename node ethernet-phy@1: %s\n", |
| 299 | fdt_strerror(ret)); |
| 300 | } |
| 301 | |
Masahiro Yamada | f7ed78b | 2020-06-26 15:13:33 +0900 | [diff] [blame] | 302 | int ft_board_setup(void *blob, struct bd_info *bd) |
Mingkai Hu | eee86ff | 2015-10-26 19:47:52 +0800 | [diff] [blame] | 303 | { |
Shaohui Xie | f6c8395 | 2015-11-23 15:23:48 +0800 | [diff] [blame] | 304 | u64 base[CONFIG_NR_DRAM_BANKS]; |
| 305 | u64 size[CONFIG_NR_DRAM_BANKS]; |
| 306 | |
| 307 | /* fixup DT for the two DDR banks */ |
| 308 | base[0] = gd->bd->bi_dram[0].start; |
| 309 | size[0] = gd->bd->bi_dram[0].size; |
| 310 | base[1] = gd->bd->bi_dram[1].start; |
| 311 | size[1] = gd->bd->bi_dram[1].size; |
| 312 | |
| 313 | fdt_fixup_memory_banks(blob, base, size, 2); |
Mingkai Hu | eee86ff | 2015-10-26 19:47:52 +0800 | [diff] [blame] | 314 | ft_cpu_setup(blob, bd); |
| 315 | |
Shaohui Xie | 0464326 | 2015-10-26 19:47:54 +0800 | [diff] [blame] | 316 | #ifdef CONFIG_SYS_DPAA_FMAN |
Madalin Bucur | b76b0a6 | 2020-04-23 16:25:19 +0300 | [diff] [blame] | 317 | #ifndef CONFIG_DM_ETH |
Shaohui Xie | 0464326 | 2015-10-26 19:47:54 +0800 | [diff] [blame] | 318 | fdt_fixup_fman_ethernet(blob); |
| 319 | #endif |
Camelia Groza | a1c4699 | 2022-07-28 17:28:11 +0300 | [diff] [blame] | 320 | fdt_fixup_phy_addr(blob); |
Madalin Bucur | b76b0a6 | 2020-04-23 16:25:19 +0300 | [diff] [blame] | 321 | #endif |
Zhao Qiang | 510e792 | 2016-02-05 10:04:19 +0800 | [diff] [blame] | 322 | |
Laurentiu Tudor | 22012d5 | 2018-08-27 17:33:59 +0300 | [diff] [blame] | 323 | fdt_fixup_icid(blob); |
| 324 | |
Zhao Qiang | 510e792 | 2016-02-05 10:04:19 +0800 | [diff] [blame] | 325 | /* |
| 326 | * qe-hdlc and usb multi-use the pins, |
| 327 | * when set hwconfig to qe-hdlc, delete usb node. |
| 328 | */ |
| 329 | if (hwconfig("qe-hdlc")) |
| 330 | #ifdef CONFIG_HAS_FSL_XHCI_USB |
| 331 | fdt_del_node_and_alias(blob, "usb1"); |
| 332 | #endif |
| 333 | /* |
| 334 | * qe just support qe-uart and qe-hdlc, |
| 335 | * if qe-uart and qe-hdlc are not set in hwconfig, |
| 336 | * delete qe node. |
| 337 | */ |
| 338 | if (!hwconfig("qe-uart") && !hwconfig("qe-hdlc")) |
| 339 | fdt_del_qe(blob); |
| 340 | |
Mingkai Hu | eee86ff | 2015-10-26 19:47:52 +0800 | [diff] [blame] | 341 | return 0; |
| 342 | } |
| 343 | |
Wei Lu | 795e806 | 2022-09-26 16:18:49 +0800 | [diff] [blame] | 344 | void nand_fixup(void) |
| 345 | { |
| 346 | u32 csor = 0; |
| 347 | |
| 348 | if (CPLD_READ(pcba_ver) < 0x7) |
| 349 | return; |
| 350 | |
| 351 | /* Change NAND Flash PGS/SPRZ configuration */ |
Tom Rini | b421349 | 2022-11-12 17:36:51 -0500 | [diff] [blame] | 352 | csor = CFG_SYS_NAND_CSOR; |
Wei Lu | 795e806 | 2022-09-26 16:18:49 +0800 | [diff] [blame] | 353 | if ((csor & CSOR_NAND_PGS_MASK) == CSOR_NAND_PGS_2K) |
| 354 | csor = (csor & ~(CSOR_NAND_PGS_MASK)) | CSOR_NAND_PGS_4K; |
| 355 | |
| 356 | if ((csor & CSOR_NAND_SPRZ_MASK) == CSOR_NAND_SPRZ_64) |
| 357 | csor = (csor & ~(CSOR_NAND_SPRZ_MASK)) | CSOR_NAND_SPRZ_224; |
| 358 | |
| 359 | if (IS_ENABLED(CONFIG_TFABOOT)) { |
| 360 | u8 cfg_rcw_src1, cfg_rcw_src2; |
| 361 | u16 cfg_rcw_src; |
| 362 | |
| 363 | cfg_rcw_src1 = CPLD_READ(cfg_rcw_src1); |
| 364 | cfg_rcw_src2 = CPLD_READ(cfg_rcw_src2); |
| 365 | cpld_rev_bit(&cfg_rcw_src1); |
| 366 | cfg_rcw_src = cfg_rcw_src1; |
| 367 | cfg_rcw_src = (cfg_rcw_src << 1) | cfg_rcw_src2; |
| 368 | |
| 369 | if (cfg_rcw_src == 0x25) |
| 370 | set_ifc_csor(IFC_CS1, csor); |
| 371 | else if (cfg_rcw_src == 0x118) |
| 372 | set_ifc_csor(IFC_CS0, csor); |
| 373 | else |
| 374 | printf("Invalid setting\n"); |
| 375 | } else { |
| 376 | if (IS_ENABLED(CONFIG_NAND_BOOT)) |
| 377 | set_ifc_csor(IFC_CS0, csor); |
| 378 | else |
| 379 | set_ifc_csor(IFC_CS1, csor); |
| 380 | } |
| 381 | } |
| 382 | |
Camelia Groza | a1c4699 | 2022-07-28 17:28:11 +0300 | [diff] [blame] | 383 | #if IS_ENABLED(CONFIG_OF_BOARD_FIXUP) |
| 384 | int board_fix_fdt(void *blob) |
| 385 | { |
Wei Lu | 795e806 | 2022-09-26 16:18:49 +0800 | [diff] [blame] | 386 | /* nand driver fix up */ |
| 387 | nand_fixup(); |
| 388 | |
| 389 | /* fdt fix up */ |
Camelia Groza | a1c4699 | 2022-07-28 17:28:11 +0300 | [diff] [blame] | 390 | fdt_fixup_phy_addr(blob); |
Wei Lu | 795e806 | 2022-09-26 16:18:49 +0800 | [diff] [blame] | 391 | |
Camelia Groza | a1c4699 | 2022-07-28 17:28:11 +0300 | [diff] [blame] | 392 | return 0; |
| 393 | } |
| 394 | #endif |
| 395 | |
Mingkai Hu | eee86ff | 2015-10-26 19:47:52 +0800 | [diff] [blame] | 396 | u8 flash_read8(void *addr) |
| 397 | { |
| 398 | return __raw_readb(addr + 1); |
| 399 | } |
| 400 | |
| 401 | void flash_write16(u16 val, void *addr) |
| 402 | { |
| 403 | u16 shftval = (((val >> 8) & 0xff) | ((val << 8) & 0xff00)); |
| 404 | |
| 405 | __raw_writew(shftval, addr); |
| 406 | } |
| 407 | |
| 408 | u16 flash_read16(void *addr) |
| 409 | { |
| 410 | u16 val = __raw_readw(addr); |
| 411 | |
| 412 | return (((val) >> 8) & 0x00ff) | (((val) << 8) & 0xff00); |
| 413 | } |
Sumit Garg | 2a2857b | 2017-03-30 09:52:38 +0530 | [diff] [blame] | 414 | |
| 415 | #endif |