--- zzzz-none-000/linux-5.4.213/drivers/pci/controller/dwc/pcie-designware.c 2022-09-15 10:04:56.000000000 +0000 +++ alder-5690pro-762/linux-5.4.213/drivers/pci/controller/dwc/pcie-designware.c 2024-08-14 09:02:08.000000000 +0000 @@ -13,6 +13,7 @@ #include #include "pcie-designware.h" +#include "pcie-designware-debugfs.h" /* * These interfaces resemble the pci_find_*capability() interfaces, but these @@ -88,6 +89,22 @@ return 0; } +u16 dw_pcie_find_vsec_capability(struct dw_pcie *pci, u8 vsec_cap) +{ + u16 vsec = 0; + u32 header; + + while ((vsec = dw_pcie_find_next_ext_capability(pci, vsec, + PCI_EXT_CAP_ID_VNDR))) { + header = dw_pcie_readl_dbi(pci, vsec + PCI_VNDR_HEADER); + if (PCI_VNDR_HEADER_ID(header) == vsec_cap) + return vsec; + } + + return 0; +} +EXPORT_SYMBOL_GPL(dw_pcie_find_vsec_capability); + u16 dw_pcie_find_ext_capability(struct dw_pcie *pci, u8 cap) { return dw_pcie_find_next_ext_capability(pci, 0, cap); @@ -445,10 +462,16 @@ int dw_pcie_wait_for_link(struct dw_pcie *pci) { - int retries; + int retries, max_link_retries; + u32 val; + + if(pci->link_retries_count != 0) + max_link_retries = pci->link_retries_count; + else + max_link_retries = LINK_WAIT_MAX_RETRIES; /* Check if the link is up or not */ - for (retries = 0; retries < LINK_WAIT_MAX_RETRIES; retries++) { + for (retries = 0; retries < max_link_retries; retries++) { if (dw_pcie_link_up(pci)) { dev_info(pci->dev, "Link up\n"); return 0; @@ -456,7 +479,11 @@ usleep_range(LINK_WAIT_USLEEP_MIN, LINK_WAIT_USLEEP_MAX); } - dev_info(pci->dev, "Phy link never came up\n"); + if (pci->ops->ltssm_read) { + pci->ops->ltssm_read(pci, &val); + dev_info(pci->dev, "Phy link never came up. PARF_LTSSM: 0x%x\n",val); + } else + dev_info(pci->dev, "Phy link nave came up\n"); return -ETIMEDOUT; } @@ -473,6 +500,7 @@ return ((val & PCIE_PORT_DEBUG1_LINK_UP) && (!(val & PCIE_PORT_DEBUG1_LINK_IN_TRAINING))); } +EXPORT_SYMBOL_GPL(dw_pcie_link_up); static u8 dw_pcie_iatu_unroll_enabled(struct dw_pcie *pci) { @@ -556,4 +584,8 @@ PCIE_PL_CHK_REG_CHK_REG_START; dw_pcie_writel_dbi(pci, PCIE_PL_CHK_REG_CONTROL_STATUS, val); } + + ret = create_debugfs_files(pci); + if (ret) + dev_err(pci->dev, "Couldn't create debugfs files\n"); }