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