Skip to content

Commit 42da71a

Browse files
committed
pinctrl: nomadik: Make gpio irqchip immutable
This makes the Nomadik GPIO irqchip immutable. Tested on the Samsung Galaxy SIII mini GT-I8190. Cc: Marc Zyngier <[email protected]> Acked-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Linus Walleij <[email protected]>
1 parent e5ec1f9 commit 42da71a

File tree

1 file changed

+35
-24
lines changed

1 file changed

+35
-24
lines changed

drivers/pinctrl/nomadik/pinctrl-nomadik.c

Lines changed: 35 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,6 @@ enum nmk_gpio_slpm {
244244

245245
struct nmk_gpio_chip {
246246
struct gpio_chip chip;
247-
struct irq_chip irqchip;
248247
void __iomem *addr;
249248
struct clk *clk;
250249
unsigned int bank;
@@ -675,10 +674,9 @@ static void __nmk_gpio_set_wake(struct nmk_gpio_chip *nmk_chip,
675674
__nmk_gpio_irq_modify(nmk_chip, offset, WAKE, on);
676675
}
677676

678-
static int nmk_gpio_irq_maskunmask(struct irq_data *d, bool enable)
677+
static void nmk_gpio_irq_maskunmask(struct nmk_gpio_chip *nmk_chip,
678+
struct irq_data *d, bool enable)
679679
{
680-
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
681-
struct nmk_gpio_chip *nmk_chip = gpiochip_get_data(gc);
682680
unsigned long flags;
683681

684682
clk_enable(nmk_chip->clk);
@@ -693,18 +691,24 @@ static int nmk_gpio_irq_maskunmask(struct irq_data *d, bool enable)
693691
spin_unlock(&nmk_chip->lock);
694692
spin_unlock_irqrestore(&nmk_gpio_slpm_lock, flags);
695693
clk_disable(nmk_chip->clk);
696-
697-
return 0;
698694
}
699695

700696
static void nmk_gpio_irq_mask(struct irq_data *d)
701697
{
702-
nmk_gpio_irq_maskunmask(d, false);
698+
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
699+
struct nmk_gpio_chip *nmk_chip = gpiochip_get_data(gc);
700+
701+
nmk_gpio_irq_maskunmask(nmk_chip, d, false);
702+
gpiochip_disable_irq(gc, irqd_to_hwirq(d));
703703
}
704704

705705
static void nmk_gpio_irq_unmask(struct irq_data *d)
706706
{
707-
nmk_gpio_irq_maskunmask(d, true);
707+
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
708+
struct nmk_gpio_chip *nmk_chip = gpiochip_get_data(gc);
709+
710+
gpiochip_enable_irq(gc, irqd_to_hwirq(d));
711+
nmk_gpio_irq_maskunmask(nmk_chip, d, true);
708712
}
709713

710714
static int nmk_gpio_irq_set_wake(struct irq_data *d, unsigned int on)
@@ -1072,13 +1076,34 @@ static struct nmk_gpio_chip *nmk_gpio_populate_chip(struct device_node *np,
10721076
return nmk_chip;
10731077
}
10741078

1079+
static void nmk_gpio_irq_print_chip(struct irq_data *d, struct seq_file *p)
1080+
{
1081+
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
1082+
struct nmk_gpio_chip *nmk_chip = gpiochip_get_data(gc);
1083+
1084+
seq_printf(p, "nmk%u-%u-%u", nmk_chip->bank,
1085+
gc->base, gc->base + gc->ngpio - 1);
1086+
}
1087+
1088+
static const struct irq_chip nmk_irq_chip = {
1089+
.irq_ack = nmk_gpio_irq_ack,
1090+
.irq_mask = nmk_gpio_irq_mask,
1091+
.irq_unmask = nmk_gpio_irq_unmask,
1092+
.irq_set_type = nmk_gpio_irq_set_type,
1093+
.irq_set_wake = nmk_gpio_irq_set_wake,
1094+
.irq_startup = nmk_gpio_irq_startup,
1095+
.irq_shutdown = nmk_gpio_irq_shutdown,
1096+
.irq_print_chip = nmk_gpio_irq_print_chip,
1097+
.flags = IRQCHIP_MASK_ON_SUSPEND | IRQCHIP_IMMUTABLE,
1098+
GPIOCHIP_IRQ_RESOURCE_HELPERS,
1099+
};
1100+
10751101
static int nmk_gpio_probe(struct platform_device *dev)
10761102
{
10771103
struct device_node *np = dev->dev.of_node;
10781104
struct nmk_gpio_chip *nmk_chip;
10791105
struct gpio_chip *chip;
10801106
struct gpio_irq_chip *girq;
1081-
struct irq_chip *irqchip;
10821107
bool supports_sleepmode;
10831108
int irq;
10841109
int ret;
@@ -1119,22 +1144,8 @@ static int nmk_gpio_probe(struct platform_device *dev)
11191144
chip->can_sleep = false;
11201145
chip->owner = THIS_MODULE;
11211146

1122-
irqchip = &nmk_chip->irqchip;
1123-
irqchip->irq_ack = nmk_gpio_irq_ack;
1124-
irqchip->irq_mask = nmk_gpio_irq_mask;
1125-
irqchip->irq_unmask = nmk_gpio_irq_unmask;
1126-
irqchip->irq_set_type = nmk_gpio_irq_set_type;
1127-
irqchip->irq_set_wake = nmk_gpio_irq_set_wake;
1128-
irqchip->irq_startup = nmk_gpio_irq_startup;
1129-
irqchip->irq_shutdown = nmk_gpio_irq_shutdown;
1130-
irqchip->flags = IRQCHIP_MASK_ON_SUSPEND;
1131-
irqchip->name = kasprintf(GFP_KERNEL, "nmk%u-%u-%u",
1132-
dev->id,
1133-
chip->base,
1134-
chip->base + chip->ngpio - 1);
1135-
11361147
girq = &chip->irq;
1137-
girq->chip = irqchip;
1148+
gpio_irq_chip_set_chip(girq, &nmk_irq_chip);
11381149
girq->parent_handler = nmk_gpio_irq_handler;
11391150
girq->num_parents = 1;
11401151
girq->parents = devm_kcalloc(&dev->dev, 1,

0 commit comments

Comments
 (0)