2 * This file contains low level CPU setup functions.
3 * Kumar Gala <galak@kernel.crashing.org>
4 * Copyright 2009 Freescale Semiconductor, Inc.
6 * Based on cpu_setup_6xx code by
7 * Benjamin Herrenschmidt <benh@kernel.crashing.org>
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version
12 * 2 of the License, or (at your option) any later version.
16 #include <asm/processor.h>
17 #include <asm/cputable.h>
18 #include <asm/ppc_asm.h>
19 #include <asm/mmu-book3e.h>
20 #include <asm/asm-offsets.h>
22 _GLOBAL(__e500_icache_setup)
24 andi. r3, r0, L1CSR1_ICE
25 bnelr /* Already enabled */
26 oris r0, r0, L1CSR1_CPE@h
27 ori r0, r0, (L1CSR1_ICFI | L1CSR1_ICLFR | L1CSR1_ICE)
28 mtspr SPRN_L1CSR1, r0 /* Enable I-Cache */
32 _GLOBAL(__e500_dcache_setup)
34 andi. r3, r0, L1CSR0_DCE
35 bnelr /* Already enabled */
39 mtspr SPRN_L1CSR0, r0 /* Disable */
42 li r0, (L1CSR0_DCFI | L1CSR0_CLFC)
43 mtspr SPRN_L1CSR0, r0 /* Invalidate */
45 1: mfspr r0, SPRN_L1CSR0
46 andi. r3, r0, L1CSR0_CLFC
47 bne+ 1b /* Wait for lock bits reset */
48 oris r0, r0, L1CSR0_CPE@h
49 ori r0, r0, L1CSR0_DCE
52 mtspr SPRN_L1CSR0, r0 /* Enable */
57 * FIXME - we haven't yet done testing to determine a reasonable default
58 * value for PW20_WAIT_IDLE_BIT.
60 #define PW20_WAIT_IDLE_BIT 50 /* 1ms, TB frequency is 41.66MHZ */
61 _GLOBAL(setup_pw20_idle)
62 mfspr r3, SPRN_PWRMGTCR0
64 /* Set PW20_WAIT bit, enable pw20 state*/
65 ori r3, r3, PWRMGTCR0_PW20_WAIT
66 li r11, PW20_WAIT_IDLE_BIT
68 /* Set Automatic PW20 Core Idle Count */
69 rlwimi r3, r11, PWRMGTCR0_PW20_ENT_SHIFT, PWRMGTCR0_PW20_ENT
71 mtspr SPRN_PWRMGTCR0, r3
76 * FIXME - we haven't yet done testing to determine a reasonable default
77 * value for AV_WAIT_IDLE_BIT.
79 #define AV_WAIT_IDLE_BIT 50 /* 1ms, TB frequency is 41.66MHZ */
80 _GLOBAL(setup_altivec_idle)
81 mfspr r3, SPRN_PWRMGTCR0
83 /* Enable Altivec Idle */
84 oris r3, r3, PWRMGTCR0_AV_IDLE_PD_EN@h
85 li r11, AV_WAIT_IDLE_BIT
87 /* Set Automatic AltiVec Idle Count */
88 rlwimi r3, r11, PWRMGTCR0_AV_IDLE_CNT_SHIFT, PWRMGTCR0_AV_IDLE_CNT
90 mtspr SPRN_PWRMGTCR0, r3
94 #ifdef CONFIG_PPC_E500MC
95 _GLOBAL(__setup_cpu_e6500)
98 bl setup_altivec_ivors
99 /* Touch IVOR42 only if the CPU supports E.HV category */
100 mfspr r10,SPRN_MMUCFG
101 rlwinm. r10,r10,0,MMUCFG_LPIDSIZE
107 bl setup_altivec_idle
111 #endif /* CONFIG_PPC_E500MC */
115 _GLOBAL(__setup_cpu_e200)
116 /* enable dedicated debug exception handling resources (Debug APU) */
118 ori r3,r3,HID0_DAPUEN@l
121 #endif /* CONFIG_E200 */
124 #ifndef CONFIG_PPC_E500MC
125 _GLOBAL(__setup_cpu_e500v1)
126 _GLOBAL(__setup_cpu_e500v2)
128 bl __e500_icache_setup
129 bl __e500_dcache_setup
130 bl __setup_e500_ivors
131 #if defined(CONFIG_FSL_RIO) || defined(CONFIG_FSL_PCI)
132 /* Ensure that RFXE is set */
134 oris r3,r3,HID1_RFXE@h
139 #else /* CONFIG_PPC_E500MC */
140 _GLOBAL(__setup_cpu_e500mc)
141 _GLOBAL(__setup_cpu_e5500)
143 bl __e500_icache_setup
144 bl __e500_dcache_setup
145 bl __setup_e500mc_ivors
147 * We only want to touch IVOR38-41 if we're running on hardware
148 * that supports category E.HV. The architectural way to determine
149 * this is MMUCFG[LPIDSIZE].
151 mfspr r3, SPRN_MMUCFG
152 rlwinm. r3, r3, 0, MMUCFG_LPIDSIZE
157 lwz r3, CPU_SPEC_FEATURES(r4)
158 /* We need this check as cpu_setup is also called for
159 * the secondary cores. So, if we have already cleared
160 * the feature on the primary core, avoid doing it on the
163 andis. r6, r3, CPU_FTR_EMB_HV@h
165 rlwinm r3, r3, 0, ~CPU_FTR_EMB_HV
166 stw r3, CPU_SPEC_FEATURES(r4)
170 #endif /* CONFIG_PPC_E500MC */
171 #endif /* CONFIG_E500 */
172 #endif /* CONFIG_PPC32 */
174 #ifdef CONFIG_PPC_BOOK3E_64
175 _GLOBAL(__restore_cpu_e6500)
177 bl setup_altivec_ivors
178 /* Touch IVOR42 only if the CPU supports E.HV category */
179 mfspr r10,SPRN_MMUCFG
180 rlwinm. r10,r10,0,MMUCFG_LPIDSIZE
185 bl setup_altivec_idle
186 bl __restore_cpu_e5500
190 _GLOBAL(__restore_cpu_e5500)
192 bl __e500_icache_setup
193 bl __e500_dcache_setup
194 bl __setup_base_ivors
195 bl setup_perfmon_ivor
196 bl setup_doorbell_ivors
198 * We only want to touch IVOR38-41 if we're running on hardware
199 * that supports category E.HV. The architectural way to determine
200 * this is MMUCFG[LPIDSIZE].
202 mfspr r10,SPRN_MMUCFG
203 rlwinm. r10,r10,0,MMUCFG_LPIDSIZE
210 _GLOBAL(__setup_cpu_e5500)
212 bl __e500_icache_setup
213 bl __e500_dcache_setup
214 bl __setup_base_ivors
215 bl setup_perfmon_ivor
216 bl setup_doorbell_ivors
218 * We only want to touch IVOR38-41 if we're running on hardware
219 * that supports category E.HV. The architectural way to determine
220 * this is MMUCFG[LPIDSIZE].
222 mfspr r10,SPRN_MMUCFG
223 rlwinm. r10,r10,0,MMUCFG_LPIDSIZE
228 ld r10,CPU_SPEC_FEATURES(r4)
229 LOAD_REG_IMMEDIATE(r9,CPU_FTR_EMB_HV)
231 std r10,CPU_SPEC_FEATURES(r4)