xref: /freebsd-src/sys/arm/include/cpuinfo.h (revision 95ee2897e98f5d444f26ed2334cc7c439f9c16c6)
12b71562fSIan Lepore /*-
22b71562fSIan Lepore  * Copyright 2014 Svatopluk Kraus <onwahe@gmail.com>
32b71562fSIan Lepore  * Copyright 2014 Michal Meloun <meloun@miracle.cz>
42b71562fSIan Lepore  * All rights reserved.
52b71562fSIan Lepore  *
62b71562fSIan Lepore  * Redistribution and use in source and binary forms, with or without
72b71562fSIan Lepore  * modification, are permitted provided that the following conditions
82b71562fSIan Lepore  * are met:
92b71562fSIan Lepore  * 1. Redistributions of source code must retain the above copyright
102b71562fSIan Lepore  *    notice, this list of conditions and the following disclaimer.
112b71562fSIan Lepore  * 2. Redistributions in binary form must reproduce the above copyright
122b71562fSIan Lepore  *    notice, this list of conditions and the following disclaimer in the
132b71562fSIan Lepore  *    documentation and/or other materials provided with the distribution.
142b71562fSIan Lepore  *
152b71562fSIan Lepore  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
162b71562fSIan Lepore  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
172b71562fSIan Lepore  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
182b71562fSIan Lepore  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
192b71562fSIan Lepore  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
202b71562fSIan Lepore  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
212b71562fSIan Lepore  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
222b71562fSIan Lepore  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
232b71562fSIan Lepore  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
242b71562fSIan Lepore  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
252b71562fSIan Lepore  * SUCH DAMAGE.
262b71562fSIan Lepore  */
272b71562fSIan Lepore 
282b71562fSIan Lepore #ifndef	_MACHINE_CPUINFO_H_
292b71562fSIan Lepore #define	_MACHINE_CPUINFO_H_
302b71562fSIan Lepore 
312b71562fSIan Lepore #include <sys/types.h>
322b71562fSIan Lepore 
33935c21a1SIan Lepore #define CPU_IMPLEMENTER_ARM		0x41
34935c21a1SIan Lepore #define CPU_IMPLEMENTER_QCOM		0x51
35935c21a1SIan Lepore #define CPU_IMPLEMENTER_MRVL		0x56
36935c21a1SIan Lepore 
37935c21a1SIan Lepore /* ARM */
38935c21a1SIan Lepore #define CPU_ARCH_ARM1176		0xB76
39935c21a1SIan Lepore #define CPU_ARCH_CORTEX_A5		0xC05
40935c21a1SIan Lepore #define CPU_ARCH_CORTEX_A7		0xC07
41935c21a1SIan Lepore #define CPU_ARCH_CORTEX_A8		0xC08
42935c21a1SIan Lepore #define CPU_ARCH_CORTEX_A9		0xC09
43935c21a1SIan Lepore #define CPU_ARCH_CORTEX_A12		0xC0D
44935c21a1SIan Lepore #define CPU_ARCH_CORTEX_A15		0xC0F
45935c21a1SIan Lepore #define CPU_ARCH_CORTEX_A17		0xC11
4655e447c9SMichal Meloun #define CPU_ARCH_CORTEX_A53		0xD03
4755e447c9SMichal Meloun #define CPU_ARCH_CORTEX_A57		0xD07
4855e447c9SMichal Meloun #define CPU_ARCH_CORTEX_A72		0xD08
49ba0bb206SMichal Meloun #define CPU_ARCH_CORTEX_A73		0xD09
50*a36b6ec0SMichal Meloun #define CPU_ARCH_CORTEX_A75		0xD0A
5155e447c9SMichal Meloun 
52935c21a1SIan Lepore /* QCOM */
53935c21a1SIan Lepore #define CPU_ARCH_KRAIT_300		0x06F
54935c21a1SIan Lepore 
5555e447c9SMichal Meloun /* MRVL */
56ba0bb206SMichal Meloun #define CPU_ARCH_SHEEVA_581		0x581	/* PJ4/PJ4B */
5755e447c9SMichal Meloun #define CPU_ARCH_SHEEVA_584		0x584 	/* PJ4B-MP/PJ4C */
5855e447c9SMichal Meloun 
592b71562fSIan Lepore struct cpuinfo {
602b71562fSIan Lepore 	/* raw id registers */
612b71562fSIan Lepore 	uint32_t midr;
622b71562fSIan Lepore 	uint32_t ctr;
632b71562fSIan Lepore 	uint32_t tcmtr;
642b71562fSIan Lepore 	uint32_t tlbtr;
652b71562fSIan Lepore 	uint32_t mpidr;
662b71562fSIan Lepore 	uint32_t revidr;
672b71562fSIan Lepore 	uint32_t id_pfr0;
682b71562fSIan Lepore 	uint32_t id_pfr1;
692b71562fSIan Lepore 	uint32_t id_dfr0;
702b71562fSIan Lepore 	uint32_t id_afr0;
712b71562fSIan Lepore 	uint32_t id_mmfr0;
722b71562fSIan Lepore 	uint32_t id_mmfr1;
732b71562fSIan Lepore 	uint32_t id_mmfr2;
742b71562fSIan Lepore 	uint32_t id_mmfr3;
752b71562fSIan Lepore 	uint32_t id_isar0;
762b71562fSIan Lepore 	uint32_t id_isar1;
772b71562fSIan Lepore 	uint32_t id_isar2;
782b71562fSIan Lepore 	uint32_t id_isar3;
792b71562fSIan Lepore 	uint32_t id_isar4;
802b71562fSIan Lepore 	uint32_t id_isar5;
812b71562fSIan Lepore 	uint32_t cbar;
82ba0bb206SMichal Meloun 	uint32_t ccsidr;
83ba0bb206SMichal Meloun 	uint32_t clidr;
842b71562fSIan Lepore 
852b71562fSIan Lepore 	/* Parsed bits of above registers... */
862b71562fSIan Lepore 
872b71562fSIan Lepore 	/* midr */
882b71562fSIan Lepore 	int implementer;
892b71562fSIan Lepore 	int revision;
902b71562fSIan Lepore 	int architecture;
912b71562fSIan Lepore 	int part_number;
922b71562fSIan Lepore 	int patch;
932b71562fSIan Lepore 
942b71562fSIan Lepore 	/* id_mmfr0 */
952b71562fSIan Lepore 	int outermost_shareability;
962b71562fSIan Lepore 	int shareability_levels;
972b71562fSIan Lepore 	int auxiliary_registers;
982b71562fSIan Lepore 	int innermost_shareability;
992b71562fSIan Lepore 
1002b71562fSIan Lepore 	/* id_mmfr1 */
1012b71562fSIan Lepore 	int mem_barrier;
1022b71562fSIan Lepore 
1032b71562fSIan Lepore 	/* id_mmfr3 */
1042b71562fSIan Lepore 	int coherent_walk;
1052b71562fSIan Lepore 	int maintenance_broadcast;
1062b71562fSIan Lepore 
1072b71562fSIan Lepore 	/* id_pfr1 */
1082b71562fSIan Lepore 	int generic_timer_ext;
1092b71562fSIan Lepore 	int virtualization_ext;
1102b71562fSIan Lepore 	int security_ext;
111a286c311SIan Lepore 
112a286c311SIan Lepore 	/* L1 cache info */
113a286c311SIan Lepore 	int dcache_line_size;
114a286c311SIan Lepore 	int dcache_line_mask;
115a286c311SIan Lepore 	int icache_line_size;
116a286c311SIan Lepore 	int icache_line_mask;
117d029cb61SAndrew Turner 
118d029cb61SAndrew Turner 	/* mpidr */
119d029cb61SAndrew Turner 	int mp_ext;
1202b71562fSIan Lepore };
1212b71562fSIan Lepore 
1222b71562fSIan Lepore extern struct cpuinfo cpuinfo;
1232b71562fSIan Lepore 
1242b71562fSIan Lepore void cpuinfo_init(void);
125*a36b6ec0SMichal Meloun void cpuinfo_init_bp_hardening(void);
1267bf5720aSMichal Meloun void cpuinfo_reinit_mmu(uint32_t ttb);
1272b71562fSIan Lepore #endif	/* _MACHINE_CPUINFO_H_ */
128