blob: 5131bb3d4fcd5408a9522c626d318014cbd78d9e [file] [log] [blame]
Vineet Guptaac4c2442013-01-18 15:12:16 +05301/*
2 * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
8
9#ifndef _ASM_ARC_ARCREGS_H
10#define _ASM_ARC_ARCREGS_H
11
12#ifdef __KERNEL__
13
Vineet Guptabacdf482013-01-18 15:12:18 +053014/* Build Configuration Registers */
15#define ARC_REG_VECBASE_BCR 0x68
16
Vineet Guptaac4c2442013-01-18 15:12:16 +053017/* status32 Bits Positions */
18#define STATUS_H_BIT 0 /* CPU Halted */
19#define STATUS_E1_BIT 1 /* Int 1 enable */
20#define STATUS_E2_BIT 2 /* Int 2 enable */
21#define STATUS_A1_BIT 3 /* Int 1 active */
22#define STATUS_A2_BIT 4 /* Int 2 active */
23#define STATUS_AE_BIT 5 /* Exception active */
24#define STATUS_DE_BIT 6 /* PC is in delay slot */
25#define STATUS_U_BIT 7 /* User/Kernel mode */
26#define STATUS_L_BIT 12 /* Loop inhibit */
27
28/* These masks correspond to the status word(STATUS_32) bits */
29#define STATUS_H_MASK (1<<STATUS_H_BIT)
30#define STATUS_E1_MASK (1<<STATUS_E1_BIT)
31#define STATUS_E2_MASK (1<<STATUS_E2_BIT)
32#define STATUS_A1_MASK (1<<STATUS_A1_BIT)
33#define STATUS_A2_MASK (1<<STATUS_A2_BIT)
34#define STATUS_AE_MASK (1<<STATUS_AE_BIT)
35#define STATUS_DE_MASK (1<<STATUS_DE_BIT)
36#define STATUS_U_MASK (1<<STATUS_U_BIT)
37#define STATUS_L_MASK (1<<STATUS_L_BIT)
38
39/* Auxiliary registers */
40#define AUX_IDENTITY 4
41#define AUX_INTR_VEC_BASE 0x25
42#define AUX_IRQ_LEV 0x200 /* IRQ Priority: L1 or L2 */
43#define AUX_IRQ_HINT 0x201 /* For generating Soft Interrupts */
44#define AUX_IRQ_LV12 0x43 /* interrupt level register */
45
46#define AUX_IENABLE 0x40c
47#define AUX_ITRIGGER 0x40d
48#define AUX_IPULSE 0x415
49
Vineet Guptad8005e62013-01-18 15:12:18 +053050/* Timer related Aux registers */
51#define ARC_REG_TIMER0_LIMIT 0x23 /* timer 0 limit */
52#define ARC_REG_TIMER0_CTRL 0x22 /* timer 0 control */
53#define ARC_REG_TIMER0_CNT 0x21 /* timer 0 count */
54#define ARC_REG_TIMER1_LIMIT 0x102 /* timer 1 limit */
55#define ARC_REG_TIMER1_CTRL 0x101 /* timer 1 control */
56#define ARC_REG_TIMER1_CNT 0x100 /* timer 1 count */
57
58#define TIMER_CTRL_IE (1 << 0) /* Interupt when Count reachs limit */
59#define TIMER_CTRL_NH (1 << 1) /* Count only when CPU NOT halted */
60
Vineet Guptabf90e1e2013-01-18 15:12:18 +053061/*
62 * Floating Pt Registers
63 * Status regs are read-only (build-time) so need not be saved/restored
64 */
65#define ARC_AUX_FP_STAT 0x300
66#define ARC_AUX_DPFP_1L 0x301
67#define ARC_AUX_DPFP_1H 0x302
68#define ARC_AUX_DPFP_2L 0x303
69#define ARC_AUX_DPFP_2H 0x304
70#define ARC_AUX_DPFP_STAT 0x305
71
Vineet Guptaac4c2442013-01-18 15:12:16 +053072#ifndef __ASSEMBLY__
73
74/*
75 ******************************************************************
76 * Inline ASM macros to read/write AUX Regs
77 * Essentially invocation of lr/sr insns from "C"
78 */
79
80#if 1
81
82#define read_aux_reg(reg) __builtin_arc_lr(reg)
83
84/* gcc builtin sr needs reg param to be long immediate */
85#define write_aux_reg(reg_immed, val) \
86 __builtin_arc_sr((unsigned int)val, reg_immed)
87
88#else
89
90#define read_aux_reg(reg) \
91({ \
92 unsigned int __ret; \
93 __asm__ __volatile__( \
94 " lr %0, [%1]" \
95 : "=r"(__ret) \
96 : "i"(reg)); \
97 __ret; \
98})
99
100/*
101 * Aux Reg address is specified as long immediate by caller
102 * e.g.
103 * write_aux_reg(0x69, some_val);
104 * This generates tightest code.
105 */
106#define write_aux_reg(reg_imm, val) \
107({ \
108 __asm__ __volatile__( \
109 " sr %0, [%1] \n" \
110 : \
111 : "ir"(val), "i"(reg_imm)); \
112})
113
114/*
115 * Aux Reg address is specified in a variable
116 * * e.g.
117 * reg_num = 0x69
118 * write_aux_reg2(reg_num, some_val);
119 * This has to generate glue code to load the reg num from
120 * memory to a reg hence not recommended.
121 */
122#define write_aux_reg2(reg_in_var, val) \
123({ \
124 unsigned int tmp; \
125 \
126 __asm__ __volatile__( \
127 " ld %0, [%2] \n\t" \
128 " sr %1, [%0] \n\t" \
129 : "=&r"(tmp) \
130 : "r"(val), "memory"(&reg_in_var)); \
131})
132
133#endif
134
Vineet Guptabf90e1e2013-01-18 15:12:18 +0530135#ifdef CONFIG_ARC_FPU_SAVE_RESTORE
136/* These DPFP regs need to be saved/restored across ctx-sw */
137struct arc_fpu {
138 struct {
139 unsigned int l, h;
140 } aux_dpfp[2];
141};
142#endif
143
Vineet Guptaac4c2442013-01-18 15:12:16 +0530144#endif /* __ASEMBLY__ */
145
146#endif /* __KERNEL__ */
147
148#endif /* _ASM_ARC_ARCREGS_H */