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