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