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 _GLOBAL(__setup_cpu_e6500)
97 bl .setup_altivec_ivors
98 /* Touch IVOR42 only if the CPU supports E.HV category */
100 rlwinm. r10,r10,0,MMUCFG_LPIDSIZE
106 bl setup_altivec_idle
112 _GLOBAL(__setup_cpu_e200)
113 /* enable dedicated debug exception handling resources (Debug APU) */
115 ori r3,r3,HID0_DAPUEN@l
118 _GLOBAL(__setup_cpu_e500v1)
119 _GLOBAL(__setup_cpu_e500v2)
121 bl __e500_icache_setup
122 bl __e500_dcache_setup
123 bl __setup_e500_ivors
124 #if defined(CONFIG_FSL_RIO) || defined(CONFIG_FSL_PCI)
125 /* Ensure that RFXE is set */
127 oris r3,r3,HID1_RFXE@h
132 _GLOBAL(__setup_cpu_e500mc)
133 _GLOBAL(__setup_cpu_e5500)
135 bl __e500_icache_setup
136 bl __e500_dcache_setup
137 bl __setup_e500mc_ivors
139 * We only want to touch IVOR38-41 if we're running on hardware
140 * that supports category E.HV. The architectural way to determine
141 * this is MMUCFG[LPIDSIZE].
143 mfspr r3, SPRN_MMUCFG
144 rlwinm. r3, r3, 0, MMUCFG_LPIDSIZE
149 lwz r3, CPU_SPEC_FEATURES(r4)
150 /* We need this check as cpu_setup is also called for
151 * the secondary cores. So, if we have already cleared
152 * the feature on the primary core, avoid doing it on the
155 andis. r6, r3, CPU_FTR_EMB_HV@h
157 rlwinm r3, r3, 0, ~CPU_FTR_EMB_HV
158 stw r3, CPU_SPEC_FEATURES(r4)
164 #ifdef CONFIG_PPC_BOOK3E_64
165 _GLOBAL(__restore_cpu_e6500)
167 bl .setup_altivec_ivors
168 /* Touch IVOR42 only if the CPU supports E.HV category */
169 mfspr r10,SPRN_MMUCFG
170 rlwinm. r10,r10,0,MMUCFG_LPIDSIZE
175 bl .setup_altivec_idle
176 bl __restore_cpu_e5500
180 _GLOBAL(__restore_cpu_e5500)
182 bl __e500_icache_setup
183 bl __e500_dcache_setup
184 bl .__setup_base_ivors
185 bl .setup_perfmon_ivor
186 bl .setup_doorbell_ivors
188 * We only want to touch IVOR38-41 if we're running on hardware
189 * that supports category E.HV. The architectural way to determine
190 * this is MMUCFG[LPIDSIZE].
192 mfspr r10,SPRN_MMUCFG
193 rlwinm. r10,r10,0,MMUCFG_LPIDSIZE
200 _GLOBAL(__setup_cpu_e5500)
202 bl __e500_icache_setup
203 bl __e500_dcache_setup
204 bl .__setup_base_ivors
205 bl .setup_perfmon_ivor
206 bl .setup_doorbell_ivors
208 * We only want to touch IVOR38-41 if we're running on hardware
209 * that supports category E.HV. The architectural way to determine
210 * this is MMUCFG[LPIDSIZE].
212 mfspr r10,SPRN_MMUCFG
213 rlwinm. r10,r10,0,MMUCFG_LPIDSIZE
218 ld r10,CPU_SPEC_FEATURES(r4)
219 LOAD_REG_IMMEDIATE(r9,CPU_FTR_EMB_HV)
221 std r10,CPU_SPEC_FEATURES(r4)