void zapm_poweroff(void) { struct pxa2x0_apm_softc *sc; int s; KASSERT(apm_cd.cd_ndevs > 0 && apm_cd.cd_devs[0] != NULL); sc = apm_cd.cd_devs[0]; #if NWSDISPLAY > 0 wsdisplay_suspend(); #endif /* NWSDISPLAY > 0 */ s = splhigh(); config_suspend_all(DVACT_SUSPEND); suspend_randomness(); /* XXX * Flag to disk drivers that they should "power down" the disk * when we get to DVACT_POWERDOWN. */ boothowto |= RB_POWERDOWN; config_suspend_all(DVACT_POWERDOWN); boothowto &= ~RB_POWERDOWN; /* XXX enable charging during suspend */ /* XXX keep power LED state during suspend */ /* XXX do the same thing for GPIO 43 (BTTXD) */ /* XXX scoop power down */ /* XXX set PGSRn and GPDRn */ pxa2x0_wakeup_config(PXA2X0_WAKEUP_ALL, 1); do { pxa2x0_apm_sleep(sc); } while (!zapm_resume(sc)); zapm_restart(); /* NOTREACHED */ config_suspend_all(DVACT_RESUME); splx(s); resume_randomness(NULL, 0); /* force RNG upper level reseed */ bufq_restart(); config_suspend_all(DVACT_WAKEUP); #if NWSDISPLAY > 0 wsdisplay_resume(); #endif /* NWSDISPLAY > 0 */ }
void apm_suspend(int state) { extern int perflevel; int s; #if NWSDISPLAY > 0 wsdisplay_suspend(); #endif /* NWSDISPLAY > 0 */ stop_periodic_resettodr(); config_suspend_all(DVACT_QUIESCE); bufq_quiesce(); s = splhigh(); intr_disable(); cold = 2; config_suspend_all(DVACT_SUSPEND); suspend_randomness(); /* XXX * Flag to disk drivers that they should "power down" the disk * when we get to DVACT_POWERDOWN. */ boothowto |= RB_POWERDOWN; config_suspend_all(DVACT_POWERDOWN); boothowto &= ~RB_POWERDOWN; /* Send machine to sleep */ apm_set_powstate(APM_DEV_ALLDEVS, state); /* Wake up */ /* They say that some machines may require reinitializing the clocks */ i8254_startclock(); if (initclock_func == i8254_initclocks) rtcstart(); /* in i8254 mode, rtc is profclock */ inittodr(time_second); config_suspend_all(DVACT_RESUME); cold = 0; intr_enable(); splx(s); resume_randomness(NULL, 0); /* force RNG upper level reseed */ bufq_restart(); config_suspend_all(DVACT_WAKEUP); start_periodic_resettodr(); #if NWSDISPLAY > 0 wsdisplay_resume(); #endif /* NWSDISPLAY > 0 */ /* restore hw.setperf */ if (cpu_setperf != NULL) cpu_setperf(perflevel); }
void apm_resume(struct pxa2x0_apm_softc *sc) { int s; s = splhigh(); config_suspend(TAILQ_FIRST(&alldevs), DVACT_RESUME); splx(s); inittodr(0); /* * Clear the OTG Peripheral hold after running the pxaudc and pxaohci * ca_activate to re-enable their operation. See 3.8.1.2 */ /* XXX ifdef NPXAUDC > 0 */ bus_space_write_4(sc->sc_iot, sc->sc_pm_ioh, POWMAN_PSSR, PSSR_OTGPH); bufq_restart(); #if NWSDISPLAY > 0 wsdisplay_resume(); #endif /* NWSDISPLAY > 0 */ }
int apm_suspend(int state) { int rv; int s; #if NWSDISPLAY > 0 wsdisplay_suspend(); #endif resettodr(); config_suspend_all(DVACT_QUIESCE); bufq_quiesce(); s = splhigh(); (void)disableintr(); cold = 1; rv = config_suspend_all(DVACT_SUSPEND); suspend_randomness(); #ifdef HIBERNATE if (state == APM_IOC_HIBERNATE) { uvm_pmr_zero_everything(); if (hibernate_suspend()) { printf("apm: hibernate_suspend failed"); hibernate_free(); uvm_pmr_dirty_everything(); return (ECANCELED); } } #endif /* XXX * Flag to disk drivers that they should "power down" the disk * when we get to DVACT_POWERDOWN. */ boothowto |= RB_POWERDOWN; config_suspend_all(DVACT_POWERDOWN); boothowto &= ~RB_POWERDOWN; if (rv == 0) { rv = sys_platform->suspend(); if (rv == 0) rv = sys_platform->resume(); } inittodr(time_second); /* Move the clock forward */ config_suspend_all(DVACT_RESUME); cold = 0; (void)enableintr(); splx(s); resume_randomness(NULL, 0); /* force RNG upper level reseed */ bufq_restart(); config_suspend_all(DVACT_WAKEUP); #if NWSDISPLAY > 0 wsdisplay_resume(); #endif return rv; }