PCI hotplug feature
Subsystems (4)
v5 cover PCI hotplug feature
These patches bring in PCI hotplug support for iproc family chipsets.
It includes DT binding documentation and, the implementation in iproc pcie RC driver.
Changes since v3:
Rebased to pci-next
Added; Acked-by: Rob Herring <[email protected]>
Changes since v3:
Resend. just to be in sync previous in-flight patches.
Changes since v2:
Addressed Rob Herring's comments.
Changed subject to "dt-bindings: PCI:..."
Made generic PCI hotplug properties 'slot-pluggable' and 'prsnt-gpios' Rebased the patches on top of Lorenzo's patches.
Oza Pawandeep (3):
dt-bindings: PCI: Add PCI hotplug property
dt-bindings: PCI iproc: Implement optional property prsnt-gpios
PCI: iproc: Implement PCI hotplug support
.../devicetree/bindings/pci/brcm,iproc-pcie.txt | 14 ++ Documentation/devicetree/bindings/pci/pci.txt | 15 ++ drivers/pci/host/pcie-iproc-platform.c | 3 + drivers/pci/host/pcie-iproc.c | 166 ++++++++++++++++++--- drivers/pci/host/pcie-iproc.h | 7 + 5 files changed, 187 insertions(+), 18 deletions(-)
Signature · 1 line
1.9.1
PATCH v5 1/3 dt-bindings: PCI: Add PCI hotplug property
Host drivers have the requirement of implementing PCI hotplug based on the how their SOC supports it.
Couple of properties have been added. the one to enable the hotplug feature itself, and the other caters to the PCI hotplug implementation with the use of gpios.
Documentation/devicetree/bindings/pci/pci.txt +15 -0
@@ -24,3 +24,18 @@ driver implementation may support the following properties: unsupported link speed, for instance, trying to do training for unsupported link speed, etc. Must be '4' for gen4, '3' for gen3, '2' for gen2, and '1' for gen1. Any other values are invalid. + +- slot-pluggable: + PCI hotplug feature is supported. + PCI hotplug implementation is SOC/Board specific, and also it depends on + how add-in card is designed (e.g. how many present pins are implemented). + If the slot-pluggable property is present, the following propertey could + become effective. + - prsnt-gpios: + Array of gpios, could be present if hotplug is supported. + This property defines gpio based hotplug implementation. + Example: + If x8 card is connected, then it might be possible that all the + 3 present pins could go low, or at least one pin goes low. + If x4 card is connected, then it might be possible that 2 present + pins go low, or at least one pin goes low.
Signature · 1 line
1.9.1
PATCH v5 2/3 dt-bindings: PCI iproc: Implement optional property prsnt-gpios
In reply to Oza PawandeepAdd description for optional device tree property 'prsnt-gpios' for PCI hotplug feature.
Documentation/devicetree/bindings/pci/brcm,iproc-pcie.txt +14 -0
@@ -72,6 +72,20 @@ Optional properties: - brcm,pcie-msi-inten: Needs to be present for some older iProc platforms that require the interrupt enable registers to be set explicitly to enable MSI +Optional properties: +- slot-pluggable: PCI hotplug feature is supported. +- prsnt-gpios: Array of gpios, needs to be present if Hotplug is supported. + +Refer to the following binding documents for more detailed description on +the use of 'slot-pluggable' and 'prsnt-gpios'. + Documentation/devicetree/bindings/pci/pci.txt + +Example: +prsnt-gpios: <&pca9505 32 1>, <&pca9505 33 1>; +This is x4 connector: monitoring max 2 present lines. +prsnt-gpios: <&pca9505 32 1>, <&pca9505 33 1>, <&pca9505 34 1>; +This is x8 connector: monitoring max 3 present lines. + Example: pcie0: pcie at 18012000 { compatible = "brcm,iproc-pcie";
Signature · 1 line
1.9.1
PATCH v5 3/3 PCI: iproc: Implement PCI hotplug support
In reply to Oza PawandeepThis patch implements PCI hotplug support for iproc family chipsets.
iproc based SOC (e.g. Stingray) does not have hotplug controller integrated.
Hence, standard PCI hotplug framework hooks can-not be used. e.g. controlled power up/down of slot.
The mechanism, for e.g. Stingray has adopted for PCI hotplug is as follows:
PCI present lines are input to GPIOs depending on the type of connector (x2, x4, x8).
GPIO array needs to be present if hotplug is supported. HW implementation is SOC/Board specific, and also it depends on how add-in card is designed
(e.g. how many present pins are implemented).
If x8 card is connected, then it might be possible that all the 3 present pins could go low, or at least one pin goes low. If x4 card is connected, then it might be possible that 2 present pins go low, or at least one pin goes low.
The implementation essentially takes care of following:
Quoted 4 lines
Initializing hotplug irq thread.
Detecting the endpoint device based on link state. Handling PERST and detecting the plugged devices. Ordered Hot plug-out, where User is expected
to write 1 to /sys/bus/pci/devices/<pci_dev>/remove
Quoted 2 lines
Handling spurious interrupt
Handling multiple interrupts and makes sure that card is
enumerated only once.
drivers/pci/host/pcie-iproc-platform.c +3 -0
@@ -92,6 +92,9 @@ static int iproc_pcie_pltfm_probe(struct platform_device *pdev) pcie->need_ob_cfg = true; } +if (of_property_read_bool (np,"slot-pluggable" )) + pcie->enable_hotplug = true; +/* PHY use is optional */ pcie->phy =devm_phy_get (dev,"pcie-phy" );if (IS_ERR (pcie->phy)) {
drivers/pci/host/pcie-iproc.c +148 -18
211 lines not on this page · raw message
drivers/pci/host/pcie-iproc.h +7 -0
@@ -77,6 +77,10 @@ struct iproc_pcie_ib {* @ib: inbound mapping related parameters * @ib_map: outbound mapping region related parameters * +* @enable_hotplug: indicates PCI hotplug feature is enabled +* @ep_is_present: when PCIe hotplug is enabled, this flag is used to +* indicate whether or not the endpoint device is present +* * @need_msi_steer: indicates additional configuration of the iProc PCIe * controller is required to steer MSI writes to external interrupt controller * @msi: MSI data
@@ -104,6 +108,9 @@ struct iproc_pcie {struct iproc_pcie_ib ib;const struct iproc_pcie_ib_map *ib_map; +bool enable_hotplug; +bool ep_is_present; +bool need_msi_steer;struct iproc_msi *msi; };
Signature · 1 line
1.9.1