Author: wmb Date: 2009-01-09 07:08:34 +0100 (Fri, 09 Jan 2009) New Revision: 1068
Added: cpu/x86/pc/olpc/biosresume.fth Modified: cpu/x86/pc/olpc/dsdt.dsl cpu/x86/pc/olpc/fw.bth dev/geode/smi.fth Log: OLPC - fix problems with lid switch handling for Windows resume, including big cleanup of ACPI DSDT code.
Added: cpu/x86/pc/olpc/biosresume.fth =================================================================== --- cpu/x86/pc/olpc/biosresume.fth (rev 0) +++ cpu/x86/pc/olpc/biosresume.fth 2009-01-09 06:08:34 UTC (rev 1068) @@ -0,0 +1,101 @@ +purpose: Platform-specific parts of BIOS emulation for Windows support +\ See license at end of file + +\ Workaround for problems with the way that Windows manages the +\ GPIOs for lid wakeup. To understand this, you need to understand +\ the Geode GPIO hardware, which is confusing and poorly documented. +\ See http://wiki.laptop.org/images/4/46/GPIO.png for a diagram. + +\ The following LID wakeup frobbing is not needed anymore; +\ I figured out how to do it in ACPI (which was fairly tricky) +0 [if] +0 value negedge-ena-state +0 value posedge-ena-state + +h# 400 constant lid-gpio \ GPIO 26 +h# 4000.0000 constant lid-pme \ PME mapper 6 +: setup-lid-wakeup ( -- ) + h# c0 gpio@ to posedge-ena-state + h# c4 gpio@ to negedge-ena-state + lid-gpio h# c8 gpio! lid-gpio h# cc gpio! \ Clear both edge status latches + d# 100 us \ Wait for the synchronizer (32 kHz clock) + + \ Empirically, Windows tries to control the wakeup policy by flipping + \ the input invert bit. If you suspend from the power button, the + \ input invert is on at this point, whereas if you suspend by closing + \ the lid, input invert is off. That doesn't quite work right - in + \ the power-button-suspend case, subsequently closing the lid causes + \ a wakeup! To fix the problem, we switch to edge-detector wakeup. + \ We leave the invert/no-invert setting as is, and choose which edge + \ to wakeup on. In both cases we want to wakeup on the lid-opening + \ event, but which edge that is depends on the inversion state. + + h# a4 gpio@ lid-gpio and if + \ Lid input is inverted. Lid opening causes rising edge on pin, + \ inverted to falling edge internally, so wakeup on negative edge. + + lid-gpio >clr h# c0 gpio! lid-gpio h# c4 gpio! + else + \ Lid input is not inverted. Lid opening causes rising edge on pin, + \ so rising edge internally, so wakeup on positive edge. + + lid-gpio >clr h# c4 gpio! lid-gpio h# c0 gpio! + then + d# 100 us \ Wait for the synchronizer (32 kHz clock) + lid-pme h# 18 acpi-l! \ Clear the final latch +; +: cleanup-lid-wakeup ( -- ) + posedge-ena-state h# c0 gpio! + negedge-ena-state h# c4 gpio! +; +[then] + +: suspend-ps2 ( -- ) + " default-disable-kbd" kbd-ih $call-method \ Stop keyboard + 1 " set-port" kbd-ih $call-method \ Select mouse (touchpad) port + " default-disable-kbd" kbd-ih $call-method \ Stop mouse +; +: resume-ps2 ( -- ) + " enable-scan" kbd-ih $call-method \ Restart mouse + 0 " set-port" kbd-ih $call-method \ Select keyboard port + " enable-scan" kbd-ih $call-method \ Restart keyboard +; + +: (suspend-devices) ( -- ) + dcon-power-off + wlan-freeze + suspend-ps2 + [ifdef] setup-lid-wakeup setup-lid-wakeup [then] +; +: (resume-devices) ( -- ) + [ifdef] cleanup-lid-wakeup cleanup-lid-wakeup [then] + resume-ps2 + wlan-reset + dcon-power-on d# 10 ms " dcon-restart" screen-ih $call-method +; +' (suspend-devices) to suspend-devices +' (resume-devices) to resume-devices + +\ LICENSE_BEGIN +\ Copyright (c) 2009 FirmWorks +\ +\ Permission is hereby granted, free of charge, to any person obtaining +\ a copy of this software and associated documentation files (the +\ "Software"), to deal in the Software without restriction, including +\ without limitation the rights to use, copy, modify, merge, publish, +\ distribute, sublicense, and/or sell copies of the Software, and to +\ permit persons to whom the Software is furnished to do so, subject to +\ the following conditions: +\ +\ The above copyright notice and this permission notice shall be +\ included in all copies or substantial portions of the Software. +\ +\ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +\ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +\ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +\ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +\ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +\ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +\ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +\ +\ LICENSE_END
Modified: cpu/x86/pc/olpc/dsdt.dsl =================================================================== --- cpu/x86/pc/olpc/dsdt.dsl 2009-01-07 09:14:26 UTC (rev 1067) +++ cpu/x86/pc/olpc/dsdt.dsl 2009-01-09 06:08:34 UTC (rev 1068) @@ -16,34 +16,34 @@ "OLPC XO-1", "$Id$" }) - OperationRegion (VSA1, SystemIO, 0xAC1C, 0x04) - Field (VSA1, WordAcc, NoLock, Preserve) { - VSA2, 16, - VSA3, 16 - } +// OperationRegion (VSA1, SystemIO, 0xAC1C, 0x04) +// Field (VSA1, WordAcc, NoLock, Preserve) { +// VSA2, 16, +// VSA3, 16 +// }
- Mutex (VSA4, 0x00) +// Mutex (VSA4, 0x00)
- Method (VSAR, 1, Serialized) { // VSAR (index -- resword ) - Name (VRRR, Zero) - Acquire (VSA4, 0xFFFF) - Store (0xFC53, VSA2) // Unlock - Store (Arg0, VSA2) - Store (VSA3, Local1) - Release (VSA4) - Store (Local1, VRRR) - Return (VRRR) - } +// Method (VSAR, 1, Serialized) { // VSAR (index -- resword ) +// Name (VRRR, Zero) +// Acquire (VSA4, 0xFFFF) +// Store (0xFC53, VSA2) // Unlock +// Store (Arg0, VSA2) +// Store (VSA3, Local1) +// Release (VSA4) +// Store (Local1, VRRR) +// Return (VRRR) +// }
- Method (VSAW, 2, Serialized) { // VSAW ( index value -- ) - Acquire (VSA4, 0xFFFF) - Store (0xFC53, VSA2) // Unlock - Store (Arg0, VSA2) - Store (Arg1, VSA3) - Release (VSA4) - } +// Method (VSAW, 2, Serialized) { // VSAW ( index value -- ) +// Acquire (VSA4, 0xFFFF) +// Store (0xFC53, VSA2) // Unlock +// Store (Arg0, VSA2) +// Store (Arg1, VSA3) +// Release (VSA4) +// }
-// Mutex (ECMX, 0x00) +// Mutex (ECMX, 0x00)
OperationRegion (UART, SystemIO, 0x03f8, 0x07)
@@ -59,8 +59,7 @@ } Method (UPUT, 1, NotSerialized) { - While( LEqual (And (USTA, 0x20), Zero) ) - { + While( LEqual (And (USTA, 0x20), Zero) ) { Stall (99) } Store (Arg0, UDAT) @@ -70,8 +69,7 @@ {
And (ShiftRight (Arg0, 4), 0xF, Local0) - If (LLess (Local0, 10)) - { + If (LLess (Local0, 10)) { Add (Local0, 0x30, Local0) // '0' } Else { Add (Local0, 0x57, Local0) // 'a' - 10 @@ -79,8 +77,7 @@ UPUT (Local0)
And (Arg0, 0xF, Local0) - If (LLess (Local0, 10)) - { + If (LLess (Local0, 10)) { Add (Local0, 0x30, Local0) // '0' } Else { Add (Local0, 0x57, Local0) // 'a' - 10 @@ -101,16 +98,16 @@
Method (ECRD, 1, NotSerialized) { -// Acquire (ECMX, 5000) +// Acquire (ECMX, 5000) Store (ShiftRight (Arg0, 0x08), EIXH) Store (And (Arg0, 0xFF), EIXL) -// Sleep (15) +// Sleep (15) Stall(255) Store (EDAT, Local0) -// UDOT (Local0) +// UDOT (Local0) Stall(255) -// Sleep (15) -// Release (ECMX) +// Sleep (15) +// Release (ECMX) Return (Local0) }
@@ -184,52 +181,76 @@
Scope (_PR) { Processor (CPU0, 0x01, 0x00000000, 0x00) {} -// Processor (CPU0, 0x01, 0x00009E00, 0x06) { -// Name (_PCT, Package (0x02) { -// ResourceTemplate () { -// Register (SystemIO, 0x08, 0x00, 0x0000000000009C2C, ,) -// }, +// Processor (CPU0, 0x01, 0x00009E00, 0x06) { +// Name (_PCT, Package (0x02) { +// ResourceTemplate () { +// Register (SystemIO, 0x08, 0x00, 0x0000000000009C2C, ,) +// }, // -// ResourceTemplate () { -// Register (SystemIO, 0x08, 0x00, 0x0000000000009C2C, ,) -// } -// }) -// // Question: Why have two identical performance states? -// Name (_PSS, Package (0x02) { -// Package (0x06) { 0x01B1, 0x03BF, 0x2D, Zero, 0x0D, 0x0D }, -// Package (0x06) { 0x01B1, 0x03BF, 0x2D, Zero, 0x0D, 0x0D } -// }) -// Name (_PPC, Zero) -// } +// ResourceTemplate () { +// Register (SystemIO, 0x08, 0x00, 0x0000000000009C2C, ,) +// } +// }) +// // Question: Why have two identical performance states? +// Name (_PSS, Package (0x02) { +// Package (0x06) { 0x01B1, 0x03BF, 0x2D, Zero, 0x0D, 0x0D }, +// Package (0x06) { 0x01B1, 0x03BF, 0x2D, Zero, 0x0D, 0x0D } +// }) +// Name (_PPC, Zero) +// } }
Name (_S0, Package (0x04) { Zero, Zero, Zero, Zero }) // Values for PM1a,b_CNT.SLP_TYP registers Name (_S1, Package (0x04) { One, One, Zero, Zero }) Name (_S3, Package (0x04) { 0x03, 0x03, Zero, Zero }) Name (_S5, Package (0x04) { 0x05, 0x05, Zero, Zero }) - Name (_SB.ZZY2, Zero) - Name (ZZY1, Zero) // Current state - see _SST page 298 for values - Name (ZZY3, Zero) // "Already inited" flag - Name (ZZY4, Zero) // EBDA base address in bytes -// Name (ZZY5, Zero) // Set to EBDA length in bytes - unused - Name (ZZY6, Zero) // Set to memory size in Kbytes + Name (SLPS, Zero) // Current state - see _SST page 298 for values + Name (INID, Zero) // "Already inited" flag + Name (EBBA, Zero) // EBDA base address in bytes + Name (MEMK, Zero) // Set to memory size in Kbytes
+ OperationRegion (GPIO, SystemIO, 0x1000, 0x0100) + Field (GPIO, DWordAcc, NoLock, Preserve) { +// Offset (0x38), +// GLEE, 32 + Offset (0xA4), + GHIN, 32, // High bank Input Invert + Offset (0xB0), // High bank read back + , 10, + LSWI, 1, // Lid switch bit + Offset (0xB8), + GHEE, 32, // High bank events enable + Offset (0xC0), + GHPE, 32, // High bank posedge enable + GHNE, 32, // High bank negedge enable + GHPS, 32, // High bank posedge status + GHNS, 32 // High bank negedge status + } + Method (_PTS, 1, NotSerialized) { -// VSAW(0, 0xc) - Store (Arg0, _SB.ZZY2) } +// UPUT(0x50) // P + Store (Arg0, SLPS)
-// Method (_GTS, 1, NotSerialized) { /* VSAW(0, 0xb) */ } // GoingToSleep -// Method (_BFS, 1, NotSerialized) { /* VSAW(0, 0xa) */ } // Back from sleep + // Having committed to sleeping, switch the lid switch edge + // detector to look for the positive edge, i.e. the lid-open event + Store (0x4000000, GHEE) // Disable events + Store (0x400, GHNS) // Clear lid negative status + Store (0x400, GHPS) // Clear lid positive status + Store ( 0x400, GHPE) // Look for lid opening + Store (0x4000000, GHNE) // .. not lid closing + Stall (100) // Let the synchronizers settle + Store (0x400, GHEE) // Enable events + }
- Method (_WAK, 1, NotSerialized) { // Arg is the sleeping state -// VSAW(0, 9) - Store (Zero, _SB.ZZY2) + Method (_WAK, 1, NotSerialized) { // Arg is the previous sleeping state +// UPUT(0x57) // W + Store (Zero, SLPS) Switch (Arg0) { Case (One) { - Notify (_SB.PCI0.USB0, Zero) - Notify (_SB.PCI0.USB1, Zero) -// Notify (_SB.PCI0.SBF0.KBC, Zero) -// Notify (_SB.PCI0.SBF0.PS2M, Zero) + Notify (_SB.PCI0.USB0, Zero) // Re-enumerate USB bus after wakeup + Notify (_SB.PCI0.USB1, Zero) // Re-enumerate USB bus after wakeup +// Notify (_SB.PCI0.SBF0.KBC, Zero) // Don't re-enumerate KBC because it is not pluggable +// Notify (_SB.PCI0.SBF0.PS2M, Zero) // Don't re-enumerate PS/2 mouse because it is not pluggable } Case (0x03) { Notify (_SB.PCI0, Zero) @@ -238,91 +259,84 @@ Return (Zero) /* Success */ }
- Scope (_GPE) { // General Purpose Events +// Windows XP doesn't use _GTS, _BTS, or _TTS, sadly +// _TTS would make the lid event handling much saner
+ Scope (_GPE) { // General Purpose Events + // pdf p 162 has Notify argument values - Method (_L00, 0, NotSerialized) { // Level-triggered event 0 -// VSAW(0, 8) - If (LEqual (ZZY1, One)) { // no state or working state -// Notify (_SB.PCI0.SBF0.KBC, 0x02) -// Notify (_SB.PCI0.SBF0.PS2M, 0x02) + Method (_L00, 0, NotSerialized) { // Level-triggered event 0 + If (LEqual (SLPS, One)) { // no state or working state +// Notify (_SB.PCI0.SBF0.KBC, 0x02) +// Notify (_SB.PCI0.SBF0.PS2M, 0x02) Notify (_SB.PCI0.SBF0, 0x02) } }
// Likely unnecessary -// Method (_L05, 0, NotSerialized) -// { -// // DDD geoderom guards this with If (LEqual (ZZY1, One)) -// Notify (_SB.PCI0.USB0, 0x02) -// } +// Method (_L05, 0, NotSerialized) +// { +// // DDD geoderom guards this with If (LEqual (SLPS, One)) +// Notify (_SB.PCI0.USB0, 0x02) +// }
// XXX probably pointless as power is off - Method (_L06, 0, NotSerialized) { // USB event -// VSAW(0, 7) - If (LEqual (ZZY1, One)) { // no state or working state + Method (_L06, 0, NotSerialized) { // USB event + If (LEqual (SLPS, One)) { // no state or working state Notify (_SB.PCI0.USB0, 0x02) }
Notify (_SB.PCI0.USB1, 0x02) }
- Method (_L1E, 0, NotSerialized) { // Comes from IRQ/PME Mapper bit 6 - LID switch -// VSAW(0, 6) -// UPUT(0x4C) // L -// UPUT(Add(0x30, ZZY1)) - If (LEqual (_SB.ZZY2, Zero)) { // Not preparing to sleep -// If (LLess (ZZY1, 0x02)) { // no state or working state or waking - Notify (_SB.LIDS, 0x80) // Request to go to sleep -// } + Method (_L1E, 0, NotSerialized) { // Comes from IRQ/PME Mapper bit 6 - LID switch + If (LEqual (SLPS, Zero)) { // Not preparing to sleep +// UPUT(0x4D) // M + Notify (_SB.LIDS, 0x80) // Request to go to sleep } Else { - Notify (_SB.LIDS, 0x02) // Request to wake up +// UPUT(0x6d) // m + Notify (_SB.LIDS, 0x02) // Request to wake up } }
- Method (_L1F, 0, NotSerialized) { // Comes from IRQ/PME Mapper bit 7 - SCI -// VSAW(0, 5) -// UPUT(0x53) // S + Method (_L1F, 0, NotSerialized) { // Comes from IRQ/PME Mapper bit 7 - SCI +// UPUT(0x53) // S
Store (One, Local0) While (Local0) { - Store (ECC1(0x84), Local0) // Read SCI Queue -// UDOT (Local0) + Store (ECC1(0x84), Local0) // Read SCI Queue +// UDOT (Local0) If (And(Local0, 0x40)) { - Notify (_SB.AC, 0x80) + Notify (_SB.AC, 0x80) // Tell OS native driver that AC status has changed } If (And(Local0, 0x0e)) { - Notify (_SB.BATT, 0x80) + Notify (_SB.BATT, 0x80) // Tell OS native driver that battery status has changed } }
-// Notify (_SB.PCI0, 0x02) // Request to wake up from EC -// Notify (_SB.AC, 0x80) -// Notify (_SB.BATT, 0x80) -// UPUT(0x54) // T +// Notify (_SB.PCI0, 0x02) // Request to wake up from EC +// Notify (_SB.AC, 0x80) +// Notify (_SB.BATT, 0x80) +// UPUT(0x54) // T } }
// This is an indicator method - it sets LEDs based on the sleep state Scope (_SI) { Method (_SST, 1, NotSerialized) { -// UPUT(0x24) // $ -// UPUT(Add(0x30, Arg0)) -// VSAW(1, Arg0) -// XXX ??? need to set LEDs by doing VR accesses - or probably the EC does it automatically - Store (Arg0, ZZY1) + // The EC handles the LEDs for us } }
Scope (_SB) { Method (_INI, 0, NotSerialized) { - If (LEqual (ZZY3, One)) { + If (LEqual (INID, One)) { Return } - Store (One, ZZY3) + Store (One, INID)
CreateWordField (^LNKA._PRS, One, IBMA) CreateWordField (^LNKB._PRS, One, IBMB) @@ -335,8 +349,8 @@ }
Store (QQH2, Local0) // Memory address 0x40e - EBDA address from BIOS data area - ShiftLeft (Local0, 0x04, ZZY4) - OperationRegion (EBDA, SystemMemory, ZZY4, 0x0400) + ShiftLeft (Local0, 0x04, EBBA) + OperationRegion (EBDA, SystemMemory, EBBA, 0x0400)
Field (EBDA, AnyAcc, NoLock, Preserve) { AccessAs (ByteAcc, 0x00), @@ -347,29 +361,9 @@ }
// Store (QQE1, Local0) -// Multiply (Local0, 0x0400, ZZY5) // Unused - Store (QQE2, ZZY6) -// VSAW(0, 1) + Store (QQE2, MEMK) }
- OperationRegion (GPIO, SystemIO, 0x1000, 0x0100) - Field (GPIO, DWordAcc, NoLock, Preserve) { -// Offset (0x38), -// GLEE, 32 - Offset (0xA4), - GHIN, 32, // High bank Input Invert - Offset (0xB0), // High bank read back - , 10, - LSWI, 1 // Lid switch bit -// Offset (0xB8), -// GHEE, 32 // High bank events enable -// Offset (0xC0), -// GHPE, 32, // High bank posedge enable -// GHNE, 32, // High bank negedge enable -// GHPS, 32, // High bank posedge status -// GHNS, 32, // High bank negedge status - } - Device (LNKA) { Name (_HID, EisaId ("PNP0C0F")) Name (_UID, One) @@ -415,7 +409,7 @@ { If (LNot (Acquire (ACMX, 5000))) { -// UPUT (0x70) // p +// UPUT (0x70) // p Store (ECRD (0xFA40), Local0) Release (ACMX) } @@ -430,8 +424,7 @@ } }
-// Name (_STA, 0x0F) -Method (_STA, 0, NotSerialized) { Return (0x0F) } + Name (_STA, 0x0F) }
// DDD geoderom has no battery stuff @@ -468,14 +461,14 @@ }) Method (_STA, 0, NotSerialized) // Battery Status { - If (LEqual (ZZY2, 0x03)) + If (LEqual (SLPS, 0x03)) { Return (0x0F) }
If (LNot (Acquire (ACMX, 5000))) { -// UPUT (0x73) // s +// UPUT (0x73) // s Store (ECRD (0xFAA4), Local0) Release (ACMX) } @@ -494,14 +487,14 @@ { If (LNot (Acquire (ACMX, 5000))) { -// UPUT (0x69) // i +// UPUT (0x69) // i Store (ECRD (0xFB5F), Local0) Store (ECRD (0xF929), Local1) Switch (Local0) { Case (0x11) { -// UPUT (0x42) // B +// UPUT (0x42) // B Store (3800, Index (BIFP, One)) Store (3000, Index (BIFP, 2)) Store (6000, Index (BIFP, 0x04)) @@ -513,11 +506,11 @@ Store ("NiMH (GP) ", Index (BIFP, 9)) Store ("", Index (BIFP, 10)) Store ("GoldPeak ", Index (BIFP, 0x0C)) -// UPUT (0x62) // b +// UPUT (0x62) // b } Case (0x12) { -// UPUT (0x44) // D +// UPUT (0x44) // D Store (3000, Index (BIFP, One)) Store (2800, Index (BIFP, 2)) Store (6000, Index (BIFP, 4)) @@ -529,11 +522,11 @@ Store ("LiFePO4 (GP) ", Index (BIFP, 9)) Store ("", Index (BIFP, 10)) Store ("GoldPeak ", Index (BIFP, 0x0C)) -// UPUT (0x64) // d +// UPUT (0x64) // d } Case (0x22) { -// UPUT (0x43) // C +// UPUT (0x43) // C Store (3550, Index (BIFP, One)) Store (3100, Index (BIFP, 2)) Store (6500, Index (BIFP, 4)) @@ -545,7 +538,7 @@ Store ("LiFePO4 (BYD) ", Index (BIFP, 9)) Store ("", Index (BIFP, 10)) Store ("BYD ", Index (BIFP, 0x0C)) -// UPUT (0x63) // c +// UPUT (0x63) // c } }
@@ -556,11 +549,11 @@ } Else { -//x Store ("LiON", Index (BIFP, 11)) +//x Store ("LiON", Index (BIFP, 11)) Store ("LiFePO4", Index (BIFP, 11)) }
-//x Store ("OLPC ", Index (BIFP, 0x0C)) +//x Store ("OLPC ", Index (BIFP, 0x0C)) Release (ACMX) }
@@ -571,7 +564,7 @@ { If (LNot (Acquire (ACMX, 5000))) { -// UPUT (0x74) // t +// UPUT (0x74) // t If (And (ECRD (0xFAA5), One)) { Store (0x02, Local1) // charging @@ -618,43 +611,34 @@ } }
-// XXX ??? Need battery device with static and dynamic info - Device (LIDS) { Name (_HID, EisaId ("PNP0C0D")) Name (_PRW, Package (0x02) { 0x1e, 0x03 }) // Event 1e, wakes from S3 - Method (_INI, 0, NotSerialized) { - Store (0x400, GHIN) // Turn on invert to see falling edge - } Method (_LID, 0, NotSerialized) { - // The expected state is LSWI == 1, because the inverter is either - // on or off depending on the previous state. - // If LSWI == 0, it means that the switch changed values then - // changed back to the previous state. -// UPUT (0x6c) // l - If (LSWI) { - If (And(GHIN, 0x400)) - { // Inverted, became closed -// UPUT (0x30) - Store (0x4000000, GHIN) // Turn on invert to see falling edge - Store (Zero, Local0) - } Else { // Not inverted, became open -// UPUT (0x31) - Store (0x400, GHIN) // Turn on invert to see falling edge - Store (One, Local0) - } - } Else { // Spurious event - If (And(GHIN, 0x400)) - { // Inverted, stayed open - Store (One, Local0) -// UPUT (0x61) - } Else { - Store (Zero, Local0) -// UPUT (0x62) - } +// UPUT (0x6c) // l + Store (0x4000000, GHEE) // Disable events during readback + + Store (0x4000000, GHNE) // Select readback port .. + Store (0x4000000, GHPE) // by setting the multiplexor to 00 + Stall (100) // Give the signal three 32 kHz clock times to propate + Store ( 0x400, GHNS) // Clear lid negative status + Store ( 0x400, GHPS) // Clear lid positive status + + If (LSWI) { // Lid is open + Store (One, Local0) // Report open + } Else { + Store (Zero, Local0) // Report closed } -// UPUT (0x20)
+ // The only time that we are interested in the lid opening event + // is when we are asleep, i.e. just after the _PTS event, so it + // suffices to always setup for the closing event herein, leaving + // _PTS to flip the state to look for the lid-opening edge + Store ( 0x400, GHNE) // Look for lid closing + Store (0x4000000, GHPE) // .. not lid opening + + Stall (100) // Give the signal three 32 kHz clock times to propate + Store (0x400, GHEE) // Enable events Return (Local0) } } @@ -664,8 +648,8 @@ Name (_ADR, Zero)
// XXX Probably should be sleep state 0 - can't wake from PCI as power is off -// Name (_PRW, Package (0x02) { 0x1f, 0x05 }) -// XXX Name (_PRW, Package (0x02) { 0x1f, 0x03 }) +// Name (_PRW, Package (0x02) { 0x1f, 0x05 }) +// XXX Name (_PRW, Package (0x02) { 0x1f, 0x03 })
// Name (_STA, 0x0F) Method (_STA, 0, NotSerialized) { Return (0x0F) } @@ -713,9 +697,9 @@ 0x00000000, 0x000A0000, 0x000BFFFF, 0x00000000, 0x00020000, ,, , AddressRangeMemory, TypeStatic)
-// DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, Cacheable, ReadWrite, -// 0x00000000, 0x000C0000, 0x000DFFFF, 0x00000000, 0x00020000, -// ,, , AddressRangeMemory, TypeStatic) +// DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, Cacheable, ReadWrite, +// 0x00000000, 0x000C0000, 0x000DFFFF, 0x00000000, 0x00020000, +// ,, , AddressRangeMemory, TypeStatic)
DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, Cacheable, ReadWrite, 0x00000000, 0x000C8000, 0x000DFFFF, 0x00000000, 0x00018000, @@ -724,18 +708,18 @@
// This is a template, edited by _CRS, for the address space that PCI claims between the top of main memory and // the bottom of (SMM memory)?. -// DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, Cacheable, ReadWrite, -// 0x00000000, 0x04000000, 0x403FFFFF, 0x00000000, 0x3C400000, -// ,, _Y04, AddressRangeMemory, TypeStatic) +// DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, Cacheable, ReadWrite, +// 0x00000000, 0x04000000, 0x403FFFFF, 0x00000000, 0x3C400000, +// ,, _Y04, AddressRangeMemory, TypeStatic)
// This is a template, edited by _CRS, for the address space that PCI claims abover the top of SMM memory -// DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, Cacheable, ReadWrite, -// 0x00000000, 0x40500000, 0xEFFFFFFF, 0x00000000, 0xAFB00000, -// ,, _Y05, AddressRangeMemory, TypeStatic) +// DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, Cacheable, ReadWrite, +// 0x00000000, 0x40500000, 0xEFFFFFFF, 0x00000000, 0xAFB00000, +// ,, _Y05, AddressRangeMemory, TypeStatic)
-// DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, Cacheable, ReadWrite, -// 0x00000000, 0xB0000000, 0xbfFFFFFF, 0x00000000, 0x10000000, -// ,, , AddressRangeMemory, TypeStatic) +// DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, Cacheable, ReadWrite, +// 0x00000000, 0xB0000000, 0xbfFFFFFF, 0x00000000, 0x10000000, +// ,, , AddressRangeMemory, TypeStatic)
// Since we can't plug in PCI devices, there is no need for an allocation pool of PCI address space // We just declare a modest amount of PCI space and preassign device addresses in the firmware @@ -743,28 +727,12 @@ 0x00000000, 0xfd000000, 0xfeFFFFFF, 0x00000000, 0x02000000, ,, , AddressRangeMemory, TypeStatic)
-// DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, Cacheable, ReadWrite, -// 0x00000000, 0xF0000000, 0xFEFFFFFF, 0x00000000, 0x0f000000, -// ,, , AddressRangeMemory, TypeStatic) +// DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, Cacheable, ReadWrite, +// 0x00000000, 0xF0000000, 0xFEFFFFFF, 0x00000000, 0x0f000000, +// ,, , AddressRangeMemory, TypeStatic)
}) Method (_CRS, 0, NotSerialized) { -// VSAW(0, 2) -// CreateDWordField (CRES, _SB.PCI0._Y04._MIN, RMIN) -// CreateDWordField (CRES, _SB.PCI0._Y04._MAX, RMAX) -// CreateDWordField (CRES, _SB.PCI0._Y04._LEN, RLEN) -// CreateDWordField (CRES, _SB.PCI0._Y05._MIN, PMIN) -// CreateDWordField (CRES, _SB.PCI0._Y05._MAX, PMAX) -// CreateDWordField (CRES, _SB.PCI0._Y05._LEN, PLEN) -// Store (ZZY6, Local0) // size from EBDA[0x180] -// Add (Local0, 0x40, Local0) // + 64 -// ShiftLeft (Local0, 0x0A, RMIN) // * 1024 -> RMIN above -// Subtract (0x80400000, One, RMAX) // 803f.ffff -> RMAX above -// Subtract (RMAX, RMIN, Local1) -// Increment (Local1) -// Store (Local1, RLEN) // -> RLEN above -// Add (0x80400000, 0x00100000, PMIN) // -> PMIN -// Add (Subtract (PMAX, PMIN), One, PLEN) // -> PLEN Return (CRES) }
@@ -772,18 +740,13 @@ Name (_ADR, 0x000F0000) // PCI dev F, fn 0 Method (_INI, 0, NotSerialized) { ^^^_INI () -// VSAW(0, 3) } // Call root _INI ? Parent: PCI0 Grandparent: system bus
Device (RTC0) { -// Method (_INI, 0, NotSerialized) { VSAW(1, 0x55) }
Name (_HID, EisaId ("PNP0B00")) Name (_UID, Zero) -// Name (_STA, 0x0F) -Method (_STA, 0, NotSerialized) { -// VSAW(1, 0x56) - Return (0x0F) } + Name (_STA, 0x0F)
Name (_CRS, ResourceTemplate () { IRQNoFlags () {8} @@ -792,12 +755,8 @@ }
Device (TMR) { -// Method (_INI, 0, NotSerialized) { VSAW(2, 0x55) } Name (_HID, EisaId ("PNP0100")) -// Name (_STA, 0x0F) -Method (_STA, 0, NotSerialized) { -// VSAW(2, 0x56) - Return (0x0F) } + Name (_STA, 0x0F) Name (_CRS, ResourceTemplate () { IRQNoFlags () {0} IO (Decode16, 0x0040, 0x0040, 0x00, 0x04, ) @@ -807,14 +766,10 @@
// Elided speaker
-// XXX ??? Do we need to reinstate this MEM node??? - Device (MEM) { -// Method (_INI, 0, NotSerialized) { VSAW(3, 0x55) } Name (_HID, EisaId ("PNP0C01")) Name (_UID, One) Method (_CRS, 0, NotSerialized) { -// VSAW(0, 4) Name (MBRB, ResourceTemplate () { Memory32Fixed (ReadWrite, 0x00000000, 0x000A0000, ) Memory32Fixed (ReadOnly, 0x000E0000, 0x00020000, ) @@ -826,7 +781,7 @@ IO (Decode16, 0x0092, 0x0092, 0x00, 0x01, ) }) CreateDWordField (MBRB, _SB.PCI0.SBF0.MEM._CRS._Y06._LEN, EM1L) - Store (ZZY6, Local0) // Memory size in Kbytes (from EBDA) + Store (MEMK, Local0) // Memory size in Kbytes (from EBDA) Subtract (Local0, 0x0400, Local0) // Subtract 1024 (for below 1M mem) ShiftLeft (Local0, 0x0A, Local0) // Multiply by 1K to convert to bytes Store (Local0, EM1L) // Punch into the data structure @@ -836,12 +791,8 @@
Device (PIC) { -// Method (_INI, 0, NotSerialized) { VSAW(4, 0x55) } Name (_HID, EisaId ("PNP0000")) -// Name (_STA, 0x0F) -Method (_STA, 0, NotSerialized) { -// VSAW(4, 0x56) - Return (0x0F) } + Name (_STA, 0x0F) Name (_CRS, ResourceTemplate () { IRQNoFlags () {2} IO (Decode16, 0x0020, 0x0020, 0x00, 0x02, ) @@ -852,12 +803,8 @@
Device (MAD) { -// Method (_INI, 0, NotSerialized) { VSAW(5, 0x55) } Name (_HID, EisaId ("PNP0200")) -// Name (_STA, 0x0F) -Method (_STA, 0, NotSerialized) { -// VSAW(5, 0x56) - Return (0x0F) } + Name (_STA, 0x0F) Name (_CRS, ResourceTemplate () { DMA (Compatibility, BusMaster, Transfer8, ) {4} IO (Decode16, 0x0000, 0x0000, 0x10, 0x10, ) @@ -868,7 +815,6 @@ }
Device (COPR) { -// Method (_INI, 0, NotSerialized) { VSAW(6, 0x55) } Name (_HID, EisaId ("PNP0C04")) Name (_CRS, ResourceTemplate () { IO (Decode16, 0x00F0, 0x00F0, 0x10, 0x10, ) @@ -882,41 +828,31 @@
// XXX ??? Maybe this should be moved out a level so it's not under SB F0 Device (KBC) { -// Method (_INI, 0, NotSerialized) { VSAW(7, 0x55) } Name (_HID, EisaId ("PNP0303")) Name (_CID, 0x0B03D041)
// Return this one if can wake from keyboard - XXX maybe need to be 3 instead of One Name (_PRW, Package (0x02) { Zero, One })
-// XXX ??? do we need a _PSW method? - Method (_PSW, 1, NotSerialized) { } + Method (_PSW, 1, NotSerialized) { }
- // XXX Can we control whether or not the keyboard can wake us up? + // Q: Can we control whether or not the keyboard can wake us up? + // A: Yes, via EC commands. But we choose not to for now. Name (_CRS, ResourceTemplate () { IRQNoFlags () {1} IO (Decode16, 0x0060, 0x0060, 0x00, 0x01, ) IO (Decode16, 0x0064, 0x0064, 0x00, 0x01, ) }) -// Name (_STA, 0x0F) -Method (_STA, 0, NotSerialized) { -// VSAW(7, 0x56) - Return (0x0F) } + Name (_STA, 0x0F) }
Device (PS2M) { -// Method (_INI, 0, NotSerialized) { VSAW(0xc, 0x55) } -// Name (_HID, EisaId ("PNP0F13")) // Microsoft Intellipoint Name (_HID, EisaId ("PNP0F03")) // ALPS Pointing device Name (_CID, 0x130FD041) Name (_PRW, Package (0x02) { Zero, One }) -// XXX ??? do we need a _PSW method? Method (_PSW, 1, NotSerialized) { } Name (_CRS, ResourceTemplate () { IRQNoFlags () {12} }) -// Name (_STA, 0x0F ) -Method (_STA, 0, NotSerialized) { -// VSAW(0xc, 0x56) - Return (0x0F) } + Name (_STA, 0x0F ) } // Elided FDC0 // Elided SuperIO UART @@ -925,37 +861,27 @@ }
Device (USB0) { -// Method (_INI, 0, NotSerialized) { VSAW(8, 0x55) } Name (_ADR, 0x000F0004) Name (_STR, Unicode ("CS553x USB Controller 0")) -// Name (_STA, 0x0F) -Method (_STA, 0, NotSerialized) { -// VSAW(8, 0x56) - Return (0x0F) } + Name (_STA, 0x0F)
Name (_PRW, Package (0x02) { 0x06, One }) }
Device (USB1) { -// Method (_INI, 0, NotSerialized) { VSAW(9, 0x55) } Name (_ADR, 0x000F0005) Name (_STR, Unicode ("CS553x USB Controller 1")) -// Name (_STA, 0x0F) -Method (_STA, 0, NotSerialized) { -// VSAW(9, 0x56) - Return (0x0F) } + Name (_STA, 0x0F) Name (_PRW, Package (0x02) { 0x06, One }) }
// Device (USB2) { -// Method (_INI, 0, NotSerialized) { VSAW(0xa, 0x55) } // Name (_ADR, 0x000F0006) // Name (_STR, Unicode ("CS5536 USB Controller 2 (UDC)")) // Name (_STA, 0x0F) // }
// Device (USB3) { -// Method (_INI, 0, NotSerialized) { VSAW(0xb, 0x55) } // Name (_ADR, 0x000F0007) // Name (_STR, Unicode ("CS5536 USB Controller 3 (OTG)")) // Name (_STA, 0x0F)
Modified: cpu/x86/pc/olpc/fw.bth =================================================================== --- cpu/x86/pc/olpc/fw.bth 2009-01-07 09:14:26 UTC (rev 1067) +++ cpu/x86/pc/olpc/fw.bth 2009-01-09 06:08:34 UTC (rev 1068) @@ -344,6 +344,7 @@ fload ${BP}/cpu/x86/pc/olpc/smbios.fth \ fload ${BP}/cpu/x86/pc/biosload/rmenter.fth fload ${BP}/cpu/x86/pc/biosints.fth +fload ${BP}/cpu/x86/pc/olpc/biosresume.fth
fload ${BP}/cpu/x86/pc/olpc/setwp.fth fload ${BP}/cpu/x86/pc/olpc/security.fth
Modified: dev/geode/smi.fth =================================================================== --- dev/geode/smi.fth 2009-01-07 09:14:26 UTC (rev 1067) +++ dev/geode/smi.fth 2009-01-09 06:08:34 UTC (rev 1068) @@ -783,6 +783,12 @@ enable-io-smis ;
+defer suspend-devices ' noop to suspend-devices +defer resume-devices ' noop to resume-devices + +defer freeze-ps2 ' noop to freeze-ps2 +defer unfreeze-ps2 ' noop to unfreeze-ps2 + \ Implement the ACPI S3 (suspend to RAM) semantics using the OFW \ "S3 looks like a subroutine call" semantics. This requires \ some fancy mode switching. @@ -794,13 +800,13 @@ resume-debug? if debug-me then exit-smi resume-debug? if ." enter s3" cr then - dcon-power-off - wlan-freeze + + suspend-devices + s3 - wlan-reset - dcon-power-on - d# 10 ms - " dcon-restart" screen-ih $call-method + + resume-devices + \ ." Return from S3" cr interact \ noop setup-smi