Skip to content

Commit f9eb654

Browse files
PCI: dwc: Update pci->num_lanes to maximum supported link width
If the num-lanes property is not present in the devicetree, update pci->num_lanes with the hardware supported maximum link width using the newly introduced dw_pcie_link_get_max_link_width() API. The API is used to get the Maximum Link Width (MLW) of the controller. Signed-off-by: Krishna Chaitanya Chundru <[email protected]> [mani: reworded commit message a bit] Signed-off-by: Manivannan Sadhasivam <[email protected]> Reviewed-by: Manivannan Sadhasivam <[email protected]> Link: https://patch.msgid.link/[email protected]
1 parent 57a4591 commit f9eb654

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

drivers/pci/controller/dwc/pcie-designware-host.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,9 @@ int dw_pcie_host_init(struct dw_pcie_rp *pp)
523523

524524
dw_pcie_iatu_detect(pci);
525525

526+
if (pci->num_lanes < 1)
527+
pci->num_lanes = dw_pcie_link_get_max_link_width(pci);
528+
526529
/*
527530
* Allocate the resource for MSG TLP before programming the iATU
528531
* outbound window in dw_pcie_setup_rc(). Since the allocation depends

drivers/pci/controller/dwc/pcie-designware.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,14 @@ static void dw_pcie_link_set_max_speed(struct dw_pcie *pci)
781781

782782
}
783783

784+
int dw_pcie_link_get_max_link_width(struct dw_pcie *pci)
785+
{
786+
u8 cap = dw_pcie_find_capability(pci, PCI_CAP_ID_EXP);
787+
u32 lnkcap = dw_pcie_readl_dbi(pci, cap + PCI_EXP_LNKCAP);
788+
789+
return FIELD_GET(PCI_EXP_LNKCAP_MLW, lnkcap);
790+
}
791+
784792
static void dw_pcie_link_set_max_link_width(struct dw_pcie *pci, u32 num_lanes)
785793
{
786794
u32 lnkcap, lwsc, plc;

drivers/pci/controller/dwc/pcie-designware.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,7 @@ void dw_pcie_write_dbi2(struct dw_pcie *pci, u32 reg, size_t size, u32 val);
540540
int dw_pcie_link_up(struct dw_pcie *pci);
541541
void dw_pcie_upconfig_setup(struct dw_pcie *pci);
542542
int dw_pcie_wait_for_link(struct dw_pcie *pci);
543+
int dw_pcie_link_get_max_link_width(struct dw_pcie *pci);
543544
int dw_pcie_prog_outbound_atu(struct dw_pcie *pci,
544545
const struct dw_pcie_ob_atu_cfg *atu);
545546
int dw_pcie_prog_inbound_atu(struct dw_pcie *pci, int index, int type,

0 commit comments

Comments
 (0)