Skip to content

Commit 907fce0

Browse files
g00308965bjorn-helgaas
authored andcommitted
PCI: designware: Make "num-lanes" an optional DT property
Currently "num-lanes" is read in dw_pcie_host_init(), but it is only used if we call dw_pcie_setup_rc() while bringing up the link. If the link has already been brought up by firmware, we need not call dw_pcie_setup_rc(), and "num-lanes" is unnecessary. Only complain about "num-lanes" if we actually need it and we didn't find a valid value. [bhelgaas: changelog] Signed-off-by: Gabriele Paoloni <gabriele.paoloni@huawei.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
1 parent b6b18f5 commit 907fce0

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

‎Documentation/devicetree/bindings/pci/designware-pcie.txt‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@ Required properties:
1414
- interrupt-map-mask and interrupt-map: standard PCI properties
1515
to define the mapping of the PCIe interface to interrupt
1616
numbers.
17-
- num-lanes: number of lanes to use
1817
- clocks: Must contain an entry for each entry in clock-names.
1918
See ../clocks/clock-bindings.txt for details.
2019
- clock-names: Must include the following entries:
2120
- "pcie"
2221
- "pcie_bus"
2322

2423
Optional properties:
24+
- num-lanes: number of lanes to use (this property should be specified unless
25+
the link is brought already up in BIOS)
2526
- reset-gpio: gpio pin number of power good signal
2627
- bus-range: PCI bus numbers covered (it is recommended for new devicetrees to
2728
specify this property, to keep backwards compatibility a range of 0x00-0xff

‎drivers/pci/host/pcie-designware.c‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -534,10 +534,9 @@ int dw_pcie_host_init(struct pcie_port *pp)
534534
}
535535
}
536536

537-
if (of_property_read_u32(np, "num-lanes", &pp->lanes)) {
538-
dev_err(pp->dev, "Failed to parse the number of lanes\n");
539-
return -EINVAL;
540-
}
537+
ret = of_property_read_u32(np, "num-lanes", &pp->lanes);
538+
if (ret)
539+
pp->lanes = 0;
541540

542541
if (IS_ENABLED(CONFIG_PCI_MSI)) {
543542
if (!pp->ops->msi_host_init) {
@@ -814,6 +813,9 @@ void dw_pcie_setup_rc(struct pcie_port *pp)
814813
case 8:
815814
val |= PORT_LINK_MODE_8_LANES;
816815
break;
816+
default:
817+
dev_err(pp->dev, "num-lanes %u: invalid value\n", pp->lanes);
818+
return;
817819
}
818820
dw_pcie_writel_rc(pp, val, PCIE_PORT_LINK_CONTROL);
819821

0 commit comments

Comments
 (0)