1
2
3
4
5
6
7
8
9#ifndef _ASM_POWERPC_REG_H
10#define _ASM_POWERPC_REG_H
11#ifdef __KERNEL__
12
13#include <linux/stringify.h>
14#include <asm/cputable.h>
15
16
17#if defined(CONFIG_BOOKE) || defined(CONFIG_40x)
18#include <asm/reg_booke.h>
19#endif
20
21#ifdef CONFIG_FSL_EMB_PERFMON
22#include <asm/reg_fsl_emb.h>
23#endif
24
25#ifdef CONFIG_8xx
26#include <asm/reg_8xx.h>
27#endif
28
29#define MSR_SF_LG 63
30#define MSR_ISF_LG 61
31#define MSR_HV_LG 60
32#define MSR_TS_T_LG 34
33#define MSR_TS_S_LG 33
34#define MSR_TS_LG 33
35#define MSR_TM_LG 32
36#define MSR_VEC_LG 25
37#define MSR_VSX_LG 23
38#define MSR_POW_LG 18
39#define MSR_WE_LG 18
40#define MSR_TGPR_LG 17
41#define MSR_CE_LG 17
42#define MSR_ILE_LG 16
43#define MSR_EE_LG 15
44#define MSR_PR_LG 14
45#define MSR_FP_LG 13
46#define MSR_ME_LG 12
47#define MSR_FE0_LG 11
48#define MSR_SE_LG 10
49#define MSR_BE_LG 9
50#define MSR_DE_LG 9
51#define MSR_FE1_LG 8
52#define MSR_IP_LG 6
53#define MSR_IR_LG 5
54#define MSR_DR_LG 4
55#define MSR_PE_LG 3
56#define MSR_PX_LG 2
57#define MSR_PMM_LG 2
58#define MSR_RI_LG 1
59#define MSR_LE_LG 0
60
61#ifdef __ASSEMBLY__
62#define __MASK(X) (1<<(X))
63#else
64#define __MASK(X) (1UL<<(X))
65#endif
66
67#ifdef CONFIG_PPC64
68#define MSR_SF __MASK(MSR_SF_LG)
69#define MSR_ISF __MASK(MSR_ISF_LG)
70#define MSR_HV __MASK(MSR_HV_LG)
71#else
72
73#define MSR_SF 0
74#define MSR_ISF 0
75#define MSR_HV 0
76#endif
77
78
79
80
81
82#ifndef MSR_SPE
83#define MSR_SPE 0
84#endif
85
86#define MSR_VEC __MASK(MSR_VEC_LG)
87#define MSR_VSX __MASK(MSR_VSX_LG)
88#define MSR_POW __MASK(MSR_POW_LG)
89#define MSR_WE __MASK(MSR_WE_LG)
90#define MSR_TGPR __MASK(MSR_TGPR_LG)
91#define MSR_CE __MASK(MSR_CE_LG)
92#define MSR_ILE __MASK(MSR_ILE_LG)
93#define MSR_EE __MASK(MSR_EE_LG)
94#define MSR_PR __MASK(MSR_PR_LG)
95#define MSR_FP __MASK(MSR_FP_LG)
96#define MSR_ME __MASK(MSR_ME_LG)
97#define MSR_FE0 __MASK(MSR_FE0_LG)
98#define MSR_SE __MASK(MSR_SE_LG)
99#define MSR_BE __MASK(MSR_BE_LG)
100#define MSR_DE __MASK(MSR_DE_LG)
101#define MSR_FE1 __MASK(MSR_FE1_LG)
102#define MSR_IP __MASK(MSR_IP_LG)
103#define MSR_IR __MASK(MSR_IR_LG)
104#define MSR_DR __MASK(MSR_DR_LG)
105#define MSR_PE __MASK(MSR_PE_LG)
106#define MSR_PX __MASK(MSR_PX_LG)
107#ifndef MSR_PMM
108#define MSR_PMM __MASK(MSR_PMM_LG)
109#endif
110#define MSR_RI __MASK(MSR_RI_LG)
111#define MSR_LE __MASK(MSR_LE_LG)
112
113#define MSR_TM __MASK(MSR_TM_LG)
114#define MSR_TS_N 0
115#define MSR_TS_S __MASK(MSR_TS_S_LG)
116#define MSR_TS_T __MASK(MSR_TS_T_LG)
117#define MSR_TS_MASK (MSR_TS_T | MSR_TS_S)
118#define MSR_TM_ACTIVE(x) (((x) & MSR_TS_MASK) != 0)
119#define MSR_TM_RESV(x) (((x) & MSR_TS_MASK) == MSR_TS_MASK)
120#define MSR_TM_TRANSACTIONAL(x) (((x) & MSR_TS_MASK) == MSR_TS_T)
121#define MSR_TM_SUSPENDED(x) (((x) & MSR_TS_MASK) == MSR_TS_S)
122
123#if defined(CONFIG_PPC_BOOK3S_64)
124#define MSR_64BIT MSR_SF
125
126
127#define __MSR (MSR_ME | MSR_RI | MSR_IR | MSR_DR | MSR_ISF |MSR_HV)
128#ifdef __BIG_ENDIAN__
129#define MSR_ __MSR
130#define MSR_IDLE (MSR_ME | MSR_SF | MSR_HV)
131#else
132#define MSR_ (__MSR | MSR_LE)
133#define MSR_IDLE (MSR_ME | MSR_SF | MSR_HV | MSR_LE)
134#endif
135#define MSR_KERNEL (MSR_ | MSR_64BIT)
136#define MSR_USER32 (MSR_ | MSR_PR | MSR_EE)
137#define MSR_USER64 (MSR_USER32 | MSR_64BIT)
138#elif defined(CONFIG_PPC_BOOK3S_32) || defined(CONFIG_8xx)
139
140#define MSR_KERNEL (MSR_ME|MSR_RI|MSR_IR|MSR_DR)
141#define MSR_USER (MSR_KERNEL|MSR_PR|MSR_EE)
142#endif
143
144#ifndef MSR_64BIT
145#define MSR_64BIT 0
146#endif
147
148
149#define PSSCR_RL_MASK 0x0000000F
150#define PSSCR_MTL_MASK 0x000000F0
151#define PSSCR_TR_MASK 0x00000300
152#define PSSCR_PSLL_MASK 0x000F0000
153#define PSSCR_EC 0x00100000
154#define PSSCR_ESL 0x00200000
155#define PSSCR_SD 0x00400000
156
157
158#define FPSCR_FX 0x80000000
159#define FPSCR_FEX 0x40000000
160#define FPSCR_VX 0x20000000
161#define FPSCR_OX 0x10000000
162#define FPSCR_UX 0x08000000
163#define FPSCR_ZX 0x04000000
164#define FPSCR_XX 0x02000000
165#define FPSCR_VXSNAN 0x01000000
166#define FPSCR_VXISI 0x00800000
167#define FPSCR_VXIDI 0x00400000
168#define FPSCR_VXZDZ 0x00200000
169#define FPSCR_VXIMZ 0x00100000
170#define FPSCR_VXVC 0x00080000
171#define FPSCR_FR 0x00040000
172#define FPSCR_FI 0x00020000
173#define FPSCR_FPRF 0x0001f000
174#define FPSCR_FPCC 0x0000f000
175#define FPSCR_VXSOFT 0x00000400
176#define FPSCR_VXSQRT 0x00000200
177#define FPSCR_VXCVI 0x00000100
178#define FPSCR_VE 0x00000080
179#define FPSCR_OE 0x00000040
180#define FPSCR_UE 0x00000020
181#define FPSCR_ZE 0x00000010
182#define FPSCR_XE 0x00000008
183#define FPSCR_NI 0x00000004
184#define FPSCR_RN 0x00000003
185
186
187#define SPEFSCR_SOVH 0x80000000
188#define SPEFSCR_OVH 0x40000000
189#define SPEFSCR_FGH 0x20000000
190#define SPEFSCR_FXH 0x10000000
191#define SPEFSCR_FINVH 0x08000000
192#define SPEFSCR_FDBZH 0x04000000
193#define SPEFSCR_FUNFH 0x02000000
194#define SPEFSCR_FOVFH 0x01000000
195#define SPEFSCR_FINXS 0x00200000
196#define SPEFSCR_FINVS 0x00100000
197#define SPEFSCR_FDBZS 0x00080000
198#define SPEFSCR_FUNFS 0x00040000
199#define SPEFSCR_FOVFS 0x00020000
200#define SPEFSCR_MODE 0x00010000
201#define SPEFSCR_SOV 0x00008000
202#define SPEFSCR_OV 0x00004000
203#define SPEFSCR_FG 0x00002000
204#define SPEFSCR_FX 0x00001000
205#define SPEFSCR_FINV 0x00000800
206#define SPEFSCR_FDBZ 0x00000400
207#define SPEFSCR_FUNF 0x00000200
208#define SPEFSCR_FOVF 0x00000100
209#define SPEFSCR_FINXE 0x00000040
210#define SPEFSCR_FINVE 0x00000020
211#define SPEFSCR_FDBZE 0x00000010
212#define SPEFSCR_FUNFE 0x00000008
213#define SPEFSCR_FOVFE 0x00000004
214#define SPEFSCR_FRMC 0x00000003
215
216
217
218#ifdef CONFIG_40x
219#define SPRN_PID 0x3B1
220#else
221#define SPRN_PID 0x030
222#ifdef CONFIG_BOOKE
223#define SPRN_PID0 SPRN_PID
224#endif
225#endif
226
227#define SPRN_CTR 0x009
228#define SPRN_DSCR 0x11
229#define SPRN_CFAR 0x1c
230#define SPRN_AMR 0x1d
231#define SPRN_UAMOR 0x9d
232#define SPRN_AMOR 0x15d
233#define SPRN_ACOP 0x1F
234#define SPRN_TFIAR 0x81
235#define SPRN_TEXASR 0x82
236#define SPRN_TEXASRU 0x83
237#define TEXASR_FS __MASK(63-36)
238#define SPRN_TFHAR 0x80
239#define SPRN_CTRLF 0x088
240#define SPRN_CTRLT 0x098
241#define CTRL_CT 0xc0000000
242#define CTRL_CT0 0x80000000
243#define CTRL_CT1 0x40000000
244#define CTRL_TE 0x00c00000
245#define CTRL_RUNLATCH 0x1
246#define SPRN_DAWR 0xB4
247#define SPRN_RPR 0xBA
248#define SPRN_CIABR 0xBB
249#define CIABR_PRIV 0x3
250#define CIABR_PRIV_USER 1
251#define CIABR_PRIV_SUPER 2
252#define CIABR_PRIV_HYPER 3
253#define SPRN_DAWRX 0xBC
254#define DAWRX_USER __MASK(0)
255#define DAWRX_KERNEL __MASK(1)
256#define DAWRX_HYP __MASK(2)
257#define DAWRX_WTI __MASK(3)
258#define DAWRX_WT __MASK(4)
259#define DAWRX_DR __MASK(5)
260#define DAWRX_DW __MASK(6)
261#define SPRN_DABR 0x3F5
262#define SPRN_DABR2 0x13D
263#define SPRN_DABRX 0x3F7
264#define DABRX_USER __MASK(0)
265#define DABRX_KERNEL __MASK(1)
266#define DABRX_HYP __MASK(2)
267#define DABRX_BTI __MASK(3)
268#define DABRX_ALL (DABRX_BTI | DABRX_HYP | DABRX_KERNEL | DABRX_USER)
269#define SPRN_DAR 0x013
270#define SPRN_DBCR 0x136
271#define SPRN_DSISR 0x012
272#define DSISR_NOHPTE 0x40000000
273#define DSISR_PROTFAULT 0x08000000
274#define DSISR_ISSTORE 0x02000000
275#define DSISR_DABRMATCH 0x00400000
276#define DSISR_NOSEGMENT 0x00200000
277#define DSISR_KEYFAULT 0x00200000
278#define SPRN_TBRL 0x10C
279#define SPRN_TBRU 0x10D
280#define SPRN_CIR 0x11B
281#define SPRN_TBWL 0x11C
282#define SPRN_TBWU 0x11D
283#define SPRN_TBU40 0x11E
284#define SPRN_SPURR 0x134
285#define SPRN_HSPRG0 0x130
286#define SPRN_HSPRG1 0x131
287#define SPRN_HDSISR 0x132
288#define SPRN_HDAR 0x133
289#define SPRN_HDEC 0x136
290#define SPRN_HIOR 0x137
291#define SPRN_RMOR 0x138
292#define SPRN_HRMOR 0x139
293#define SPRN_HSRR0 0x13A
294#define SPRN_HSRR1 0x13B
295#define SPRN_LMRR 0x32D
296#define SPRN_LMSER 0x32E
297#define SPRN_IC 0x350
298#define SPRN_VTB 0x351
299#define SPRN_LDBAR 0x352
300#define SPRN_PMICR 0x354
301#define SPRN_PMSR 0x355
302#define SPRN_PMMAR 0x356
303#define SPRN_PSSCR 0x357
304#define SPRN_PMCR 0x374
305
306
307#define FSCR_LM_LG 11
308#define FSCR_TAR_LG 8
309#define FSCR_EBB_LG 7
310#define FSCR_TM_LG 5
311#define FSCR_BHRB_LG 4
312#define FSCR_PM_LG 3
313#define FSCR_DSCR_LG 2
314#define FSCR_VECVSX_LG 1
315#define FSCR_FP_LG 0
316#define SPRN_FSCR 0x099
317#define FSCR_LM __MASK(FSCR_LM_LG)
318#define FSCR_TAR __MASK(FSCR_TAR_LG)
319#define FSCR_EBB __MASK(FSCR_EBB_LG)
320#define FSCR_DSCR __MASK(FSCR_DSCR_LG)
321#define SPRN_HFSCR 0xbe
322#define HFSCR_LM __MASK(FSCR_LM_LG)
323#define HFSCR_TAR __MASK(FSCR_TAR_LG)
324#define HFSCR_EBB __MASK(FSCR_EBB_LG)
325#define HFSCR_TM __MASK(FSCR_TM_LG)
326#define HFSCR_PM __MASK(FSCR_PM_LG)
327#define HFSCR_BHRB __MASK(FSCR_BHRB_LG)
328#define HFSCR_DSCR __MASK(FSCR_DSCR_LG)
329#define HFSCR_VECVSX __MASK(FSCR_VECVSX_LG)
330#define HFSCR_FP __MASK(FSCR_FP_LG)
331#define SPRN_TAR 0x32f
332#define SPRN_LPCR 0x13E
333#define LPCR_VPM0 ASM_CONST(0x8000000000000000)
334#define LPCR_VPM1 ASM_CONST(0x4000000000000000)
335#define LPCR_ISL ASM_CONST(0x2000000000000000)
336#define LPCR_VC_SH 61
337#define LPCR_DPFD_SH 52
338#define LPCR_DPFD (ASM_CONST(7) << LPCR_DPFD_SH)
339#define LPCR_VRMASD_SH 47
340#define LPCR_VRMASD (ASM_CONST(1) << LPCR_VRMASD_SH)
341#define LPCR_VRMA_L ASM_CONST(0x0008000000000000)
342#define LPCR_VRMA_LP0 ASM_CONST(0x0001000000000000)
343#define LPCR_VRMA_LP1 ASM_CONST(0x0000800000000000)
344#define LPCR_RMLS 0x1C000000
345#define LPCR_RMLS_SH 26
346#define LPCR_ILE ASM_CONST(0x0000000002000000)
347#define LPCR_AIL ASM_CONST(0x0000000001800000)
348#define LPCR_AIL_0 ASM_CONST(0x0000000000000000)
349#define LPCR_AIL_3 ASM_CONST(0x0000000001800000)
350#define LPCR_ONL ASM_CONST(0x0000000000040000)
351#define LPCR_LD ASM_CONST(0x0000000000020000)
352#define LPCR_PECE ASM_CONST(0x000000000001f000)
353#define LPCR_PECEDP ASM_CONST(0x0000000000010000)
354#define LPCR_PECEDH ASM_CONST(0x0000000000008000)
355#define LPCR_PECE0 ASM_CONST(0x0000000000004000)
356#define LPCR_PECE1 ASM_CONST(0x0000000000002000)
357#define LPCR_PECE2 ASM_CONST(0x0000000000001000)
358#define LPCR_PECE_HVEE ASM_CONST(0x0000400000000000)
359#define LPCR_MER ASM_CONST(0x0000000000000800)
360#define LPCR_MER_SH 11
361#define LPCR_TC ASM_CONST(0x0000000000000200)
362#define LPCR_LPES 0x0000000c
363#define LPCR_LPES0 ASM_CONST(0x0000000000000008)
364#define LPCR_LPES1 ASM_CONST(0x0000000000000004)
365#define LPCR_LPES_SH 2
366#define LPCR_RMI ASM_CONST(0x0000000000000002)
367#define LPCR_HVICE ASM_CONST(0x0000000000000002)
368#define LPCR_HDICE ASM_CONST(0x0000000000000001)
369#define LPCR_UPRT ASM_CONST(0x0000000000400000)
370#define LPCR_HR ASM_CONST(0x0000000000100000)
371#ifndef SPRN_LPID
372#define SPRN_LPID 0x13F
373#endif
374#define LPID_RSVD 0x3ff
375#define SPRN_HMER 0x150
376#define SPRN_HMEER 0x151
377#define SPRN_PCR 0x152
378#define PCR_VEC_DIS (1ul << (63-0))
379#define PCR_VSX_DIS (1ul << (63-1))
380#define PCR_TM_DIS (1ul << (63-2))
381#define PCR_ARCH_206 0x4
382#define PCR_ARCH_205 0x2
383#define SPRN_HEIR 0x153
384#define SPRN_TLBINDEXR 0x154
385#define SPRN_TLBVPNR 0x155
386#define SPRN_TLBRPNR 0x156
387#define SPRN_TLBLPIDR 0x157
388#define SPRN_DBAT0L 0x219
389#define SPRN_DBAT0U 0x218
390#define SPRN_DBAT1L 0x21B
391#define SPRN_DBAT1U 0x21A
392#define SPRN_DBAT2L 0x21D
393#define SPRN_DBAT2U 0x21C
394#define SPRN_DBAT3L 0x21F
395#define SPRN_DBAT3U 0x21E
396#define SPRN_DBAT4L 0x239
397#define SPRN_DBAT4U 0x238
398#define SPRN_DBAT5L 0x23B
399#define SPRN_DBAT5U 0x23A
400#define SPRN_DBAT6L 0x23D
401#define SPRN_DBAT6U 0x23C
402#define SPRN_DBAT7L 0x23F
403#define SPRN_DBAT7U 0x23E
404#define SPRN_PPR 0x380
405#define SPRN_TSCR 0x399
406
407#define SPRN_DEC 0x016
408#define SPRN_DER 0x095
409#define DER_RSTE 0x40000000
410#define DER_CHSTPE 0x20000000
411#define DER_MCIE 0x10000000
412#define DER_EXTIE 0x02000000
413#define DER_ALIE 0x01000000
414#define DER_PRIE 0x00800000
415#define DER_FPUVIE 0x00400000
416#define DER_DECIE 0x00200000
417#define DER_SYSIE 0x00040000
418#define DER_TRE 0x00020000
419#define DER_SEIE 0x00004000
420#define DER_ITLBMSE 0x00002000
421#define DER_ITLBERE 0x00001000
422#define DER_DTLBMSE 0x00000800
423#define DER_DTLBERE 0x00000400
424#define DER_LBRKE 0x00000008
425#define DER_IBRKE 0x00000004
426#define DER_EBRKE 0x00000002
427#define DER_DPIE 0x00000001
428#define SPRN_DMISS 0x3D0
429#define SPRN_DHDES 0x0B1
430#define SPRN_DPDES 0x0B0
431#define SPRN_EAR 0x11A
432#define SPRN_HASH1 0x3D2
433#define SPRN_HASH2 0x3D3
434#define SPRN_HID0 0x3F0
435#define HID0_HDICE_SH (63 - 23)
436#define HID0_EMCP (1<<31)
437#define HID0_EBA (1<<29)
438#define HID0_EBD (1<<28)
439#define HID0_SBCLK (1<<27)
440#define HID0_EICE (1<<26)
441#define HID0_TBEN (1<<26)
442#define HID0_ECLK (1<<25)
443#define HID0_PAR (1<<24)
444#define HID0_STEN (1<<24)
445#define HID0_HIGH_BAT (1<<23)
446#define HID0_DOZE (1<<23)
447#define HID0_NAP (1<<22)
448#define HID0_SLEEP (1<<21)
449#define HID0_DPM (1<<20)
450#define HID0_BHTCLR (1<<18)
451#define HID0_XAEN (1<<17)
452#define HID0_NHR (1<<16)
453#define HID0_ICE (1<<15)
454#define HID0_DCE (1<<14)
455#define HID0_ILOCK (1<<13)
456#define HID0_DLOCK (1<<12)
457#define HID0_ICFI (1<<11)
458#define HID0_DCI (1<<10)
459#define HID0_SPD (1<<9)
460#define HID0_DAPUEN (1<<8)
461#define HID0_SGE (1<<7)
462#define HID0_SIED (1<<7)
463#define HID0_DCFA (1<<6)
464#define HID0_LRSTK (1<<4)
465#define HID0_BTIC (1<<5)
466#define HID0_ABE (1<<3)
467#define HID0_FOLD (1<<3)
468#define HID0_BHTE (1<<2)
469#define HID0_BTCD (1<<1)
470#define HID0_NOPDST (1<<1)
471#define HID0_NOPTI (1<<0)
472
473#define HID0_POWER8_4LPARMODE __MASK(61)
474#define HID0_POWER8_2LPARMODE __MASK(57)
475#define HID0_POWER8_1TO2LPAR __MASK(52)
476#define HID0_POWER8_1TO4LPAR __MASK(51)
477#define HID0_POWER8_DYNLPARDIS __MASK(48)
478
479
480#define HID0_POWER9_RADIX __MASK(63 - 8)
481
482#define SPRN_HID1 0x3F1
483#ifdef CONFIG_6xx
484#define HID1_EMCP (1<<31)
485#define HID1_DFS (1<<22)
486#define HID1_PC0 (1<<16)
487#define HID1_PC1 (1<<15)
488#define HID1_PC2 (1<<14)
489#define HID1_PC3 (1<<13)
490#define HID1_SYNCBE (1<<11)
491#define HID1_ABE (1<<10)
492#define HID1_PS (1<<16)
493#endif
494#define SPRN_HID2 0x3F8
495#define SPRN_HID2_GEKKO 0x398
496#define SPRN_IABR 0x3F2
497#define SPRN_IABR2 0x3FA
498#define SPRN_IBCR 0x135
499#define SPRN_IAMR 0x03D
500#define SPRN_HID4 0x3F4
501#define HID4_LPES0 (1ul << (63-0))
502#define HID4_RMLS2_SH (63 - 2)
503#define HID4_LPID5_SH (63 - 6)
504#define HID4_RMOR_SH (63 - 22)
505#define HID4_RMOR (0xFFFFul << HID4_RMOR_SH)
506#define HID4_LPES1 (1 << (63-57))
507#define HID4_RMLS0_SH (63 - 58)
508#define HID4_LPID1_SH 0
509#define SPRN_HID4_GEKKO 0x3F3
510#define SPRN_HID5 0x3F6
511#define SPRN_HID6 0x3F9
512#define HID6_LB (0x0F<<12)
513#define HID6_DLP (1<<20)
514#define SPRN_TSC_CELL 0x399
515#define TSC_CELL_DEC_ENABLE_0 0x400000
516#define TSC_CELL_DEC_ENABLE_1 0x200000
517#define TSC_CELL_EE_ENABLE 0x100000
518#define TSC_CELL_EE_BOOST 0x080000
519#define SPRN_TSC 0x3FD
520#define SPRN_TST 0x3FC
521#if !defined(SPRN_IAC1) && !defined(SPRN_IAC2)
522#define SPRN_IAC1 0x3F4
523#define SPRN_IAC2 0x3F5
524#endif
525#define SPRN_IBAT0L 0x211
526#define SPRN_IBAT0U 0x210
527#define SPRN_IBAT1L 0x213
528#define SPRN_IBAT1U 0x212
529#define SPRN_IBAT2L 0x215
530#define SPRN_IBAT2U 0x214
531#define SPRN_IBAT3L 0x217
532#define SPRN_IBAT3U 0x216
533#define SPRN_IBAT4L 0x231
534#define SPRN_IBAT4U 0x230
535#define SPRN_IBAT5L 0x233
536#define SPRN_IBAT5U 0x232
537#define SPRN_IBAT6L 0x235
538#define SPRN_IBAT6U 0x234
539#define SPRN_IBAT7L 0x237
540#define SPRN_IBAT7U 0x236
541#define SPRN_ICMP 0x3D5
542#define SPRN_ICTC 0x3FB
543#define SPRN_ICTRL 0x3F3
544#define ICTRL_EICE 0x08000000
545#define ICTRL_EDC 0x04000000
546#define ICTRL_EICP 0x00000100
547#define SPRN_IMISS 0x3D4
548#define SPRN_IMMR 0x27E
549#define SPRN_L2CR 0x3F9
550#define SPRN_L2CR2 0x3f8
551#define L2CR_L2E 0x80000000
552#define L2CR_L2PE 0x40000000
553#define L2CR_L2SIZ_MASK 0x30000000
554#define L2CR_L2SIZ_256KB 0x10000000
555#define L2CR_L2SIZ_512KB 0x20000000
556#define L2CR_L2SIZ_1MB 0x30000000
557#define L2CR_L2CLK_MASK 0x0e000000
558#define L2CR_L2CLK_DISABLED 0x00000000
559#define L2CR_L2CLK_DIV1 0x02000000
560#define L2CR_L2CLK_DIV1_5 0x04000000
561#define L2CR_L2CLK_DIV2 0x08000000
562#define L2CR_L2CLK_DIV2_5 0x0a000000
563#define L2CR_L2CLK_DIV3 0x0c000000
564#define L2CR_L2RAM_MASK 0x01800000
565#define L2CR_L2RAM_FLOW 0x00000000
566#define L2CR_L2RAM_PIPE 0x01000000
567#define L2CR_L2RAM_PIPE_LW 0x01800000
568#define L2CR_L2DO 0x00400000
569#define L2CR_L2I 0x00200000
570#define L2CR_L2CTL 0x00100000
571#define L2CR_L2WT 0x00080000
572#define L2CR_L2TS 0x00040000
573#define L2CR_L2OH_MASK 0x00030000
574#define L2CR_L2OH_0_5 0x00000000
575#define L2CR_L2OH_1_0 0x00010000
576#define L2CR_L2SL 0x00008000
577#define L2CR_L2DF 0x00004000
578#define L2CR_L2BYP 0x00002000
579#define L2CR_L2IP 0x00000001
580#define L2CR_L2IO_745x 0x00100000
581#define L2CR_L2DO_745x 0x00010000
582#define L2CR_L2REP_745x 0x00001000
583#define L2CR_L2HWF_745x 0x00000800
584#define SPRN_L3CR 0x3FA
585#define L3CR_L3E 0x80000000
586#define L3CR_L3PE 0x40000000
587#define L3CR_L3APE 0x20000000
588#define L3CR_L3SIZ 0x10000000
589#define L3CR_L3CLKEN 0x08000000
590#define L3CR_L3RES 0x04000000
591#define L3CR_L3CLKDIV 0x03800000
592#define L3CR_L3IO 0x00400000
593#define L3CR_L3SPO 0x00040000
594#define L3CR_L3CKSP 0x00030000
595#define L3CR_L3PSP 0x0000e000
596#define L3CR_L3REP 0x00001000
597#define L3CR_L3HWF 0x00000800
598#define L3CR_L3I 0x00000400
599#define L3CR_L3RT 0x00000300
600#define L3CR_L3NIRCA 0x00000080
601#define L3CR_L3DO 0x00000040
602#define L3CR_PMEN 0x00000004
603#define L3CR_PMSIZ 0x00000001
604
605#define SPRN_MSSCR0 0x3f6
606#define SPRN_MSSSR0 0x3f7
607#define SPRN_LDSTCR 0x3f8
608#define SPRN_LDSTDB 0x3f4
609#define SPRN_LR 0x008
610#ifndef SPRN_PIR
611#define SPRN_PIR 0x3FF
612#endif
613#define SPRN_TIR 0x1BE
614#define SPRN_PTCR 0x1D0
615#define SPRN_PSPB 0x09F
616#define SPRN_PTEHI 0x3D5
617#define SPRN_PTELO 0x3D6
618#define SPRN_PURR 0x135
619#define SPRN_PVR 0x11F
620#define SPRN_RPA 0x3D6
621#define SPRN_SDA 0x3BF
622#define SPRN_SDR1 0x019
623#define SPRN_ASR 0x118
624#define SPRN_SIA 0x3BB
625#define SPRN_SPRG0 0x110
626#define SPRN_SPRG1 0x111
627#define SPRN_SPRG2 0x112
628#define SPRN_SPRG3 0x113
629#define SPRN_USPRG3 0x103
630#define SPRN_SPRG4 0x114
631#define SPRN_USPRG4 0x104
632#define SPRN_SPRG5 0x115
633#define SPRN_USPRG5 0x105
634#define SPRN_SPRG6 0x116
635#define SPRN_USPRG6 0x106
636#define SPRN_SPRG7 0x117
637#define SPRN_USPRG7 0x107
638#define SPRN_SRR0 0x01A
639#define SPRN_SRR1 0x01B
640#define SRR1_ISI_NOPT 0x40000000
641#define SRR1_ISI_N_OR_G 0x10000000
642#define SRR1_ISI_PROT 0x08000000
643#define SRR1_WAKEMASK 0x00380000
644#define SRR1_WAKEMASK_P8 0x003c0000
645#define SRR1_WAKESYSERR 0x00300000
646#define SRR1_WAKEEE 0x00200000
647#define SRR1_WAKEMT 0x00280000
648#define SRR1_WAKEHMI 0x00280000
649#define SRR1_WAKEDEC 0x00180000
650#define SRR1_WAKEDBELL 0x00140000
651#define SRR1_WAKETHERM 0x00100000
652#define SRR1_WAKERESET 0x00100000
653#define SRR1_WAKEHDBELL 0x000c0000
654#define SRR1_WAKESTATE 0x00030000
655#define SRR1_WS_DEEPEST 0x00030000
656
657#define SRR1_WS_DEEPER 0x00020000
658#define SRR1_WS_DEEP 0x00010000
659#define SRR1_PROGFPE 0x00100000
660#define SRR1_PROGILL 0x00080000
661#define SRR1_PROGPRIV 0x00040000
662#define SRR1_PROGTRAP 0x00020000
663#define SRR1_PROGADDR 0x00010000
664
665#define SPRN_HSRR0 0x13A
666#define SPRN_HSRR1 0x13B
667#define HSRR1_DENORM 0x00100000
668
669#define SPRN_TBCTL 0x35f
670#define TBCTL_FREEZE 0x0000000000000000ull
671#define TBCTL_RESTART 0x0000000100000000ull
672#define TBCTL_UPDATE_UPPER 0x0000000200000000ull
673#define TBCTL_UPDATE_LOWER 0x0000000300000000ull
674
675#ifndef SPRN_SVR
676#define SPRN_SVR 0x11E
677#endif
678#define SPRN_THRM1 0x3FC
679
680#define THRM1_TIN (1 << 31)
681#define THRM1_TIV (1 << 30)
682#define THRM1_THRES(x) ((x&0x7f)<<23)
683#define THRM3_SITV(x) ((x&0x3fff)<<1)
684#define THRM1_TID (1<<2)
685#define THRM1_TIE (1<<1)
686#define THRM1_V (1<<0)
687#define SPRN_THRM2 0x3FD
688#define SPRN_THRM3 0x3FE
689#define THRM3_E (1<<0)
690#define SPRN_TLBMISS 0x3D4
691#define SPRN_UMMCR0 0x3A8
692#define SPRN_UMMCR1 0x3AC
693#define SPRN_UPMC1 0x3A9
694#define SPRN_UPMC2 0x3AA
695#define SPRN_UPMC3 0x3AD
696#define SPRN_UPMC4 0x3AE
697#define SPRN_USIA 0x3AB
698#define SPRN_VRSAVE 0x100
699#define SPRN_XER 0x001
700
701#define SPRN_MMCR0_GEKKO 0x3B8
702#define SPRN_MMCR1_GEKKO 0x3BC
703#define SPRN_PMC1_GEKKO 0x3B9
704#define SPRN_PMC2_GEKKO 0x3BA
705#define SPRN_PMC3_GEKKO 0x3BD
706#define SPRN_PMC4_GEKKO 0x3BE
707#define SPRN_WPAR_GEKKO 0x399
708
709#define SPRN_SCOMC 0x114
710#define SPRN_SCOMD 0x115
711
712
713#ifdef CONFIG_PPC64
714#define SPRN_MMCR0 795
715#define MMCR0_FC 0x80000000UL
716#define MMCR0_FCS 0x40000000UL
717#define MMCR0_KERNEL_DISABLE MMCR0_FCS
718#define MMCR0_FCP 0x20000000UL
719#define MMCR0_PROBLEM_DISABLE MMCR0_FCP
720#define MMCR0_FCM1 0x10000000UL
721#define MMCR0_FCM0 0x08000000UL
722#define MMCR0_PMXE ASM_CONST(0x04000000)
723#define MMCR0_FCECE ASM_CONST(0x02000000)
724#define MMCR0_TBEE 0x00400000UL
725#define MMCR0_BHRBA 0x00200000UL
726#define MMCR0_EBE 0x00100000UL
727#define MMCR0_PMCC 0x000c0000UL
728#define MMCR0_PMCC_U6 0x00080000UL
729#define MMCR0_PMC1CE 0x00008000UL
730#define MMCR0_PMCjCE ASM_CONST(0x00004000)
731#define MMCR0_TRIGGER 0x00002000UL
732#define MMCR0_PMAO_SYNC ASM_CONST(0x00000800)
733#define MMCR0_C56RUN ASM_CONST(0x00000100)
734
735#define MMCR0_PMAO ASM_CONST(0x00000080)
736#define MMCR0_SHRFC 0x00000040UL
737#define MMCR0_FC56 0x00000010UL
738#define MMCR0_FCTI 0x00000008UL
739#define MMCR0_FCTA 0x00000004UL
740#define MMCR0_FCWAIT 0x00000002UL
741#define MMCR0_FCHV 0x00000001UL
742#define SPRN_MMCR1 798
743#define SPRN_MMCR2 785
744#define SPRN_UMMCR2 769
745#define SPRN_MMCRA 0x312
746#define MMCRA_SDSYNC 0x80000000UL
747#define MMCRA_SDAR_DCACHE_MISS 0x40000000UL
748#define MMCRA_SDAR_ERAT_MISS 0x20000000UL
749#define MMCRA_SIHV 0x10000000UL
750#define MMCRA_SIPR 0x08000000UL
751#define MMCRA_SLOT 0x07000000UL
752#define MMCRA_SLOT_SHIFT 24
753#define MMCRA_SAMPLE_ENABLE 0x00000001UL
754#define POWER6_MMCRA_SDSYNC 0x0000080000000000ULL
755#define POWER6_MMCRA_SIHV 0x0000040000000000ULL
756#define POWER6_MMCRA_SIPR 0x0000020000000000ULL
757#define POWER6_MMCRA_THRM 0x00000020UL
758#define POWER6_MMCRA_OTHER 0x0000000EUL
759
760#define POWER7P_MMCRA_SIAR_VALID 0x10000000
761#define POWER7P_MMCRA_SDAR_VALID 0x08000000
762
763#define SPRN_MMCRH 316
764#define SPRN_MMCRS 894
765#define SPRN_MMCRC 851
766#define SPRN_EBBHR 804
767#define SPRN_EBBRR 805
768#define SPRN_BESCR 806
769#define BESCR_GE 0x8000000000000000ULL
770#define SPRN_WORT 895
771#define SPRN_WORC 863
772
773#define SPRN_PMC1 787
774#define SPRN_PMC2 788
775#define SPRN_PMC3 789
776#define SPRN_PMC4 790
777#define SPRN_PMC5 791
778#define SPRN_PMC6 792
779#define SPRN_PMC7 793
780#define SPRN_PMC8 794
781#define SPRN_SIER 784
782#define SIER_SIPR 0x2000000
783#define SIER_SIHV 0x1000000
784#define SIER_SIAR_VALID 0x0400000
785#define SIER_SDAR_VALID 0x0200000
786#define SPRN_SIAR 796
787#define SPRN_SDAR 797
788#define SPRN_TACR 888
789#define SPRN_TCSCR 889
790#define SPRN_CSIGR 890
791#define SPRN_SPMC1 892
792#define SPRN_SPMC2 893
793
794
795#define MMCR0_USER_MASK (MMCR0_FC | MMCR0_PMXE | MMCR0_PMAO)
796#define MMCR2_USER_MASK 0x4020100804020000UL
797#define SIER_USER_MASK 0x7fffffUL
798
799#define SPRN_PA6T_MMCR0 795
800#define PA6T_MMCR0_EN0 0x0000000000000001UL
801#define PA6T_MMCR0_EN1 0x0000000000000002UL
802#define PA6T_MMCR0_EN2 0x0000000000000004UL
803#define PA6T_MMCR0_EN3 0x0000000000000008UL
804#define PA6T_MMCR0_EN4 0x0000000000000010UL
805#define PA6T_MMCR0_EN5 0x0000000000000020UL
806#define PA6T_MMCR0_SUPEN 0x0000000000000040UL
807#define PA6T_MMCR0_PREN 0x0000000000000080UL
808#define PA6T_MMCR0_HYPEN 0x0000000000000100UL
809#define PA6T_MMCR0_FCM0 0x0000000000000200UL
810#define PA6T_MMCR0_FCM1 0x0000000000000400UL
811#define PA6T_MMCR0_INTGEN 0x0000000000000800UL
812#define PA6T_MMCR0_INTEN0 0x0000000000001000UL
813#define PA6T_MMCR0_INTEN1 0x0000000000002000UL
814#define PA6T_MMCR0_INTEN2 0x0000000000004000UL
815#define PA6T_MMCR0_INTEN3 0x0000000000008000UL
816#define PA6T_MMCR0_INTEN4 0x0000000000010000UL
817#define PA6T_MMCR0_INTEN5 0x0000000000020000UL
818#define PA6T_MMCR0_DISCNT 0x0000000000040000UL
819#define PA6T_MMCR0_UOP 0x0000000000080000UL
820#define PA6T_MMCR0_TRG 0x0000000000100000UL
821#define PA6T_MMCR0_TRGEN 0x0000000000200000UL
822#define PA6T_MMCR0_TRGREG 0x0000000001600000UL
823#define PA6T_MMCR0_SIARLOG 0x0000000002000000UL
824#define PA6T_MMCR0_SDARLOG 0x0000000004000000UL
825#define PA6T_MMCR0_PROEN 0x0000000008000000UL
826#define PA6T_MMCR0_PROLOG 0x0000000010000000UL
827#define PA6T_MMCR0_DAMEN2 0x0000000020000000UL
828#define PA6T_MMCR0_DAMEN3 0x0000000040000000UL
829#define PA6T_MMCR0_DAMEN4 0x0000000080000000UL
830#define PA6T_MMCR0_DAMEN5 0x0000000100000000UL
831#define PA6T_MMCR0_DAMSEL2 0x0000000200000000UL
832#define PA6T_MMCR0_DAMSEL3 0x0000000400000000UL
833#define PA6T_MMCR0_DAMSEL4 0x0000000800000000UL
834#define PA6T_MMCR0_DAMSEL5 0x0000001000000000UL
835#define PA6T_MMCR0_HANDDIS 0x0000002000000000UL
836#define PA6T_MMCR0_PCTEN 0x0000004000000000UL
837#define PA6T_MMCR0_SOCEN 0x0000008000000000UL
838#define PA6T_MMCR0_SOCMOD 0x0000010000000000UL
839
840#define SPRN_PA6T_MMCR1 798
841#define PA6T_MMCR1_ES2 0x00000000000000ffUL
842#define PA6T_MMCR1_ES3 0x000000000000ff00UL
843#define PA6T_MMCR1_ES4 0x0000000000ff0000UL
844#define PA6T_MMCR1_ES5 0x00000000ff000000UL
845
846#define SPRN_PA6T_UPMC0 771
847#define SPRN_PA6T_UPMC1 772
848#define SPRN_PA6T_UPMC2 773
849#define SPRN_PA6T_UPMC3 774
850#define SPRN_PA6T_UPMC4 775
851#define SPRN_PA6T_UPMC5 776
852#define SPRN_PA6T_UMMCR0 779
853#define SPRN_PA6T_SIAR 780
854#define SPRN_PA6T_UMMCR1 782
855#define SPRN_PA6T_SIER 785
856#define SPRN_PA6T_PMC0 787
857#define SPRN_PA6T_PMC1 788
858#define SPRN_PA6T_PMC2 789
859#define SPRN_PA6T_PMC3 790
860#define SPRN_PA6T_PMC4 791
861#define SPRN_PA6T_PMC5 792
862#define SPRN_PA6T_TSR0 793
863#define SPRN_PA6T_TSR1 794
864#define SPRN_PA6T_TSR2 799
865#define SPRN_PA6T_TSR3 784
866
867#define SPRN_PA6T_IER 981
868#define SPRN_PA6T_DER 982
869#define SPRN_PA6T_BER 862
870#define SPRN_PA6T_MER 849
871
872#define SPRN_PA6T_IMA0 880
873#define SPRN_PA6T_IMA1 881
874#define SPRN_PA6T_IMA2 882
875#define SPRN_PA6T_IMA3 883
876#define SPRN_PA6T_IMA4 884
877#define SPRN_PA6T_IMA5 885
878#define SPRN_PA6T_IMA6 886
879#define SPRN_PA6T_IMA7 887
880#define SPRN_PA6T_IMA8 888
881#define SPRN_PA6T_IMA9 889
882#define SPRN_PA6T_BTCR 978
883#define SPRN_PA6T_IMAAT 979
884#define SPRN_PA6T_PCCR 1019
885#define SPRN_BKMK 1020
886#define SPRN_PA6T_RPCCR 1021
887
888
889#else
890#define SPRN_MMCR0 952
891#define MMCR0_FC 0x80000000UL
892#define MMCR0_FCS 0x40000000UL
893#define MMCR0_FCP 0x20000000UL
894#define MMCR0_FCM1 0x10000000UL
895#define MMCR0_FCM0 0x08000000UL
896#define MMCR0_PMXE 0x04000000UL
897#define MMCR0_FCECE 0x02000000UL
898#define MMCR0_TBEE 0x00400000UL
899#define MMCR0_PMC1CE 0x00008000UL
900#define MMCR0_PMCnCE 0x00004000UL
901#define MMCR0_TRIGGER 0x00002000UL
902#define MMCR0_PMC1SEL 0x00001fc0UL
903#define MMCR0_PMC2SEL 0x0000003fUL
904
905#define SPRN_MMCR1 956
906#define MMCR1_PMC3SEL 0xf8000000UL
907#define MMCR1_PMC4SEL 0x07c00000UL
908#define MMCR1_PMC5SEL 0x003e0000UL
909#define MMCR1_PMC6SEL 0x0001f800UL
910#define SPRN_MMCR2 944
911#define SPRN_PMC1 953
912#define SPRN_PMC2 954
913#define SPRN_PMC3 957
914#define SPRN_PMC4 958
915#define SPRN_PMC5 945
916#define SPRN_PMC6 946
917
918#define SPRN_SIAR 955
919
920
921#define MMCR0_PMC1_CYCLES (1 << 7)
922#define MMCR0_PMC1_ICACHEMISS (5 << 7)
923#define MMCR0_PMC1_DTLB (6 << 7)
924#define MMCR0_PMC2_DCACHEMISS 0x6
925#define MMCR0_PMC2_CYCLES 0x1
926#define MMCR0_PMC2_ITLB 0x7
927#define MMCR0_PMC2_LOADMISSTIME 0x5
928#endif
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994#ifdef CONFIG_PPC64
995#define SPRN_SPRG_PACA SPRN_SPRG1
996#else
997#define SPRN_SPRG_THREAD SPRN_SPRG3
998#endif
999
1000#ifdef CONFIG_PPC_BOOK3S_64
1001#define SPRN_SPRG_SCRATCH0 SPRN_SPRG2
1002#define SPRN_SPRG_HPACA SPRN_HSPRG0
1003#define SPRN_SPRG_HSCRATCH0 SPRN_HSPRG1
1004#define SPRN_SPRG_VDSO_READ SPRN_USPRG3
1005#define SPRN_SPRG_VDSO_WRITE SPRN_SPRG3
1006
1007#define GET_PACA(rX) \
1008 BEGIN_FTR_SECTION_NESTED(66); \
1009 mfspr rX,SPRN_SPRG_PACA; \
1010 FTR_SECTION_ELSE_NESTED(66); \
1011 mfspr rX,SPRN_SPRG_HPACA; \
1012 ALT_FTR_SECTION_END_NESTED_IFCLR(CPU_FTR_HVMODE, 66)
1013
1014#define SET_PACA(rX) \
1015 BEGIN_FTR_SECTION_NESTED(66); \
1016 mtspr SPRN_SPRG_PACA,rX; \
1017 FTR_SECTION_ELSE_NESTED(66); \
1018 mtspr SPRN_SPRG_HPACA,rX; \
1019 ALT_FTR_SECTION_END_NESTED_IFCLR(CPU_FTR_HVMODE, 66)
1020
1021#define GET_SCRATCH0(rX) \
1022 BEGIN_FTR_SECTION_NESTED(66); \
1023 mfspr rX,SPRN_SPRG_SCRATCH0; \
1024 FTR_SECTION_ELSE_NESTED(66); \
1025 mfspr rX,SPRN_SPRG_HSCRATCH0; \
1026 ALT_FTR_SECTION_END_NESTED_IFCLR(CPU_FTR_HVMODE, 66)
1027
1028#define SET_SCRATCH0(rX) \
1029 BEGIN_FTR_SECTION_NESTED(66); \
1030 mtspr SPRN_SPRG_SCRATCH0,rX; \
1031 FTR_SECTION_ELSE_NESTED(66); \
1032 mtspr SPRN_SPRG_HSCRATCH0,rX; \
1033 ALT_FTR_SECTION_END_NESTED_IFCLR(CPU_FTR_HVMODE, 66)
1034
1035#else
1036#define GET_SCRATCH0(rX) mfspr rX,SPRN_SPRG_SCRATCH0
1037#define SET_SCRATCH0(rX) mtspr SPRN_SPRG_SCRATCH0,rX
1038
1039#endif
1040
1041#ifdef CONFIG_PPC_BOOK3E_64
1042#define SPRN_SPRG_MC_SCRATCH SPRN_SPRG8
1043#define SPRN_SPRG_CRIT_SCRATCH SPRN_SPRG3
1044#define SPRN_SPRG_DBG_SCRATCH SPRN_SPRG9
1045#define SPRN_SPRG_TLB_EXFRAME SPRN_SPRG2
1046#define SPRN_SPRG_TLB_SCRATCH SPRN_SPRG6
1047#define SPRN_SPRG_GEN_SCRATCH SPRN_SPRG0
1048#define SPRN_SPRG_GDBELL_SCRATCH SPRN_SPRG_GEN_SCRATCH
1049#define SPRN_SPRG_VDSO_READ SPRN_USPRG7
1050#define SPRN_SPRG_VDSO_WRITE SPRN_SPRG7
1051
1052#define SET_PACA(rX) mtspr SPRN_SPRG_PACA,rX
1053#define GET_PACA(rX) mfspr rX,SPRN_SPRG_PACA
1054
1055#endif
1056
1057#ifdef CONFIG_PPC_BOOK3S_32
1058#define SPRN_SPRG_SCRATCH0 SPRN_SPRG0
1059#define SPRN_SPRG_SCRATCH1 SPRN_SPRG1
1060#define SPRN_SPRG_RTAS SPRN_SPRG2
1061#define SPRN_SPRG_603_LRU SPRN_SPRG4
1062#endif
1063
1064#ifdef CONFIG_40x
1065#define SPRN_SPRG_SCRATCH0 SPRN_SPRG0
1066#define SPRN_SPRG_SCRATCH1 SPRN_SPRG1
1067#define SPRN_SPRG_SCRATCH2 SPRN_SPRG2
1068#define SPRN_SPRG_SCRATCH3 SPRN_SPRG4
1069#define SPRN_SPRG_SCRATCH4 SPRN_SPRG5
1070#define SPRN_SPRG_SCRATCH5 SPRN_SPRG6
1071#define SPRN_SPRG_SCRATCH6 SPRN_SPRG7
1072#endif
1073
1074#ifdef CONFIG_BOOKE
1075#define SPRN_SPRG_RSCRATCH0 SPRN_SPRG0
1076#define SPRN_SPRG_WSCRATCH0 SPRN_SPRG0
1077#define SPRN_SPRG_RSCRATCH1 SPRN_SPRG1
1078#define SPRN_SPRG_WSCRATCH1 SPRN_SPRG1
1079#define SPRN_SPRG_RSCRATCH_CRIT SPRN_SPRG2
1080#define SPRN_SPRG_WSCRATCH_CRIT SPRN_SPRG2
1081#define SPRN_SPRG_RSCRATCH2 SPRN_SPRG4R
1082#define SPRN_SPRG_WSCRATCH2 SPRN_SPRG4W
1083#define SPRN_SPRG_RSCRATCH3 SPRN_SPRG5R
1084#define SPRN_SPRG_WSCRATCH3 SPRN_SPRG5W
1085#define SPRN_SPRG_RSCRATCH_MC SPRN_SPRG1
1086#define SPRN_SPRG_WSCRATCH_MC SPRN_SPRG1
1087#define SPRN_SPRG_RSCRATCH4 SPRN_SPRG7R
1088#define SPRN_SPRG_WSCRATCH4 SPRN_SPRG7W
1089#ifdef CONFIG_E200
1090#define SPRN_SPRG_RSCRATCH_DBG SPRN_SPRG6R
1091#define SPRN_SPRG_WSCRATCH_DBG SPRN_SPRG6W
1092#else
1093#define SPRN_SPRG_RSCRATCH_DBG SPRN_SPRG9
1094#define SPRN_SPRG_WSCRATCH_DBG SPRN_SPRG9
1095#endif
1096#endif
1097
1098#ifdef CONFIG_8xx
1099#define SPRN_SPRG_SCRATCH0 SPRN_SPRG0
1100#define SPRN_SPRG_SCRATCH1 SPRN_SPRG1
1101#define SPRN_SPRG_SCRATCH2 SPRN_SPRG2
1102#endif
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112#ifdef CONFIG_PPC64
1113#define MTFSF_L(REG) \
1114 .long (0xfc00058e | ((0xff) << 17) | ((REG) << 11) | (1 << 25))
1115#else
1116#define MTFSF_L(REG) mtfsf 0xff, (REG)
1117#endif
1118
1119
1120
1121#define PVR_VER(pvr) (((pvr) >> 16) & 0xFFFF)
1122#define PVR_REV(pvr) (((pvr) >> 0) & 0xFFFF)
1123
1124#define pvr_version_is(pvr) (PVR_VER(mfspr(SPRN_PVR)) == (pvr))
1125
1126
1127
1128
1129
1130
1131#define PVR_FAM(pvr) (((pvr) >> 20) & 0xFFF)
1132#define PVR_MEM(pvr) (((pvr) >> 16) & 0xF)
1133#define PVR_CORE(pvr) (((pvr) >> 12) & 0xF)
1134#define PVR_CFG(pvr) (((pvr) >> 8) & 0xF)
1135#define PVR_MAJ(pvr) (((pvr) >> 4) & 0xF)
1136#define PVR_MIN(pvr) (((pvr) >> 0) & 0xF)
1137
1138
1139
1140#define PVR_403GA 0x00200000
1141#define PVR_403GB 0x00200100
1142#define PVR_403GC 0x00200200
1143#define PVR_403GCX 0x00201400
1144#define PVR_405GP 0x40110000
1145#define PVR_476 0x11a52000
1146#define PVR_476FPE 0x7ff50000
1147#define PVR_STB03XXX 0x40310000
1148#define PVR_NP405H 0x41410000
1149#define PVR_NP405L 0x41610000
1150#define PVR_601 0x00010000
1151#define PVR_602 0x00050000
1152#define PVR_603 0x00030000
1153#define PVR_603e 0x00060000
1154#define PVR_603ev 0x00070000
1155#define PVR_603r 0x00071000
1156#define PVR_604 0x00040000
1157#define PVR_604e 0x00090000
1158#define PVR_604r 0x000A0000
1159#define PVR_620 0x00140000
1160#define PVR_740 0x00080000
1161#define PVR_750 PVR_740
1162#define PVR_740P 0x10080000
1163#define PVR_750P PVR_740P
1164#define PVR_7400 0x000C0000
1165#define PVR_7410 0x800C0000
1166#define PVR_7450 0x80000000
1167#define PVR_8540 0x80200000
1168#define PVR_8560 0x80200000
1169#define PVR_VER_E500V1 0x8020
1170#define PVR_VER_E500V2 0x8021
1171#define PVR_VER_E500MC 0x8023
1172#define PVR_VER_E5500 0x8024
1173#define PVR_VER_E6500 0x8040
1174
1175
1176
1177
1178
1179
1180
1181#define PVR_821 0x00500000
1182#define PVR_823 PVR_821
1183#define PVR_850 PVR_821
1184#define PVR_860 PVR_821
1185#define PVR_8240 0x00810100
1186#define PVR_8245 0x80811014
1187#define PVR_8260 PVR_8240
1188
1189
1190#define PVR_476_ISS 0x00052000
1191
1192
1193#define PVR_NORTHSTAR 0x0033
1194#define PVR_PULSAR 0x0034
1195#define PVR_POWER4 0x0035
1196#define PVR_ICESTAR 0x0036
1197#define PVR_SSTAR 0x0037
1198#define PVR_POWER4p 0x0038
1199#define PVR_970 0x0039
1200#define PVR_POWER5 0x003A
1201#define PVR_POWER5p 0x003B
1202#define PVR_970FX 0x003C
1203#define PVR_POWER6 0x003E
1204#define PVR_POWER7 0x003F
1205#define PVR_630 0x0040
1206#define PVR_630p 0x0041
1207#define PVR_970MP 0x0044
1208#define PVR_970GX 0x0045
1209#define PVR_POWER7p 0x004A
1210#define PVR_POWER8E 0x004B
1211#define PVR_POWER8NVL 0x004C
1212#define PVR_POWER8 0x004D
1213#define PVR_BE 0x0070
1214#define PVR_PA6T 0x0090
1215
1216
1217#define PVR_ARCH_204 0x0f000001
1218#define PVR_ARCH_205 0x0f000002
1219#define PVR_ARCH_206 0x0f000003
1220#define PVR_ARCH_206p 0x0f100003
1221#define PVR_ARCH_207 0x0f000004
1222
1223
1224#ifndef __ASSEMBLY__
1225#define mfmsr() ({unsigned long rval; \
1226 asm volatile("mfmsr %0" : "=r" (rval) : \
1227 : "memory"); rval;})
1228#ifdef CONFIG_PPC_BOOK3S_64
1229#define __mtmsrd(v, l) asm volatile("mtmsrd %0," __stringify(l) \
1230 : : "r" (v) : "memory")
1231#define mtmsr(v) __mtmsrd((v), 0)
1232#define __MTMSR "mtmsrd"
1233#else
1234#define mtmsr(v) asm volatile("mtmsr %0" : \
1235 : "r" ((unsigned long)(v)) \
1236 : "memory")
1237#define __MTMSR "mtmsr"
1238#endif
1239
1240static inline void mtmsr_isync(unsigned long val)
1241{
1242 asm volatile(__MTMSR " %0; " ASM_FTR_IFCLR("isync", "nop", %1) : :
1243 "r" (val), "i" (CPU_FTR_ARCH_206) : "memory");
1244}
1245
1246#define mfspr(rn) ({unsigned long rval; \
1247 asm volatile("mfspr %0," __stringify(rn) \
1248 : "=r" (rval)); rval;})
1249#ifndef mtspr
1250#define mtspr(rn, v) asm volatile("mtspr " __stringify(rn) ",%0" : \
1251 : "r" ((unsigned long)(v)) \
1252 : "memory")
1253#endif
1254#define wrtspr(rn) asm volatile("mtspr " __stringify(rn) ",0" : \
1255 : : "memory")
1256
1257extern unsigned long msr_check_and_set(unsigned long bits);
1258extern bool strict_msr_control;
1259extern void __msr_check_and_clear(unsigned long bits);
1260static inline void msr_check_and_clear(unsigned long bits)
1261{
1262 if (strict_msr_control)
1263 __msr_check_and_clear(bits);
1264}
1265
1266#ifdef __powerpc64__
1267#if defined(CONFIG_PPC_CELL) || defined(CONFIG_PPC_FSL_BOOK3E)
1268#define mftb() ({unsigned long rval; \
1269 asm volatile( \
1270 "90: mfspr %0, %2;\n" \
1271 "97: cmpwi %0,0;\n" \
1272 " beq- 90b;\n" \
1273 "99:\n" \
1274 ".section __ftr_fixup,\"a\"\n" \
1275 ".align 3\n" \
1276 "98:\n" \
1277 " .llong %1\n" \
1278 " .llong %1\n" \
1279 " .llong 97b-98b\n" \
1280 " .llong 99b-98b\n" \
1281 " .llong 0\n" \
1282 " .llong 0\n" \
1283 ".previous" \
1284 : "=r" (rval) \
1285 : "i" (CPU_FTR_CELL_TB_BUG), "i" (SPRN_TBRL)); \
1286 rval;})
1287#else
1288#define mftb() ({unsigned long rval; \
1289 asm volatile("mfspr %0, %1" : \
1290 "=r" (rval) : "i" (SPRN_TBRL)); rval;})
1291#endif
1292
1293#else
1294
1295#if defined(CONFIG_8xx)
1296#define mftbl() ({unsigned long rval; \
1297 asm volatile("mftbl %0" : "=r" (rval)); rval;})
1298#define mftbu() ({unsigned long rval; \
1299 asm volatile("mftbu %0" : "=r" (rval)); rval;})
1300#else
1301#define mftbl() ({unsigned long rval; \
1302 asm volatile("mfspr %0, %1" : "=r" (rval) : \
1303 "i" (SPRN_TBRL)); rval;})
1304#define mftbu() ({unsigned long rval; \
1305 asm volatile("mfspr %0, %1" : "=r" (rval) : \
1306 "i" (SPRN_TBRU)); rval;})
1307#endif
1308#define mftb() mftbl()
1309#endif
1310
1311#define mttbl(v) asm volatile("mttbl %0":: "r"(v))
1312#define mttbu(v) asm volatile("mttbu %0":: "r"(v))
1313
1314#ifdef CONFIG_PPC32
1315#define mfsrin(v) ({unsigned int rval; \
1316 asm volatile("mfsrin %0,%1" : "=r" (rval) : "r" (v)); \
1317 rval;})
1318#endif
1319
1320#define proc_trap() asm volatile("trap")
1321
1322extern unsigned long current_stack_pointer(void);
1323
1324extern unsigned long scom970_read(unsigned int address);
1325extern void scom970_write(unsigned int address, unsigned long value);
1326
1327struct pt_regs;
1328
1329extern void ppc_save_regs(struct pt_regs *regs);
1330
1331static inline void update_power8_hid0(unsigned long hid0)
1332{
1333
1334
1335
1336
1337
1338 asm volatile("sync; mtspr %0,%1; isync":: "i"(SPRN_HID0), "r"(hid0));
1339}
1340#endif
1341#endif
1342#endif
1343