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