Linux 4.16.11
[linux/fpc-iii.git] / drivers / soc / bcm / brcmstb / pm / s2-arm.S
blob1d472d56463813e981b75194cb58d0a792f0eede
1 /*
2  * Copyright © 2014-2017 Broadcom
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  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  */
14 #include <linux/linkage.h>
15 #include <asm/assembler.h>
17 #include "pm.h"
19         .text
20         .align  3
22 #define AON_CTRL_REG            r10
23 #define DDR_PHY_STATUS_REG      r11
26  * r0: AON_CTRL base address
27  * r1: DDRY PHY PLL status register address
28  */
29 ENTRY(brcmstb_pm_do_s2)
30         stmfd   sp!, {r4-r11, lr}
31         mov     AON_CTRL_REG, r0
32         mov     DDR_PHY_STATUS_REG, r1
34         /* Flush memory transactions */
35         dsb
37         /* Cache DDR_PHY_STATUS_REG translation */
38         ldr     r0, [DDR_PHY_STATUS_REG]
40         /* power down request */
41         ldr     r0, =PM_S2_COMMAND
42         ldr     r1, =0
43         str     r1, [AON_CTRL_REG, #AON_CTRL_PM_CTRL]
44         ldr     r1, [AON_CTRL_REG, #AON_CTRL_PM_CTRL]
45         str     r0, [AON_CTRL_REG, #AON_CTRL_PM_CTRL]
46         ldr     r0, [AON_CTRL_REG, #AON_CTRL_PM_CTRL]
48         /* Wait for interrupt */
49         wfi
50         nop
52         /* Bring MEMC back up */
53 1:      ldr     r0, [DDR_PHY_STATUS_REG]
54         ands    r0, #1
55         beq     1b
57         /* Power-up handshake */
58         ldr     r0, =1
59         str     r0, [AON_CTRL_REG, #AON_CTRL_HOST_MISC_CMDS]
60         ldr     r0, [AON_CTRL_REG, #AON_CTRL_HOST_MISC_CMDS]
62         ldr     r0, =0
63         str     r0, [AON_CTRL_REG, #AON_CTRL_PM_CTRL]
64         ldr     r0, [AON_CTRL_REG, #AON_CTRL_PM_CTRL]
66         /* Return to caller */
67         ldr     r0, =0
68         ldmfd   sp!, {r4-r11, pc}
70         ENDPROC(brcmstb_pm_do_s2)
72         /* Place literal pool here */
73         .ltorg
75 ENTRY(brcmstb_pm_do_s2_sz)
76         .word   . - brcmstb_pm_do_s2