2 * This file is part of the coreboot project.
4 * Copyright (C) 2014 Imagination Technologies
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 #ifndef __MIPS_ARCH_CPU_H
21 #define __MIPS_ARCH_CPU_H
27 #include <device/device.h>
30 struct device_operations
*ops
;
31 struct cpu_device_id
*id_table
;
41 #endif /* !__PRE_RAM__ */
43 /***************************************************************************
44 * The following section was copied from arch/mips/include/asm/mipsregs.h in
45 * the 3.14 kernel tree.
49 * Macros to access the system control coprocessor
52 #define __read_32bit_c0_register(source, sel) \
55 __asm__ __volatile__( \
56 "mfc0\t%0, " #source "\n\t" \
59 __asm__ __volatile__( \
61 "mfc0\t%0, " #source ", " #sel "\n\t" \
67 #define __write_32bit_c0_register(register, sel, value) \
70 __asm__ __volatile__( \
71 "mtc0\t%z0, " #register "\n\t" \
72 : : "Jr" ((unsigned int)(value))); \
74 __asm__ __volatile__( \
76 "mtc0\t%z0, " #register ", " #sel "\n\t" \
78 : : "Jr" ((unsigned int)(value))); \
81 /* Shortcuts to access various internal registers, keep adding as needed. */
82 #define read_c0_index() __read_32bit_c0_register($0, 0)
83 #define write_c0_index(val) __write_32bit_c0_register($0, 0, (val))
85 #define read_c0_entrylo0() __read_32bit_c0_register($2, 0)
86 #define write_c0_entrylo0(val) __write_32bit_c0_register($2, 0, (val))
88 #define read_c0_entrylo1() __read_32bit_c0_register($3, 0)
89 #define write_c0_entrylo1(val) __write_32bit_c0_register($3, 0, (val))
91 #define read_c0_pagemask() __read_32bit_c0_register($5, 0)
92 #define write_c0_pagemask(val) __write_32bit_c0_register($5, 0, (val))
94 #define read_c0_wired() __read_32bit_c0_register($6, 0)
95 #define write_c0_wired(val) __write_32bit_c0_register($6, 0, (val))
97 #define read_c0_count() __read_32bit_c0_register($9, 0)
98 #define write_c0_count(val) __write_32bit_c0_register($9, 0, (val))
100 #define read_c0_entryhi() __read_32bit_c0_register($10, 0)
101 #define write_c0_entryhi(val) __write_32bit_c0_register($10, 0, (val))
103 #define read_c0_cause() __read_32bit_c0_register($13, 0)
104 #define write_c0_cause(val) __write_32bit_c0_register($13, 0, (val))
106 #define read_c0_config1() __read_32bit_c0_register($16, 1)
107 #define write_c0_config1(val) __write_32bit_c0_register($16, 1, (val))
109 #define read_c0_config2() __read_32bit_c0_register($16, 2)
110 #define write_c0_config2(val) __write_32bit_c0_register($16, 2, (val))
112 #define read_c0_l23taglo() __read_32bit_c0_register($28, 4)
113 #define write_c0_l23taglo(val) __write_32bit_c0_register($28, 4, (val))
116 #define C0_ENTRYLO_PFN_SHIFT 6
117 #define C0_ENTRYLO_WB (0x3 << 3) /* Cacheable, write-back, non-coherent */
118 #define C0_ENTRYLO_D (0x1 << 2) /* Writeable */
119 #define C0_ENTRYLO_V (0x1 << 1) /* Valid */
120 #define C0_ENTRYLO_G (0x1 << 0) /* Global */
122 #define C0_PAGEMASK_SHIFT 13
123 #define C0_PAGEMASK_MASK 0xffff
125 #define C0_WIRED_MASK 0x3f
127 #define C0_CAUSE_DC (1 << 27)
129 #define C0_CONFIG1_MMUSIZE_SHIFT 25
130 #define C0_CONFIG1_MMUSIZE_MASK 0x3f
132 /* Hazard handling */
133 static inline void __nop(void)
135 __asm__
__volatile__("nop");
138 static inline void __ssnop(void)
140 __asm__
__volatile__("sll\t$0, $0, 1");
143 #define mtc0_tlbw_hazard() \
149 #define tlbw_use_hazard() \
156 #define tlb_probe_hazard() \
163 #define back_to_back_c0_hazard() \
169 /**************************************************************************/
171 #endif /* __MIPS_ARCH_CPU_H */