aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pinctrl/sunxi
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2014-06-29 10:11:00 -0400
committerLinus Walleij <linus.walleij@linaro.org>2014-07-11 08:08:24 -0400
commitfea6d8efd023a2438c848c049480ea67ea0bca16 (patch)
treeccf7e232dfb80c3955a0e3a0c47205ce5b8b689c /drivers/pinctrl/sunxi
parent578c0a8721278770b851ecd23c5873ceda598ae8 (diff)
pinctrl: sunxi: Move setting of mux to irq type
With level triggered interrupt mask / unmask will get called for each interrupt, doing the somewhat expensive mux setting on each unmask thus is not a good idea. Instead add a request_resources callback and do it there. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl/sunxi')
-rw-r--r--drivers/pinctrl/sunxi/pinctrl-sunxi.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.c b/drivers/pinctrl/sunxi/pinctrl-sunxi.c
index c19933737fa5..8bdd65b924ca 100644
--- a/drivers/pinctrl/sunxi/pinctrl-sunxi.c
+++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.c
@@ -531,6 +531,21 @@ static int sunxi_pinctrl_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
531 return irq_find_mapping(pctl->domain, desc->irqnum); 531 return irq_find_mapping(pctl->domain, desc->irqnum);
532} 532}
533 533
534static int sunxi_pinctrl_irq_request_resources(struct irq_data *d)
535{
536 struct sunxi_pinctrl *pctl = irq_data_get_irq_chip_data(d);
537 struct sunxi_desc_function *func;
538
539 func = sunxi_pinctrl_desc_find_function_by_pin(pctl,
540 pctl->irq_array[d->hwirq], "irq");
541 if (!func)
542 return -EINVAL;
543
544 /* Change muxing to INT mode */
545 sunxi_pmx_set(pctl->pctl_dev, pctl->irq_array[d->hwirq], func->muxval);
546
547 return 0;
548}
534 549
535static int sunxi_pinctrl_irq_set_type(struct irq_data *d, 550static int sunxi_pinctrl_irq_set_type(struct irq_data *d,
536 unsigned int type) 551 unsigned int type)
@@ -603,19 +618,11 @@ static void sunxi_pinctrl_irq_mask(struct irq_data *d)
603static void sunxi_pinctrl_irq_unmask(struct irq_data *d) 618static void sunxi_pinctrl_irq_unmask(struct irq_data *d)
604{ 619{
605 struct sunxi_pinctrl *pctl = irq_data_get_irq_chip_data(d); 620 struct sunxi_pinctrl *pctl = irq_data_get_irq_chip_data(d);
606 struct sunxi_desc_function *func;
607 u32 reg = sunxi_irq_ctrl_reg(d->hwirq); 621 u32 reg = sunxi_irq_ctrl_reg(d->hwirq);
608 u8 idx = sunxi_irq_ctrl_offset(d->hwirq); 622 u8 idx = sunxi_irq_ctrl_offset(d->hwirq);
609 unsigned long flags; 623 unsigned long flags;
610 u32 val; 624 u32 val;
611 625
612 func = sunxi_pinctrl_desc_find_function_by_pin(pctl,
613 pctl->irq_array[d->hwirq],
614 "irq");
615
616 /* Change muxing to INT mode */
617 sunxi_pmx_set(pctl->pctl_dev, pctl->irq_array[d->hwirq], func->muxval);
618
619 spin_lock_irqsave(&pctl->lock, flags); 626 spin_lock_irqsave(&pctl->lock, flags);
620 627
621 /* Unmask the IRQ */ 628 /* Unmask the IRQ */
@@ -629,6 +636,7 @@ static struct irq_chip sunxi_pinctrl_irq_chip = {
629 .irq_ack = sunxi_pinctrl_irq_ack, 636 .irq_ack = sunxi_pinctrl_irq_ack,
630 .irq_mask = sunxi_pinctrl_irq_mask, 637 .irq_mask = sunxi_pinctrl_irq_mask,
631 .irq_unmask = sunxi_pinctrl_irq_unmask, 638 .irq_unmask = sunxi_pinctrl_irq_unmask,
639 .irq_request_resources = sunxi_pinctrl_irq_request_resources,
632 .irq_set_type = sunxi_pinctrl_irq_set_type, 640 .irq_set_type = sunxi_pinctrl_irq_set_type,
633 .flags = IRQCHIP_SKIP_SET_WAKE, 641 .flags = IRQCHIP_SKIP_SET_WAKE,
634}; 642};