When flipping the polarity will be generated interrupt under certain circumstances, but GPIO external signal has not changed. Then, mask the interrupt before polarity setting, and clear the unexpected interrupt after trigger type setting completed. Remove mtk_eint_flip_edge: because mtk_eint_unmask already calls it.
Unified · Split
| @@ -157,6 +157,7 @@ static void mtk_eint_ack(struct irq_data *d) · 156 unmodified lines | |||
| 157 | static int mtk_eint_set_type(struct irq_data *d, unsigned int type) | 157 | static int mtk_eint_set_type(struct irq_data *d, unsigned int type) |
| 158 | { | 158 | { |
| 159 | struct mtk_eint *eint = irq_data_get_irq_chip_data(d); | 159 | struct mtk_eint *eint = irq_data_get_irq_chip_data(d); |
| 160 | bool masked; | ||
| 160 | u32 mask = BIT(d->hwirq & 0x1f); | 161 | u32 mask = BIT(d->hwirq & 0x1f); |
| 161 | void __iomem *reg; | 162 | void __iomem *reg; |
| 162 | 163 | ||
| @@ -173,6 +174,13 @@ static int mtk_eint_set_type(struct irq_data *d, unsigned int type) · 10 unmodified lines | |||
| 173 | else | 174 | else |
| 174 | eint->dual_edge[d->hwirq] = 0; | 175 | eint->dual_edge[d->hwirq] = 0; |
| 175 | 176 | ||
| 177 | if (!mtk_eint_get_mask(eint, d->hwirq)) { | ||
| 178 | mtk_eint_mask(d); | ||
| 179 | masked = false; | ||
| 180 | } else { | ||
| 181 | masked = true; | ||
| 182 | } | ||
| 183 | |||
| 176 | if (type & (IRQ_TYPE_LEVEL_LOW | IRQ_TYPE_EDGE_FALLING)) { | 184 | if (type & (IRQ_TYPE_LEVEL_LOW | IRQ_TYPE_EDGE_FALLING)) { |
| 177 | reg = mtk_eint_get_offset(eint, d->hwirq, eint->regs->pol_clr); | 185 | reg = mtk_eint_get_offset(eint, d->hwirq, eint->regs->pol_clr); |
| 178 | writel(mask, reg); | 186 | writel(mask, reg); |
| @@ -189,8 +197,9 @@ static int mtk_eint_set_type(struct irq_data *d, unsigned int type) · 10 unmodified lines | |||
| 189 | writel(mask, reg); | 197 | writel(mask, reg); |
| 190 | } | 198 | } |
| 191 | 199 | ||
| 192 | if (eint->dual_edge[d->hwirq]) | 200 | mtk_eint_ack(d); |
| 193 | mtk_eint_flip_edge(eint, d->hwirq); | 201 | if (!masked) |
| 202 | mtk_eint_unmask(d); | ||
| 194 | 203 | ||
| 195 | return 0; | 204 | return 0; |
| 196 | } | 205 | } |