Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Gabriele Paoloni and committed by
Bjorn Helgaas
907fce09 b6b18f58

+8 -5
+2 -1
Documentation/devicetree/bindings/pci/designware-pcie.txt
··· 14 14 - interrupt-map-mask and interrupt-map: standard PCI properties 15 15 to define the mapping of the PCIe interface to interrupt 16 16 numbers. 17 - - num-lanes: number of lanes to use 18 17 - clocks: Must contain an entry for each entry in clock-names. 19 18 See ../clocks/clock-bindings.txt for details. 20 19 - clock-names: Must include the following entries: ··· 21 22 - "pcie_bus" 22 23 23 24 Optional properties: 25 + - num-lanes: number of lanes to use (this property should be specified unless 26 + the link is brought already up in BIOS) 24 27 - reset-gpio: gpio pin number of power good signal 25 28 - bus-range: PCI bus numbers covered (it is recommended for new devicetrees to 26 29 specify this property, to keep backwards compatibility a range of 0x00-0xff
+6 -4
drivers/pci/host/pcie-designware.c
··· 534 534 } 535 535 } 536 536 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; 541 540 542 541 if (IS_ENABLED(CONFIG_PCI_MSI)) { 543 542 if (!pp->ops->msi_host_init) { ··· 813 814 case 8: 814 815 val |= PORT_LINK_MODE_8_LANES; 815 816 break; 817 + default: 818 + dev_err(pp->dev, "num-lanes %u: invalid value\n", pp->lanes); 819 + return; 816 820 } 817 821 dw_pcie_writel_rc(pp, val, PCIE_PORT_LINK_CONTROL); 818 822