Skip to content

Commit c7f6c72

Browse files
mindachen1987bjorn-helgaas
authored andcommitted
PCI: microchip: Add get_events() callback and PLDA get_event()
As PLDA DT binding doc (Documentation/devicetree/bindings/pci/ plda,xpressrich3-axi-common.yaml) showed, PLDA PCIe contains an interrupt controller. PolarFire implements its own PCIe interrupts, additional to the regular PCIe interrupts, due to lack of an MSI controller, so the interrupt to event number mapping is different to the PLDA regular interrupts, necessitating a custom get_events() implementation. Microchip PolarFire PCIe additional interrupts (defined in drivers/pci/controller/plda/pcie-microchip-host.c): EVENT_PCIE_L2_EXIT EVENT_PCIE_HOTRST_EXIT EVENT_PCIE_DLUP_EXIT EVENT_SEC_TX_RAM_SEC_ERR EVENT_SEC_RX_RAM_SEC_ERR ... plda_get_events() adds interrupt register to PLDA event num mapping codes. All the PLDA interrupts can be seen in new added graph. [kwilczynski: commit log] Link: https://lore.kernel.org/linux-pci/[email protected] Signed-off-by: Minda Chen <[email protected]> Signed-off-by: Krzysztof Wilczyński <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]> Acked-by: Conor Dooley <[email protected]>
1 parent 62df57b commit c7f6c72

File tree

2 files changed

+66
-1
lines changed

2 files changed

+66
-1
lines changed

drivers/pci/controller/plda/pcie-microchip-host.c

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,26 @@ static u32 mc_get_events(struct plda_pcie_rp *port)
626626
return events;
627627
}
628628

629+
static u32 plda_get_events(struct plda_pcie_rp *port)
630+
{
631+
u32 events, val, origin;
632+
633+
origin = readl_relaxed(port->bridge_addr + ISTATUS_LOCAL);
634+
635+
/* MSI event and sys events */
636+
val = (origin & SYS_AND_MSI_MASK) >> PM_MSI_INT_MSI_SHIFT;
637+
events = val << (PM_MSI_INT_MSI_SHIFT - PCI_NUM_INTX + 1);
638+
639+
/* INTx events */
640+
if (origin & PM_MSI_INT_INTX_MASK)
641+
events |= BIT(PM_MSI_INT_INTX_SHIFT);
642+
643+
/* remains are same with register */
644+
events |= origin & GENMASK(P_ATR_EVT_DOORBELL_SHIFT, 0);
645+
646+
return events;
647+
}
648+
629649
static irqreturn_t mc_event_handler(int irq, void *dev_id)
630650
{
631651
struct plda_pcie_rp *port = dev_id;
@@ -656,7 +676,7 @@ static void plda_handle_event(struct irq_desc *desc)
656676

657677
chained_irq_enter(chip, desc);
658678

659-
events = mc_get_events(port);
679+
events = port->event_ops->get_events(port);
660680

661681
for_each_set_bit(bit, &events, port->num_events)
662682
generic_handle_domain_irq(port->event_domain, bit);
@@ -750,6 +770,10 @@ static struct irq_chip mc_event_irq_chip = {
750770
.irq_unmask = mc_unmask_event_irq,
751771
};
752772

773+
static const struct plda_event_ops plda_event_ops = {
774+
.get_events = plda_get_events,
775+
};
776+
753777
static int plda_pcie_event_map(struct irq_domain *domain, unsigned int irq,
754778
irq_hw_number_t hwirq)
755779
{
@@ -815,6 +839,10 @@ static int mc_request_event_irq(struct plda_pcie_rp *plda, int event_irq,
815839
0, event_cause[event].sym, plda);
816840
}
817841

842+
static const struct plda_event_ops mc_event_ops = {
843+
.get_events = mc_get_events,
844+
};
845+
818846
static const struct plda_event mc_event = {
819847
.request_event_irq = mc_request_event_irq,
820848
.intx_event = EVENT_LOCAL_PM_MSI_INT_INTX,
@@ -931,6 +959,9 @@ static int plda_init_interrupts(struct platform_device *pdev,
931959
int i, intx_irq, msi_irq, event_irq;
932960
int ret;
933961

962+
if (!port->event_ops)
963+
port->event_ops = &plda_event_ops;
964+
934965
ret = plda_pcie_init_irq_domains(port);
935966
if (ret) {
936967
dev_err(dev, "failed creating IRQ domains\n");
@@ -1006,6 +1037,8 @@ static int mc_platform_init(struct pci_config_window *cfg)
10061037
if (ret)
10071038
return ret;
10081039

1040+
port->plda.event_ops = &mc_event_ops;
1041+
10091042
/* Address translation is up; safe to enable interrupts */
10101043
ret = plda_init_interrupts(pdev, &port->plda, &mc_event);
10111044
if (ret)

drivers/pci/controller/plda/pcie-plda.h

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
#define PM_MSI_INT_EVENTS_SHIFT 30
5959
#define PM_MSI_INT_SYS_ERR_MASK 0x80000000u
6060
#define PM_MSI_INT_SYS_ERR_SHIFT 31
61+
#define SYS_AND_MSI_MASK GENMASK(31, 28)
6162
#define NUM_LOCAL_EVENTS 15
6263
#define ISTATUS_LOCAL 0x184
6364
#define IMASK_HOST 0x188
@@ -108,6 +109,36 @@ enum plda_int_event {
108109

109110
#define PLDA_MAX_EVENT_NUM (PLDA_NUM_DMA_EVENTS + PLDA_INT_EVENT_NUM)
110111

112+
/*
113+
* PLDA interrupt register
114+
*
115+
* 31 27 23 15 7 0
116+
* +--+--+--+-+------+-+-+-+-+-+-+-+-+-----------+-----------+
117+
* |12|11|10|9| intx |7|6|5|4|3|2|1|0| DMA error | DMA end |
118+
* +--+--+--+-+------+-+-+-+-+-+-+-+-+-----------+-----------+
119+
* bit 0-7 DMA interrupt end : reserved for vendor implement
120+
* bit 8-15 DMA error : reserved for vendor implement
121+
* 0: AXI post error (PLDA_AXI_POST_ERR)
122+
* 1: AXI fetch error (PLDA_AXI_FETCH_ERR)
123+
* 2: AXI discard error (PLDA_AXI_DISCARD_ERR)
124+
* 3: AXI doorbell (PLDA_PCIE_DOORBELL)
125+
* 4: PCIe post error (PLDA_PCIE_POST_ERR)
126+
* 5: PCIe fetch error (PLDA_PCIE_FETCH_ERR)
127+
* 6: PCIe discard error (PLDA_PCIE_DISCARD_ERR)
128+
* 7: PCIe doorbell (PLDA_PCIE_DOORBELL)
129+
* 8: 4 INTx interruts (PLDA_INTX)
130+
* 9: MSI interrupt (PLDA_MSI)
131+
* 10: AER event (PLDA_AER_EVENT)
132+
* 11: PM/LTR/Hotplug (PLDA_MISC_EVENTS)
133+
* 12: System error (PLDA_SYS_ERR)
134+
*/
135+
136+
struct plda_pcie_rp;
137+
138+
struct plda_event_ops {
139+
u32 (*get_events)(struct plda_pcie_rp *pcie);
140+
};
141+
111142
struct plda_msi {
112143
struct mutex lock; /* Protect used bitmap */
113144
struct irq_domain *msi_domain;
@@ -123,6 +154,7 @@ struct plda_pcie_rp {
123154
struct irq_domain *event_domain;
124155
raw_spinlock_t lock;
125156
struct plda_msi msi;
157+
const struct plda_event_ops *event_ops;
126158
void __iomem *bridge_addr;
127159
int num_events;
128160
};

0 commit comments

Comments
 (0)