blob: 85863741ef8bb6d5b6c0fa9199036557ac3aa734 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * SA11x0 Assembler Sleep/WakeUp Management Routines
3 *
4 * Copyright (c) 2001 Cliff Brake <cbrake@accelent.com>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License.
8 *
9 * History:
10 *
11 * 2001-02-06: Cliff Brake Initial code
12 *
13 * 2001-08-29: Nicolas Pitre Simplified.
14 *
15 * 2002-05-27: Nicolas Pitre Revisited, more cleanup and simplification.
16 * Storage is on the stack now.
17 */
18
19#include <linux/linkage.h>
20#include <asm/assembler.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010021#include <mach/hardware.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070022
Linus Torvalds1da177e2005-04-16 15:20:36 -070023 .text
Linus Torvalds1da177e2005-04-16 15:20:36 -070024/*
Russell King34c79de2011-06-21 16:26:29 +010025 * sa1100_finish_suspend()
Linus Torvalds1da177e2005-04-16 15:20:36 -070026 *
27 * Causes sa11x0 to enter sleep state
28 *
Russell Kingf3bb3d72012-01-23 18:39:21 +000029 * Must be aligned to a cacheline.
Linus Torvalds1da177e2005-04-16 15:20:36 -070030 */
Russell Kingf3bb3d72012-01-23 18:39:21 +000031 .balign 32
Russell King34c79de2011-06-21 16:26:29 +010032ENTRY(sa1100_finish_suspend)
Linus Torvalds1da177e2005-04-16 15:20:36 -070033 @ disable clock switching
34 mcr p15, 0, r1, c15, c2, 2
35
Russell Kingf3bb3d72012-01-23 18:39:21 +000036 ldr r6, =MDREFR
37 ldr r4, [r6]
38 orr r4, r4, #MDREFR_K1DB2
39 ldr r5, =PPCR
40
Will Deacond0a533b2012-07-06 15:47:17 +010041 @ Pre-load __loop_udelay into the I-cache
Russell Kingf3bb3d72012-01-23 18:39:21 +000042 mov r0, #1
Will Deacond0a533b2012-07-06 15:47:17 +010043 bl __loop_udelay
Russell Kingf3bb3d72012-01-23 18:39:21 +000044 mov r0, r0
45
46 @ The following must all exist in a single cache line to
47 @ avoid accessing memory until this sequence is complete,
48 @ otherwise we occasionally hang.
49
50 @ Adjust memory timing before lowering CPU clock
51 str r4, [r6]
Linus Torvalds1da177e2005-04-16 15:20:36 -070052
53 @ delay 90us and set CPU PLL to lowest speed
54 @ fixes resume problem on high speed SA1110
55 mov r0, #90
Will Deacond0a533b2012-07-06 15:47:17 +010056 bl __loop_udelay
Linus Torvalds1da177e2005-04-16 15:20:36 -070057 mov r1, #0
Russell Kingf3bb3d72012-01-23 18:39:21 +000058 str r1, [r5]
Linus Torvalds1da177e2005-04-16 15:20:36 -070059 mov r0, #90
Will Deacond0a533b2012-07-06 15:47:17 +010060 bl __loop_udelay
Linus Torvalds1da177e2005-04-16 15:20:36 -070061
62 /*
63 * SA1110 SDRAM controller workaround. register values:
64 *
65 * r0 = &MSC0
66 * r1 = &MSC1
67 * r2 = &MSC2
68 * r3 = MSC0 value
69 * r4 = MSC1 value
70 * r5 = MSC2 value
71 * r6 = &MDREFR
72 * r7 = first MDREFR value
73 * r8 = second MDREFR value
74 * r9 = &MDCNFG
75 * r10 = MDCNFG value
76 * r11 = third MDREFR value
77 * r12 = &PMCR
78 * r13 = PMCR value (1)
79 */
80
81 ldr r0, =MSC0
82 ldr r1, =MSC1
83 ldr r2, =MSC2
84
Kristoffer Ericson93982532008-11-26 20:58:43 +010085 ldr r3, [r0]
86 bic r3, r3, #FMsk(MSC_RT)
87 bic r3, r3, #FMsk(MSC_RT)<<16
Linus Torvalds1da177e2005-04-16 15:20:36 -070088
Kristoffer Ericson93982532008-11-26 20:58:43 +010089 ldr r4, [r1]
90 bic r4, r4, #FMsk(MSC_RT)
91 bic r4, r4, #FMsk(MSC_RT)<<16
Linus Torvalds1da177e2005-04-16 15:20:36 -070092
Kristoffer Ericson93982532008-11-26 20:58:43 +010093 ldr r5, [r2]
94 bic r5, r5, #FMsk(MSC_RT)
95 bic r5, r5, #FMsk(MSC_RT)<<16
Linus Torvalds1da177e2005-04-16 15:20:36 -070096
Kristoffer Ericson93982532008-11-26 20:58:43 +010097 ldr r7, [r6]
Russell Kingf3bb3d72012-01-23 18:39:21 +000098 bic r7, r7, #0x0000FF00
99 bic r7, r7, #0x000000F0
100 orr r8, r7, #MDREFR_SLFRSH
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101
Kristoffer Ericson93982532008-11-26 20:58:43 +0100102 ldr r9, =MDCNFG
103 ldr r10, [r9]
104 bic r10, r10, #(MDCNFG_DE0+MDCNFG_DE1)
105 bic r10, r10, #(MDCNFG_DE2+MDCNFG_DE3)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106
Kristoffer Ericson93982532008-11-26 20:58:43 +0100107 bic r11, r8, #MDREFR_SLFRSH
108 bic r11, r11, #MDREFR_E1PIN
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109
Kristoffer Ericson93982532008-11-26 20:58:43 +0100110 ldr r12, =PMCR
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111
Kristoffer Ericson93982532008-11-26 20:58:43 +0100112 mov r13, #PMCR_SF
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113
114 b sa1110_sdram_controller_fix
115
116 .align 5
117sa1110_sdram_controller_fix:
118
119 @ Step 1 clear RT field of all MSCx registers
120 str r3, [r0]
121 str r4, [r1]
122 str r5, [r2]
123
124 @ Step 2 clear DRI field in MDREFR
125 str r7, [r6]
126
127 @ Step 3 set SLFRSH bit in MDREFR
128 str r8, [r6]
129
130 @ Step 4 clear DE bis in MDCNFG
131 str r10, [r9]
132
133 @ Step 5 clear DRAM refresh control register
134 str r11, [r6]
135
136 @ Wow, now the hardware suspend request pins can be used, that makes them functional for
137 @ about 7 ns out of the entire time that the CPU is running!
138
139 @ Step 6 set force sleep bit in PMCR
140
141 str r13, [r12]
142
14320: b 20b @ loop waiting for sleep