summaryrefslogtreecommitdiff
path: root/drivers/soc/bcm/brcmstb/pm/s2-arm.S
blob: 1d472d56463813e981b75194cb58d0a792f0eede (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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
 * Copyright © 2014-2017 Broadcom
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 *
 * 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.
 */

#include <linux/linkage.h>
#include <asm/assembler.h>

#include "pm.h"

	.text
	.align	3

#define AON_CTRL_REG		r10
#define DDR_PHY_STATUS_REG	r11

/*
 * r0: AON_CTRL base address
 * r1: DDRY PHY PLL status register address
 */
ENTRY(brcmstb_pm_do_s2)
	stmfd	sp!, {r4-r11, lr}
	mov	AON_CTRL_REG, r0
	mov	DDR_PHY_STATUS_REG, r1

	/* Flush memory transactions */
	dsb

	/* Cache DDR_PHY_STATUS_REG translation */
	ldr	r0, [DDR_PHY_STATUS_REG]

	/* power down request */
	ldr	r0, =PM_S2_COMMAND
	ldr	r1, =0
	str	r1, [AON_CTRL_REG, #AON_CTRL_PM_CTRL]
	ldr	r1, [AON_CTRL_REG, #AON_CTRL_PM_CTRL]
	str	r0, [AON_CTRL_REG, #AON_CTRL_PM_CTRL]
	ldr	r0, [AON_CTRL_REG, #AON_CTRL_PM_CTRL]

	/* Wait for interrupt */
	wfi
	nop

	/* Bring MEMC back up */
1:	ldr	r0, [DDR_PHY_STATUS_REG]
	ands	r0, #1
	beq	1b

	/* Power-up handshake */
	ldr	r0, =1
	str	r0, [AON_CTRL_REG, #AON_CTRL_HOST_MISC_CMDS]
	ldr	r0, [AON_CTRL_REG, #AON_CTRL_HOST_MISC_CMDS]

	ldr	r0, =0
	str	r0, [AON_CTRL_REG, #AON_CTRL_PM_CTRL]
	ldr	r0, [AON_CTRL_REG, #AON_CTRL_PM_CTRL]

	/* Return to caller */
	ldr	r0, =0
	ldmfd	sp!, {r4-r11, pc}

	ENDPROC(brcmstb_pm_do_s2)

	/* Place literal pool here */
	.ltorg

ENTRY(brcmstb_pm_do_s2_sz)
	.word   . - brcmstb_pm_do_s2