Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1 | /* |
Michael Hennerich | 14b0320 | 2008-05-07 11:41:26 +0800 | [diff] [blame] | 2 | * Copyright 2004-2008 Analog Devices Inc. |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 3 | * |
Michael Hennerich | 14b0320 | 2008-05-07 11:41:26 +0800 | [diff] [blame] | 4 | * Licensed under the GPL-2 or later. |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <linux/linkage.h> |
| 8 | #include <asm/blackfin.h> |
Bryan Wu | 639f657 | 2008-08-27 10:51:02 +0800 | [diff] [blame] | 9 | #include <mach/irq.h> |
Michael Hennerich | 1efc80b | 2008-07-19 16:57:32 +0800 | [diff] [blame] | 10 | #include <asm/dpmc.h> |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 11 | |
| 12 | .section .l1.text |
Steven Miao | 93f8951 | 2012-05-16 18:26:10 +0800 | [diff] [blame^] | 13 | #ifndef CONFIG_BF60x |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 14 | ENTRY(_sleep_mode) |
Mike Frysinger | da31d6f | 2011-06-27 15:43:56 -0400 | [diff] [blame] | 15 | [--SP] = (R7:4, P5:3); |
| 16 | [--SP] = RETS; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 17 | |
| 18 | call _set_sic_iwr; |
| 19 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 20 | P0.H = hi(PLL_CTL); |
| 21 | P0.L = lo(PLL_CTL); |
| 22 | R1 = W[P0](z); |
| 23 | BITSET (R1, 3); |
| 24 | W[P0] = R1.L; |
| 25 | |
| 26 | CLI R2; |
| 27 | SSYNC; |
| 28 | IDLE; |
| 29 | STI R2; |
| 30 | |
| 31 | call _test_pll_locked; |
| 32 | |
| 33 | R0 = IWR_ENABLE(0); |
Michael Hennerich | cfefe3c | 2008-02-09 04:12:37 +0800 | [diff] [blame] | 34 | R1 = IWR_DISABLE_ALL; |
| 35 | R2 = IWR_DISABLE_ALL; |
| 36 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 37 | call _set_sic_iwr; |
| 38 | |
| 39 | P0.H = hi(PLL_CTL); |
| 40 | P0.L = lo(PLL_CTL); |
| 41 | R7 = w[p0](z); |
| 42 | BITCLR (R7, 3); |
| 43 | BITCLR (R7, 5); |
| 44 | w[p0] = R7.L; |
| 45 | IDLE; |
| 46 | call _test_pll_locked; |
| 47 | |
| 48 | RETS = [SP++]; |
Mike Frysinger | da31d6f | 2011-06-27 15:43:56 -0400 | [diff] [blame] | 49 | (R7:4, P5:3) = [SP++]; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 50 | RTS; |
Mike Frysinger | 1a8caee | 2008-07-16 17:07:26 +0800 | [diff] [blame] | 51 | ENDPROC(_sleep_mode) |
Steven Miao | 93f8951 | 2012-05-16 18:26:10 +0800 | [diff] [blame^] | 52 | #endif |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 53 | |
Mike Frysinger | eed7b83 | 2011-06-26 23:11:19 -0400 | [diff] [blame] | 54 | /* |
| 55 | * This func never returns as it puts the part into hibernate, and |
| 56 | * is only called from do_hibernate, so we don't bother saving or |
| 57 | * restoring any of the normal C runtime state. When we wake up, |
| 58 | * the entry point will be in do_hibernate and not here. |
| 59 | * |
| 60 | * We accept just one argument -- the value to write to VR_CTL. |
| 61 | */ |
Steven Miao | 93f8951 | 2012-05-16 18:26:10 +0800 | [diff] [blame^] | 62 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 63 | ENTRY(_hibernate_mode) |
Mike Frysinger | eed7b83 | 2011-06-26 23:11:19 -0400 | [diff] [blame] | 64 | /* Save/setup the regs we need early for minor pipeline optimization */ |
| 65 | R4 = R0; |
Steven Miao | 93f8951 | 2012-05-16 18:26:10 +0800 | [diff] [blame^] | 66 | |
| 67 | #ifndef CONFIG_BF60x |
Mike Frysinger | eed7b83 | 2011-06-26 23:11:19 -0400 | [diff] [blame] | 68 | P3.H = hi(VR_CTL); |
| 69 | P3.L = lo(VR_CTL); |
Mike Frysinger | eed7b83 | 2011-06-26 23:11:19 -0400 | [diff] [blame] | 70 | /* Disable all wakeup sources */ |
Michael Hennerich | 1efc80b | 2008-07-19 16:57:32 +0800 | [diff] [blame] | 71 | R0 = IWR_DISABLE_ALL; |
| 72 | R1 = IWR_DISABLE_ALL; |
| 73 | R2 = IWR_DISABLE_ALL; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 74 | call _set_sic_iwr; |
Michael Hennerich | 1efc80b | 2008-07-19 16:57:32 +0800 | [diff] [blame] | 75 | call _set_dram_srfs; |
| 76 | SSYNC; |
Steven Miao | 93f8951 | 2012-05-16 18:26:10 +0800 | [diff] [blame^] | 77 | #endif |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 78 | |
Mike Frysinger | eed7b83 | 2011-06-26 23:11:19 -0400 | [diff] [blame] | 79 | /* Finally, we climb into our cave to hibernate */ |
| 80 | W[P3] = R4.L; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 81 | CLI R2; |
| 82 | IDLE; |
Michael Hennerich | 1efc80b | 2008-07-19 16:57:32 +0800 | [diff] [blame] | 83 | .Lforever: |
| 84 | jump .Lforever; |
Mike Frysinger | 1a8caee | 2008-07-16 17:07:26 +0800 | [diff] [blame] | 85 | ENDPROC(_hibernate_mode) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 86 | |
Steven Miao | 93f8951 | 2012-05-16 18:26:10 +0800 | [diff] [blame^] | 87 | #ifndef CONFIG_BF60x |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 88 | ENTRY(_sleep_deeper) |
Mike Frysinger | da31d6f | 2011-06-27 15:43:56 -0400 | [diff] [blame] | 89 | [--SP] = (R7:4, P5:3); |
| 90 | [--SP] = RETS; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 91 | |
| 92 | CLI R4; |
| 93 | |
| 94 | P3 = R0; |
Michael Hennerich | cfefe3c | 2008-02-09 04:12:37 +0800 | [diff] [blame] | 95 | P4 = R1; |
| 96 | P5 = R2; |
| 97 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 98 | R0 = IWR_ENABLE(0); |
Michael Hennerich | cfefe3c | 2008-02-09 04:12:37 +0800 | [diff] [blame] | 99 | R1 = IWR_DISABLE_ALL; |
| 100 | R2 = IWR_DISABLE_ALL; |
| 101 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 102 | call _set_sic_iwr; |
Michael Hennerich | 4521ef4 | 2008-01-11 17:21:41 +0800 | [diff] [blame] | 103 | call _set_dram_srfs; /* Set SDRAM Self Refresh */ |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 104 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 105 | P0.H = hi(PLL_DIV); |
| 106 | P0.L = lo(PLL_DIV); |
| 107 | R6 = W[P0](z); |
| 108 | R0.L = 0xF; |
Michael Hennerich | 4521ef4 | 2008-01-11 17:21:41 +0800 | [diff] [blame] | 109 | W[P0] = R0.l; /* Set Max VCO to SCLK divider */ |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 110 | |
| 111 | P0.H = hi(PLL_CTL); |
| 112 | P0.L = lo(PLL_CTL); |
| 113 | R5 = W[P0](z); |
Robin Getz | f16295e | 2007-08-03 18:07:17 +0800 | [diff] [blame] | 114 | R0.L = (CONFIG_MIN_VCO_HZ/CONFIG_CLKIN_HZ) << 9; |
Michael Hennerich | 4521ef4 | 2008-01-11 17:21:41 +0800 | [diff] [blame] | 115 | W[P0] = R0.l; /* Set Min CLKIN to VCO multiplier */ |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 116 | |
| 117 | SSYNC; |
| 118 | IDLE; |
| 119 | |
| 120 | call _test_pll_locked; |
| 121 | |
| 122 | P0.H = hi(VR_CTL); |
| 123 | P0.L = lo(VR_CTL); |
| 124 | R7 = W[P0](z); |
| 125 | R1 = 0x6; |
| 126 | R1 <<= 16; |
| 127 | R2 = 0x0404(Z); |
| 128 | R1 = R1|R2; |
| 129 | |
| 130 | R2 = DEPOSIT(R7, R1); |
Michael Hennerich | 4521ef4 | 2008-01-11 17:21:41 +0800 | [diff] [blame] | 131 | W[P0] = R2; /* Set Min Core Voltage */ |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 132 | |
| 133 | SSYNC; |
| 134 | IDLE; |
| 135 | |
| 136 | call _test_pll_locked; |
| 137 | |
Michael Hennerich | 4521ef4 | 2008-01-11 17:21:41 +0800 | [diff] [blame] | 138 | R0 = P3; |
Michael Hennerich | cfefe3c | 2008-02-09 04:12:37 +0800 | [diff] [blame] | 139 | R1 = P4; |
| 140 | R3 = P5; |
Michael Hennerich | 4521ef4 | 2008-01-11 17:21:41 +0800 | [diff] [blame] | 141 | call _set_sic_iwr; /* Set Awake from IDLE */ |
| 142 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 143 | P0.H = hi(PLL_CTL); |
| 144 | P0.L = lo(PLL_CTL); |
| 145 | R0 = W[P0](z); |
| 146 | BITSET (R0, 3); |
Michael Hennerich | 4521ef4 | 2008-01-11 17:21:41 +0800 | [diff] [blame] | 147 | W[P0] = R0.L; /* Turn CCLK OFF */ |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 148 | SSYNC; |
| 149 | IDLE; |
| 150 | |
| 151 | call _test_pll_locked; |
| 152 | |
| 153 | R0 = IWR_ENABLE(0); |
Michael Hennerich | cfefe3c | 2008-02-09 04:12:37 +0800 | [diff] [blame] | 154 | R1 = IWR_DISABLE_ALL; |
| 155 | R2 = IWR_DISABLE_ALL; |
| 156 | |
Michael Hennerich | 4521ef4 | 2008-01-11 17:21:41 +0800 | [diff] [blame] | 157 | call _set_sic_iwr; /* Set Awake from IDLE PLL */ |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 158 | |
| 159 | P0.H = hi(VR_CTL); |
| 160 | P0.L = lo(VR_CTL); |
| 161 | W[P0]= R7; |
| 162 | |
| 163 | SSYNC; |
| 164 | IDLE; |
| 165 | |
| 166 | call _test_pll_locked; |
| 167 | |
| 168 | P0.H = hi(PLL_DIV); |
| 169 | P0.L = lo(PLL_DIV); |
Michael Hennerich | 4521ef4 | 2008-01-11 17:21:41 +0800 | [diff] [blame] | 170 | W[P0]= R6; /* Restore CCLK and SCLK divider */ |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 171 | |
| 172 | P0.H = hi(PLL_CTL); |
| 173 | P0.L = lo(PLL_CTL); |
Michael Hennerich | 4521ef4 | 2008-01-11 17:21:41 +0800 | [diff] [blame] | 174 | w[p0] = R5; /* Restore VCO multiplier */ |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 175 | IDLE; |
| 176 | call _test_pll_locked; |
| 177 | |
Michael Hennerich | 4521ef4 | 2008-01-11 17:21:41 +0800 | [diff] [blame] | 178 | call _unset_dram_srfs; /* SDRAM Self Refresh Off */ |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 179 | |
| 180 | STI R4; |
| 181 | |
| 182 | RETS = [SP++]; |
Mike Frysinger | da31d6f | 2011-06-27 15:43:56 -0400 | [diff] [blame] | 183 | (R7:4, P5:3) = [SP++]; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 184 | RTS; |
Mike Frysinger | 1a8caee | 2008-07-16 17:07:26 +0800 | [diff] [blame] | 185 | ENDPROC(_sleep_deeper) |
Michael Hennerich | 1efc80b | 2008-07-19 16:57:32 +0800 | [diff] [blame] | 186 | |
Sonic Zhang | fb5f004 | 2007-12-23 23:02:13 +0800 | [diff] [blame] | 187 | ENTRY(_set_dram_srfs) |
| 188 | /* set the dram to self refresh mode */ |
Michael Hennerich | 1efc80b | 2008-07-19 16:57:32 +0800 | [diff] [blame] | 189 | SSYNC; |
| 190 | #if defined(EBIU_RSTCTL) /* DDR */ |
Sonic Zhang | fb5f004 | 2007-12-23 23:02:13 +0800 | [diff] [blame] | 191 | P0.H = hi(EBIU_RSTCTL); |
| 192 | P0.L = lo(EBIU_RSTCTL); |
| 193 | R2 = [P0]; |
Michael Hennerich | 1efc80b | 2008-07-19 16:57:32 +0800 | [diff] [blame] | 194 | BITSET(R2, 3); /* SRREQ enter self-refresh mode */ |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 195 | [P0] = R2; |
Michael Hennerich | 1efc80b | 2008-07-19 16:57:32 +0800 | [diff] [blame] | 196 | SSYNC; |
| 197 | 1: |
Sonic Zhang | fb5f004 | 2007-12-23 23:02:13 +0800 | [diff] [blame] | 198 | R2 = [P0]; |
| 199 | CC = BITTST(R2, 4); |
Michael Hennerich | 1efc80b | 2008-07-19 16:57:32 +0800 | [diff] [blame] | 200 | if !CC JUMP 1b; |
| 201 | #else /* SDRAM */ |
| 202 | P0.L = lo(EBIU_SDGCTL); |
| 203 | P0.H = hi(EBIU_SDGCTL); |
Mike Frysinger | 9e770f7 | 2011-06-27 15:46:40 -0400 | [diff] [blame] | 204 | P1.L = lo(EBIU_SDSTAT); |
| 205 | P1.H = hi(EBIU_SDSTAT); |
| 206 | |
Michael Hennerich | 1efc80b | 2008-07-19 16:57:32 +0800 | [diff] [blame] | 207 | R2 = [P0]; |
| 208 | BITSET(R2, 24); /* SRFS enter self-refresh mode */ |
| 209 | [P0] = R2; |
| 210 | SSYNC; |
| 211 | |
Michael Hennerich | 1efc80b | 2008-07-19 16:57:32 +0800 | [diff] [blame] | 212 | 1: |
Mike Frysinger | 9e770f7 | 2011-06-27 15:46:40 -0400 | [diff] [blame] | 213 | R2 = w[P1]; |
Michael Hennerich | 1efc80b | 2008-07-19 16:57:32 +0800 | [diff] [blame] | 214 | SSYNC; |
| 215 | cc = BITTST(R2, 1); /* SDSRA poll self-refresh status */ |
| 216 | if !cc jump 1b; |
| 217 | |
Michael Hennerich | 1efc80b | 2008-07-19 16:57:32 +0800 | [diff] [blame] | 218 | R2 = [P0]; |
| 219 | BITCLR(R2, 0); /* SCTLE disable CLKOUT */ |
| 220 | [P0] = R2; |
Sonic Zhang | fb5f004 | 2007-12-23 23:02:13 +0800 | [diff] [blame] | 221 | #endif |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 222 | RTS; |
Mike Frysinger | 1a8caee | 2008-07-16 17:07:26 +0800 | [diff] [blame] | 223 | ENDPROC(_set_dram_srfs) |
Michael Hennerich | 1efc80b | 2008-07-19 16:57:32 +0800 | [diff] [blame] | 224 | |
Sonic Zhang | fb5f004 | 2007-12-23 23:02:13 +0800 | [diff] [blame] | 225 | ENTRY(_unset_dram_srfs) |
| 226 | /* set the dram out of self refresh mode */ |
Mike Frysinger | 9e770f7 | 2011-06-27 15:46:40 -0400 | [diff] [blame] | 227 | |
Michael Hennerich | 1efc80b | 2008-07-19 16:57:32 +0800 | [diff] [blame] | 228 | #if defined(EBIU_RSTCTL) /* DDR */ |
Sonic Zhang | fb5f004 | 2007-12-23 23:02:13 +0800 | [diff] [blame] | 229 | P0.H = hi(EBIU_RSTCTL); |
| 230 | P0.L = lo(EBIU_RSTCTL); |
| 231 | R2 = [P0]; |
Michael Hennerich | 1efc80b | 2008-07-19 16:57:32 +0800 | [diff] [blame] | 232 | BITCLR(R2, 3); /* clear SRREQ bit */ |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 233 | [P0] = R2; |
Michael Hennerich | 1efc80b | 2008-07-19 16:57:32 +0800 | [diff] [blame] | 234 | #elif defined(EBIU_SDGCTL) /* SDRAM */ |
Mike Frysinger | 9e770f7 | 2011-06-27 15:46:40 -0400 | [diff] [blame] | 235 | /* release CLKOUT from self-refresh */ |
| 236 | P0.L = lo(EBIU_SDGCTL); |
Michael Hennerich | 1efc80b | 2008-07-19 16:57:32 +0800 | [diff] [blame] | 237 | P0.H = hi(EBIU_SDGCTL); |
Mike Frysinger | 9e770f7 | 2011-06-27 15:46:40 -0400 | [diff] [blame] | 238 | |
Michael Hennerich | 1efc80b | 2008-07-19 16:57:32 +0800 | [diff] [blame] | 239 | R2 = [P0]; |
| 240 | BITSET(R2, 0); /* SCTLE enable CLKOUT */ |
| 241 | [P0] = R2 |
| 242 | SSYNC; |
| 243 | |
Mike Frysinger | 9e770f7 | 2011-06-27 15:46:40 -0400 | [diff] [blame] | 244 | /* release SDRAM from self-refresh */ |
Michael Hennerich | 1efc80b | 2008-07-19 16:57:32 +0800 | [diff] [blame] | 245 | R2 = [P0]; |
| 246 | BITCLR(R2, 24); /* clear SRFS bit */ |
| 247 | [P0] = R2 |
| 248 | #endif |
Mike Frysinger | 9e770f7 | 2011-06-27 15:46:40 -0400 | [diff] [blame] | 249 | |
Michael Hennerich | 1efc80b | 2008-07-19 16:57:32 +0800 | [diff] [blame] | 250 | SSYNC; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 251 | RTS; |
Mike Frysinger | 1a8caee | 2008-07-16 17:07:26 +0800 | [diff] [blame] | 252 | ENDPROC(_unset_dram_srfs) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 253 | |
| 254 | ENTRY(_set_sic_iwr) |
Mike Frysinger | 85c2737 | 2011-06-26 13:55:24 -0400 | [diff] [blame] | 255 | #ifdef SIC_IWR0 |
Mike Frysinger | 4705a25 | 2011-06-26 14:07:17 -0400 | [diff] [blame] | 256 | P0.H = hi(SYSMMR_BASE); |
| 257 | P0.L = lo(SYSMMR_BASE); |
| 258 | [P0 + (SIC_IWR0 - SYSMMR_BASE)] = R0; |
| 259 | [P0 + (SIC_IWR1 - SYSMMR_BASE)] = R1; |
Mike Frysinger | 85c2737 | 2011-06-26 13:55:24 -0400 | [diff] [blame] | 260 | # ifdef SIC_IWR2 |
Mike Frysinger | 4705a25 | 2011-06-26 14:07:17 -0400 | [diff] [blame] | 261 | [P0 + (SIC_IWR2 - SYSMMR_BASE)] = R2; |
Mike Frysinger | 85c2737 | 2011-06-26 13:55:24 -0400 | [diff] [blame] | 262 | # endif |
Sonic Zhang | fb5f004 | 2007-12-23 23:02:13 +0800 | [diff] [blame] | 263 | #else |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 264 | P0.H = hi(SIC_IWR); |
| 265 | P0.L = lo(SIC_IWR); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 266 | [P0] = R0; |
Mike Frysinger | 4705a25 | 2011-06-26 14:07:17 -0400 | [diff] [blame] | 267 | #endif |
Michael Hennerich | cfefe3c | 2008-02-09 04:12:37 +0800 | [diff] [blame] | 268 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 269 | SSYNC; |
| 270 | RTS; |
Mike Frysinger | 1a8caee | 2008-07-16 17:07:26 +0800 | [diff] [blame] | 271 | ENDPROC(_set_sic_iwr) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 272 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 273 | ENTRY(_test_pll_locked) |
| 274 | P0.H = hi(PLL_STAT); |
| 275 | P0.L = lo(PLL_STAT); |
| 276 | 1: |
| 277 | R0 = W[P0] (Z); |
| 278 | CC = BITTST(R0,5); |
| 279 | IF !CC JUMP 1b; |
| 280 | RTS; |
Mike Frysinger | 1a8caee | 2008-07-16 17:07:26 +0800 | [diff] [blame] | 281 | ENDPROC(_test_pll_locked) |
Steven Miao | 93f8951 | 2012-05-16 18:26:10 +0800 | [diff] [blame^] | 282 | #endif |
Michael Hennerich | 1efc80b | 2008-07-19 16:57:32 +0800 | [diff] [blame] | 283 | |
| 284 | .section .text |
Michael Hennerich | 1efc80b | 2008-07-19 16:57:32 +0800 | [diff] [blame] | 285 | ENTRY(_do_hibernate) |
Steven Miao | 93f8951 | 2012-05-16 18:26:10 +0800 | [diff] [blame^] | 286 | bfin_cpu_reg_save; |
| 287 | bfin_sys_mmr_save; |
| 288 | bfin_core_mmr_save; |
Mike Frysinger | eed7b83 | 2011-06-26 23:11:19 -0400 | [diff] [blame] | 289 | |
| 290 | /* Setup args to hibernate mode early for pipeline optimization */ |
| 291 | R0 = M3; |
| 292 | P1.H = _hibernate_mode; |
| 293 | P1.L = _hibernate_mode; |
Michael Hennerich | 1efc80b | 2008-07-19 16:57:32 +0800 | [diff] [blame] | 294 | |
| 295 | /* Save Magic, return address and Stack Pointer */ |
Mike Frysinger | eed7b83 | 2011-06-26 23:11:19 -0400 | [diff] [blame] | 296 | P0 = 0; |
| 297 | R1.H = 0xDEAD; /* Hibernate Magic */ |
| 298 | R1.L = 0xBEEF; |
| 299 | R2.H = .Lpm_resume_here; |
| 300 | R2.L = .Lpm_resume_here; |
| 301 | [P0++] = R1; /* Store Hibernate Magic */ |
| 302 | [P0++] = R2; /* Save Return Address */ |
Michael Hennerich | 1efc80b | 2008-07-19 16:57:32 +0800 | [diff] [blame] | 303 | [P0++] = SP; /* Save Stack Pointer */ |
Mike Frysinger | eed7b83 | 2011-06-26 23:11:19 -0400 | [diff] [blame] | 304 | |
| 305 | /* Must use an indirect call as we need to jump to L1 */ |
| 306 | call (P1); /* Goodbye */ |
Michael Hennerich | 1efc80b | 2008-07-19 16:57:32 +0800 | [diff] [blame] | 307 | |
Mike Frysinger | 1a8caee | 2008-07-16 17:07:26 +0800 | [diff] [blame] | 308 | .Lpm_resume_here: |
Michael Hennerich | 1efc80b | 2008-07-19 16:57:32 +0800 | [diff] [blame] | 309 | |
Steven Miao | 93f8951 | 2012-05-16 18:26:10 +0800 | [diff] [blame^] | 310 | bfin_core_mmr_restore; |
| 311 | bfin_sys_mmr_restore; |
| 312 | bfin_cpu_reg_restore; |
Michael Hennerich | 1efc80b | 2008-07-19 16:57:32 +0800 | [diff] [blame] | 313 | |
| 314 | [--sp] = RETI; /* Clear Global Interrupt Disable */ |
| 315 | SP += 4; |
| 316 | |
Michael Hennerich | 1efc80b | 2008-07-19 16:57:32 +0800 | [diff] [blame] | 317 | RTS; |
Mike Frysinger | 1a8caee | 2008-07-16 17:07:26 +0800 | [diff] [blame] | 318 | ENDPROC(_do_hibernate) |