Skip to content

Commit 4b7618f

Browse files
Srinivas Ramanalinusw
authored andcommitted
pinctrl: qcom: Add irq_enable callback for msm gpio
Introduce the irq_enable callback which will be same as irq_unmask except that it will also clear the status bit before unmask. This will help in clearing any erroneous interrupts that would have got latched when the interrupt is not in use. There may be devices like UART which can use the same gpio line for data rx as well as a wakeup gpio when in suspend. The data that was flowing on the line may latch the interrupt and when we enable the interrupt before going to suspend, this would trigger the unexpected interrupt. This change helps clearing the interrupt so that these unexpected interrupts gets cleared. Signed-off-by: Srinivas Ramana <[email protected]> Signed-off-by: Neeraj Upadhyay <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Linus Walleij <[email protected]>
1 parent 4cb8df3 commit 4b7618f

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

drivers/pinctrl/qcom/pinctrl-msm.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,7 @@ static void msm_gpio_irq_mask(struct irq_data *d)
752752
raw_spin_unlock_irqrestore(&pctrl->lock, flags);
753753
}
754754

755-
static void msm_gpio_irq_unmask(struct irq_data *d)
755+
static void msm_gpio_irq_clear_unmask(struct irq_data *d, bool status_clear)
756756
{
757757
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
758758
struct msm_pinctrl *pctrl = gpiochip_get_data(gc);
@@ -764,6 +764,17 @@ static void msm_gpio_irq_unmask(struct irq_data *d)
764764

765765
raw_spin_lock_irqsave(&pctrl->lock, flags);
766766

767+
if (status_clear) {
768+
/*
769+
* clear the interrupt status bit before unmask to avoid
770+
* any erroneous interrupts that would have got latched
771+
* when the interrupt is not in use.
772+
*/
773+
val = msm_readl_intr_status(pctrl, g);
774+
val &= ~BIT(g->intr_status_bit);
775+
msm_writel_intr_status(val, pctrl, g);
776+
}
777+
767778
val = msm_readl_intr_cfg(pctrl, g);
768779
val |= BIT(g->intr_raw_status_bit);
769780
val |= BIT(g->intr_enable_bit);
@@ -774,6 +785,17 @@ static void msm_gpio_irq_unmask(struct irq_data *d)
774785
raw_spin_unlock_irqrestore(&pctrl->lock, flags);
775786
}
776787

788+
static void msm_gpio_irq_enable(struct irq_data *d)
789+
{
790+
791+
msm_gpio_irq_clear_unmask(d, true);
792+
}
793+
794+
static void msm_gpio_irq_unmask(struct irq_data *d)
795+
{
796+
msm_gpio_irq_clear_unmask(d, false);
797+
}
798+
777799
static void msm_gpio_irq_ack(struct irq_data *d)
778800
{
779801
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
@@ -1004,6 +1026,7 @@ static int msm_gpio_init(struct msm_pinctrl *pctrl)
10041026
chip->need_valid_mask = msm_gpio_needs_valid_mask(pctrl);
10051027

10061028
pctrl->irq_chip.name = "msmgpio";
1029+
pctrl->irq_chip.irq_enable = msm_gpio_irq_enable;
10071030
pctrl->irq_chip.irq_mask = msm_gpio_irq_mask;
10081031
pctrl->irq_chip.irq_unmask = msm_gpio_irq_unmask;
10091032
pctrl->irq_chip.irq_ack = msm_gpio_irq_ack;

0 commit comments

Comments
 (0)