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