packaging: release out (3.8.3)
[profile/ivi/kernel-adaptation-intel-automotive.git] / arch / powerpc / kernel / cpu_setup_power.S
1 /*
2  * This file contains low level CPU setup functions.
3  *    Copyright (C) 2003 Benjamin Herrenschmidt (benh@kernel.crashing.org)
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version
8  * 2 of the License, or (at your option) any later version.
9  *
10  */
11
12 #include <asm/processor.h>
13 #include <asm/page.h>
14 #include <asm/cputable.h>
15 #include <asm/ppc_asm.h>
16 #include <asm/asm-offsets.h>
17 #include <asm/cache.h>
18
19 /* Entry: r3 = crap, r4 = ptr to cputable entry
20  *
21  * Note that we can be called twice for pseudo-PVRs
22  */
23 _GLOBAL(__setup_cpu_power7)
24         mflr    r11
25         bl      __init_hvmode_206
26         mtlr    r11
27         beqlr
28         li      r0,0
29         mtspr   SPRN_LPID,r0
30         mfspr   r3,SPRN_LPCR
31         bl      __init_LPCR
32         bl      __init_TLB
33         mtlr    r11
34         blr
35
36 _GLOBAL(__restore_cpu_power7)
37         mflr    r11
38         mfmsr   r3
39         rldicl. r0,r3,4,63
40         beqlr
41         li      r0,0
42         mtspr   SPRN_LPID,r0
43         mfspr   r3,SPRN_LPCR
44         bl      __init_LPCR
45         bl      __init_TLB
46         mtlr    r11
47         blr
48
49 _GLOBAL(__setup_cpu_power8)
50         mflr    r11
51         bl      __init_hvmode_206
52         mtlr    r11
53         beqlr
54         li      r0,0
55         mtspr   SPRN_LPID,r0
56         mfspr   r3,SPRN_LPCR
57         oris    r3, r3, LPCR_AIL_3@h
58         bl      __init_LPCR
59         bl      __init_TLB
60         mtlr    r11
61         blr
62
63 _GLOBAL(__restore_cpu_power8)
64         mflr    r11
65         mfmsr   r3
66         rldicl. r0,r3,4,63
67         beqlr
68         li      r0,0
69         mtspr   SPRN_LPID,r0
70         mfspr   r3,SPRN_LPCR
71         oris    r3, r3, LPCR_AIL_3@h
72         bl      __init_LPCR
73         bl      __init_TLB
74         mtlr    r11
75         blr
76
77 __init_hvmode_206:
78         /* Disable CPU_FTR_HVMODE and exit if MSR:HV is not set */
79         mfmsr   r3
80         rldicl. r0,r3,4,63
81         bnelr
82         ld      r5,CPU_SPEC_FEATURES(r4)
83         LOAD_REG_IMMEDIATE(r6,CPU_FTR_HVMODE)
84         xor     r5,r5,r6
85         std     r5,CPU_SPEC_FEATURES(r4)
86         blr
87
88 __init_LPCR:
89         /* Setup a sane LPCR:
90          *   Called with initial LPCR in R3
91          *
92          *   LPES = 0b01 (HSRR0/1 used for 0x500)
93          *   PECE = 0b111
94          *   DPFD = 4
95          *   HDICE = 0
96          *   VC = 0b100 (VPM0=1, VPM1=0, ISL=0)
97          *   VRMASD = 0b10000 (L=1, LP=00)
98          *
99          * Other bits untouched for now
100          */
101         li      r5,1
102         rldimi  r3,r5, LPCR_LPES_SH, 64-LPCR_LPES_SH-2
103         ori     r3,r3,(LPCR_PECE0|LPCR_PECE1|LPCR_PECE2)
104         li      r5,4
105         rldimi  r3,r5, LPCR_DPFD_SH, 64-LPCR_DPFD_SH-3
106         clrrdi  r3,r3,1         /* clear HDICE */
107         li      r5,4
108         rldimi  r3,r5, LPCR_VC_SH, 0
109         li      r5,0x10
110         rldimi  r3,r5, LPCR_VRMASD_SH, 64-LPCR_VRMASD_SH-5
111         mtspr   SPRN_LPCR,r3
112         isync
113         blr
114
115 __init_TLB:
116         /* Clear the TLB */
117         li      r6,128
118         mtctr   r6
119         li      r7,0xc00        /* IS field = 0b11 */
120         ptesync
121 2:      tlbiel  r7
122         addi    r7,r7,0x1000
123         bdnz    2b
124         ptesync
125 1:      blr