diff options
| -rw-r--r-- | Documentation/xtensa/mmu.txt | 18 | ||||
| -rw-r--r-- | arch/xtensa/include/asm/initialize_mmu.h | 9 | ||||
| -rw-r--r-- | arch/xtensa/include/asm/io.h | 10 | ||||
| -rw-r--r-- | arch/xtensa/include/asm/vectors.h | 8 | ||||
| -rw-r--r-- | arch/xtensa/kernel/setup.c | 37 | ||||
| -rw-r--r-- | arch/xtensa/mm/mmu.c | 16 |
6 files changed, 93 insertions, 5 deletions
diff --git a/Documentation/xtensa/mmu.txt b/Documentation/xtensa/mmu.txt index 2b1af7606d57..0312fe66475c 100644 --- a/Documentation/xtensa/mmu.txt +++ b/Documentation/xtensa/mmu.txt | |||
| @@ -44,3 +44,21 @@ After step 4, we jump to intended (linked) address of this code. | |||
| 44 | 40..5F -> 40 40..5F -> pc -> pc 40..5F -> pc | 44 | 40..5F -> 40 40..5F -> pc -> pc 40..5F -> pc |
| 45 | 20..3F -> 20 -> 20 20..3F -> 20 | 45 | 20..3F -> 20 -> 20 20..3F -> 20 |
| 46 | 00..1F -> 00 -> 00 00..1F -> 00 | 46 | 00..1F -> 00 -> 00 00..1F -> 00 |
| 47 | |||
| 48 | The default location of IO peripherals is above 0xf0000000. This may change | ||
| 49 | using a "ranges" property in a device tree simple-bus node. See ePAPR 1.1, ยง6.5 | ||
| 50 | for details on the syntax and semantic of simple-bus nodes. The following | ||
| 51 | limitations apply: | ||
| 52 | |||
| 53 | 1. Only top level simple-bus nodes are considered | ||
| 54 | |||
| 55 | 2. Only one (first) simple-bus node is considered | ||
| 56 | |||
| 57 | 3. Empty "ranges" properties are not supported | ||
| 58 | |||
| 59 | 4. Only the first triplet in the "ranges" property is considered | ||
| 60 | |||
| 61 | 5. The parent-bus-address value is rounded down to the nearest 256MB boundary | ||
| 62 | |||
| 63 | 6. The IO area covers the entire 256MB segment of parent-bus-address; the | ||
| 64 | "ranges" triplet length field is ignored | ||
diff --git a/arch/xtensa/include/asm/initialize_mmu.h b/arch/xtensa/include/asm/initialize_mmu.h index a2078a2e5476..600781edc8a3 100644 --- a/arch/xtensa/include/asm/initialize_mmu.h +++ b/arch/xtensa/include/asm/initialize_mmu.h | |||
| @@ -26,6 +26,9 @@ | |||
| 26 | #include <asm/pgtable.h> | 26 | #include <asm/pgtable.h> |
| 27 | #include <asm/vectors.h> | 27 | #include <asm/vectors.h> |
| 28 | 28 | ||
| 29 | #define CA_BYPASS (_PAGE_CA_BYPASS | _PAGE_HW_WRITE | _PAGE_HW_EXEC) | ||
| 30 | #define CA_WRITEBACK (_PAGE_CA_WB | _PAGE_HW_WRITE | _PAGE_HW_EXEC) | ||
| 31 | |||
| 29 | #ifdef __ASSEMBLY__ | 32 | #ifdef __ASSEMBLY__ |
| 30 | 33 | ||
| 31 | #define XTENSA_HWVERSION_RC_2009_0 230000 | 34 | #define XTENSA_HWVERSION_RC_2009_0 230000 |
| @@ -80,8 +83,6 @@ | |||
| 80 | /* Step 2: map 0x40000000..0x47FFFFFF to paddr containing this code | 83 | /* Step 2: map 0x40000000..0x47FFFFFF to paddr containing this code |
| 81 | * and jump to the new mapping. | 84 | * and jump to the new mapping. |
| 82 | */ | 85 | */ |
| 83 | #define CA_BYPASS (_PAGE_CA_BYPASS | _PAGE_HW_WRITE | _PAGE_HW_EXEC) | ||
| 84 | #define CA_WRITEBACK (_PAGE_CA_WB | _PAGE_HW_WRITE | _PAGE_HW_EXEC) | ||
| 85 | 86 | ||
| 86 | srli a3, a0, 27 | 87 | srli a3, a0, 27 |
| 87 | slli a3, a3, 27 | 88 | slli a3, a3, 27 |
| @@ -124,12 +125,12 @@ | |||
| 124 | witlb a4, a5 | 125 | witlb a4, a5 |
| 125 | 126 | ||
| 126 | movi a5, XCHAL_KIO_CACHED_VADDR + 6 | 127 | movi a5, XCHAL_KIO_CACHED_VADDR + 6 |
| 127 | movi a4, XCHAL_KIO_PADDR + CA_WRITEBACK | 128 | movi a4, XCHAL_KIO_DEFAULT_PADDR + CA_WRITEBACK |
| 128 | wdtlb a4, a5 | 129 | wdtlb a4, a5 |
| 129 | witlb a4, a5 | 130 | witlb a4, a5 |
| 130 | 131 | ||
| 131 | movi a5, XCHAL_KIO_BYPASS_VADDR + 6 | 132 | movi a5, XCHAL_KIO_BYPASS_VADDR + 6 |
| 132 | movi a4, XCHAL_KIO_PADDR + CA_BYPASS | 133 | movi a4, XCHAL_KIO_DEFAULT_PADDR + CA_BYPASS |
| 133 | wdtlb a4, a5 | 134 | wdtlb a4, a5 |
| 134 | witlb a4, a5 | 135 | witlb a4, a5 |
| 135 | 136 | ||
diff --git a/arch/xtensa/include/asm/io.h b/arch/xtensa/include/asm/io.h index 1482a3636381..2a042d430c25 100644 --- a/arch/xtensa/include/asm/io.h +++ b/arch/xtensa/include/asm/io.h | |||
| @@ -24,6 +24,16 @@ | |||
| 24 | #define IO_SPACE_LIMIT ~0 | 24 | #define IO_SPACE_LIMIT ~0 |
| 25 | 25 | ||
| 26 | #ifdef CONFIG_MMU | 26 | #ifdef CONFIG_MMU |
| 27 | |||
| 28 | #if XCHAL_HAVE_PTP_MMU && XCHAL_HAVE_SPANNING_WAY && CONFIG_OF | ||
| 29 | extern unsigned long xtensa_kio_paddr; | ||
| 30 | |||
| 31 | static inline unsigned long xtensa_get_kio_paddr(void) | ||
| 32 | { | ||
| 33 | return xtensa_kio_paddr; | ||
| 34 | } | ||
| 35 | #endif | ||
| 36 | |||
| 27 | /* | 37 | /* |
| 28 | * Return the virtual address for the specified bus memory. | 38 | * Return the virtual address for the specified bus memory. |
| 29 | * Note that we currently don't support any address outside the KIO segment. | 39 | * Note that we currently don't support any address outside the KIO segment. |
diff --git a/arch/xtensa/include/asm/vectors.h b/arch/xtensa/include/asm/vectors.h index 221a60d804d5..5791b45d5a5d 100644 --- a/arch/xtensa/include/asm/vectors.h +++ b/arch/xtensa/include/asm/vectors.h | |||
| @@ -22,9 +22,15 @@ | |||
| 22 | 22 | ||
| 23 | #define XCHAL_KIO_CACHED_VADDR 0xe0000000 | 23 | #define XCHAL_KIO_CACHED_VADDR 0xe0000000 |
| 24 | #define XCHAL_KIO_BYPASS_VADDR 0xf0000000 | 24 | #define XCHAL_KIO_BYPASS_VADDR 0xf0000000 |
| 25 | #define XCHAL_KIO_PADDR 0xf0000000 | 25 | #define XCHAL_KIO_DEFAULT_PADDR 0xf0000000 |
| 26 | #define XCHAL_KIO_SIZE 0x10000000 | 26 | #define XCHAL_KIO_SIZE 0x10000000 |
| 27 | 27 | ||
| 28 | #if XCHAL_HAVE_PTP_MMU && XCHAL_HAVE_SPANNING_WAY && CONFIG_OF | ||
| 29 | #define XCHAL_KIO_PADDR xtensa_get_kio_paddr() | ||
| 30 | #else | ||
| 31 | #define XCHAL_KIO_PADDR XCHAL_KIO_DEFAULT_PADDR | ||
| 32 | #endif | ||
| 33 | |||
| 28 | #if defined(CONFIG_MMU) | 34 | #if defined(CONFIG_MMU) |
| 29 | 35 | ||
| 30 | /* Will Become VECBASE */ | 36 | /* Will Become VECBASE */ |
diff --git a/arch/xtensa/kernel/setup.c b/arch/xtensa/kernel/setup.c index f38badeb7747..7d12af1317f1 100644 --- a/arch/xtensa/kernel/setup.c +++ b/arch/xtensa/kernel/setup.c | |||
| @@ -212,6 +212,42 @@ static int __init parse_bootparam(const bp_tag_t* tag) | |||
| 212 | #ifdef CONFIG_OF | 212 | #ifdef CONFIG_OF |
| 213 | bool __initdata dt_memory_scan = false; | 213 | bool __initdata dt_memory_scan = false; |
| 214 | 214 | ||
| 215 | #if XCHAL_HAVE_PTP_MMU && XCHAL_HAVE_SPANNING_WAY | ||
| 216 | unsigned long xtensa_kio_paddr = XCHAL_KIO_DEFAULT_PADDR; | ||
| 217 | EXPORT_SYMBOL(xtensa_kio_paddr); | ||
| 218 | |||
| 219 | static int __init xtensa_dt_io_area(unsigned long node, const char *uname, | ||
| 220 | int depth, void *data) | ||
| 221 | { | ||
| 222 | const __be32 *ranges; | ||
| 223 | unsigned long len; | ||
| 224 | |||
| 225 | if (depth > 1) | ||
| 226 | return 0; | ||
| 227 | |||
| 228 | if (!of_flat_dt_is_compatible(node, "simple-bus")) | ||
| 229 | return 0; | ||
| 230 | |||
| 231 | ranges = of_get_flat_dt_prop(node, "ranges", &len); | ||
| 232 | if (!ranges) | ||
| 233 | return 1; | ||
| 234 | if (len == 0) | ||
| 235 | return 1; | ||
| 236 | |||
| 237 | xtensa_kio_paddr = of_read_ulong(ranges+1, 1); | ||
| 238 | /* round down to nearest 256MB boundary */ | ||
| 239 | xtensa_kio_paddr &= 0xf0000000; | ||
| 240 | |||
| 241 | return 1; | ||
| 242 | } | ||
| 243 | #else | ||
| 244 | static int __init xtensa_dt_io_area(unsigned long node, const char *uname, | ||
| 245 | int depth, void *data) | ||
| 246 | { | ||
| 247 | return 1; | ||
| 248 | } | ||
| 249 | #endif | ||
| 250 | |||
| 215 | void __init early_init_dt_add_memory_arch(u64 base, u64 size) | 251 | void __init early_init_dt_add_memory_arch(u64 base, u64 size) |
| 216 | { | 252 | { |
| 217 | if (!dt_memory_scan) | 253 | if (!dt_memory_scan) |
| @@ -232,6 +268,7 @@ void __init early_init_devtree(void *params) | |||
| 232 | dt_memory_scan = true; | 268 | dt_memory_scan = true; |
| 233 | 269 | ||
| 234 | early_init_dt_scan(params); | 270 | early_init_dt_scan(params); |
| 271 | of_scan_flat_dt(xtensa_dt_io_area, NULL); | ||
| 235 | 272 | ||
| 236 | if (!command_line[0]) | 273 | if (!command_line[0]) |
| 237 | strlcpy(command_line, boot_command_line, COMMAND_LINE_SIZE); | 274 | strlcpy(command_line, boot_command_line, COMMAND_LINE_SIZE); |
diff --git a/arch/xtensa/mm/mmu.c b/arch/xtensa/mm/mmu.c index 5bb8e3c61d85..36ec171698b8 100644 --- a/arch/xtensa/mm/mmu.c +++ b/arch/xtensa/mm/mmu.c | |||
| @@ -13,6 +13,8 @@ | |||
| 13 | #include <asm/tlbflush.h> | 13 | #include <asm/tlbflush.h> |
| 14 | #include <asm/mmu_context.h> | 14 | #include <asm/mmu_context.h> |
| 15 | #include <asm/page.h> | 15 | #include <asm/page.h> |
| 16 | #include <asm/initialize_mmu.h> | ||
| 17 | #include <asm/io.h> | ||
| 16 | 18 | ||
| 17 | void __init paging_init(void) | 19 | void __init paging_init(void) |
| 18 | { | 20 | { |
| @@ -37,6 +39,20 @@ void init_mmu(void) | |||
| 37 | set_itlbcfg_register(0); | 39 | set_itlbcfg_register(0); |
| 38 | set_dtlbcfg_register(0); | 40 | set_dtlbcfg_register(0); |
| 39 | #endif | 41 | #endif |
| 42 | #if XCHAL_HAVE_PTP_MMU && XCHAL_HAVE_SPANNING_WAY && CONFIG_OF | ||
| 43 | /* | ||
| 44 | * Update the IO area mapping in case xtensa_kio_paddr has changed | ||
| 45 | */ | ||
| 46 | write_dtlb_entry(__pte(xtensa_kio_paddr + CA_WRITEBACK), | ||
| 47 | XCHAL_KIO_CACHED_VADDR + 6); | ||
| 48 | write_itlb_entry(__pte(xtensa_kio_paddr + CA_WRITEBACK), | ||
| 49 | XCHAL_KIO_CACHED_VADDR + 6); | ||
| 50 | write_dtlb_entry(__pte(xtensa_kio_paddr + CA_BYPASS), | ||
| 51 | XCHAL_KIO_BYPASS_VADDR + 6); | ||
| 52 | write_itlb_entry(__pte(xtensa_kio_paddr + CA_BYPASS), | ||
| 53 | XCHAL_KIO_BYPASS_VADDR + 6); | ||
| 54 | #endif | ||
| 55 | |||
| 40 | local_flush_tlb_all(); | 56 | local_flush_tlb_all(); |
| 41 | 57 | ||
| 42 | /* Set rasid register to a known value. */ | 58 | /* Set rasid register to a known value. */ |
