Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Kumar Gala | 8975d7a | 2010-12-30 12:09:53 -0600 | [diff] [blame] | 2 | /* |
| 3 | * Copyright 2011 Freescale Semiconductor, Inc. |
Kumar Gala | 8975d7a | 2010-12-30 12:09:53 -0600 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <common.h> |
| 7 | #include <config.h> |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 8 | #include <log.h> |
Simon Glass | 45c7890 | 2019-11-14 12:57:26 -0700 | [diff] [blame] | 9 | #include <time.h> |
Kumar Gala | 8975d7a | 2010-12-30 12:09:53 -0600 | [diff] [blame] | 10 | #include <asm/fsl_law.h> |
| 11 | #include <asm/fsl_serdes.h> |
Liu Gang | 4cc8532 | 2012-03-08 00:33:17 +0000 | [diff] [blame] | 12 | #include <asm/fsl_srio.h> |
Simon Glass | dbd7954 | 2020-05-10 11:40:11 -0600 | [diff] [blame] | 13 | #include <linux/delay.h> |
Masahiro Yamada | 56a931c | 2016-09-21 11:28:55 +0900 | [diff] [blame] | 14 | #include <linux/errno.h> |
Liu Gang | 4cc8532 | 2012-03-08 00:33:17 +0000 | [diff] [blame] | 15 | |
Liu Gang | 27afb9c | 2013-05-07 16:30:46 +0800 | [diff] [blame] | 16 | #ifdef CONFIG_SRIO_PCIE_BOOT_MASTER |
Liu Gang | 4cc8532 | 2012-03-08 00:33:17 +0000 | [diff] [blame] | 17 | #define SRIO_PORT_ACCEPT_ALL 0x10000001 |
| 18 | #define SRIO_IB_ATMU_AR 0x80f55000 |
Liu Gang | f420aa9 | 2012-03-08 00:33:21 +0000 | [diff] [blame] | 19 | #define SRIO_OB_ATMU_AR_MAINT 0x80077000 |
| 20 | #define SRIO_OB_ATMU_AR_RW 0x80045000 |
| 21 | #define SRIO_LCSBA1CSR_OFFSET 0x5c |
| 22 | #define SRIO_MAINT_WIN_SIZE 0x1000000 /* 16M */ |
| 23 | #define SRIO_RW_WIN_SIZE 0x100000 /* 1M */ |
| 24 | #define SRIO_LCSBA1CSR 0x60000000 |
Liu Gang | 558359a | 2012-10-14 20:55:17 +0000 | [diff] [blame] | 25 | #endif |
Kumar Gala | 8975d7a | 2010-12-30 12:09:53 -0600 | [diff] [blame] | 26 | |
| 27 | #if defined(CONFIG_FSL_CORENET) |
York Sun | 9941a22 | 2012-10-08 07:44:19 +0000 | [diff] [blame] | 28 | #ifdef CONFIG_SYS_FSL_QORIQ_CHASSIS2 |
| 29 | #define _DEVDISR_SRIO1 FSL_CORENET_DEVDISR3_SRIO1 |
| 30 | #define _DEVDISR_SRIO2 FSL_CORENET_DEVDISR3_SRIO2 |
| 31 | #else |
Kumar Gala | 8975d7a | 2010-12-30 12:09:53 -0600 | [diff] [blame] | 32 | #define _DEVDISR_SRIO1 FSL_CORENET_DEVDISR_SRIO1 |
| 33 | #define _DEVDISR_SRIO2 FSL_CORENET_DEVDISR_SRIO2 |
York Sun | 9941a22 | 2012-10-08 07:44:19 +0000 | [diff] [blame] | 34 | #endif |
Kumar Gala | 8975d7a | 2010-12-30 12:09:53 -0600 | [diff] [blame] | 35 | #define _DEVDISR_RMU FSL_CORENET_DEVDISR_RMU |
| 36 | #define CONFIG_SYS_MPC8xxx_GUTS_ADDR CONFIG_SYS_MPC85xx_GUTS_ADDR |
| 37 | #elif defined(CONFIG_MPC85xx) |
| 38 | #define _DEVDISR_SRIO1 MPC85xx_DEVDISR_SRIO |
| 39 | #define _DEVDISR_SRIO2 MPC85xx_DEVDISR_SRIO |
| 40 | #define _DEVDISR_RMU MPC85xx_DEVDISR_RMSG |
| 41 | #define CONFIG_SYS_MPC8xxx_GUTS_ADDR CONFIG_SYS_MPC85xx_GUTS_ADDR |
| 42 | #elif defined(CONFIG_MPC86xx) |
| 43 | #define _DEVDISR_SRIO1 MPC86xx_DEVDISR_SRIO |
| 44 | #define _DEVDISR_SRIO2 MPC86xx_DEVDISR_SRIO |
| 45 | #define _DEVDISR_RMU MPC86xx_DEVDISR_RMSG |
| 46 | #define CONFIG_SYS_MPC8xxx_GUTS_ADDR \ |
| 47 | (&((immap_t *)CONFIG_SYS_IMMR)->im_gur) |
| 48 | #else |
| 49 | #error "No defines for DEVDISR_SRIO" |
| 50 | #endif |
| 51 | |
Liu Gang | 712b662 | 2012-09-28 21:26:19 +0000 | [diff] [blame] | 52 | #ifdef CONFIG_SYS_FSL_ERRATUM_SRIO_A004034 |
| 53 | /* |
| 54 | * Erratum A-004034 |
| 55 | * Affects: SRIO |
| 56 | * Description: During port initialization, the SRIO port performs |
| 57 | * lane synchronization (detecting valid symbols on a lane) and |
| 58 | * lane alignment (coordinating multiple lanes to receive valid data |
| 59 | * across lanes). Internal errors in lane synchronization and lane |
| 60 | * alignment may cause failure to achieve link initialization at |
| 61 | * the configured port width. |
| 62 | * An SRIO port configured as a 4x port may see one of these scenarios: |
| 63 | * 1. One or more lanes fails to achieve lane synchronization. Depending |
| 64 | * on which lanes fail, this may result in downtraining from 4x to 1x |
| 65 | * on lane 0, 4x to 1x on lane R (redundant lane). |
| 66 | * 2. The link may fail to achieve lane alignment as a 4x, even though |
| 67 | * all 4 lanes achieve lane synchronization, and downtrain to a 1x. |
| 68 | * An SRIO port configured as a 1x port may fail to complete port |
| 69 | * initialization (PnESCSR[PU] never deasserts) because of scenario 1. |
| 70 | * Impact: SRIO port may downtrain to 1x, or may fail to complete |
| 71 | * link initialization. Once a port completes link initialization |
| 72 | * successfully, it will operate normally. |
| 73 | */ |
| 74 | static int srio_erratum_a004034(u8 port) |
| 75 | { |
| 76 | serdes_corenet_t *srds_regs; |
| 77 | u32 conf_lane; |
| 78 | u32 init_lane; |
| 79 | int idx, first, last; |
| 80 | u32 i; |
| 81 | unsigned long long end_tick; |
| 82 | struct ccsr_rio *srio_regs = (void *)CONFIG_SYS_FSL_SRIO_ADDR; |
| 83 | |
| 84 | srds_regs = (void *)(CONFIG_SYS_FSL_CORENET_SERDES_ADDR); |
| 85 | conf_lane = (in_be32((void *)&srds_regs->srdspccr0) |
| 86 | >> (12 - port * 4)) & 0x3; |
| 87 | init_lane = (in_be32((void *)&srio_regs->lp_serial |
| 88 | .port[port].pccsr) >> 27) & 0x7; |
| 89 | |
| 90 | /* |
| 91 | * Start a counter set to ~2 ms after the SERDES reset is |
| 92 | * complete (SERDES SRDSBnRSTCTL[RST_DONE]=1 for n |
| 93 | * corresponding to the SERDES bank/PLL for the SRIO port). |
| 94 | */ |
| 95 | if (in_be32((void *)&srds_regs->bank[0].rstctl) |
| 96 | & SRDS_RSTCTL_RSTDONE) { |
| 97 | /* |
| 98 | * Poll the port uninitialized status (SRIO PnESCSR[PO]) until |
| 99 | * PO=1 or the counter expires. If the counter expires, the |
| 100 | * port has failed initialization: go to recover steps. If PO=1 |
| 101 | * and the desired port width is 1x, go to normal steps. If |
| 102 | * PO = 1 and the desired port width is 4x, go to recover steps. |
| 103 | */ |
| 104 | end_tick = usec2ticks(2000) + get_ticks(); |
| 105 | do { |
| 106 | if (in_be32((void *)&srio_regs->lp_serial |
| 107 | .port[port].pescsr) & 0x2) { |
| 108 | if (conf_lane == 0x1) |
| 109 | goto host_ok; |
| 110 | else { |
| 111 | if (init_lane == 0x2) |
| 112 | goto host_ok; |
| 113 | else |
| 114 | break; |
| 115 | } |
| 116 | } |
| 117 | } while (end_tick > get_ticks()); |
| 118 | |
| 119 | /* recover at most 3 times */ |
| 120 | for (i = 0; i < 3; i++) { |
| 121 | /* Set SRIO PnCCSR[PD]=1 */ |
| 122 | setbits_be32((void *)&srio_regs->lp_serial |
| 123 | .port[port].pccsr, |
| 124 | 0x800000); |
| 125 | /* |
| 126 | * Set SRIO PnPCR[OBDEN] on the host to |
| 127 | * enable the discarding of any pending packets. |
| 128 | */ |
| 129 | setbits_be32((void *)&srio_regs->impl.port[port].pcr, |
| 130 | 0x04); |
| 131 | /* Wait 50 us */ |
| 132 | udelay(50); |
| 133 | /* Run sync command */ |
| 134 | isync(); |
| 135 | |
| 136 | if (port) |
| 137 | first = serdes_get_first_lane(SRIO2); |
| 138 | else |
| 139 | first = serdes_get_first_lane(SRIO1); |
| 140 | if (unlikely(first < 0)) |
| 141 | return -ENODEV; |
| 142 | if (conf_lane == 0x1) |
| 143 | last = first; |
| 144 | else |
| 145 | last = first + 3; |
| 146 | /* |
| 147 | * Set SERDES BnGCRm0[RRST]=0 for each SRIO |
| 148 | * bank n and lane m. |
| 149 | */ |
| 150 | for (idx = first; idx <= last; idx++) |
| 151 | clrbits_be32(&srds_regs->lane[idx].gcr0, |
| 152 | SRDS_GCR0_RRST); |
| 153 | /* |
| 154 | * Read SERDES BnGCRm0 for each SRIO |
| 155 | * bank n and lane m |
| 156 | */ |
| 157 | for (idx = first; idx <= last; idx++) |
| 158 | in_be32(&srds_regs->lane[idx].gcr0); |
| 159 | /* Run sync command */ |
| 160 | isync(); |
| 161 | /* Wait >= 100 ns */ |
| 162 | udelay(1); |
| 163 | /* |
| 164 | * Set SERDES BnGCRm0[RRST]=1 for each SRIO |
| 165 | * bank n and lane m. |
| 166 | */ |
| 167 | for (idx = first; idx <= last; idx++) |
| 168 | setbits_be32(&srds_regs->lane[idx].gcr0, |
| 169 | SRDS_GCR0_RRST); |
| 170 | /* |
| 171 | * Read SERDES BnGCRm0 for each SRIO |
| 172 | * bank n and lane m |
| 173 | */ |
| 174 | for (idx = first; idx <= last; idx++) |
| 175 | in_be32(&srds_regs->lane[idx].gcr0); |
| 176 | /* Run sync command */ |
| 177 | isync(); |
| 178 | /* Wait >= 300 ns */ |
| 179 | udelay(1); |
| 180 | |
| 181 | /* Write 1 to clear all bits in SRIO PnSLCSR */ |
| 182 | out_be32((void *)&srio_regs->impl.port[port].slcsr, |
| 183 | 0xffffffff); |
| 184 | /* Clear SRIO PnPCR[OBDEN] on the host */ |
| 185 | clrbits_be32((void *)&srio_regs->impl.port[port].pcr, |
| 186 | 0x04); |
| 187 | /* Set SRIO PnCCSR[PD]=0 */ |
| 188 | clrbits_be32((void *)&srio_regs->lp_serial |
| 189 | .port[port].pccsr, |
| 190 | 0x800000); |
| 191 | /* Wait >= 24 ms */ |
| 192 | udelay(24000); |
| 193 | /* Poll the state of the port again */ |
| 194 | init_lane = |
| 195 | (in_be32((void *)&srio_regs->lp_serial |
| 196 | .port[port].pccsr) >> 27) & 0x7; |
| 197 | if (in_be32((void *)&srio_regs->lp_serial |
| 198 | .port[port].pescsr) & 0x2) { |
| 199 | if (conf_lane == 0x1) |
| 200 | goto host_ok; |
| 201 | else { |
| 202 | if (init_lane == 0x2) |
| 203 | goto host_ok; |
| 204 | } |
| 205 | } |
| 206 | if (i == 2) |
| 207 | return -ENODEV; |
| 208 | } |
| 209 | } else |
| 210 | return -ENODEV; |
| 211 | |
| 212 | host_ok: |
| 213 | /* Poll PnESCSR[OES] on the host until it is clear */ |
| 214 | end_tick = usec2ticks(1000000) + get_ticks(); |
| 215 | do { |
| 216 | if (!(in_be32((void *)&srio_regs->lp_serial.port[port].pescsr) |
| 217 | & 0x10000)) { |
| 218 | out_be32(((void *)&srio_regs->lp_serial |
| 219 | .port[port].pescsr), 0xffffffff); |
| 220 | out_be32(((void *)&srio_regs->phys_err |
| 221 | .port[port].edcsr), 0); |
| 222 | out_be32(((void *)&srio_regs->logical_err.ltledcsr), 0); |
| 223 | return 0; |
| 224 | } |
| 225 | } while (end_tick > get_ticks()); |
| 226 | |
| 227 | return -ENODEV; |
| 228 | } |
| 229 | #endif |
| 230 | |
Kumar Gala | 8975d7a | 2010-12-30 12:09:53 -0600 | [diff] [blame] | 231 | void srio_init(void) |
| 232 | { |
| 233 | ccsr_gur_t *gur = (void *)CONFIG_SYS_MPC8xxx_GUTS_ADDR; |
| 234 | int srio1_used = 0, srio2_used = 0; |
York Sun | 9941a22 | 2012-10-08 07:44:19 +0000 | [diff] [blame] | 235 | u32 *devdisr; |
Kumar Gala | 8975d7a | 2010-12-30 12:09:53 -0600 | [diff] [blame] | 236 | |
York Sun | 9941a22 | 2012-10-08 07:44:19 +0000 | [diff] [blame] | 237 | #ifdef CONFIG_SYS_FSL_QORIQ_CHASSIS2 |
| 238 | devdisr = &gur->devdisr3; |
| 239 | #else |
| 240 | devdisr = &gur->devdisr; |
| 241 | #endif |
Kumar Gala | 8975d7a | 2010-12-30 12:09:53 -0600 | [diff] [blame] | 242 | if (is_serdes_configured(SRIO1)) { |
| 243 | set_next_law(CONFIG_SYS_SRIO1_MEM_PHYS, |
| 244 | law_size_bits(CONFIG_SYS_SRIO1_MEM_SIZE), |
| 245 | LAW_TRGT_IF_RIO_1); |
| 246 | srio1_used = 1; |
Liu Gang | 712b662 | 2012-09-28 21:26:19 +0000 | [diff] [blame] | 247 | #ifdef CONFIG_SYS_FSL_ERRATUM_SRIO_A004034 |
| 248 | if (srio_erratum_a004034(0) < 0) |
| 249 | printf("SRIO1: enabled but port error\n"); |
| 250 | else |
| 251 | #endif |
Kumar Gala | 8975d7a | 2010-12-30 12:09:53 -0600 | [diff] [blame] | 252 | printf("SRIO1: enabled\n"); |
| 253 | } else { |
| 254 | printf("SRIO1: disabled\n"); |
| 255 | } |
| 256 | |
| 257 | #ifdef CONFIG_SRIO2 |
| 258 | if (is_serdes_configured(SRIO2)) { |
| 259 | set_next_law(CONFIG_SYS_SRIO2_MEM_PHYS, |
| 260 | law_size_bits(CONFIG_SYS_SRIO2_MEM_SIZE), |
| 261 | LAW_TRGT_IF_RIO_2); |
| 262 | srio2_used = 1; |
Liu Gang | 712b662 | 2012-09-28 21:26:19 +0000 | [diff] [blame] | 263 | #ifdef CONFIG_SYS_FSL_ERRATUM_SRIO_A004034 |
| 264 | if (srio_erratum_a004034(1) < 0) |
| 265 | printf("SRIO2: enabled but port error\n"); |
| 266 | else |
| 267 | #endif |
Kumar Gala | 8975d7a | 2010-12-30 12:09:53 -0600 | [diff] [blame] | 268 | printf("SRIO2: enabled\n"); |
Liu Gang | 712b662 | 2012-09-28 21:26:19 +0000 | [diff] [blame] | 269 | |
Kumar Gala | 8975d7a | 2010-12-30 12:09:53 -0600 | [diff] [blame] | 270 | } else { |
| 271 | printf("SRIO2: disabled\n"); |
| 272 | } |
| 273 | #endif |
| 274 | |
| 275 | #ifdef CONFIG_FSL_CORENET |
| 276 | /* On FSL_CORENET devices we can disable individual ports */ |
| 277 | if (!srio1_used) |
York Sun | 9941a22 | 2012-10-08 07:44:19 +0000 | [diff] [blame] | 278 | setbits_be32(devdisr, _DEVDISR_SRIO1); |
Kumar Gala | 8975d7a | 2010-12-30 12:09:53 -0600 | [diff] [blame] | 279 | if (!srio2_used) |
York Sun | 9941a22 | 2012-10-08 07:44:19 +0000 | [diff] [blame] | 280 | setbits_be32(devdisr, _DEVDISR_SRIO2); |
Kumar Gala | 8975d7a | 2010-12-30 12:09:53 -0600 | [diff] [blame] | 281 | #endif |
| 282 | |
| 283 | /* neither port is used - disable everything */ |
| 284 | if (!srio1_used && !srio2_used) { |
York Sun | 9941a22 | 2012-10-08 07:44:19 +0000 | [diff] [blame] | 285 | setbits_be32(devdisr, _DEVDISR_SRIO1); |
| 286 | setbits_be32(devdisr, _DEVDISR_SRIO2); |
| 287 | setbits_be32(devdisr, _DEVDISR_RMU); |
Kumar Gala | 8975d7a | 2010-12-30 12:09:53 -0600 | [diff] [blame] | 288 | } |
| 289 | } |
Liu Gang | 4cc8532 | 2012-03-08 00:33:17 +0000 | [diff] [blame] | 290 | |
Liu Gang | 27afb9c | 2013-05-07 16:30:46 +0800 | [diff] [blame] | 291 | #ifdef CONFIG_SRIO_PCIE_BOOT_MASTER |
Liu Gang | d7b17a9 | 2012-08-09 05:09:59 +0000 | [diff] [blame] | 292 | void srio_boot_master(int port) |
Liu Gang | 4cc8532 | 2012-03-08 00:33:17 +0000 | [diff] [blame] | 293 | { |
| 294 | struct ccsr_rio *srio = (void *)CONFIG_SYS_FSL_SRIO_ADDR; |
| 295 | |
| 296 | /* set port accept-all */ |
Liu Gang | d7b17a9 | 2012-08-09 05:09:59 +0000 | [diff] [blame] | 297 | out_be32((void *)&srio->impl.port[port - 1].ptaacr, |
Liu Gang | 4cc8532 | 2012-03-08 00:33:17 +0000 | [diff] [blame] | 298 | SRIO_PORT_ACCEPT_ALL); |
| 299 | |
Liu Gang | d7b17a9 | 2012-08-09 05:09:59 +0000 | [diff] [blame] | 300 | debug("SRIOBOOT - MASTER: Master port [ %d ] for srio boot.\n", port); |
Liu Gang | 58f030c | 2012-03-08 00:33:19 +0000 | [diff] [blame] | 301 | /* configure inbound window for slave's u-boot image */ |
| 302 | debug("SRIOBOOT - MASTER: Inbound window for slave's image; " |
Liu Gang | 4cc8532 | 2012-03-08 00:33:17 +0000 | [diff] [blame] | 303 | "Local = 0x%llx, Srio = 0x%llx, Size = 0x%x\n", |
Liu Gang | 99e0c29 | 2012-08-09 05:10:02 +0000 | [diff] [blame] | 304 | (u64)CONFIG_SRIO_PCIE_BOOT_IMAGE_MEM_PHYS, |
| 305 | (u64)CONFIG_SRIO_PCIE_BOOT_IMAGE_MEM_BUS1, |
| 306 | CONFIG_SRIO_PCIE_BOOT_IMAGE_SIZE); |
Liu Gang | d7b17a9 | 2012-08-09 05:09:59 +0000 | [diff] [blame] | 307 | out_be32((void *)&srio->atmu.port[port - 1].inbw[0].riwtar, |
Liu Gang | 99e0c29 | 2012-08-09 05:10:02 +0000 | [diff] [blame] | 308 | CONFIG_SRIO_PCIE_BOOT_IMAGE_MEM_PHYS >> 12); |
Liu Gang | d7b17a9 | 2012-08-09 05:09:59 +0000 | [diff] [blame] | 309 | out_be32((void *)&srio->atmu.port[port - 1].inbw[0].riwbar, |
Liu Gang | 99e0c29 | 2012-08-09 05:10:02 +0000 | [diff] [blame] | 310 | CONFIG_SRIO_PCIE_BOOT_IMAGE_MEM_BUS1 >> 12); |
Liu Gang | d7b17a9 | 2012-08-09 05:09:59 +0000 | [diff] [blame] | 311 | out_be32((void *)&srio->atmu.port[port - 1].inbw[0].riwar, |
Liu Gang | 4cc8532 | 2012-03-08 00:33:17 +0000 | [diff] [blame] | 312 | SRIO_IB_ATMU_AR |
Liu Gang | 99e0c29 | 2012-08-09 05:10:02 +0000 | [diff] [blame] | 313 | | atmu_size_mask(CONFIG_SRIO_PCIE_BOOT_IMAGE_SIZE)); |
Liu Gang | 4cc8532 | 2012-03-08 00:33:17 +0000 | [diff] [blame] | 314 | |
Liu Gang | 58f030c | 2012-03-08 00:33:19 +0000 | [diff] [blame] | 315 | /* configure inbound window for slave's u-boot image */ |
| 316 | debug("SRIOBOOT - MASTER: Inbound window for slave's image; " |
Liu Gang | 4cc8532 | 2012-03-08 00:33:17 +0000 | [diff] [blame] | 317 | "Local = 0x%llx, Srio = 0x%llx, Size = 0x%x\n", |
Liu Gang | 99e0c29 | 2012-08-09 05:10:02 +0000 | [diff] [blame] | 318 | (u64)CONFIG_SRIO_PCIE_BOOT_IMAGE_MEM_PHYS, |
| 319 | (u64)CONFIG_SRIO_PCIE_BOOT_IMAGE_MEM_BUS2, |
| 320 | CONFIG_SRIO_PCIE_BOOT_IMAGE_SIZE); |
Liu Gang | d7b17a9 | 2012-08-09 05:09:59 +0000 | [diff] [blame] | 321 | out_be32((void *)&srio->atmu.port[port - 1].inbw[1].riwtar, |
Liu Gang | 99e0c29 | 2012-08-09 05:10:02 +0000 | [diff] [blame] | 322 | CONFIG_SRIO_PCIE_BOOT_IMAGE_MEM_PHYS >> 12); |
Liu Gang | d7b17a9 | 2012-08-09 05:09:59 +0000 | [diff] [blame] | 323 | out_be32((void *)&srio->atmu.port[port - 1].inbw[1].riwbar, |
Liu Gang | 99e0c29 | 2012-08-09 05:10:02 +0000 | [diff] [blame] | 324 | CONFIG_SRIO_PCIE_BOOT_IMAGE_MEM_BUS2 >> 12); |
Liu Gang | d7b17a9 | 2012-08-09 05:09:59 +0000 | [diff] [blame] | 325 | out_be32((void *)&srio->atmu.port[port - 1].inbw[1].riwar, |
Liu Gang | 4cc8532 | 2012-03-08 00:33:17 +0000 | [diff] [blame] | 326 | SRIO_IB_ATMU_AR |
Liu Gang | 99e0c29 | 2012-08-09 05:10:02 +0000 | [diff] [blame] | 327 | | atmu_size_mask(CONFIG_SRIO_PCIE_BOOT_IMAGE_SIZE)); |
Liu Gang | 58f030c | 2012-03-08 00:33:19 +0000 | [diff] [blame] | 328 | |
Liu Gang | d7b17a9 | 2012-08-09 05:09:59 +0000 | [diff] [blame] | 329 | /* configure inbound window for slave's ucode and ENV */ |
| 330 | debug("SRIOBOOT - MASTER: Inbound window for slave's ucode and ENV; " |
Liu Gang | 58f030c | 2012-03-08 00:33:19 +0000 | [diff] [blame] | 331 | "Local = 0x%llx, Srio = 0x%llx, Size = 0x%x\n", |
Liu Gang | 99e0c29 | 2012-08-09 05:10:02 +0000 | [diff] [blame] | 332 | (u64)CONFIG_SRIO_PCIE_BOOT_UCODE_ENV_MEM_PHYS, |
| 333 | (u64)CONFIG_SRIO_PCIE_BOOT_UCODE_ENV_MEM_BUS, |
| 334 | CONFIG_SRIO_PCIE_BOOT_UCODE_ENV_SIZE); |
Liu Gang | d7b17a9 | 2012-08-09 05:09:59 +0000 | [diff] [blame] | 335 | out_be32((void *)&srio->atmu.port[port - 1].inbw[2].riwtar, |
Liu Gang | 99e0c29 | 2012-08-09 05:10:02 +0000 | [diff] [blame] | 336 | CONFIG_SRIO_PCIE_BOOT_UCODE_ENV_MEM_PHYS >> 12); |
Liu Gang | d7b17a9 | 2012-08-09 05:09:59 +0000 | [diff] [blame] | 337 | out_be32((void *)&srio->atmu.port[port - 1].inbw[2].riwbar, |
Liu Gang | 99e0c29 | 2012-08-09 05:10:02 +0000 | [diff] [blame] | 338 | CONFIG_SRIO_PCIE_BOOT_UCODE_ENV_MEM_BUS >> 12); |
Liu Gang | d7b17a9 | 2012-08-09 05:09:59 +0000 | [diff] [blame] | 339 | out_be32((void *)&srio->atmu.port[port - 1].inbw[2].riwar, |
Liu Gang | 58f030c | 2012-03-08 00:33:19 +0000 | [diff] [blame] | 340 | SRIO_IB_ATMU_AR |
Liu Gang | 99e0c29 | 2012-08-09 05:10:02 +0000 | [diff] [blame] | 341 | | atmu_size_mask(CONFIG_SRIO_PCIE_BOOT_UCODE_ENV_SIZE)); |
Liu Gang | 4cc8532 | 2012-03-08 00:33:17 +0000 | [diff] [blame] | 342 | } |
Liu Gang | f420aa9 | 2012-03-08 00:33:21 +0000 | [diff] [blame] | 343 | |
Liu Gang | d7b17a9 | 2012-08-09 05:09:59 +0000 | [diff] [blame] | 344 | void srio_boot_master_release_slave(int port) |
Liu Gang | f420aa9 | 2012-03-08 00:33:21 +0000 | [diff] [blame] | 345 | { |
| 346 | struct ccsr_rio *srio = (void *)CONFIG_SYS_FSL_SRIO_ADDR; |
| 347 | u32 escsr; |
| 348 | debug("SRIOBOOT - MASTER: " |
| 349 | "Check the port status and release slave core ...\n"); |
| 350 | |
Liu Gang | d7b17a9 | 2012-08-09 05:09:59 +0000 | [diff] [blame] | 351 | escsr = in_be32((void *)&srio->lp_serial.port[port - 1].pescsr); |
Liu Gang | f420aa9 | 2012-03-08 00:33:21 +0000 | [diff] [blame] | 352 | if (escsr & 0x2) { |
| 353 | if (escsr & 0x10100) { |
| 354 | debug("SRIOBOOT - MASTER: Port [ %d ] is error.\n", |
Liu Gang | d7b17a9 | 2012-08-09 05:09:59 +0000 | [diff] [blame] | 355 | port); |
Liu Gang | f420aa9 | 2012-03-08 00:33:21 +0000 | [diff] [blame] | 356 | } else { |
| 357 | debug("SRIOBOOT - MASTER: " |
Liu Gang | d7b17a9 | 2012-08-09 05:09:59 +0000 | [diff] [blame] | 358 | "Port [ %d ] is ready, now release slave's core ...\n", |
| 359 | port); |
Liu Gang | f420aa9 | 2012-03-08 00:33:21 +0000 | [diff] [blame] | 360 | /* |
| 361 | * configure outbound window |
| 362 | * with maintenance attribute to set slave's LCSBA1CSR |
| 363 | */ |
Liu Gang | d7b17a9 | 2012-08-09 05:09:59 +0000 | [diff] [blame] | 364 | out_be32((void *)&srio->atmu.port[port - 1] |
Liu Gang | f420aa9 | 2012-03-08 00:33:21 +0000 | [diff] [blame] | 365 | .outbw[1].rowtar, 0); |
Liu Gang | d7b17a9 | 2012-08-09 05:09:59 +0000 | [diff] [blame] | 366 | out_be32((void *)&srio->atmu.port[port - 1] |
Liu Gang | f420aa9 | 2012-03-08 00:33:21 +0000 | [diff] [blame] | 367 | .outbw[1].rowtear, 0); |
Liu Gang | d7b17a9 | 2012-08-09 05:09:59 +0000 | [diff] [blame] | 368 | if (port - 1) |
| 369 | out_be32((void *)&srio->atmu.port[port - 1] |
Liu Gang | f420aa9 | 2012-03-08 00:33:21 +0000 | [diff] [blame] | 370 | .outbw[1].rowbar, |
| 371 | CONFIG_SYS_SRIO2_MEM_PHYS >> 12); |
| 372 | else |
Liu Gang | d7b17a9 | 2012-08-09 05:09:59 +0000 | [diff] [blame] | 373 | out_be32((void *)&srio->atmu.port[port - 1] |
Liu Gang | f420aa9 | 2012-03-08 00:33:21 +0000 | [diff] [blame] | 374 | .outbw[1].rowbar, |
| 375 | CONFIG_SYS_SRIO1_MEM_PHYS >> 12); |
Liu Gang | d7b17a9 | 2012-08-09 05:09:59 +0000 | [diff] [blame] | 376 | out_be32((void *)&srio->atmu.port[port - 1] |
Liu Gang | f420aa9 | 2012-03-08 00:33:21 +0000 | [diff] [blame] | 377 | .outbw[1].rowar, |
| 378 | SRIO_OB_ATMU_AR_MAINT |
| 379 | | atmu_size_mask(SRIO_MAINT_WIN_SIZE)); |
| 380 | |
| 381 | /* |
| 382 | * configure outbound window |
| 383 | * with R/W attribute to set slave's BRR |
| 384 | */ |
Liu Gang | d7b17a9 | 2012-08-09 05:09:59 +0000 | [diff] [blame] | 385 | out_be32((void *)&srio->atmu.port[port - 1] |
Liu Gang | f420aa9 | 2012-03-08 00:33:21 +0000 | [diff] [blame] | 386 | .outbw[2].rowtar, |
| 387 | SRIO_LCSBA1CSR >> 9); |
Liu Gang | d7b17a9 | 2012-08-09 05:09:59 +0000 | [diff] [blame] | 388 | out_be32((void *)&srio->atmu.port[port - 1] |
Liu Gang | f420aa9 | 2012-03-08 00:33:21 +0000 | [diff] [blame] | 389 | .outbw[2].rowtear, 0); |
Liu Gang | d7b17a9 | 2012-08-09 05:09:59 +0000 | [diff] [blame] | 390 | if (port - 1) |
| 391 | out_be32((void *)&srio->atmu.port[port - 1] |
Liu Gang | f420aa9 | 2012-03-08 00:33:21 +0000 | [diff] [blame] | 392 | .outbw[2].rowbar, |
| 393 | (CONFIG_SYS_SRIO2_MEM_PHYS |
| 394 | + SRIO_MAINT_WIN_SIZE) >> 12); |
| 395 | else |
Liu Gang | d7b17a9 | 2012-08-09 05:09:59 +0000 | [diff] [blame] | 396 | out_be32((void *)&srio->atmu.port[port - 1] |
Liu Gang | f420aa9 | 2012-03-08 00:33:21 +0000 | [diff] [blame] | 397 | .outbw[2].rowbar, |
| 398 | (CONFIG_SYS_SRIO1_MEM_PHYS |
| 399 | + SRIO_MAINT_WIN_SIZE) >> 12); |
Liu Gang | d7b17a9 | 2012-08-09 05:09:59 +0000 | [diff] [blame] | 400 | out_be32((void *)&srio->atmu.port[port - 1] |
Liu Gang | f420aa9 | 2012-03-08 00:33:21 +0000 | [diff] [blame] | 401 | .outbw[2].rowar, |
| 402 | SRIO_OB_ATMU_AR_RW |
| 403 | | atmu_size_mask(SRIO_RW_WIN_SIZE)); |
| 404 | |
| 405 | /* |
| 406 | * Set the LCSBA1CSR register in slave |
| 407 | * by the maint-outbound window |
| 408 | */ |
Liu Gang | d7b17a9 | 2012-08-09 05:09:59 +0000 | [diff] [blame] | 409 | if (port - 1) { |
Liu Gang | f420aa9 | 2012-03-08 00:33:21 +0000 | [diff] [blame] | 410 | out_be32((void *)CONFIG_SYS_SRIO2_MEM_VIRT |
| 411 | + SRIO_LCSBA1CSR_OFFSET, |
| 412 | SRIO_LCSBA1CSR); |
| 413 | while (in_be32((void *)CONFIG_SYS_SRIO2_MEM_VIRT |
| 414 | + SRIO_LCSBA1CSR_OFFSET) |
| 415 | != SRIO_LCSBA1CSR) |
| 416 | ; |
| 417 | /* |
| 418 | * And then set the BRR register |
| 419 | * to release slave core |
| 420 | */ |
| 421 | out_be32((void *)CONFIG_SYS_SRIO2_MEM_VIRT |
| 422 | + SRIO_MAINT_WIN_SIZE |
Liu Gang | 99e0c29 | 2012-08-09 05:10:02 +0000 | [diff] [blame] | 423 | + CONFIG_SRIO_PCIE_BOOT_BRR_OFFSET, |
| 424 | CONFIG_SRIO_PCIE_BOOT_RELEASE_MASK); |
Liu Gang | f420aa9 | 2012-03-08 00:33:21 +0000 | [diff] [blame] | 425 | } else { |
| 426 | out_be32((void *)CONFIG_SYS_SRIO1_MEM_VIRT |
| 427 | + SRIO_LCSBA1CSR_OFFSET, |
| 428 | SRIO_LCSBA1CSR); |
| 429 | while (in_be32((void *)CONFIG_SYS_SRIO1_MEM_VIRT |
| 430 | + SRIO_LCSBA1CSR_OFFSET) |
| 431 | != SRIO_LCSBA1CSR) |
| 432 | ; |
| 433 | /* |
| 434 | * And then set the BRR register |
| 435 | * to release slave core |
| 436 | */ |
| 437 | out_be32((void *)CONFIG_SYS_SRIO1_MEM_VIRT |
| 438 | + SRIO_MAINT_WIN_SIZE |
Liu Gang | 99e0c29 | 2012-08-09 05:10:02 +0000 | [diff] [blame] | 439 | + CONFIG_SRIO_PCIE_BOOT_BRR_OFFSET, |
| 440 | CONFIG_SRIO_PCIE_BOOT_RELEASE_MASK); |
Liu Gang | f420aa9 | 2012-03-08 00:33:21 +0000 | [diff] [blame] | 441 | } |
| 442 | debug("SRIOBOOT - MASTER: " |
| 443 | "Release slave successfully! Now the slave should start up!\n"); |
| 444 | } |
| 445 | } else |
Liu Gang | d7b17a9 | 2012-08-09 05:09:59 +0000 | [diff] [blame] | 446 | debug("SRIOBOOT - MASTER: Port [ %d ] is not ready.\n", port); |
Liu Gang | f420aa9 | 2012-03-08 00:33:21 +0000 | [diff] [blame] | 447 | } |
| 448 | #endif |