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