Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Wang Huan | ddf89f9 | 2014-09-05 13:52:45 +0800 | [diff] [blame] | 2 | /* |
| 3 | * Copyright 2014 Freescale Semiconductor, Inc. |
Gaurav Jain | 119c700 | 2022-06-23 16:31:35 +0530 | [diff] [blame] | 4 | * Copyright 2019, 2021-2022 NXP |
Wang Huan | ddf89f9 | 2014-09-05 13:52:45 +0800 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <common.h> |
Simon Glass | 85d6531 | 2019-12-28 10:44:58 -0700 | [diff] [blame] | 8 | #include <clock_legacy.h> |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 9 | #include <command.h> |
Simon Glass | 3bbe70c | 2019-12-28 10:44:54 -0700 | [diff] [blame] | 10 | #include <fdt_support.h> |
Wang Huan | ddf89f9 | 2014-09-05 13:52:45 +0800 | [diff] [blame] | 11 | #include <i2c.h> |
Simon Glass | a7b5130 | 2019-11-14 12:57:46 -0700 | [diff] [blame] | 12 | #include <init.h> |
Simon Glass | 274e0b0 | 2020-05-10 11:39:56 -0600 | [diff] [blame] | 13 | #include <net.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 14 | #include <asm/global_data.h> |
Wang Huan | ddf89f9 | 2014-09-05 13:52:45 +0800 | [diff] [blame] | 15 | #include <asm/io.h> |
| 16 | #include <asm/arch/immap_ls102xa.h> |
| 17 | #include <asm/arch/clock.h> |
| 18 | #include <asm/arch/fsl_serdes.h> |
Zhuoyu Zhang | fe4f288 | 2015-08-17 18:55:12 +0800 | [diff] [blame] | 19 | #include <asm/arch/ls102xa_devdis.h> |
Yao Yuan | e0f8f54 | 2015-12-05 14:59:10 +0800 | [diff] [blame] | 20 | #include <asm/arch/ls102xa_soc.h> |
Shiji Yang | bb11234 | 2023-08-03 09:47:16 +0800 | [diff] [blame] | 21 | #include <asm/sections.h> |
Yao Yuan | 064f0a1 | 2015-03-03 16:35:18 +0800 | [diff] [blame] | 22 | #include <hwconfig.h> |
Wang Huan | ddf89f9 | 2014-09-05 13:52:45 +0800 | [diff] [blame] | 23 | #include <mmc.h> |
Mingkai Hu | 5b0df8a | 2015-10-26 19:47:41 +0800 | [diff] [blame] | 24 | #include <fsl_csu.h> |
Wang Huan | ddf89f9 | 2014-09-05 13:52:45 +0800 | [diff] [blame] | 25 | #include <fsl_ifc.h> |
York Sun | 1006cad | 2015-04-29 10:35:35 -0700 | [diff] [blame] | 26 | #include <fsl_immap.h> |
Wang Huan | ddf89f9 | 2014-09-05 13:52:45 +0800 | [diff] [blame] | 27 | #include <netdev.h> |
| 28 | #include <fsl_mdio.h> |
| 29 | #include <tsec.h> |
Zhuoyu Zhang | fe4f288 | 2015-08-17 18:55:12 +0800 | [diff] [blame] | 30 | #include <fsl_devdis.h> |
Alison Wang | 948c609 | 2014-12-03 15:00:48 +0800 | [diff] [blame] | 31 | #include <spl.h> |
Simon Glass | dbd7954 | 2020-05-10 11:40:11 -0600 | [diff] [blame] | 32 | #include <linux/delay.h> |
Tang Yuantian | 8b160bc | 2015-05-14 17:20:28 +0800 | [diff] [blame] | 33 | #include "../common/sleep.h" |
Zhao Qiang | f3cc6b7 | 2014-09-26 16:25:33 +0800 | [diff] [blame] | 34 | #ifdef CONFIG_U_QE |
Qianyu Gong | ae6a758 | 2016-02-18 13:01:59 +0800 | [diff] [blame] | 35 | #include <fsl_qe.h> |
Zhao Qiang | f3cc6b7 | 2014-09-26 16:25:33 +0800 | [diff] [blame] | 36 | #endif |
Aneesh Bansal | 39d5b3b | 2016-01-22 16:37:26 +0530 | [diff] [blame] | 37 | #include <fsl_validate.h> |
Gaurav Jain | 119c700 | 2022-06-23 16:31:35 +0530 | [diff] [blame] | 38 | #include <dm/uclass.h> |
Wang Huan | ddf89f9 | 2014-09-05 13:52:45 +0800 | [diff] [blame] | 39 | |
| 40 | DECLARE_GLOBAL_DATA_PTR; |
| 41 | |
| 42 | #define VERSION_MASK 0x00FF |
| 43 | #define BANK_MASK 0x0001 |
Simon Glass | 1877f2c | 2021-03-26 16:13:01 +1300 | [diff] [blame] | 44 | #define CFG_RESET 0x1 |
Wang Huan | ddf89f9 | 2014-09-05 13:52:45 +0800 | [diff] [blame] | 45 | #define INIT_RESET 0x1 |
| 46 | |
| 47 | #define CPLD_SET_MUX_SERDES 0x20 |
| 48 | #define CPLD_SET_BOOT_BANK 0x40 |
| 49 | |
| 50 | #define BOOT_FROM_UPPER_BANK 0x0 |
| 51 | #define BOOT_FROM_LOWER_BANK 0x1 |
| 52 | |
| 53 | #define LANEB_SATA (0x01) |
| 54 | #define LANEB_SGMII1 (0x02) |
| 55 | #define LANEC_SGMII1 (0x04) |
| 56 | #define LANEC_PCIEX1 (0x08) |
| 57 | #define LANED_PCIEX2 (0x10) |
| 58 | #define LANED_SGMII2 (0x20) |
| 59 | |
| 60 | #define MASK_LANE_B 0x1 |
| 61 | #define MASK_LANE_C 0x2 |
| 62 | #define MASK_LANE_D 0x4 |
| 63 | #define MASK_SGMII 0x8 |
| 64 | |
| 65 | #define KEEP_STATUS 0x0 |
| 66 | #define NEED_RESET 0x1 |
| 67 | |
Yao Yuan | 064f0a1 | 2015-03-03 16:35:18 +0800 | [diff] [blame] | 68 | #define SOFT_MUX_ON_I2C3_IFC 0x2 |
| 69 | #define SOFT_MUX_ON_CAN3_USB2 0x8 |
| 70 | #define SOFT_MUX_ON_QE_LCD 0x10 |
| 71 | |
| 72 | #define PIN_I2C3_IFC_MUX_I2C3 0x0 |
| 73 | #define PIN_I2C3_IFC_MUX_IFC 0x1 |
| 74 | #define PIN_CAN3_USB2_MUX_USB2 0x0 |
| 75 | #define PIN_CAN3_USB2_MUX_CAN3 0x1 |
| 76 | #define PIN_QE_LCD_MUX_LCD 0x0 |
| 77 | #define PIN_QE_LCD_MUX_QE 0x1 |
| 78 | |
Wang Huan | ddf89f9 | 2014-09-05 13:52:45 +0800 | [diff] [blame] | 79 | struct cpld_data { |
| 80 | u8 cpld_ver; /* cpld revision */ |
| 81 | u8 cpld_ver_sub; /* cpld sub revision */ |
| 82 | u8 pcba_ver; /* pcb revision number */ |
| 83 | u8 system_rst; /* reset system by cpld */ |
| 84 | u8 soft_mux_on; /* CPLD override physical switches Enable */ |
| 85 | u8 cfg_rcw_src1; /* Reset config word 1 */ |
| 86 | u8 cfg_rcw_src2; /* Reset config word 2 */ |
| 87 | u8 vbank; /* Flash bank selection Control */ |
| 88 | u8 gpio; /* GPIO for TWR-ELEV */ |
| 89 | u8 i2c3_ifc_mux; |
| 90 | u8 mux_spi2; |
| 91 | u8 can3_usb2_mux; /* CAN3 and USB2 Selection */ |
| 92 | u8 qe_lcd_mux; /* QE and LCD Selection */ |
| 93 | u8 serdes_mux; /* Multiplexed pins for SerDes Lanes */ |
| 94 | u8 global_rst; /* reset with init CPLD reg to default */ |
| 95 | u8 rev1; /* Reserved */ |
| 96 | u8 rev2; /* Reserved */ |
| 97 | }; |
| 98 | |
Alison Wang | dd45cc5 | 2015-10-15 17:54:40 +0800 | [diff] [blame] | 99 | #if !defined(CONFIG_QSPI_BOOT) && !defined(CONFIG_SD_BOOT_QSPI) |
Tom Rini | e982d18 | 2018-01-03 09:01:33 -0500 | [diff] [blame] | 100 | static void cpld_show(void) |
Wang Huan | ddf89f9 | 2014-09-05 13:52:45 +0800 | [diff] [blame] | 101 | { |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 102 | struct cpld_data *cpld_data = (void *)(CFG_SYS_CPLD_BASE); |
Wang Huan | ddf89f9 | 2014-09-05 13:52:45 +0800 | [diff] [blame] | 103 | |
| 104 | printf("CPLD: V%x.%x\nPCBA: V%x.0\nVBank: %d\n", |
| 105 | in_8(&cpld_data->cpld_ver) & VERSION_MASK, |
| 106 | in_8(&cpld_data->cpld_ver_sub) & VERSION_MASK, |
| 107 | in_8(&cpld_data->pcba_ver) & VERSION_MASK, |
| 108 | in_8(&cpld_data->vbank) & BANK_MASK); |
| 109 | |
Tom Rini | fad5430 | 2022-03-30 18:07:27 -0400 | [diff] [blame] | 110 | #ifdef DEBUG |
Wang Huan | ddf89f9 | 2014-09-05 13:52:45 +0800 | [diff] [blame] | 111 | printf("soft_mux_on =%x\n", |
| 112 | in_8(&cpld_data->soft_mux_on)); |
| 113 | printf("cfg_rcw_src1 =%x\n", |
| 114 | in_8(&cpld_data->cfg_rcw_src1)); |
| 115 | printf("cfg_rcw_src2 =%x\n", |
| 116 | in_8(&cpld_data->cfg_rcw_src2)); |
| 117 | printf("vbank =%x\n", |
| 118 | in_8(&cpld_data->vbank)); |
| 119 | printf("gpio =%x\n", |
| 120 | in_8(&cpld_data->gpio)); |
| 121 | printf("i2c3_ifc_mux =%x\n", |
| 122 | in_8(&cpld_data->i2c3_ifc_mux)); |
| 123 | printf("mux_spi2 =%x\n", |
| 124 | in_8(&cpld_data->mux_spi2)); |
| 125 | printf("can3_usb2_mux =%x\n", |
| 126 | in_8(&cpld_data->can3_usb2_mux)); |
| 127 | printf("qe_lcd_mux =%x\n", |
| 128 | in_8(&cpld_data->qe_lcd_mux)); |
| 129 | printf("serdes_mux =%x\n", |
| 130 | in_8(&cpld_data->serdes_mux)); |
| 131 | #endif |
| 132 | } |
Alison Wang | 2145a37 | 2014-12-09 17:38:02 +0800 | [diff] [blame] | 133 | #endif |
Wang Huan | ddf89f9 | 2014-09-05 13:52:45 +0800 | [diff] [blame] | 134 | |
| 135 | int checkboard(void) |
| 136 | { |
| 137 | puts("Board: LS1021ATWR\n"); |
Alison Wang | dd45cc5 | 2015-10-15 17:54:40 +0800 | [diff] [blame] | 138 | #if !defined(CONFIG_QSPI_BOOT) && !defined(CONFIG_SD_BOOT_QSPI) |
Wang Huan | ddf89f9 | 2014-09-05 13:52:45 +0800 | [diff] [blame] | 139 | cpld_show(); |
Alison Wang | 2145a37 | 2014-12-09 17:38:02 +0800 | [diff] [blame] | 140 | #endif |
Wang Huan | ddf89f9 | 2014-09-05 13:52:45 +0800 | [diff] [blame] | 141 | |
| 142 | return 0; |
| 143 | } |
| 144 | |
| 145 | void ddrmc_init(void) |
| 146 | { |
Tom Rini | 376b88a | 2022-10-28 20:27:13 -0400 | [diff] [blame] | 147 | struct ccsr_ddr *ddr = (struct ccsr_ddr *)CFG_SYS_FSL_DDR_ADDR; |
Shengzhou Liu | 80a12ab | 2016-09-01 14:50:36 +0800 | [diff] [blame] | 148 | u32 temp_sdram_cfg, tmp; |
Wang Huan | ddf89f9 | 2014-09-05 13:52:45 +0800 | [diff] [blame] | 149 | |
| 150 | out_be32(&ddr->sdram_cfg, DDR_SDRAM_CFG); |
| 151 | |
| 152 | out_be32(&ddr->cs0_bnds, DDR_CS0_BNDS); |
| 153 | out_be32(&ddr->cs0_config, DDR_CS0_CONFIG); |
| 154 | |
| 155 | out_be32(&ddr->timing_cfg_0, DDR_TIMING_CFG_0); |
| 156 | out_be32(&ddr->timing_cfg_1, DDR_TIMING_CFG_1); |
| 157 | out_be32(&ddr->timing_cfg_2, DDR_TIMING_CFG_2); |
| 158 | out_be32(&ddr->timing_cfg_3, DDR_TIMING_CFG_3); |
| 159 | out_be32(&ddr->timing_cfg_4, DDR_TIMING_CFG_4); |
| 160 | out_be32(&ddr->timing_cfg_5, DDR_TIMING_CFG_5); |
| 161 | |
Tang Yuantian | 8b160bc | 2015-05-14 17:20:28 +0800 | [diff] [blame] | 162 | #ifdef CONFIG_DEEP_SLEEP |
| 163 | if (is_warm_boot()) { |
| 164 | out_be32(&ddr->sdram_cfg_2, |
| 165 | DDR_SDRAM_CFG_2 & ~SDRAM_CFG2_D_INIT); |
Tom Rini | bb4dd96 | 2022-11-16 13:10:37 -0500 | [diff] [blame] | 166 | out_be32(&ddr->init_addr, CFG_SYS_SDRAM_BASE); |
Tang Yuantian | 8b160bc | 2015-05-14 17:20:28 +0800 | [diff] [blame] | 167 | out_be32(&ddr->init_ext_addr, (1 << 31)); |
| 168 | |
| 169 | /* DRAM VRef will not be trained */ |
| 170 | out_be32(&ddr->ddr_cdr2, |
| 171 | DDR_DDR_CDR2 & ~DDR_CDR2_VREF_TRAIN_EN); |
| 172 | } else |
| 173 | #endif |
| 174 | { |
| 175 | out_be32(&ddr->sdram_cfg_2, DDR_SDRAM_CFG_2); |
| 176 | out_be32(&ddr->ddr_cdr2, DDR_DDR_CDR2); |
| 177 | } |
Wang Huan | ddf89f9 | 2014-09-05 13:52:45 +0800 | [diff] [blame] | 178 | |
| 179 | out_be32(&ddr->sdram_mode, DDR_SDRAM_MODE); |
| 180 | out_be32(&ddr->sdram_mode_2, DDR_SDRAM_MODE_2); |
| 181 | |
| 182 | out_be32(&ddr->sdram_interval, DDR_SDRAM_INTERVAL); |
| 183 | |
| 184 | out_be32(&ddr->ddr_wrlvl_cntl, DDR_DDR_WRLVL_CNTL); |
| 185 | |
| 186 | out_be32(&ddr->ddr_wrlvl_cntl_2, DDR_DDR_WRLVL_CNTL_2); |
| 187 | out_be32(&ddr->ddr_wrlvl_cntl_3, DDR_DDR_WRLVL_CNTL_3); |
| 188 | |
| 189 | out_be32(&ddr->ddr_cdr1, DDR_DDR_CDR1); |
Wang Huan | ddf89f9 | 2014-09-05 13:52:45 +0800 | [diff] [blame] | 190 | |
| 191 | out_be32(&ddr->sdram_clk_cntl, DDR_SDRAM_CLK_CNTL); |
| 192 | out_be32(&ddr->ddr_zq_cntl, DDR_DDR_ZQ_CNTL); |
| 193 | |
| 194 | out_be32(&ddr->cs0_config_2, DDR_CS0_CONFIG_2); |
Shengzhou Liu | 80a12ab | 2016-09-01 14:50:36 +0800 | [diff] [blame] | 195 | |
| 196 | /* DDR erratum A-009942 */ |
| 197 | tmp = in_be32(&ddr->debug[28]); |
| 198 | out_be32(&ddr->debug[28], tmp | 0x0070006f); |
| 199 | |
Wang Huan | ddf89f9 | 2014-09-05 13:52:45 +0800 | [diff] [blame] | 200 | udelay(1); |
Tang Yuantian | 8b160bc | 2015-05-14 17:20:28 +0800 | [diff] [blame] | 201 | |
| 202 | #ifdef CONFIG_DEEP_SLEEP |
| 203 | if (is_warm_boot()) { |
| 204 | /* enter self-refresh */ |
| 205 | temp_sdram_cfg = in_be32(&ddr->sdram_cfg_2); |
| 206 | temp_sdram_cfg |= SDRAM_CFG2_FRC_SR; |
| 207 | out_be32(&ddr->sdram_cfg_2, temp_sdram_cfg); |
| 208 | |
| 209 | temp_sdram_cfg = (DDR_SDRAM_CFG_MEM_EN | SDRAM_CFG_BI); |
| 210 | } else |
| 211 | #endif |
| 212 | temp_sdram_cfg = (DDR_SDRAM_CFG_MEM_EN & ~SDRAM_CFG_BI); |
| 213 | |
| 214 | out_be32(&ddr->sdram_cfg, DDR_SDRAM_CFG | temp_sdram_cfg); |
| 215 | |
| 216 | #ifdef CONFIG_DEEP_SLEEP |
| 217 | if (is_warm_boot()) { |
| 218 | /* exit self-refresh */ |
| 219 | temp_sdram_cfg = in_be32(&ddr->sdram_cfg_2); |
| 220 | temp_sdram_cfg &= ~SDRAM_CFG2_FRC_SR; |
| 221 | out_be32(&ddr->sdram_cfg_2, temp_sdram_cfg); |
| 222 | } |
| 223 | #endif |
Wang Huan | ddf89f9 | 2014-09-05 13:52:45 +0800 | [diff] [blame] | 224 | } |
| 225 | |
| 226 | int dram_init(void) |
| 227 | { |
| 228 | #if (!defined(CONFIG_SPL) || defined(CONFIG_SPL_BUILD)) |
| 229 | ddrmc_init(); |
| 230 | #endif |
| 231 | |
Alison Wang | d6be97b | 2019-03-06 14:49:14 +0800 | [diff] [blame] | 232 | erratum_a008850_post(); |
| 233 | |
Wang Huan | ddf89f9 | 2014-09-05 13:52:45 +0800 | [diff] [blame] | 234 | gd->ram_size = get_ram_size((void *)PHYS_SDRAM, PHYS_SDRAM_SIZE); |
Tang Yuantian | 8b160bc | 2015-05-14 17:20:28 +0800 | [diff] [blame] | 235 | |
| 236 | #if defined(CONFIG_DEEP_SLEEP) && !defined(CONFIG_SPL_BUILD) |
| 237 | fsl_dp_resume(); |
| 238 | #endif |
| 239 | |
Wang Huan | ddf89f9 | 2014-09-05 13:52:45 +0800 | [diff] [blame] | 240 | return 0; |
| 241 | } |
| 242 | |
Masahiro Yamada | f7ed78b | 2020-06-26 15:13:33 +0900 | [diff] [blame] | 243 | int board_eth_init(struct bd_info *bis) |
Wang Huan | ddf89f9 | 2014-09-05 13:52:45 +0800 | [diff] [blame] | 244 | { |
Wang Huan | ddf89f9 | 2014-09-05 13:52:45 +0800 | [diff] [blame] | 245 | return pci_eth_init(bis); |
| 246 | } |
Wang Huan | ddf89f9 | 2014-09-05 13:52:45 +0800 | [diff] [blame] | 247 | |
Alison Wang | dd45cc5 | 2015-10-15 17:54:40 +0800 | [diff] [blame] | 248 | #if !defined(CONFIG_QSPI_BOOT) && !defined(CONFIG_SD_BOOT_QSPI) |
Tom Rini | e982d18 | 2018-01-03 09:01:33 -0500 | [diff] [blame] | 249 | static void convert_serdes_mux(int type, int need_reset) |
| 250 | { |
| 251 | char current_serdes; |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 252 | struct cpld_data *cpld_data = (void *)(CFG_SYS_CPLD_BASE); |
Tom Rini | e982d18 | 2018-01-03 09:01:33 -0500 | [diff] [blame] | 253 | |
| 254 | current_serdes = cpld_data->serdes_mux; |
| 255 | |
| 256 | switch (type) { |
| 257 | case LANEB_SATA: |
| 258 | current_serdes &= ~MASK_LANE_B; |
| 259 | break; |
| 260 | case LANEB_SGMII1: |
| 261 | current_serdes |= (MASK_LANE_B | MASK_SGMII | MASK_LANE_C); |
| 262 | break; |
| 263 | case LANEC_SGMII1: |
| 264 | current_serdes &= ~(MASK_LANE_B | MASK_SGMII | MASK_LANE_C); |
| 265 | break; |
| 266 | case LANED_SGMII2: |
| 267 | current_serdes |= MASK_LANE_D; |
| 268 | break; |
| 269 | case LANEC_PCIEX1: |
| 270 | current_serdes |= MASK_LANE_C; |
| 271 | break; |
| 272 | case (LANED_PCIEX2 | LANEC_PCIEX1): |
| 273 | current_serdes |= MASK_LANE_C; |
| 274 | current_serdes &= ~MASK_LANE_D; |
| 275 | break; |
| 276 | default: |
| 277 | printf("CPLD serdes MUX: unsupported MUX type 0x%x\n", type); |
| 278 | return; |
| 279 | } |
| 280 | |
| 281 | cpld_data->soft_mux_on |= CPLD_SET_MUX_SERDES; |
| 282 | cpld_data->serdes_mux = current_serdes; |
| 283 | |
| 284 | if (need_reset == 1) { |
| 285 | printf("Reset board to enable configuration\n"); |
Simon Glass | 1877f2c | 2021-03-26 16:13:01 +1300 | [diff] [blame] | 286 | cpld_data->system_rst = CFG_RESET; |
Tom Rini | e982d18 | 2018-01-03 09:01:33 -0500 | [diff] [blame] | 287 | } |
| 288 | } |
| 289 | |
Wang Huan | ddf89f9 | 2014-09-05 13:52:45 +0800 | [diff] [blame] | 290 | int config_serdes_mux(void) |
| 291 | { |
Tom Rini | 376b88a | 2022-10-28 20:27:13 -0400 | [diff] [blame] | 292 | struct ccsr_gur __iomem *gur = (void *)(CFG_SYS_FSL_GUTS_ADDR); |
Wang Huan | ddf89f9 | 2014-09-05 13:52:45 +0800 | [diff] [blame] | 293 | u32 protocol = in_be32(&gur->rcwsr[4]) & RCWSR4_SRDS1_PRTCL_MASK; |
| 294 | |
| 295 | protocol >>= RCWSR4_SRDS1_PRTCL_SHIFT; |
| 296 | switch (protocol) { |
| 297 | case 0x10: |
| 298 | convert_serdes_mux(LANEB_SATA, KEEP_STATUS); |
| 299 | convert_serdes_mux(LANED_PCIEX2 | |
| 300 | LANEC_PCIEX1, KEEP_STATUS); |
| 301 | break; |
| 302 | case 0x20: |
| 303 | convert_serdes_mux(LANEB_SGMII1, KEEP_STATUS); |
| 304 | convert_serdes_mux(LANEC_PCIEX1, KEEP_STATUS); |
| 305 | convert_serdes_mux(LANED_SGMII2, KEEP_STATUS); |
| 306 | break; |
| 307 | case 0x30: |
| 308 | convert_serdes_mux(LANEB_SATA, KEEP_STATUS); |
| 309 | convert_serdes_mux(LANEC_SGMII1, KEEP_STATUS); |
| 310 | convert_serdes_mux(LANED_SGMII2, KEEP_STATUS); |
| 311 | break; |
| 312 | case 0x70: |
| 313 | convert_serdes_mux(LANEB_SATA, KEEP_STATUS); |
| 314 | convert_serdes_mux(LANEC_PCIEX1, KEEP_STATUS); |
| 315 | convert_serdes_mux(LANED_SGMII2, KEEP_STATUS); |
| 316 | break; |
| 317 | } |
| 318 | |
| 319 | return 0; |
| 320 | } |
Alison Wang | 2145a37 | 2014-12-09 17:38:02 +0800 | [diff] [blame] | 321 | #endif |
Wang Huan | ddf89f9 | 2014-09-05 13:52:45 +0800 | [diff] [blame] | 322 | |
Alison Wang | dd45cc5 | 2015-10-15 17:54:40 +0800 | [diff] [blame] | 323 | #if !defined(CONFIG_QSPI_BOOT) && !defined(CONFIG_SD_BOOT_QSPI) |
Yao Yuan | 064f0a1 | 2015-03-03 16:35:18 +0800 | [diff] [blame] | 324 | int config_board_mux(void) |
| 325 | { |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 326 | struct cpld_data *cpld_data = (void *)(CFG_SYS_CPLD_BASE); |
Yao Yuan | 064f0a1 | 2015-03-03 16:35:18 +0800 | [diff] [blame] | 327 | int conflict_flag; |
| 328 | |
| 329 | conflict_flag = 0; |
| 330 | if (hwconfig("i2c3")) { |
| 331 | conflict_flag++; |
| 332 | cpld_data->soft_mux_on |= SOFT_MUX_ON_I2C3_IFC; |
| 333 | cpld_data->i2c3_ifc_mux = PIN_I2C3_IFC_MUX_I2C3; |
| 334 | } |
| 335 | |
| 336 | if (hwconfig("ifc")) { |
| 337 | conflict_flag++; |
| 338 | /* some signals can not enable simultaneous*/ |
| 339 | if (conflict_flag > 1) |
| 340 | goto conflict; |
| 341 | cpld_data->soft_mux_on |= SOFT_MUX_ON_I2C3_IFC; |
| 342 | cpld_data->i2c3_ifc_mux = PIN_I2C3_IFC_MUX_IFC; |
| 343 | } |
| 344 | |
| 345 | conflict_flag = 0; |
| 346 | if (hwconfig("usb2")) { |
| 347 | conflict_flag++; |
| 348 | cpld_data->soft_mux_on |= SOFT_MUX_ON_CAN3_USB2; |
| 349 | cpld_data->can3_usb2_mux = PIN_CAN3_USB2_MUX_USB2; |
| 350 | } |
| 351 | |
| 352 | if (hwconfig("can3")) { |
| 353 | conflict_flag++; |
| 354 | /* some signals can not enable simultaneous*/ |
| 355 | if (conflict_flag > 1) |
| 356 | goto conflict; |
| 357 | cpld_data->soft_mux_on |= SOFT_MUX_ON_CAN3_USB2; |
| 358 | cpld_data->can3_usb2_mux = PIN_CAN3_USB2_MUX_CAN3; |
| 359 | } |
| 360 | |
| 361 | conflict_flag = 0; |
| 362 | if (hwconfig("lcd")) { |
| 363 | conflict_flag++; |
| 364 | cpld_data->soft_mux_on |= SOFT_MUX_ON_QE_LCD; |
| 365 | cpld_data->qe_lcd_mux = PIN_QE_LCD_MUX_LCD; |
| 366 | } |
| 367 | |
| 368 | if (hwconfig("qe")) { |
| 369 | conflict_flag++; |
| 370 | /* some signals can not enable simultaneous*/ |
| 371 | if (conflict_flag > 1) |
| 372 | goto conflict; |
| 373 | cpld_data->soft_mux_on |= SOFT_MUX_ON_QE_LCD; |
| 374 | cpld_data->qe_lcd_mux = PIN_QE_LCD_MUX_QE; |
| 375 | } |
| 376 | |
| 377 | return 0; |
| 378 | |
| 379 | conflict: |
| 380 | printf("WARNING: pin conflict! MUX setting may failed!\n"); |
| 381 | return 0; |
| 382 | } |
| 383 | #endif |
| 384 | |
Wang Huan | ddf89f9 | 2014-09-05 13:52:45 +0800 | [diff] [blame] | 385 | int board_early_init_f(void) |
| 386 | { |
Tom Rini | 376b88a | 2022-10-28 20:27:13 -0400 | [diff] [blame] | 387 | struct ccsr_scfg *scfg = (struct ccsr_scfg *)CFG_SYS_FSL_SCFG_ADDR; |
Wang Huan | ddf89f9 | 2014-09-05 13:52:45 +0800 | [diff] [blame] | 388 | |
| 389 | #ifdef CONFIG_TSEC_ENET |
Claudiu Manoil | 51b503e | 2015-08-12 13:29:14 +0300 | [diff] [blame] | 390 | /* clear BD & FR bits for BE BD's and frame data */ |
| 391 | clrbits_be32(&scfg->etsecdmamcr, SCFG_ETSECDMAMCR_LE_BD_FR); |
Wang Huan | ddf89f9 | 2014-09-05 13:52:45 +0800 | [diff] [blame] | 392 | out_be32(&scfg->etsecmcr, SCFG_ETSECCMCR_GE2_CLK125); |
Wang Huan | ddf89f9 | 2014-09-05 13:52:45 +0800 | [diff] [blame] | 393 | #endif |
| 394 | |
| 395 | #ifdef CONFIG_FSL_IFC |
| 396 | init_early_memctl_regs(); |
| 397 | #endif |
| 398 | |
Yao Yuan | e0f8f54 | 2015-12-05 14:59:10 +0800 | [diff] [blame] | 399 | arch_soc_init(); |
Alison Wang | d42fc52 | 2015-01-15 17:29:29 +0800 | [diff] [blame] | 400 | |
Tang Yuantian | 8b160bc | 2015-05-14 17:20:28 +0800 | [diff] [blame] | 401 | #if defined(CONFIG_DEEP_SLEEP) |
tang yuantian | fcefdad | 2015-09-24 15:52:02 +0800 | [diff] [blame] | 402 | if (is_warm_boot()) { |
| 403 | timer_init(); |
| 404 | dram_init(); |
| 405 | } |
Tang Yuantian | 8b160bc | 2015-05-14 17:20:28 +0800 | [diff] [blame] | 406 | #endif |
| 407 | |
Wang Huan | ddf89f9 | 2014-09-05 13:52:45 +0800 | [diff] [blame] | 408 | return 0; |
| 409 | } |
| 410 | |
Alison Wang | 948c609 | 2014-12-03 15:00:48 +0800 | [diff] [blame] | 411 | #ifdef CONFIG_SPL_BUILD |
| 412 | void board_init_f(ulong dummy) |
| 413 | { |
tang yuantian | fcefdad | 2015-09-24 15:52:02 +0800 | [diff] [blame] | 414 | void (*second_uboot)(void); |
| 415 | |
Alison Wang | 948c609 | 2014-12-03 15:00:48 +0800 | [diff] [blame] | 416 | /* Clear the BSS */ |
| 417 | memset(__bss_start, 0, __bss_end - __bss_start); |
| 418 | |
| 419 | get_clocks(); |
| 420 | |
Tang Yuantian | 8b160bc | 2015-05-14 17:20:28 +0800 | [diff] [blame] | 421 | #if defined(CONFIG_DEEP_SLEEP) |
| 422 | if (is_warm_boot()) |
| 423 | fsl_dp_disable_console(); |
| 424 | #endif |
| 425 | |
Alison Wang | 948c609 | 2014-12-03 15:00:48 +0800 | [diff] [blame] | 426 | preloader_console_init(); |
| 427 | |
Alison Wang | 2825303 | 2018-10-16 16:19:22 +0800 | [diff] [blame] | 428 | timer_init(); |
Alison Wang | 948c609 | 2014-12-03 15:00:48 +0800 | [diff] [blame] | 429 | dram_init(); |
| 430 | |
Alison Wang | 5dec9d7 | 2015-07-09 10:50:07 +0800 | [diff] [blame] | 431 | /* Allow OCRAM access permission as R/W */ |
Mingkai Hu | 5b0df8a | 2015-10-26 19:47:41 +0800 | [diff] [blame] | 432 | #ifdef CONFIG_LAYERSCAPE_NS_ACCESS |
| 433 | enable_layerscape_ns_access(); |
Alison Wang | 5dec9d7 | 2015-07-09 10:50:07 +0800 | [diff] [blame] | 434 | #endif |
| 435 | |
tang yuantian | fcefdad | 2015-09-24 15:52:02 +0800 | [diff] [blame] | 436 | /* |
| 437 | * if it is woken up from deep sleep, then jump to second |
| 438 | * stage uboot and continue executing without recopying |
| 439 | * it from SD since it has already been reserved in memeory |
| 440 | * in last boot. |
| 441 | */ |
| 442 | if (is_warm_boot()) { |
Simon Glass | 72cc538 | 2022-10-20 18:22:39 -0600 | [diff] [blame] | 443 | second_uboot = (void (*)(void))CONFIG_TEXT_BASE; |
tang yuantian | fcefdad | 2015-09-24 15:52:02 +0800 | [diff] [blame] | 444 | second_uboot(); |
| 445 | } |
| 446 | |
Alison Wang | 948c609 | 2014-12-03 15:00:48 +0800 | [diff] [blame] | 447 | board_init_r(NULL, 0); |
| 448 | } |
| 449 | #endif |
| 450 | |
chenhui zhao | 08a01d4 | 2015-05-15 14:42:30 +0800 | [diff] [blame] | 451 | #ifdef CONFIG_DEEP_SLEEP |
| 452 | /* program the regulator (MC34VR500) to support deep sleep */ |
| 453 | void ls1twr_program_regulator(void) |
| 454 | { |
chenhui zhao | 08a01d4 | 2015-05-15 14:42:30 +0800 | [diff] [blame] | 455 | u8 i2c_device_id; |
| 456 | |
| 457 | #define LS1TWR_I2C_BUS_MC34VR500 1 |
| 458 | #define MC34VR500_ADDR 0x8 |
| 459 | #define MC34VR500_DEVICEID 0x4 |
| 460 | #define MC34VR500_DEVICEID_MASK 0x0f |
Igor Opaniuk | f7c9176 | 2021-02-09 13:52:45 +0200 | [diff] [blame] | 461 | #if CONFIG_IS_ENABLED(DM_I2C) |
Biwen Li | d15aa9f | 2019-12-31 15:33:44 +0800 | [diff] [blame] | 462 | struct udevice *dev; |
| 463 | int ret; |
chenhui zhao | 08a01d4 | 2015-05-15 14:42:30 +0800 | [diff] [blame] | 464 | |
Biwen Li | d15aa9f | 2019-12-31 15:33:44 +0800 | [diff] [blame] | 465 | ret = i2c_get_chip_for_busnum(LS1TWR_I2C_BUS_MC34VR500, MC34VR500_ADDR, |
| 466 | 1, &dev); |
| 467 | if (ret) { |
| 468 | printf("%s: Cannot find udev for a bus %d\n", __func__, |
| 469 | LS1TWR_I2C_BUS_MC34VR500); |
| 470 | return; |
| 471 | } |
| 472 | i2c_device_id = dm_i2c_reg_read(dev, 0x0) & |
| 473 | MC34VR500_DEVICEID_MASK; |
| 474 | if (i2c_device_id != MC34VR500_DEVICEID) { |
| 475 | printf("The regulator (MC34VR500) does not exist. The device does not support deep sleep.\n"); |
| 476 | return; |
| 477 | } |
| 478 | |
| 479 | dm_i2c_reg_write(dev, 0x31, 0x4); |
| 480 | dm_i2c_reg_write(dev, 0x4d, 0x4); |
| 481 | dm_i2c_reg_write(dev, 0x6d, 0x38); |
| 482 | dm_i2c_reg_write(dev, 0x6f, 0x37); |
| 483 | dm_i2c_reg_write(dev, 0x71, 0x30); |
| 484 | #else |
| 485 | unsigned int i2c_bus; |
chenhui zhao | 08a01d4 | 2015-05-15 14:42:30 +0800 | [diff] [blame] | 486 | i2c_bus = i2c_get_bus_num(); |
| 487 | i2c_set_bus_num(LS1TWR_I2C_BUS_MC34VR500); |
| 488 | i2c_device_id = i2c_reg_read(MC34VR500_ADDR, 0x0) & |
| 489 | MC34VR500_DEVICEID_MASK; |
| 490 | if (i2c_device_id != MC34VR500_DEVICEID) { |
| 491 | printf("The regulator (MC34VR500) does not exist. The device does not support deep sleep.\n"); |
| 492 | return; |
| 493 | } |
| 494 | |
| 495 | i2c_reg_write(MC34VR500_ADDR, 0x31, 0x4); |
| 496 | i2c_reg_write(MC34VR500_ADDR, 0x4d, 0x4); |
| 497 | i2c_reg_write(MC34VR500_ADDR, 0x6d, 0x38); |
| 498 | i2c_reg_write(MC34VR500_ADDR, 0x6f, 0x37); |
| 499 | i2c_reg_write(MC34VR500_ADDR, 0x71, 0x30); |
| 500 | |
| 501 | i2c_set_bus_num(i2c_bus); |
Biwen Li | d15aa9f | 2019-12-31 15:33:44 +0800 | [diff] [blame] | 502 | #endif |
chenhui zhao | 08a01d4 | 2015-05-15 14:42:30 +0800 | [diff] [blame] | 503 | } |
| 504 | #endif |
| 505 | |
Wang Huan | ddf89f9 | 2014-09-05 13:52:45 +0800 | [diff] [blame] | 506 | int board_init(void) |
| 507 | { |
Hou Zhiqiang | 4b23ca8 | 2016-08-02 19:03:27 +0800 | [diff] [blame] | 508 | #ifdef CONFIG_SYS_FSL_ERRATUM_A010315 |
| 509 | erratum_a010315(); |
| 510 | #endif |
| 511 | |
Wang Huan | ddf89f9 | 2014-09-05 13:52:45 +0800 | [diff] [blame] | 512 | #ifndef CONFIG_SYS_FSL_NO_SERDES |
| 513 | fsl_serdes_init(); |
Alison Wang | dd45cc5 | 2015-10-15 17:54:40 +0800 | [diff] [blame] | 514 | #if !defined(CONFIG_QSPI_BOOT) && !defined(CONFIG_SD_BOOT_QSPI) |
Wang Huan | ddf89f9 | 2014-09-05 13:52:45 +0800 | [diff] [blame] | 515 | config_serdes_mux(); |
| 516 | #endif |
Alison Wang | 2145a37 | 2014-12-09 17:38:02 +0800 | [diff] [blame] | 517 | #endif |
Wang Huan | ddf89f9 | 2014-09-05 13:52:45 +0800 | [diff] [blame] | 518 | |
Alison Wang | 6936492 | 2016-02-05 12:48:17 +0800 | [diff] [blame] | 519 | ls102xa_smmu_stream_id_init(); |
Xiubo Li | 03d40aa | 2014-11-21 17:40:59 +0800 | [diff] [blame] | 520 | |
Zhao Qiang | f3cc6b7 | 2014-09-26 16:25:33 +0800 | [diff] [blame] | 521 | #ifdef CONFIG_U_QE |
| 522 | u_qe_init(); |
| 523 | #endif |
| 524 | |
chenhui zhao | 08a01d4 | 2015-05-15 14:42:30 +0800 | [diff] [blame] | 525 | #ifdef CONFIG_DEEP_SLEEP |
| 526 | ls1twr_program_regulator(); |
| 527 | #endif |
Wang Huan | ddf89f9 | 2014-09-05 13:52:45 +0800 | [diff] [blame] | 528 | return 0; |
| 529 | } |
| 530 | |
Sumit Garg | e2ca943 | 2016-06-14 13:52:40 -0400 | [diff] [blame] | 531 | #if defined(CONFIG_SPL_BUILD) |
| 532 | void spl_board_init(void) |
| 533 | { |
Gaurav Jain | 119c700 | 2022-06-23 16:31:35 +0530 | [diff] [blame] | 534 | if (IS_ENABLED(CONFIG_FSL_CAAM)) { |
| 535 | struct udevice *dev; |
| 536 | int ret; |
| 537 | |
| 538 | ret = uclass_get_device_by_driver(UCLASS_MISC, DM_DRIVER_GET(caam_jr), &dev); |
| 539 | if (ret) |
| 540 | printf("Failed to initialize caam_jr: %d\n", ret); |
| 541 | } |
| 542 | |
Sumit Garg | e2ca943 | 2016-06-14 13:52:40 -0400 | [diff] [blame] | 543 | ls102xa_smmu_stream_id_init(); |
| 544 | } |
| 545 | #endif |
| 546 | |
tang yuantian | 9f51db2 | 2015-10-16 16:06:05 +0800 | [diff] [blame] | 547 | #ifdef CONFIG_BOARD_LATE_INIT |
| 548 | int board_late_init(void) |
| 549 | { |
Aneesh Bansal | 39d5b3b | 2016-01-22 16:37:26 +0530 | [diff] [blame] | 550 | #ifdef CONFIG_CHAIN_OF_TRUST |
| 551 | fsl_setenv_chain_of_trust(); |
| 552 | #endif |
tang yuantian | 9f51db2 | 2015-10-16 16:06:05 +0800 | [diff] [blame] | 553 | |
| 554 | return 0; |
| 555 | } |
| 556 | #endif |
| 557 | |
Ruchika Gupta | 901ae76 | 2014-10-15 11:39:06 +0530 | [diff] [blame] | 558 | #if defined(CONFIG_MISC_INIT_R) |
| 559 | int misc_init_r(void) |
| 560 | { |
Zhuoyu Zhang | fe4f288 | 2015-08-17 18:55:12 +0800 | [diff] [blame] | 561 | #ifdef CONFIG_FSL_DEVICE_DISABLE |
| 562 | device_disable(devdis_tbl, ARRAY_SIZE(devdis_tbl)); |
| 563 | #endif |
Alison Wang | dd45cc5 | 2015-10-15 17:54:40 +0800 | [diff] [blame] | 564 | #if !defined(CONFIG_QSPI_BOOT) && !defined(CONFIG_SD_BOOT_QSPI) |
Yao Yuan | 064f0a1 | 2015-03-03 16:35:18 +0800 | [diff] [blame] | 565 | config_board_mux(); |
| 566 | #endif |
Gaurav Jain | 476c639 | 2022-03-24 11:50:35 +0530 | [diff] [blame] | 567 | return 0; |
Ruchika Gupta | 901ae76 | 2014-10-15 11:39:06 +0530 | [diff] [blame] | 568 | } |
| 569 | #endif |
| 570 | |
Tang Yuantian | 8b160bc | 2015-05-14 17:20:28 +0800 | [diff] [blame] | 571 | #if defined(CONFIG_DEEP_SLEEP) |
| 572 | void board_sleep_prepare(void) |
| 573 | { |
Mingkai Hu | 5b0df8a | 2015-10-26 19:47:41 +0800 | [diff] [blame] | 574 | #ifdef CONFIG_LAYERSCAPE_NS_ACCESS |
| 575 | enable_layerscape_ns_access(); |
Tang Yuantian | 8b160bc | 2015-05-14 17:20:28 +0800 | [diff] [blame] | 576 | #endif |
| 577 | } |
| 578 | #endif |
| 579 | |
Masahiro Yamada | f7ed78b | 2020-06-26 15:13:33 +0900 | [diff] [blame] | 580 | int ft_board_setup(void *blob, struct bd_info *bd) |
Wang Huan | ddf89f9 | 2014-09-05 13:52:45 +0800 | [diff] [blame] | 581 | { |
| 582 | ft_cpu_setup(blob, bd); |
Simon Glass | 2aec3cc | 2014-10-23 18:58:47 -0600 | [diff] [blame] | 583 | |
Minghuan Lian | 0c53524 | 2015-03-12 10:58:48 +0800 | [diff] [blame] | 584 | #ifdef CONFIG_PCI |
| 585 | ft_pci_setup(blob, bd); |
Minghuan Lian | a4d6b61 | 2014-10-31 13:43:44 +0800 | [diff] [blame] | 586 | #endif |
| 587 | |
Simon Glass | 2aec3cc | 2014-10-23 18:58:47 -0600 | [diff] [blame] | 588 | return 0; |
Wang Huan | ddf89f9 | 2014-09-05 13:52:45 +0800 | [diff] [blame] | 589 | } |
| 590 | |
| 591 | u8 flash_read8(void *addr) |
| 592 | { |
| 593 | return __raw_readb(addr + 1); |
| 594 | } |
| 595 | |
| 596 | void flash_write16(u16 val, void *addr) |
| 597 | { |
| 598 | u16 shftval = (((val >> 8) & 0xff) | ((val << 8) & 0xff00)); |
| 599 | |
| 600 | __raw_writew(shftval, addr); |
| 601 | } |
| 602 | |
| 603 | u16 flash_read16(void *addr) |
| 604 | { |
| 605 | u16 val = __raw_readw(addr); |
| 606 | |
| 607 | return (((val) >> 8) & 0x00ff) | (((val) << 8) & 0xff00); |
| 608 | } |
| 609 | |
Tom Rini | e982d18 | 2018-01-03 09:01:33 -0500 | [diff] [blame] | 610 | #if !defined(CONFIG_QSPI_BOOT) && !defined(CONFIG_SD_BOOT_QSPI) \ |
| 611 | && !defined(CONFIG_SPL_BUILD) |
Wang Huan | ddf89f9 | 2014-09-05 13:52:45 +0800 | [diff] [blame] | 612 | static void convert_flash_bank(char bank) |
| 613 | { |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 614 | struct cpld_data *cpld_data = (void *)(CFG_SYS_CPLD_BASE); |
Wang Huan | ddf89f9 | 2014-09-05 13:52:45 +0800 | [diff] [blame] | 615 | |
| 616 | printf("Now switch to boot from flash bank %d.\n", bank); |
| 617 | cpld_data->soft_mux_on = CPLD_SET_BOOT_BANK; |
| 618 | cpld_data->vbank = bank; |
| 619 | |
| 620 | printf("Reset board to enable configuration.\n"); |
Simon Glass | 1877f2c | 2021-03-26 16:13:01 +1300 | [diff] [blame] | 621 | cpld_data->system_rst = CFG_RESET; |
Wang Huan | ddf89f9 | 2014-09-05 13:52:45 +0800 | [diff] [blame] | 622 | } |
| 623 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 624 | static int flash_bank_cmd(struct cmd_tbl *cmdtp, int flag, int argc, |
| 625 | char *const argv[]) |
Wang Huan | ddf89f9 | 2014-09-05 13:52:45 +0800 | [diff] [blame] | 626 | { |
| 627 | if (argc != 2) |
| 628 | return CMD_RET_USAGE; |
| 629 | if (strcmp(argv[1], "0") == 0) |
| 630 | convert_flash_bank(BOOT_FROM_UPPER_BANK); |
| 631 | else if (strcmp(argv[1], "1") == 0) |
| 632 | convert_flash_bank(BOOT_FROM_LOWER_BANK); |
| 633 | else |
| 634 | return CMD_RET_USAGE; |
| 635 | |
| 636 | return 0; |
| 637 | } |
| 638 | |
| 639 | U_BOOT_CMD( |
| 640 | boot_bank, 2, 0, flash_bank_cmd, |
| 641 | "Flash bank Selection Control", |
| 642 | "bank[0-upper bank/1-lower bank] (e.g. boot_bank 0)" |
| 643 | ); |
| 644 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 645 | static int cpld_reset_cmd(struct cmd_tbl *cmdtp, int flag, int argc, |
| 646 | char *const argv[]) |
Wang Huan | ddf89f9 | 2014-09-05 13:52:45 +0800 | [diff] [blame] | 647 | { |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 648 | struct cpld_data *cpld_data = (void *)(CFG_SYS_CPLD_BASE); |
Wang Huan | ddf89f9 | 2014-09-05 13:52:45 +0800 | [diff] [blame] | 649 | |
| 650 | if (argc > 2) |
| 651 | return CMD_RET_USAGE; |
| 652 | if ((argc == 1) || (strcmp(argv[1], "conf") == 0)) |
Simon Glass | 1877f2c | 2021-03-26 16:13:01 +1300 | [diff] [blame] | 653 | cpld_data->system_rst = CFG_RESET; |
Wang Huan | ddf89f9 | 2014-09-05 13:52:45 +0800 | [diff] [blame] | 654 | else if (strcmp(argv[1], "init") == 0) |
| 655 | cpld_data->global_rst = INIT_RESET; |
| 656 | else |
| 657 | return CMD_RET_USAGE; |
| 658 | |
| 659 | return 0; |
| 660 | } |
| 661 | |
| 662 | U_BOOT_CMD( |
| 663 | cpld_reset, 2, 0, cpld_reset_cmd, |
| 664 | "Reset via CPLD", |
| 665 | "conf\n" |
| 666 | " -reset with current CPLD configuration\n" |
| 667 | "init\n" |
| 668 | " -reset and initial CPLD configuration with default value" |
| 669 | |
| 670 | ); |
| 671 | |
Tom Rini | e982d18 | 2018-01-03 09:01:33 -0500 | [diff] [blame] | 672 | static void print_serdes_mux(void) |
Wang Huan | ddf89f9 | 2014-09-05 13:52:45 +0800 | [diff] [blame] | 673 | { |
| 674 | char current_serdes; |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 675 | struct cpld_data *cpld_data = (void *)(CFG_SYS_CPLD_BASE); |
Wang Huan | ddf89f9 | 2014-09-05 13:52:45 +0800 | [diff] [blame] | 676 | |
| 677 | current_serdes = cpld_data->serdes_mux; |
| 678 | |
| 679 | printf("Serdes Lane B: "); |
| 680 | if ((current_serdes & MASK_LANE_B) == 0) |
| 681 | printf("SATA,\n"); |
| 682 | else |
| 683 | printf("SGMII 1,\n"); |
| 684 | |
| 685 | printf("Serdes Lane C: "); |
| 686 | if ((current_serdes & MASK_LANE_C) == 0) |
| 687 | printf("SGMII 1,\n"); |
| 688 | else |
| 689 | printf("PCIe,\n"); |
| 690 | |
| 691 | printf("Serdes Lane D: "); |
| 692 | if ((current_serdes & MASK_LANE_D) == 0) |
| 693 | printf("PCIe,\n"); |
| 694 | else |
| 695 | printf("SGMII 2,\n"); |
| 696 | |
| 697 | printf("SGMII 1 is on lane "); |
| 698 | if ((current_serdes & MASK_SGMII) == 0) |
| 699 | printf("C.\n"); |
| 700 | else |
| 701 | printf("B.\n"); |
| 702 | } |
| 703 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 704 | static int serdes_mux_cmd(struct cmd_tbl *cmdtp, int flag, int argc, |
| 705 | char *const argv[]) |
Wang Huan | ddf89f9 | 2014-09-05 13:52:45 +0800 | [diff] [blame] | 706 | { |
| 707 | if (argc != 2) |
| 708 | return CMD_RET_USAGE; |
| 709 | if (strcmp(argv[1], "sata") == 0) { |
| 710 | printf("Set serdes lane B to SATA.\n"); |
| 711 | convert_serdes_mux(LANEB_SATA, NEED_RESET); |
| 712 | } else if (strcmp(argv[1], "sgmii1b") == 0) { |
| 713 | printf("Set serdes lane B to SGMII 1.\n"); |
| 714 | convert_serdes_mux(LANEB_SGMII1, NEED_RESET); |
| 715 | } else if (strcmp(argv[1], "sgmii1c") == 0) { |
| 716 | printf("Set serdes lane C to SGMII 1.\n"); |
| 717 | convert_serdes_mux(LANEC_SGMII1, NEED_RESET); |
| 718 | } else if (strcmp(argv[1], "sgmii2") == 0) { |
| 719 | printf("Set serdes lane D to SGMII 2.\n"); |
| 720 | convert_serdes_mux(LANED_SGMII2, NEED_RESET); |
| 721 | } else if (strcmp(argv[1], "pciex1") == 0) { |
| 722 | printf("Set serdes lane C to PCIe X1.\n"); |
| 723 | convert_serdes_mux(LANEC_PCIEX1, NEED_RESET); |
| 724 | } else if (strcmp(argv[1], "pciex2") == 0) { |
| 725 | printf("Set serdes lane C & lane D to PCIe X2.\n"); |
| 726 | convert_serdes_mux((LANED_PCIEX2 | LANEC_PCIEX1), NEED_RESET); |
| 727 | } else if (strcmp(argv[1], "show") == 0) { |
| 728 | print_serdes_mux(); |
| 729 | } else { |
| 730 | return CMD_RET_USAGE; |
| 731 | } |
| 732 | |
| 733 | return 0; |
| 734 | } |
| 735 | |
| 736 | U_BOOT_CMD( |
| 737 | lane_bank, 2, 0, serdes_mux_cmd, |
| 738 | "Multiplexed function setting for SerDes Lanes", |
| 739 | "sata\n" |
| 740 | " -change lane B to sata\n" |
| 741 | "lane_bank sgmii1b\n" |
| 742 | " -change lane B to SGMII1\n" |
| 743 | "lane_bank sgmii1c\n" |
| 744 | " -change lane C to SGMII1\n" |
| 745 | "lane_bank sgmii2\n" |
| 746 | " -change lane D to SGMII2\n" |
| 747 | "lane_bank pciex1\n" |
| 748 | " -change lane C to PCIeX1\n" |
| 749 | "lane_bank pciex2\n" |
| 750 | " -change lane C & lane D to PCIeX2\n" |
| 751 | "\nWARNING: If you aren't familiar with the setting of serdes, don't try to change anything!\n" |
| 752 | ); |
Alison Wang | 2145a37 | 2014-12-09 17:38:02 +0800 | [diff] [blame] | 753 | #endif |