spmi: qpnp-int: clear the latched status when unmasking an interrupt
PMIC interrupts each have an internal latched status bit which is not visible from any register. This status bit is set as soon as the conditions specified in the interrupt type and polarity registers are met even if the interrupt is not enabled. When it is set, nothing else changes within the PMIC and no interrupt notification packets are sent. If the internal latched status bit is set when an interrupt is enabled, then the value is immediately propagated into the interrupt latched status register and an interrupt notification packet is sent out from the PMIC over SPMI. This PMIC hardware behavior can lead to a situation where the handler for a level triggered interrupt is called immediately after enable_irq() is called even though the interrupt physically triggered while it was disabled within the genirq framework. This situation takes place if the the interrupt fires twice after calling disable_irq(). The first time it fires, the level flow handler will mask and disregard it. Unfortunately, the second time it fires, the internal latched status bit is set within the PMIC and no further notification is received. When enable_irq() is called later, the interrupt is unmasked (enabled in the PMIC) which results in the PMIC immediately sending an interrupt notification packet out over SPMI. This breaks the semantics of level triggered interrupts within the genirq framework since they should be completely ignored while disabled. The PMIC internal latched status behavior also affects how interrupts are treated during suspend. While entering suspend, all interrupts not specified as wakeup mode are masked. Upon resume, these interrupts are unmasked. Thus if any of the non-wakeup PMIC interrupts fired while the system was suspended, then the PMIC will send interrupt notification packets out via SPMI as soon as they are unmasked during resume. This behavior violates genirq semantics as well since non-wakeup interrupts should be completely ignored during suspend. Modify the qpnpint_irq_unmask() function so that the interrupt latched status clear register is written immediately before the interrupt enable register. This clears the internal latched status bit of the interrupt so that it cannot trigger spuriously immediately upon being enabled. Also, before writing these registers, check if the interrupt is already enabled within the PMIC. If it is enabled, then no further register writes are required. This condition check ensures that a valid latched status register bit is not cleared until it is properly handled. Change-Id: Ib99a384bfeba440a4ad91cd0e16e8f62e4352f28 Signed-off-by: David Collins <collinsd@codeaurora.org>
This commit is contained in:
parent
d079346dec
commit
069376c1fe
|
@ -251,6 +251,7 @@ static void qpnpint_irq_unmask(struct irq_data *d)
|
|||
struct q_chip_data *chip_d = irq_d->chip_d;
|
||||
struct q_perip_data *per_d = irq_d->per_d;
|
||||
int rc;
|
||||
uint8_t buf[2];
|
||||
uint8_t prev_int_en = per_d->int_en;
|
||||
|
||||
pr_debug("hwirq %lu irq: %d\n", d->hwirq, d->irq);
|
||||
|
@ -271,12 +272,29 @@ static void qpnpint_irq_unmask(struct irq_data *d)
|
|||
*/
|
||||
qpnpint_arbiter_op(d, irq_d, chip_d->cb->unmask);
|
||||
}
|
||||
rc = qpnpint_spmi_write(irq_d, QPNPINT_REG_EN_SET,
|
||||
&irq_d->mask_shift, 1);
|
||||
|
||||
/* Check the current state of the interrupt enable bit. */
|
||||
rc = qpnpint_spmi_read(irq_d, QPNPINT_REG_EN_SET, buf, 1);
|
||||
if (rc) {
|
||||
pr_err("spmi failure on irq %d\n", d->irq);
|
||||
pr_err("SPMI read failure for IRQ %d, rc=%d\n", d->irq, rc);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(buf[0] & irq_d->mask_shift)) {
|
||||
/*
|
||||
* Since the interrupt is currently disabled, write to both the
|
||||
* LATCHED_CLR and EN_SET registers so that a spurious interrupt
|
||||
* cannot be triggered when the interrupt is enabled.
|
||||
*/
|
||||
buf[0] = irq_d->mask_shift;
|
||||
buf[1] = irq_d->mask_shift;
|
||||
rc = qpnpint_spmi_write(irq_d, QPNPINT_REG_LATCHED_CLR, buf, 2);
|
||||
if (rc) {
|
||||
pr_err("SPMI write failure for IRQ %d, rc=%d\n", d->irq,
|
||||
rc);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int qpnpint_irq_set_type(struct irq_data *d, unsigned int flow_type)
|
||||
|
|
Loading…
Reference in New Issue