blob: 56391fbae1e11625280614d6e7e75abd77111274 [file] [log] [blame]
Catalin Marinas72c58392014-07-24 14:14:42 +01001/*
2 * Macros for accessing system registers with older binutils.
3 *
4 * Copyright (C) 2014 ARM Ltd.
5 * Author: Catalin Marinas <catalin.marinas@arm.com>
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef __ASM_SYSREG_H
21#define __ASM_SYSREG_H
22
James Morse870828e2015-07-21 13:23:27 +010023#define SCTLR_EL1_CP15BEN (0x1 << 5)
24#define SCTLR_EL1_SED (0x1 << 8)
25
Catalin Marinas72c58392014-07-24 14:14:42 +010026#define sys_reg(op0, op1, crn, crm, op2) \
27 ((((op0)-2)<<19)|((op1)<<16)|((crn)<<12)|((crm)<<8)|((op2)<<5))
28
29#ifdef __ASSEMBLY__
30
31 .irp num,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30
32 .equ __reg_num_x\num, \num
33 .endr
34 .equ __reg_num_xzr, 31
35
36 .macro mrs_s, rt, sreg
37 .inst 0xd5300000|(\sreg)|(__reg_num_\rt)
38 .endm
39
40 .macro msr_s, sreg, rt
41 .inst 0xd5100000|(\sreg)|(__reg_num_\rt)
42 .endm
43
44#else
45
46asm(
47" .irp num,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30\n"
48" .equ __reg_num_x\\num, \\num\n"
49" .endr\n"
50" .equ __reg_num_xzr, 31\n"
51"\n"
52" .macro mrs_s, rt, sreg\n"
53" .inst 0xd5300000|(\\sreg)|(__reg_num_\\rt)\n"
54" .endm\n"
55"\n"
56" .macro msr_s, sreg, rt\n"
57" .inst 0xd5100000|(\\sreg)|(__reg_num_\\rt)\n"
58" .endm\n"
59);
60
James Morse870828e2015-07-21 13:23:27 +010061static inline void config_sctlr_el1(u32 clear, u32 set)
62{
63 u32 val;
64
65 asm volatile("mrs %0, sctlr_el1" : "=r" (val));
66 val &= ~clear;
67 val |= set;
68 asm volatile("msr sctlr_el1, %0" : : "r" (val));
69}
Catalin Marinas72c58392014-07-24 14:14:42 +010070#endif
71
72#endif /* __ASM_SYSREG_H */