Manage the PCIe supplies with pwrctrl
v2 cover Manage the PCIe supplies with pwrctrl
The Rockchip PCIe host controller describes a single vpcie3v3 supply on the controller node to power whatever is plugged into the slot. That is enough for a board that only ever has one device there, but it cannot express per-device supplies, and it does not fit boards where the slot power is owned by a separate power sequencing or switch device.
This series switches the pcie-dw-rockchip driver to the generic PCI pwrctrl framework, which lets the supplies of the devices below a host controller be described in their own DT nodes and be enabled before the PHY is initialized.
Patch 1 makes the driver create and power on the pwrctrl devices below the controller ahead of the PHY init. The controller level vpcie3v3 supply is kept for backward compatibility, so existing boards keep working unchanged.
Patch 2 moves the supply of the RK3588 EVB1 slot into a child node that describes the slot as a PCI bridge.
Changes in v2:
- Select PCI_PWRCTRL_GENERIC from PCIE_ROCKCHIP_DW, so that the built-in controller driver cannot end up with undefined pci_pwrctrl_* references when the pwrctrl core is a module(sashiko)
- Do not destroy the pwrctrl devices on -EPROBE_DEFER, so that the deferred child devices can still bind and retrigger the probe(sashiko)
Shawn Lin (2):
PCI: dw-rockchip: Power on devices below the RC using pwrctrl
arm64: dts: rockchip: rk3588-evb1: describe the PCIe3x4 slot supply
.../boot/dts/rockchip/rk3588-evb1-v10.dts | 14 +++++++- drivers/pci/controller/dwc/Kconfig | 1 + drivers/pci/controller/dwc/pcie-dw-rockchip.c | 32 ++++++++++++++++--- 3 files changed, 42 insertions(+), 5 deletions(-)
Signature · 1 line
2.25.1
PATCH v2 1/2 PCI: dw-rockchip: Power on devices below the RC using pwrctrl
Devices below the Rockchip PCIe host controller may need resources (regulators, clocks) enabled before they can be detected on the bus. So far the driver only enabled a single vpcie3v3 supply described by the controller node itself, which cannot express per-device or per-slot supplies.
Use the PCI pwrctrl framework: before initializing the PHY, create the pwrctrl devices for the DT nodes below the controller and power them on. The supplies of the slot must be up before PHY init, so this has to run ahead of rockchip_pcie_phy_init().
The controller node supply is kept for backward compatibility: boards that still describe vpcie3v3 on the controller keep working, and boards that move the supply into a child node get it enabled by pwrctrl.
Only the RC mode is affected, the endpoint does not own the supplies of the devices below it.
---
Changes in v2:
- Select PCI_PWRCTRL_GENERIC from PCIE_ROCKCHIP_DW, so that the built-in controller driver cannot end up with undefined pci_pwrctrl_* references when the pwrctrl core is a module(sashiko)
- Do not destroy the pwrctrl devices on -EPROBE_DEFER, so that the deferred child devices can still bind and retrigger the probe(sashiko)
drivers/pci/controller/dwc/Kconfig | 1 + drivers/pci/controller/dwc/pcie-dw-rockchip.c | 32 ++++++++++++++++--- 2 files changed, 29 insertions(+), 4 deletions(-)
drivers/pci/controller/dwc/Kconfig +1 -0
@@ -368,6 +368,7 @@ config PCIE_RCAR_GEN4_EP config PCIE_ROCKCHIP_DW bool + select PCI_PWRCTRL_GENERIC config PCIE_ROCKCHIP_DW_HOST bool "Rockchip DesignWare PCIe controller (host mode)"
drivers/pci/controller/dwc/pcie-dw-rockchip.c +28 -4
@@ -19,6 +19,7 @@#include <linux/of.h> #include <linux/of_irq.h> #include <linux/phy/phy.h> +#include <linux/pci-pwrctrl.h> #include <linux/platform_device.h> #include <linux/regmap.h> #include <linux/regulator/consumer.h>
@@ -841,16 +842,33 @@ static int rockchip_pcie_probe(struct platform_device *pdev)if (ret)return ret; +/* +* Power on the devices described below this controller before the PHY +* is initialized: the slot supplies must be up before PHY init. +*/ +if (data->mode ==DW_PCIE_RC_TYPE ) { + ret =pci_pwrctrl_create_devices (dev); +if (ret) +return dev_err_probe (dev, ret, +"failed to create pwrctrl devices\n" ); + + ret =pci_pwrctrl_power_on_devices (dev); +if (ret) { +if (ret != -EPROBE_DEFER ) +pci_pwrctrl_destroy_devices (dev); +return dev_err_probe (dev, ret, +"failed to power on pwrctrl devices\n" ); + } + } +/* DON'T MOVE ME: must be enable before PHY init */ ret =devm_regulator_get_enable_optional (dev,"vpcie3v3" );if (ret <0 && ret != -ENODEV ) -return dev_err_probe (dev, ret, -"failed to enable vpcie3v3 regulator\n" ); + goto err_pwrctrl_off; ret =rockchip_pcie_phy_init (rockchip);if (ret) -return dev_err_probe (dev, ret, -"failed to initialize the phy\n" ); + goto err_pwrctrl_off; ret =reset_control_deassert (rockchip->rst);if (ret)
@@ -883,6 +901,12 @@ static int rockchip_pcie_probe(struct platform_device *pdev)clk_bulk_disable_unprepare (rockchip->clk_cnt, rockchip->clks); deinit_phy:rockchip_pcie_phy_deinit (rockchip); +err_pwrctrl_off: +if (data->mode ==DW_PCIE_RC_TYPE ) { +pci_pwrctrl_power_off_devices (dev); +if (ret != -EPROBE_DEFER ) +pci_pwrctrl_destroy_devices (dev); + }return ret; }
Signature · 1 line
2.25.1
[email protected]
AI reviewRe: [PATCH v2 1/2] PCI: dw-rockchip: Power on devices below the RC using pwrctrl
Sashiko has reviewed this patch and found no issues.
Quoted 11 lines
Devices below the Rockchip PCIe host controller may need resources (regulators, clocks) enabled before they can be detected on the bus. So far the driver only enabled a single vpcie3v3 supply described by the controller node itself, which cannot express per-device or per-slot supplies.
Use the PCI pwrctrl framework: before initializing the PHY, create the pwrctrl devices for the DT nodes below the controller and power them on. The supplies of the slot must be up before PHY init, so this has to run ahead of
rockchip_pcie_phy_init().
Quoted 8 lines
The controller node supply is kept for backward compatibility: boards that still describe vpcie3v3 on the controller keep working, and boards that move the supply into a child node get it enabled by pwrctrl.
Only the RC mode is affected, the endpoint does not own the supplies of the devices below it.
Signed-off-by Shawn Lin <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
PATCH v2 2/2 arm64: dts: rockchip: rk3588-evb1: describe the PCIe3x4 slot supply
In reply to Shawn LinMove the vpcie3v3 supply of the PCIe3x4 controller into a child node describing the slot, so that the PCI pwrctrl framework manages it.
The child node is modelled as a PCI bridge, which is what dtc expects for a node below a PCI host bridge, and carries the regulator that powers the devices in the slot.
---
(no changes since v1)
arch/arm64/boot/dts/rockchip/rk3588-evb1-v10.dts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/rockchip/rk3588-evb1-v10.dts +13 -1
@@ -569,8 +569,20 @@ &pcie3x4 { pinctrl-0 = <&pcie3_reset>, <&pcie30x4m1_clkreqn>; supports-clkreq; reset-gpios = <&gpio4 RK_PB6 GPIO_ACTIVE_HIGH>; - vpcie3v3-supply = <&vcc3v3_pcie30>; status = "okay"; + + pcie@0 { + device_type = "pci"; + compatible = "pciclass,0604"; + reg = <0x000000 0x0 0x0 0x0 0x0>; + bus-range = <0x00 0x0f>; + + #address-cells = <3>; + #size-cells = <2>; + ranges; + + vpcie3v3-supply = <&vcc3v3_pcie30>; + }; }; &pd_gpu {
Signature · 1 line
2.25.1
[email protected]
AI reviewRe: [PATCH v2 2/2] arm64: dts: rockchip: rk3588-evb1: describe the PCIe3x4 slot supply
Sashiko has reviewed this patch and found no issues.
Quoted 8 lines
Move the vpcie3v3 supply of the PCIe3x4 controller into a child node describing the slot, so that the PCI pwrctrl framework manages it.
The child node is modelled as a PCI bridge, which is what dtc expects for a node below a PCI host bridge, and carries the regulator that powers the devices in the slot.
Signed-off-by Shawn Lin <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2