Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

MIPS: malta: Configure Segment Control registers for EVA boot

The Malta board aliases 0x80000000 - 0xffffffff to 0x00000000
- 0x7fffffff ignoring the 256 MB IO hole in 0x10000000.
The physical memory is shifted to 0x80000000 so up to 2GB
can be used. Kuseg is expanded to 3GB (due to board limitations
only 2GB can be accessed) and lowmem (kernel space) is expanded to 2GB.

The Segment Control registers are programmed as follows:

Virtual memory Physical memory Mapping
0x00000000 - 0x7fffffff 0x80000000 - 0xfffffffff MUSUK (kuseg)
0x80000000 - 0x9fffffff 0x00000000 - 0x1ffffffff MUSUK (kseg0)
0xa0000000 - 0xbf000000 0x00000000 - 0x1ffffffff MUSUK (kseg1)
0xc0000000 - 0xdfffffff - MK (kseg2)
0xe0000000 - 0xffffffff - MK (kseg3)

The location of exception vectors remain the same since 0xbfc00000
(traditional exception base) still maps to 0x1fc00000 physical.

Signed-off-by: Markos Chandras <markos.chandras@imgtec.com>

authored by

Markos Chandras and committed by
Ralf Baechle
f8b7faf1 4676f935

+112 -1
+108 -1
arch/mips/include/asm/mach-malta/kernel-entry-init.h
··· 5 5 * 6 6 * Chris Dearman (chris@mips.com) 7 7 * Copyright (C) 2007 Mips Technologies, Inc. 8 + * Copyright (C) 2014 Imagination Technologies Ltd. 8 9 */ 9 10 #ifndef __ASM_MACH_MIPS_KERNEL_ENTRY_INIT_H 10 11 #define __ASM_MACH_MIPS_KERNEL_ENTRY_INIT_H 12 + 13 + /* 14 + * Prepare segments for EVA boot: 15 + * 16 + * This is in case the processor boots in legacy configuration 17 + * (SI_EVAReset is de-asserted and CONFIG5.K == 0) 18 + * 19 + * On entry, t1 is loaded with CP0_CONFIG 20 + * 21 + * ========================= Mappings ============================= 22 + * Virtual memory Physical memory Mapping 23 + * 0x00000000 - 0x7fffffff 0x80000000 - 0xfffffffff MUSUK (kuseg) 24 + * Flat 2GB physical memory 25 + * 26 + * 0x80000000 - 0x9fffffff 0x00000000 - 0x1ffffffff MUSUK (kseg0) 27 + * 0xa0000000 - 0xbf000000 0x00000000 - 0x1ffffffff MUSUK (kseg1) 28 + * 0xc0000000 - 0xdfffffff - MK (kseg2) 29 + * 0xe0000000 - 0xffffffff - MK (kseg3) 30 + * 31 + * 32 + * Lowmem is expanded to 2GB 33 + */ 34 + .macro eva_entry 35 + /* 36 + * Get Config.K0 value and use it to program 37 + * the segmentation registers 38 + */ 39 + andi t1, 0x7 /* CCA */ 40 + move t2, t1 41 + ins t2, t1, 16, 3 42 + /* SegCtl0 */ 43 + li t0, ((MIPS_SEGCFG_MK << MIPS_SEGCFG_AM_SHIFT) | \ 44 + (0 << MIPS_SEGCFG_PA_SHIFT) | \ 45 + (1 << MIPS_SEGCFG_EU_SHIFT)) | \ 46 + (((MIPS_SEGCFG_MK << MIPS_SEGCFG_AM_SHIFT) | \ 47 + (0 << MIPS_SEGCFG_PA_SHIFT) | \ 48 + (1 << MIPS_SEGCFG_EU_SHIFT)) << 16) 49 + or t0, t2 50 + mtc0 t0, $5, 2 51 + 52 + /* SegCtl1 */ 53 + li t0, ((MIPS_SEGCFG_MUSUK << MIPS_SEGCFG_AM_SHIFT) | \ 54 + (0 << MIPS_SEGCFG_PA_SHIFT) | \ 55 + (2 << MIPS_SEGCFG_C_SHIFT) | \ 56 + (1 << MIPS_SEGCFG_EU_SHIFT)) | \ 57 + (((MIPS_SEGCFG_MUSUK << MIPS_SEGCFG_AM_SHIFT) | \ 58 + (0 << MIPS_SEGCFG_PA_SHIFT) | \ 59 + (1 << MIPS_SEGCFG_EU_SHIFT)) << 16) 60 + ins t0, t1, 16, 3 61 + mtc0 t0, $5, 3 62 + 63 + /* SegCtl2 */ 64 + li t0, ((MIPS_SEGCFG_MUSUK << MIPS_SEGCFG_AM_SHIFT) | \ 65 + (6 << MIPS_SEGCFG_PA_SHIFT) | \ 66 + (1 << MIPS_SEGCFG_EU_SHIFT)) | \ 67 + (((MIPS_SEGCFG_MUSUK << MIPS_SEGCFG_AM_SHIFT) | \ 68 + (4 << MIPS_SEGCFG_PA_SHIFT) | \ 69 + (1 << MIPS_SEGCFG_EU_SHIFT)) << 16) 70 + or t0, t2 71 + mtc0 t0, $5, 4 72 + 73 + jal mips_ihb 74 + mfc0 t0, $16, 5 75 + li t2, 0x40000000 /* K bit */ 76 + or t0, t0, t2 77 + mtc0 t0, $16, 5 78 + sync 79 + jal mips_ihb 80 + .endm 11 81 12 82 .macro kernel_entry_setup 13 83 #ifdef CONFIG_MIPS_MT_SMTC ··· 109 39 nonmt_processor: 110 40 .asciz "SMTC kernel requires the MT ASE to run\n" 111 41 __FINIT 112 - 0: 113 42 #endif 43 + 44 + #ifdef CONFIG_EVA 45 + sync 46 + ehb 47 + 48 + mfc0 t1, CP0_CONFIG 49 + bgez t1, 9f 50 + mfc0 t0, CP0_CONFIG, 1 51 + bgez t0, 9f 52 + mfc0 t0, CP0_CONFIG, 2 53 + bgez t0, 9f 54 + mfc0 t0, CP0_CONFIG, 3 55 + sll t0, t0, 6 /* SC bit */ 56 + bgez t0, 9f 57 + 58 + eva_entry 59 + b 0f 60 + 9: 61 + /* Assume we came from YAMON... */ 62 + PTR_LA v0, 0x9fc00534 /* YAMON print */ 63 + lw v0, (v0) 64 + move a0, zero 65 + PTR_LA a1, nonsc_processor 66 + jal v0 67 + 68 + PTR_LA v0, 0x9fc00520 /* YAMON exit */ 69 + lw v0, (v0) 70 + li a0, 1 71 + jal v0 72 + 73 + 1: b 1b 74 + nop 75 + __INITDATA 76 + nonsc_processor: 77 + .asciz "EVA kernel requires a MIPS core with Segment Control implemented\n" 78 + __FINIT 79 + #endif /* CONFIG_EVA */ 80 + 0: 114 81 .endm 115 82 116 83 /*
+4
arch/mips/mti-malta/malta-setup.c
··· 247 247 { 248 248 unsigned int i; 249 249 250 + if (config_enabled(CONFIG_EVA)) 251 + /* EVA has already been configured in mach-malta/kernel-init.h */ 252 + pr_info("Enhanced Virtual Addressing (EVA) activated\n"); 253 + 250 254 mips_pcibios_init(); 251 255 252 256 /* Request I/O space for devices used on the Malta board. */