Kumar Gala | a09b9b6 | 2010-12-30 12:09:53 -0600 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2011 Freescale Semiconductor, Inc. |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify it |
| 5 | * under the terms of the GNU General Public License as published by the Free |
| 6 | * Software Foundation; either version 2 of the License, or (at your option) |
| 7 | * any later version. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 17 | * MA 02111-1307 USA |
| 18 | */ |
| 19 | |
| 20 | #include <common.h> |
| 21 | #include <config.h> |
| 22 | #include <asm/fsl_law.h> |
| 23 | #include <asm/fsl_serdes.h> |
Liu Gang | 5ffa88e | 2012-03-08 00:33:17 +0000 | [diff] [blame] | 24 | #include <asm/fsl_srio.h> |
| 25 | |
| 26 | #define SRIO_PORT_ACCEPT_ALL 0x10000001 |
| 27 | #define SRIO_IB_ATMU_AR 0x80f55000 |
Liu Gang | 5056c8e | 2012-03-08 00:33:21 +0000 | [diff] [blame] | 28 | #define SRIO_OB_ATMU_AR_MAINT 0x80077000 |
| 29 | #define SRIO_OB_ATMU_AR_RW 0x80045000 |
| 30 | #define SRIO_LCSBA1CSR_OFFSET 0x5c |
| 31 | #define SRIO_MAINT_WIN_SIZE 0x1000000 /* 16M */ |
| 32 | #define SRIO_RW_WIN_SIZE 0x100000 /* 1M */ |
| 33 | #define SRIO_LCSBA1CSR 0x60000000 |
Kumar Gala | a09b9b6 | 2010-12-30 12:09:53 -0600 | [diff] [blame] | 34 | |
| 35 | #if defined(CONFIG_FSL_CORENET) |
| 36 | #define _DEVDISR_SRIO1 FSL_CORENET_DEVDISR_SRIO1 |
| 37 | #define _DEVDISR_SRIO2 FSL_CORENET_DEVDISR_SRIO2 |
| 38 | #define _DEVDISR_RMU FSL_CORENET_DEVDISR_RMU |
| 39 | #define CONFIG_SYS_MPC8xxx_GUTS_ADDR CONFIG_SYS_MPC85xx_GUTS_ADDR |
| 40 | #elif defined(CONFIG_MPC85xx) |
| 41 | #define _DEVDISR_SRIO1 MPC85xx_DEVDISR_SRIO |
| 42 | #define _DEVDISR_SRIO2 MPC85xx_DEVDISR_SRIO |
| 43 | #define _DEVDISR_RMU MPC85xx_DEVDISR_RMSG |
| 44 | #define CONFIG_SYS_MPC8xxx_GUTS_ADDR CONFIG_SYS_MPC85xx_GUTS_ADDR |
| 45 | #elif defined(CONFIG_MPC86xx) |
| 46 | #define _DEVDISR_SRIO1 MPC86xx_DEVDISR_SRIO |
| 47 | #define _DEVDISR_SRIO2 MPC86xx_DEVDISR_SRIO |
| 48 | #define _DEVDISR_RMU MPC86xx_DEVDISR_RMSG |
| 49 | #define CONFIG_SYS_MPC8xxx_GUTS_ADDR \ |
| 50 | (&((immap_t *)CONFIG_SYS_IMMR)->im_gur) |
| 51 | #else |
| 52 | #error "No defines for DEVDISR_SRIO" |
| 53 | #endif |
| 54 | |
| 55 | void srio_init(void) |
| 56 | { |
| 57 | ccsr_gur_t *gur = (void *)CONFIG_SYS_MPC8xxx_GUTS_ADDR; |
| 58 | int srio1_used = 0, srio2_used = 0; |
| 59 | |
| 60 | if (is_serdes_configured(SRIO1)) { |
| 61 | set_next_law(CONFIG_SYS_SRIO1_MEM_PHYS, |
| 62 | law_size_bits(CONFIG_SYS_SRIO1_MEM_SIZE), |
| 63 | LAW_TRGT_IF_RIO_1); |
| 64 | srio1_used = 1; |
| 65 | printf("SRIO1: enabled\n"); |
| 66 | } else { |
| 67 | printf("SRIO1: disabled\n"); |
| 68 | } |
| 69 | |
| 70 | #ifdef CONFIG_SRIO2 |
| 71 | if (is_serdes_configured(SRIO2)) { |
| 72 | set_next_law(CONFIG_SYS_SRIO2_MEM_PHYS, |
| 73 | law_size_bits(CONFIG_SYS_SRIO2_MEM_SIZE), |
| 74 | LAW_TRGT_IF_RIO_2); |
| 75 | srio2_used = 1; |
| 76 | printf("SRIO2: enabled\n"); |
| 77 | } else { |
| 78 | printf("SRIO2: disabled\n"); |
| 79 | } |
| 80 | #endif |
| 81 | |
| 82 | #ifdef CONFIG_FSL_CORENET |
| 83 | /* On FSL_CORENET devices we can disable individual ports */ |
| 84 | if (!srio1_used) |
| 85 | setbits_be32(&gur->devdisr, FSL_CORENET_DEVDISR_SRIO1); |
| 86 | if (!srio2_used) |
| 87 | setbits_be32(&gur->devdisr, FSL_CORENET_DEVDISR_SRIO2); |
| 88 | #endif |
| 89 | |
| 90 | /* neither port is used - disable everything */ |
| 91 | if (!srio1_used && !srio2_used) { |
| 92 | setbits_be32(&gur->devdisr, _DEVDISR_SRIO1); |
| 93 | setbits_be32(&gur->devdisr, _DEVDISR_SRIO2); |
| 94 | setbits_be32(&gur->devdisr, _DEVDISR_RMU); |
| 95 | } |
| 96 | } |
Liu Gang | 5ffa88e | 2012-03-08 00:33:17 +0000 | [diff] [blame] | 97 | |
Liu Gang | ff65f12 | 2012-08-09 05:09:59 +0000 | [diff] [blame] | 98 | #ifdef CONFIG_FSL_CORENET |
| 99 | void srio_boot_master(int port) |
Liu Gang | 5ffa88e | 2012-03-08 00:33:17 +0000 | [diff] [blame] | 100 | { |
| 101 | struct ccsr_rio *srio = (void *)CONFIG_SYS_FSL_SRIO_ADDR; |
| 102 | |
| 103 | /* set port accept-all */ |
Liu Gang | ff65f12 | 2012-08-09 05:09:59 +0000 | [diff] [blame] | 104 | out_be32((void *)&srio->impl.port[port - 1].ptaacr, |
Liu Gang | 5ffa88e | 2012-03-08 00:33:17 +0000 | [diff] [blame] | 105 | SRIO_PORT_ACCEPT_ALL); |
| 106 | |
Liu Gang | ff65f12 | 2012-08-09 05:09:59 +0000 | [diff] [blame] | 107 | debug("SRIOBOOT - MASTER: Master port [ %d ] for srio boot.\n", port); |
Liu Gang | 3f1af81 | 2012-03-08 00:33:19 +0000 | [diff] [blame] | 108 | /* configure inbound window for slave's u-boot image */ |
| 109 | debug("SRIOBOOT - MASTER: Inbound window for slave's image; " |
Liu Gang | 5ffa88e | 2012-03-08 00:33:17 +0000 | [diff] [blame] | 110 | "Local = 0x%llx, Srio = 0x%llx, Size = 0x%x\n", |
Liu Gang | b5f7c87 | 2012-08-09 05:10:02 +0000 | [diff] [blame^] | 111 | (u64)CONFIG_SRIO_PCIE_BOOT_IMAGE_MEM_PHYS, |
| 112 | (u64)CONFIG_SRIO_PCIE_BOOT_IMAGE_MEM_BUS1, |
| 113 | CONFIG_SRIO_PCIE_BOOT_IMAGE_SIZE); |
Liu Gang | ff65f12 | 2012-08-09 05:09:59 +0000 | [diff] [blame] | 114 | out_be32((void *)&srio->atmu.port[port - 1].inbw[0].riwtar, |
Liu Gang | b5f7c87 | 2012-08-09 05:10:02 +0000 | [diff] [blame^] | 115 | CONFIG_SRIO_PCIE_BOOT_IMAGE_MEM_PHYS >> 12); |
Liu Gang | ff65f12 | 2012-08-09 05:09:59 +0000 | [diff] [blame] | 116 | out_be32((void *)&srio->atmu.port[port - 1].inbw[0].riwbar, |
Liu Gang | b5f7c87 | 2012-08-09 05:10:02 +0000 | [diff] [blame^] | 117 | CONFIG_SRIO_PCIE_BOOT_IMAGE_MEM_BUS1 >> 12); |
Liu Gang | ff65f12 | 2012-08-09 05:09:59 +0000 | [diff] [blame] | 118 | out_be32((void *)&srio->atmu.port[port - 1].inbw[0].riwar, |
Liu Gang | 5ffa88e | 2012-03-08 00:33:17 +0000 | [diff] [blame] | 119 | SRIO_IB_ATMU_AR |
Liu Gang | b5f7c87 | 2012-08-09 05:10:02 +0000 | [diff] [blame^] | 120 | | atmu_size_mask(CONFIG_SRIO_PCIE_BOOT_IMAGE_SIZE)); |
Liu Gang | 5ffa88e | 2012-03-08 00:33:17 +0000 | [diff] [blame] | 121 | |
Liu Gang | 3f1af81 | 2012-03-08 00:33:19 +0000 | [diff] [blame] | 122 | /* configure inbound window for slave's u-boot image */ |
| 123 | debug("SRIOBOOT - MASTER: Inbound window for slave's image; " |
Liu Gang | 5ffa88e | 2012-03-08 00:33:17 +0000 | [diff] [blame] | 124 | "Local = 0x%llx, Srio = 0x%llx, Size = 0x%x\n", |
Liu Gang | b5f7c87 | 2012-08-09 05:10:02 +0000 | [diff] [blame^] | 125 | (u64)CONFIG_SRIO_PCIE_BOOT_IMAGE_MEM_PHYS, |
| 126 | (u64)CONFIG_SRIO_PCIE_BOOT_IMAGE_MEM_BUS2, |
| 127 | CONFIG_SRIO_PCIE_BOOT_IMAGE_SIZE); |
Liu Gang | ff65f12 | 2012-08-09 05:09:59 +0000 | [diff] [blame] | 128 | out_be32((void *)&srio->atmu.port[port - 1].inbw[1].riwtar, |
Liu Gang | b5f7c87 | 2012-08-09 05:10:02 +0000 | [diff] [blame^] | 129 | CONFIG_SRIO_PCIE_BOOT_IMAGE_MEM_PHYS >> 12); |
Liu Gang | ff65f12 | 2012-08-09 05:09:59 +0000 | [diff] [blame] | 130 | out_be32((void *)&srio->atmu.port[port - 1].inbw[1].riwbar, |
Liu Gang | b5f7c87 | 2012-08-09 05:10:02 +0000 | [diff] [blame^] | 131 | CONFIG_SRIO_PCIE_BOOT_IMAGE_MEM_BUS2 >> 12); |
Liu Gang | ff65f12 | 2012-08-09 05:09:59 +0000 | [diff] [blame] | 132 | out_be32((void *)&srio->atmu.port[port - 1].inbw[1].riwar, |
Liu Gang | 5ffa88e | 2012-03-08 00:33:17 +0000 | [diff] [blame] | 133 | SRIO_IB_ATMU_AR |
Liu Gang | b5f7c87 | 2012-08-09 05:10:02 +0000 | [diff] [blame^] | 134 | | atmu_size_mask(CONFIG_SRIO_PCIE_BOOT_IMAGE_SIZE)); |
Liu Gang | 3f1af81 | 2012-03-08 00:33:19 +0000 | [diff] [blame] | 135 | |
Liu Gang | ff65f12 | 2012-08-09 05:09:59 +0000 | [diff] [blame] | 136 | /* configure inbound window for slave's ucode and ENV */ |
| 137 | debug("SRIOBOOT - MASTER: Inbound window for slave's ucode and ENV; " |
Liu Gang | 3f1af81 | 2012-03-08 00:33:19 +0000 | [diff] [blame] | 138 | "Local = 0x%llx, Srio = 0x%llx, Size = 0x%x\n", |
Liu Gang | b5f7c87 | 2012-08-09 05:10:02 +0000 | [diff] [blame^] | 139 | (u64)CONFIG_SRIO_PCIE_BOOT_UCODE_ENV_MEM_PHYS, |
| 140 | (u64)CONFIG_SRIO_PCIE_BOOT_UCODE_ENV_MEM_BUS, |
| 141 | CONFIG_SRIO_PCIE_BOOT_UCODE_ENV_SIZE); |
Liu Gang | ff65f12 | 2012-08-09 05:09:59 +0000 | [diff] [blame] | 142 | out_be32((void *)&srio->atmu.port[port - 1].inbw[2].riwtar, |
Liu Gang | b5f7c87 | 2012-08-09 05:10:02 +0000 | [diff] [blame^] | 143 | CONFIG_SRIO_PCIE_BOOT_UCODE_ENV_MEM_PHYS >> 12); |
Liu Gang | ff65f12 | 2012-08-09 05:09:59 +0000 | [diff] [blame] | 144 | out_be32((void *)&srio->atmu.port[port - 1].inbw[2].riwbar, |
Liu Gang | b5f7c87 | 2012-08-09 05:10:02 +0000 | [diff] [blame^] | 145 | CONFIG_SRIO_PCIE_BOOT_UCODE_ENV_MEM_BUS >> 12); |
Liu Gang | ff65f12 | 2012-08-09 05:09:59 +0000 | [diff] [blame] | 146 | out_be32((void *)&srio->atmu.port[port - 1].inbw[2].riwar, |
Liu Gang | 3f1af81 | 2012-03-08 00:33:19 +0000 | [diff] [blame] | 147 | SRIO_IB_ATMU_AR |
Liu Gang | b5f7c87 | 2012-08-09 05:10:02 +0000 | [diff] [blame^] | 148 | | atmu_size_mask(CONFIG_SRIO_PCIE_BOOT_UCODE_ENV_SIZE)); |
Liu Gang | 5ffa88e | 2012-03-08 00:33:17 +0000 | [diff] [blame] | 149 | } |
Liu Gang | 5056c8e | 2012-03-08 00:33:21 +0000 | [diff] [blame] | 150 | |
Liu Gang | ff65f12 | 2012-08-09 05:09:59 +0000 | [diff] [blame] | 151 | void srio_boot_master_release_slave(int port) |
Liu Gang | 5056c8e | 2012-03-08 00:33:21 +0000 | [diff] [blame] | 152 | { |
| 153 | struct ccsr_rio *srio = (void *)CONFIG_SYS_FSL_SRIO_ADDR; |
| 154 | u32 escsr; |
| 155 | debug("SRIOBOOT - MASTER: " |
| 156 | "Check the port status and release slave core ...\n"); |
| 157 | |
Liu Gang | ff65f12 | 2012-08-09 05:09:59 +0000 | [diff] [blame] | 158 | escsr = in_be32((void *)&srio->lp_serial.port[port - 1].pescsr); |
Liu Gang | 5056c8e | 2012-03-08 00:33:21 +0000 | [diff] [blame] | 159 | if (escsr & 0x2) { |
| 160 | if (escsr & 0x10100) { |
| 161 | debug("SRIOBOOT - MASTER: Port [ %d ] is error.\n", |
Liu Gang | ff65f12 | 2012-08-09 05:09:59 +0000 | [diff] [blame] | 162 | port); |
Liu Gang | 5056c8e | 2012-03-08 00:33:21 +0000 | [diff] [blame] | 163 | } else { |
| 164 | debug("SRIOBOOT - MASTER: " |
Liu Gang | ff65f12 | 2012-08-09 05:09:59 +0000 | [diff] [blame] | 165 | "Port [ %d ] is ready, now release slave's core ...\n", |
| 166 | port); |
Liu Gang | 5056c8e | 2012-03-08 00:33:21 +0000 | [diff] [blame] | 167 | /* |
| 168 | * configure outbound window |
| 169 | * with maintenance attribute to set slave's LCSBA1CSR |
| 170 | */ |
Liu Gang | ff65f12 | 2012-08-09 05:09:59 +0000 | [diff] [blame] | 171 | out_be32((void *)&srio->atmu.port[port - 1] |
Liu Gang | 5056c8e | 2012-03-08 00:33:21 +0000 | [diff] [blame] | 172 | .outbw[1].rowtar, 0); |
Liu Gang | ff65f12 | 2012-08-09 05:09:59 +0000 | [diff] [blame] | 173 | out_be32((void *)&srio->atmu.port[port - 1] |
Liu Gang | 5056c8e | 2012-03-08 00:33:21 +0000 | [diff] [blame] | 174 | .outbw[1].rowtear, 0); |
Liu Gang | ff65f12 | 2012-08-09 05:09:59 +0000 | [diff] [blame] | 175 | if (port - 1) |
| 176 | out_be32((void *)&srio->atmu.port[port - 1] |
Liu Gang | 5056c8e | 2012-03-08 00:33:21 +0000 | [diff] [blame] | 177 | .outbw[1].rowbar, |
| 178 | CONFIG_SYS_SRIO2_MEM_PHYS >> 12); |
| 179 | else |
Liu Gang | ff65f12 | 2012-08-09 05:09:59 +0000 | [diff] [blame] | 180 | out_be32((void *)&srio->atmu.port[port - 1] |
Liu Gang | 5056c8e | 2012-03-08 00:33:21 +0000 | [diff] [blame] | 181 | .outbw[1].rowbar, |
| 182 | CONFIG_SYS_SRIO1_MEM_PHYS >> 12); |
Liu Gang | ff65f12 | 2012-08-09 05:09:59 +0000 | [diff] [blame] | 183 | out_be32((void *)&srio->atmu.port[port - 1] |
Liu Gang | 5056c8e | 2012-03-08 00:33:21 +0000 | [diff] [blame] | 184 | .outbw[1].rowar, |
| 185 | SRIO_OB_ATMU_AR_MAINT |
| 186 | | atmu_size_mask(SRIO_MAINT_WIN_SIZE)); |
| 187 | |
| 188 | /* |
| 189 | * configure outbound window |
| 190 | * with R/W attribute to set slave's BRR |
| 191 | */ |
Liu Gang | ff65f12 | 2012-08-09 05:09:59 +0000 | [diff] [blame] | 192 | out_be32((void *)&srio->atmu.port[port - 1] |
Liu Gang | 5056c8e | 2012-03-08 00:33:21 +0000 | [diff] [blame] | 193 | .outbw[2].rowtar, |
| 194 | SRIO_LCSBA1CSR >> 9); |
Liu Gang | ff65f12 | 2012-08-09 05:09:59 +0000 | [diff] [blame] | 195 | out_be32((void *)&srio->atmu.port[port - 1] |
Liu Gang | 5056c8e | 2012-03-08 00:33:21 +0000 | [diff] [blame] | 196 | .outbw[2].rowtear, 0); |
Liu Gang | ff65f12 | 2012-08-09 05:09:59 +0000 | [diff] [blame] | 197 | if (port - 1) |
| 198 | out_be32((void *)&srio->atmu.port[port - 1] |
Liu Gang | 5056c8e | 2012-03-08 00:33:21 +0000 | [diff] [blame] | 199 | .outbw[2].rowbar, |
| 200 | (CONFIG_SYS_SRIO2_MEM_PHYS |
| 201 | + SRIO_MAINT_WIN_SIZE) >> 12); |
| 202 | else |
Liu Gang | ff65f12 | 2012-08-09 05:09:59 +0000 | [diff] [blame] | 203 | out_be32((void *)&srio->atmu.port[port - 1] |
Liu Gang | 5056c8e | 2012-03-08 00:33:21 +0000 | [diff] [blame] | 204 | .outbw[2].rowbar, |
| 205 | (CONFIG_SYS_SRIO1_MEM_PHYS |
| 206 | + SRIO_MAINT_WIN_SIZE) >> 12); |
Liu Gang | ff65f12 | 2012-08-09 05:09:59 +0000 | [diff] [blame] | 207 | out_be32((void *)&srio->atmu.port[port - 1] |
Liu Gang | 5056c8e | 2012-03-08 00:33:21 +0000 | [diff] [blame] | 208 | .outbw[2].rowar, |
| 209 | SRIO_OB_ATMU_AR_RW |
| 210 | | atmu_size_mask(SRIO_RW_WIN_SIZE)); |
| 211 | |
| 212 | /* |
| 213 | * Set the LCSBA1CSR register in slave |
| 214 | * by the maint-outbound window |
| 215 | */ |
Liu Gang | ff65f12 | 2012-08-09 05:09:59 +0000 | [diff] [blame] | 216 | if (port - 1) { |
Liu Gang | 5056c8e | 2012-03-08 00:33:21 +0000 | [diff] [blame] | 217 | out_be32((void *)CONFIG_SYS_SRIO2_MEM_VIRT |
| 218 | + SRIO_LCSBA1CSR_OFFSET, |
| 219 | SRIO_LCSBA1CSR); |
| 220 | while (in_be32((void *)CONFIG_SYS_SRIO2_MEM_VIRT |
| 221 | + SRIO_LCSBA1CSR_OFFSET) |
| 222 | != SRIO_LCSBA1CSR) |
| 223 | ; |
| 224 | /* |
| 225 | * And then set the BRR register |
| 226 | * to release slave core |
| 227 | */ |
| 228 | out_be32((void *)CONFIG_SYS_SRIO2_MEM_VIRT |
| 229 | + SRIO_MAINT_WIN_SIZE |
Liu Gang | b5f7c87 | 2012-08-09 05:10:02 +0000 | [diff] [blame^] | 230 | + CONFIG_SRIO_PCIE_BOOT_BRR_OFFSET, |
| 231 | CONFIG_SRIO_PCIE_BOOT_RELEASE_MASK); |
Liu Gang | 5056c8e | 2012-03-08 00:33:21 +0000 | [diff] [blame] | 232 | } else { |
| 233 | out_be32((void *)CONFIG_SYS_SRIO1_MEM_VIRT |
| 234 | + SRIO_LCSBA1CSR_OFFSET, |
| 235 | SRIO_LCSBA1CSR); |
| 236 | while (in_be32((void *)CONFIG_SYS_SRIO1_MEM_VIRT |
| 237 | + SRIO_LCSBA1CSR_OFFSET) |
| 238 | != SRIO_LCSBA1CSR) |
| 239 | ; |
| 240 | /* |
| 241 | * And then set the BRR register |
| 242 | * to release slave core |
| 243 | */ |
| 244 | out_be32((void *)CONFIG_SYS_SRIO1_MEM_VIRT |
| 245 | + SRIO_MAINT_WIN_SIZE |
Liu Gang | b5f7c87 | 2012-08-09 05:10:02 +0000 | [diff] [blame^] | 246 | + CONFIG_SRIO_PCIE_BOOT_BRR_OFFSET, |
| 247 | CONFIG_SRIO_PCIE_BOOT_RELEASE_MASK); |
Liu Gang | 5056c8e | 2012-03-08 00:33:21 +0000 | [diff] [blame] | 248 | } |
| 249 | debug("SRIOBOOT - MASTER: " |
| 250 | "Release slave successfully! Now the slave should start up!\n"); |
| 251 | } |
| 252 | } else |
Liu Gang | ff65f12 | 2012-08-09 05:09:59 +0000 | [diff] [blame] | 253 | debug("SRIOBOOT - MASTER: Port [ %d ] is not ready.\n", port); |
Liu Gang | 5056c8e | 2012-03-08 00:33:21 +0000 | [diff] [blame] | 254 | } |
| 255 | #endif |