2 * A2 specific assembly support code
4 * Copyright 2009 Ben Herrenschmidt, IBM Corp.
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
12 #include <asm/asm-offsets.h>
13 #include <asm/ppc_asm.h>
14 #include <asm/ppc-opcode.h>
15 #include <asm/processor.h>
16 #include <asm/reg_a2.h>
18 #include <asm/thread_info.h>
21 * Disable thdid and class fields in ERATs to bump PID to full 14 bits capacity.
22 * This also prevents external LPID accesses but that isn't a problem when not a
23 * guest. Under PV, this setting will be ignored and MMUCR will return the right
24 * number of PID bits we can use.
26 #define MMUCR1_EXTEND_PID \
27 (MMUCR1_ICTID | MMUCR1_ITTID | MMUCR1_DCTID | \
28 MMUCR1_DTTID | MMUCR1_DCCD)
31 * Use extended PIDs if enabled.
32 * Don't clear the ERATs on context sync events and enable I & D LRU.
33 * Enable ERAT back invalidate when tlbwe overwrites an entry.
35 #define INITIAL_MMUCR1 \
36 (MMUCR1_EXTEND_PID | MMUCR1_CSINV_NEVER | MMUCR1_IRRE | \
37 MMUCR1_DRRE | MMUCR1_TLBWE_BINV)
39 _GLOBAL(__setup_cpu_a2)
40 /* Some of these are actually thread local and some are
41 * core local but doing it always won't hurt
44 #ifdef CONFIG_PPC_WSP_COPRO
45 /* Make sure ACOP starts out as zero */
49 /* Enable icswx instruction */
51 ori r3,r3,A2_CCR2_ENABLE_ICSWX
54 /* Unmask all CTs in HACOP */
57 #endif /* CONFIG_PPC_WSP_COPRO */
61 oris r3,r3,A2_CCR2_ENABLE_PC@h
65 /* Setup CCR0 to disable power saving for now as it's busted
66 * in the current implementations. Setup CCR1 to wake on
67 * interrupts normally (we write the default value but who
68 * knows what FW may have clobbered...)
71 mtspr SPRN_A2_CCR0, r3
72 LOAD_REG_IMMEDIATE(r3,0x0f0f0f0f)
73 mtspr SPRN_A2_CCR1, r3
75 /* Initialise MMUCR1 */
76 lis r3,INITIAL_MMUCR1@h
77 ori r3,r3,INITIAL_MMUCR1@l
80 /* Set MMUCR2 to enable 4K, 64K, 1M, 16M and 1G pages */
81 LOAD_REG_IMMEDIATE(r3, 0x000a7531)
84 /* Set MMUCR3 to write all thids bit to the TLB */
85 LOAD_REG_IMMEDIATE(r3, 0x0000000f)
88 /* Don't do ERAT stuff if running guest mode */
93 /* Now set the I-ERAT watermark to 15 */
94 lis r4,(MMUCR0_TLBSEL_I|MMUCR0_ECL)@h
99 /* Now set the D-ERAT watermark to 31 */
100 lis r4,(MMUCR0_TLBSEL_D|MMUCR0_ECL)@h
101 mtspr SPRN_MMUCR0, r4
102 li r4,A2_DERAT_SIZE-1
105 /* And invalidate the beast just in case. That won't get rid of
106 * a bolted entry though it will be in LRU and so will go away eventually
107 * but let's not bother for now
113 _GLOBAL(__restore_cpu_a2)