Skip to content

Commit 5037ec7

Browse files
mindachen1987bjorn-helgaas
authored andcommitted
PCI: microchip: Add event irqchip field to host port and add PLDA irqchip
As the PLDA DT binding doc (Documentation/devicetree/bindings/pci/ plda,xpressrich3-axi-common.yaml) shows, PLDA PCIe contains an interrupt controller. Microchip PolarFire PCIe event IRQs include PLDA interrupts and PolarFire additional interrupts. The interrupt irqchip ops includes ack/mask/unmask interrupt ops, which will write correct registers. Microchip PolarFire PCIe additional interrupts require to write PolarFire SoC self-defined registers. So Microchip PCIe event irqchip ops can not be re-used. 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 ... To support PLDA its own event IRQ process, implements PLDA irqchip ops and add event irqchip field to struct pcie_plda_rp. [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 c7f6c72 commit 5037ec7

File tree

2 files changed

+84
-16
lines changed

2 files changed

+84
-16
lines changed

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

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -770,14 +770,74 @@ static struct irq_chip mc_event_irq_chip = {
770770
.irq_unmask = mc_unmask_event_irq,
771771
};
772772

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+
773831
static const struct plda_event_ops plda_event_ops = {
774832
.get_events = plda_get_events,
775833
};
776834

777835
static int plda_pcie_event_map(struct irq_domain *domain, unsigned int irq,
778836
irq_hw_number_t hwirq)
779837
{
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);
781841
irq_set_chip_data(irq, domain->host_data);
782842

783843
return 0;
@@ -962,6 +1022,9 @@ static int plda_init_interrupts(struct platform_device *pdev,
9621022
if (!port->event_ops)
9631023
port->event_ops = &plda_event_ops;
9641024

1025+
if (!port->event_irq_chip)
1026+
port->event_irq_chip = &plda_event_irq_chip;
1027+
9651028
ret = plda_pcie_init_irq_domains(port);
9661029
if (ret) {
9671030
dev_err(dev, "failed creating IRQ domains\n");
@@ -1038,6 +1101,7 @@ static int mc_platform_init(struct pci_config_window *cfg)
10381101
return ret;
10391102

10401103
port->plda.event_ops = &mc_event_ops;
1104+
port->plda.event_irq_chip = &mc_event_irq_chip;
10411105

10421106
/* Address translation is up; safe to enable interrupts */
10431107
ret = plda_init_interrupts(pdev, &port->plda, &mc_event);

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

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ enum plda_int_event {
107107

108108
#define PLDA_NUM_DMA_EVENTS 16
109109

110+
#define EVENT_PM_MSI_INT_INTX (PLDA_NUM_DMA_EVENTS + PLDA_INTX)
111+
#define EVENT_PM_MSI_INT_MSI (PLDA_NUM_DMA_EVENTS + PLDA_MSI)
110112
#define PLDA_MAX_EVENT_NUM (PLDA_NUM_DMA_EVENTS + PLDA_INT_EVENT_NUM)
111113

112114
/*
@@ -116,21 +118,22 @@ enum plda_int_event {
116118
* +--+--+--+-+------+-+-+-+-+-+-+-+-+-----------+-----------+
117119
* |12|11|10|9| intx |7|6|5|4|3|2|1|0| DMA error | DMA end |
118120
* +--+--+--+-+------+-+-+-+-+-+-+-+-+-----------+-----------+
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)
121+
* event bit
122+
* 0-7 (0-7) DMA interrupt end : reserved for vendor implement
123+
* 8-15 (8-15) DMA error : reserved for vendor implement
124+
* 16 (16) AXI post error (PLDA_AXI_POST_ERR)
125+
* 17 (17) AXI fetch error (PLDA_AXI_FETCH_ERR)
126+
* 18 (18) AXI discard error (PLDA_AXI_DISCARD_ERR)
127+
* 19 (19) AXI doorbell (PLDA_PCIE_DOORBELL)
128+
* 20 (20) PCIe post error (PLDA_PCIE_POST_ERR)
129+
* 21 (21) PCIe fetch error (PLDA_PCIE_FETCH_ERR)
130+
* 22 (22) PCIe discard error (PLDA_PCIE_DISCARD_ERR)
131+
* 23 (23) PCIe doorbell (PLDA_PCIE_DOORBELL)
132+
* 24 (27-24) INTx interruts (PLDA_INTX)
133+
* 25 (28): MSI interrupt (PLDA_MSI)
134+
* 26 (29): AER event (PLDA_AER_EVENT)
135+
* 27 (30): PM/LTR/Hotplug (PLDA_MISC_EVENTS)
136+
* 28 (31): System error (PLDA_SYS_ERR)
134137
*/
135138

136139
struct plda_pcie_rp;
@@ -155,6 +158,7 @@ struct plda_pcie_rp {
155158
raw_spinlock_t lock;
156159
struct plda_msi msi;
157160
const struct plda_event_ops *event_ops;
161+
const struct irq_chip *event_irq_chip;
158162
void __iomem *bridge_addr;
159163
int num_events;
160164
};

0 commit comments

Comments
 (0)