#5703 HIGH 8.2.0 (: Lid switch detection is unreliable.
Zarro Boogs per Child
bugtracker at laptop.org
Tue Jul 29 20:42:59 EDT 2008
#5703: Lid switch detection is unreliable.
-------------------------+--------------------------------------------------
Reporter: cjb | Owner: dilinger
Type: defect | Status: new
Priority: high | Milestone: 8.2.0 (was Update.2)
Component: kernel | Version:
Resolution: | Keywords: power
Next_action: never set | Verified: 0
Blockedby: | Blocking: 6590
-------------------------+--------------------------------------------------
Comment(by wmb at firmworks.com):
I don't think we can distinguish between 2 edges (close open) and 3 edges
(close open close) without using pin readback.
Here is an idea for a way to setup and use the GPIO circuit so as to avoid
the inherent problems with the edge detection. (The problem is that you
can't read back the input pin state when the edge detectors are on, and
when you turn them off, you have to wait 100 uS before you can see the pin
state. It's best not to have delays in an interrupt routine.)
The idea depends on the facts that 0 to 1 events are detected even when
both edge enables are off and that you can invert the GPIO pin at the
source.
The trick is to leave both edge enables off (the master event enable can
stay on).
When the GPIO pin is currently high, as determined by readback, set the
"input invert" bit to make its internal version "go low" with respect to
the event detector. That high-to-low internal transition does not cause an
event.
When the external signal goes low, the inverted internal form goes high,
triggering an event. The interrupt handler uses the readback to verify
that it is indeed still in the expected new state (internal version high),
and if so, clears the inverter so the next event will occur when the
external signal goes high again. If the readback show that the pin is
still in the old state, the event can be ignored as a glitch (i.e. a brief
transition that was subsequently "undone").
The posedge and negedge detectors never come into play. Only the implicit
positive edge detector represented by the PME EdgeLatch is used. There is
no need for any delays. There are no worries about missed events because
the action to take depends on the readback state, not on the assumption
that there was exactly one edge.
--
Ticket URL: <http://dev.laptop.org/ticket/5703#comment:16>
One Laptop Per Child <http://laptop.org/>
OLPC bug tracking system
More information about the Bugs
mailing list