Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Wang Huan | f0ce7d6 | 2014-09-05 13:52:44 +0800 | [diff] [blame] | 2 | /* |
| 3 | * Copyright 2014 Freescale Semiconductor, Inc. |
Biwen Li | d15aa9f | 2019-12-31 15:33:44 +0800 | [diff] [blame] | 4 | * Copyright 2019 NXP |
Wang Huan | f0ce7d6 | 2014-09-05 13:52:44 +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 | 3bbe70c | 2019-12-28 10:44:54 -0700 | [diff] [blame] | 9 | #include <fdt_support.h> |
Wang Huan | f0ce7d6 | 2014-09-05 13:52:44 +0800 | [diff] [blame] | 10 | #include <i2c.h> |
Simon Glass | a7b5130 | 2019-11-14 12:57:46 -0700 | [diff] [blame] | 11 | #include <init.h> |
Wang Huan | f0ce7d6 | 2014-09-05 13:52:44 +0800 | [diff] [blame] | 12 | #include <asm/io.h> |
| 13 | #include <asm/arch/immap_ls102xa.h> |
| 14 | #include <asm/arch/clock.h> |
| 15 | #include <asm/arch/fsl_serdes.h> |
Yao Yuan | e0f8f54 | 2015-12-05 14:59:10 +0800 | [diff] [blame] | 16 | #include <asm/arch/ls102xa_soc.h> |
Zhuoyu Zhang | fe4f288 | 2015-08-17 18:55:12 +0800 | [diff] [blame] | 17 | #include <asm/arch/ls102xa_devdis.h> |
Yao Yuan | fec6aa0 | 2014-11-26 14:54:33 +0800 | [diff] [blame] | 18 | #include <hwconfig.h> |
Wang Huan | f0ce7d6 | 2014-09-05 13:52:44 +0800 | [diff] [blame] | 19 | #include <mmc.h> |
Mingkai Hu | 5b0df8a | 2015-10-26 19:47:41 +0800 | [diff] [blame] | 20 | #include <fsl_csu.h> |
Wang Huan | f0ce7d6 | 2014-09-05 13:52:44 +0800 | [diff] [blame] | 21 | #include <fsl_ifc.h> |
Ruchika Gupta | 901ae76 | 2014-10-15 11:39:06 +0530 | [diff] [blame] | 22 | #include <fsl_sec.h> |
Alison Wang | 9da5178 | 2014-12-03 15:00:47 +0800 | [diff] [blame] | 23 | #include <spl.h> |
Zhuoyu Zhang | fe4f288 | 2015-08-17 18:55:12 +0800 | [diff] [blame] | 24 | #include <fsl_devdis.h> |
Aneesh Bansal | 39d5b3b | 2016-01-22 16:37:26 +0530 | [diff] [blame] | 25 | #include <fsl_validate.h> |
Shengzhou Liu | 15875a5 | 2016-11-21 11:36:48 +0800 | [diff] [blame] | 26 | #include <fsl_ddr.h> |
tang yuantian | 57296e7 | 2014-12-17 12:58:05 +0800 | [diff] [blame] | 27 | #include "../common/sleep.h" |
Wang Huan | f0ce7d6 | 2014-09-05 13:52:44 +0800 | [diff] [blame] | 28 | #include "../common/qixis.h" |
| 29 | #include "ls1021aqds_qixis.h" |
Zhao Qiang | 9fc2f30 | 2014-09-26 16:25:32 +0800 | [diff] [blame] | 30 | #ifdef CONFIG_U_QE |
Qianyu Gong | ae6a758 | 2016-02-18 13:01:59 +0800 | [diff] [blame] | 31 | #include <fsl_qe.h> |
Zhao Qiang | 9fc2f30 | 2014-09-26 16:25:32 +0800 | [diff] [blame] | 32 | #endif |
Wang Huan | f0ce7d6 | 2014-09-05 13:52:44 +0800 | [diff] [blame] | 33 | |
Yao Yuan | fec6aa0 | 2014-11-26 14:54:33 +0800 | [diff] [blame] | 34 | #define PIN_MUX_SEL_CAN 0x03 |
| 35 | #define PIN_MUX_SEL_IIC2 0xa0 |
| 36 | #define PIN_MUX_SEL_RGMII 0x00 |
| 37 | #define PIN_MUX_SEL_SAI 0x0c |
| 38 | #define PIN_MUX_SEL_SDHC 0x00 |
| 39 | |
| 40 | #define SET_SDHC_MUX_SEL(reg, value) ((reg & 0x0f) | value) |
| 41 | #define SET_EC_MUX_SEL(reg, value) ((reg & 0xf0) | value) |
Wang Huan | f0ce7d6 | 2014-09-05 13:52:44 +0800 | [diff] [blame] | 42 | enum { |
Yao Yuan | fec6aa0 | 2014-11-26 14:54:33 +0800 | [diff] [blame] | 43 | MUX_TYPE_CAN, |
| 44 | MUX_TYPE_IIC2, |
| 45 | MUX_TYPE_RGMII, |
| 46 | MUX_TYPE_SAI, |
| 47 | MUX_TYPE_SDHC, |
Wang Huan | f0ce7d6 | 2014-09-05 13:52:44 +0800 | [diff] [blame] | 48 | MUX_TYPE_SD_PCI4, |
| 49 | MUX_TYPE_SD_PC_SA_SG_SG, |
| 50 | MUX_TYPE_SD_PC_SA_PC_SG, |
| 51 | MUX_TYPE_SD_PC_SG_SG, |
| 52 | }; |
| 53 | |
Alison Wang | 29d7543 | 2014-12-09 17:38:23 +0800 | [diff] [blame] | 54 | enum { |
| 55 | GE0_CLK125, |
| 56 | GE2_CLK125, |
| 57 | GE1_CLK125, |
| 58 | }; |
| 59 | |
Wang Huan | f0ce7d6 | 2014-09-05 13:52:44 +0800 | [diff] [blame] | 60 | int checkboard(void) |
| 61 | { |
Alison Wang | 34de5e4 | 2016-02-02 15:16:23 +0800 | [diff] [blame] | 62 | #if !defined(CONFIG_QSPI_BOOT) && !defined(CONFIG_SD_BOOT_QSPI) |
Wang Huan | f0ce7d6 | 2014-09-05 13:52:44 +0800 | [diff] [blame] | 63 | char buf[64]; |
Alison Wang | 2145a37 | 2014-12-09 17:38:02 +0800 | [diff] [blame] | 64 | #endif |
Alison Wang | 9da5178 | 2014-12-03 15:00:47 +0800 | [diff] [blame] | 65 | #if !defined(CONFIG_SD_BOOT) && !defined(CONFIG_QSPI_BOOT) |
Wang Huan | f0ce7d6 | 2014-09-05 13:52:44 +0800 | [diff] [blame] | 66 | u8 sw; |
Alison Wang | 9da5178 | 2014-12-03 15:00:47 +0800 | [diff] [blame] | 67 | #endif |
Wang Huan | f0ce7d6 | 2014-09-05 13:52:44 +0800 | [diff] [blame] | 68 | |
| 69 | puts("Board: LS1021AQDS\n"); |
| 70 | |
Alison Wang | 9da5178 | 2014-12-03 15:00:47 +0800 | [diff] [blame] | 71 | #ifdef CONFIG_SD_BOOT |
| 72 | puts("SD\n"); |
| 73 | #elif CONFIG_QSPI_BOOT |
| 74 | puts("QSPI\n"); |
| 75 | #else |
Wang Huan | f0ce7d6 | 2014-09-05 13:52:44 +0800 | [diff] [blame] | 76 | sw = QIXIS_READ(brdcfg[0]); |
| 77 | sw = (sw & QIXIS_LBMAP_MASK) >> QIXIS_LBMAP_SHIFT; |
| 78 | |
| 79 | if (sw < 0x8) |
| 80 | printf("vBank: %d\n", sw); |
| 81 | else if (sw == 0x8) |
| 82 | puts("PromJet\n"); |
| 83 | else if (sw == 0x9) |
| 84 | puts("NAND\n"); |
| 85 | else if (sw == 0x15) |
| 86 | printf("IFCCard\n"); |
| 87 | else |
| 88 | printf("invalid setting of SW%u\n", QIXIS_LBMAP_SWITCH); |
Alison Wang | 9da5178 | 2014-12-03 15:00:47 +0800 | [diff] [blame] | 89 | #endif |
Wang Huan | f0ce7d6 | 2014-09-05 13:52:44 +0800 | [diff] [blame] | 90 | |
Alison Wang | 34de5e4 | 2016-02-02 15:16:23 +0800 | [diff] [blame] | 91 | #if !defined(CONFIG_QSPI_BOOT) && !defined(CONFIG_SD_BOOT_QSPI) |
Wang Huan | f0ce7d6 | 2014-09-05 13:52:44 +0800 | [diff] [blame] | 92 | printf("Sys ID:0x%02x, Sys Ver: 0x%02x\n", |
| 93 | QIXIS_READ(id), QIXIS_READ(arch)); |
| 94 | |
| 95 | printf("FPGA: v%d (%s), build %d\n", |
| 96 | (int)QIXIS_READ(scver), qixis_read_tag(buf), |
| 97 | (int)qixis_read_minor()); |
Alison Wang | 2145a37 | 2014-12-09 17:38:02 +0800 | [diff] [blame] | 98 | #endif |
Wang Huan | f0ce7d6 | 2014-09-05 13:52:44 +0800 | [diff] [blame] | 99 | |
| 100 | return 0; |
| 101 | } |
| 102 | |
| 103 | unsigned long get_board_sys_clk(void) |
| 104 | { |
| 105 | u8 sysclk_conf = QIXIS_READ(brdcfg[1]); |
| 106 | |
| 107 | switch (sysclk_conf & 0x0f) { |
| 108 | case QIXIS_SYSCLK_64: |
| 109 | return 64000000; |
| 110 | case QIXIS_SYSCLK_83: |
| 111 | return 83333333; |
| 112 | case QIXIS_SYSCLK_100: |
| 113 | return 100000000; |
| 114 | case QIXIS_SYSCLK_125: |
| 115 | return 125000000; |
| 116 | case QIXIS_SYSCLK_133: |
| 117 | return 133333333; |
| 118 | case QIXIS_SYSCLK_150: |
| 119 | return 150000000; |
| 120 | case QIXIS_SYSCLK_160: |
| 121 | return 160000000; |
| 122 | case QIXIS_SYSCLK_166: |
| 123 | return 166666666; |
| 124 | } |
| 125 | return 66666666; |
| 126 | } |
| 127 | |
| 128 | unsigned long get_board_ddr_clk(void) |
| 129 | { |
| 130 | u8 ddrclk_conf = QIXIS_READ(brdcfg[1]); |
| 131 | |
| 132 | switch ((ddrclk_conf & 0x30) >> 4) { |
| 133 | case QIXIS_DDRCLK_100: |
| 134 | return 100000000; |
| 135 | case QIXIS_DDRCLK_125: |
| 136 | return 125000000; |
| 137 | case QIXIS_DDRCLK_133: |
| 138 | return 133333333; |
| 139 | } |
| 140 | return 66666666; |
| 141 | } |
| 142 | |
Biwen Li | d15aa9f | 2019-12-31 15:33:44 +0800 | [diff] [blame] | 143 | int select_i2c_ch_pca9547(u8 ch, int bus_num) |
Chenhui Zhao | 5096694 | 2014-11-06 10:51:59 +0800 | [diff] [blame] | 144 | { |
| 145 | int ret; |
Biwen Li | d15aa9f | 2019-12-31 15:33:44 +0800 | [diff] [blame] | 146 | #ifdef CONFIG_DM_I2C |
| 147 | struct udevice *dev; |
Chenhui Zhao | 5096694 | 2014-11-06 10:51:59 +0800 | [diff] [blame] | 148 | |
Biwen Li | d15aa9f | 2019-12-31 15:33:44 +0800 | [diff] [blame] | 149 | ret = i2c_get_chip_for_busnum(bus_num, I2C_MUX_PCA_ADDR_PRI, |
| 150 | 1, &dev); |
| 151 | if (ret) { |
| 152 | printf("%s: Cannot find udev for a bus %d\n", __func__, |
| 153 | bus_num); |
| 154 | return ret; |
| 155 | } |
| 156 | ret = dm_i2c_write(dev, 0, &ch, 1); |
| 157 | #else |
Chenhui Zhao | 5096694 | 2014-11-06 10:51:59 +0800 | [diff] [blame] | 158 | ret = i2c_write(I2C_MUX_PCA_ADDR_PRI, 0, 1, &ch, 1); |
Biwen Li | d15aa9f | 2019-12-31 15:33:44 +0800 | [diff] [blame] | 159 | #endif |
Chenhui Zhao | 5096694 | 2014-11-06 10:51:59 +0800 | [diff] [blame] | 160 | if (ret) { |
| 161 | puts("PCA: failed to select proper channel\n"); |
| 162 | return ret; |
| 163 | } |
| 164 | |
| 165 | return 0; |
| 166 | } |
| 167 | |
Wang Huan | f0ce7d6 | 2014-09-05 13:52:44 +0800 | [diff] [blame] | 168 | int dram_init(void) |
| 169 | { |
Chenhui Zhao | 5096694 | 2014-11-06 10:51:59 +0800 | [diff] [blame] | 170 | /* |
| 171 | * When resuming from deep sleep, the I2C channel may not be |
| 172 | * in the default channel. So, switch to the default channel |
| 173 | * before accessing DDR SPD. |
Biwen Li | d15aa9f | 2019-12-31 15:33:44 +0800 | [diff] [blame] | 174 | * |
| 175 | * PCA9547(0x77) mount on I2C1 bus |
Chenhui Zhao | 5096694 | 2014-11-06 10:51:59 +0800 | [diff] [blame] | 176 | */ |
Biwen Li | d15aa9f | 2019-12-31 15:33:44 +0800 | [diff] [blame] | 177 | select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT, 0); |
Simon Glass | 0e0ac20 | 2017-04-06 12:47:04 -0600 | [diff] [blame] | 178 | return fsl_initdram(); |
Wang Huan | f0ce7d6 | 2014-09-05 13:52:44 +0800 | [diff] [blame] | 179 | } |
| 180 | |
Wang Huan | f0ce7d6 | 2014-09-05 13:52:44 +0800 | [diff] [blame] | 181 | int board_early_init_f(void) |
| 182 | { |
| 183 | struct ccsr_scfg *scfg = (struct ccsr_scfg *)CONFIG_SYS_FSL_SCFG_ADDR; |
Wang Huan | f0ce7d6 | 2014-09-05 13:52:44 +0800 | [diff] [blame] | 184 | |
| 185 | #ifdef CONFIG_TSEC_ENET |
Claudiu Manoil | 51b503e | 2015-08-12 13:29:14 +0300 | [diff] [blame] | 186 | /* clear BD & FR bits for BE BD's and frame data */ |
| 187 | clrbits_be32(&scfg->etsecdmamcr, SCFG_ETSECDMAMCR_LE_BD_FR); |
Wang Huan | f0ce7d6 | 2014-09-05 13:52:44 +0800 | [diff] [blame] | 188 | #endif |
| 189 | |
| 190 | #ifdef CONFIG_FSL_IFC |
| 191 | init_early_memctl_regs(); |
| 192 | #endif |
| 193 | |
Yao Yuan | e0f8f54 | 2015-12-05 14:59:10 +0800 | [diff] [blame] | 194 | arch_soc_init(); |
Wang Huan | f0ce7d6 | 2014-09-05 13:52:44 +0800 | [diff] [blame] | 195 | |
tang yuantian | 57296e7 | 2014-12-17 12:58:05 +0800 | [diff] [blame] | 196 | #if defined(CONFIG_DEEP_SLEEP) |
| 197 | if (is_warm_boot()) |
| 198 | fsl_dp_disable_console(); |
| 199 | #endif |
| 200 | |
Wang Huan | f0ce7d6 | 2014-09-05 13:52:44 +0800 | [diff] [blame] | 201 | return 0; |
| 202 | } |
Alison Wang | 9da5178 | 2014-12-03 15:00:47 +0800 | [diff] [blame] | 203 | |
| 204 | #ifdef CONFIG_SPL_BUILD |
| 205 | void board_init_f(ulong dummy) |
| 206 | { |
Alison Wang | ab98bb5 | 2014-12-09 17:38:14 +0800 | [diff] [blame] | 207 | #ifdef CONFIG_NAND_BOOT |
| 208 | struct ccsr_gur __iomem *gur = (void *)CONFIG_SYS_FSL_GUTS_ADDR; |
| 209 | u32 porsr1, pinctl; |
| 210 | |
| 211 | /* |
| 212 | * There is LS1 SoC issue where NOR, FPGA are inaccessible during |
| 213 | * NAND boot because IFC signals > IFC_AD7 are not enabled. |
| 214 | * This workaround changes RCW source to make all signals enabled. |
| 215 | */ |
| 216 | porsr1 = in_be32(&gur->porsr1); |
| 217 | pinctl = ((porsr1 & ~(DCFG_CCSR_PORSR1_RCW_MASK)) | |
| 218 | DCFG_CCSR_PORSR1_RCW_SRC_I2C); |
| 219 | out_be32((unsigned int *)(CONFIG_SYS_DCSR_DCFG_ADDR + DCFG_DCSR_PORCR1), |
| 220 | pinctl); |
| 221 | #endif |
| 222 | |
Alison Wang | 9da5178 | 2014-12-03 15:00:47 +0800 | [diff] [blame] | 223 | /* Clear the BSS */ |
| 224 | memset(__bss_start, 0, __bss_end - __bss_start); |
| 225 | |
| 226 | #ifdef CONFIG_FSL_IFC |
| 227 | init_early_memctl_regs(); |
| 228 | #endif |
| 229 | |
| 230 | get_clocks(); |
| 231 | |
tang yuantian | 57296e7 | 2014-12-17 12:58:05 +0800 | [diff] [blame] | 232 | #if defined(CONFIG_DEEP_SLEEP) |
| 233 | if (is_warm_boot()) |
| 234 | fsl_dp_disable_console(); |
| 235 | #endif |
| 236 | |
Alison Wang | 9da5178 | 2014-12-03 15:00:47 +0800 | [diff] [blame] | 237 | preloader_console_init(); |
| 238 | |
| 239 | #ifdef CONFIG_SPL_I2C_SUPPORT |
| 240 | i2c_init_all(); |
| 241 | #endif |
Alison Wang | 6027eb4 | 2015-03-12 11:31:44 +0800 | [diff] [blame] | 242 | |
Alison Wang | 2825303 | 2018-10-16 16:19:22 +0800 | [diff] [blame] | 243 | timer_init(); |
Alison Wang | 9da5178 | 2014-12-03 15:00:47 +0800 | [diff] [blame] | 244 | dram_init(); |
| 245 | |
Alison Wang | 5dec9d7 | 2015-07-09 10:50:07 +0800 | [diff] [blame] | 246 | /* Allow OCRAM access permission as R/W */ |
Mingkai Hu | 5b0df8a | 2015-10-26 19:47:41 +0800 | [diff] [blame] | 247 | #ifdef CONFIG_LAYERSCAPE_NS_ACCESS |
| 248 | enable_layerscape_ns_access(); |
Alison Wang | 5dec9d7 | 2015-07-09 10:50:07 +0800 | [diff] [blame] | 249 | #endif |
| 250 | |
Alison Wang | 9da5178 | 2014-12-03 15:00:47 +0800 | [diff] [blame] | 251 | board_init_r(NULL, 0); |
| 252 | } |
| 253 | #endif |
Wang Huan | f0ce7d6 | 2014-09-05 13:52:44 +0800 | [diff] [blame] | 254 | |
Alison Wang | 29d7543 | 2014-12-09 17:38:23 +0800 | [diff] [blame] | 255 | void config_etseccm_source(int etsec_gtx_125_mux) |
| 256 | { |
| 257 | struct ccsr_scfg *scfg = (struct ccsr_scfg *)CONFIG_SYS_FSL_SCFG_ADDR; |
| 258 | |
| 259 | switch (etsec_gtx_125_mux) { |
| 260 | case GE0_CLK125: |
| 261 | out_be32(&scfg->etsecmcr, SCFG_ETSECCMCR_GE0_CLK125); |
| 262 | debug("etseccm set to GE0_CLK125\n"); |
| 263 | break; |
| 264 | |
| 265 | case GE2_CLK125: |
| 266 | out_be32(&scfg->etsecmcr, SCFG_ETSECCMCR_GE2_CLK125); |
| 267 | debug("etseccm set to GE2_CLK125\n"); |
| 268 | break; |
| 269 | |
| 270 | case GE1_CLK125: |
| 271 | out_be32(&scfg->etsecmcr, SCFG_ETSECCMCR_GE1_CLK125); |
| 272 | debug("etseccm set to GE1_CLK125\n"); |
| 273 | break; |
| 274 | |
| 275 | default: |
| 276 | printf("Error! trying to set etseccm to invalid value\n"); |
| 277 | break; |
| 278 | } |
| 279 | } |
| 280 | |
Wang Huan | f0ce7d6 | 2014-09-05 13:52:44 +0800 | [diff] [blame] | 281 | int config_board_mux(int ctrl_type) |
| 282 | { |
Yao Yuan | fec6aa0 | 2014-11-26 14:54:33 +0800 | [diff] [blame] | 283 | u8 reg12, reg14; |
Wang Huan | f0ce7d6 | 2014-09-05 13:52:44 +0800 | [diff] [blame] | 284 | |
| 285 | reg12 = QIXIS_READ(brdcfg[12]); |
Yao Yuan | fec6aa0 | 2014-11-26 14:54:33 +0800 | [diff] [blame] | 286 | reg14 = QIXIS_READ(brdcfg[14]); |
Wang Huan | f0ce7d6 | 2014-09-05 13:52:44 +0800 | [diff] [blame] | 287 | |
| 288 | switch (ctrl_type) { |
Yao Yuan | fec6aa0 | 2014-11-26 14:54:33 +0800 | [diff] [blame] | 289 | case MUX_TYPE_CAN: |
Alison Wang | 29d7543 | 2014-12-09 17:38:23 +0800 | [diff] [blame] | 290 | config_etseccm_source(GE2_CLK125); |
Yao Yuan | fec6aa0 | 2014-11-26 14:54:33 +0800 | [diff] [blame] | 291 | reg14 = SET_EC_MUX_SEL(reg14, PIN_MUX_SEL_CAN); |
| 292 | break; |
| 293 | case MUX_TYPE_IIC2: |
| 294 | reg14 = SET_SDHC_MUX_SEL(reg14, PIN_MUX_SEL_IIC2); |
| 295 | break; |
| 296 | case MUX_TYPE_RGMII: |
| 297 | reg14 = SET_EC_MUX_SEL(reg14, PIN_MUX_SEL_RGMII); |
| 298 | break; |
| 299 | case MUX_TYPE_SAI: |
Alison Wang | 29d7543 | 2014-12-09 17:38:23 +0800 | [diff] [blame] | 300 | config_etseccm_source(GE2_CLK125); |
Yao Yuan | fec6aa0 | 2014-11-26 14:54:33 +0800 | [diff] [blame] | 301 | reg14 = SET_EC_MUX_SEL(reg14, PIN_MUX_SEL_SAI); |
| 302 | break; |
| 303 | case MUX_TYPE_SDHC: |
| 304 | reg14 = SET_SDHC_MUX_SEL(reg14, PIN_MUX_SEL_SDHC); |
| 305 | break; |
Wang Huan | f0ce7d6 | 2014-09-05 13:52:44 +0800 | [diff] [blame] | 306 | case MUX_TYPE_SD_PCI4: |
| 307 | reg12 = 0x38; |
| 308 | break; |
| 309 | case MUX_TYPE_SD_PC_SA_SG_SG: |
| 310 | reg12 = 0x01; |
| 311 | break; |
| 312 | case MUX_TYPE_SD_PC_SA_PC_SG: |
| 313 | reg12 = 0x01; |
| 314 | break; |
| 315 | case MUX_TYPE_SD_PC_SG_SG: |
| 316 | reg12 = 0x21; |
| 317 | break; |
| 318 | default: |
| 319 | printf("Wrong mux interface type\n"); |
| 320 | return -1; |
| 321 | } |
| 322 | |
| 323 | QIXIS_WRITE(brdcfg[12], reg12); |
Yao Yuan | fec6aa0 | 2014-11-26 14:54:33 +0800 | [diff] [blame] | 324 | QIXIS_WRITE(brdcfg[14], reg14); |
Wang Huan | f0ce7d6 | 2014-09-05 13:52:44 +0800 | [diff] [blame] | 325 | |
| 326 | return 0; |
| 327 | } |
| 328 | |
| 329 | int config_serdes_mux(void) |
| 330 | { |
| 331 | struct ccsr_gur *gur = (struct ccsr_gur *)CONFIG_SYS_FSL_GUTS_ADDR; |
| 332 | u32 cfg; |
| 333 | |
| 334 | cfg = in_be32(&gur->rcwsr[4]) & RCWSR4_SRDS1_PRTCL_MASK; |
| 335 | cfg >>= RCWSR4_SRDS1_PRTCL_SHIFT; |
| 336 | |
| 337 | switch (cfg) { |
| 338 | case 0x0: |
| 339 | config_board_mux(MUX_TYPE_SD_PCI4); |
| 340 | break; |
| 341 | case 0x30: |
| 342 | config_board_mux(MUX_TYPE_SD_PC_SA_SG_SG); |
| 343 | break; |
| 344 | case 0x60: |
| 345 | config_board_mux(MUX_TYPE_SD_PC_SG_SG); |
| 346 | break; |
| 347 | case 0x70: |
| 348 | config_board_mux(MUX_TYPE_SD_PC_SA_PC_SG); |
| 349 | break; |
| 350 | default: |
| 351 | printf("SRDS1 prtcl:0x%x\n", cfg); |
| 352 | break; |
| 353 | } |
| 354 | |
| 355 | return 0; |
| 356 | } |
| 357 | |
tang yuantian | 9f51db2 | 2015-10-16 16:06:05 +0800 | [diff] [blame] | 358 | #ifdef CONFIG_BOARD_LATE_INIT |
| 359 | int board_late_init(void) |
| 360 | { |
Aneesh Bansal | 39d5b3b | 2016-01-22 16:37:26 +0530 | [diff] [blame] | 361 | #ifdef CONFIG_CHAIN_OF_TRUST |
| 362 | fsl_setenv_chain_of_trust(); |
| 363 | #endif |
tang yuantian | 9f51db2 | 2015-10-16 16:06:05 +0800 | [diff] [blame] | 364 | |
| 365 | return 0; |
| 366 | } |
| 367 | #endif |
| 368 | |
Ruchika Gupta | 901ae76 | 2014-10-15 11:39:06 +0530 | [diff] [blame] | 369 | int misc_init_r(void) |
| 370 | { |
Yao Yuan | fec6aa0 | 2014-11-26 14:54:33 +0800 | [diff] [blame] | 371 | int conflict_flag; |
| 372 | |
| 373 | /* some signals can not enable simultaneous*/ |
| 374 | conflict_flag = 0; |
| 375 | if (hwconfig("sdhc")) |
| 376 | conflict_flag++; |
| 377 | if (hwconfig("iic2")) |
| 378 | conflict_flag++; |
| 379 | if (conflict_flag > 1) { |
| 380 | printf("WARNING: pin conflict !\n"); |
| 381 | return 0; |
| 382 | } |
| 383 | |
| 384 | conflict_flag = 0; |
| 385 | if (hwconfig("rgmii")) |
| 386 | conflict_flag++; |
| 387 | if (hwconfig("can")) |
| 388 | conflict_flag++; |
| 389 | if (hwconfig("sai")) |
| 390 | conflict_flag++; |
| 391 | if (conflict_flag > 1) { |
| 392 | printf("WARNING: pin conflict !\n"); |
| 393 | return 0; |
| 394 | } |
| 395 | |
| 396 | if (hwconfig("can")) |
| 397 | config_board_mux(MUX_TYPE_CAN); |
| 398 | else if (hwconfig("rgmii")) |
| 399 | config_board_mux(MUX_TYPE_RGMII); |
| 400 | else if (hwconfig("sai")) |
| 401 | config_board_mux(MUX_TYPE_SAI); |
| 402 | |
| 403 | if (hwconfig("iic2")) |
| 404 | config_board_mux(MUX_TYPE_IIC2); |
| 405 | else if (hwconfig("sdhc")) |
| 406 | config_board_mux(MUX_TYPE_SDHC); |
| 407 | |
Zhuoyu Zhang | fe4f288 | 2015-08-17 18:55:12 +0800 | [diff] [blame] | 408 | #ifdef CONFIG_FSL_DEVICE_DISABLE |
| 409 | device_disable(devdis_tbl, ARRAY_SIZE(devdis_tbl)); |
| 410 | #endif |
Ruchika Gupta | 901ae76 | 2014-10-15 11:39:06 +0530 | [diff] [blame] | 411 | #ifdef CONFIG_FSL_CAAM |
| 412 | return sec_init(); |
| 413 | #endif |
Yao Yuan | fec6aa0 | 2014-11-26 14:54:33 +0800 | [diff] [blame] | 414 | return 0; |
Ruchika Gupta | 901ae76 | 2014-10-15 11:39:06 +0530 | [diff] [blame] | 415 | } |
Ruchika Gupta | 901ae76 | 2014-10-15 11:39:06 +0530 | [diff] [blame] | 416 | |
Wang Huan | f0ce7d6 | 2014-09-05 13:52:44 +0800 | [diff] [blame] | 417 | int board_init(void) |
| 418 | { |
Hou Zhiqiang | 4b23ca8 | 2016-08-02 19:03:27 +0800 | [diff] [blame] | 419 | #ifdef CONFIG_SYS_FSL_ERRATUM_A010315 |
| 420 | erratum_a010315(); |
| 421 | #endif |
Shengzhou Liu | 15875a5 | 2016-11-21 11:36:48 +0800 | [diff] [blame] | 422 | #ifdef CONFIG_SYS_FSL_ERRATUM_A009942 |
| 423 | erratum_a009942_check_cpo(); |
| 424 | #endif |
Wang Huan | f0ce7d6 | 2014-09-05 13:52:44 +0800 | [diff] [blame] | 425 | |
Biwen Li | d15aa9f | 2019-12-31 15:33:44 +0800 | [diff] [blame] | 426 | select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT, 0); |
Wang Huan | f0ce7d6 | 2014-09-05 13:52:44 +0800 | [diff] [blame] | 427 | |
| 428 | #ifndef CONFIG_SYS_FSL_NO_SERDES |
| 429 | fsl_serdes_init(); |
| 430 | config_serdes_mux(); |
| 431 | #endif |
Zhao Qiang | 9fc2f30 | 2014-09-26 16:25:32 +0800 | [diff] [blame] | 432 | |
Alison Wang | 6936492 | 2016-02-05 12:48:17 +0800 | [diff] [blame] | 433 | ls102xa_smmu_stream_id_init(); |
Xiubo Li | 03d40aa | 2014-11-21 17:40:59 +0800 | [diff] [blame] | 434 | |
Zhao Qiang | 9fc2f30 | 2014-09-26 16:25:32 +0800 | [diff] [blame] | 435 | #ifdef CONFIG_U_QE |
| 436 | u_qe_init(); |
| 437 | #endif |
| 438 | |
Wang Huan | f0ce7d6 | 2014-09-05 13:52:44 +0800 | [diff] [blame] | 439 | return 0; |
| 440 | } |
tang yuantian | 57296e7 | 2014-12-17 12:58:05 +0800 | [diff] [blame] | 441 | |
| 442 | #if defined(CONFIG_DEEP_SLEEP) |
| 443 | void board_sleep_prepare(void) |
| 444 | { |
Mingkai Hu | 5b0df8a | 2015-10-26 19:47:41 +0800 | [diff] [blame] | 445 | #ifdef CONFIG_LAYERSCAPE_NS_ACCESS |
| 446 | enable_layerscape_ns_access(); |
tang yuantian | 57296e7 | 2014-12-17 12:58:05 +0800 | [diff] [blame] | 447 | #endif |
| 448 | } |
| 449 | #endif |
Wang Huan | f0ce7d6 | 2014-09-05 13:52:44 +0800 | [diff] [blame] | 450 | |
Simon Glass | 2aec3cc | 2014-10-23 18:58:47 -0600 | [diff] [blame] | 451 | int ft_board_setup(void *blob, bd_t *bd) |
Wang Huan | f0ce7d6 | 2014-09-05 13:52:44 +0800 | [diff] [blame] | 452 | { |
| 453 | ft_cpu_setup(blob, bd); |
Simon Glass | 2aec3cc | 2014-10-23 18:58:47 -0600 | [diff] [blame] | 454 | |
Minghuan Lian | 0c53524 | 2015-03-12 10:58:48 +0800 | [diff] [blame] | 455 | #ifdef CONFIG_PCI |
| 456 | ft_pci_setup(blob, bd); |
Minghuan Lian | a4d6b61 | 2014-10-31 13:43:44 +0800 | [diff] [blame] | 457 | #endif |
| 458 | |
Simon Glass | 2aec3cc | 2014-10-23 18:58:47 -0600 | [diff] [blame] | 459 | return 0; |
Wang Huan | f0ce7d6 | 2014-09-05 13:52:44 +0800 | [diff] [blame] | 460 | } |
| 461 | |
| 462 | u8 flash_read8(void *addr) |
| 463 | { |
| 464 | return __raw_readb(addr + 1); |
| 465 | } |
| 466 | |
| 467 | void flash_write16(u16 val, void *addr) |
| 468 | { |
| 469 | u16 shftval = (((val >> 8) & 0xff) | ((val << 8) & 0xff00)); |
| 470 | |
| 471 | __raw_writew(shftval, addr); |
| 472 | } |
| 473 | |
| 474 | u16 flash_read16(void *addr) |
| 475 | { |
| 476 | u16 val = __raw_readw(addr); |
| 477 | |
| 478 | return (((val) >> 8) & 0x00ff) | (((val) << 8) & 0xff00); |
| 479 | } |