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