PCI: introduce the concept of power sequencing of PCIe devices
Subsystems (8)
cover PCI: introduce the concept of power sequencing of PCIe devices
From: Bartosz Golaszewski <[email protected]>
The responses to the RFC were rather positive so here's a proper series.
During last year's Linux Plumbers we had several discussions centered around the need to power-on PCI devices before they can be detected on the bus.
The consensus during the conference was that we need to introduce a class of "PCI slot drivers" that would handle the power-sequencing.
After some additional brain-storming with Manivannan and the realization that DT maintainers won't like adding any "fake" nodes not representing actual devices, we decided to reuse existing PCI infrastructure.
The general idea is to instantiate platform devices for child nodes of the PCIe port DT node. For those nodes for which a power-sequencing driver exists, we bind it and let it probe. The driver then triggers a rescan of the PCI bus with the aim of detecting the now powered-on device. The device will consume the same DT node as the platform, power-sequencing device. We use device links to make the latter become the parent of the former.
The main advantage of this approach is not modifying the existing DT in any way and especially not adding any "fake" platform devices.
Changes since RFC:
- move the pwrseq functionality out of the port driver and into PCI core
- add support for WCN7850 to the first pwrseq driver (and update bindings)
- describe the WLAN modules in sm8550-qrd and sm8650-qrd
- rework Kconfig options, drop the defconfig changes from the series as they are no longer needed
- drop the dt-binding changes for PCI vendor codes
- extend the DT bindings for ath11k_pci with strict property checking
- various minor tweaks and fixes
Bartosz Golaszewski (7):
arm64: dts: qcom: qrb5165-rb5: describe the WLAN module of QCA6390
PCI: create platform devices for child OF nodes of the port node
PCI: hold the rescan mutex when scanning for the first time PCI/pwrseq: add pwrseq core code
dt-bindings: wireless: ath11k: describe QCA6390
dt-bindings: wireless: ath11k: describe WCN7850 PCI/pwrseq: add a pwrseq driver for QCA6390
Neil Armstrong (2):
arm64: dts: qcom: sm8550-qrd: add Wifi nodes
arm64: dts: qcom: sm8650-qrd: add Wifi nodes
.../net/wireless/qcom,ath11k-pci.yaml | 89 ++++++ arch/arm64/boot/dts/qcom/qrb5165-rb5.dts | 29 ++ arch/arm64/boot/dts/qcom/sm8250.dtsi | 10 + arch/arm64/boot/dts/qcom/sm8550-qrd.dts | 37 +++ arch/arm64/boot/dts/qcom/sm8550.dtsi | 10 + arch/arm64/boot/dts/qcom/sm8650-qrd.dts | 29 ++ arch/arm64/boot/dts/qcom/sm8650.dtsi | 10 + drivers/pci/Kconfig | 1 + drivers/pci/Makefile | 1 + drivers/pci/bus.c | 9 +- drivers/pci/probe.c | 2 + drivers/pci/pwrseq/Kconfig | 16 ++ drivers/pci/pwrseq/Makefile | 4 + drivers/pci/pwrseq/pci-pwrseq-qca6390.c | 267 ++++++++++++++++++ drivers/pci/pwrseq/pwrseq.c | 82 ++++++ drivers/pci/remove.c | 3 +- include/linux/pci-pwrseq.h | 24 ++ 17 files changed, 621 insertions(+), 2 deletions(-) create mode 100644 drivers/pci/pwrseq/Kconfig create mode 100644 drivers/pci/pwrseq/Makefile create mode 100644 drivers/pci/pwrseq/pci-pwrseq-qca6390.c create mode 100644 drivers/pci/pwrseq/pwrseq.c create mode 100644 include/linux/pci-pwrseq.h
Signature · 1 line
2.40.1
PATCH 1/9 arm64: dts: qcom: qrb5165-rb5: describe the WLAN module of QCA6390
From: Bartosz Golaszewski <[email protected]>
Describe the ath11k WLAN on-board the QCA6390 module. Include the relevant regulators and the enable GPIO.
--- arch/arm64/boot/dts/qcom/qrb5165-rb5.dts | 29 ++++++++++++++++++++++++ arch/arm64/boot/dts/qcom/sm8250.dtsi | 10 ++++++++ 2 files changed, 39 insertions(+)
arch/arm64/boot/dts/qcom/qrb5165-rb5.dts +29 -0
@@ -734,6 +734,27 @@ &pcie0_phy { vdda-pll-supply = <&vreg_l9a_1p2>; }; +&pcieport0 { + wifi@0 { + compatible = "pci17cb,1101"; + reg = <0x10000 0x0 0x0 0x0 0x0>; + + pinctrl-names = "default"; + pinctrl-0 = <&wlan_en_state>; + + enable-gpios = <&tlmm 20 GPIO_ACTIVE_HIGH>; + + vddio-supply = <&vreg_s4a_1p8>; + vddaon-supply = <&vreg_s6a_0p95>; + vddpmu-supply = <&vreg_s2f_0p95>; + vddrfa1-supply = <&vreg_s2f_0p95>; + vddrfa2-supply = <&vreg_s8c_1p3>; + vddrfa3-supply = <&vreg_s5a_1p9>; + vddpcie1-supply = <&vreg_s8c_1p3>; + vddpcie2-supply = <&vreg_s5a_1p9>; + }; +}; + &pcie1 { status = "okay"; };
@@ -1303,6 +1324,14 @@ sdc2_card_det_n: sd-card-det-n-state { function = "gpio"; bias-pull-up; }; + + wlan_en_state: wlan-default-state { + pins = "gpio20"; + function = "gpio"; + drive-strength = <16>; + output-low; + bias-pull-up; + }; }; &uart6 {
arch/arm64/boot/dts/qcom/sm8250.dtsi +10 -0
@@ -2197,6 +2197,16 @@ pcie0: pcie@1c00000 { dma-coherent; status = "disabled"; + + pcieport0: pcie@0 { + device_type = "pci"; + reg = <0x0 0x0 0x0 0x0 0x0>; + #address-cells = <3>; + #size-cells = <2>; + ranges; + + bus-range = <0x01 0xff>; + }; }; pcie0_phy: phy@1c06000 {
Signature · 1 line
2.40.1
PATCH 2/9 arm64: dts: qcom: sm8550-qrd: add Wifi nodes
In reply to Bartosz GolaszewskiFrom: Neil Armstrong <[email protected]>
Describe the ath12k WLAN on-board the WCN7850 module present on the board.
[Bartosz:
- move the pcieport0 node into the .dtsi
- make regulator naming consistent with existing DT code
- add commit message]
--- arch/arm64/boot/dts/qcom/sm8550-qrd.dts | 37 +++++++++++++++++++++++++ arch/arm64/boot/dts/qcom/sm8550.dtsi | 10 +++++++ 2 files changed, 47 insertions(+)
arch/arm64/boot/dts/qcom/sm8550-qrd.dts +37 -0
@@ -813,6 +813,25 @@ &pcie0 { status = "okay"; }; +&pcieport0 { + wifi@0 { + compatible = "pci17cb,1107"; + reg = <0x10000 0x0 0x0 0x0 0x0>; + + pinctrl-names = "default"; + pinctrl-0 = <&wlan_en>, <&pmk8550_sleep_clk>; + + enable-gpios = <&tlmm 80 GPIO_ACTIVE_HIGH>; + + vddio-supply = <&vreg_l15b_1p8>; + vdd-supply = <&vreg_s5g_0p85>; + vddaon-supply = <&vreg_s2g_0p85>; + vdddig-supply = <&vreg_s4e_0p95>; + vddrfa1-supply = <&vreg_s6g_1p86>; + vddrfa2-supply = <&vreg_s4g_1p25>; + }; +}; + &pcie0_phy { vdda-phy-supply = <&vreg_l1e_0p88>; vdda-pll-supply = <&vreg_l3e_1p2>;
@@ -900,6 +919,17 @@ &pcie_1_phy_aux_clk { clock-frequency = <1000>; }; +&pmk8550_gpios { + pmk8550_sleep_clk: sleep-clk-state { + pins = "gpio3"; + function = "func1"; + input-disable; + output-enable; + bias-disable; + power-source = <0>; + }; +}; + &qupv3_id_0 { status = "okay"; };
@@ -1035,6 +1065,13 @@ wcd_default: wcd-reset-n-active-state { bias-disable; output-low; }; + + wlan_en: wlan-en-state { + pins = "gpio80"; + function = "gpio"; + drive-strength = <8>; + bias-pull-down; + }; }; &uart7 {
arch/arm64/boot/dts/qcom/sm8550.dtsi +10 -0
@@ -1754,6 +1754,16 @@ pcie0: pcie@1c00000 { phy-names = "pciephy"; status = "disabled"; + + pcieport0: pcie@0 { + device_type = "pci"; + reg = <0x0 0x0 0x0 0x0 0x0>; + #address-cells = <3>; + #size-cells = <2>; + ranges; + + bus-range = <0x01 0xff>; + }; }; pcie0_phy: phy@1c06000 {
Signature · 1 line
2.40.1
PATCH 3/9 arm64: dts: qcom: sm8650-qrd: add Wifi nodes
In reply to Bartosz GolaszewskiFrom: Neil Armstrong <[email protected]>
Describe the ath12k WLAN on-board the WCN7850 module present on the board.
[Bartosz:
- move the pcieport0 node into the .dtsi
- make regulator naming consistent with existing DT code
- add commit message]
--- arch/arm64/boot/dts/qcom/sm8650-qrd.dts | 29 +++++++++++++++++++++++++ arch/arm64/boot/dts/qcom/sm8650.dtsi | 10 +++++++++ 2 files changed, 39 insertions(+)
arch/arm64/boot/dts/qcom/sm8650-qrd.dts +29 -0
@@ -513,6 +513,28 @@ &pcie0 { status = "okay"; }; +&pcieport0 { + wifi@0 { + compatible = "pci17cb,1107"; + reg = <0x10000 0x0 0x0 0x0 0x0>; + + pinctrl-names = "default"; + pinctrl-0 = <&wlan_en>; + + enable-gpios = <&tlmm 16 GPIO_ACTIVE_HIGH>; + + vddio12-supply = <&vreg_l3c_1p2>; + vddio-supply = <&vreg_l15b_1p8>; + vdd-supply = <&vreg_s4i_0p85>; + vddaon-supply = <&vreg_s2c_0p8>; + vdddig-supply = <&vreg_s3c_0p9>; + vddrfa1-supply = <&vreg_s6c_1p8>; + vddrfa2-supply = <&vreg_s1c_1p2>; + + clocks = <&rpmhcc RPMH_RF_CLK1>; + }; +}; + &pcie0_phy { vdda-phy-supply = <&vreg_l1i_0p88>; vdda-pll-supply = <&vreg_l3i_1p2>;
@@ -718,6 +740,13 @@ ts_reset: ts-reset-state { drive-strength = <8>; bias-pull-up; }; + + wlan_en: wlan-en-state { + pins = "gpio16"; + function = "gpio"; + drive-strength = <8>; + bias-pull-down; + }; }; &uart14 {
arch/arm64/boot/dts/qcom/sm8650.dtsi +10 -0
@@ -2270,6 +2270,16 @@ &mc_virt SLAVE_EBI1 QCOM_ICC_TAG_ALWAYS>, dma-coherent; status = "disabled"; + + pcieport0: pcie@0 { + device_type = "pci"; + reg = <0x0 0x0 0x0 0x0 0x0>; + #address-cells = <3>; + #size-cells = <2>; + ranges; + + bus-range = <0x01 0xff>; + }; }; pcie0_phy: phy@1c06000 {
Signature · 1 line
2.40.1
PATCH 4/9 PCI: create platform devices for child OF nodes of the port node
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
In order to introduce PCI power-sequencing, we need to create platform devices for child nodes of the port node. They will get matched against the pwrseq drivers (if one exists) and then the actual PCI device will reuse the node once it's detected on the bus.
--- drivers/pci/bus.c | 9 ++++++++- drivers/pci/remove.c | 3 ++- 2 files changed, 10 insertions(+), 2 deletions(-)
drivers/pci/bus.c +8 -1
@@ -12,6 +12,7 @@#include <linux/errno.h> #include <linux/ioport.h> #include <linux/of.h> +#include <linux/of_platform.h> #include <linux/proc_fs.h> #include <linux/slab.h>
@@ -342,8 +343,14 @@ void pci_bus_add_device(struct pci_dev *dev)*/ pcibios_bus_add_device (dev);pci_fixup_device (pci_fixup_final, dev); -if (pci_is_bridge (dev)) +if (pci_is_bridge (dev)) {of_pci_make_dev_node (dev); + retval =of_platform_populate (dev->dev.of_node,NULL ,NULL , + &dev->dev); +if (retval) +pci_err (dev,"failed to populate child OF nodes (%d)\n" , + retval); + }pci_create_sysfs_dev_files (dev);pci_proc_attach_device (dev);pci_bridge_d3_update (dev);
drivers/pci/remove.c +2 -1
@@ -1,6 +1,7 @@// SPDX-License-Identifier: GPL-2.0 #include <linux/pci.h> #include <linux/module.h> +#include <linux/of_platform.h> #include "pci.h" static void pci_free_resources (struct pci_dev *dev)
@@ -18,11 +19,11 @@ static void pci_stop_dev(struct pci_dev *dev)pci_pme_active (dev, false);if (pci_dev_is_added (dev)) { -device_release_driver (&dev->dev);pci_proc_detach_device (dev);pci_remove_sysfs_dev_files (dev);of_pci_remove_node (dev); +of_platform_depopulate (&dev->dev);pci_dev_assign_added (dev, false); }
Signature · 1 line
2.40.1
PATCH 5/9 PCI: hold the rescan mutex when scanning for the first time
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
With the introduction of the power sequencing drivers that will be able to trigger the port rescan, we need to hold the rescan mutex during the initial pci_host_probe() too or the two could get in each other's way.
--- drivers/pci/probe.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/pci/probe.c +2 -0
@@ -3122,7 +3122,9 @@ int pci_host_probe(struct pci_host_bridge *bridge)struct pci_bus *bus, *child;int ret; +pci_lock_rescan_remove (); ret =pci_scan_root_bus_bridge (bridge); +pci_unlock_rescan_remove ();if (ret <0 ) {dev_err (bridge->dev.parent,"Scanning root bridge failed" );return ret;
Signature · 1 line
2.40.1
PATCH 6/9 PCI/pwrseq: add pwrseq core code
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
Some PCI devices must be powered-on before they can be detected on the bus. Introduce a simple framework reusing the existing PCI OF infrastructure.
The way this works is: a DT node representing a PCI device connected to the port can be matched against its power sequencing platform driver. If the match succeeds, the driver is responsible for powering-up the device and calling pcie_pwrseq_device_enable() which will trigger a PCI bus rescan as well as subscribe to PCI bus notifications.
When the device is detected and created, we'll make it consume the same DT node that the platform device did. When the device is bound, we'll create a device link between it and the parent power sequencing device.
--- drivers/pci/Kconfig | 1 + drivers/pci/Makefile | 1 + drivers/pci/pwrseq/Kconfig | 8 ++++ drivers/pci/pwrseq/Makefile | 3 ++ drivers/pci/pwrseq/pwrseq.c | 82 +++++++++++++++++++++++++++++++++++++ include/linux/pci-pwrseq.h | 24 +++++++++++ 6 files changed, 119 insertions(+) create mode 100644 drivers/pci/pwrseq/Kconfig create mode 100644 drivers/pci/pwrseq/Makefile create mode 100644 drivers/pci/pwrseq/pwrseq.c create mode 100644 include/linux/pci-pwrseq.h
drivers/pci/Kconfig +1 -0
@@ -291,5 +291,6 @@ source "drivers/pci/hotplug/Kconfig" source "drivers/pci/controller/Kconfig" source "drivers/pci/endpoint/Kconfig" source "drivers/pci/switch/Kconfig" +source "drivers/pci/pwrseq/Kconfig" endif
drivers/pci/Makefile +1 -0
@@ -9,6 +9,7 @@ obj-$(CONFIG_PCI) += access.o bus.o probe.o host-bridge.o \ obj-$(CONFIG_PCI) += msi/ obj-$(CONFIG_PCI) += pcie/ +obj-$(CONFIG_PCI) += pwrseq/ ifdef CONFIG_PCI obj-$(CONFIG_PROC_FS) += proc.o
drivers/pci/pwrseq/Kconfig new file +8 -0
@@ -0,0 +1,8 @@ +# SPDX-License-Identifier: GPL-2.0 + +menu "PCI Power sequencing drivers" + +config PCI_PWRSEQ + bool + +endmenu
drivers/pci/pwrseq/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0 + +obj-$(CONFIG_PCI_PWRSEQ) += pwrseq.o
drivers/pci/pwrseq/pwrseq.c new file +82 -0
82 lines not on this page · raw message
include/linux/pci-pwrseq.h new file +24 -0
@@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* +* Copyright (C) 2024 Linaro Ltd. +*/ + +#ifndef __PCI_PWRSEQ_H__ +#define __PCI_PWRSEQ_H__ + +#include <linux/notifier.h> + +struct device ; + +struct pci_pwrseq { +struct notifier_block nb; +struct device *dev; +struct device_link *link; +}; + +int pci_pwrseq_device_enable (struct pci_pwrseq *pwrseq); +void pci_pwrseq_device_disable (struct pci_pwrseq *pwrseq); +int devm_pci_pwrseq_device_enable (struct device *dev, +struct pci_pwrseq *pwrseq); + +#endif /* __PCI_PWRSEQ_H__ */
Signature · 1 line
2.40.1
PATCH 7/9 dt-bindings: wireless: ath11k: describe QCA6390
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
Describe the ath11k variant present on the QCA6390 module.
--- .../net/wireless/qcom,ath11k-pci.yaml | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+)
Documentation/devicetree/bindings/net/wireless/qcom,ath11k-pci.yaml +48 -0
@@ -16,6 +16,7 @@ description: | properties: compatible: enum: + - pci17cb,1101 # QCA6390 - pci17cb,1103 # WCN6855 reg:
@@ -27,10 +28,57 @@ properties: string to uniquely identify variant of the calibration data for designs with colliding bus and device ids + enable-gpios: + description: GPIO line enabling the ATH11K module when asserted. + maxItems: 1 + + vddio-supply: + description: VDD_IO supply regulator handle + + vddaon-supply: + description: VDD_AON supply regulator handle + + vddpmu-supply: + description: VDD_PMU supply regulator handle + + vddpcie1-supply: + description: VDD_PCIE1 supply regulator handle + + vddpcie2-supply: + description: VDD_PCIE2 supply regulator handle + + vddrfa1-supply: + description: VDD_RFA1 supply regulator handle + + vddrfa2-supply: + description: VDD_RFA2 supply regulator handle + + vddrfa3-supply: + description: VDD_RFA3 supply regulator handle + required: - compatible - reg +allOf: + - if: + properties: + compatible: + contains: + enum: + - pci17cb,1103 + then: + properties: + enable-gpios: false + vddio-supply: false + vddaon-supply: false + vddpmu-supply: false + vddrfa1-supply: false + vddrfa2-supply: false + vddrfa3-supply: false + vddpcie1-supply: false + vddpcie2-supply: false + additionalProperties: false examples:
Signature · 1 line
2.40.1
PATCH 8/9 dt-bindings: wireless: ath11k: describe WCN7850
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
Describe the ath11k variant present on the WCN7850 module.
--- .../net/wireless/qcom,ath11k-pci.yaml | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+)
Documentation/devicetree/bindings/net/wireless/qcom,ath11k-pci.yaml +41 -0
@@ -18,6 +18,7 @@ properties: enum: - pci17cb,1101 # QCA6390 - pci17cb,1103 # WCN6855 + - pci17cb,1107 # WCN7850 reg: maxItems: 1
@@ -28,13 +29,25 @@ properties: string to uniquely identify variant of the calibration data for designs with colliding bus and device ids + clocks: + maxItems: 1 + enable-gpios: description: GPIO line enabling the ATH11K module when asserted. maxItems: 1 + vdd-supply: + description: VDD supply regulator handle + + vdddig-supply: + description: VDD_DIG supply regulator handle + vddio-supply: description: VDD_IO supply regulator handle + vddio12-supply: + description: VDD_IO12 supply regulator handle + vddaon-supply: description: VDD_AON supply regulator handle
@@ -61,6 +74,18 @@ required: - reg allOf: + - if: + properties: + compatible: + contains: + enum: + - pci17cb,1101 + then: + properties: + clocks: false + vdd-supply: false + vdddig-supply: false + vddio12-supply: false - if: properties: compatible:
@@ -69,7 +94,11 @@ allOf: - pci17cb,1103 then: properties: + clocks: false enable-gpios: false + vdd-supply: false + vddio12-supply: false + vdddig-supply: false vddio-supply: false vddaon-supply: false vddpmu-supply: false
@@ -78,6 +107,18 @@ allOf: vddrfa3-supply: false vddpcie1-supply: false vddpcie2-supply: false + - if: + properties: + compatible: + contains: + enum: + - pci17cb,1107 + then: + properties: + vddpmu-supply: false + vddrfa3-supply: false + vddpcie1-supply: false + vddpcie2-supply: false additionalProperties: false
Signature · 1 line
2.40.1
PATCH 9/9 PCI/pwrseq: add a pwrseq driver for QCA6390
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
Add a PCI power sequencing driver that's capable of correctly powering up the ath11k module on QCA6390 and WCN7850 using the PCI pwrseq functionality.
--- drivers/pci/pwrseq/Kconfig | 8 + drivers/pci/pwrseq/Makefile | 1 + drivers/pci/pwrseq/pci-pwrseq-qca6390.c | 267 ++++++++++++++++++++++++ 3 files changed, 276 insertions(+) create mode 100644 drivers/pci/pwrseq/pci-pwrseq-qca6390.c
drivers/pci/pwrseq/Kconfig +8 -0
@@ -5,4 +5,12 @@ menu "PCI Power sequencing drivers" config PCI_PWRSEQ bool +config PCI_PWRSEQ_QCA6390 + tristate "PCI Power Sequencing driver for QCA6390" + select PCI_PWRSEQ + default (ATH11K_PCI && ARCH_QCOM) + help + Enable support for the PCI power sequencing driver for the + ath11k module of the QCA6390 WLAN/BT chip. + endmenu
drivers/pci/pwrseq/Makefile +1 -0
@@ -1,3 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_PCI_PWRSEQ) += pwrseq.o +obj-$(CONFIG_PCI_PWRSEQ_QCA6390) += pci-pwrseq-qca6390.o
drivers/pci/pwrseq/pci-pwrseq-qca6390.c new file +267 -0
267 lines not on this page · raw message
Signature · 1 line
2.40.1
RE: [PATCH 4/9] PCI: create platform devices for child OF nodes of the port node
In reply to Bartosz GolaszewskiQuoted 8 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
In order to introduce PCI power-sequencing, we need to create platform devices for child nodes of the port node. They will get matched against the pwrseq drivers (if one exists) and then the actual PCI device will reuse the node once it's detected on the bus.
Signed-off-by Bartosz Golaszewski <[email protected]>
[..]
Quoted 14 lines
drivers/pci/remove.c +1
-0@@ -1,6 +1,7 @@// SPDX-License-Identifier: GPL-2.0 #include <linux/pci.h> #include <linux/module.h> +#include <linux/of_platform.h> #include "pci.h" static void pci_free_resources (struct pci_dev *dev)@@ -18,11 +19,11 @@ static void pci_stop_dev(struct pci_dev *dev)pci_pme_active (dev, false);
drivers/pci/remove.c static void pci_stop_dev(struct pci_dev *dev) · line 28
Quoted 10 lines
drivers/pci/remove.c +1
-1if (pci_dev_is_added (dev)) { -device_release_driver (&dev->dev);pci_proc_detach_device (dev);pci_remove_sysfs_dev_files (dev);of_pci_remove_node (dev); +of_platform_depopulate (&dev->dev);pci_dev_assign_added (dev, false);
Why is pci_stop_dev() not in strict reverse order of pci_bus_add_device()? I see that pci_dev_assign_added() was already not in reverse "add" order before your change, but I otherwise would have expected of_platform_depopulate() before of_pci_remove_node() (assumed paired with of_pci_make_dev_node()).
Re: [PATCH 4/9] PCI: create platform devices for child OF nodes of the port node
In reply to Bartosz GolaszewskiQuoted 4 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
In order to introduce PCI power-sequencing, we need to create platform devices for child nodes of the port node.
Ick, why a platform device? What is the parent of this device, a PCI device? If so, then this can't be a platform device, as that's not what it is, it's something else so make it a device of that type,.
Quoted 3 lines
They will get matched against
the pwrseq drivers (if one exists) and then the actual PCI device will reuse the node once it's detected on the bus.
Reuse it how?
Quoted 19 lines
Signed-off-by Bartosz Golaszewski <[email protected]>--- drivers/pci/bus.c | 9 ++++++++- drivers/pci/remove.c | 3 ++- 2 files changed, 10 insertions(+), 2 deletions(-)drivers/pci/bus.c +1
-0@@ -12,6 +12,7 @@#include <linux/errno.h> #include <linux/ioport.h> #include <linux/of.h> +#include <linux/of_platform.h> #include <linux/proc_fs.h> #include <linux/slab.h>
drivers/pci/bus.c void pci_bus_add_device(struct pci_dev *dev) · line 349
Quoted 8 lines
drivers/pci/bus.c +3
-1@@ -342,8 +343,14 @@ void pci_bus_add_device(struct pci_dev *dev)*/ pcibios_bus_add_device (dev);pci_fixup_device (pci_fixup_final, dev); -if (pci_is_bridge (dev)) +if (pci_is_bridge (dev)) {of_pci_make_dev_node (dev); + retval =of_platform_populate (dev->dev.of_node,NULL ,NULL , + &dev->dev);
So this is a pci bridge device, not a platform device, please don't do this, make it a real device of a new type.
thanks,
greg k-h
Quoted 67 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
The responses to the RFC were rather positive so here's a proper series.
During last year's Linux Plumbers we had several discussions centered around the need to power-on PCI devices before they can be detected on the bus.
The consensus during the conference was that we need to introduce a class of "PCI slot drivers" that would handle the power-sequencing.
After some additional brain-storming with Manivannan and the realization that DT maintainers won't like adding any "fake" nodes not representing actual devices, we decided to reuse existing PCI infrastructure.
The general idea is to instantiate platform devices for child nodes of the PCIe port DT node. For those nodes for which a power-sequencing driver exists, we bind it and let it probe. The driver then triggers a rescan of the PCI bus with the aim of detecting the now powered-on device. The device will consume the same DT node as the platform, power-sequencing device. We use device links to make the latter become the parent of the former.
The main advantage of this approach is not modifying the existing DT in any way and especially not adding any "fake" platform devices.
Changes since RFC:
- move the pwrseq functionality out of the port driver and into PCI core
- add support for WCN7850 to the first pwrseq driver (and update bindings)
- describe the WLAN modules in sm8550-qrd and sm8650-qrd
- reworkKconfigoptions, drop the defconfig changes from the series as they are no longer needed
- drop the dt-binding changes for PCI vendor codes
- extend the DT bindings forath11k_pciwith strict property checking
- various minor tweaks and fixesBartosz Golaszewski (7):
arm64: dts: qcom: qrb5165-rb5: describe the WLAN module of QCA6390
PCI: create platform devices for child OF nodes of the port node
PCI: hold the rescan mutex when scanning for the first time PCI/pwrseq: add pwrseq core code
dt-bindings: wireless: ath11k: describe QCA6390
dt-bindings: wireless: ath11k: describe WCN7850 PCI/pwrseq: add a pwrseq driver for QCA6390Neil Armstrong (2):
arm64: dts: qcom: sm8550-qrd: add Wifi nodes
arm64: dts: qcom: sm8650-qrd: add Wifi nodes.../net/wireless/qcom,ath11k-pci.yaml | 89 ++++++ arch/arm64/boot/dts/qcom/qrb5165-rb5.dts | 29 ++ arch/arm64/boot/dts/qcom/sm8250.dtsi | 10 + arch/arm64/boot/dts/qcom/sm8550-qrd.dts | 37 +++ arch/arm64/boot/dts/qcom/sm8550.dtsi | 10 + arch/arm64/boot/dts/qcom/sm8650-qrd.dts | 29 ++ arch/arm64/boot/dts/qcom/sm8650.dtsi | 10 + drivers/pci/Kconfig | 1 + drivers/pci/Makefile | 1 + drivers/pci/bus.c | 9 +- drivers/pci/probe.c | 2 + drivers/pci/pwrseq/Kconfig | 16 ++ drivers/pci/pwrseq/Makefile | 4 + drivers/pci/pwrseq/pci-pwrseq-qca6390.c | 267 ++++++++++++++++++ drivers/pci/pwrseq/pwrseq.c | 82 ++++++ drivers/pci/remove.c | 3 +- include/linux/pci-pwrseq.h | 24 ++ 17 files changed, 621 insertions(+), 2 deletions(-)
Quoted 6 lines
create mode 100644
drivers/pci/pwrseq/Kconfigcreate mode 100644drivers/pci/pwrseq/Makefilecreate mode 100644drivers/pci/pwrseq/pci-pwrseq-qca6390.ccreate mode 100644drivers/pci/pwrseq/pwrseq.ccreate mode 100644include/linux/pci-pwrseq.h
Thanks,
Neil
Re: [PATCH 8/9] dt-bindings: wireless: ath11k: describe WCN7850
In reply to Bartosz GolaszewskiQuoted 5 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
Describe the ath11k variant present on the WCN7850 module.
Signed-off-by Bartosz Golaszewski <[email protected]>
ath12k supports WCN7850 (a Wi-Fi 7 chipset), not ath11k.
Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/list/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
Quoted 24 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
The responses to the RFC were rather positive so here's a proper series.
During last year's Linux Plumbers we had several discussions centered around the need to power-on PCI devices before they can be detected on the bus.
The consensus during the conference was that we need to introduce a class of "PCI slot drivers" that would handle the power-sequencing.
After some additional brain-storming with Manivannan and the realization that DT maintainers won't like adding any "fake" nodes not representing actual devices, we decided to reuse existing PCI infrastructure.
The general idea is to instantiate platform devices for child nodes of the PCIe port DT node. For those nodes for which a power-sequencing driver exists, we bind it and let it probe. The driver then triggers a rescan of the PCI bus with the aim of detecting the now powered-on device. The device will consume the same DT node as the platform, power-sequencing device. We use device links to make the latter become the parent of the former.
Quoted 2 lines
The main advantage of this approach is not modifying the existing DT in any way and especially not adding any "fake" platform devices.
I'd still like to see how this can be extended to handle BT power up, having a single entity driving both of the BT and WiFI.
The device tree changes behave in exactly the opposite way: they define regulators for the WiFi device, while the WiFi is not being powered by these regulators. Both WiFi and BT are powered by the PMU, which in turn consumes all specified regulators.
Quoted 52 lines
Changes since RFC:
- move the pwrseq functionality out of the port driver and into PCI core
- add support for WCN7850 to the first pwrseq driver (and update bindings)
- describe the WLAN modules in sm8550-qrd and sm8650-qrd
- reworkKconfigoptions, drop the defconfig changes from the series as they are no longer needed
- drop the dt-binding changes for PCI vendor codes
- extend the DT bindings forath11k_pciwith strict property checking
- various minor tweaks and fixesBartosz Golaszewski (7):
arm64: dts: qcom: qrb5165-rb5: describe the WLAN module of QCA6390
PCI: create platform devices for child OF nodes of the port node
PCI: hold the rescan mutex when scanning for the first time PCI/pwrseq: add pwrseq core code
dt-bindings: wireless: ath11k: describe QCA6390
dt-bindings: wireless: ath11k: describe WCN7850 PCI/pwrseq: add a pwrseq driver for QCA6390Neil Armstrong (2):
arm64: dts: qcom: sm8550-qrd: add Wifi nodes
arm64: dts: qcom: sm8650-qrd: add Wifi nodes.../net/wireless/qcom,ath11k-pci.yaml | 89 ++++++ arch/arm64/boot/dts/qcom/qrb5165-rb5.dts | 29 ++ arch/arm64/boot/dts/qcom/sm8250.dtsi | 10 + arch/arm64/boot/dts/qcom/sm8550-qrd.dts | 37 +++ arch/arm64/boot/dts/qcom/sm8550.dtsi | 10 + arch/arm64/boot/dts/qcom/sm8650-qrd.dts | 29 ++ arch/arm64/boot/dts/qcom/sm8650.dtsi | 10 + drivers/pci/Kconfig | 1 + drivers/pci/Makefile | 1 + drivers/pci/bus.c | 9 +- drivers/pci/probe.c | 2 + drivers/pci/pwrseq/Kconfig | 16 ++ drivers/pci/pwrseq/Makefile | 4 + drivers/pci/pwrseq/pci-pwrseq-qca6390.c | 267 ++++++++++++++++++ drivers/pci/pwrseq/pwrseq.c | 82 ++++++ drivers/pci/remove.c | 3 +- include/linux/pci-pwrseq.h | 24 ++ 17 files changed, 621 insertions(+), 2 deletions(-) create mode 100644 drivers/pci/pwrseq/Kconfig create mode 100644 drivers/pci/pwrseq/Makefile create mode 100644 drivers/pci/pwrseq/pci-pwrseq-qca6390.c create mode 100644 drivers/pci/pwrseq/pwrseq.c create mode 100644 include/linux/pci-pwrseq.h--
2.40.1
Signature · 2 lines
With best wishes Dmitry
Re: [PATCH 8/9] dt-bindings: wireless: ath11k: describe WCN7850
In reply to Kalle ValoQuoted 7 lines · Kalle Valo
Quoted 4 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
Describe the ath11k variant present on the WCN7850 module.
Quoted 8 lines
Quoted 1 line
Signed-off-by Bartosz Golaszewski <[email protected]>ath12k supports WCN7850 (a Wi-Fi 7 chipset), not ath11k.
--
https://patchwork.kernel.org/project/linux-wireless/list/https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
Eek! Indeed. So most of the ifs in the bindings are not really needed after all... which is good actually.
Bart
Re: [PATCH 9/9] PCI/pwrseq: add a pwrseq driver for QCA6390
In reply to Bartosz GolaszewskiQuoted 9 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
Add a PCI power sequencing driver that's capable of correctly powering up the ath11k module on QCA6390 and WCN7850 using the PCI pwrseq functionality.
Signed-off-by Bartosz Golaszewski <[email protected]>[Neil: add support for WCN7850]Signed-off-by Neil Armstrong <[email protected]>
Here also: ath12k supports WCN7850, not ath11k.
Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/list/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
Re: [PATCH 4/9] PCI: create platform devices for child OF nodes of the port node
In reply to Greg Kroah-HartmanQuoted 11 lines · Greg Kroah-Hartman
Quoted 4 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
In order to introduce PCI power-sequencing, we need to create platform devices for child nodes of the port node.
Ick, why a platform device? What is the parent of this device, a PCI device? If so, then this can't be a platform device, as that's not what it is, it's something else so make it a device of that type,.
Greg,
This is literally what we agreed on at LPC. In fact: during one of the hall track discussions I said that you typically NAK any attempts at using the platform bus for "fake" devices but you responded that this is what the USB on-board HUB does and while it's not pretty, this is what we need to do.
Now as for the implementation, the way I see it we have two solutions:
either we introduce a fake, top-level PCI slot platform device device that will reference the PCI host controller by phandle or we will live with a secondary, "virtual" platform device for power sequencing that is tied to the actual PCI device. The former requires us to add DT bindings, add a totally fake DT node representing the "slot" which doesn't really exist (and Krzysztof already expressed his negative opinion of that) and then have code that will be more complex than it needs to be. The latter allows us to not change DT at all (other than adding regulators, clocks and GPIOs to already existing WLAN nodes), reuse the existing parent-child relationship between the port node and the instantiated platform device as well as result in simpler code.
Given that DT needs to be stable while the underlying C code can freely change if we find a better solution, I think that the second option is a no-brainer here.
Quoted 6 lines
Quoted 3 lines
They will get matched against
the pwrseq drivers (if one exists) and then the actual PCI device will reuse the node once it's detected on the bus.Reuse it how?
By consuming the same DT node using device_set_of_node_from_dev() when the PCI device is registered. This ensures we don't try to bind pinctrl twice etc.
Quoted 18 lines
Quoted 18 lines
Signed-off-by Bartosz Golaszewski <[email protected]>--- drivers/pci/bus.c | 9 ++++++++- drivers/pci/remove.c | 3 ++- 2 files changed, 10 insertions(+), 2 deletions(-)drivers/pci/bus.c +1
-0@@ -12,6 +12,7 @@#include <linux/errno.h> #include <linux/ioport.h> #include <linux/of.h> +#include <linux/of_platform.h> #include <linux/proc_fs.h> #include <linux/slab.h>
Quoted 13 lines
drivers/pci/bus.c void pci_bus_add_device(struct pci_dev *dev) · line 349
Quoted 9 lines
drivers/pci/bus.c +3
-1@@ -342,8 +343,14 @@ void pci_bus_add_device(struct pci_dev *dev)*/ pcibios_bus_add_device (dev);pci_fixup_device (pci_fixup_final, dev); -if (pci_is_bridge (dev)) +if (pci_is_bridge (dev)) {of_pci_make_dev_node (dev); + retval =of_platform_populate (dev->dev.of_node,NULL ,NULL , + &dev->dev);So this is a pci bridge device, not a platform device, please don't do this, make it a real device of a new type.
Not sure what you mean. Are you suggesting adding a new bus? Or do we already have a concept of PCI bridge devices in the kernel?
Bartosz
Quoted 3 lines
thanks,
greg k-h
Re: [PATCH 4/9] PCI: create platform devices for child OF nodes of the port node
Quoted 14 lines · Bartosz Golaszewski
Quoted 11 lines · Greg Kroah-Hartman
Quoted 4 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
In order to introduce PCI power-sequencing, we need to create platform devices for child nodes of the port node.
Ick, why a platform device? What is the parent of this device, a PCI device? If so, then this can't be a platform device, as that's not what it is, it's something else so make it a device of that type,.
Quoted 7 lines
Greg,
This is literally what we agreed on at LPC. In fact: during one of the hall track discussions I said that you typically NAK any attempts at using the platform bus for "fake" devices but you responded that this is what the USB on-board HUB does and while it's not pretty, this is what we need to do.
Ah, you need to remind me of these things, this changelog was pretty sparse :)
Quoted 13 lines
Now as for the implementation, the way I see it we have two solutions:
either we introduce a fake, top-level PCI slot platform device device that will reference the PCI host controller by phandle or we will live with a secondary, "virtual" platform device for power sequencing that is tied to the actual PCI device. The former requires us to add DT bindings, add a totally fake DT node representing the "slot" which doesn't really exist (and Krzysztof already expressed his negative opinion of that) and then have code that will be more complex than it needs to be. The latter allows us to not change DT at all (other than adding regulators, clocks and GPIOs to already existing WLAN nodes), reuse the existing parent-child relationship between the port node and the instantiated platform device as well as result in simpler code.
Quoted 3 lines
Given that DT needs to be stable while the underlying C code can freely change if we find a better solution, I think that the second option is a no-brainer here.
Ok, I remove my objections, sorry about that, my confusion.
greg k-h
Re: [PATCH 4/9] PCI: create platform devices for child OF nodes of the port node
In reply to Dan WilliamsQuoted 34 lines · Dan Williams
Quoted 8 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
In order to introduce PCI power-sequencing, we need to create platform devices for child nodes of the port node. They will get matched against the pwrseq drivers (if one exists) and then the actual PCI device will reuse the node once it's detected on the bus.
Signed-off-by Bartosz Golaszewski <[email protected]>[..]
Quoted 23 lines
drivers/pci/remove.c +2
-1@@ -1,6 +1,7 @@// SPDX-License-Identifier: GPL-2.0 #include <linux/pci.h> #include <linux/module.h> +#include <linux/of_platform.h> #include "pci.h" static void pci_free_resources (struct pci_dev *dev)@@ -18,11 +19,11 @@ static void pci_stop_dev(struct pci_dev *dev)pci_pme_active (dev, false);if (pci_dev_is_added (dev)) { -device_release_driver (&dev->dev);pci_proc_detach_device (dev);pci_remove_sysfs_dev_files (dev);of_pci_remove_node (dev); +of_platform_depopulate (&dev->dev);
Quoted 7 lines
drivers/pci/remove.c static void pci_stop_dev(struct pci_dev *dev) · line 28
Quoted 1 line
drivers/pci/remove.c +0
-0pci_dev_assign_added (dev, false);Why is
pci_stop_dev()not in strict reverse order ofpci_bus_add_device()? I see thatpci_dev_assign_added()was already not in reverse "add" order before your change, but I otherwise would have expectedof_platform_depopulate()beforeof_pci_remove_node()(assumed paired withof_pci_make_dev_node()).
The naming here is confusing but the two have nothing in common. One is used by CONFIG_PCI_DYNAMIC_OF_NODES to *create* new DT nodes for detected PCI devices. The one I'm adding, creates power sequencing *devices* (no nodes) for *existing* DT nodes.
So the order is not really relevant here but I can change in v2.
Bartosz
Quoted 4 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
The responses to the RFC were rather positive so here's a proper series.
Thanks for tackling this.
Quoted 10 lines
During last year's Linux Plumbers we had several discussions centered around the need to power-on PCI devices before they can be detected on the bus.
The consensus during the conference was that we need to introduce a class of "PCI slot drivers" that would handle the power-sequencing.
After some additional brain-storming with Manivannan and the realization that DT maintainers won't like adding any "fake" nodes not representing actual devices, we decided to reuse existing PCI infrastructure.
Thank you. :)
Quoted 10 lines
The general idea is to instantiate platform devices for child nodes of the PCIe port DT node. For those nodes for which a power-sequencing driver exists, we bind it and let it probe. The driver then triggers a rescan of the PCI bus with the aim of detecting the now powered-on device. The device will consume the same DT node as the platform, power-sequencing device. We use device links to make the latter become the parent of the former.
The main advantage of this approach is not modifying the existing DT in any way and especially not adding any "fake" platform devices.
Suspend/resume has been brought up already, but I disagree we can worry about that later unless there is and always will be no power sequencing during suspend/resume for all devices ever. Given the supplies aren't standard, it wouldn't surprise me if standard PCI power management isn't either. The primary issue I see with this design is we will end up with 2 drivers doing the same power
sequencing: the platform driver for initial power on and the device's PCI driver for suspend/resume.
Rob
Quoted 2 lines · Rob Herring
On Wed, Jan 17, 2024 at 10:08 AM Bartosz Golaszewski <[email protected]> wrote:
[snip]
Quoted 21 lines
Quoted 11 lines
The general idea is to instantiate platform devices for child nodes of the PCIe port DT node. For those nodes for which a power-sequencing driver exists, we bind it and let it probe. The driver then triggers a rescan of the PCI bus with the aim of detecting the now powered-on device. The device will consume the same DT node as the platform, power-sequencing device. We use device links to make the latter become the parent of the former.
The main advantage of this approach is not modifying the existing DT in any way and especially not adding any "fake" platform devices.
Suspend/resume has been brought up already, but I disagree we can worry about that later unless there is and always will be no power sequencing during suspend/resume for all devices ever. Given the supplies aren't standard, it wouldn't surprise me if standard PCI power management isn't either. The primary issue I see with this design is we will end up with 2 drivers doing the same power
sequencing: the platform driver for initial power on and the device's PCI driver for suspend/resume.
Quoted 2 lines
Rob
I admit that I don't have any HW where I could test it but I my thinking was that with the following relationships between the devices:
┌─────────────────────┐
│ │
│ PCI Port device │
│ │
└───┬───────────┬─────┘
│ │
│ │
│ │
┌─────────────────────▼─────┐ │
│ │ │
│ QCA6390 pwrseq device │ │
│ │ │
└─────────────────────┬─────┘ │
│ │
│ │
│ │
┌─────▼───────────▼───┐
│ │
│ ath11k_pci device │
│ │
└─────────────────────┘the PM subsystem would handle the dependencies automatically and correctly setup the sequence for suspend and resume. Also: the PCI ath11k driver does not deal with the kind of resources that the power sequencing platform driver
handles: regulators, GPIOs and clocks.
I agree, it would be useful to have a working case of handling suspend/resume with this code though.
Bartosz
Quoted 32 lines · Rob Herring
Quoted 4 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
The responses to the RFC were rather positive so here's a proper series.
Thanks for tackling this.
Quoted 10 lines
During last year's Linux Plumbers we had several discussions centered around the need to power-on PCI devices before they can be detected on the bus.
The consensus during the conference was that we need to introduce a class of "PCI slot drivers" that would handle the power-sequencing.
After some additional brain-storming with Manivannan and the realization that DT maintainers won't like adding any "fake" nodes not representing actual devices, we decided to reuse existing PCI infrastructure.
Thank you. :)
Quoted 10 lines
The general idea is to instantiate platform devices for child nodes of the PCIe port DT node. For those nodes for which a power-sequencing driver exists, we bind it and let it probe. The driver then triggers a rescan of the PCI bus with the aim of detecting the now powered-on device. The device will consume the same DT node as the platform, power-sequencing device. We use device links to make the latter become the parent of the former.
The main advantage of this approach is not modifying the existing DT in any way and especially not adding any "fake" platform devices.
Quoted 9 lines
Suspend/resume has been brought up already, but I disagree we can worry about that later unless there is and always will be no power sequencing during suspend/resume for all devices ever. Given the supplies aren't standard, it wouldn't surprise me if standard PCI power management isn't either. The primary issue I see with this design is we will end up with 2 drivers doing the same power
sequencing: the platform driver for initial power on and the device's PCI driver for suspend/resume.
There are actually 3 drivers need to do their own power management operations:
1. PCIe device driver - Handle the PM of the device itself (shutdown, low power)
2. PCIe pwrseq driver (this one) - Control resources of the PCIe devices
3. PCIe controller driver - Control resources of PCIe controller and Link
And all of them has different responsibilities, so I do not see an issue with that. But what is really important is that all 3 has to work in sync and that's quite involved. That's why I thought of dealing with that later.
Moreover, even if driver (2) doesn't do any PM operations now, it won't break anything on the currently supported platforms (Qcom). It will be a problem once people start adding pwrseq drivers for platforms whose controller drivers are already handling the job which is now offloaded by this driver.
- Mani
Quoted 2 lines
Rob
Signature · 1 line
மணிவண்ணன் சதாசிவம்
Re: [PATCH 9/9] PCI/pwrseq: add a pwrseq driver for QCA6390
In reply to Bartosz GolaszewskiQuoted 10 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
Add a PCI power sequencing driver that's capable of correctly powering up the ath11k module on QCA6390 and WCN7850 using the PCI pwrseq functionality.
Signed-off-by Bartosz Golaszewski <[email protected]>[Neil: add support for WCN7850]Signed-off-by Neil Armstrong <[email protected]>---
[...]
drivers/pci/pwrseq/pci-pwrseq-qca6390.c line 84
Quoted 4 lines
drivers/pci/pwrseq/pci-pwrseq-qca6390.c new file +4
-0+static struct pci_pwrseq_qca6390_vreg pci_pwrseq_wcn7850_vregs[] = { + { + .name ="vdd" , + },
Weird there's no .load here.. On Qualcomm they're used for asking the regluators to enter the high power mode, so it'd be useful.
Konrad
Quoted 29 lines · Dmitry Baryshkov
Quoted 24 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
The responses to the RFC were rather positive so here's a proper series.
During last year's Linux Plumbers we had several discussions centered around the need to power-on PCI devices before they can be detected on the bus.
The consensus during the conference was that we need to introduce a class of "PCI slot drivers" that would handle the power-sequencing.
After some additional brain-storming with Manivannan and the realization that DT maintainers won't like adding any "fake" nodes not representing actual devices, we decided to reuse existing PCI infrastructure.
The general idea is to instantiate platform devices for child nodes of the PCIe port DT node. For those nodes for which a power-sequencing driver exists, we bind it and let it probe. The driver then triggers a rescan of the PCI bus with the aim of detecting the now powered-on device. The device will consume the same DT node as the platform, power-sequencing device. We use device links to make the latter become the parent of the former.
Quoted 2 lines
The main advantage of this approach is not modifying the existing DT in any way and especially not adding any "fake" platform devices.
Quoted 7 lines
I'd still like to see how this can be extended to handle BT power up, having a single entity driving both of the BT and WiFI.
The device tree changes behave in exactly the opposite way: they define regulators for the WiFi device, while the WiFi is not being powered by these regulators. Both WiFi and BT are powered by the PMU, which in turn consumes all specified regulators.
Some additional justification, why I think that this should be modelled as a single instance instead of two different items.
This is from msm-5.10 kernel:
===== CUT HERE =====
/**
* cnss_select_pinctrl_enable - select WLAN_GPIO for Active pinctrl status
* @plat_priv: Platform private data structure pointer
*
* For QCA6490, PMU requires minimum 100ms delay between BT_EN_GPIO off and
* WLAN_EN_GPIO on. This is done to avoid power up issues.
*
* Return: Status of pinctrl select operation. 0 - Success.
*/
static int cnss_select_pinctrl_enable(struct cnss_plat_data *plat_priv) ===== CUT HERE =====
Also see the bt_configure_gpios() function in the same kernel.
Quoted 58 lines
Quoted 49 lines
Changes since RFC:
- move the pwrseq functionality out of the port driver and into PCI core
- add support for WCN7850 to the first pwrseq driver (and update bindings)
- describe the WLAN modules in sm8550-qrd and sm8650-qrd
- reworkKconfigoptions, drop the defconfig changes from the series as they are no longer needed
- drop the dt-binding changes for PCI vendor codes
- extend the DT bindings forath11k_pciwith strict property checking
- various minor tweaks and fixesBartosz Golaszewski (7):
arm64: dts: qcom: qrb5165-rb5: describe the WLAN module of QCA6390
PCI: create platform devices for child OF nodes of the port node
PCI: hold the rescan mutex when scanning for the first time PCI/pwrseq: add pwrseq core code
dt-bindings: wireless: ath11k: describe QCA6390
dt-bindings: wireless: ath11k: describe WCN7850 PCI/pwrseq: add a pwrseq driver for QCA6390Neil Armstrong (2):
arm64: dts: qcom: sm8550-qrd: add Wifi nodes
arm64: dts: qcom: sm8650-qrd: add Wifi nodes.../net/wireless/qcom,ath11k-pci.yaml | 89 ++++++ arch/arm64/boot/dts/qcom/qrb5165-rb5.dts | 29 ++ arch/arm64/boot/dts/qcom/sm8250.dtsi | 10 + arch/arm64/boot/dts/qcom/sm8550-qrd.dts | 37 +++ arch/arm64/boot/dts/qcom/sm8550.dtsi | 10 + arch/arm64/boot/dts/qcom/sm8650-qrd.dts | 29 ++ arch/arm64/boot/dts/qcom/sm8650.dtsi | 10 + drivers/pci/Kconfig | 1 + drivers/pci/Makefile | 1 + drivers/pci/bus.c | 9 +- drivers/pci/probe.c | 2 + drivers/pci/pwrseq/Kconfig | 16 ++ drivers/pci/pwrseq/Makefile | 4 + drivers/pci/pwrseq/pci-pwrseq-qca6390.c | 267 ++++++++++++++++++ drivers/pci/pwrseq/pwrseq.c | 82 ++++++ drivers/pci/remove.c | 3 +- include/linux/pci-pwrseq.h | 24 ++ 17 files changed, 621 insertions(+), 2 deletions(-) create mode 100644 drivers/pci/pwrseq/Kconfig create mode 100644 drivers/pci/pwrseq/Makefile create mode 100644 drivers/pci/pwrseq/pci-pwrseq-qca6390.c create mode 100644 drivers/pci/pwrseq/pwrseq.c create mode 100644 include/linux/pci-pwrseq.hQuoted 4 lines
--
2.40.1--
With best wishes
Dmitry
Signature · 2 lines
With best wishes Dmitry
Quoted 1 line · Dmitry Baryshkov
[snip]
Quoted 29 lines
Quoted 8 lines
I'd still like to see how this can be extended to handle BT power up, having a single entity driving both of the BT and WiFI.
The device tree changes behave in exactly the opposite way: they define regulators for the WiFi device, while the WiFi is not being powered by these regulators. Both WiFi and BT are powered by the PMU, which in turn consumes all specified regulators.
Some additional justification, why I think that this should be modelled as a single instance instead of two different items.
This is from msm-5.10 kernel:
===== CUT HERE =====
/**
*cnss_select_pinctrl_enable- selectWLAN_GPIOfor Active pinctrl status
* @plat_priv: Platform private data structure pointer
*
* For QCA6490, PMU requires minimum 100ms delay betweenBT_EN_GPIOoff and
*WLAN_EN_GPIOon. This is done to avoid power up issues.
*
* Return: Status of pinctrl select operation. 0 - Success.
*/
static intcnss_select_pinctrl_enable(struct cnss_plat_data *plat_priv)===== CUT HERE =====
Quoted 2 lines
Also see the
bt_configure_gpios()function in the same kernel.
You are talking about a different problem. Unfortunately we're using similar naming here but I don't have a better alternative in mind.
We have two separate issues: one is powering-up a PCI device so that it can be detected and the second is dealing with a device that has multiple modules in it which share a power sequence. The two are independent and this series isn't trying to solve the latter.
But I am aware of this and so I actually have an idea for a generalized power sequencing framework. Let's call it pwrseq as opposed to pci_pwrseq.
Krzysztof is telling me that there cannot be any power sequencing information contained in DT. Also: modelling the PMU in DT would just over complicate stuff for now reason. We'd end up having the PMU node consuming the regulators but it too would need to expose regulators for WLAN and BT or be otherwise referenced by their nodes.
So I'm thinking that the DT representation should remain as it is:
with separate WLAN and BT nodes consuming resources relevant to their functionality (BT does not need to enable PCIe regulators). Now how to handle the QCA6490 model you brought up? How about pwrseq drivers that would handle the sequence based on compatibles?
We'd add a new subsystem at drivers/pwrseq/. Inside there would be:drivers/pwrseq/pwrseq-qca6490.c. The pwrseq framework would expose an API to "sub-drivers" (in this case: BT serdev driver and the qca6490 power sequencing driver). Now the latter goes:
struct pwrseq_desc *pwrseq = pwrseq_get(dev);
And the pwrseq subsystem matches the device's compatible against the correct, *shared* sequence. The BT driver can do the same at any time. The pwrseq driver then gets regulators, GPIOs, clocks etc. and will be responsible for dealing with them.
In sub-drivers we now do:
ret = pwrseq_power_on(pwrseq);
or
ret = pwrseq_power_off(pwrseq);
in the sub-device drivers and no longer interact with each regulator on our own. The pwrseq subsystem is now in charge of adding delays etc.
That's only an idea and I haven't done any real work yet but I'm throwing it out there for discussion.
Bartosz
[snip]
Quoted 39 lines · Bartosz Golaszewski
Quoted 1 line · Dmitry Baryshkov
[snip]
Quoted 29 lines
Quoted 8 lines
I'd still like to see how this can be extended to handle BT power up, having a single entity driving both of the BT and WiFI.
The device tree changes behave in exactly the opposite way: they define regulators for the WiFi device, while the WiFi is not being powered by these regulators. Both WiFi and BT are powered by the PMU, which in turn consumes all specified regulators.
Some additional justification, why I think that this should be modelled as a single instance instead of two different items.
This is from msm-5.10 kernel:
===== CUT HERE =====
/**
*cnss_select_pinctrl_enable- selectWLAN_GPIOfor Active pinctrl status
* @plat_priv: Platform private data structure pointer
*
* For QCA6490, PMU requires minimum 100ms delay betweenBT_EN_GPIOoff and
*WLAN_EN_GPIOon. This is done to avoid power up issues.
*
* Return: Status of pinctrl select operation. 0 - Success.
*/
static intcnss_select_pinctrl_enable(struct cnss_plat_data *plat_priv)===== CUT HERE =====Quoted 2 lines
Also see the
bt_configure_gpios()function in the same kernel.
Quoted 7 lines
You are talking about a different problem. Unfortunately we're using similar naming here but I don't have a better alternative in mind.
We have two separate issues: one is powering-up a PCI device so that it can be detected and the second is dealing with a device that has multiple modules in it which share a power sequence. The two are independent and this series isn't trying to solve the latter.
I see it from a different angle: a power up of the WiFi+BT chips. This includes devices like wcn3990 (which have platform + serial parts) and qca6390 / qca6490 / wcn6750 / etc. (which have PCI and serial parts).
From my point of view, the PCIe-only part was nice for an RFC, but for v1 I have expected to see a final solution that we can reuse for wcn3990.
Quoted 10 lines
But I am aware of this and so I actually have an idea for a generalized power sequencing framework. Let's call it pwrseq as opposed to
pci_pwrseq.Krzysztof is telling me that there cannot be any power sequencing information contained in DT. Also: modelling the PMU in DT would just over complicate stuff for now reason. We'd end up having the PMU node consuming the regulators but it too would need to expose regulators for WLAN and BT or be otherwise referenced by their nodes.
Yes. And it is a correct representation of the device. The WiFi and BT parts are powered up by the outputs from PMU. We happen to have three different pieces (WiFi, BT and PMU) squashed on a single physical device.
Quoted 4 lines
So I'm thinking that the DT representation should remain as it is:
with separate WLAN and BT nodes consuming resources relevant to their functionality (BT does not need to enable PCIe regulators).
Is it so? The QCA6390 docs clearly say that all regulators should be enabled before asserting BT_EN / WLAN_EN. See the powerup timing diagram and the t2 note to that diagram.
Quoted 3 lines
Now how to
handle the QCA6490 model you brought up? How about pwrseq drivers that would handle the sequence based on compatibles?
The QCA6490 is also known as WCN6855. So this problem applies to Qualcomm sm8350 / sm8450 platforms.
And strictly speaking I don't see any significant difference between QCA6390 and WCN6855. The regulators might be different, but the implementation should be the same.
Quoted 19 lines
We'd add a new subsystem at
drivers/pwrseq/. Inside there would be:drivers/pwrseq/pwrseq-qca6490.c. The pwrseq framework would expose an API to "sub-drivers" (in this case: BT serdev driver and the qca6490 power sequencing driver). Now the latter goes:struct
pwrseq_desc*pwrseq =pwrseq_get(dev);And the pwrseq subsystem matches the device's compatible against the correct, *shared* sequence. The BT driver can do the same at any time. The pwrseq driver then gets regulators, GPIOs, clocks etc. and will be responsible for dealing with them.
In sub-drivers we now do:
ret =
pwrseq_power_on(pwrseq);or
Quoted 8 lines
ret =
pwrseq_power_off(pwrseq);in the sub-device drivers and no longer interact with each regulator on our own. The pwrseq subsystem is now in charge of adding delays etc.
That's only an idea and I haven't done any real work yet but I'm throwing it out there for discussion.
I've been there and I had implemented it in the same way, but rather having the pwrseq as a primary device in DT and parsing end-devices only as a fallback / compatibility case.
Signature · 2 lines
With best wishes Dmitry
Quoted 48 lines · Dmitry Baryshkov
Quoted 39 lines · Bartosz Golaszewski
Quoted 1 line · Dmitry Baryshkov
[snip]
Quoted 29 lines
Quoted 8 lines
I'd still like to see how this can be extended to handle BT power up, having a single entity driving both of the BT and WiFI.
The device tree changes behave in exactly the opposite way: they define regulators for the WiFi device, while the WiFi is not being powered by these regulators. Both WiFi and BT are powered by the PMU, which in turn consumes all specified regulators.
Some additional justification, why I think that this should be modelled as a single instance instead of two different items.
This is from msm-5.10 kernel:
===== CUT HERE =====
/**
*cnss_select_pinctrl_enable- selectWLAN_GPIOfor Active pinctrl status
* @plat_priv: Platform private data structure pointer
*
* For QCA6490, PMU requires minimum 100ms delay betweenBT_EN_GPIOoff and
*WLAN_EN_GPIOon. This is done to avoid power up issues.
*
* Return: Status of pinctrl select operation. 0 - Success.
*/
static intcnss_select_pinctrl_enable(struct cnss_plat_data *plat_priv)===== CUT HERE =====Quoted 2 lines
Also see the
bt_configure_gpios()function in the same kernel.Quoted 7 lines
You are talking about a different problem. Unfortunately we're using similar naming here but I don't have a better alternative in mind.
We have two separate issues: one is powering-up a PCI device so that it can be detected and the second is dealing with a device that has multiple modules in it which share a power sequence. The two are independent and this series isn't trying to solve the latter.
Quoted 8 lines
I see it from a different angle: a power up of the WiFi+BT chips. This includes devices like wcn3990 (which have platform + serial parts) and qca6390 / qca6490 / wcn6750 / etc. (which have PCI and serial parts).
From my point of view, the PCIe-only part was nice for an RFC, but for v1 I have expected to see a final solution that we can reuse for wcn3990.
The submodules are represented as independent devices on the DT and I don't think this will change. It's not even possible as they operate on different buses so it's not like we can MFD it with a top-level platform device and two sub-nodes of which one is PCI and another serdev. With that in mind, I'm insisting that there are two separate issues and a generic power sequencing can be built on top of the PCI-specific pwrseq added here.
Quoted 11 lines
Quoted 10 lines
But I am aware of this and so I actually have an idea for a generalized power sequencing framework. Let's call it pwrseq as opposed to
pci_pwrseq.Krzysztof is telling me that there cannot be any power sequencing information contained in DT. Also: modelling the PMU in DT would just over complicate stuff for now reason. We'd end up having the PMU node consuming the regulators but it too would need to expose regulators for WLAN and BT or be otherwise referenced by their nodes.
Quoted 5 lines
Yes. And it is a correct representation of the device. The WiFi and BT parts are powered up by the outputs from PMU. We happen to have three different pieces (WiFi, BT and PMU) squashed on a single physical device.
Alright, so let's imagine we do model the PMU on the device tree. It would look something like this:
qca6390_pmu: pmic@0 {
compatible = "qcom,qca6390-pmu";
bt-gpios = <...>;
wlan-gpios = <...>;
vdd-supply = <&vreg...>;
...
regulators-0 {
vreg_x: foo {
...
};
...
};
};Then the WLAN and BT consume the regulators from &qca6390_pmu. Obviously we cannot go:
wlan {
pwrseq = &qca6390_pmu;
};But it's enough to:
wlan {
vdd-supply = <&vreg_x>;
};But the pwrseq driver for "qcom,qca6390-pmu" could map BT and WLAN compatibles to the correct power sequence and then the relevant drivers could enable it using pwrseq_power_on().
But that comes back to what I'm doing here: the PCI part for ath11k still needs the platform driver that will trigger the power sequence and that could be the PCI pwrseq driver for which the framework is introduced in this series.
As I said: the two are largely orthogonal.
Quoted 9 lines
Quoted 4 lines
So I'm thinking that the DT representation should remain as it is:
with separate WLAN and BT nodes consuming resources relevant to their functionality (BT does not need to enable PCIe regulators).Is it so? The QCA6390 docs clearly say that all regulators should be enabled before asserting
BT_EN/WLAN_EN. See the powerup timing diagram and the t2 note to that diagram.
Fair enough.
Quoted 36 lines
Quoted 3 lines
Now how to
handle the QCA6490 model you brought up? How about pwrseq drivers that would handle the sequence based on compatibles?The QCA6490 is also known as WCN6855. So this problem applies to Qualcomm sm8350 / sm8450 platforms.
And strictly speaking I don't see any significant difference between QCA6390 and WCN6855. The regulators might be different, but the implementation should be the same.
Quoted 25 lines
We'd add a new subsystem at
drivers/pwrseq/. Inside there would be:drivers/pwrseq/pwrseq-qca6490.c. The pwrseq framework would expose an API to "sub-drivers" (in this case: BT serdev driver and the qca6490 power sequencing driver). Now the latter goes:struct
pwrseq_desc*pwrseq =pwrseq_get(dev);And the pwrseq subsystem matches the device's compatible against the correct, *shared* sequence. The BT driver can do the same at any time. The pwrseq driver then gets regulators, GPIOs, clocks etc. and will be responsible for dealing with them.
In sub-drivers we now do:
ret =
pwrseq_power_on(pwrseq);or
ret =
pwrseq_power_off(pwrseq);in the sub-device drivers and no longer interact with each regulator on our own. The pwrseq subsystem is now in charge of adding delays etc.
Quoted 7 lines
Quoted 2 lines
That's only an idea and I haven't done any real work yet but I'm throwing it out there for discussion.
I've been there and I had implemented it in the same way, but rather having the pwrseq as a primary device in DT and parsing end-devices only as a fallback / compatibility case.
Would you mind posting an example DT code here? I'm not sure if I understand what "primary device" means in this context.
Bartosz
Quoted 6 lines
--
With best wishes
Dmitry
Quoted 112 lines · On Fri, 19 Jan 2024 at 15:35, <[email protected]> wrote:
Quoted 48 lines · Dmitry Baryshkov
Quoted 39 lines · Bartosz Golaszewski
Quoted 1 line · Dmitry Baryshkov
[snip]
Quoted 29 lines
Quoted 8 lines
I'd still like to see how this can be extended to handle BT power up, having a single entity driving both of the BT and WiFI.
The device tree changes behave in exactly the opposite way: they define regulators for the WiFi device, while the WiFi is not being powered by these regulators. Both WiFi and BT are powered by the PMU, which in turn consumes all specified regulators.
Some additional justification, why I think that this should be modelled as a single instance instead of two different items.
This is from msm-5.10 kernel:
===== CUT HERE =====
/**
*cnss_select_pinctrl_enable- selectWLAN_GPIOfor Active pinctrl status
* @plat_priv: Platform private data structure pointer
*
* For QCA6490, PMU requires minimum 100ms delay betweenBT_EN_GPIOoff and
*WLAN_EN_GPIOon. This is done to avoid power up issues.
*
* Return: Status of pinctrl select operation. 0 - Success.
*/
static intcnss_select_pinctrl_enable(struct cnss_plat_data *plat_priv)===== CUT HERE =====Quoted 2 lines
Also see the
bt_configure_gpios()function in the same kernel.Quoted 7 lines
You are talking about a different problem. Unfortunately we're using similar naming here but I don't have a better alternative in mind.
We have two separate issues: one is powering-up a PCI device so that it can be detected and the second is dealing with a device that has multiple modules in it which share a power sequence. The two are independent and this series isn't trying to solve the latter.
Quoted 8 lines
I see it from a different angle: a power up of the WiFi+BT chips. This includes devices like wcn3990 (which have platform + serial parts) and qca6390 / qca6490 / wcn6750 / etc. (which have PCI and serial parts).
From my point of view, the PCIe-only part was nice for an RFC, but for v1 I have expected to see a final solution that we can reuse for wcn3990.
The submodules are represented as independent devices on the DT and I don't think this will change. It's not even possible as they operate on different buses so it's not like we can MFD it with a top-level platform device and two sub-nodes of which one is PCI and another serdev. With that in mind, I'm insisting that there are two separate issues and a generic power sequencing can be built on top of the PCI-specific pwrseq added here.
Quoted 11 lines
Quoted 10 lines
But I am aware of this and so I actually have an idea for a generalized power sequencing framework. Let's call it pwrseq as opposed to
pci_pwrseq.Krzysztof is telling me that there cannot be any power sequencing information contained in DT. Also: modelling the PMU in DT would just over complicate stuff for now reason. We'd end up having the PMU node consuming the regulators but it too would need to expose regulators for WLAN and BT or be otherwise referenced by their nodes.
Quoted 5 lines
Yes. And it is a correct representation of the device. The WiFi and BT parts are powered up by the outputs from PMU. We happen to have three different pieces (WiFi, BT and PMU) squashed on a single physical device.
Alright, so let's imagine we do model the PMU on the device tree. It would look something like this:
qca6390_pmu: pmic@0 { compatible = "qcom,qca6390-pmu"; bt-gpios = <...>; wlan-gpios = <...>; vdd-supply = <&vreg...>; ... regulators-0 { vreg_x: foo { ... }; ... }; };Then the WLAN and BT consume the regulators from
&qca6390_pmu. Obviously we cannot go:wlan { pwrseq = &qca6390_pmu; };
Quoted 5 lines
But it's enough to:
wlan { vdd-supply = <&vreg_x>; };
I'm not sure this will fly. This means expecting that regulator framework is reentrant, which I think is not the case.
Quoted 9 lines
But the pwrseq driver for "qcom,qca6390-pmu" could map BT and WLAN compatibles to the correct power sequence and then the relevant drivers could enable it using
pwrseq_power_on().But that comes back to what I'm doing here: the PCI part for ath11k still needs the platform driver that will trigger the power sequence and that could be the PCI pwrseq driver for which the framework is introduced in this series.
As I said: the two are largely orthogonal.
I'm fine with that as long as it stays as an RFC. We need to fix both issues before committing qca6390 power up support.
Quoted 52 lines
Quoted 10 lines
Quoted 5 lines
So I'm thinking that the DT representation should remain as it is:
with separate WLAN and BT nodes consuming resources relevant to their functionality (BT does not need to enable PCIe regulators).Is it so? The QCA6390 docs clearly say that all regulators should be enabled before asserting
BT_EN/WLAN_EN. See the powerup timing diagram and the t2 note to that diagram.Fair enough.
Quoted 39 lines
Quoted 3 lines
Now how to
handle the QCA6490 model you brought up? How about pwrseq drivers that would handle the sequence based on compatibles?The QCA6490 is also known as WCN6855. So this problem applies to Qualcomm sm8350 / sm8450 platforms.
And strictly speaking I don't see any significant difference between QCA6390 and WCN6855. The regulators might be different, but the implementation should be the same.
Quoted 27 lines
We'd add a new subsystem at
drivers/pwrseq/. Inside there would be:drivers/pwrseq/pwrseq-qca6490.c. The pwrseq framework would expose an API to "sub-drivers" (in this case: BT serdev driver and the qca6490 power sequencing driver). Now the latter goes:struct
pwrseq_desc*pwrseq =pwrseq_get(dev);And the pwrseq subsystem matches the device's compatible against the correct, *shared* sequence. The BT driver can do the same at any time. The pwrseq driver then gets regulators, GPIOs, clocks etc. and will be responsible for dealing with them.
In sub-drivers we now do:
ret =
pwrseq_power_on(pwrseq);or
ret =
pwrseq_power_off(pwrseq);in the sub-device drivers and no longer interact with each regulator on our own. The pwrseq subsystem is now in charge of adding delays etc.
That's only an idea and I haven't done any real work yet but I'm throwing it out there for discussion.
Quoted 7 lines
Quoted 4 lines
I've been there and I had implemented it in the same way, but rather having the pwrseq as a primary device in DT and parsing end-devices only as a fallback / compatibility case.
Would you mind posting an example DT code here? I'm not sure if I understand what "primary device" means in this context.
qca_pwrseq: qca-pwrseq {
compatible = "qcom,qca6390-pwrseq";
#pwrseq-cells = <1>; vddaon-supply = <&vreg_s6a_0p95>; vddpmu-supply = <&vreg_s2f_0p95>; vddrfa1-supply = <&vreg_s2f_0p95>; vddrfa2-supply = <&vreg_s8c_1p3>; vddrfa3-supply = <&vreg_s5a_1p9>; vddpcie1-supply = <&vreg_s8c_1p3>; vddpcie2-supply = <&vreg_s5a_1p9>; vddio-supply = <&vreg_s4a_1p8>;
bt-enable-gpios = <&tlmm 21 GPIO_ACTIVE_HIGH>; wifi-enable-gpios = <&tlmm 20 GPIO_ACTIVE_HIGH>; swctrl-gpios = <&tlmm 124 GPIO_ACTIVE_HIGH>;
};
&uart6 {
status = "okay";
bluetooth {
compatible = "qcom,qca6390-bt";
clocks = <&sleep_clk>;
bt-pwrseq = <&qca_pwrseq 1>;
};
};
See https://lore.kernel.org/linux-arm-msm/[email protected]/
Signature · 2 lines
With best wishes Dmitry
Quoted 1 line · Dmitry Baryshkov
[snip]
Quoted 30 lines
Quoted 30 lines
Quoted 1 line
Alright, so let's imagine we do model the PMU on the device tree. It would look something like this:
qca6390_pmu: pmic@0 { compatible = "qcom,qca6390-pmu"; bt-gpios = <...>; wlan-gpios = <...>; vdd-supply = <&vreg...>; ... regulators-0 { vreg_x: foo { ... }; ... }; };Then the WLAN and BT consume the regulators from
&qca6390_pmu. Obviously we cannot go:wlan { pwrseq = &qca6390_pmu; };
Quoted 9 lines
Quoted 5 lines
But it's enough to:
wlan { vdd-supply = <&vreg_x>; };I'm not sure this will fly. This means expecting that regulator framework is reentrant, which I think is not the case.
Oh maybe I didn't make myself clear. That's the DT representation of HW. With pwrseq, the BT or ATH11K drivers wouldn't use the regulator framework. They would use the pwrseq framework and it could use the phandle of the regulator to get into the correct pwrseq device without making Rob and Krzysztof angry.
Bart
[snip]
Quoted 53 lines · Bartosz Golaszewski
Quoted 1 line · Dmitry Baryshkov
[snip]
Quoted 30 lines
Quoted 30 lines
Quoted 1 line
Alright, so let's imagine we do model the PMU on the device tree. It would look something like this:
qca6390_pmu: pmic@0 { compatible = "qcom,qca6390-pmu"; bt-gpios = <...>; wlan-gpios = <...>; vdd-supply = <&vreg...>; ... regulators-0 { vreg_x: foo { ... }; ... }; };Then the WLAN and BT consume the regulators from
&qca6390_pmu. Obviously we cannot go:wlan { pwrseq = &qca6390_pmu; };Quoted 9 lines
Quoted 5 lines
But it's enough to:
wlan { vdd-supply = <&vreg_x>; };I'm not sure this will fly. This means expecting that regulator framework is reentrant, which I think is not the case.
Oh maybe I didn't make myself clear. That's the DT representation of HW. With pwrseq, the BT or ATH11K drivers wouldn't use the regulator framework. They would use the pwrseq framework and it could use the phandle of the regulator to get into the correct pwrseq device without making Rob and Krzysztof angry.
Quoted 3 lines
Bart
[snip]
I'm working on a PoC of the generic pwrseq framework but without the explicit pwrseq modelling in DT. Should have an RFC ready early next week.
Bart
Quoted 2 lines · Bartosz Golaszewski
We have two separate issues: one is powering-up a PCI device so that it can be detected
Just wondering, I note in really_probe() we configure the pin controller, active the pm_domain etc before probing a driver.
Would it make sense for the issue you mention above to similarly amend pci_scan_device() to enable whatever clocks or regulators are described in the devicetree as providers for the given PCI device?
Thanks,
Lukas
Quoted 11 lines · Lukas Wunner
Quoted 2 lines · Bartosz Golaszewski
We have two separate issues: one is powering-up a PCI device so that it can be detected
Just wondering, I note in
really_probe()we configure the pin controller, active thepm_domainetc before probing a driver.Would it make sense for the issue you mention above to similarly amend
pci_scan_device()to enable whatever clocks or regulators are described in the devicetree as providers for the given PCI device?
If you mean via a callback to some device specific code, then yes, I think that's exactly what should be done here. That's roughly what MDIO does. If firmware says there is a device present, then probe it anyways even if not detected. I don't think that will work for PCI because it accesses a lot of registers before probe. We'd need some sort of pre-probe hook instead called after reading vendor and device ID, but before anything else.
If you mean PCI core just enable whatever clocks and regulators (and GPIOs), then no, because what is the correct order and timing for each of those? You don't know because that is device specific information just as how to program a device is.
Rob
Bjorn Andersson
maintainerRe: Re: [PATCH 4/9] PCI: create platform devices for child OF nodes of the port node
In reply to Greg Kroah-HartmanQuoted 17 lines · Greg Kroah-Hartman
Quoted 16 lines · Bartosz Golaszewski
Quoted 11 lines · Greg Kroah-Hartman
Quoted 4 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
In order to introduce PCI power-sequencing, we need to create platform devices for child nodes of the port node.
Ick, why a platform device? What is the parent of this device, a PCI device? If so, then this can't be a platform device, as that's not what it is, it's something else so make it a device of that type,.
Greg,
Quoted 9 lines
Quoted 5 lines
This is literally what we agreed on at LPC. In fact: during one of the hall track discussions I said that you typically NAK any attempts at using the platform bus for "fake" devices but you responded that this is what the USB on-board HUB does and while it's not pretty, this is what we need to do.
Ah, you need to remind me of these things, this changelog was pretty sparse :)
I believe I missed this part of the discussion, why does this need to be a platform_device? What does the platform_bus bring that can't be provided by some other bus?
(I'm not questioning the need for having a bus, creating devices, and matching/binding them to a set of drivers)
Regards,
Bjorn
Quoted 20 lines
Quoted 13 lines
Now as for the implementation, the way I see it we have two solutions:
either we introduce a fake, top-level PCI slot platform device device that will reference the PCI host controller by phandle or we will live with a secondary, "virtual" platform device for power sequencing that is tied to the actual PCI device. The former requires us to add DT bindings, add a totally fake DT node representing the "slot" which doesn't really exist (and Krzysztof already expressed his negative opinion of that) and then have code that will be more complex than it needs to be. The latter allows us to not change DT at all (other than adding regulators, clocks and GPIOs to already existing WLAN nodes), reuse the existing parent-child relationship between the port node and the instantiated platform device as well as result in simpler code.Quoted 3 lines
Given that DT needs to be stable while the underlying C code can freely change if we find a better solution, I think that the second option is a no-brainer here.
Ok, I remove my objections, sorry about that, my confusion.
greg k-h
Re: Re: [PATCH 4/9] PCI: create platform devices for child OF nodes of the port node
Quoted 25 lines · Bjorn Andersson
Quoted 23 lines · Greg Kroah-Hartman
Quoted 21 lines · Bartosz Golaszewski
Quoted 11 lines · Greg Kroah-Hartman
Quoted 4 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
In order to introduce PCI power-sequencing, we need to create platform devices for child nodes of the port node.
Ick, why a platform device? What is the parent of this device, a PCI device? If so, then this can't be a platform device, as that's not what it is, it's something else so make it a device of that type,.
Greg,
This is literally what we agreed on at LPC. In fact: during one of the hall track discussions I said that you typically NAK any attempts at using the platform bus for "fake" devices but you responded that this is what the USB on-board HUB does and while it's not pretty, this is what we need to do.
Quoted 8 lines
Quoted 3 lines
Ah, you need to remind me of these things, this changelog was pretty sparse :)
I believe I missed this part of the discussion, why does this need to be a
platform_device? What does theplatform_busbring that can't be provided by some other bus?
Does it need to be a platform_device? No, of course not. Does it make sense for it to be one? Yes, for two reasons:
1. The ATH11K WLAN module is represented on the device tree like a platform device, we know it's always there and it consumes regulators from another platform device. The fact it uses PCIe doesn't change the fact that it is logically a platform device.
2. The platform bus already provides us with the entire infrastructure that we'd now need to duplicate (possibly adding bugs) in order to introduce a "power sequencing bus".
Bart
Quoted 6 lines
(I'm not questioning the need for having a bus, creating devices, and matching/binding them to a set of drivers)
Regards,
Bjorn
[snip]
Bjorn Andersson
maintainerRe: Re: Re: [PATCH 4/9] PCI: create platform devices for child OF nodes of the port node
Quoted 35 lines · Bartosz Golaszewski
Quoted 25 lines · Bjorn Andersson
Quoted 23 lines · Greg Kroah-Hartman
Quoted 21 lines · Bartosz Golaszewski
Quoted 11 lines · Greg Kroah-Hartman
Quoted 4 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
In order to introduce PCI power-sequencing, we need to create platform devices for child nodes of the port node.
Ick, why a platform device? What is the parent of this device, a PCI device? If so, then this can't be a platform device, as that's not what it is, it's something else so make it a device of that type,.
Greg,
This is literally what we agreed on at LPC. In fact: during one of the hall track discussions I said that you typically NAK any attempts at using the platform bus for "fake" devices but you responded that this is what the USB on-board HUB does and while it's not pretty, this is what we need to do.
Quoted 8 lines
Quoted 3 lines
Ah, you need to remind me of these things, this changelog was pretty sparse :)
I believe I missed this part of the discussion, why does this need to be a
platform_device? What does theplatform_busbring that can't be provided by some other bus?
Quoted 7 lines
Does it need to be a
platform_device? No, of course not. Does it make sense for it to be one? Yes, for two reasons:1. The ATH11K WLAN module is represented on the device tree like a platform device, we know it's always there and it consumes regulators from another platform device. The fact it uses PCIe doesn't change the fact that it is logically a platform device.
Are you referring to the ath11k SNOC (firmware running on co-processor in the SoC) variant?
Afaict the PCIe-attached ath11k is not represented as a platform_device in DeviceTree.
Said platform_device is also not a child under the PCIe bus, so this would be a different platform_device...
Quoted 4 lines
2. The platform bus already provides us with the entire infrastructure that we'd now need to duplicate (possibly adding bugs) in order to introduce a "power sequencing bus".
This is a perfectly reasonable desire. Look at our PMICs, they are full of platform_devices. But through the years it's been said many times, that this is not a valid or good reason for using platform_devices, and as a result we have e.g. auxiliary bus.
Anyway, (please) don't claim that "we need to", when it actually is "we want to use platform_device because that's more convenient"!
Regards,
Bjorn
Quoted 10 lines
Bart
Quoted 6 lines
(I'm not questioning the need for having a bus, creating devices, and matching/binding them to a set of drivers)
Regards,
Bjorn[snip]
Re: [PATCH 4/9] PCI: create platform devices for child OF nodes of the port node
Quoted 44 lines · Bjorn Andersson
Quoted 35 lines · Bartosz Golaszewski
Quoted 25 lines · Bjorn Andersson
Quoted 23 lines · Greg Kroah-Hartman
Quoted 21 lines · Bartosz Golaszewski
Quoted 11 lines · Greg Kroah-Hartman
Quoted 4 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
In order to introduce PCI power-sequencing, we need to create platform devices for child nodes of the port node.
Ick, why a platform device? What is the parent of this device, a PCI device? If so, then this can't be a platform device, as that's not what it is, it's something else so make it a device of that type,.
Greg,
This is literally what we agreed on at LPC. In fact: during one of the hall track discussions I said that you typically NAK any attempts at using the platform bus for "fake" devices but you responded that this is what the USB on-board HUB does and while it's not pretty, this is what we need to do.
Quoted 8 lines
Quoted 3 lines
Ah, you need to remind me of these things, this changelog was pretty sparse :)
I believe I missed this part of the discussion, why does this need to be a
platform_device? What does theplatform_busbring that can't be provided by some other bus?Quoted 7 lines
Does it need to be a
platform_device? No, of course not. Does it make sense for it to be one? Yes, for two reasons:1. The ATH11K WLAN module is represented on the device tree like a platform device, we know it's always there and it consumes regulators from another platform device. The fact it uses PCIe doesn't change the fact that it is logically a platform device.
Quoted 5 lines
Are you referring to the ath11k SNOC (firmware running on co-processor in the SoC) variant?
Afaict the PCIe-attached ath11k is not represented as a
platform_devicein DeviceTree.
Are you considering out-of-tree drivers? My understanding is that there are different PCIe modules, ones that don't have GPIO-control for x86 and ones that do have GPIO-control for ARM. The out-of-tree cnss platform driver used for Android has a large amount of DT control
<https://git.codelinaro.org/clo/la/platform/vendor/qcom-opensource/wlan/platform/-/blob/wlan-platform.lnx.1.0.r1-rel/cnss2/power.c?ref_type=heads>
(not sure off hand where the DT files themselves are)
/jeff
Re: Re: Re: [PATCH 4/9] PCI: create platform devices for child OF nodes of the port node
In reply to Bjorn AnderssonQuoted 1 line · Bjorn Andersson
[snip]
Quoted 14 lines
Quoted 6 lines
Quoted 5 lines
I believe I missed this part of the discussion, why does this need to be a
platform_device? What does theplatform_busbring that can't be provided by some other bus?Quoted 7 lines
Does it need to be a
platform_device? No, of course not. Does it make sense for it to be one? Yes, for two reasons:1. The ATH11K WLAN module is represented on the device tree like a platform device, we know it's always there and it consumes regulators from another platform device. The fact it uses PCIe doesn't change the fact that it is logically a platform device.
Quoted 6 lines
Are you referring to the ath11k SNOC (firmware running on co-processor in the SoC) variant?
Afaict the PCIe-attached ath11k is not represented as a
platform_devicein DeviceTree.
My bad. In RB5 it isn't (yet - I want to add it in the power sequencing series). It is in X13s though[1].
Quoted 3 lines
Said
platform_deviceis also not a child under the PCIe bus, so this would be a differentplatform_device...
It's the child of the PCIe port node but there's a reason for it to have the compatible property. It's because it's an entity of whose existence we are aware before the system boots.
Quoted 10 lines
Quoted 4 lines
2. The platform bus already provides us with the entire infrastructure that we'd now need to duplicate (possibly adding bugs) in order to introduce a "power sequencing bus".
This is a perfectly reasonable desire. Look at our PMICs, they are full of
platform_devices. But through the years it's been said many times, that this is not a valid or good reason for usingplatform_devices, and as a result we have e.g. auxiliary bus.
Ok, so I cannot find this information anywhere (nor any example). Do you happen to know if the auxiliary bus offers any software node integration so that the compatible property from DT can get seamlessly mapped to auxiliary device IDs?
Quoted 2 lines
Anyway, (please) don't claim that "we need to", when it actually is "we want to use
platform_devicebecause that's more convenient"!
Bart
[snip]
Re: Re: Re: [PATCH 4/9] PCI: create platform devices for child OF nodes of the port node
Quoted 49 lines · Bartosz Golaszewski
Quoted 1 line · Bjorn Andersson
[snip]
Quoted 14 lines
Quoted 6 lines
Quoted 5 lines
I believe I missed this part of the discussion, why does this need to be a
platform_device? What does theplatform_busbring that can't be provided by some other bus?Quoted 7 lines
Does it need to be a
platform_device? No, of course not. Does it make sense for it to be one? Yes, for two reasons:1. The ATH11K WLAN module is represented on the device tree like a platform device, we know it's always there and it consumes regulators from another platform device. The fact it uses PCIe doesn't change the fact that it is logically a platform device.
Quoted 6 lines
Are you referring to the ath11k SNOC (firmware running on co-processor in the SoC) variant?
Afaict the PCIe-attached ath11k is not represented as a
platform_devicein DeviceTree.My bad. In RB5 it isn't (yet - I want to add it in the power sequencing series). It is in X13s though[1].
Quoted 3 lines
Said
platform_deviceis also not a child under the PCIe bus, so this would be a differentplatform_device...It's the child of the PCIe port node but there's a reason for it to have the
compatibleproperty. It's because it's an entity of whose existence we are aware before the system boots.Quoted 10 lines
Quoted 4 lines
2. The platform bus already provides us with the entire infrastructure that we'd now need to duplicate (possibly adding bugs) in order to introduce a "power sequencing bus".
This is a perfectly reasonable desire. Look at our PMICs, they are full of
platform_devices. But through the years it's been said many times, that this is not a valid or good reason for usingplatform_devices, and as a result we have e.g. auxiliary bus.
Quoted 5 lines
Ok, so I cannot find this information anywhere (nor any example). Do you happen to know if the auxiliary bus offers any software node integration so that the
compatibleproperty from DT can get seamlessly mapped to auxiliary device IDs?
So I was just trying to port this to using the auxiliary bus, only to find myself literally reimplementing functions from drivers/of/device.c. I have a feeling that this is simply wrong. If we're instantiating devices well defined on the device-tree then IMO we *should* make them platform devices. Anything else and we'll be reimplementing drivers/of/ because we will need to parse the device nodes, check the compatible, match it against drivers etc. Things that are already implemented for the platform bus and of_* APIs.
Greg: Could you chime in and confirm that it's alright to use the platform bus here? Or maybe there is some infrastructure to create auxiliary devices from software nodes?
Bartosz
Quoted 8 lines
Quoted 2 lines
Anyway, (please) don't claim that "we need to", when it actually is "we want to use
platform_devicebecause that's more convenient"!Bart
[snip]
Re: Re: Re: [PATCH 4/9] PCI: create platform devices for child OF nodes of the port node
Quoted 65 lines · Bartosz Golaszewski
Quoted 49 lines · Bartosz Golaszewski
Quoted 1 line · Bjorn Andersson
[snip]
Quoted 14 lines
Quoted 6 lines
Quoted 5 lines
I believe I missed this part of the discussion, why does this need to be a
platform_device? What does theplatform_busbring that can't be provided by some other bus?Quoted 7 lines
Does it need to be a
platform_device? No, of course not. Does it make sense for it to be one? Yes, for two reasons:1. The ATH11K WLAN module is represented on the device tree like a platform device, we know it's always there and it consumes regulators from another platform device. The fact it uses PCIe doesn't change the fact that it is logically a platform device.
Quoted 6 lines
Are you referring to the ath11k SNOC (firmware running on co-processor in the SoC) variant?
Afaict the PCIe-attached ath11k is not represented as a
platform_devicein DeviceTree.My bad. In RB5 it isn't (yet - I want to add it in the power sequencing series). It is in X13s though[1].
Quoted 3 lines
Said
platform_deviceis also not a child under the PCIe bus, so this would be a differentplatform_device...It's the child of the PCIe port node but there's a reason for it to have the
compatibleproperty. It's because it's an entity of whose existence we are aware before the system boots.Quoted 10 lines
Quoted 4 lines
2. The platform bus already provides us with the entire infrastructure that we'd now need to duplicate (possibly adding bugs) in order to introduce a "power sequencing bus".
This is a perfectly reasonable desire. Look at our PMICs, they are full of
platform_devices. But through the years it's been said many times, that this is not a valid or good reason for usingplatform_devices, and as a result we have e.g. auxiliary bus.Quoted 5 lines
Ok, so I cannot find this information anywhere (nor any example). Do you happen to know if the auxiliary bus offers any software node integration so that the
compatibleproperty from DT can get seamlessly mapped to auxiliary device IDs?So I was just trying to port this to using the auxiliary bus, only to find myself literally reimplementing functions from
drivers/of/device.c. I have a feeling that this is simply wrong. If we're instantiating devices well defined on the device-tree then IMO we *should* make them platform devices. Anything else and we'll be reimplementingdrivers/of/because we will need to parse the device nodes, check the compatible, match it against drivers etc. Things that are already implemented for the platform bus and of_* APIs.
Quoted 3 lines
Greg: Could you chime in and confirm that it's alright to use the platform bus here? Or maybe there is some infrastructure to create auxiliary devices from software nodes?
Note, I HATE the use of the platform bus here, but I don't have a better suggestion.
I'd love for the auxbus to work, and if you can create that from software nodes, all the better! But I don't think that's possible just yet, and you would end up implementing all the same stuff that the platform bus has today for this functionality, so I doubt it would be worth it.
thanks,
greg k-h