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