Skip to content

Commit 2b6ee04

Browse files
paliLorenzo Pieralisi
authored andcommitted
PCI: mvebu: Add support for Advanced Error Reporting registers on emulated bridge
AER registers start at mvebu offset 0x0100. Registers PCI_ERR_ROOT_COMMAND, PCI_ERR_ROOT_STATUS and PCI_ERR_ROOT_ERR_SRC are not supported on pre-XP hardware and returns zeros. Note that AER interrupt is not supported yet as mvebu emulated bridge does not implement interrupts support at all yet. Also remove custom macro PCIE_HEADER_LOG_4_OFF as it is unused and correctly this register should be referenced via standard macros with offset, e.g. as: PCIE_CAP_PCIERR_OFF + PCI_ERR_HEADER_LOG + 4. Link: https://lore.kernel.org/r/20220222155030.988-8-pali@kernel.org Signed-off-by: Pali Rohár <pali@kernel.org> Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
1 parent e3e13c9 commit 2b6ee04

1 file changed

Lines changed: 66 additions & 1 deletion

File tree

drivers/pci/controller/pci-mvebu.c

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#define PCIE_BAR_HI_OFF(n) (0x0014 + ((n) << 3))
3535
#define PCIE_SSDEV_ID_OFF 0x002c
3636
#define PCIE_CAP_PCIEXP 0x0060
37-
#define PCIE_HEADER_LOG_4_OFF 0x0128
37+
#define PCIE_CAP_PCIERR_OFF 0x0100
3838
#define PCIE_BAR_CTRL_OFF(n) (0x1804 + (((n) - 1) * 4))
3939
#define PCIE_WIN04_CTRL_OFF(n) (0x1820 + ((n) << 4))
4040
#define PCIE_WIN04_BASE_OFF(n) (0x1824 + ((n) << 4))
@@ -603,6 +603,37 @@ mvebu_pci_bridge_emul_pcie_conf_read(struct pci_bridge_emul *bridge,
603603
return PCI_BRIDGE_EMUL_HANDLED;
604604
}
605605

606+
static pci_bridge_emul_read_status_t
607+
mvebu_pci_bridge_emul_ext_conf_read(struct pci_bridge_emul *bridge,
608+
int reg, u32 *value)
609+
{
610+
struct mvebu_pcie_port *port = bridge->data;
611+
612+
switch (reg) {
613+
case 0:
614+
case PCI_ERR_UNCOR_STATUS:
615+
case PCI_ERR_UNCOR_MASK:
616+
case PCI_ERR_UNCOR_SEVER:
617+
case PCI_ERR_COR_STATUS:
618+
case PCI_ERR_COR_MASK:
619+
case PCI_ERR_CAP:
620+
case PCI_ERR_HEADER_LOG+0:
621+
case PCI_ERR_HEADER_LOG+4:
622+
case PCI_ERR_HEADER_LOG+8:
623+
case PCI_ERR_HEADER_LOG+12:
624+
case PCI_ERR_ROOT_COMMAND:
625+
case PCI_ERR_ROOT_STATUS:
626+
case PCI_ERR_ROOT_ERR_SRC:
627+
*value = mvebu_readl(port, PCIE_CAP_PCIERR_OFF + reg);
628+
break;
629+
630+
default:
631+
return PCI_BRIDGE_EMUL_NOT_HANDLED;
632+
}
633+
634+
return PCI_BRIDGE_EMUL_HANDLED;
635+
}
636+
606637
static void
607638
mvebu_pci_bridge_emul_base_conf_write(struct pci_bridge_emul *bridge,
608639
int reg, u32 old, u32 new, u32 mask)
@@ -715,11 +746,45 @@ mvebu_pci_bridge_emul_pcie_conf_write(struct pci_bridge_emul *bridge,
715746
}
716747
}
717748

749+
static void
750+
mvebu_pci_bridge_emul_ext_conf_write(struct pci_bridge_emul *bridge,
751+
int reg, u32 old, u32 new, u32 mask)
752+
{
753+
struct mvebu_pcie_port *port = bridge->data;
754+
755+
switch (reg) {
756+
/* These are W1C registers, so clear other bits */
757+
case PCI_ERR_UNCOR_STATUS:
758+
case PCI_ERR_COR_STATUS:
759+
case PCI_ERR_ROOT_STATUS:
760+
new &= mask;
761+
fallthrough;
762+
763+
case PCI_ERR_UNCOR_MASK:
764+
case PCI_ERR_UNCOR_SEVER:
765+
case PCI_ERR_COR_MASK:
766+
case PCI_ERR_CAP:
767+
case PCI_ERR_HEADER_LOG+0:
768+
case PCI_ERR_HEADER_LOG+4:
769+
case PCI_ERR_HEADER_LOG+8:
770+
case PCI_ERR_HEADER_LOG+12:
771+
case PCI_ERR_ROOT_COMMAND:
772+
case PCI_ERR_ROOT_ERR_SRC:
773+
mvebu_writel(port, new, PCIE_CAP_PCIERR_OFF + reg);
774+
break;
775+
776+
default:
777+
break;
778+
}
779+
}
780+
718781
static const struct pci_bridge_emul_ops mvebu_pci_bridge_emul_ops = {
719782
.read_base = mvebu_pci_bridge_emul_base_conf_read,
720783
.write_base = mvebu_pci_bridge_emul_base_conf_write,
721784
.read_pcie = mvebu_pci_bridge_emul_pcie_conf_read,
722785
.write_pcie = mvebu_pci_bridge_emul_pcie_conf_write,
786+
.read_ext = mvebu_pci_bridge_emul_ext_conf_read,
787+
.write_ext = mvebu_pci_bridge_emul_ext_conf_write,
723788
};
724789

725790
/*

0 commit comments

Comments
 (0)