Commit 4b7618fd authored by Srinivas Ramana's avatar Srinivas Ramana Committed by Linus Walleij

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: default avatarSrinivas Ramana <sramana@codeaurora.org>
Signed-off-by: default avatarNeeraj Upadhyay <neeraju@codeaurora.org>
Link: https://lore.kernel.org/r/1561472086-23360-1-git-send-email-neeraju@codeaurora.orgSigned-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 4cb8df37
...@@ -752,7 +752,7 @@ static void msm_gpio_irq_mask(struct irq_data *d) ...@@ -752,7 +752,7 @@ static void msm_gpio_irq_mask(struct irq_data *d)
raw_spin_unlock_irqrestore(&pctrl->lock, flags); raw_spin_unlock_irqrestore(&pctrl->lock, flags);
} }
static void msm_gpio_irq_unmask(struct irq_data *d) static void msm_gpio_irq_clear_unmask(struct irq_data *d, bool status_clear)
{ {
struct gpio_chip *gc = irq_data_get_irq_chip_data(d); struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
struct msm_pinctrl *pctrl = gpiochip_get_data(gc); struct msm_pinctrl *pctrl = gpiochip_get_data(gc);
...@@ -764,6 +764,17 @@ static void msm_gpio_irq_unmask(struct irq_data *d) ...@@ -764,6 +764,17 @@ static void msm_gpio_irq_unmask(struct irq_data *d)
raw_spin_lock_irqsave(&pctrl->lock, flags); raw_spin_lock_irqsave(&pctrl->lock, flags);
if (status_clear) {
/*
* clear the interrupt status bit before unmask to avoid
* any erroneous interrupts that would have got latched
* when the interrupt is not in use.
*/
val = msm_readl_intr_status(pctrl, g);
val &= ~BIT(g->intr_status_bit);
msm_writel_intr_status(val, pctrl, g);
}
val = msm_readl_intr_cfg(pctrl, g); val = msm_readl_intr_cfg(pctrl, g);
val |= BIT(g->intr_raw_status_bit); val |= BIT(g->intr_raw_status_bit);
val |= BIT(g->intr_enable_bit); val |= BIT(g->intr_enable_bit);
...@@ -774,6 +785,17 @@ static void msm_gpio_irq_unmask(struct irq_data *d) ...@@ -774,6 +785,17 @@ static void msm_gpio_irq_unmask(struct irq_data *d)
raw_spin_unlock_irqrestore(&pctrl->lock, flags); raw_spin_unlock_irqrestore(&pctrl->lock, flags);
} }
static void msm_gpio_irq_enable(struct irq_data *d)
{
msm_gpio_irq_clear_unmask(d, true);
}
static void msm_gpio_irq_unmask(struct irq_data *d)
{
msm_gpio_irq_clear_unmask(d, false);
}
static void msm_gpio_irq_ack(struct irq_data *d) static void msm_gpio_irq_ack(struct irq_data *d)
{ {
struct gpio_chip *gc = irq_data_get_irq_chip_data(d); struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
...@@ -1004,6 +1026,7 @@ static int msm_gpio_init(struct msm_pinctrl *pctrl) ...@@ -1004,6 +1026,7 @@ static int msm_gpio_init(struct msm_pinctrl *pctrl)
chip->need_valid_mask = msm_gpio_needs_valid_mask(pctrl); chip->need_valid_mask = msm_gpio_needs_valid_mask(pctrl);
pctrl->irq_chip.name = "msmgpio"; pctrl->irq_chip.name = "msmgpio";
pctrl->irq_chip.irq_enable = msm_gpio_irq_enable;
pctrl->irq_chip.irq_mask = msm_gpio_irq_mask; pctrl->irq_chip.irq_mask = msm_gpio_irq_mask;
pctrl->irq_chip.irq_unmask = msm_gpio_irq_unmask; pctrl->irq_chip.irq_unmask = msm_gpio_irq_unmask;
pctrl->irq_chip.irq_ack = msm_gpio_irq_ack; pctrl->irq_chip.irq_ack = msm_gpio_irq_ack;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment