summaryrefslogtreecommitdiff
path: root/drivers/spmi
diff options
context:
space:
mode:
authorDavid Collins <collinsd@codeaurora.org>2013-11-05 09:31:16 -0800
committerRohit Vaswani <rvaswani@codeaurora.org>2016-03-01 12:22:48 -0800
commit1f314dfa8f7be08155e096ad59954159fc534f5b (patch)
tree8c7e89bc23f35fff53372024d3edecab36670600 /drivers/spmi
parentd08f416687fb1cf36d2a6765d0fa5096a12f0e19 (diff)
spmi: pmic-arb: 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, while resuming an irq, an unmask could be called even if it was not previously masked. So, before writing these registers, check if the interrupt is already enabled within the PMIC. If it is, 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: Ie05845b692a151c39943aa3e2aad6bcae4194d83 Signed-off-by: David Collins <collinsd@codeaurora.org> Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
Diffstat (limited to 'drivers/spmi')
-rw-r--r--drivers/spmi/spmi-pmic-arb.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/drivers/spmi/spmi-pmic-arb.c b/drivers/spmi/spmi-pmic-arb.c
index f5b22175ee49..01a9f8d5515e 100644
--- a/drivers/spmi/spmi-pmic-arb.c
+++ b/drivers/spmi/spmi-pmic-arb.c
@@ -616,8 +616,8 @@ static void qpnpint_irq_unmask(struct irq_data *d)
u8 apid = d->hwirq;
unsigned long flags;
u32 status;
- u8 data = BIT(irq);
u8 prev_enabled_irq_mask;
+ u8 buf[2];
prev_enabled_irq_mask = pa->apid_data[apid].enabled_irq_mask;
pa->apid_data[apid].enabled_irq_mask &= ~BIT(irq);
@@ -635,7 +635,17 @@ static void qpnpint_irq_unmask(struct irq_data *d)
raw_spin_unlock_irqrestore(&pa->lock, flags);
}
- qpnpint_spmi_write(d, QPNPINT_REG_EN_SET, &data, 1);
+ qpnpint_spmi_read(d, QPNPINT_REG_EN_SET, &buf[0], 1);
+ if (!(buf[0] & BIT(irq))) {
+ /*
+ * 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] = BIT(irq);
+ buf[1] = BIT(irq);
+ qpnpint_spmi_write(d, QPNPINT_REG_LATCHED_CLR, &buf, 2);
+ }
}
static int qpnpint_irq_set_type(struct irq_data *d, unsigned int flow_type)