Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Kumar Gala | 95fd2f6 | 2008-01-16 01:13:58 -0600 | [diff] [blame] | 2 | /* |
Poonam Aggrwal | 2ba3ee0 | 2011-01-13 21:39:27 +0530 | [diff] [blame] | 3 | * Copyright 2008-2011 Freescale Semiconductor, Inc. |
Kumar Gala | 95fd2f6 | 2008-01-16 01:13:58 -0600 | [diff] [blame] | 4 | * |
| 5 | * (C) Copyright 2000 |
| 6 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
Kumar Gala | 95fd2f6 | 2008-01-16 01:13:58 -0600 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #include <common.h> |
Simon Glass | 4dcacfc | 2020-05-10 11:40:13 -0600 | [diff] [blame] | 10 | #include <asm/bitops.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 11 | #include <asm/global_data.h> |
Kumar Gala | 6a74ade | 2011-02-03 09:02:13 -0600 | [diff] [blame] | 12 | #include <linux/compiler.h> |
Kumar Gala | 95fd2f6 | 2008-01-16 01:13:58 -0600 | [diff] [blame] | 13 | #include <asm/fsl_law.h> |
| 14 | #include <asm/io.h> |
Fabio Estevam | 1a03a7e | 2015-11-05 12:43:40 -0200 | [diff] [blame] | 15 | #include <linux/log2.h> |
Kumar Gala | 95fd2f6 | 2008-01-16 01:13:58 -0600 | [diff] [blame] | 16 | |
Kumar Gala | 75639e0 | 2008-06-11 00:44:10 -0500 | [diff] [blame] | 17 | DECLARE_GLOBAL_DATA_PTR; |
| 18 | |
Kumar Gala | fe13711 | 2011-01-19 03:05:26 -0600 | [diff] [blame] | 19 | #define FSL_HW_NUM_LAWS CONFIG_SYS_FSL_NUM_LAWS |
Kumar Gala | 95fd2f6 | 2008-01-16 01:13:58 -0600 | [diff] [blame] | 20 | |
Kumar Gala | 65e6c32 | 2009-03-19 02:32:23 -0500 | [diff] [blame] | 21 | #ifdef CONFIG_FSL_CORENET |
Becky Bruce | eb891f0 | 2010-06-17 11:37:23 -0500 | [diff] [blame] | 22 | #define LAW_BASE (CONFIG_SYS_FSL_CORENET_CCM_ADDR) |
| 23 | #define LAWAR_ADDR(x) (&((ccsr_local_t *)LAW_BASE)->law[x].lawar) |
| 24 | #define LAWBARH_ADDR(x) (&((ccsr_local_t *)LAW_BASE)->law[x].lawbarh) |
| 25 | #define LAWBARL_ADDR(x) (&((ccsr_local_t *)LAW_BASE)->law[x].lawbarl) |
| 26 | #define LAWBAR_SHIFT 0 |
| 27 | #else |
| 28 | #define LAW_BASE (CONFIG_SYS_IMMR + 0xc08) |
| 29 | #define LAWAR_ADDR(x) ((u32 *)LAW_BASE + 8 * x + 2) |
| 30 | #define LAWBAR_ADDR(x) ((u32 *)LAW_BASE + 8 * x) |
| 31 | #define LAWBAR_SHIFT 12 |
| 32 | #endif |
Kumar Gala | 65e6c32 | 2009-03-19 02:32:23 -0500 | [diff] [blame] | 33 | |
Kumar Gala | 65e6c32 | 2009-03-19 02:32:23 -0500 | [diff] [blame] | 34 | |
Becky Bruce | eb891f0 | 2010-06-17 11:37:23 -0500 | [diff] [blame] | 35 | static inline phys_addr_t get_law_base_addr(int idx) |
Kumar Gala | 65e6c32 | 2009-03-19 02:32:23 -0500 | [diff] [blame] | 36 | { |
Becky Bruce | eb891f0 | 2010-06-17 11:37:23 -0500 | [diff] [blame] | 37 | #ifdef CONFIG_FSL_CORENET |
| 38 | return (phys_addr_t) |
| 39 | ((u64)in_be32(LAWBARH_ADDR(idx)) << 32) | |
| 40 | in_be32(LAWBARL_ADDR(idx)); |
| 41 | #else |
| 42 | return (phys_addr_t)in_be32(LAWBAR_ADDR(idx)) << LAWBAR_SHIFT; |
| 43 | #endif |
Kumar Gala | 65e6c32 | 2009-03-19 02:32:23 -0500 | [diff] [blame] | 44 | } |
| 45 | |
Becky Bruce | eb891f0 | 2010-06-17 11:37:23 -0500 | [diff] [blame] | 46 | static inline void set_law_base_addr(int idx, phys_addr_t addr) |
Kumar Gala | 65e6c32 | 2009-03-19 02:32:23 -0500 | [diff] [blame] | 47 | { |
Becky Bruce | eb891f0 | 2010-06-17 11:37:23 -0500 | [diff] [blame] | 48 | #ifdef CONFIG_FSL_CORENET |
| 49 | out_be32(LAWBARL_ADDR(idx), addr & 0xffffffff); |
| 50 | out_be32(LAWBARH_ADDR(idx), (u64)addr >> 32); |
Kumar Gala | 65e6c32 | 2009-03-19 02:32:23 -0500 | [diff] [blame] | 51 | #else |
Becky Bruce | eb891f0 | 2010-06-17 11:37:23 -0500 | [diff] [blame] | 52 | out_be32(LAWBAR_ADDR(idx), addr >> LAWBAR_SHIFT); |
| 53 | #endif |
| 54 | } |
| 55 | |
Kumar Gala | 65e6c32 | 2009-03-19 02:32:23 -0500 | [diff] [blame] | 56 | void set_law(u8 idx, phys_addr_t addr, enum law_size sz, enum law_trgt_if id) |
| 57 | { |
Simon Glass | c6622d6 | 2012-12-13 20:48:51 +0000 | [diff] [blame] | 58 | gd->arch.used_laws |= (1 << idx); |
Kumar Gala | 75639e0 | 2008-06-11 00:44:10 -0500 | [diff] [blame] | 59 | |
Becky Bruce | eb891f0 | 2010-06-17 11:37:23 -0500 | [diff] [blame] | 60 | out_be32(LAWAR_ADDR(idx), 0); |
| 61 | set_law_base_addr(idx, addr); |
| 62 | out_be32(LAWAR_ADDR(idx), LAW_EN | ((u32)id << 20) | (u32)sz); |
Kumar Gala | 95fd2f6 | 2008-01-16 01:13:58 -0600 | [diff] [blame] | 63 | |
Timur Tabi | 52fa71f | 2009-09-04 17:05:24 -0500 | [diff] [blame] | 64 | /* Read back so that we sync the writes */ |
Becky Bruce | eb891f0 | 2010-06-17 11:37:23 -0500 | [diff] [blame] | 65 | in_be32(LAWAR_ADDR(idx)); |
Kumar Gala | 95fd2f6 | 2008-01-16 01:13:58 -0600 | [diff] [blame] | 66 | } |
| 67 | |
Kumar Gala | 65e6c32 | 2009-03-19 02:32:23 -0500 | [diff] [blame] | 68 | void disable_law(u8 idx) |
| 69 | { |
Simon Glass | c6622d6 | 2012-12-13 20:48:51 +0000 | [diff] [blame] | 70 | gd->arch.used_laws &= ~(1 << idx); |
Kumar Gala | 65e6c32 | 2009-03-19 02:32:23 -0500 | [diff] [blame] | 71 | |
Becky Bruce | eb891f0 | 2010-06-17 11:37:23 -0500 | [diff] [blame] | 72 | out_be32(LAWAR_ADDR(idx), 0); |
| 73 | set_law_base_addr(idx, 0); |
Kumar Gala | 65e6c32 | 2009-03-19 02:32:23 -0500 | [diff] [blame] | 74 | |
| 75 | /* Read back so that we sync the writes */ |
Becky Bruce | eb891f0 | 2010-06-17 11:37:23 -0500 | [diff] [blame] | 76 | in_be32(LAWAR_ADDR(idx)); |
Kumar Gala | 65e6c32 | 2009-03-19 02:32:23 -0500 | [diff] [blame] | 77 | |
| 78 | return; |
| 79 | } |
| 80 | |
Ying Zhang | ffc86e2 | 2013-08-16 15:16:10 +0800 | [diff] [blame] | 81 | #if !defined(CONFIG_NAND_SPL) && \ |
Tom Rini | 6b15c16 | 2022-05-13 12:26:35 -0400 | [diff] [blame] | 82 | (!defined(CONFIG_SPL_BUILD) || !CONFIG_IS_ENABLED(INIT_MINIMAL)) |
Kumar Gala | 65e6c32 | 2009-03-19 02:32:23 -0500 | [diff] [blame] | 83 | static int get_law_entry(u8 i, struct law_entry *e) |
| 84 | { |
Becky Bruce | eb891f0 | 2010-06-17 11:37:23 -0500 | [diff] [blame] | 85 | u32 lawar; |
Kumar Gala | 65e6c32 | 2009-03-19 02:32:23 -0500 | [diff] [blame] | 86 | |
Becky Bruce | eb891f0 | 2010-06-17 11:37:23 -0500 | [diff] [blame] | 87 | lawar = in_be32(LAWAR_ADDR(i)); |
Kumar Gala | 65e6c32 | 2009-03-19 02:32:23 -0500 | [diff] [blame] | 88 | |
Becky Bruce | eb891f0 | 2010-06-17 11:37:23 -0500 | [diff] [blame] | 89 | if (!(lawar & LAW_EN)) |
Kumar Gala | 65e6c32 | 2009-03-19 02:32:23 -0500 | [diff] [blame] | 90 | return 0; |
| 91 | |
Becky Bruce | eb891f0 | 2010-06-17 11:37:23 -0500 | [diff] [blame] | 92 | e->addr = get_law_base_addr(i); |
| 93 | e->size = lawar & 0x3f; |
| 94 | e->trgt_id = (lawar >> 20) & 0xff; |
Kumar Gala | 65e6c32 | 2009-03-19 02:32:23 -0500 | [diff] [blame] | 95 | |
| 96 | return 1; |
| 97 | } |
| 98 | #endif |
| 99 | |
Kumar Gala | 75639e0 | 2008-06-11 00:44:10 -0500 | [diff] [blame] | 100 | int set_next_law(phys_addr_t addr, enum law_size sz, enum law_trgt_if id) |
| 101 | { |
Simon Glass | c6622d6 | 2012-12-13 20:48:51 +0000 | [diff] [blame] | 102 | u32 idx = ffz(gd->arch.used_laws); |
Kumar Gala | 75639e0 | 2008-06-11 00:44:10 -0500 | [diff] [blame] | 103 | |
| 104 | if (idx >= FSL_HW_NUM_LAWS) |
| 105 | return -1; |
| 106 | |
| 107 | set_law(idx, addr, sz, id); |
| 108 | |
| 109 | return idx; |
| 110 | } |
| 111 | |
Ying Zhang | ffc86e2 | 2013-08-16 15:16:10 +0800 | [diff] [blame] | 112 | #if !defined(CONFIG_NAND_SPL) && \ |
Tom Rini | 6b15c16 | 2022-05-13 12:26:35 -0400 | [diff] [blame] | 113 | (!defined(CONFIG_SPL_BUILD) || !CONFIG_IS_ENABLED(INIT_MINIMAL)) |
Kumar Gala | a9abb00 | 2008-06-10 16:16:02 -0500 | [diff] [blame] | 114 | int set_last_law(phys_addr_t addr, enum law_size sz, enum law_trgt_if id) |
| 115 | { |
| 116 | u32 idx; |
| 117 | |
| 118 | /* we have no LAWs free */ |
Simon Glass | c6622d6 | 2012-12-13 20:48:51 +0000 | [diff] [blame] | 119 | if (gd->arch.used_laws == -1) |
Kumar Gala | a9abb00 | 2008-06-10 16:16:02 -0500 | [diff] [blame] | 120 | return -1; |
| 121 | |
| 122 | /* grab the last free law */ |
Simon Glass | c6622d6 | 2012-12-13 20:48:51 +0000 | [diff] [blame] | 123 | idx = __ilog2(~(gd->arch.used_laws)); |
Kumar Gala | a9abb00 | 2008-06-10 16:16:02 -0500 | [diff] [blame] | 124 | |
| 125 | if (idx >= FSL_HW_NUM_LAWS) |
| 126 | return -1; |
| 127 | |
| 128 | set_law(idx, addr, sz, id); |
| 129 | |
| 130 | return idx; |
| 131 | } |
| 132 | |
Kumar Gala | 65e6c32 | 2009-03-19 02:32:23 -0500 | [diff] [blame] | 133 | struct law_entry find_law(phys_addr_t addr) |
Kumar Gala | 95fd2f6 | 2008-01-16 01:13:58 -0600 | [diff] [blame] | 134 | { |
Kumar Gala | 65e6c32 | 2009-03-19 02:32:23 -0500 | [diff] [blame] | 135 | struct law_entry entry; |
| 136 | int i; |
Kumar Gala | 95fd2f6 | 2008-01-16 01:13:58 -0600 | [diff] [blame] | 137 | |
Kumar Gala | 65e6c32 | 2009-03-19 02:32:23 -0500 | [diff] [blame] | 138 | entry.index = -1; |
| 139 | entry.addr = 0; |
| 140 | entry.size = 0; |
| 141 | entry.trgt_id = 0; |
Kumar Gala | 75639e0 | 2008-06-11 00:44:10 -0500 | [diff] [blame] | 142 | |
Kumar Gala | 65e6c32 | 2009-03-19 02:32:23 -0500 | [diff] [blame] | 143 | for (i = 0; i < FSL_HW_NUM_LAWS; i++) { |
| 144 | u64 upper; |
Kumar Gala | 95fd2f6 | 2008-01-16 01:13:58 -0600 | [diff] [blame] | 145 | |
Kumar Gala | 65e6c32 | 2009-03-19 02:32:23 -0500 | [diff] [blame] | 146 | if (!get_law_entry(i, &entry)) |
| 147 | continue; |
| 148 | |
| 149 | upper = entry.addr + (2ull << entry.size); |
| 150 | if ((addr >= entry.addr) && (addr < upper)) { |
| 151 | entry.index = i; |
| 152 | break; |
| 153 | } |
| 154 | } |
| 155 | |
| 156 | return entry; |
Kumar Gala | 95fd2f6 | 2008-01-16 01:13:58 -0600 | [diff] [blame] | 157 | } |
| 158 | |
Becky Bruce | 2a15f75 | 2008-01-23 16:31:05 -0600 | [diff] [blame] | 159 | void print_laws(void) |
| 160 | { |
Becky Bruce | 2a15f75 | 2008-01-23 16:31:05 -0600 | [diff] [blame] | 161 | int i; |
Becky Bruce | eb891f0 | 2010-06-17 11:37:23 -0500 | [diff] [blame] | 162 | u32 lawar; |
Becky Bruce | 2a15f75 | 2008-01-23 16:31:05 -0600 | [diff] [blame] | 163 | |
| 164 | printf("\nLocal Access Window Configuration\n"); |
Becky Bruce | eb891f0 | 2010-06-17 11:37:23 -0500 | [diff] [blame] | 165 | for (i = 0; i < FSL_HW_NUM_LAWS; i++) { |
| 166 | lawar = in_be32(LAWAR_ADDR(i)); |
Becky Bruce | d58f8d5 | 2010-06-17 11:37:24 -0500 | [diff] [blame] | 167 | #ifdef CONFIG_FSL_CORENET |
| 168 | printf("LAWBARH%02d: 0x%08x LAWBARL%02d: 0x%08x", |
| 169 | i, in_be32(LAWBARH_ADDR(i)), |
| 170 | i, in_be32(LAWBARL_ADDR(i))); |
| 171 | #else |
Becky Bruce | eb891f0 | 2010-06-17 11:37:23 -0500 | [diff] [blame] | 172 | printf("LAWBAR%02d: 0x%08x", i, in_be32(LAWBAR_ADDR(i))); |
Becky Bruce | d58f8d5 | 2010-06-17 11:37:24 -0500 | [diff] [blame] | 173 | #endif |
Kumar Gala | 978bb79 | 2011-02-12 15:34:08 -0600 | [diff] [blame] | 174 | printf(" LAWAR%02d: 0x%08x\n", i, lawar); |
Becky Bruce | eb891f0 | 2010-06-17 11:37:23 -0500 | [diff] [blame] | 175 | printf("\t(EN: %d TGT: 0x%02x SIZE: ", |
| 176 | (lawar & LAW_EN) ? 1 : 0, (lawar >> 20) & 0xff); |
| 177 | print_size(lawar_size(lawar), ")\n"); |
Becky Bruce | 2a15f75 | 2008-01-23 16:31:05 -0600 | [diff] [blame] | 178 | } |
| 179 | |
| 180 | return; |
| 181 | } |
| 182 | |
Kumar Gala | 61ed053 | 2008-08-26 15:01:28 -0500 | [diff] [blame] | 183 | /* use up to 2 LAWs for DDR, used the last available LAWs */ |
| 184 | int set_ddr_laws(u64 start, u64 sz, enum law_trgt_if id) |
| 185 | { |
| 186 | u64 start_align, law_sz; |
| 187 | int law_sz_enc; |
| 188 | |
| 189 | if (start == 0) |
| 190 | start_align = 1ull << (LAW_SIZE_32G + 1); |
| 191 | else |
Ashish kumar | e7d15f6 | 2016-01-22 15:50:10 +0530 | [diff] [blame] | 192 | start_align = 1ull << (__ffs64(start)); |
Kumar Gala | 61ed053 | 2008-08-26 15:01:28 -0500 | [diff] [blame] | 193 | law_sz = min(start_align, sz); |
| 194 | law_sz_enc = __ilog2_u64(law_sz) - 1; |
| 195 | |
| 196 | if (set_last_law(start, law_sz_enc, id) < 0) |
| 197 | return -1; |
| 198 | |
Kumar Gala | 894cc88 | 2009-04-04 10:21:02 -0500 | [diff] [blame] | 199 | /* recalculate size based on what was actually covered by the law */ |
| 200 | law_sz = 1ull << __ilog2_u64(law_sz); |
| 201 | |
Kumar Gala | 61ed053 | 2008-08-26 15:01:28 -0500 | [diff] [blame] | 202 | /* do we still have anything to map */ |
| 203 | sz = sz - law_sz; |
| 204 | if (sz) { |
| 205 | start += law_sz; |
| 206 | |
Ashish kumar | e7d15f6 | 2016-01-22 15:50:10 +0530 | [diff] [blame] | 207 | start_align = 1ull << (__ffs64(start)); |
Kumar Gala | 61ed053 | 2008-08-26 15:01:28 -0500 | [diff] [blame] | 208 | law_sz = min(start_align, sz); |
| 209 | law_sz_enc = __ilog2_u64(law_sz) - 1; |
| 210 | |
| 211 | if (set_last_law(start, law_sz_enc, id) < 0) |
| 212 | return -1; |
| 213 | } else { |
| 214 | return 0; |
| 215 | } |
| 216 | |
| 217 | /* do we still have anything to map */ |
| 218 | sz = sz - law_sz; |
| 219 | if (sz) |
| 220 | return 1; |
| 221 | |
| 222 | return 0; |
| 223 | } |
Scott Wood | 095b712 | 2012-09-20 19:02:18 -0500 | [diff] [blame] | 224 | #endif /* not SPL */ |
Kumar Gala | 61ed053 | 2008-08-26 15:01:28 -0500 | [diff] [blame] | 225 | |
Prabhakar Kushwaha | 21a2590 | 2014-04-08 19:12:46 +0530 | [diff] [blame] | 226 | void disable_non_ddr_laws(void) |
| 227 | { |
| 228 | int i; |
| 229 | int id; |
| 230 | for (i = 0; i < FSL_HW_NUM_LAWS; i++) { |
| 231 | u32 lawar = in_be32(LAWAR_ADDR(i)); |
| 232 | |
| 233 | if (lawar & LAW_EN) { |
| 234 | id = (lawar & ~LAW_EN) >> 20; |
| 235 | switch (id) { |
| 236 | case LAW_TRGT_IF_DDR_1: |
| 237 | case LAW_TRGT_IF_DDR_2: |
| 238 | case LAW_TRGT_IF_DDR_3: |
| 239 | case LAW_TRGT_IF_DDR_4: |
| 240 | case LAW_TRGT_IF_DDR_INTRLV: |
| 241 | case LAW_TRGT_IF_DDR_INTLV_34: |
| 242 | case LAW_TRGT_IF_DDR_INTLV_123: |
| 243 | case LAW_TRGT_IF_DDR_INTLV_1234: |
| 244 | continue; |
| 245 | default: |
| 246 | disable_law(i); |
| 247 | } |
| 248 | } |
| 249 | } |
| 250 | } |
| 251 | |
Kumar Gala | 95fd2f6 | 2008-01-16 01:13:58 -0600 | [diff] [blame] | 252 | void init_laws(void) |
| 253 | { |
| 254 | int i; |
Kumar Gala | 95fd2f6 | 2008-01-16 01:13:58 -0600 | [diff] [blame] | 255 | |
Kumar Gala | 65e6c32 | 2009-03-19 02:32:23 -0500 | [diff] [blame] | 256 | #if FSL_HW_NUM_LAWS < 32 |
Simon Glass | c6622d6 | 2012-12-13 20:48:51 +0000 | [diff] [blame] | 257 | gd->arch.used_laws = ~((1 << FSL_HW_NUM_LAWS) - 1); |
Kumar Gala | 65e6c32 | 2009-03-19 02:32:23 -0500 | [diff] [blame] | 258 | #elif FSL_HW_NUM_LAWS == 32 |
Simon Glass | c6622d6 | 2012-12-13 20:48:51 +0000 | [diff] [blame] | 259 | gd->arch.used_laws = 0; |
Kumar Gala | 65e6c32 | 2009-03-19 02:32:23 -0500 | [diff] [blame] | 260 | #else |
| 261 | #error FSL_HW_NUM_LAWS can not be greater than 32 w/o code changes |
| 262 | #endif |
Kumar Gala | 95fd2f6 | 2008-01-16 01:13:58 -0600 | [diff] [blame] | 263 | |
Udit Agarwal | d2dd2f7 | 2019-11-07 16:11:39 +0000 | [diff] [blame] | 264 | #if defined(CONFIG_NXP_ESBC) && defined(CONFIG_E500) && \ |
Aneesh Bansal | 060384a | 2014-03-11 23:21:45 +0530 | [diff] [blame] | 265 | !defined(CONFIG_E500MC) |
| 266 | /* ISBC (Boot ROM) creates a LAW 0 entry for non PBL platforms, |
| 267 | * which is not disabled before transferring the control to uboot. |
| 268 | * Disable the LAW 0 entry here. |
| 269 | */ |
| 270 | disable_law(0); |
| 271 | #endif |
| 272 | |
Udit Agarwal | d2dd2f7 | 2019-11-07 16:11:39 +0000 | [diff] [blame] | 273 | #if !defined(CONFIG_NXP_ESBC) |
Prabhakar Kushwaha | 21a2590 | 2014-04-08 19:12:46 +0530 | [diff] [blame] | 274 | /* |
| 275 | * if any non DDR LAWs has been created earlier, remove them before |
| 276 | * LAW table is parsed. |
| 277 | */ |
| 278 | disable_non_ddr_laws(); |
| 279 | #endif |
Aneesh Bansal | 060384a | 2014-03-11 23:21:45 +0530 | [diff] [blame] | 280 | |
Wolfgang Denk | 80f7021 | 2011-05-19 22:21:41 +0200 | [diff] [blame] | 281 | /* |
Kumar Gala | 6a74ade | 2011-02-03 09:02:13 -0600 | [diff] [blame] | 282 | * Any LAWs that were set up before we booted assume they are meant to |
| 283 | * be around and mark them used. |
| 284 | */ |
| 285 | for (i = 0; i < FSL_HW_NUM_LAWS; i++) { |
| 286 | u32 lawar = in_be32(LAWAR_ADDR(i)); |
Wolfgang Denk | 80f7021 | 2011-05-19 22:21:41 +0200 | [diff] [blame] | 287 | |
Kumar Gala | 6a74ade | 2011-02-03 09:02:13 -0600 | [diff] [blame] | 288 | if (lawar & LAW_EN) |
Simon Glass | c6622d6 | 2012-12-13 20:48:51 +0000 | [diff] [blame] | 289 | gd->arch.used_laws |= (1 << i); |
Kumar Gala | 6a74ade | 2011-02-03 09:02:13 -0600 | [diff] [blame] | 290 | } |
| 291 | |
Kumar Gala | 75639e0 | 2008-06-11 00:44:10 -0500 | [diff] [blame] | 292 | for (i = 0; i < num_law_entries; i++) { |
| 293 | if (law_table[i].index == -1) |
| 294 | set_next_law(law_table[i].addr, law_table[i].size, |
| 295 | law_table[i].trgt_id); |
| 296 | else |
| 297 | set_law(law_table[i].index, law_table[i].addr, |
| 298 | law_table[i].size, law_table[i].trgt_id); |
Kumar Gala | 95fd2f6 | 2008-01-16 01:13:58 -0600 | [diff] [blame] | 299 | } |
| 300 | |
Liu Gang | b4611ee | 2012-08-09 05:10:03 +0000 | [diff] [blame] | 301 | #ifdef CONFIG_SRIO_PCIE_BOOT_SLAVE |
Liu Gang | e86e1a3 | 2012-08-09 05:10:00 +0000 | [diff] [blame] | 302 | /* check RCW to get which port is used for boot */ |
| 303 | ccsr_gur_t *gur = (void *)CONFIG_SYS_MPC85xx_GUTS_ADDR; |
| 304 | u32 bootloc = in_be32(&gur->rcwsr[6]); |
Liu Gang | b4611ee | 2012-08-09 05:10:03 +0000 | [diff] [blame] | 305 | /* |
| 306 | * in SRIO or PCIE boot we need to set specail LAWs for |
| 307 | * SRIO or PCIE interfaces. |
| 308 | */ |
Liu Gang | e86e1a3 | 2012-08-09 05:10:00 +0000 | [diff] [blame] | 309 | switch ((bootloc & FSL_CORENET_RCWSR6_BOOT_LOC) >> 23) { |
Liu Gang | b4611ee | 2012-08-09 05:10:03 +0000 | [diff] [blame] | 310 | case 0x0: /* boot from PCIE1 */ |
| 311 | set_next_law(CONFIG_SYS_SRIO_PCIE_BOOT_SLAVE_ADDR_PHYS, |
| 312 | LAW_SIZE_1M, |
| 313 | LAW_TRGT_IF_PCIE_1); |
| 314 | set_next_law(CONFIG_SYS_SRIO_PCIE_BOOT_UCODE_ENV_ADDR_PHYS, |
| 315 | LAW_SIZE_1M, |
| 316 | LAW_TRGT_IF_PCIE_1); |
| 317 | break; |
| 318 | case 0x1: /* boot from PCIE2 */ |
| 319 | set_next_law(CONFIG_SYS_SRIO_PCIE_BOOT_SLAVE_ADDR_PHYS, |
| 320 | LAW_SIZE_1M, |
| 321 | LAW_TRGT_IF_PCIE_2); |
| 322 | set_next_law(CONFIG_SYS_SRIO_PCIE_BOOT_UCODE_ENV_ADDR_PHYS, |
| 323 | LAW_SIZE_1M, |
| 324 | LAW_TRGT_IF_PCIE_2); |
| 325 | break; |
| 326 | case 0x2: /* boot from PCIE3 */ |
| 327 | set_next_law(CONFIG_SYS_SRIO_PCIE_BOOT_SLAVE_ADDR_PHYS, |
| 328 | LAW_SIZE_1M, |
| 329 | LAW_TRGT_IF_PCIE_3); |
| 330 | set_next_law(CONFIG_SYS_SRIO_PCIE_BOOT_UCODE_ENV_ADDR_PHYS, |
| 331 | LAW_SIZE_1M, |
| 332 | LAW_TRGT_IF_PCIE_3); |
| 333 | break; |
Liu Gang | e86e1a3 | 2012-08-09 05:10:00 +0000 | [diff] [blame] | 334 | case 0x8: /* boot from SRIO1 */ |
Liu Gang | b4611ee | 2012-08-09 05:10:03 +0000 | [diff] [blame] | 335 | set_next_law(CONFIG_SYS_SRIO_PCIE_BOOT_SLAVE_ADDR_PHYS, |
Liu Gang | e86e1a3 | 2012-08-09 05:10:00 +0000 | [diff] [blame] | 336 | LAW_SIZE_1M, |
| 337 | LAW_TRGT_IF_RIO_1); |
Liu Gang | b4611ee | 2012-08-09 05:10:03 +0000 | [diff] [blame] | 338 | set_next_law(CONFIG_SYS_SRIO_PCIE_BOOT_UCODE_ENV_ADDR_PHYS, |
Liu Gang | e86e1a3 | 2012-08-09 05:10:00 +0000 | [diff] [blame] | 339 | LAW_SIZE_1M, |
| 340 | LAW_TRGT_IF_RIO_1); |
| 341 | break; |
| 342 | case 0x9: /* boot from SRIO2 */ |
Liu Gang | b4611ee | 2012-08-09 05:10:03 +0000 | [diff] [blame] | 343 | set_next_law(CONFIG_SYS_SRIO_PCIE_BOOT_SLAVE_ADDR_PHYS, |
Liu Gang | e86e1a3 | 2012-08-09 05:10:00 +0000 | [diff] [blame] | 344 | LAW_SIZE_1M, |
| 345 | LAW_TRGT_IF_RIO_2); |
Liu Gang | b4611ee | 2012-08-09 05:10:03 +0000 | [diff] [blame] | 346 | set_next_law(CONFIG_SYS_SRIO_PCIE_BOOT_UCODE_ENV_ADDR_PHYS, |
Liu Gang | e86e1a3 | 2012-08-09 05:10:00 +0000 | [diff] [blame] | 347 | LAW_SIZE_1M, |
| 348 | LAW_TRGT_IF_RIO_2); |
| 349 | break; |
| 350 | default: |
| 351 | break; |
| 352 | } |
| 353 | #endif |
| 354 | |
Kumar Gala | 95fd2f6 | 2008-01-16 01:13:58 -0600 | [diff] [blame] | 355 | return ; |
| 356 | } |