soc/amd/stoneyridge/gpio: Configure debounce for irq gpios
commitb82afce18aff24b6e5e3b73a67a6533cc4865a26
authorDaniel Kurtz <djkurtz@chromium.org>
Mon, 14 Jan 2019 21:45:47 +0000 (14 14:45 -0700)
committerMartin Roth <martinroth@google.com>
Wed, 16 Jan 2019 18:20:36 +0000 (16 18:20 +0000)
tree772e5e50b47e354b7e6ab4e3ef8172dbb0100a96
parentac1a5a82181c3276963807c4a11ab5edb5eb52f7
soc/amd/stoneyridge/gpio: Configure debounce for irq gpios

FT4 has a strange property where whenever the debounce registers for any
one gpio are changed, the FT4 disables interrupt propagation for ALL
gpio irqs for ~4ms.

In other words, if an edge interrupt of one gpio happens exactly during
this debounce-irq-off window immediately following the configuration of
another gpio, the interrupt will be lost.

It is quite difficult to deal with this in the kernel, since during kernel
boot time, drivers & devices are probed asynchronously, meaning it may
happen that an already loaded driver may miss an interrupt when some
later driver is being probed and configuring its gpio interrupt.

To eliminate this possibility, we pre-configure the debounce registers in
ram stage for all gpios that will be used as irqs later by the kernel
using the same configuration as used by the kernel, as per this table:

 IRQ         Debounce
 Edge        Remove Glitch
 Level High  Preserve Low Glitch
 Level Low   Preserve High Glitch

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
BUG=b:113880780
BRANCH=none
TEST=Reboot stress test grunt (>100 times); no messages in dmesg like:
  tpm tpm0: Timeout waiting for TPM ready

Change-Id: I94c7ecfb14e5bb209b3598e10287c80eb19da25b
Reviewed-on: https://review.coreboot.org/c/30921
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Martin Roth <martinroth@google.com>
src/soc/amd/stoneyridge/gpio.c
src/soc/amd/stoneyridge/include/soc/gpio.h