@@ -47,6 +47,7 @@ static void __iomem *gic_base;
47
47
static struct gic_pcpu_mask pcpu_masks [NR_CPUS ];
48
48
static DEFINE_SPINLOCK (gic_lock );
49
49
static struct irq_domain * gic_irq_domain ;
50
+ static struct irq_domain * gic_dev_domain ;
50
51
static struct irq_domain * gic_ipi_domain ;
51
52
static int gic_shared_intrs ;
52
53
static int gic_vpes ;
@@ -793,25 +794,6 @@ static int gic_irq_domain_map(struct irq_domain *d, unsigned int virq,
793
794
return gic_shared_irq_domain_map (d , virq , hw , 0 );
794
795
}
795
796
796
- static int gic_irq_domain_xlate (struct irq_domain * d , struct device_node * ctrlr ,
797
- const u32 * intspec , unsigned int intsize ,
798
- irq_hw_number_t * out_hwirq ,
799
- unsigned int * out_type )
800
- {
801
- if (intsize != 3 )
802
- return - EINVAL ;
803
-
804
- if (intspec [0 ] == GIC_SHARED )
805
- * out_hwirq = GIC_SHARED_TO_HWIRQ (intspec [1 ]);
806
- else if (intspec [0 ] == GIC_LOCAL )
807
- * out_hwirq = GIC_LOCAL_TO_HWIRQ (intspec [1 ]);
808
- else
809
- return - EINVAL ;
810
- * out_type = intspec [2 ] & IRQ_TYPE_SENSE_MASK ;
811
-
812
- return 0 ;
813
- }
814
-
815
797
static int gic_irq_domain_alloc (struct irq_domain * d , unsigned int virq ,
816
798
unsigned int nr_irqs , void * arg )
817
799
{
@@ -881,11 +863,86 @@ void gic_irq_domain_free(struct irq_domain *d, unsigned int virq,
881
863
bitmap_set (ipi_resrv , base_hwirq , nr_irqs );
882
864
}
883
865
866
+ int gic_irq_domain_match (struct irq_domain * d , struct device_node * node ,
867
+ enum irq_domain_bus_token bus_token )
868
+ {
869
+ /* this domain should'nt be accessed directly */
870
+ return 0 ;
871
+ }
872
+
884
873
static const struct irq_domain_ops gic_irq_domain_ops = {
885
874
.map = gic_irq_domain_map ,
886
- .xlate = gic_irq_domain_xlate ,
887
875
.alloc = gic_irq_domain_alloc ,
888
876
.free = gic_irq_domain_free ,
877
+ .match = gic_irq_domain_match ,
878
+ };
879
+
880
+ static int gic_dev_domain_xlate (struct irq_domain * d , struct device_node * ctrlr ,
881
+ const u32 * intspec , unsigned int intsize ,
882
+ irq_hw_number_t * out_hwirq ,
883
+ unsigned int * out_type )
884
+ {
885
+ if (intsize != 3 )
886
+ return - EINVAL ;
887
+
888
+ if (intspec [0 ] == GIC_SHARED )
889
+ * out_hwirq = GIC_SHARED_TO_HWIRQ (intspec [1 ]);
890
+ else if (intspec [0 ] == GIC_LOCAL )
891
+ * out_hwirq = GIC_LOCAL_TO_HWIRQ (intspec [1 ]);
892
+ else
893
+ return - EINVAL ;
894
+ * out_type = intspec [2 ] & IRQ_TYPE_SENSE_MASK ;
895
+
896
+ return 0 ;
897
+ }
898
+
899
+ static int gic_dev_domain_alloc (struct irq_domain * d , unsigned int virq ,
900
+ unsigned int nr_irqs , void * arg )
901
+ {
902
+ struct irq_fwspec * fwspec = arg ;
903
+ struct gic_irq_spec spec = {
904
+ .type = GIC_DEVICE ,
905
+ .hwirq = fwspec -> param [1 ],
906
+ };
907
+ int i , ret ;
908
+ bool is_shared = fwspec -> param [0 ] == GIC_SHARED ;
909
+
910
+ if (is_shared ) {
911
+ ret = irq_domain_alloc_irqs_parent (d , virq , nr_irqs , & spec );
912
+ if (ret )
913
+ return ret ;
914
+ }
915
+
916
+ for (i = 0 ; i < nr_irqs ; i ++ ) {
917
+ irq_hw_number_t hwirq ;
918
+
919
+ if (is_shared )
920
+ hwirq = GIC_SHARED_TO_HWIRQ (spec .hwirq + i );
921
+ else
922
+ hwirq = GIC_LOCAL_TO_HWIRQ (spec .hwirq + i );
923
+
924
+ ret = irq_domain_set_hwirq_and_chip (d , virq + i ,
925
+ hwirq ,
926
+ & gic_level_irq_controller ,
927
+ NULL );
928
+ if (ret )
929
+ return ret ;
930
+ }
931
+
932
+ return 0 ;
933
+ }
934
+
935
+ void gic_dev_domain_free (struct irq_domain * d , unsigned int virq ,
936
+ unsigned int nr_irqs )
937
+ {
938
+ /* no real allocation is done for dev irqs, so no need to free anything */
939
+ return ;
940
+ }
941
+
942
+ static struct irq_domain_ops gic_dev_domain_ops = {
943
+ .xlate = gic_dev_domain_xlate ,
944
+ .alloc = gic_dev_domain_alloc ,
945
+ .free = gic_dev_domain_free ,
889
946
};
890
947
891
948
static int gic_ipi_domain_xlate (struct irq_domain * d , struct device_node * ctrlr ,
@@ -1026,6 +1083,12 @@ static void __init __gic_init(unsigned long gic_base_addr,
1026
1083
if (!gic_irq_domain )
1027
1084
panic ("Failed to add GIC IRQ domain" );
1028
1085
1086
+ gic_dev_domain = irq_domain_add_hierarchy (gic_irq_domain , 0 ,
1087
+ GIC_NUM_LOCAL_INTRS + gic_shared_intrs ,
1088
+ node , & gic_dev_domain_ops , NULL );
1089
+ if (!gic_dev_domain )
1090
+ panic ("Failed to add GIC DEV domain" );
1091
+
1029
1092
gic_ipi_domain = irq_domain_add_hierarchy (gic_irq_domain ,
1030
1093
IRQ_DOMAIN_FLAG_IPI_PER_CPU ,
1031
1094
GIC_NUM_LOCAL_INTRS + gic_shared_intrs ,
0 commit comments