Skip to contentSkip to conversation

PCI: Add initial support for handling PCIe M.2 connectors in devicetree

PATCH Applied Manivannan Sadhasivam 6 participants 17 messages Jan 7 – Jan 14

Subsystems (7)

v5 of 7 Applied Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v5 cover PCI: Add initial support for handling PCIe M.2 connectors in devicetree

Hi,

This series is an initial attempt to support the PCIe M.2 connectors in the kernel and devicetree binding. The PCIe M.2 connectors as defined in the PCI Express M.2 Specification are widely used in Notebooks/Tablet form factors (even in PCs). On the ACPI platforms, power to these connectors are mostly handled by the firmware/BIOS and the kernel never bothered to directly power manage them as like other PCIe connectors. But on the devicetree platforms, the kernel needs to power manage these connectors with the help of the devicetree description. But so far, there is no proper representation of the M.2 connectors in devicetree binding. This forced the developers to fake the M.2 connectors as PMU nodes [1] and fixed regulators in devicetree.

So to properly support the M.2 connectors in devicetree platforms, this series introduces the devicetree binding for Mechanical Key M connector as an example and also the corresponding pwrseq driver and PCI changes in kernel to driver the connector.

The Mechanical Key M connector is used to connect SSDs to the host machine over PCIe/SATA interfaces. Due to the hardware constraints, this series only adds support for driving the PCIe interface of the connector in the kernel.

Also, the optional interfaces supported by the Key M connectors are not supported in the driver and left for the future enhancements.

Testing
=======

This series, together with the devicetree changes [2] [3] were tested on the Qualcomm X1e based Lenovo Thinkpad T14s Laptop which has the NVMe SSD connected over PCIe.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/arch/arm64/boot/dts/qcom/x1e80100-qcp.dts?h=v6.18-rc4&id=d09ab685a8f51ba412d37305ea62628a01cbea57
[2] https://github.com/Mani-Sadhasivam/linux/commit/40120d02219f34d2040ffa6328f0d406b1e4c04d
[3] https://github.com/Mani-Sadhasivam/linux/commit/ff6c3075836cc794a3700b0ec6a4a9eb21d14c6f

---
Changes in v5:
- used of_node_get() and devm_action to free regulators
- Link to v4: https://lore.kernel.org/r/[email protected]

Changes in v4:
- Added graph property to SATA in this series and PCI to dtschema:
https://github.com/devicetree-org/dt-schema/pull/180
- Used 'i2c-parent' instead of SMBus port
- Reworded the -gpios property description
- Rebased on top of v6.19-rc1
- Link to v3: https://lore.kernel.org/r/[email protected]

Changes in v3:
- Changed the VIO supply name as per dtschema
- Added explicit endpoint properties to port 0 node for host I/F
- Used scope based cleanup for OF node in pwrseq driver
- Collected review tags
- Link to v2: https://lore.kernel.org/r/[email protected]

Changes in v2:
- Incorporated comments from Bartosz and Frank for pwrseq and dt-binding patches, especially adding the pwrseq match() code.
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Manivannan Sadhasivam (5):
dt-bindings: ata: sata: Document the graph port
dt-bindings: connector: Add PCIe M.2 Mechanical Key M connector PCI/pwrctrl: Add support for handling PCIe M.2 connectors PCI/pwrctrl: Create pwrctrl device if the graph port is found
power: sequencing: Add the Power Sequencing driver for the PCIe M.2 connectors

 .../devicetree/bindings/ata/sata-common.yaml       |   3 +
 .../bindings/connector/pcie-m2-m-connector.yaml    | 133 ++++++++++++++++
 MAINTAINERS                                        |   7 +
 drivers/pci/probe.c                                |   3 +-
 drivers/pci/pwrctrl/Kconfig                        |   1 +
 drivers/pci/pwrctrl/slot.c                         |  35 ++++-
 drivers/power/sequencing/Kconfig                   |   8 +
 drivers/power/sequencing/Makefile                  |   1 +
 drivers/power/sequencing/pwrseq-pcie-m2.c          | 169 +++++++++++++++++++++
 9 files changed, 354 insertions(+), 6 deletions(-)

---
base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8
change-id: 20251103-pci-m2-7633631b6faa

Best regards,

Signature · 1 line
Manivannan Sadhasivam <[email protected]>
#1 lore raw

PATCH v5 1/5 dt-bindings: ata: sata: Document the graph port

An external connector like M.2 could expose the SATA interface to the plugin cards. So add the graph port to establish link between the SATA Port and the connector node.

---
 Documentation/devicetree/bindings/ata/sata-common.yaml | 3 +++
 1 file changed, 3 insertions(+)
Documentation/devicetree/bindings/ata/sata-common.yaml +3 -0
index 58c9342b9925..97cd69ebf331 100644
@@ -54,4 +54,7 @@ $defs:
           each port can have a Port Multiplier attached thus allowing to
           access more than one drive by means of a single SATA port.
 
+      port:
+        $ref: /schemas/graph.yaml#/properties/port
+
 ...
Signature · 1 line
2.48.1
maintainer Reviewed-by on v5 1/5
#2 lore raw

Re: [PATCH v5 1/5] dt-bindings: ata: sata: Document the graph port

Quoted 9 lines · Manivannan Sadhasivam

An external connector like M.2 could expose the SATA interface to the plugin cards. So add the graph port to establish link between the SATA Port and the connector node.

---
 Documentation/devicetree/bindings/ata/sata-common.yaml | 3 +++
 1 file changed, 3 insertions(+)
maintainer Applied
#3 lore raw

Re: [PATCH v5 1/5] dt-bindings: ata: sata: Document the graph port

In reply to Manivannan Sadhasivam
Quoted 7 lines · On 1/7/26 15:11, Manivannan Sadhasivam via B4 Relay wrote:

From: Manivannan Sadhasivam <[email protected]>

An external connector like M.2 could expose the SATA interface to the plugin cards. So add the graph port to establish link between the SATA Port and the connector node.

I applied this patch to the libata tree, for-6.20 branch. Thanks !

Signature · 2 lines
Damien Le Moal
Western Digital Research
#4 lore raw

PATCH v5 2/5 dt-bindings: connector: Add PCIe M.2 Mechanical Key M connector

In reply to Manivannan Sadhasivam

Add the devicetree binding for PCIe M.2 Mechanical Key M connector defined in the PCI Express M.2 Specification, r4.0, sec 5.3. This connector provides interfaces like PCIe and SATA to attach the Solid State Drives (SSDs) to the host machine along with additional interfaces like USB, and SMBus for debugging and supplementary features.

The connector provides a primary power supply of 3.3v, along with an optional 1.8v VIO supply for the Adapter I/O buffer circuitry operating at 1.8v sideband signaling.

The connector also supplies optional signals in the form of GPIOs for fine grained power management.

---
 .../bindings/connector/pcie-m2-m-connector.yaml    | 133 +++++++++++++++++++++
 1 file changed, 133 insertions(+)
Documentation/devicetree/bindings/connector/pcie-m2-m-connector.yaml new file +133 -0
new file mode 100644
index 000000000000..e912ee6f6a59
@@ -0,0 +1,133 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/connector/pcie-m2-m-connector.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: PCIe M.2 Mechanical Key M Connector
+
+maintainers:
+  - Manivannan Sadhasivam <[email protected]>
+
+description:
+  A PCIe M.2 M connector node represents a physical PCIe M.2 Mechanical Key M
+  connector. The Mechanical Key M connectors are used to connect SSDs to the
+  host system over PCIe/SATA interfaces. These connectors also offer optional
+  interfaces like USB, SMBus.
+
+properties:
+  compatible:
+    const: pcie-m2-m-connector
+
+  vpcie3v3-supply:
+    description: A phandle to the regulator for 3.3v supply.
+
+  vpcie1v8-supply:
+    description: A phandle to the regulator for VIO 1.8v supply.
+
+  ports:
+    $ref: /schemas/graph.yaml#/properties/ports
+    description: OF graph bindings modeling the interfaces exposed on the
+      connector. Since a single connector can have multiple interfaces, every
+      interface has an assigned OF graph port number as described below.
+
+    properties:
+      port@0:
+        $ref: /schemas/graph.yaml#/properties/port
+        description: Host interfaces of the connector
+
+        properties:
+          endpoint@0:
+            $ref: /schemas/graph.yaml#/properties/endpoint
+            description: PCIe interface
+
+          endpoint@1:
+            $ref: /schemas/graph.yaml#/properties/endpoint
+            description: SATA interface
+
+        anyOf:
+          - required:
+              - endpoint@0
+          - required:
+              - endpoint@1
+
+      port@1:
+        $ref: /schemas/graph.yaml#/properties/port
+        description: USB 2.0 interface
+
+      i2c-parent:
+        $ref: /schemas/types.yaml#/definitions/phandle
+        description: SMBus interface
+
+    required:
+      - port@0
+
+  clocks:
+    description: 32.768 KHz Suspend Clock (SUSCLK) input from the host system to
+      the M.2 card. Refer, PCI Express M.2 Specification r4.0, sec 3.1.12.1 for
+      more details.
+    maxItems: 1
+
+  pedet-gpios:
+    description: GPIO input to PEDET signal. This signal is used by the host
+      systems to determine the communication protocol that the M.2 card uses;
+      SATA signaling (low) or PCIe signaling (high). Refer, PCI Express M.2
+      Specification r4.0, sec 3.3.4.2 for more details.
+    maxItems: 1
+
+  viocfg-gpios:
+    description: GPIO output to IO voltage configuration (VIO_CFG) signal. This
+      signal is used by the M.2 card to indicate to the host system that the
+      card supports an independent IO voltage domain for the sideband signals.
+      Refer, PCI Express M.2 Specification r4.0, sec 3.1.15.1 for more details.
+    maxItems: 1
+
+  pwrdis-gpios:
+    description: GPIO input to Power Disable (PWRDIS) signal. This signal is
+      used by the host system to disable power on the M.2 card. Refer, PCI
+      Express M.2 Specification r4.0, sec 3.3.5.2 for more details.
+    maxItems: 1
+
+  pln-gpios:
+    description: GPIO output to Power Loss Notification (PLN#) signal. This
+      signal is use to notify the M.2 card by the host system that the power
+      loss event is expected to occur. Refer, PCI Express M.2 Specification
+      r4.0, sec 3.2.17.1 for more details.
+    maxItems: 1
+
+  plas3-gpios:
+    description: GPIO output to Power Loss Acknowledge (PLA_S3#) signal. This
+      signal is used by the M.2 card to notify the host system, the status of
+      the M.2 card's preparation for power loss.
+    maxItems: 1
+
+required:
+  - compatible
+  - vpcie3v3-supply
+
+additionalProperties: false
+
+examples:
+  # PCI M.2 Key M connector for SSDs with PCIe interface
+  - |
+    connector {
+        compatible = "pcie-m2-m-connector";
+        vpcie3v3-supply = <&vreg_nvme>;
+
+        ports {
+            #address-cells = <1>;
+            #size-cells = <0>;
+
+            port@0 {
+                #address-cells = <1>;
+                #size-cells = <0>;
+
+                reg = <0>;
+
+                endpoint@0 {
+                    reg = <0>;
+                    remote-endpoint = <&pcie6_port0_ep>;
+                };
+            };
+        };
+    };
Signature · 1 line
2.48.1
maintainer
#5 lore raw

Re: [PATCH v5 2/5] dt-bindings: connector: Add PCIe M.2 Mechanical Key M connector

Quoted 75 lines · Manivannan Sadhasivam

Add the devicetree binding for PCIe M.2 Mechanical Key M connector defined in the PCI Express M.2 Specification, r4.0, sec 5.3. This connector provides interfaces like PCIe and SATA to attach the Solid State Drives (SSDs) to the host machine along with additional interfaces like USB, and SMBus for debugging and supplementary features.

The connector provides a primary power supply of 3.3v, along with an optional 1.8v VIO supply for the Adapter I/O buffer circuitry operating at 1.8v sideband signaling.

The connector also supplies optional signals in the form of GPIOs for fine grained power management.

---
 .../bindings/connector/pcie-m2-m-connector.yaml    | 133 +++++++++++++++++++++
 1 file changed, 133 insertions(+)
Documentation/devicetree/bindings/connector/pcie-m2-m-connector.yaml new file +50 -0
new file mode 100644
index 000000000000..e912ee6f6a59
@@ -0,0 +1,133 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/connector/pcie-m2-m-connector.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: PCIe M.2 Mechanical Key M Connector
+
+maintainers:
+  - Manivannan Sadhasivam <[email protected]>
+
+description:
+  A PCIe M.2 M connector node represents a physical PCIe M.2 Mechanical Key M
+  connector. The Mechanical Key M connectors are used to connect SSDs to the
+  host system over PCIe/SATA interfaces. These connectors also offer optional
+  interfaces like USB, SMBus.
+
+properties:
+  compatible:
+    const: pcie-m2-m-connector
+
+  vpcie3v3-supply:
+    description: A phandle to the regulator for 3.3v supply.
+
+  vpcie1v8-supply:
+    description: A phandle to the regulator for VIO 1.8v supply.
+
+  ports:
+    $ref: /schemas/graph.yaml#/properties/ports
+    description: OF graph bindings modeling the interfaces exposed on the
+      connector. Since a single connector can have multiple interfaces, every
+      interface has an assigned OF graph port number as described below.
+
+    properties:
+      port@0:
+        $ref: /schemas/graph.yaml#/properties/port
+        description: Host interfaces of the connector
+
+        properties:
+          endpoint@0:
+            $ref: /schemas/graph.yaml#/properties/endpoint
+            description: PCIe interface
+
+          endpoint@1:
+            $ref: /schemas/graph.yaml#/properties/endpoint
+            description: SATA interface
+
+        anyOf:
+          - required:
+              - endpoint@0

Documentation/devicetree/bindings/connector/pcie-m2-m-connector.yaml line 60

Quoted 10 lines
Documentation/devicetree/bindings/connector/pcie-m2-m-connector.yaml new file +10 -0
+          - required:
+              - endpoint@1
+
+      port@1:
+        $ref: /schemas/graph.yaml#/properties/port
+        description: USB 2.0 interface
+
+      i2c-parent:
+        $ref: /schemas/types.yaml#/definitions/phandle
+        description: SMBus interface

This belongs outside of 'ports'. I would expect you'd get an error if you tried to put it here as '/schemas/graph.yaml#/properties/ports' shouldn't allow it. Please include the property in the example.

Quoted 29 lines
Documentation/devicetree/bindings/connector/pcie-m2-m-connector.yaml new file +29 -0
+
+    required:
+      - port@0
+
+  clocks:
+    description: 32.768 KHz Suspend Clock (SUSCLK) input from the host system to
+      the M.2 card. Refer, PCI Express M.2 Specification r4.0, sec 3.1.12.1 for
+      more details.
+    maxItems: 1
+
+  pedet-gpios:
+    description: GPIO input to PEDET signal. This signal is used by the host
+      systems to determine the communication protocol that the M.2 card uses;
+      SATA signaling (low) or PCIe signaling (high). Refer, PCI Express M.2
+      Specification r4.0, sec 3.3.4.2 for more details.
+    maxItems: 1
+
+  viocfg-gpios:
+    description: GPIO output to IO voltage configuration (VIO_CFG) signal. This
+      signal is used by the M.2 card to indicate to the host system that the
+      card supports an independent IO voltage domain for the sideband signals.
+      Refer, PCI Express M.2 Specification r4.0, sec 3.1.15.1 for more details.
+    maxItems: 1
+
+  pwrdis-gpios:
+    description: GPIO input to Power Disable (PWRDIS) signal. This signal is
+      used by the host system to disable power on the M.2 card. Refer, PCI
+      Express M.2 Specification r4.0, sec 3.3.5.2 for more details.
+    maxItems: 1

Documentation/devicetree/bindings/connector/pcie-m2-m-connector.yaml line 99

Quoted 10 lines
Documentation/devicetree/bindings/connector/pcie-m2-m-connector.yaml new file +10 -0
+
+  pln-gpios:
+    description: GPIO output to Power Loss Notification (PLN#) signal. This
+      signal is use to notify the M.2 card by the host system that the power
+      loss event is expected to occur. Refer, PCI Express M.2 Specification
+      r4.0, sec 3.2.17.1 for more details.
+    maxItems: 1
+
+  plas3-gpios:
+    description: GPIO output to Power Loss Acknowledge (PLA_S3#) signal. This

GPIO input?

Documentation/devicetree/bindings/connector/pcie-m2-m-connector.yaml line 106

Quoted 7 lines
Documentation/devicetree/bindings/connector/pcie-m2-m-connector.yaml new file +7 -0
+      signal is used by the M.2 card to notify the host system, the status of
+      the M.2 card's preparation for power loss.
+    maxItems: 1
+
+required:
+  - compatible
+  - vpcie3v3-supply

All the GPIOs are really optional?

Quoted 14 lines
Documentation/devicetree/bindings/connector/pcie-m2-m-connector.yaml new file +14 -0
+
+additionalProperties: false
+
+examples:
+  # PCI M.2 Key M connector for SSDs with PCIe interface
+  - |
+    connector {
+        compatible = "pcie-m2-m-connector";
+        vpcie3v3-supply = <&vreg_nvme>;
+
+        ports {
+            #address-cells = <1>;
+            #size-cells = <0>;
+

Documentation/devicetree/bindings/connector/pcie-m2-m-connector.yaml line 130

Quoted 10 lines
Documentation/devicetree/bindings/connector/pcie-m2-m-connector.yaml new file +10 -0
+            port@0 {
+                #address-cells = <1>;
+                #size-cells = <0>;
+
+                reg = <0>;
+
+                endpoint@0 {
+                    reg = <0>;
+                    remote-endpoint = <&pcie6_port0_ep>;
+                };

Please make the example as complete as possible.

Quoted 7 lines
Documentation/devicetree/bindings/connector/pcie-m2-m-connector.yaml new file +3 -0
+            };
+        };
+    };
Signature · 2 lines
-- 
2.48.1
#6 lore raw

Re: [PATCH v5 2/5] dt-bindings: connector: Add PCIe M.2 Mechanical Key M connector

Quoted 82 lines · Rob Herring
Quoted 81 lines · Manivannan Sadhasivam

Add the devicetree binding for PCIe M.2 Mechanical Key M connector defined in the PCI Express M.2 Specification, r4.0, sec 5.3. This connector provides interfaces like PCIe and SATA to attach the Solid State Drives (SSDs) to the host machine along with additional interfaces like USB, and SMBus for debugging and supplementary features.

The connector provides a primary power supply of 3.3v, along with an optional 1.8v VIO supply for the Adapter I/O buffer circuitry operating at 1.8v sideband signaling.

The connector also supplies optional signals in the form of GPIOs for fine grained power management.

---
 .../bindings/connector/pcie-m2-m-connector.yaml    | 133 +++++++++++++++++++++
 1 file changed, 133 insertions(+)
Documentation/devicetree/bindings/connector/pcie-m2-m-connector.yaml new file +56 -0
new file mode 100644
index 000000000000..e912ee6f6a59
@@ -0,0 +1,133 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/connector/pcie-m2-m-connector.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: PCIe M.2 Mechanical Key M Connector
+
+maintainers:
+  - Manivannan Sadhasivam <[email protected]>
+
+description:
+  A PCIe M.2 M connector node represents a physical PCIe M.2 Mechanical Key M
+  connector. The Mechanical Key M connectors are used to connect SSDs to the
+  host system over PCIe/SATA interfaces. These connectors also offer optional
+  interfaces like USB, SMBus.
+
+properties:
+  compatible:
+    const: pcie-m2-m-connector
+
+  vpcie3v3-supply:
+    description: A phandle to the regulator for 3.3v supply.
+
+  vpcie1v8-supply:
+    description: A phandle to the regulator for VIO 1.8v supply.
+
+  ports:
+    $ref: /schemas/graph.yaml#/properties/ports
+    description: OF graph bindings modeling the interfaces exposed on the
+      connector. Since a single connector can have multiple interfaces, every
+      interface has an assigned OF graph port number as described below.
+
+    properties:
+      port@0:
+        $ref: /schemas/graph.yaml#/properties/port
+        description: Host interfaces of the connector
+
+        properties:
+          endpoint@0:
+            $ref: /schemas/graph.yaml#/properties/endpoint
+            description: PCIe interface
+
+          endpoint@1:
+            $ref: /schemas/graph.yaml#/properties/endpoint
+            description: SATA interface
+
+        anyOf:
+          - required:
+              - endpoint@0
+          - required:
+              - endpoint@1
+
+      port@1:
+        $ref: /schemas/graph.yaml#/properties/port
+        description: USB 2.0 interface
Quoted 9 lines

Documentation/devicetree/bindings/connector/pcie-m2-m-connector.yaml line 60

Quoted 4 lines
Documentation/devicetree/bindings/connector/pcie-m2-m-connector.yaml new file +4 -0
+
+      i2c-parent:
+        $ref: /schemas/types.yaml#/definitions/phandle
+        description: SMBus interface

This belongs outside of 'ports'. I would expect you'd get an error if you tried to put it here as '/schemas/graph.yaml#/properties/ports' shouldn't allow it. Please include the property in the example.

Okay.

Quoted 33 lines
Quoted 33 lines
Documentation/devicetree/bindings/connector/pcie-m2-m-connector.yaml new file +33 -0
+
+    required:
+      - port@0
+
+  clocks:
+    description: 32.768 KHz Suspend Clock (SUSCLK) input from the host system to
+      the M.2 card. Refer, PCI Express M.2 Specification r4.0, sec 3.1.12.1 for
+      more details.
+    maxItems: 1
+
+  pedet-gpios:
+    description: GPIO input to PEDET signal. This signal is used by the host
+      systems to determine the communication protocol that the M.2 card uses;
+      SATA signaling (low) or PCIe signaling (high). Refer, PCI Express M.2
+      Specification r4.0, sec 3.3.4.2 for more details.
+    maxItems: 1
+
+  viocfg-gpios:
+    description: GPIO output to IO voltage configuration (VIO_CFG) signal. This
+      signal is used by the M.2 card to indicate to the host system that the
+      card supports an independent IO voltage domain for the sideband signals.
+      Refer, PCI Express M.2 Specification r4.0, sec 3.1.15.1 for more details.
+    maxItems: 1
+
+  pwrdis-gpios:
+    description: GPIO input to Power Disable (PWRDIS) signal. This signal is
+      used by the host system to disable power on the M.2 card. Refer, PCI
+      Express M.2 Specification r4.0, sec 3.3.5.2 for more details.
+    maxItems: 1
+
+  pln-gpios:
+    description: GPIO output to Power Loss Notification (PLN#) signal. This
+      signal is use to notify the M.2 card by the host system that the power
Quoted 9 lines

Documentation/devicetree/bindings/connector/pcie-m2-m-connector.yaml line 99

Quoted 6 lines
Documentation/devicetree/bindings/connector/pcie-m2-m-connector.yaml new file +6 -0
+      loss event is expected to occur. Refer, PCI Express M.2 Specification
+      r4.0, sec 3.2.17.1 for more details.
+    maxItems: 1
+
+  plas3-gpios:
+    description: GPIO output to Power Loss Acknowledge (PLA_S3#) signal. This

GPIO input?

I defined the role from a card PoV, but it should be the other way around, from the connector/host PoV. In that case, this will become input. I will change others also.

Quoted 10 lines

Documentation/devicetree/bindings/connector/pcie-m2-m-connector.yaml line 106

Quoted 7 lines
Documentation/devicetree/bindings/connector/pcie-m2-m-connector.yaml new file +7 -0
+      signal is used by the M.2 card to notify the host system, the status of
+      the M.2 card's preparation for power loss.
+    maxItems: 1
+
+required:
+  - compatible
+  - vpcie3v3-supply

All the GPIOs are really optional?

Yes.

Quoted 18 lines
Quoted 18 lines
Documentation/devicetree/bindings/connector/pcie-m2-m-connector.yaml new file +18 -0
+
+additionalProperties: false
+
+examples:
+  # PCI M.2 Key M connector for SSDs with PCIe interface
+  - |
+    connector {
+        compatible = "pcie-m2-m-connector";
+        vpcie3v3-supply = <&vreg_nvme>;
+
+        ports {
+            #address-cells = <1>;
+            #size-cells = <0>;
+
+            port@0 {
+                #address-cells = <1>;
+                #size-cells = <0>;
+
Quoted 9 lines

Documentation/devicetree/bindings/connector/pcie-m2-m-connector.yaml line 130

Quoted 6 lines
Documentation/devicetree/bindings/connector/pcie-m2-m-connector.yaml new file +6 -0
+                reg = <0>;
+
+                endpoint@0 {
+                    reg = <0>;
+                    remote-endpoint = <&pcie6_port0_ep>;
+                };

Please make the example as complete as possible.

Okay.

- Mani

Signature · 1 line
மணிவண்ணன் சதாசிவம்
#7 lore raw

PATCH v5 3/5 PCI/pwrctrl: Add support for handling PCIe M.2 connectors

In reply to Manivannan Sadhasivam

Add support for handling the PCIe M.2 connectors as Power Sequencing devices. These connectors are exposed as the Power Sequencing devices as they often support multiple interfaces like PCIe/SATA, USB/UART to the host machine and each interfaces could be driven by different client drivers at the same time.

This driver handles the PCIe interface of these connectors. It first checks for the presence of the graph port in the Root Port node with the help of of_graph_is_present() API, if present, it acquires/poweres ON the corresponding pwrseq device.

Once the pwrseq device is powered ON, the driver will skip parsing the Root Port/Slot resources and registers with the pwrctrl framework.

---
 drivers/pci/pwrctrl/Kconfig |  1 +
 drivers/pci/pwrctrl/slot.c  | 35 ++++++++++++++++++++++++++++++-----
 2 files changed, 31 insertions(+), 5 deletions(-)
drivers/pci/pwrctrl/Kconfig +1 -0
index e0f999f299bb..cd3aa15bad00 100644
@@ -13,6 +13,7 @@ config PCI_PWRCTRL_PWRSEQ
 
 config PCI_PWRCTRL_SLOT
 	tristate "PCI Power Control driver for PCI slots"
+	select POWER_SEQUENCING
 	select PCI_PWRCTRL
 	help
 	  Say Y here to enable the PCI Power Control driver to control the power
drivers/pci/pwrctrl/slot.c +30 -5
index 3320494b62d8..d46c2365208a 100644
@@ -8,8 +8,10 @@
 #include <linux/device.h>
 #include <linux/mod_devicetable.h>
 #include <linux/module.h>
+#include <linux/of_graph.h>
 #include <linux/pci-pwrctrl.h>
 #include <linux/platform_device.h>
+#include <linux/pwrseq/consumer.h>
 #include <linux/regulator/consumer.h>
 #include <linux/slab.h>
 
@@ -17,12 +19,18 @@ struct pci_pwrctrl_slot_data {
 	struct pci_pwrctrl ctx;
 	struct regulator_bulk_data *supplies;
 	int num_supplies;
+	struct pwrseq_desc *pwrseq;
 };
 
 static void devm_pci_pwrctrl_slot_power_off(void *data)
 {
 	struct pci_pwrctrl_slot_data *slot = data;
 
+	if (slot->pwrseq) {
+		pwrseq_power_off(slot->pwrseq);
+		return;
+	}
+
 	regulator_bulk_disable(slot->num_supplies, slot->supplies);
 	regulator_bulk_free(slot->num_supplies, slot->supplies);
 }
@@ -38,6 +46,20 @@ static int pci_pwrctrl_slot_probe(struct platform_device *pdev)
 	if (!slot)
 		return -ENOMEM;
 
+	if (of_graph_is_present(dev_of_node(dev))) {
+		slot->pwrseq = devm_pwrseq_get(dev, "pcie");
+		if (IS_ERR(slot->pwrseq))
+			return dev_err_probe(dev, PTR_ERR(slot->pwrseq),
+				     "Failed to get the power sequencer\n");
+
+		ret = pwrseq_power_on(slot->pwrseq);
+		if (ret)
+			return dev_err_probe(dev, ret,
+				     "Failed to power-on the device\n");
+
+		goto skip_resources;
+	}
+
 	ret = of_regulator_bulk_get_all(dev, dev_of_node(dev),
 					&slot->supplies);
 	if (ret < 0) {
@@ -53,17 +75,20 @@ static int pci_pwrctrl_slot_probe(struct platform_device *pdev)
 		return ret;
 	}
 
-	ret = devm_add_action_or_reset(dev, devm_pci_pwrctrl_slot_power_off,
-				       slot);
-	if (ret)
-		return ret;
-
 	clk = devm_clk_get_optional_enabled(dev, NULL);
 	if (IS_ERR(clk)) {
+		regulator_bulk_disable(slot->num_supplies, slot->supplies);
+		regulator_bulk_free(slot->num_supplies, slot->supplies);
 		return dev_err_probe(dev, PTR_ERR(clk),
 				     "Failed to enable slot clock\n");
 	}
 
+skip_resources:
+	ret = devm_add_action_or_reset(dev, devm_pci_pwrctrl_slot_power_off,
+				       slot);
+	if (ret)
+		return ret;
+
 	pci_pwrctrl_init(&slot->ctx, dev);
 
 	ret = devm_pci_pwrctrl_device_set_ready(dev, &slot->ctx);
Signature · 1 line
2.48.1
#8 lore raw

PATCH v5 4/5 PCI/pwrctrl: Create pwrctrl device if the graph port is found

In reply to Manivannan Sadhasivam

The devicetree node of the PCIe Root Port/Slot could have the graph port to link the PCIe M.2 connector node. Since the M.2 connectors are modelled as Power Sequencing devices, they need to be controlled by the pwrctrl driver as like the Root Port/Slot supplies.

Hence, create the pwrctrl device if the graph port is found in the node.

---
 drivers/pci/probe.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/pci/probe.c +2 -1
index 41183aed8f5d..cd7efd20a74a 100644
@@ -9,6 +9,7 @@
 #include <linux/init.h>
 #include <linux/pci.h>
 #include <linux/msi.h>
+#include <linux/of_graph.h>
 #include <linux/of_pci.h>
 #include <linux/of_platform.h>
 #include <linux/platform_device.h>
@@ -2585,7 +2586,7 @@ static struct platform_device *pci_pwrctrl_create_device(struct pci_bus *bus, in
 	 * not. This is decided based on at least one of the power supplies
 	 * being defined in the devicetree node of the device.
 	 */
-	if (!of_pci_supply_present(np)) {
+	if (!of_pci_supply_present(np) && !of_graph_is_present(np)) {
 		pr_debug("PCI/pwrctrl: Skipping OF node: %s\n", np->name);
 		goto err_put_of_node;
 	}
Signature · 1 line
2.48.1
#9 lore raw

PATCH v5 5/5 power: sequencing: Add the Power Sequencing driver for the PCIe M.2 connectors

In reply to Manivannan Sadhasivam

This driver is used to control the PCIe M.2 connectors of different Mechanical Keys attached to the host machines and supporting different interfaces like PCIe/SATA, USB/UART etc...

Currently, this driver supports only the Mechanical Key M connectors with PCIe interface. The driver also only supports driving the mandatory 3.3v and optional 1.8v power supplies. The optional signals of the Key M connectors are not currently supported.

---
 MAINTAINERS                               |   7 ++
 drivers/power/sequencing/Kconfig          |   8 ++
 drivers/power/sequencing/Makefile         |   1 +
 drivers/power/sequencing/pwrseq-pcie-m2.c | 169 ++++++++++++++++++++++++++++++
 4 files changed, 185 insertions(+)
MAINTAINERS +7 -0
index 5b11839cba9d..2eb7b6d26573 100644
@@ -20791,6 +20791,13 @@ F:	Documentation/driver-api/pwrseq.rst
 F:	drivers/power/sequencing/
 F:	include/linux/pwrseq/
 
+PCIE M.2 POWER SEQUENCING
+M:	Manivannan Sadhasivam <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	Documentation/devicetree/bindings/connector/pcie-m2-m-connector.yaml
+F:	drivers/power/sequencing/pwrseq-pcie-m2.c
+
 POWER STATE COORDINATION INTERFACE (PSCI)
 M:	Mark Rutland <[email protected]>
 M:	Lorenzo Pieralisi <[email protected]>
drivers/power/sequencing/Kconfig +8 -0
index 280f92beb5d0..f5fff84566ba 100644
@@ -35,4 +35,12 @@ config POWER_SEQUENCING_TH1520_GPU
 	  GPU. This driver handles the complex clock and reset sequence
 	  required to power on the Imagination BXM GPU on this platform.
 
+config POWER_SEQUENCING_PCIE_M2
+	tristate "PCIe M.2 connector power sequencing driver"
+	depends on OF || COMPILE_TEST
+	help
+	  Say Y here to enable the power sequencing driver for PCIe M.2
+	  connectors. This driver handles the power sequencing for the M.2
+	  connectors exposing multiple interfaces like PCIe, SATA, UART, etc...
+
 endif
drivers/power/sequencing/Makefile +1 -0
index 96c1cf0a98ac..0911d4618298 100644
@@ -5,3 +5,4 @@ pwrseq-core-y				:= core.o
 
 obj-$(CONFIG_POWER_SEQUENCING_QCOM_WCN)	+= pwrseq-qcom-wcn.o
 obj-$(CONFIG_POWER_SEQUENCING_TH1520_GPU) += pwrseq-thead-gpu.o
+obj-$(CONFIG_POWER_SEQUENCING_PCIE_M2)	+= pwrseq-pcie-m2.o
drivers/power/sequencing/pwrseq-pcie-m2.c new file +169 -0

169 lines not on this page · raw message

Signature · 1 line
2.48.1
#10 lore raw

Re: [PATCH v5 5/5] power: sequencing: Add the Power Sequencing driver for the PCIe M.2 connectors

Quoted 7 lines · On Wed, Jan 7, 2026 at 3:11 PM Manivannan Sadhasivam via B4 Relay…

From: Manivannan Sadhasivam <[email protected]>

This driver is used to control the PCIe M.2 connectors of different Mechanical Keys attached to the host machines and supporting different interfaces like PCIe/SATA, USB/UART etc...

Quoted 6 lines

Currently, this driver supports only the Mechanical Key M connectors with PCIe interface. The driver also only supports driving the mandatory 3.3v and optional 1.8v power supplies. The optional signals of the Key M connectors are not currently supported.

This looks good to me, though there are some nits I may fix when applying.

I'll pick it up for v7.0 once the bindings are reviewed.

Quoted 4 lines

+++ b/drivers/power/sequencing/pwrseq-pcie-m2.c

drivers/power/sequencing/pwrseq-pcie-m2.c new file +2 -0
@@ -0,0 +1,169 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*

drivers/power/sequencing/pwrseq-pcie-m2.c line 12

Quoted 10 lines
drivers/power/sequencing/pwrseq-pcie-m2.c new file +10 -0
+ * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
+ * Author: Manivannan Sadhasivam <[email protected]>
+ */
+
+#include <linux/device.h>
+#include <linux/mod_devicetable.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/of_graph.h>
+#include <linux/of_platform.h>

It looks like this is a leftover from previous versions and you no longer need it?

drivers/power/sequencing/pwrseq-pcie-m2.c line 100

Quoted 7 lines
drivers/power/sequencing/pwrseq-pcie-m2.c new file +7 -0
+
+static void pwrseq_pcie_free_resources(void *data)
+{
+       struct pwrseq_pcie_m2_ctx *ctx = data;
+
+       regulator_bulk_free(ctx->num_vregs, ctx->regs);
+}

I would call it pwrseq_pcie_m2_free_regulators() if you don't mind.

Bart

#11 lore raw

Re: [PATCH v5 5/5] power: sequencing: Add the Power Sequencing driver for the PCIe M.2 connectors

Quoted 14 lines · Bartosz Golaszewski
Quoted 12 lines · On Wed, Jan 7, 2026 at 3:11 PM Manivannan Sadhasivam via B4 Relay…

From: Manivannan Sadhasivam <[email protected]>

This driver is used to control the PCIe M.2 connectors of different Mechanical Keys attached to the host machines and supporting different interfaces like PCIe/SATA, USB/UART etc...

Currently, this driver supports only the Mechanical Key M connectors with PCIe interface. The driver also only supports driving the mandatory 3.3v and optional 1.8v power supplies. The optional signals of the Key M connectors are not currently supported.

Quoted 6 lines
Quoted 1 line

This looks good to me, though there are some nits I may fix when applying.

I'll pick it up for v7.0 once the bindings are reviewed.

Ok. I'm expecting patch 1 to go through ATA tree, patch 2 through DT, and patches 3,4 through PCI tree.

Quoted 9 lines
Quoted 9 lines

+++ b/drivers/power/sequencing/pwrseq-pcie-m2.c

drivers/power/sequencing/pwrseq-pcie-m2.c new file +7 -0
@@ -0,0 +1,169 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
+ * Author: Manivannan Sadhasivam <[email protected]>
+ */
+
+#include <linux/device.h>
Quoted 9 lines

drivers/power/sequencing/pwrseq-pcie-m2.c line 12

Quoted 5 lines
drivers/power/sequencing/pwrseq-pcie-m2.c new file +5 -0
+#include <linux/mod_devicetable.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/of_graph.h>
+#include <linux/of_platform.h>

It looks like this is a leftover from previous versions and you no longer need it?

Yeah.

Quoted 10 lines

drivers/power/sequencing/pwrseq-pcie-m2.c line 100

Quoted 7 lines
drivers/power/sequencing/pwrseq-pcie-m2.c new file +7 -0
+
+static void pwrseq_pcie_free_resources(void *data)
+{
+       struct pwrseq_pcie_m2_ctx *ctx = data;
+
+       regulator_bulk_free(ctx->num_vregs, ctx->regs);
+}

I would call it pwrseq_pcie_m2_free_regulators() if you don't mind.

Sure. I indeed missed '_m2'.

- Mani

Signature · 1 line
மணிவண்ணன் சதாசிவம்
#12 lore raw

Re: [PATCH v5 5/5] power: sequencing: Add the Power Sequencing driver for the PCIe M.2 connectors

Quoted 18 lines · Manivannan Sadhasivam
Quoted 16 lines · Bartosz Golaszewski
Quoted 13 lines · On Wed, Jan 7, 2026 at 3:11 PM Manivannan Sadhasivam via B4 Relay…

From: Manivannan Sadhasivam <[email protected]>

This driver is used to control the PCIe M.2 connectors of different Mechanical Keys attached to the host machines and supporting different interfaces like PCIe/SATA, USB/UART etc...

Currently, this driver supports only the Mechanical Key M connectors with PCIe interface. The driver also only supports driving the mandatory 3.3v and optional 1.8v power supplies. The optional signals of the Key M connectors are not currently supported.

Quoted 8 lines
Quoted 4 lines

This looks good to me, though there are some nits I may fix when applying.

I'll pick it up for v7.0 once the bindings are reviewed.

Ok. I'm expecting patch 1 to go through ATA tree, patch 2 through DT, and patches 3,4 through PCI tree.

I think it would make sense for patch 2 to go through the pwrseq tree with an Ack from DT maintainers.

Bartosz

maintainer
#13 lore raw

Re: [PATCH v5 5/5] power: sequencing: Add the Power Sequencing driver for the PCIe M.2 connectors

In reply to Manivannan Sadhasivam
Quoted 17 lines · Manivannan Sadhasivam
Quoted 16 lines · Bartosz Golaszewski
Quoted 13 lines · On Wed, Jan 7, 2026 at 3:11 PM Manivannan Sadhasivam via B4 Relay…

From: Manivannan Sadhasivam <[email protected]>

This driver is used to control the PCIe M.2 connectors of different Mechanical Keys attached to the host machines and supporting different interfaces like PCIe/SATA, USB/UART etc...

Currently, this driver supports only the Mechanical Key M connectors with PCIe interface. The driver also only supports driving the mandatory 3.3v and optional 1.8v power supplies. The optional signals of the Key M connectors are not currently supported.

Quoted 7 lines
Quoted 4 lines

This looks good to me, though there are some nits I may fix when applying.

I'll pick it up for v7.0 once the bindings are reviewed.

Ok. I'm expecting patch 1 to go through ATA tree, patch 2 through DT, and patches 3,4 through PCI tree.

Patch 1 seems to be completely unrelated to the power changes, so please send it to the ata list separately. It is otherwise very complicated and confusing for everyone to have patches from one series being applied through multiple trees.

Signature · 2 lines
Damien Le Moal
Western Digital Research
#14 lore raw

Re: [PATCH v5 5/5] power: sequencing: Add the Power Sequencing driver for the PCIe M.2 connectors

Quoted 23 lines · Damien Le Moal
Quoted 22 lines · Manivannan Sadhasivam
Quoted 20 lines · Bartosz Golaszewski
Quoted 7 lines · On Wed, Jan 7, 2026 at 3:11 PM Manivannan Sadhasivam via B4 Relay…

From: Manivannan Sadhasivam <[email protected]>

This driver is used to control the PCIe M.2 connectors of different Mechanical Keys attached to the host machines and supporting different interfaces like PCIe/SATA, USB/UART etc...

Quoted 6 lines

Currently, this driver supports only the Mechanical Key M connectors with PCIe interface. The driver also only supports driving the mandatory 3.3v and optional 1.8v power supplies. The optional signals of the Key M connectors are not currently supported.

This looks good to me, though there are some nits I may fix when applying.

I'll pick it up for v7.0 once the bindings are reviewed.

Quoted 7 lines
Quoted 2 lines

Ok. I'm expecting patch 1 to go through ATA tree, patch 2 through DT, and patches 3,4 through PCI tree.

Patch 1 seems to be completely unrelated to the power changes, so please send it to the ata list separately. It is otherwise very complicated and confusing for everyone to have patches from one series being applied through multiple trees.

Many maintainers often prefer patches in a single series for the complete picture. That's why I clubbed all of them in a single series. But I can send the ATA binding separately also (once it got reviewed by Rob).

Btw, with b4, it is no longer a hassle to apply individual patches from a single series.

- Mani

Signature · 1 line
மணிவண்ணன் சதாசிவம்
maintainer
#15 lore raw
In reply to Manivannan Sadhasivam
Quoted 18 lines · On Wed, Jan 07, 2026 at 07:41:22PM +0530, Manivannan Sadhasivam via B4 Relay…

Hi,

This series is an initial attempt to support the PCIe M.2 connectors in the kernel and devicetree binding. The PCIe M.2 connectors as defined in the PCI Express M.2 Specification are widely used in Notebooks/Tablet form factors (even in PCs). On the ACPI platforms, power to these connectors are mostly handled by the firmware/BIOS and the kernel never bothered to directly power manage them as like other PCIe connectors. But on the devicetree platforms, the kernel needs to power manage these connectors with the help of the devicetree description. But so far, there is no proper representation of the M.2 connectors in devicetree binding. This forced the developers to fake the M.2 connectors as PMU nodes [1] and fixed regulators in devicetree.

So to properly support the M.2 connectors in devicetree platforms, this series introduces the devicetree binding for Mechanical Key M connector as an example and also the corresponding pwrseq driver and PCI changes in kernel to driver the connector.

Quoted 6 lines

The Mechanical Key M connector is used to connect SSDs to the host machine over PCIe/SATA interfaces. Due to the hardware constraints, this series only adds support for driving the PCIe interface of the connector in the kernel.

Also, the optional interfaces supported by the Key M connectors are not supported in the driver and left for the future enhancements.

For me, it is not clear if there is a dependency or conflict with your
"major pwrctrl rework series":
[PATCH v4 0/8] PCI/pwrctrl: Major rework to integrate pwrctrl devices with controller drivers

Does one need to go before the other, or are they completely unrelated and can be merged in any order without conflicts?

Kind regards,
Niklas

#16 lore raw
Quoted 26 lines · Niklas Cassel
Quoted 18 lines · On Wed, Jan 07, 2026 at 07:41:22PM +0530, Manivannan Sadhasivam via B4 Relay…

Hi,

This series is an initial attempt to support the PCIe M.2 connectors in the kernel and devicetree binding. The PCIe M.2 connectors as defined in the PCI Express M.2 Specification are widely used in Notebooks/Tablet form factors (even in PCs). On the ACPI platforms, power to these connectors are mostly handled by the firmware/BIOS and the kernel never bothered to directly power manage them as like other PCIe connectors. But on the devicetree platforms, the kernel needs to power manage these connectors with the help of the devicetree description. But so far, there is no proper representation of the M.2 connectors in devicetree binding. This forced the developers to fake the M.2 connectors as PMU nodes [1] and fixed regulators in devicetree.

So to properly support the M.2 connectors in devicetree platforms, this series introduces the devicetree binding for Mechanical Key M connector as an example and also the corresponding pwrseq driver and PCI changes in kernel to driver the connector.

Quoted 6 lines

The Mechanical Key M connector is used to connect SSDs to the host machine over PCIe/SATA interfaces. Due to the hardware constraints, this series only adds support for driving the PCIe interface of the connector in the kernel.

Also, the optional interfaces supported by the Key M connectors are not supported in the driver and left for the future enhancements.

Quoted 7 lines

For me, it is not clear if there is a dependency or conflict with your
"major pwrctrl rework series":
[PATCH v4 0/8] PCI/pwrctrl: Major rework to integrate pwrctrl devices with controller drivers

Does one need to go before the other, or are they completely unrelated and can be merged in any order without conflicts?

Only patch 2 has the conflict with pwrctrl rework series, but that is trivial to fix. Otherwise, both are mostly independent.

- Mani

Signature · 1 line
மணிவண்ணன் சதாசிவம்