bcm27xx: add linux 5.4 support
[openwrt/staging/jogo.git] / target / linux / bcm27xx / patches-5.4 / 950-0343-Revert-pinctrl-bcm2835-Pass-irqchip-when-adding-gpio.patch
1 From b1d33d1e5a44afd2025c5a44a85dc2fab00ec6a7 Mon Sep 17 00:00:00 2001
2 From: popcornmix <popcornmix@gmail.com>
3 Date: Tue, 5 Nov 2019 11:28:19 +0000
4 Subject: [PATCH] Revert "pinctrl: bcm2835: Pass irqchip when adding
5 gpiochip"
6
7 This reverts commit 73345a18d464b1b945b29f54f630ace6873344e2.
8 ---
9 drivers/pinctrl/bcm/pinctrl-bcm2835.c | 55 +++++++++++++++------------
10 1 file changed, 30 insertions(+), 25 deletions(-)
11
12 --- a/drivers/pinctrl/bcm/pinctrl-bcm2835.c
13 +++ b/drivers/pinctrl/bcm/pinctrl-bcm2835.c
14 @@ -78,6 +78,7 @@
15 struct bcm2835_pinctrl {
16 struct device *dev;
17 void __iomem *base;
18 + int irq[BCM2835_NUM_IRQS];
19
20 /* note: locking assumes each bank will have its own unsigned long */
21 unsigned long enabled_irq_map[BCM2835_NUM_BANKS];
22 @@ -381,14 +382,14 @@ static void bcm2835_gpio_irq_handler(str
23 int group;
24 int i;
25
26 - for (i = 0; i < BCM2835_NUM_IRQS; i++) {
27 - if (chip->irq.parents[i] == irq) {
28 + for (i = 0; i < ARRAY_SIZE(pc->irq); i++) {
29 + if (pc->irq[i] == irq) {
30 group = i;
31 break;
32 }
33 }
34 /* This should not happen, every IRQ has a bank */
35 - if (i == BCM2835_NUM_IRQS)
36 + if (i == ARRAY_SIZE(pc->irq))
37 BUG();
38
39 chained_irq_enter(host_chip, desc);
40 @@ -1086,7 +1087,6 @@ static int bcm2835_pinctrl_probe(struct
41 struct device *dev = &pdev->dev;
42 struct device_node *np = dev->of_node;
43 struct bcm2835_pinctrl *pc;
44 - struct gpio_irq_chip *girq;
45 struct resource iomem;
46 int err, i;
47 const struct of_device_id *match;
48 @@ -1135,33 +1135,38 @@ static int bcm2835_pinctrl_probe(struct
49 raw_spin_lock_init(&pc->irq_lock[i]);
50 }
51
52 - girq = &pc->gpio_chip.irq;
53 - girq->chip = &bcm2835_gpio_irq_chip;
54 - girq->parent_handler = bcm2835_gpio_irq_handler;
55 - girq->num_parents = BCM2835_NUM_IRQS;
56 - girq->parents = devm_kcalloc(dev, BCM2835_NUM_IRQS,
57 - sizeof(*girq->parents),
58 - GFP_KERNEL);
59 - if (!girq->parents)
60 - return -ENOMEM;
61 - /*
62 - * Use the same handler for all groups: this is necessary
63 - * since we use one gpiochip to cover all lines - the
64 - * irq handler then needs to figure out which group and
65 - * bank that was firing the IRQ and look up the per-group
66 - * and bank data.
67 - */
68 - for (i = 0; i < BCM2835_NUM_IRQS; i++)
69 - girq->parents[i] = irq_of_parse_and_map(np, i);
70 - girq->default_type = IRQ_TYPE_NONE;
71 - girq->handler = handle_level_irq;
72 -
73 err = gpiochip_add_data(&pc->gpio_chip, pc);
74 if (err) {
75 dev_err(dev, "could not add GPIO chip\n");
76 return err;
77 }
78
79 + err = gpiochip_irqchip_add(&pc->gpio_chip, &bcm2835_gpio_irq_chip,
80 + 0, handle_level_irq, IRQ_TYPE_NONE);
81 + if (err) {
82 + dev_info(dev, "could not add irqchip\n");
83 + return err;
84 + }
85 +
86 + for (i = 0; i < BCM2835_NUM_IRQS; i++) {
87 + pc->irq[i] = irq_of_parse_and_map(np, i);
88 +
89 + if (pc->irq[i] == 0)
90 + continue;
91 +
92 + /*
93 + * Use the same handler for all groups: this is necessary
94 + * since we use one gpiochip to cover all lines - the
95 + * irq handler then needs to figure out which group and
96 + * bank that was firing the IRQ and look up the per-group
97 + * and bank data.
98 + */
99 + gpiochip_set_chained_irqchip(&pc->gpio_chip,
100 + &bcm2835_gpio_irq_chip,
101 + pc->irq[i],
102 + bcm2835_gpio_irq_handler);
103 + }
104 +
105 match = of_match_node(bcm2835_pinctrl_match, pdev->dev.of_node);
106 if (match) {
107 bcm2835_pinctrl_desc.confops =