Skip to content

Commit 6dea278

Browse files
ziyao233gregkh
authored andcommitted
PCI: cadence: Add flags for disabling ASPM capability for broken Root Ports
[ Upstream commit 5ccc76a ] Add flags for disabling the ASPM L0s/L1 capability for broken Root Ports by clearing the corresponding bits in Link Capabilities Register through the local management bus. This allows ASPM to be disabled on platforms which don't support it. Signed-off-by: Yao Zi <me@ziyao.cc> Signed-off-by: Manivannan Sadhasivam <mani@kernel.org> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Tested-by: Han Gao <gaohan@iscas.ac.cn> Tested-by: Chen Wang <unicorn_wang@outlook.com> # Pioneerbox Reviewed-by: Chen Wang <unicorn_wang@outlook.com> Link: https://patch.msgid.link/20260405154154.46829-2-me@ziyao.cc Stable-dep-of: 988ef70 ("PCI: sg2042: Avoid L0s and L1 on Sophgo 2042 PCIe Root Ports") Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent fd204cf commit 6dea278

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

drivers/pci/controller/cadence/pcie-cadence-host.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,13 @@ static int cdns_pcie_host_init_root_port(struct cdns_pcie_rc *rc)
147147
cdns_pcie_rp_writeb(pcie, PCI_CLASS_PROG, 0);
148148
cdns_pcie_rp_writew(pcie, PCI_CLASS_DEVICE, PCI_CLASS_BRIDGE_PCI);
149149

150+
value = cdns_pcie_rp_readl(pcie, CDNS_PCIE_RP_CAP_OFFSET + PCI_EXP_LNKCAP);
151+
if (rc->quirk_broken_aspm_l0s)
152+
value &= ~PCI_EXP_LNKCAP_ASPM_L0S;
153+
if (rc->quirk_broken_aspm_l1)
154+
value &= ~PCI_EXP_LNKCAP_ASPM_L1;
155+
cdns_pcie_rp_writel(pcie, CDNS_PCIE_RP_CAP_OFFSET + PCI_EXP_LNKCAP, value);
156+
150157
return 0;
151158
}
152159

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ struct cdns_pcie {
115115
* @quirk_detect_quiet_flag: LTSSM Detect Quiet min delay set as quirk
116116
* @ecam_supported: Whether the ECAM is supported
117117
* @no_inbound_map: Whether inbound mapping is supported
118+
* @quirk_broken_aspm_l0s: Disable ASPM L0s support as quirk
119+
* @quirk_broken_aspm_l1: Disable ASPM L1 support as quirk
118120
*/
119121
struct cdns_pcie_rc {
120122
struct cdns_pcie pcie;
@@ -127,6 +129,8 @@ struct cdns_pcie_rc {
127129
unsigned int quirk_detect_quiet_flag:1;
128130
unsigned int ecam_supported:1;
129131
unsigned int no_inbound_map:1;
132+
unsigned int quirk_broken_aspm_l0s:1;
133+
unsigned int quirk_broken_aspm_l1:1;
130134
};
131135

132136
/**
@@ -338,6 +342,21 @@ static inline u16 cdns_pcie_rp_readw(struct cdns_pcie *pcie, u32 reg)
338342
return cdns_pcie_read_sz(addr, 0x2);
339343
}
340344

345+
static inline void cdns_pcie_rp_writel(struct cdns_pcie *pcie,
346+
u32 reg, u32 value)
347+
{
348+
void __iomem *addr = pcie->reg_base + CDNS_PCIE_RP_BASE + reg;
349+
350+
cdns_pcie_write_sz(addr, 0x4, value);
351+
}
352+
353+
static inline u32 cdns_pcie_rp_readl(struct cdns_pcie *pcie, u32 reg)
354+
{
355+
void __iomem *addr = pcie->reg_base + CDNS_PCIE_RP_BASE + reg;
356+
357+
return cdns_pcie_read_sz(addr, 0x4);
358+
}
359+
341360
static inline void cdns_pcie_hpa_rp_writeb(struct cdns_pcie *pcie,
342361
u32 reg, u8 value)
343362
{

0 commit comments

Comments
 (0)