Skip to content

Commit 7d1aa08

Browse files
clamor-sBartosz Golaszewski
authored andcommitted
gpio: tegra: Convert to immutable irq chip
Update the driver to use an immutable IRQ chip to fix this warning: "not an immutable chip, please consider fixing it!" Preserve per-chip labels by adding an ->irq_print_chip() callback. Tested-by: Svyatoslav Ryhel <[email protected]> # TF201 T30 Tested-by: Robert Eckelmann <[email protected]> # TF101 T20 Signed-off-by: Svyatoslav Ryhel <[email protected]> Reviewed-by: Dmitry Osipenko <[email protected]> Signed-off-by: Bartosz Golaszewski <[email protected]>
1 parent 9abf231 commit 7d1aa08

File tree

1 file changed

+44
-16
lines changed

1 file changed

+44
-16
lines changed

drivers/gpio/gpio-tegra.c

Lines changed: 44 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <linux/of_device.h>
1919
#include <linux/platform_device.h>
2020
#include <linux/module.h>
21+
#include <linux/seq_file.h>
2122
#include <linux/irqdomain.h>
2223
#include <linux/irqchip/chained_irq.h>
2324
#include <linux/pinctrl/consumer.h>
@@ -94,7 +95,6 @@ struct tegra_gpio_info {
9495
struct tegra_gpio_bank *bank_info;
9596
const struct tegra_gpio_soc_config *soc;
9697
struct gpio_chip gc;
97-
struct irq_chip ic;
9898
u32 bank_count;
9999
unsigned int *irqs;
100100
};
@@ -288,6 +288,7 @@ static void tegra_gpio_irq_mask(struct irq_data *d)
288288
unsigned int gpio = d->hwirq;
289289

290290
tegra_gpio_mask_write(tgi, GPIO_MSK_INT_ENB(tgi, gpio), gpio, 0);
291+
gpiochip_disable_irq(chip, gpio);
291292
}
292293

293294
static void tegra_gpio_irq_unmask(struct irq_data *d)
@@ -296,6 +297,7 @@ static void tegra_gpio_irq_unmask(struct irq_data *d)
296297
struct tegra_gpio_info *tgi = gpiochip_get_data(chip);
297298
unsigned int gpio = d->hwirq;
298299

300+
gpiochip_enable_irq(chip, gpio);
299301
tegra_gpio_mask_write(tgi, GPIO_MSK_INT_ENB(tgi, gpio), gpio, 1);
300302
}
301303

@@ -598,10 +600,47 @@ static void tegra_gpio_irq_release_resources(struct irq_data *d)
598600
tegra_gpio_enable(tgi, d->hwirq);
599601
}
600602

603+
static void tegra_gpio_irq_print_chip(struct irq_data *d, struct seq_file *s)
604+
{
605+
struct gpio_chip *chip = irq_data_get_irq_chip_data(d);
606+
607+
seq_printf(s, dev_name(chip->parent));
608+
}
609+
610+
static const struct irq_chip tegra_gpio_irq_chip = {
611+
.irq_shutdown = tegra_gpio_irq_shutdown,
612+
.irq_ack = tegra_gpio_irq_ack,
613+
.irq_mask = tegra_gpio_irq_mask,
614+
.irq_unmask = tegra_gpio_irq_unmask,
615+
.irq_set_type = tegra_gpio_irq_set_type,
616+
#ifdef CONFIG_PM_SLEEP
617+
.irq_set_wake = tegra_gpio_irq_set_wake,
618+
#endif
619+
.irq_print_chip = tegra_gpio_irq_print_chip,
620+
.irq_request_resources = tegra_gpio_irq_request_resources,
621+
.irq_release_resources = tegra_gpio_irq_release_resources,
622+
.flags = IRQCHIP_IMMUTABLE,
623+
};
624+
625+
static const struct irq_chip tegra210_gpio_irq_chip = {
626+
.irq_shutdown = tegra_gpio_irq_shutdown,
627+
.irq_ack = tegra_gpio_irq_ack,
628+
.irq_mask = tegra_gpio_irq_mask,
629+
.irq_unmask = tegra_gpio_irq_unmask,
630+
.irq_set_affinity = tegra_gpio_irq_set_affinity,
631+
.irq_set_type = tegra_gpio_irq_set_type,
632+
#ifdef CONFIG_PM_SLEEP
633+
.irq_set_wake = tegra_gpio_irq_set_wake,
634+
#endif
635+
.irq_print_chip = tegra_gpio_irq_print_chip,
636+
.irq_request_resources = tegra_gpio_irq_request_resources,
637+
.irq_release_resources = tegra_gpio_irq_release_resources,
638+
.flags = IRQCHIP_IMMUTABLE,
639+
};
640+
601641
#ifdef CONFIG_DEBUG_FS
602642

603643
#include <linux/debugfs.h>
604-
#include <linux/seq_file.h>
605644

606645
static int tegra_dbg_gpio_show(struct seq_file *s, void *unused)
607646
{
@@ -689,18 +728,6 @@ static int tegra_gpio_probe(struct platform_device *pdev)
689728
tgi->gc.ngpio = tgi->bank_count * 32;
690729
tgi->gc.parent = &pdev->dev;
691730

692-
tgi->ic.name = "GPIO";
693-
tgi->ic.irq_ack = tegra_gpio_irq_ack;
694-
tgi->ic.irq_mask = tegra_gpio_irq_mask;
695-
tgi->ic.irq_unmask = tegra_gpio_irq_unmask;
696-
tgi->ic.irq_set_type = tegra_gpio_irq_set_type;
697-
tgi->ic.irq_shutdown = tegra_gpio_irq_shutdown;
698-
#ifdef CONFIG_PM_SLEEP
699-
tgi->ic.irq_set_wake = tegra_gpio_irq_set_wake;
700-
#endif
701-
tgi->ic.irq_request_resources = tegra_gpio_irq_request_resources;
702-
tgi->ic.irq_release_resources = tegra_gpio_irq_release_resources;
703-
704731
platform_set_drvdata(pdev, tgi);
705732

706733
if (tgi->soc->debounce_supported)
@@ -733,7 +760,6 @@ static int tegra_gpio_probe(struct platform_device *pdev)
733760
}
734761

735762
irq = &tgi->gc.irq;
736-
irq->chip = &tgi->ic;
737763
irq->fwnode = of_node_to_fwnode(pdev->dev.of_node);
738764
irq->child_to_parent_hwirq = tegra_gpio_child_to_parent_hwirq;
739765
irq->populate_parent_alloc_arg = tegra_gpio_populate_parent_fwspec;
@@ -752,7 +778,9 @@ static int tegra_gpio_probe(struct platform_device *pdev)
752778
if (!irq->parent_domain)
753779
return -EPROBE_DEFER;
754780

755-
tgi->ic.irq_set_affinity = tegra_gpio_irq_set_affinity;
781+
gpio_irq_chip_set_chip(irq, &tegra210_gpio_irq_chip);
782+
} else {
783+
gpio_irq_chip_set_chip(irq, &tegra_gpio_irq_chip);
756784
}
757785

758786
tgi->regs = devm_platform_ioremap_resource(pdev, 0);

0 commit comments

Comments
 (0)