2 * Copyright 2004-2008 Analog Devices Inc.
4 * Licensed under the GPL-2 or later.
7 #include <linux/linkage.h>
8 #include <asm/blackfin.h>
14 [--SP] = (R7:4, P5:3);
30 call _test_pll_locked;
46 bfin_init_pm_bench_cycles;
48 call _test_pll_locked;
51 (R7:4, P5:3) = [SP++];
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.
61 * We accept just one argument -- the value to write to VR_CTL.
64 ENTRY(_hibernate_mode)
65 /* Save/setup the regs we need early for minor pipeline optimization */
70 /* Disable all wakeup sources */
78 /* Finally, we climb into our cave to hibernate */
81 bfin_init_pm_bench_cycles;
87 ENDPROC(_hibernate_mode)
90 [--SP] = (R7:4, P5:3);
100 R1 = IWR_DISABLE_ALL;
101 R2 = IWR_DISABLE_ALL;
104 call _set_dram_srfs; /* Set SDRAM Self Refresh */
110 W[P0] = R0.l; /* Set Max VCO to SCLK divider */
115 R0.L = (CONFIG_MIN_VCO_HZ/CONFIG_CLKIN_HZ) << 9;
116 W[P0] = R0.l; /* Set Min CLKIN to VCO multiplier */
121 call _test_pll_locked;
131 R2 = DEPOSIT(R7, R1);
132 W[P0] = R2; /* Set Min Core Voltage */
137 call _test_pll_locked;
142 call _set_sic_iwr; /* Set Awake from IDLE */
148 W[P0] = R0.L; /* Turn CCLK OFF */
152 call _test_pll_locked;
155 R1 = IWR_DISABLE_ALL;
156 R2 = IWR_DISABLE_ALL;
158 call _set_sic_iwr; /* Set Awake from IDLE PLL */
167 bfin_init_pm_bench_cycles;
169 call _test_pll_locked;
173 W[P0]= R6; /* Restore CCLK and SCLK divider */
177 w[p0] = R5; /* Restore VCO multiplier */
179 call _test_pll_locked;
181 call _unset_dram_srfs; /* SDRAM Self Refresh Off */
186 (R7:4, P5:3) = [SP++];
188 ENDPROC(_sleep_deeper)
190 ENTRY(_set_dram_srfs)
191 /* set the dram to self refresh mode */
193 #if defined(EBIU_RSTCTL) /* DDR */
194 P0.H = hi(EBIU_RSTCTL);
195 P0.L = lo(EBIU_RSTCTL);
197 BITSET(R2, 3); /* SRREQ enter self-refresh mode */
205 P0.L = lo(EBIU_SDGCTL);
206 P0.H = hi(EBIU_SDGCTL);
207 P1.L = lo(EBIU_SDSTAT);
208 P1.H = hi(EBIU_SDSTAT);
211 BITSET(R2, 24); /* SRFS enter self-refresh mode */
218 cc = BITTST(R2, 1); /* SDSRA poll self-refresh status */
222 BITCLR(R2, 0); /* SCTLE disable CLKOUT */
226 ENDPROC(_set_dram_srfs)
228 ENTRY(_unset_dram_srfs)
229 /* set the dram out of self refresh mode */
231 #if defined(EBIU_RSTCTL) /* DDR */
232 P0.H = hi(EBIU_RSTCTL);
233 P0.L = lo(EBIU_RSTCTL);
235 BITCLR(R2, 3); /* clear SRREQ bit */
237 #elif defined(EBIU_SDGCTL) /* SDRAM */
238 /* release CLKOUT from self-refresh */
239 P0.L = lo(EBIU_SDGCTL);
240 P0.H = hi(EBIU_SDGCTL);
243 BITSET(R2, 0); /* SCTLE enable CLKOUT */
247 /* release SDRAM from self-refresh */
249 BITCLR(R2, 24); /* clear SRFS bit */
255 ENDPROC(_unset_dram_srfs)
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;
264 [P0 + (SIC_IWR2 - SYSMMR_BASE)] = R2;
274 ENDPROC(_set_sic_iwr)
276 ENTRY(_test_pll_locked)
284 ENDPROC(_test_pll_locked)
292 /* Setup args to hibernate mode early for pipeline optimization */
294 P1.H = _hibernate_mode;
295 P1.L = _hibernate_mode;
297 /* Save Magic, return address and Stack Pointer */
299 R1.H = 0xDEAD; /* Hibernate Magic */
301 R2.H = .Lpm_resume_here;
302 R2.L = .Lpm_resume_here;
303 [P0++] = R1; /* Store Hibernate Magic */
304 [P0++] = R2; /* Save Return Address */
305 [P0++] = SP; /* Save Stack Pointer */
307 /* Must use an indirect call as we need to jump to L1 */
308 call (P1); /* Goodbye */
312 bfin_core_mmr_restore;
313 bfin_sys_mmr_restore;
314 bfin_cpu_reg_restore;
316 [--sp] = RETI; /* Clear Global Interrupt Disable */
320 ENDPROC(_do_hibernate)