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