diff options
Diffstat (limited to 'arch/arm/mach-tegra/asm_macros.h')
-rw-r--r-- | arch/arm/mach-tegra/asm_macros.h | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/arch/arm/mach-tegra/asm_macros.h b/arch/arm/mach-tegra/asm_macros.h new file mode 100644 index 00000000000..2463d797ce3 --- /dev/null +++ b/arch/arm/mach-tegra/asm_macros.h | |||
@@ -0,0 +1,72 @@ | |||
1 | /* | ||
2 | * arch/arm/mach-tegra/include/mach/asm_macros.h | ||
3 | * | ||
4 | * Copyright (C) 2011 NVIDIA Corporation | ||
5 | * | ||
6 | * This software is licensed under the terms of the GNU General Public | ||
7 | * License version 2, as published by the Free Software Foundation, and | ||
8 | * may be copied, distributed, and modified under those terms. | ||
9 | * | ||
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. | ||
14 | * | ||
15 | */ | ||
16 | |||
17 | #ifndef _MACH_TEGRA_ASM_MACROS_H_ | ||
18 | #define _MACH_TEGRA_ASM_MACROS_H_ | ||
19 | |||
20 | #ifdef __ASSEMBLY__ | ||
21 | |||
22 | /* waits until the microsecond counter (base) ticks, for exact timing loops */ | ||
23 | .macro wait_for_us, rd, base, tmp | ||
24 | ldr \rd, [\base] | ||
25 | 1001: ldr \tmp, [\base] | ||
26 | cmp \rd, \tmp | ||
27 | beq 1001b | ||
28 | mov \tmp, \rd | ||
29 | .endm | ||
30 | |||
31 | /* waits until the microsecond counter (base) is > rn */ | ||
32 | .macro wait_until, rn, base, tmp | ||
33 | add \rn, \rn, #1 | ||
34 | 1002: ldr \tmp, [\base] | ||
35 | sub \tmp, \tmp, \rn | ||
36 | ands \tmp, \tmp, #0x80000000 | ||
37 | dmb | ||
38 | bne 1002b | ||
39 | .endm | ||
40 | |||
41 | /* returns the offset of the flow controller halt register for a cpu */ | ||
42 | .macro cpu_to_halt_reg rd, rcpu | ||
43 | cmp \rcpu, #0 | ||
44 | subne \rd, \rcpu, #1 | ||
45 | movne \rd, \rd, lsl #3 | ||
46 | addne \rd, \rd, #0x14 | ||
47 | moveq \rd, #0 | ||
48 | .endm | ||
49 | |||
50 | /* returns the offset of the flow controller csr register for a cpu */ | ||
51 | .macro cpu_to_csr_reg rd, rcpu | ||
52 | cmp \rcpu, #0 | ||
53 | subne \rd, \rcpu, #1 | ||
54 | movne \rd, \rd, lsl #3 | ||
55 | addne \rd, \rd, #0x18 | ||
56 | moveq \rd, #8 | ||
57 | .endm | ||
58 | |||
59 | /* returns the ID of the current processor */ | ||
60 | .macro cpu_id, rd | ||
61 | mrc p15, 0, \rd, c0, c0, 5 | ||
62 | and \rd, \rd, #0xF | ||
63 | .endm | ||
64 | |||
65 | /* loads a 32-bit value into a register without a data access */ | ||
66 | .macro mov32, reg, val | ||
67 | movw \reg, #:lower16:\val | ||
68 | movt \reg, #:upper16:\val | ||
69 | .endm | ||
70 | |||
71 | #endif | ||
72 | #endif | ||