Brown-bag firmware with suspend support

Mitch Bradley wmb at firmworks.com
Wed Mar 7 05:52:38 EST 2007


http://dev.laptop.org/~wmb/suspend0.rom

is a brown-bag (i.e. not officially released) version of OFW for OLPC 
that supports suspend-to-RAM and subsequent wakeup.

This release is not for the faint of heart.  It is intended for 
developers who are familiar with firmware recovery procedures.  It works 
on my B2 system and I don't think it will brick your system, but no 
guarantees.

At the ok prompt, you can do this:

 ok s

that will put the system in suspend-to-RAM mode.  The main power to the 
CPU and 5536 chips will be off, the RAMs will be powered in self-refresh 
mode, the DCON will be in "freeze frame" mode.

It will wake up again when you press the power button.

The display should work after wakeup; it does on my machine.  It is 
possible that you will see a display glitch at wakeup.  If so, that is 
probably because of http://dev.laptop.org/ticket/947 .  My system is 
modified to pull DCONLOAD down instead of up, and does not glitch.

USB won't work after wakeup; I don't have save/restore code for it yet.  
Nor for CaFe devices or audio.

The OS kernel can invoke the save/restore sequence by calling 0xf0000 as 
a subroutine.  The subroutine will return on wakeup.

The subroutine saves/restores the core machine state, but not the video 
state.  The video stuff (including the DCON fiddling for freeze-frame 
enter and exit) is done at the Forth level in the OFW test word "s" (an 
alias for "suspend").

One other thing the kernel will need to do for now before calling the 
subroutine:  set the value of ACPI register 02 to enable the PWRBTN 
wakeup event.   Jordan has code to do that.  The suspend subroutine sets 
most of the ACPI and PM registers for you, but it leaves that one out so 
external code controls the set of events that wake you up.

Here is the list of things the subroutine saves/restores:

MSRs (including the ones that configure the video)
GPIO configuration and value
PIC
PIT
SMBUS
MFGPTs
USB port-to-power assignment
CR0,3,4
GDT, IDT, LDT (but not TR)
Sets up serial port in 115200,8,n,1 mode
CS,DS,ES,FS,GS,SS
general registers and eflags




More information about the Devel mailing list