Pritesh Raithatha | c88654f | 2017-01-02 20:11:32 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved. |
| 3 | * |
| 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 5 | * copy of this software and associated documentation files (the "Software"), |
| 6 | * to deal in the Software without restriction, including without limitation |
| 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 8 | * and/or sell copies of the Software, and to permit persons to whom the |
| 9 | * Software is furnished to do so, subject to the following conditions: |
| 10 | * |
| 11 | * The above copyright notice and this permission notice shall be included in |
| 12 | * all copies or substantial portions of the Software. |
| 13 | * |
| 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 20 | * DEALINGS IN THE SOFTWARE. |
| 21 | */ |
| 22 | |
| 23 | #include <bl_common.h> |
| 24 | #include <smmu.h> |
| 25 | #include <tegra_def.h> |
| 26 | |
| 27 | /******************************************************************************* |
| 28 | * Array to hold SMMU context for Tegra186 |
| 29 | ******************************************************************************/ |
| 30 | static __attribute__((aligned(16))) smmu_regs_t tegra186_smmu_context[] = { |
| 31 | _START_OF_TABLE_, |
| 32 | mc_make_sid_security_cfg(SCEW), |
| 33 | mc_make_sid_security_cfg(AFIR), |
| 34 | mc_make_sid_security_cfg(NVDISPLAYR1), |
| 35 | mc_make_sid_security_cfg(XUSB_DEVR), |
| 36 | mc_make_sid_security_cfg(VICSRD1), |
| 37 | mc_make_sid_security_cfg(NVENCSWR), |
| 38 | mc_make_sid_security_cfg(TSECSRDB), |
| 39 | mc_make_sid_security_cfg(AXISW), |
| 40 | mc_make_sid_security_cfg(SDMMCWAB), |
| 41 | mc_make_sid_security_cfg(AONDMAW), |
| 42 | mc_make_sid_security_cfg(GPUSWR2), |
| 43 | mc_make_sid_security_cfg(SATAW), |
| 44 | mc_make_sid_security_cfg(UFSHCW), |
| 45 | mc_make_sid_security_cfg(AFIW), |
| 46 | mc_make_sid_security_cfg(SDMMCR), |
| 47 | mc_make_sid_security_cfg(SCEDMAW), |
| 48 | mc_make_sid_security_cfg(UFSHCR), |
| 49 | mc_make_sid_security_cfg(SDMMCWAA), |
| 50 | mc_make_sid_security_cfg(APEDMAW), |
| 51 | mc_make_sid_security_cfg(SESWR), |
| 52 | mc_make_sid_security_cfg(MPCORER), |
| 53 | mc_make_sid_security_cfg(PTCR), |
| 54 | mc_make_sid_security_cfg(BPMPW), |
| 55 | mc_make_sid_security_cfg(ETRW), |
| 56 | mc_make_sid_security_cfg(GPUSRD), |
| 57 | mc_make_sid_security_cfg(VICSWR), |
| 58 | mc_make_sid_security_cfg(SCEDMAR), |
| 59 | mc_make_sid_security_cfg(HDAW), |
| 60 | mc_make_sid_security_cfg(ISPWA), |
| 61 | mc_make_sid_security_cfg(EQOSW), |
| 62 | mc_make_sid_security_cfg(XUSB_HOSTW), |
| 63 | mc_make_sid_security_cfg(TSECSWR), |
| 64 | mc_make_sid_security_cfg(SDMMCRAA), |
| 65 | mc_make_sid_security_cfg(APER), |
| 66 | mc_make_sid_security_cfg(VIW), |
| 67 | mc_make_sid_security_cfg(APEW), |
| 68 | mc_make_sid_security_cfg(AXISR), |
| 69 | mc_make_sid_security_cfg(SDMMCW), |
| 70 | mc_make_sid_security_cfg(BPMPDMAW), |
| 71 | mc_make_sid_security_cfg(ISPRA), |
| 72 | mc_make_sid_security_cfg(NVDECSWR), |
| 73 | mc_make_sid_security_cfg(XUSB_DEVW), |
| 74 | mc_make_sid_security_cfg(NVDECSRD), |
| 75 | mc_make_sid_security_cfg(MPCOREW), |
| 76 | mc_make_sid_security_cfg(NVDISPLAYR), |
| 77 | mc_make_sid_security_cfg(BPMPDMAR), |
| 78 | mc_make_sid_security_cfg(NVJPGSWR), |
| 79 | mc_make_sid_security_cfg(NVDECSRD1), |
| 80 | mc_make_sid_security_cfg(TSECSRD), |
| 81 | mc_make_sid_security_cfg(NVJPGSRD), |
| 82 | mc_make_sid_security_cfg(SDMMCWA), |
| 83 | mc_make_sid_security_cfg(SCER), |
| 84 | mc_make_sid_security_cfg(XUSB_HOSTR), |
| 85 | mc_make_sid_security_cfg(VICSRD), |
| 86 | mc_make_sid_security_cfg(AONDMAR), |
| 87 | mc_make_sid_security_cfg(AONW), |
| 88 | mc_make_sid_security_cfg(SDMMCRA), |
| 89 | mc_make_sid_security_cfg(HOST1XDMAR), |
| 90 | mc_make_sid_security_cfg(EQOSR), |
| 91 | mc_make_sid_security_cfg(SATAR), |
| 92 | mc_make_sid_security_cfg(BPMPR), |
| 93 | mc_make_sid_security_cfg(HDAR), |
| 94 | mc_make_sid_security_cfg(SDMMCRAB), |
| 95 | mc_make_sid_security_cfg(ETRR), |
| 96 | mc_make_sid_security_cfg(AONR), |
| 97 | mc_make_sid_security_cfg(APEDMAR), |
| 98 | mc_make_sid_security_cfg(SESRD), |
| 99 | mc_make_sid_security_cfg(NVENCSRD), |
| 100 | mc_make_sid_security_cfg(GPUSWR), |
| 101 | mc_make_sid_security_cfg(TSECSWRB), |
| 102 | mc_make_sid_security_cfg(ISPWB), |
| 103 | mc_make_sid_security_cfg(GPUSRD2), |
| 104 | mc_make_sid_override_cfg(APER), |
| 105 | mc_make_sid_override_cfg(VICSRD), |
| 106 | mc_make_sid_override_cfg(NVENCSRD), |
| 107 | mc_make_sid_override_cfg(NVJPGSWR), |
| 108 | mc_make_sid_override_cfg(AONW), |
| 109 | mc_make_sid_override_cfg(BPMPR), |
| 110 | mc_make_sid_override_cfg(BPMPW), |
| 111 | mc_make_sid_override_cfg(HDAW), |
| 112 | mc_make_sid_override_cfg(NVDISPLAYR1), |
| 113 | mc_make_sid_override_cfg(APEDMAR), |
| 114 | mc_make_sid_override_cfg(AFIR), |
| 115 | mc_make_sid_override_cfg(AXISR), |
| 116 | mc_make_sid_override_cfg(VICSRD1), |
| 117 | mc_make_sid_override_cfg(TSECSRD), |
| 118 | mc_make_sid_override_cfg(BPMPDMAW), |
| 119 | mc_make_sid_override_cfg(MPCOREW), |
| 120 | mc_make_sid_override_cfg(XUSB_HOSTR), |
| 121 | mc_make_sid_override_cfg(GPUSWR), |
| 122 | mc_make_sid_override_cfg(XUSB_DEVR), |
| 123 | mc_make_sid_override_cfg(UFSHCW), |
| 124 | mc_make_sid_override_cfg(XUSB_HOSTW), |
| 125 | mc_make_sid_override_cfg(SDMMCWAB), |
| 126 | mc_make_sid_override_cfg(SATAW), |
| 127 | mc_make_sid_override_cfg(SCEDMAR), |
| 128 | mc_make_sid_override_cfg(HOST1XDMAR), |
| 129 | mc_make_sid_override_cfg(SDMMCWA), |
| 130 | mc_make_sid_override_cfg(APEDMAW), |
| 131 | mc_make_sid_override_cfg(SESWR), |
| 132 | mc_make_sid_override_cfg(AXISW), |
| 133 | mc_make_sid_override_cfg(AONDMAW), |
| 134 | mc_make_sid_override_cfg(TSECSWRB), |
| 135 | mc_make_sid_override_cfg(MPCORER), |
| 136 | mc_make_sid_override_cfg(ISPWB), |
| 137 | mc_make_sid_override_cfg(AONR), |
| 138 | mc_make_sid_override_cfg(BPMPDMAR), |
| 139 | mc_make_sid_override_cfg(HDAR), |
| 140 | mc_make_sid_override_cfg(SDMMCRA), |
| 141 | mc_make_sid_override_cfg(ETRW), |
| 142 | mc_make_sid_override_cfg(GPUSWR2), |
| 143 | mc_make_sid_override_cfg(EQOSR), |
| 144 | mc_make_sid_override_cfg(TSECSWR), |
| 145 | mc_make_sid_override_cfg(ETRR), |
| 146 | mc_make_sid_override_cfg(NVDECSRD), |
| 147 | mc_make_sid_override_cfg(TSECSRDB), |
| 148 | mc_make_sid_override_cfg(SDMMCRAA), |
| 149 | mc_make_sid_override_cfg(NVDECSRD1), |
| 150 | mc_make_sid_override_cfg(SDMMCR), |
| 151 | mc_make_sid_override_cfg(NVJPGSRD), |
| 152 | mc_make_sid_override_cfg(SCEDMAW), |
| 153 | mc_make_sid_override_cfg(SDMMCWAA), |
| 154 | mc_make_sid_override_cfg(APEW), |
| 155 | mc_make_sid_override_cfg(AONDMAR), |
| 156 | mc_make_sid_override_cfg(PTCR), |
| 157 | mc_make_sid_override_cfg(SCER), |
| 158 | mc_make_sid_override_cfg(ISPRA), |
| 159 | mc_make_sid_override_cfg(ISPWA), |
| 160 | mc_make_sid_override_cfg(VICSWR), |
| 161 | mc_make_sid_override_cfg(SESRD), |
| 162 | mc_make_sid_override_cfg(SDMMCW), |
| 163 | mc_make_sid_override_cfg(SDMMCRAB), |
| 164 | mc_make_sid_override_cfg(EQOSW), |
| 165 | mc_make_sid_override_cfg(GPUSRD2), |
| 166 | mc_make_sid_override_cfg(SCEW), |
| 167 | mc_make_sid_override_cfg(GPUSRD), |
| 168 | mc_make_sid_override_cfg(NVDECSWR), |
| 169 | mc_make_sid_override_cfg(XUSB_DEVW), |
| 170 | mc_make_sid_override_cfg(SATAR), |
| 171 | mc_make_sid_override_cfg(NVDISPLAYR), |
| 172 | mc_make_sid_override_cfg(VIW), |
| 173 | mc_make_sid_override_cfg(UFSHCR), |
| 174 | mc_make_sid_override_cfg(NVENCSWR), |
| 175 | mc_make_sid_override_cfg(AFIW), |
| 176 | smmu_make_gnsr0_nsec_cfg(CR0), |
| 177 | smmu_make_gnsr0_sec_cfg(IDR0), |
| 178 | smmu_make_gnsr0_sec_cfg(IDR1), |
| 179 | smmu_make_gnsr0_sec_cfg(IDR2), |
| 180 | smmu_make_gnsr0_nsec_cfg(GFSR), |
| 181 | smmu_make_gnsr0_nsec_cfg(GFSYNR0), |
| 182 | smmu_make_gnsr0_nsec_cfg(GFSYNR1), |
| 183 | smmu_make_gnsr0_nsec_cfg(TLBGSTATUS), |
| 184 | smmu_make_gnsr0_nsec_cfg(PIDR2), |
| 185 | smmu_make_smrg_group(0), |
| 186 | smmu_make_smrg_group(1), |
| 187 | smmu_make_smrg_group(2), |
| 188 | smmu_make_smrg_group(3), |
| 189 | smmu_make_smrg_group(4), |
| 190 | smmu_make_smrg_group(5), |
| 191 | smmu_make_smrg_group(6), |
| 192 | smmu_make_smrg_group(7), |
| 193 | smmu_make_smrg_group(8), |
| 194 | smmu_make_smrg_group(9), |
| 195 | smmu_make_smrg_group(10), |
| 196 | smmu_make_smrg_group(11), |
| 197 | smmu_make_smrg_group(12), |
| 198 | smmu_make_smrg_group(13), |
| 199 | smmu_make_smrg_group(14), |
| 200 | smmu_make_smrg_group(15), |
| 201 | smmu_make_smrg_group(16), |
| 202 | smmu_make_smrg_group(17), |
| 203 | smmu_make_smrg_group(18), |
| 204 | smmu_make_smrg_group(19), |
| 205 | smmu_make_smrg_group(20), |
| 206 | smmu_make_smrg_group(21), |
| 207 | smmu_make_smrg_group(22), |
| 208 | smmu_make_smrg_group(23), |
| 209 | smmu_make_smrg_group(24), |
| 210 | smmu_make_smrg_group(25), |
| 211 | smmu_make_smrg_group(26), |
| 212 | smmu_make_smrg_group(27), |
| 213 | smmu_make_smrg_group(28), |
| 214 | smmu_make_smrg_group(29), |
| 215 | smmu_make_smrg_group(30), |
| 216 | smmu_make_smrg_group(31), |
| 217 | smmu_make_smrg_group(32), |
| 218 | smmu_make_smrg_group(33), |
| 219 | smmu_make_smrg_group(34), |
| 220 | smmu_make_smrg_group(35), |
| 221 | smmu_make_smrg_group(36), |
| 222 | smmu_make_smrg_group(37), |
| 223 | smmu_make_smrg_group(38), |
| 224 | smmu_make_smrg_group(39), |
| 225 | smmu_make_smrg_group(40), |
| 226 | smmu_make_smrg_group(41), |
| 227 | smmu_make_smrg_group(42), |
| 228 | smmu_make_smrg_group(43), |
| 229 | smmu_make_smrg_group(44), |
| 230 | smmu_make_smrg_group(45), |
| 231 | smmu_make_smrg_group(46), |
| 232 | smmu_make_smrg_group(47), |
| 233 | smmu_make_smrg_group(48), |
| 234 | smmu_make_smrg_group(49), |
| 235 | smmu_make_smrg_group(50), |
| 236 | smmu_make_smrg_group(51), |
| 237 | smmu_make_smrg_group(52), |
| 238 | smmu_make_smrg_group(53), |
| 239 | smmu_make_smrg_group(54), |
| 240 | smmu_make_smrg_group(55), |
| 241 | smmu_make_smrg_group(56), |
| 242 | smmu_make_smrg_group(57), |
| 243 | smmu_make_smrg_group(58), |
| 244 | smmu_make_smrg_group(59), |
| 245 | smmu_make_smrg_group(60), |
| 246 | smmu_make_smrg_group(61), |
| 247 | smmu_make_smrg_group(62), |
| 248 | smmu_make_smrg_group(63), |
| 249 | smmu_make_cb_group(0), |
| 250 | smmu_make_cb_group(1), |
| 251 | smmu_make_cb_group(2), |
| 252 | smmu_make_cb_group(3), |
| 253 | smmu_make_cb_group(4), |
| 254 | smmu_make_cb_group(5), |
| 255 | smmu_make_cb_group(6), |
| 256 | smmu_make_cb_group(7), |
| 257 | smmu_make_cb_group(8), |
| 258 | smmu_make_cb_group(9), |
| 259 | smmu_make_cb_group(10), |
| 260 | smmu_make_cb_group(11), |
| 261 | smmu_make_cb_group(12), |
| 262 | smmu_make_cb_group(13), |
| 263 | smmu_make_cb_group(14), |
| 264 | smmu_make_cb_group(15), |
| 265 | smmu_make_cb_group(16), |
| 266 | smmu_make_cb_group(17), |
| 267 | smmu_make_cb_group(18), |
| 268 | smmu_make_cb_group(19), |
| 269 | smmu_make_cb_group(20), |
| 270 | smmu_make_cb_group(21), |
| 271 | smmu_make_cb_group(22), |
| 272 | smmu_make_cb_group(23), |
| 273 | smmu_make_cb_group(24), |
| 274 | smmu_make_cb_group(25), |
| 275 | smmu_make_cb_group(26), |
| 276 | smmu_make_cb_group(27), |
| 277 | smmu_make_cb_group(28), |
| 278 | smmu_make_cb_group(29), |
| 279 | smmu_make_cb_group(30), |
| 280 | smmu_make_cb_group(31), |
| 281 | smmu_make_cb_group(32), |
| 282 | smmu_make_cb_group(33), |
| 283 | smmu_make_cb_group(34), |
| 284 | smmu_make_cb_group(35), |
| 285 | smmu_make_cb_group(36), |
| 286 | smmu_make_cb_group(37), |
| 287 | smmu_make_cb_group(38), |
| 288 | smmu_make_cb_group(39), |
| 289 | smmu_make_cb_group(40), |
| 290 | smmu_make_cb_group(41), |
| 291 | smmu_make_cb_group(42), |
| 292 | smmu_make_cb_group(43), |
| 293 | smmu_make_cb_group(44), |
| 294 | smmu_make_cb_group(45), |
| 295 | smmu_make_cb_group(46), |
| 296 | smmu_make_cb_group(47), |
| 297 | smmu_make_cb_group(48), |
| 298 | smmu_make_cb_group(49), |
| 299 | smmu_make_cb_group(50), |
| 300 | smmu_make_cb_group(51), |
| 301 | smmu_make_cb_group(52), |
| 302 | smmu_make_cb_group(53), |
| 303 | smmu_make_cb_group(54), |
| 304 | smmu_make_cb_group(55), |
| 305 | smmu_make_cb_group(56), |
| 306 | smmu_make_cb_group(57), |
| 307 | smmu_make_cb_group(58), |
| 308 | smmu_make_cb_group(59), |
| 309 | smmu_make_cb_group(60), |
| 310 | smmu_make_cb_group(61), |
| 311 | smmu_make_cb_group(62), |
| 312 | smmu_make_cb_group(63), |
| 313 | smmu_bypass_cfg, /* TBU settings */ |
| 314 | _END_OF_TABLE_, |
| 315 | }; |
| 316 | |
| 317 | /******************************************************************************* |
| 318 | * Handler to return the pointer to the SMMU's context struct |
| 319 | ******************************************************************************/ |
| 320 | smmu_regs_t *plat_get_smmu_ctx(void) |
| 321 | { |
| 322 | /* index of _END_OF_TABLE_ */ |
| 323 | tegra186_smmu_context[0].val = ARRAY_SIZE(tegra186_smmu_context) - 1; |
| 324 | |
| 325 | return tegra186_smmu_context; |
| 326 | } |