@@ -770,14 +770,74 @@ static struct irq_chip mc_event_irq_chip = {
770
770
.irq_unmask = mc_unmask_event_irq ,
771
771
};
772
772
773
+ static u32 plda_hwirq_to_mask (int hwirq )
774
+ {
775
+ u32 mask ;
776
+
777
+ /* hwirq 23 - 0 are the same with register */
778
+ if (hwirq < EVENT_PM_MSI_INT_INTX )
779
+ mask = BIT (hwirq );
780
+ else if (hwirq == EVENT_PM_MSI_INT_INTX )
781
+ mask = PM_MSI_INT_INTX_MASK ;
782
+ else
783
+ mask = BIT (hwirq + PCI_NUM_INTX - 1 );
784
+
785
+ return mask ;
786
+ }
787
+
788
+ static void plda_ack_event_irq (struct irq_data * data )
789
+ {
790
+ struct plda_pcie_rp * port = irq_data_get_irq_chip_data (data );
791
+
792
+ writel_relaxed (plda_hwirq_to_mask (data -> hwirq ),
793
+ port -> bridge_addr + ISTATUS_LOCAL );
794
+ }
795
+
796
+ static void plda_mask_event_irq (struct irq_data * data )
797
+ {
798
+ struct plda_pcie_rp * port = irq_data_get_irq_chip_data (data );
799
+ u32 mask , val ;
800
+
801
+ mask = plda_hwirq_to_mask (data -> hwirq );
802
+
803
+ raw_spin_lock (& port -> lock );
804
+ val = readl_relaxed (port -> bridge_addr + IMASK_LOCAL );
805
+ val &= ~mask ;
806
+ writel_relaxed (val , port -> bridge_addr + IMASK_LOCAL );
807
+ raw_spin_unlock (& port -> lock );
808
+ }
809
+
810
+ static void plda_unmask_event_irq (struct irq_data * data )
811
+ {
812
+ struct plda_pcie_rp * port = irq_data_get_irq_chip_data (data );
813
+ u32 mask , val ;
814
+
815
+ mask = plda_hwirq_to_mask (data -> hwirq );
816
+
817
+ raw_spin_lock (& port -> lock );
818
+ val = readl_relaxed (port -> bridge_addr + IMASK_LOCAL );
819
+ val |= mask ;
820
+ writel_relaxed (val , port -> bridge_addr + IMASK_LOCAL );
821
+ raw_spin_unlock (& port -> lock );
822
+ }
823
+
824
+ static struct irq_chip plda_event_irq_chip = {
825
+ .name = "PLDA PCIe EVENT" ,
826
+ .irq_ack = plda_ack_event_irq ,
827
+ .irq_mask = plda_mask_event_irq ,
828
+ .irq_unmask = plda_unmask_event_irq ,
829
+ };
830
+
773
831
static const struct plda_event_ops plda_event_ops = {
774
832
.get_events = plda_get_events ,
775
833
};
776
834
777
835
static int plda_pcie_event_map (struct irq_domain * domain , unsigned int irq ,
778
836
irq_hw_number_t hwirq )
779
837
{
780
- irq_set_chip_and_handler (irq , & mc_event_irq_chip , handle_level_irq );
838
+ struct plda_pcie_rp * port = (void * )domain -> host_data ;
839
+
840
+ irq_set_chip_and_handler (irq , port -> event_irq_chip , handle_level_irq );
781
841
irq_set_chip_data (irq , domain -> host_data );
782
842
783
843
return 0 ;
@@ -962,6 +1022,9 @@ static int plda_init_interrupts(struct platform_device *pdev,
962
1022
if (!port -> event_ops )
963
1023
port -> event_ops = & plda_event_ops ;
964
1024
1025
+ if (!port -> event_irq_chip )
1026
+ port -> event_irq_chip = & plda_event_irq_chip ;
1027
+
965
1028
ret = plda_pcie_init_irq_domains (port );
966
1029
if (ret ) {
967
1030
dev_err (dev , "failed creating IRQ domains\n" );
@@ -1038,6 +1101,7 @@ static int mc_platform_init(struct pci_config_window *cfg)
1038
1101
return ret ;
1039
1102
1040
1103
port -> plda .event_ops = & mc_event_ops ;
1104
+ port -> plda .event_irq_chip = & mc_event_irq_chip ;
1041
1105
1042
1106
/* Address translation is up; safe to enable interrupts */
1043
1107
ret = plda_init_interrupts (pdev , & port -> plda , & mc_event );
0 commit comments