summaryrefslogtreecommitdiff
path: root/arch/arm/mach-tegra/power-macros.S
blob: 386bec1737e54ab676197562fe1d11f92d8e5901 (plain)
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
 * arch/arm/mach-tegra/power-macros.S
 *
 * Assembly macros useful for power state save / restore routines
 *
 * Copyright (c) 2010, NVIDIA Corporation.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

/* returns the ID of the current processor */
.macro	cpu_id, rd
	mrc	p15, 0, \rd, c0, c0, 5
	and	\rd, \rd, #0xF
.endm


.macro mov32, reg, val
	movw	\reg, #:lower16:\val
	movt	\reg, #:upper16:\val
.endm

/* waits until the microsecond counter (base) ticks, for exact timing loops */
.macro	wait_for_us, rd, base, tmp
	ldr	\rd, [\base]
1001:	ldr	\tmp, [\base]
	cmp	\rd, \tmp
	beq	1001b
	mov	\rd, \tmp
.endm

/* waits until the microsecond counter (base) is >= rn */
.macro	wait_until, rn, base, tmp
1002:	ldr	\tmp, [\base]
	sub	\tmp, \tmp, \rn
	ands	\tmp, \tmp, #0x80000000
	dmb
	bne	1002b
.endm