cpu_setup_power.S 2.6 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
/*
 * This file contains low level CPU setup functions.
 *    Copyright (C) 2003 Benjamin Herrenschmidt (benh@kernel.crashing.org)
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version
 * 2 of the License, or (at your option) any later version.
 *
 */

#include <asm/processor.h>
#include <asm/page.h>
#include <asm/cputable.h>
#include <asm/ppc_asm.h>
#include <asm/asm-offsets.h>
#include <asm/cache.h>

/* Entry: r3 = crap, r4 = ptr to cputable entry
 *
 * Note that we can be called twice for pseudo-PVRs
 */
_GLOBAL(__setup_cpu_power7)
	mflr	r11
	bl	__init_hvmode_206
	mtlr	r11
	beqlr
28 29
	li	r0,0
	mtspr	SPRN_LPID,r0
30
	mfspr	r3,SPRN_LPCR
31
	bl	__init_LPCR
32
	bl	__init_TLB
33 34 35 36 37 38 39 40
	mtlr	r11
	blr

_GLOBAL(__restore_cpu_power7)
	mflr	r11
	mfmsr	r3
	rldicl.	r0,r3,4,63
	beqlr
41 42
	li	r0,0
	mtspr	SPRN_LPID,r0
43
	mfspr	r3,SPRN_LPCR
44
	bl	__init_LPCR
M
Michael Neuling 已提交
45 46 47 48 49 50
	bl	__init_TLB
	mtlr	r11
	blr

_GLOBAL(__setup_cpu_power8)
	mflr	r11
51
	bl	__init_FSCR
M
Michael Neuling 已提交
52 53 54 55 56
	bl	__init_hvmode_206
	mtlr	r11
	beqlr
	li	r0,0
	mtspr	SPRN_LPID,r0
57
	mfspr	r3,SPRN_LPCR
58
	oris	r3, r3, LPCR_AIL_3@h
M
Michael Neuling 已提交
59
	bl	__init_LPCR
60
	bl	__init_HFSCR
M
Michael Neuling 已提交
61 62 63 64 65 66
	bl	__init_TLB
	mtlr	r11
	blr

_GLOBAL(__restore_cpu_power8)
	mflr	r11
67
	bl	__init_FSCR
M
Michael Neuling 已提交
68 69 70 71 72
	mfmsr	r3
	rldicl.	r0,r3,4,63
	beqlr
	li	r0,0
	mtspr	SPRN_LPID,r0
73
	mfspr   r3,SPRN_LPCR
74
	oris	r3, r3, LPCR_AIL_3@h
M
Michael Neuling 已提交
75
	bl	__init_LPCR
76
	bl	__init_HFSCR
77
	bl	__init_TLB
78 79 80 81
	mtlr	r11
	blr

__init_hvmode_206:
82
	/* Disable CPU_FTR_HVMODE and exit if MSR:HV is not set */
83 84 85 86
	mfmsr	r3
	rldicl.	r0,r3,4,63
	bnelr
	ld	r5,CPU_SPEC_FEATURES(r4)
87
	LOAD_REG_IMMEDIATE(r6,CPU_FTR_HVMODE)
88 89 90 91 92 93
	xor	r5,r5,r6
	std	r5,CPU_SPEC_FEATURES(r4)
	blr

__init_LPCR:
	/* Setup a sane LPCR:
94
	 *   Called with initial LPCR in R3
95
	 *
96
	 *   LPES = 0b01 (HSRR0/1 used for 0x500)
97
	 *   PECE = 0b111
98
	 *   DPFD = 4
99 100 101
	 *   HDICE = 0
	 *   VC = 0b100 (VPM0=1, VPM1=0, ISL=0)
	 *   VRMASD = 0b10000 (L=1, LP=00)
102 103 104
	 *
	 * Other bits untouched for now
	 */
105 106
	li	r5,1
	rldimi	r3,r5, LPCR_LPES_SH, 64-LPCR_LPES_SH-2
107
	ori	r3,r3,(LPCR_PECE0|LPCR_PECE1|LPCR_PECE2)
108
	li	r5,4
109 110 111 112 113 114
	rldimi	r3,r5, LPCR_DPFD_SH, 64-LPCR_DPFD_SH-3
	clrrdi	r3,r3,1		/* clear HDICE */
	li	r5,4
	rldimi	r3,r5, LPCR_VC_SH, 0
	li	r5,0x10
	rldimi	r3,r5, LPCR_VRMASD_SH, 64-LPCR_VRMASD_SH-5
115 116 117
	mtspr	SPRN_LPCR,r3
	isync
	blr
118

119 120
__init_FSCR:
	mfspr	r3,SPRN_FSCR
121
	ori	r3,r3,FSCR_TAR|FSCR_DSCR
122 123 124
	mtspr	SPRN_FSCR,r3
	blr

125 126 127 128 129 130
__init_HFSCR:
	mfspr	r3,SPRN_HFSCR
	ori	r3,r3,HFSCR_TAR|HFSCR_TM|HFSCR_DSCR|HFSCR_VECVSX|HFSCR_FP
	mtspr	SPRN_HFSCR,r3
	blr

131 132 133 134 135 136 137 138 139 140 141
__init_TLB:
	/* Clear the TLB */
	li	r6,128
	mtctr	r6
	li	r7,0xc00	/* IS field = 0b11 */
	ptesync
2:	tlbiel	r7
	addi	r7,r7,0x1000
	bdnz	2b
	ptesync
1:	blr