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
293294static 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,43 @@ 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+ .irq_set_wake = pm_sleep_ptr (tegra_gpio_irq_set_wake ),
617+ .irq_print_chip = tegra_gpio_irq_print_chip ,
618+ .irq_request_resources = tegra_gpio_irq_request_resources ,
619+ .irq_release_resources = tegra_gpio_irq_release_resources ,
620+ .flags = IRQCHIP_IMMUTABLE ,
621+ };
622+
623+ static const struct irq_chip tegra210_gpio_irq_chip = {
624+ .irq_shutdown = tegra_gpio_irq_shutdown ,
625+ .irq_ack = tegra_gpio_irq_ack ,
626+ .irq_mask = tegra_gpio_irq_mask ,
627+ .irq_unmask = tegra_gpio_irq_unmask ,
628+ .irq_set_affinity = tegra_gpio_irq_set_affinity ,
629+ .irq_set_type = tegra_gpio_irq_set_type ,
630+ .irq_set_wake = pm_sleep_ptr (tegra_gpio_irq_set_wake ),
631+ .irq_print_chip = tegra_gpio_irq_print_chip ,
632+ .irq_request_resources = tegra_gpio_irq_request_resources ,
633+ .irq_release_resources = tegra_gpio_irq_release_resources ,
634+ .flags = IRQCHIP_IMMUTABLE ,
635+ };
636+
601637#ifdef CONFIG_DEBUG_FS
602638
603639#include <linux/debugfs.h>
604- #include <linux/seq_file.h>
605640
606641static int tegra_dbg_gpio_show (struct seq_file * s , void * unused )
607642{
@@ -689,18 +724,6 @@ static int tegra_gpio_probe(struct platform_device *pdev)
689724 tgi -> gc .ngpio = tgi -> bank_count * 32 ;
690725 tgi -> gc .parent = & pdev -> dev ;
691726
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-
704727 platform_set_drvdata (pdev , tgi );
705728
706729 if (tgi -> soc -> debounce_supported )
@@ -733,7 +756,6 @@ static int tegra_gpio_probe(struct platform_device *pdev)
733756 }
734757
735758 irq = & tgi -> gc .irq ;
736- irq -> chip = & tgi -> ic ;
737759 irq -> fwnode = of_node_to_fwnode (pdev -> dev .of_node );
738760 irq -> child_to_parent_hwirq = tegra_gpio_child_to_parent_hwirq ;
739761 irq -> populate_parent_alloc_arg = tegra_gpio_populate_parent_fwspec ;
@@ -752,7 +774,9 @@ static int tegra_gpio_probe(struct platform_device *pdev)
752774 if (!irq -> parent_domain )
753775 return - EPROBE_DEFER ;
754776
755- tgi -> ic .irq_set_affinity = tegra_gpio_irq_set_affinity ;
777+ gpio_irq_chip_set_chip (irq , & tegra210_gpio_irq_chip );
778+ } else {
779+ gpio_irq_chip_set_chip (irq , & tegra_gpio_irq_chip );
756780 }
757781
758782 tgi -> regs = devm_platform_ioremap_resource (pdev , 0 );
0 commit comments