1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * This file contains low level CPU setup functions.
4 * Copyright (C) 2003 Benjamin Herrenschmidt (benh@kernel.crashing.org)
7 #include <asm/processor.h>
9 #include <asm/cputable.h>
10 #include <asm/ppc_asm.h>
11 #include <asm/asm-offsets.h>
12 #include <asm/cache.h>
14 _GLOBAL(__cpu_preinit_ppc970)
15 /* Do nothing if not running in HV mode */
20 /* Make sure HID4:rm_ci is off before MMU is turned off, that large
21 * pages are enabled with HID4:61 and clear HID5:DCBZ_size and
26 rldimi r3,r0,40,23 /* clear bit 23 (rm_ci) */
27 rldimi r3,r0,2,61 /* clear bit 61 (lg_pg_en) */
33 rldimi r3,r0,6,56 /* clear bits 56 & 57 (DCBZ*) */
39 /* Setup some basic HID1 features */
41 li r3,0x1200 /* enable i-fetch cacheability */
42 sldi r3,r3,44 /* and prefetch */
51 mtspr SPRN_HIOR,0 /* Clear interrupt prefix */
55 /* Definitions for the table use to save CPU states */
63 .balign L1_CACHE_BYTES,0
66 .balign L1_CACHE_BYTES,0
70 _GLOBAL(__setup_cpu_ppc970)
71 /* Do nothing if not running in HV mode */
77 li r11,5 /* clear DOZE and SLEEP */
78 rldimi r0,r11,52,8 /* set NAP and DPM */
80 rldimi r0,r11,32,31 /* clear EN_ATTN */
81 b load_hids /* Jump to shared code */
84 _GLOBAL(__setup_cpu_ppc970MP)
85 /* Do nothing if not running in HV mode */
91 li r11,0x15 /* clear DOZE and SLEEP */
92 rldimi r0,r11,52,6 /* set DEEPNAP, NAP and DPM */
94 rldimi r0,r11,32,31 /* clear EN_ATTN */
107 /* Try to set LPES = 01 in HID4 */
109 clrldi r0,r0,1 /* clear LPES0 */
110 ori r0,r0,HID4_LPES1 /* set LPES1 */
115 /* Save away cpu state */
116 LOAD_REG_ADDR(r5,cpu_state_storage)
118 /* Save HID0,1,4 and 5 */
128 /* See if we successfully set LPES1 to 1; if not we are in Apple mode */
129 andi. r4,r4,HID4_LPES1
133 /* Disable CPU_FTR_HVMODE and exit, since we don't have HV mode */
134 ld r5,CPU_SPEC_FEATURES(r4)
135 LOAD_REG_IMMEDIATE(r6,CPU_FTR_HVMODE)
137 std r5,CPU_SPEC_FEATURES(r4)
140 /* Called with no MMU context (typically MSR:IR/DR off) to
141 * restore CPU state as backed up by the previous
142 * function. This does not include cache setting
144 _GLOBAL(__restore_cpu_ppc970)
145 /* Do nothing if not running in HV mode */
150 LOAD_REG_ADDR(r5,cpu_state_storage)
151 /* Before accessing memory, we make sure rm_ci is clear */
154 rldimi r3,r0,40,23 /* clear bit 23 (rm_ci) */
160 /* Clear interrupt prefix */