18
18
#include <linux/of_device.h>
19
19
#include <linux/platform_device.h>
20
20
#include <linux/module.h>
21
+ #include <linux/seq_file.h>
21
22
#include <linux/irqdomain.h>
22
23
#include <linux/irqchip/chained_irq.h>
23
24
#include <linux/pinctrl/consumer.h>
@@ -94,7 +95,6 @@ struct tegra_gpio_info {
94
95
struct tegra_gpio_bank * bank_info ;
95
96
const struct tegra_gpio_soc_config * soc ;
96
97
struct gpio_chip gc ;
97
- struct irq_chip ic ;
98
98
u32 bank_count ;
99
99
unsigned int * irqs ;
100
100
};
@@ -288,6 +288,7 @@ static void tegra_gpio_irq_mask(struct irq_data *d)
288
288
unsigned int gpio = d -> hwirq ;
289
289
290
290
tegra_gpio_mask_write (tgi , GPIO_MSK_INT_ENB (tgi , gpio ), gpio , 0 );
291
+ gpiochip_disable_irq (chip , gpio );
291
292
}
292
293
293
294
static void tegra_gpio_irq_unmask (struct irq_data * d )
@@ -296,6 +297,7 @@ static void tegra_gpio_irq_unmask(struct irq_data *d)
296
297
struct tegra_gpio_info * tgi = gpiochip_get_data (chip );
297
298
unsigned int gpio = d -> hwirq ;
298
299
300
+ gpiochip_enable_irq (chip , gpio );
299
301
tegra_gpio_mask_write (tgi , GPIO_MSK_INT_ENB (tgi , gpio ), gpio , 1 );
300
302
}
301
303
@@ -598,10 +600,43 @@ static void tegra_gpio_irq_release_resources(struct irq_data *d)
598
600
tegra_gpio_enable (tgi , d -> hwirq );
599
601
}
600
602
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
+
601
637
#ifdef CONFIG_DEBUG_FS
602
638
603
639
#include <linux/debugfs.h>
604
- #include <linux/seq_file.h>
605
640
606
641
static int tegra_dbg_gpio_show (struct seq_file * s , void * unused )
607
642
{
@@ -689,18 +724,6 @@ static int tegra_gpio_probe(struct platform_device *pdev)
689
724
tgi -> gc .ngpio = tgi -> bank_count * 32 ;
690
725
tgi -> gc .parent = & pdev -> dev ;
691
726
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
-
704
727
platform_set_drvdata (pdev , tgi );
705
728
706
729
if (tgi -> soc -> debounce_supported )
@@ -733,7 +756,6 @@ static int tegra_gpio_probe(struct platform_device *pdev)
733
756
}
734
757
735
758
irq = & tgi -> gc .irq ;
736
- irq -> chip = & tgi -> ic ;
737
759
irq -> fwnode = of_node_to_fwnode (pdev -> dev .of_node );
738
760
irq -> child_to_parent_hwirq = tegra_gpio_child_to_parent_hwirq ;
739
761
irq -> populate_parent_alloc_arg = tegra_gpio_populate_parent_fwspec ;
@@ -752,7 +774,9 @@ static int tegra_gpio_probe(struct platform_device *pdev)
752
774
if (!irq -> parent_domain )
753
775
return - EPROBE_DEFER ;
754
776
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 );
756
780
}
757
781
758
782
tgi -> regs = devm_platform_ioremap_resource (pdev , 0 );
0 commit comments