fix-pcf50633-disable-irq-from-suspend-until-resume.patch
commiteaa55efc0b559abebbcf2acea6ce267cea4c26f2
authorAndy Green <andy@openmoko.com>
Wed, 2 Jul 2008 21:41:52 +0000 (2 22:41 +0100)
committerAndy Green <agreen@localhost.localdomain>
Wed, 2 Jul 2008 21:41:52 +0000 (2 22:41 +0100)
tree6446dd6c4a88a317baa97dc4d584cf5af7f8e8f2
parentdd7ff306b150c36950fa0f9dd718a1745a984d38
fix-pcf50633-disable-irq-from-suspend-until-resume.patch

Disable pcf interrupt (not for wake, just as interrupt) in
suspend, re-enable it again just before we force-call the
workqueue function at end of pcf resume, which leads to
pcf interrupt source registers getting cleared so it can
signal an interrupt normally again.

This change ends the uncontrolled appearance of pcf interrupts
during resume time which previously caused the work to attempt
to use the I2C stuff before i2c host device had itself resumed.
Now the isr work is only queued, and the isr work function called,
definitively after pcf resume completes.

In suspend time, the work function may have been queued some
time before and be pending, and it could still show up at a
bad time.  Therefore if the work function sees that it is
coming since the start of pcf50633 suspend function, it
aborts without attempting to read the pcf interrupt regs,
leaving them for resume to take care of.

USB current limit and no battery work functions are also made
aware of suspend state and act accordingly.

Lastly I noticed that in early resume, i2c_get_clientdata(&pcf->client)
returns NULL, presumably because i2c device is still suspended.  This
could easily make trouble for async events like interrupt work,
since pcf pointer is the client data.  Disabling appearance of the
work until after pcf50633 resume will also avoid that.

Signed-off-by: Andy Green <andy@openmoko.com>
drivers/i2c/chips/pcf50633.c