Merge remote branch 'common/android-2.6.36' into android-tegra-2.6.36
[firefly-linux-kernel-4.4.55.git] / arch / arm / mach-tegra / power-macros.S
1 /*
2  * arch/arm/mach-tegra/power-macros.S
3  *
4  * Assembly macros useful for power state save / restore routines
5  *
6  * Copyright (c) 2010, NVIDIA Corporation.
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
16  * more details.
17  *
18  * You should have received a copy of the GNU General Public License along
19  * with this program; if not, write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21  */
22
23 /* returns the ID of the current processor */
24 .macro  cpu_id, rd
25         mrc     p15, 0, \rd, c0, c0, 5
26         and     \rd, \rd, #0xF
27 .endm
28
29
30 .macro mov32, reg, val
31         movw    \reg, #:lower16:\val
32         movt    \reg, #:upper16:\val
33 .endm
34
35 /* waits until the microsecond counter (base) ticks, for exact timing loops */
36 .macro  wait_for_us, rd, base, tmp
37         ldr     \rd, [\base]
38 1001:   ldr     \tmp, [\base]
39         cmp     \rd, \tmp
40         beq     1001b
41         mov     \tmp, \rd
42 .endm
43
44 /* waits until the microsecond counter (base) is >= rn */
45 .macro  wait_until, rn, base, tmp
46 1002:   ldr     \tmp, [\base]
47         sub     \tmp, \tmp, \rn
48         ands    \tmp, \tmp, #0x80000000
49         dmb
50         bne     1002b
51 .endm
52
53 /* Enable Coresight access on cpu */
54 .macro  enable_coresite, tmp
55         mov32   \tmp, 0xC5ACCE55
56         mcr     p14, 0, \tmp, c7, c12, 6
57 .endm