Qualcomm Type-C support for 1st generation
Subsystems (7)
cover Qualcomm Type-C support for 1st generation
This series adds basic USB Type-C support for 1st gen devices, covering configurations that do not require VBUS power (e.g. devices using externally powered docks).
VBUS support will be added in a follow-up series after this one is merged. Supporting VBUS will likely require refactoring parts of the SMBX charger support, which is why it is not included here.
Tested with an externally powered dock station:
- Pixel 3 / 3 XL
- SHIFT 6mq
- OnePlus 6
Tested with an additional, not-yet-included VBUS patch for non-powered devices:
- Xiaomi Redmi Note 7
- Xiaomi Mi Pad 4
Credits to everyone who has contributed to Type-C enablement before:
Casey Connolly
Zachary Dry — LLM generation and testing
Max Furman — LLM generation and testing
---
Alexey Minnekhanov (1):
arm64: dts: qcom: pm660: Add USB Type-C port controller node
David Heidelberg (11):
usb: typec: tcpm: qcom: Release the connector fwnode reference
dt-bindings: usb: qcom,pmic-typec: Update example with vbus-supply
dt-bindings: usb: Add Qualcomm 1st-gen PMIC Type-C
usb: typec: qcom: Make PMIC port probe selectable
usb: typec: qcom: Make typec_port accept also different structure
usb: typec: qcom: Add gen1 Type-C port support
arm64: dts: qcom: pmi8998: Add USB Type-C port controller node
arm64: dts: qcom: sdm670-google-common: Enable USB Type-C port controller
arm64: dts: qcom: sdm845-google-common: Enable USB Type-C port controller
arm64: dts: qcom: sdm845-oneplus-common: Enable USB Type-C port controller
arm64: dts: qcom: sdm845-shift-axolotl: Enable USB Type-C port controller
.../devicetree/bindings/mfd/qcom,spmi-pmic.yaml | 4 +- .../bindings/usb/qcom,pmic-typec-gen1.yaml | 130 +++++ .../devicetree/bindings/usb/qcom,pmic-typec.yaml | 3 +- arch/arm64/boot/dts/qcom/pm660.dtsi | 27 + arch/arm64/boot/dts/qcom/pmi8998.dtsi | 27 + arch/arm64/boot/dts/qcom/sdm670-google-common.dtsi | 51 +- arch/arm64/boot/dts/qcom/sdm845-google-common.dtsi | 59 +- .../arm64/boot/dts/qcom/sdm845-oneplus-common.dtsi | 48 +- arch/arm64/boot/dts/qcom/sdm845-shift-axolotl.dts | 62 ++- drivers/usb/typec/tcpm/qcom/Makefile | 1 + drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c | 20 +- drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.h | 2 +- drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c | 2 + .../typec/tcpm/qcom/qcom_pmic_typec_port_gen1.c | 605 +++++++++++++++++++++ .../typec/tcpm/qcom/qcom_pmic_typec_port_gen1.h | 15 + 15 files changed, 1045 insertions(+), 11 deletions(-)
---
base-commit: 7079a12d7506b07fb53b54a664bfad5fa9b16d70
change-id: 20260922-typec-6c48ef7ac8b0
Best regards,
Signature · 1 line
David Heidelberg <[email protected]>
RFC PATCH 1/12 usb: typec: tcpm: qcom: Release the connector fwnode reference
device_get_named_child_node() returns the connector node with its reference count incremented, but the port probe never drops it. The node is only needed for the VBUS regulator lookup, so release it right after.
--- drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c +2 -0
@@ -5,16 +5,17 @@#include <linux/delay.h> #include <linux/err.h> #include <linux/interrupt.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/of.h> #include <linux/platform_device.h> +#include <linux/property.h> #include <linux/regmap.h> #include <linux/regulator/consumer.h> #include <linux/slab.h> #include <linux/string_choices.h> #include <linux/usb/tcpm.h> #include <linux/usb/typec_mux.h> #include <linux/workqueue.h>
@@ -723,16 +724,17 @@ int qcom_pmic_typec_port_probe(struct platform_device *pdev, connector =device_get_named_child_node (dev,"connector" );if (!connector)return -EINVAL ; pmic_typec_port->vdd_vbus =devm_of_regulator_get_optional (dev,to_of_node (connector),"vbus" ); +fwnode_handle_put (connector);if (pmic_typec_port->vdd_vbus ==ERR_PTR (-ENODEV )) pmic_typec_port->vdd_vbus =devm_regulator_get (dev,"vdd-vbus" );if (IS_ERR (pmic_typec_port->vdd_vbus))return PTR_ERR (pmic_typec_port->vdd_vbus); pmic_typec_port->dev = dev; pmic_typec_port->base = base; pmic_typec_port->regmap = regmap;
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH RFC 01/12] usb: typec: tcpm: qcom: Release the connector fwnode reference
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 9 lines
From: David Heidelberg <[email protected]>
device_get_named_child_node()returns the connector node with its reference count incremented, but the port probe never drops it. The node is only needed for the VBUS regulator lookup, so release it right after.Assisted-by LLMFixes 506927b6bf29 ("usb: typec: tcpm: qcom: prefer VBUS supply from the connector node")Signed-off-by David Heidelberg <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Re: [PATCH RFC 01/12] usb: typec: tcpm: qcom: Release the connector fwnode reference
In reply to David HeidelbergHi David,
Quoted 9 lines · On Sat, Sep 26, 2026 at 02:40:20PM +0200, David Heidelberg via B4 Relay wrote:
From: David Heidelberg <[email protected]>
device_get_named_child_node()returns the connector node with its reference count incremented, but the port probe never drops it. The node is only needed for the VBUS regulator lookup, so release it right after.Assisted-by LLMFixes 506927b6bf29 ("usb: typec: tcpm: qcom: prefer VBUS supply from the connector node")Signed-off-by David Heidelberg <[email protected]>
I think this should be send separately. Cc stable?
Thanks,
Quoted 48 lines
--- drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c | 2 ++ 1 file changed, 2 insertions(+)drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c +2
-0@@ -5,16 +5,17 @@#include <linux/delay.h> #include <linux/err.h> #include <linux/interrupt.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/of.h> #include <linux/platform_device.h> +#include <linux/property.h> #include <linux/regmap.h> #include <linux/regulator/consumer.h> #include <linux/slab.h> #include <linux/string_choices.h> #include <linux/usb/tcpm.h> #include <linux/usb/typec_mux.h> #include <linux/workqueue.h> @@ -723,16 +724,17 @@ int qcom_pmic_typec_port_probe(struct platform_device *pdev, connector =device_get_named_child_node (dev,"connector" );if (!connector)return -EINVAL ; pmic_typec_port->vdd_vbus =devm_of_regulator_get_optional (dev,to_of_node (connector),"vbus" ); +fwnode_handle_put (connector);if (pmic_typec_port->vdd_vbus ==ERR_PTR (-ENODEV )) pmic_typec_port->vdd_vbus =devm_regulator_get (dev,"vdd-vbus" );if (IS_ERR (pmic_typec_port->vdd_vbus))return PTR_ERR (pmic_typec_port->vdd_vbus); pmic_typec_port->dev = dev; pmic_typec_port->base = base; pmic_typec_port->regmap = regmap;Signature · 2 lines
-- 2.55.0
Signature · 1 line
heikki
RFC PATCH 2/12 dt-bindings: usb: qcom,pmic-typec: Update example with vbus-supply
In reply to David HeidelbergThe vdd-vbus-supply is deprecated, thus don't suggest deprecated usage in example.
--- Documentation/devicetree/bindings/usb/qcom,pmic-typec.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/usb/qcom,pmic-typec.yaml +2 -1
@@ -163,29 +163,30 @@ examples: "sig-rx", "msg-tx", "msg-rx", "msg-tx-failed", "msg-tx-discarded", "msg-rx-discarded", "fr-swap"; - vdd-vbus-supply = <&pm8150b_vbus>; vdd-pdphy-supply = <&vreg_l2a_3p1>; connector { compatible = "usb-c-connector"; power-role = "source"; data-role = "dual"; self-powered; source-pdos = <PDO_FIXED(5000, 3000, PDO_FIXED_DUAL_ROLE | PDO_FIXED_USB_COMM | PDO_FIXED_DATA_SWAP)>; + vbus-supply = <&pm8150b_vbus>; + ports { #address-cells = <1>; #size-cells = <0>; port@0 { reg = <0>; pmic_typec_hs_in: endpoint { remote-endpoint = <&usb_hs_out>;
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH RFC 02/12] dt-bindings: usb: qcom,pmic-typec: Update example with vbus-supply
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 7 lines
From: David Heidelberg <[email protected]>
The vdd-vbus-supply is deprecated, thus don't suggest deprecated usage in example.
Assisted-by LLMSigned-off-by David Heidelberg <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
Re: [PATCH RFC 02/12] dt-bindings: usb: qcom,pmic-typec: Update example with vbus-supply
In reply to David HeidelbergQuoted 38 lines · On 26/09/2026 13:40, David Heidelberg via B4 Relay wrote:
From: David Heidelberg <[email protected]>
The vdd-vbus-supply is deprecated, thus don't suggest deprecated usage in example.
Assisted-by LLMSigned-off-by David Heidelberg <[email protected]>--- Documentation/devicetree/bindings/usb/qcom,pmic-typec.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)Documentation/devicetree/bindings/usb/qcom,pmic-typec.yaml +0
-1@@ -163,29 +163,30 @@ examples: "sig-rx", "msg-tx", "msg-rx", "msg-tx-failed", "msg-tx-discarded", "msg-rx-discarded", "fr-swap"; - vdd-vbus-supply = <&pm8150b_vbus>; vdd-pdphy-supply = <&vreg_l2a_3p1>; connector { compatible = "usb-c-connector"; power-role = "source"; data-role = "dual"; self-powered; source-pdos = <PDO_FIXED(5000, 3000, PDO_FIXED_DUAL_ROLE | PDO_FIXED_USB_COMM | PDO_FIXED_DATA_SWAP)>;
Documentation/devicetree/bindings/usb/qcom,pmic-typec.yaml examples: · line 192
Quoted 10 lines
Documentation/devicetree/bindings/usb/qcom,pmic-typec.yaml +2
-0+ vbus-supply = <&pm8150b_vbus>; + ports { #address-cells = <1>; #size-cells = <0>; port@0 { reg = <0>; pmic_typec_hs_in: endpoint { remote-endpoint = <&usb_hs_out>;
RFC PATCH 3/12 dt-bindings: usb: Add Qualcomm 1st-gen PMIC Type-C
In reply to David HeidelbergAdd a binding for the first generation of the Qualcomm PMIC USB Type-C port controller, found on the PM660 and PMI8998 PMICs.
Unlike the later standalone Type-C peripheral at 0x1500 (e.g. PM8150B), the gen1 Type-C CC logic is part of the charger's USBIN peripheral (base 0x1300) and signals all Type-C events (CC state change, tCCDebounce done, VBUS change and error) through a single aggregate "type-c-change" interrupt. The USB PD PHY at 0x1700 is register compatible with PM8150B.
The different interrupt set and register layout make it a separate binding rather than another variant of qcom,pmic-typec. As with PM8150B, the Type-C block and PD PHY are described as a separate SPMI node from the charger.
Allow typec nodes of the Qualcomm SPMI PMIC to use the new binding as well.
--- .../devicetree/bindings/mfd/qcom,spmi-pmic.yaml | 4 +- .../bindings/usb/qcom,pmic-typec-gen1.yaml | 130 +++++++++++++++++++++ 2 files changed, 133 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/mfd/qcom,spmi-pmic.yaml +3 -1
@@ -199,17 +199,19 @@ patternProperties: $ref: /schemas/thermal/qcom,spmi-temp-alarm.yaml# "^temperature-sensor@[0-9a-f]+$": type: object $ref: /schemas/thermal/qcom,pm8775-mbg-tm.yaml# "^typec@[0-9a-f]+$": type: object - $ref: /schemas/usb/qcom,pmic-typec.yaml# + oneOf: + - $ref: /schemas/usb/qcom,pmic-typec.yaml# + - $ref: /schemas/usb/qcom,pmic-typec-gen1.yaml# "^usb-detect@[0-9a-f]+$": type: object $ref: /schemas/extcon/qcom,pm8941-misc.yaml# "^usb-vbus-regulator@[0-9a-f]+$": type: object $ref: /schemas/regulator/qcom,usb-vbus-regulator.yaml#
Documentation/devicetree/bindings/usb/qcom,pmic-typec-gen1.yaml new file +130 -0
130 lines not on this page · raw message
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH RFC 03/12] dt-bindings: usb: Add Qualcomm 1st-gen PMIC Type-C
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 17 lines
From: David Heidelberg <[email protected]>
Add a binding for the first generation of the Qualcomm PMIC USB Type-C port controller, found on the PM660 and PMI8998 PMICs.
Unlike the later standalone Type-C peripheral at
0x1500(e.g. PM8150B), the gen1 Type-C CC logic is part of the charger's USBIN peripheral (base0x1300) and signals all Type-C events (CC state change, tCCDebounce done, VBUS change and error) through a single aggregate "type-c-change" interrupt. The USB PD PHY at0x1700is register compatible with PM8150B.The different interrupt set and register layout make it a separate binding rather than another variant of qcom,pmic-typec. As with PM8150B, the Type-C block and PD PHY are described as a separate SPMI node from the charger.
Quoted 5 lines
Allow typec nodes of the Qualcomm SPMI PMIC to use the new binding as well.
Assisted-by LLMSigned-off-by David Heidelberg <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
RFC PATCH 4/12 usb: typec: qcom: Make PMIC port probe selectable
In reply to David HeidelbergThis is a preparation for extending the support with 1st generation Type-C.
--- drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c +9 -2
@@ -13,19 +13,25 @@#include <linux/usb/tcpm.h> #include <drm/bridge/aux-bridge.h> #include "qcom_pmic_typec.h" #include "qcom_pmic_typec_pdphy.h" #include "qcom_pmic_typec_port.h" +typedef int (*pmic_typec_port_probe_fn )(struct platform_device *pdev, +struct pmic_typec *tcpm, +const struct pmic_typec_port_resources *res, +struct regmap *regmap,u32 base); +struct pmic_typec_resources {const struct pmic_typec_pdphy_resources *pdphy_res;const struct pmic_typec_port_resources *port_res; +pmic_typec_port_probe_fn port_probe; };static int qcom_pmic_typec_init (struct tcpc_dev *tcpc) {return 0 ; }static int qcom_pmic_typec_probe (struct platform_device *pdev)
@@ -55,18 +61,17 @@ static int qcom_pmic_typec_probe(struct platform_device *pdev)dev_err (dev,"Failed to get regmap\n" );return -ENODEV ; } ret =of_property_read_u32_index (np,"reg" ,0 , &base);if (ret)return ret; - ret =qcom_pmic_typec_port_probe (pdev, tcpm, - res->port_res, regmap, base); + ret = res->port_probe (pdev, tcpm, res->port_res, regmap, base);if (ret)return ret;if (res->pdphy_res) { ret =of_property_read_u32_index (np,"reg" ,1 , &base);if (ret)return ret;
@@ -132,21 +137,23 @@ static void qcom_pmic_typec_remove(struct platform_device *pdev) tcpm->port_stop (tcpm);tcpm_unregister_port (tcpm->tcpm_port);fwnode_handle_put (tcpm->tcpc.fwnode); }static const struct pmic_typec_resources pm8150b_typec_res = { .pdphy_res = &pm8150b_pdphy_res, .port_res = &pm8150b_port_res, + .port_probe = qcom_pmic_typec_port_probe, };static const struct pmic_typec_resources pmi632_typec_res = {/* PD PHY not present */ .port_res = &pm8150b_port_res, + .port_probe = qcom_pmic_typec_port_probe, };static const struct of_device_id qcom_pmic_typec_table[] = { { .compatible ="qcom,pm8150b-typec" , .data = &pm8150b_typec_res }, { .compatible ="qcom,pmi632-typec" , .data = &pmi632_typec_res }, { } };MODULE_DEVICE_TABLE (of, qcom_pmic_typec_table);
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH RFC 04/12] usb: typec: qcom: Make PMIC port probe selectable
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 9 lines
From: David Heidelberg <[email protected]>
This is a preparation for extending the support with 1st generation Type-C.
Assisted-by LLMCo-developed-by Alexey Minnekhanov <[email protected]>Signed-off-by Alexey Minnekhanov <[email protected]>Signed-off-by David Heidelberg <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
Re: [PATCH RFC 04/12] usb: typec: qcom: Make PMIC port probe selectable
In reply to David HeidelbergQuoted 9 lines · On 26/09/2026 13:40, David Heidelberg via B4 Relay wrote:
From: David Heidelberg<[email protected]>
This is a preparation for extending the support with 1st generation Type-C.
Assisted-by LLMCo-developed-by Alexey Minnekhanov<[email protected]>Signed-off-by Alexey Minnekhanov<[email protected]>Signed-off-by David Heidelberg<[email protected]>
The code looks fine but, I think the commit log could do with a bit more flesh on the bones. "We want our own probe function because"
Then:
RFC PATCH 5/12 usb: typec: qcom: Make typec_port accept also different structure
In reply to David HeidelbergThis is needed by followup commit introducing 1st gen of type-c support.
--- drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.h +1 -1
@@ -6,17 +6,17 @@ #ifndef __QCOM_PMIC_TYPEC_H__ #define __QCOM_PMIC_TYPEC_H__ struct pmic_typec { struct device *dev; struct tcpm_port *tcpm_port; struct tcpc_dev tcpc; struct pmic_typec_pdphy *pmic_typec_pdphy; - struct pmic_typec_port *pmic_typec_port; + void *pmic_typec_port; int (*pdphy_start)(struct pmic_typec *tcpm, struct tcpm_port *tcpm_port); void (*pdphy_stop)(struct pmic_typec *tcpm); int (*port_start)(struct pmic_typec *tcpm, struct tcpm_port *tcpm_port); void (*port_stop)(struct pmic_typec *tcpm);
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH RFC 05/12] usb: typec: qcom: Make typec_port accept also different structure
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 8 lines
From: David Heidelberg <[email protected]>
This is needed by followup commit introducing 1st gen of type-c support.
Assisted-by LLMCo-developed-by Alexey Minnekhanov <[email protected]>Signed-off-by Alexey Minnekhanov <[email protected]>Signed-off-by David Heidelberg <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5
Re: [PATCH RFC 05/12] usb: typec: qcom: Make typec_port accept also different structure
In reply to David HeidelbergQuoted 8 lines · On 26/09/2026 13:40, David Heidelberg via B4 Relay wrote:
From: David Heidelberg<[email protected]>
This is needed by followup commit introducing 1st gen of type-c support.
Assisted-by LLMCo-developed-by Alexey Minnekhanov<[email protected]>Signed-off-by Alexey Minnekhanov<[email protected]>Signed-off-by David Heidelberg<[email protected]>
Same comment.
Understood its needed but, please describe why. I haven't read the next patch yet but I guess you are going to have something other than struct pmic_typec_port *
Again a minor nit you an fixup in the next rev
RFC PATCH 6/12 usb: typec: qcom: Add gen1 Type-C port support
In reply to David HeidelbergAdd a port backend for the first generation of the Qualcomm PMIC Type-C block, found on PM660 and PMI8998.
On gen1 the Type-C CC logic is part of the charger's USBIN peripheral (base 0x1300) instead of the standalone Type-C peripheral used by PM8150B and later PMICs. All Type-C events (CC state change, tCCDebounce done, VBUS change and error) are signalled through a single aggregate "type-c-change" interrupt, the handler re-reads TYPEC_STATUS_4 to find out what changed. The PD PHY is register compatible with PM8150B and is reused as is.
Differences to the PM8150B backend:
- get_cc() returns -EBUSY until the hardware reports tCCDebounce done, instead of using a software debounce.
- As a source, only the default and 1.5A Rp can be advertised, 3.0A requests are advertised as 1.5A.
- The PBS workaround of the downstream SMB2 driver (TM_IO_DTEST4_SEL) is applied on every power role change.
VBUS sourcing is optional and only used when the connector provides a vbus-supply, as the charger doesn't expose a VBUS regulator yet.
--- drivers/usb/typec/tcpm/qcom/Makefile | 1 + drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c | 9 + .../typec/tcpm/qcom/qcom_pmic_typec_port_gen1.c | 605 +++++++++++++++++++++ .../typec/tcpm/qcom/qcom_pmic_typec_port_gen1.h | 15 + 4 files changed, 630 insertions(+)
drivers/usb/typec/tcpm/qcom/Makefile +1 -0
@@ -1,7 +1,8 @@ # SPDX-License-Identifier: GPL-2.0 # obj-$(CONFIG_TYPEC_QCOM_PMIC) += qcom_pmic_tcpm.o qcom_pmic_tcpm-y += qcom_pmic_typec.o \ qcom_pmic_typec_port.o \ + qcom_pmic_typec_port_gen1.o \ qcom_pmic_typec_pdphy.o \ qcom_pmic_typec_pdphy_stub.o \
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c +9 -0
@@ -12,16 +12,17 @@#include <linux/slab.h> #include <linux/usb/tcpm.h> #include <drm/bridge/aux-bridge.h> #include "qcom_pmic_typec.h" #include "qcom_pmic_typec_pdphy.h" #include "qcom_pmic_typec_port.h" +#include "qcom_pmic_typec_port_gen1.h" typedef int (*pmic_typec_port_probe_fn )(struct platform_device *pdev,struct pmic_typec *tcpm,const struct pmic_typec_port_resources *res,struct regmap *regmap,u32 base);struct pmic_typec_resources {const struct pmic_typec_pdphy_resources *pdphy_res;
@@ -134,31 +135,39 @@ static void qcom_pmic_typec_remove(struct platform_device *pdev)struct pmic_typec *tcpm =platform_get_drvdata (pdev); tcpm->pdphy_stop (tcpm); tcpm->port_stop (tcpm);tcpm_unregister_port (tcpm->tcpm_port);fwnode_handle_put (tcpm->tcpc.fwnode); } +static const struct pmic_typec_resources gen1_typec_res = { + .pdphy_res = &pm8150b_pdphy_res, + .port_res = &gen1_port_res, + .port_probe = qcom_pmic_typec_gen1_port_probe, +}; +static const struct pmic_typec_resources pm8150b_typec_res = { .pdphy_res = &pm8150b_pdphy_res, .port_res = &pm8150b_port_res, .port_probe = qcom_pmic_typec_port_probe, };static const struct pmic_typec_resources pmi632_typec_res = {/* PD PHY not present */ .port_res = &pm8150b_port_res, .port_probe = qcom_pmic_typec_port_probe, };static const struct of_device_id qcom_pmic_typec_table[] = { + { .compatible ="qcom,pm660-typec" , .data = &gen1_typec_res }, { .compatible ="qcom,pm8150b-typec" , .data = &pm8150b_typec_res }, { .compatible ="qcom,pmi632-typec" , .data = &pmi632_typec_res }, + { .compatible ="qcom,pmi8998-typec" , .data = &gen1_typec_res }, { } };MODULE_DEVICE_TABLE (of, qcom_pmic_typec_table);static struct platform_driver qcom_pmic_typec_driver = { .driver = { .name ="qcom,pmic-typec" , .of_match_table = qcom_pmic_typec_table,
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port_gen1.c new file +605 -0
605 lines not on this page · raw message
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port_gen1.h new file +15 -0
@@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef __QCOM_PMIC_TYPEC_PORT_GEN1_H__ +#define __QCOM_PMIC_TYPEC_PORT_GEN1_H__ + +#include "qcom_pmic_typec_port.h" + +extern const struct pmic_typec_port_resources gen1_port_res; + +int qcom_pmic_typec_gen1_port_probe (struct platform_device *pdev, +struct pmic_typec *tcpm, +const struct pmic_typec_port_resources *res, +struct regmap *regmap, +u32 base); + +#endif /* __QCOM_PMIC_TYPEC_PORT_GEN1_H__ */
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH RFC 06/12] usb: typec: qcom: Add gen1 Type-C port support
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] usb: typec: qcom: data race on port->tcpm_port causes NULL dereference --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] usb: typec: qcom: data race on port->tcpm_port causes NULL dereference --
commit c724ae85ceb0ca42ea62d9d3f8a3d994453a3cf9
Author: David Heidelberg <[email protected]>
usb: typec: qcom: Add gen1 Type-C port support
Add a port backend for the first generation of the Qualcomm PMIC Type-C block, found on PM660 and PMI8998.
Quoted 5 lines
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port_gen1.c new file +0
-0
[ ... ]
Quoted 6 lines
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port_gen1.c new file +6
-0+static int gen1_typec_set_vbus (struct tcpc_dev *tcpc,bool on,bool sink) +{ +struct pmic_typec *tcpm =tcpc_to_tcpm (tcpc); +struct gen1_typec_port *port = tcpm->pmic_typec_port; +bool changed = false; +int ret =0 ;
[ ... ]
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port_gen1.c line 196
Quoted 9 lines
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port_gen1.c new file +9
-0+/* +* set_vbus() may run during tcpm_register_port() before port_start() +* provides tcpm_port. Once registered, notify TCPM whenever the +* source regulator actually changes state. get_vbus() also accounts +* for vbus_enabled when GEN1 does not reflect sourced VBUS in +* TYPEC_VBUS_STATUS. +*/ +if (changed && port->tcpm_port) +tcpm_vbus_change (port->tcpm_port);
[Severity: High]
Could this sequence lead to a NULL pointer dereference if device teardown occurs concurrently?
It appears port->tcpm_port is evaluated outside port->lock. Without READ_ONCE(), the compiler could emit a double fetch (TOCTOU) here.
If the TCPM worker thread (driven by external cable events) executes a VBUS state transition concurrently with unbind, the pointer could become NULL between the condition check and the function call, causing tcpm_vbus_change(NULL) to crash.
[ ... ]
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port_gen1.c line 539
Quoted 6 lines
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port_gen1.c new file +6
-0+static void gen1_typec_port_stop (struct pmic_typec *tcpm) +{ +struct gen1_typec_port *port = tcpm->pmic_typec_port; + +disable_irq (port->irq); + port->tcpm_port =NULL ;
[Severity: High]
Is it safe to clear port->tcpm_port locklessly here?
During unbind, qcom_pmic_typec_remove() calls gen1_typec_port_stop(), which executes port->tcpm_port = NULL without holding a lock. This appears to be what creates the potential race with gen1_typec_set_vbus() shown above.
Quoted 1 line
+}
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=6
Bryan O'Donoghue
maintainerRe: [PATCH RFC 06/12] usb: typec: qcom: Add gen1 Type-C port support
In reply to David HeidelbergQuoted 92 lines · On 26/09/2026 13:40, David Heidelberg via B4 Relay wrote:
From: David Heidelberg <[email protected]>
Add a port backend for the first generation of the Qualcomm PMIC Type-C block, found on PM660 and PMI8998.
On gen1 the Type-C CC logic is part of the charger's USBIN peripheral (base
0x1300) instead of the standalone Type-C peripheral used by PM8150B and later PMICs. All Type-C events (CC state change, tCCDebounce done, VBUS change and error) are signalled through a single aggregate "type-c-change" interrupt, the handler re-readsTYPEC_STATUS_4to find out what changed. The PD PHY is register compatible with PM8150B and is reused as is.Differences to the PM8150B backend:
-get_cc()returns-EBUSYuntil the hardware reports tCCDebounce done, instead of using a software debounce.
- As a source, only the default and 1.5A Rp can be advertised, 3.0A requests are advertised as 1.5A.
- The PBS workaround of the downstream SMB2 driver (TM_IO_DTEST4_SEL) is applied on every power role change.VBUS sourcing is optional and only used when the connector provides a vbus-supply, as the charger doesn't expose a VBUS regulator yet.
Assisted-by LLMCo-developed-by Alexey Minnekhanov <[email protected]>Signed-off-by Alexey Minnekhanov <[email protected]>Signed-off-by David Heidelberg <[email protected]>--- drivers/usb/typec/tcpm/qcom/Makefile | 1 + drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c | 9 + .../typec/tcpm/qcom/qcom_pmic_typec_port_gen1.c | 605 +++++++++++++++++++++ .../typec/tcpm/qcom/qcom_pmic_typec_port_gen1.h | 15 + 4 files changed, 630 insertions(+)drivers/usb/typec/tcpm/qcom/Makefile +1
-0@@ -1,7 +1,8 @@ # SPDX-License-Identifier: GPL-2.0 # obj-$(CONFIG_TYPEC_QCOM_PMIC) += qcom_pmic_tcpm.o qcom_pmic_tcpm-y += qcom_pmic_typec.o \ qcom_pmic_typec_port.o \ + qcom_pmic_typec_port_gen1.o \ qcom_pmic_typec_pdphy.o \ qcom_pmic_typec_pdphy_stub.o \drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c +7
-0@@ -12,16 +12,17 @@#include <linux/slab.h> #include <linux/usb/tcpm.h> #include <drm/bridge/aux-bridge.h> #include "qcom_pmic_typec.h" #include "qcom_pmic_typec_pdphy.h" #include "qcom_pmic_typec_port.h" +#include "qcom_pmic_typec_port_gen1.h" typedef int (*pmic_typec_port_probe_fn )(struct platform_device *pdev,struct pmic_typec *tcpm,const struct pmic_typec_port_resources *res,struct regmap *regmap,u32 base);struct pmic_typec_resources {const struct pmic_typec_pdphy_resources *pdphy_res;@@ -134,31 +135,39 @@ static void qcom_pmic_typec_remove(struct platform_device *pdev)struct pmic_typec *tcpm =platform_get_drvdata (pdev); tcpm->pdphy_stop (tcpm); tcpm->port_stop (tcpm);tcpm_unregister_port (tcpm->tcpm_port);fwnode_handle_put (tcpm->tcpc.fwnode); } +static const struct pmic_typec_resources gen1_typec_res = { + .pdphy_res = &pm8150b_pdphy_res, + .port_res = &gen1_port_res, + .port_probe = qcom_pmic_typec_gen1_port_probe, +}; +static const struct pmic_typec_resources pm8150b_typec_res = { .pdphy_res = &pm8150b_pdphy_res, .port_res = &pm8150b_port_res, .port_probe = qcom_pmic_typec_port_probe, };static const struct pmic_typec_resources pmi632_typec_res = {
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c static void qcom_pmic_typec_remove(struct platform_device *pdev) · line 165
Quoted 10 lines
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c +2
-0/* PD PHY not present */ .port_res = &pm8150b_port_res, .port_probe = qcom_pmic_typec_port_probe, };static const struct of_device_id qcom_pmic_typec_table[] = { + { .compatible ="qcom,pm660-typec" , .data = &gen1_typec_res }, { .compatible ="qcom,pm8150b-typec" , .data = &pm8150b_typec_res }, { .compatible ="qcom,pmi632-typec" , .data = &pmi632_typec_res }, + { .compatible ="qcom,pmi8998-typec" , .data = &gen1_typec_res },
I think this should be
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c static void qcom_pmic_typec_remove(struct platform_device *pdev)
Quoted 4 lines
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c +2
-0+ { .compatible = "qcom,pm660-typec", .data = &pm660_typec_res }, { .compatible = "qcom,pm8150b-typec", .data = &pm8150b_typec_res }, { .compatible = "qcom,pmi632-typec", .data = &pmi632_typec_res }, + { .compatible = "qcom,pmi8998-typec", .data = &pmi8998_typec_res },
Since I'm not sure "gen1" is a real thing and besides, I see this gen1/gen2/gen3 stuff in CAMSS and it means almost nothing. The silicon version is the salient thing.
/rant
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port_gen1.c
Quoted 9 lines
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c +0
-0{ } };MODULE_DEVICE_TABLE (of, qcom_pmic_typec_table);static struct platform_driver qcom_pmic_typec_driver = { .driver = { .name ="qcom,pmic-typec" , .of_match_table = qcom_pmic_typec_table,drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port_gen1.c +0
-0
I'd rename the existing file to qcom_pmic_typec_port_pm8150b and the new file to qcom_pmic_typec_port_pm660.c or pmi8998.c at your preference, probably whichever version hit the market first would make sense.
Quoted 90 lines
new file mode 100644
index 0000000000000..b4e3e49664f9ddrivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port_gen1.c new file +85
-0@@ -0,0 +1,605 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Qualcomm Type-C port backend (1st gen) +* +* GEN1 predates the standalone PM8150B-style Type-C register block. +* Its CC/role controls live in the USBIN peripheral, while the PD PHY +* is a separate PMIC peripheral. +*/ + +#include <linux/interrupt.h> +#include <linux/kernel.h> +#include <linux/mutex.h> +#include <linux/of.h> +#include <linux/platform_device.h> +#include <linux/property.h> +#include <linux/regmap.h> +#include <linux/regulator/consumer.h> +#include <linux/slab.h> +#include <linux/usb/tcpm.h> + +#include "qcom_pmic_typec.h" +#include "qcom_pmic_typec_port.h" +#include "qcom_pmic_typec_port_gen1.h" + +/* USBIN Type-C status */ +#define TYPEC_STATUS_1_REG 0x0b +#define UFP_TYPEC_MASK GENMASK(7, 5) +#define UFP_TYPEC_RDSTD BIT(7) +#define UFP_TYPEC_RD1P5 BIT(6) +#define UFP_TYPEC_RD3P0 BIT(5) + +#define TYPEC_STATUS_2_REG 0x0c +#define DFP_TYPEC_MASK GENMASK(3, 0) +#define DFP_RD_OPEN BIT(3) +#define DFP_RD_RA_VCONN BIT(2) +#define DFP_RD_RD BIT(1) +#define DFP_RA_RA BIT(0) + +#define TYPEC_STATUS_4_REG 0x0e +#define UFP_DFP_MODE_STATUS BIT(7) +#define TYPEC_VBUS_STATUS BIT(6) +#define TYPEC_VBUS_ERROR BIT(5) +#define TYPEC_DEBOUNCE_DONE BIT(4) +#define CC_ORIENTATION BIT(1) +#define CC_ATTACHED BIT(0) + +/* USBIN Type-C configuration */ +#define TYPEC_CFG_REG 0x58 +#define TYPEC_OR_U_USB BIT(0) + +#define TYPEC_CFG_2_REG 0x59 +#define EN_TRY_SOURCE_MODE BIT(3) +#define EN_80UA_180UA_CUR_SOURCE BIT(0) + +#define TYPEC_CFG_3_REG 0x5a +#define EN_TRYSINK_MODE BIT(2) + +#define TYPEC_INTRPT_ENB_REG 0x67 +#define VBUS_ERROR_INT_EN BIT(5) +#define DEBOUNCE_DONE_INT_EN BIT(3) +#define CCSTATE_CHANGE_INT_EN BIT(2) +#define VBUS_DEASSERT_INT_EN BIT(1) +#define VBUS_ASSERT_INT_EN BIT(0) + +#define TYPEC_SW_CTRL_REG 0x68 +#define VCONN_EN_ORIENTATION BIT(6) +#define VCONN_EN_SRC BIT(4) +#define VCONN_EN_VALUE BIT(3) +#define POWER_ROLE_CMD_MASK GENMASK(2, 0) +#define UFP_EN_CMD BIT(2) +#define DFP_EN_CMD BIT(1) +#define TYPEC_DISABLE_CMD BIT(0) + +/* GEN1 TYPEC_PBS_WA_BIT workaround used by the downstream SMB2 driver. */ +#define MISC_BASE_OFFSET 0x300 +#define TM_IO_DTEST4_SEL 0xe9 +#define PBS_CRUDE_SENSOR_ENABLE 0xa5 + +/* Interrupt numbers */ +#define PMIC_TYPEC_CHANGE_IRQ 0x0 + +struct gen1_typec_port { +struct device *dev; +struct tcpm_port *tcpm_port; +struct regmap *regmap;
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port_gen1.c line 95
Quoted 10 lines
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port_gen1.c new file +10
-0+u32 base; +int irq; + +struct regulator *vbus; +bool vbus_enabled; +bool vbus_present; +bool vbus_valid; +struct mutex lock;/* serializes register RMW and VBUS state */ +}; +
Existing data-structure is :
struct pmic_typec_port {
struct device *dev;
struct tcpm_port *tcpm_port;
struct regmap *regmap;
u32 base;
unsigned int nr_irqs;
struct pmic_typec_port_irq_data *irq_data;
struct regulator *vdd_vbus;
bool vbus_enabled;
struct mutex vbus_lock; /* VBUS state serialization */
int cc;
bool debouncing_cc;
struct delayed_work cc_debounce_dwork; spinlock_t lock; /* Register atomicity */
};
Just re-use that one - also that way we ahe a consistent aproach to locking.
At the worst case you guys need to add .vbus_present ?
It seems weird to me to have one version of the port use spinlock with another using mutex - which leads to other questions down below.
Quoted 13 lines
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port_gen1.c new file +13
-0+const struct pmic_typec_port_resources gen1_port_res = { + .nr_irqs =1 , + .irq_params = { + { + .irq_name ="type-c-change" , + .virq =PMIC_TYPEC_CHANGE_IRQ , + }, + }, +}; + +/* +* Failure of this workaround write is non-fatal and +* we can continue with the role transition.
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port_gen1.c line 118
Quoted 10 lines
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port_gen1.c new file +10
-0+*/ +static void gen1_typec_pbs_wa (struct gen1_typec_port *port,bool sink) +{ +unsigned int val = sink ?0 :PBS_CRUDE_SENSOR_ENABLE ; +int ret; + + ret =regmap_write (port->regmap, port->base + +MISC_BASE_OFFSET +TM_IO_DTEST4_SEL , val); +if (!ret) +return ;
Why would the write fail and why wouldn't that be a critical case if the write did fail ?
Quoted 67 lines
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port_gen1.c new file +67
-0+dev_warn (port->dev, +"failed to update GEN1 Type-C PBS workaround: %d\n" , + ret); +} + +static int gen1_typec_set_power_role (struct gen1_typec_port *port, +unsigned int role) +{ +int ret; + +gen1_typec_pbs_wa (port, role ==UFP_EN_CMD ); + + ret =regmap_update_bits (port->regmap, + port->base +TYPEC_SW_CTRL_REG , +POWER_ROLE_CMD_MASK , role); +if (ret) +dev_err (port->dev,"failed to set Type-C power role: %d\n" , ret); + +return ret; +} + +static int gen1_typec_get_vbus (struct tcpc_dev *tcpc) +{ +struct pmic_typec *tcpm =tcpc_to_tcpm (tcpc); +struct gen1_typec_port *port = tcpm->pmic_typec_port; +unsigned int status; +int ret; + +mutex_lock (&port->lock); + ret =regmap_read (port->regmap, port->base + +TYPEC_STATUS_4_REG , &status); +if (ret) + ret = port->vbus_enabled; +else + ret = port->vbus_enabled || !!(status &TYPEC_VBUS_STATUS ); +mutex_unlock (&port->lock); + +return ret; +} + +static int gen1_typec_set_vbus (struct tcpc_dev *tcpc,bool on,bool sink) +{ +struct pmic_typec *tcpm =tcpc_to_tcpm (tcpc); +struct gen1_typec_port *port = tcpm->pmic_typec_port; +bool changed = false; +int ret =0 ; + +if (!port->vbus) +return 0 ; + +mutex_lock (&port->lock); + +if (port->vbus_enabled == on) + goto out; + +if (on) + ret =regulator_enable (port->vbus); +else + ret =regulator_disable (port->vbus); + +if (!ret) { + port->vbus_enabled = on; + changed = true; + } + +out: +mutex_unlock (&port->lock);
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port_gen1.c line 196
Quoted 10 lines
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port_gen1.c new file +10
-0+ +/* +* set_vbus() may run during tcpm_register_port() before port_start() +* provides tcpm_port. Once registered, notify TCPM whenever the +* source regulator actually changes state. get_vbus() also accounts +* for vbus_enabled when GEN1 does not reflect sourced VBUS in +* TYPEC_VBUS_STATUS. +*/ +if (changed && port->tcpm_port) +tcpm_vbus_change (port->tcpm_port);
This describes a race condition which is implied in the existing code no ?
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port_gen1.c line 139
Quoted 3 lines
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port_gen1.c new file +3
-0+ +return ret; +}
The get() I agree with the set() I'm not so sure.
Looking at the original:
static int qcom_pmic_typec_port_set_vbus(struct tcpc_dev *tcpc, bool on, bool sink)
{
struct pmic_typec *tcpm = tcpc_to_tcpm(tcpc);
struct pmic_typec_port *pmic_typec_port = tcpm->pmic_typec_port;
int ret = 0;
mutex_lock(&pmic_typec_port->vbus_lock);
if (pmic_typec_port->vbus_enabled == on)
goto done;
ret = qcom_pmic_typec_port_vbus_toggle(pmic_typec_port, on);
if (ret)
goto done;
pmic_typec_port->vbus_enabled = on;
tcpm_vbus_change(tcpm->tcpm_port);done:
dev_dbg(tcpm->dev, "set_vbus set: %d result %d\n", on, ret);
mutex_unlock(&pmic_typec_port->vbus_lock);
return ret;
}Why would the logic be substantially different to that ?
If such a race exists why is the solution not to have vbus_lock own the assignement of tcpm_port - and why not hold that lock for the durection of set_vbus as is done with pm8150b ?
reads code...
vbus_lock is supposed to own the vbus state is why - the point remains how is tcpm_port racy and why is that raciness unique to this particular version of set_vbus () ?
Quoted 395 lines
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port_gen1.c new file +395
-0+static int gen1_typec_get_cc (struct tcpc_dev *tcpc, +enum typec_cc_status *cc1, +enum typec_cc_status *cc2) +{ +struct pmic_typec *tcpm =tcpc_to_tcpm (tcpc); +struct gen1_typec_port *port = tcpm->pmic_typec_port; +enum typec_cc_status active =TYPEC_CC_OPEN ; +unsigned int status1, status2, status4; +bool orientation_cc2; +int ret; + + *cc1 =TYPEC_CC_OPEN ; + *cc2 =TYPEC_CC_OPEN ; + +mutex_lock (&port->lock); + + ret =regmap_read (port->regmap, port->base + +TYPEC_STATUS_4_REG , &status4); +if (ret) + goto out; + +if (!(status4 &CC_ATTACHED )) + goto out; + +/* +* CC is not stable until tCCDebounce has elapsed. TCPM ignores +* -EBUSY and the DEBOUNCE_DONE interrupt triggers a new read. +*/ +if (!(status4 &TYPEC_DEBOUNCE_DONE )) { + ret = -EBUSY ; + goto out; + } + + ret =regmap_read (port->regmap, port->base + +TYPEC_STATUS_1_REG , &status1); +if (ret) + goto out; + + ret =regmap_read (port->regmap, port->base + +TYPEC_STATUS_2_REG , &status2); +if (ret) + goto out; + + orientation_cc2 = !!(status4 &CC_ORIENTATION ); + +if (status4 &UFP_DFP_MODE_STATUS ) { +/* Local port is DFP/source; decode the partner's Rd/Ra. */ +switch (status2 &DFP_TYPEC_MASK ) { +case DFP_RA_RA : + *cc1 =TYPEC_CC_RA ; + *cc2 =TYPEC_CC_RA ; + goto out; +case DFP_RD_RD : + *cc1 =TYPEC_CC_RD ; + *cc2 =TYPEC_CC_RD ; + goto out; +case DFP_RD_RA_VCONN : + active =TYPEC_CC_RD ; + *cc1 =TYPEC_CC_RA ; + *cc2 =TYPEC_CC_RA ; +break ; +case DFP_RD_OPEN : + active =TYPEC_CC_RD ; +break ; +default : +dev_dbg (port->dev,"unhandled GEN1 DFP status %#x\n" , + status2); + goto out; + } + }else { +/* Local port is UFP/sink; decode the partner's advertised Rp. */ +switch (status1 &UFP_TYPEC_MASK ) { +case UFP_TYPEC_RDSTD : + active =TYPEC_CC_RP_DEF ; +break ; +case UFP_TYPEC_RD1P5 : + active =TYPEC_CC_RP_1_5 ; +break ; +case UFP_TYPEC_RD3P0 : + active =TYPEC_CC_RP_3_0 ; +break ; +default : +dev_dbg (port->dev,"unhandled GEN1 UFP status %#x\n" , + status1); + goto out; + } + } + +if (orientation_cc2) + *cc2 = active; +else + *cc1 = active; + +out: +mutex_unlock (&port->lock); +return ret; +} + +static int gen1_typec_set_cc (struct tcpc_dev *tcpc, +enum typec_cc_status cc) +{ +struct pmic_typec *tcpm =tcpc_to_tcpm (tcpc); +struct gen1_typec_port *port = tcpm->pmic_typec_port; +unsigned int role; +unsigned int rp_current =0 ; +int ret; + +switch (cc) { +case TYPEC_CC_OPEN : + role =TYPEC_DISABLE_CMD ; +break ; +case TYPEC_CC_RD : + role =UFP_EN_CMD ; +break ; +case TYPEC_CC_RP_DEF : + role =DFP_EN_CMD ; + rp_current =0 ; +break ; +case TYPEC_CC_RP_1_5 : +case TYPEC_CC_RP_3_0 : +/* +* GEN1 can only source 80 uA (default) or 180 uA (1.5 A). +* Advertise 1.5 A for 3.0 A requests, TCPM ignores set_cc() +* errors and would otherwise keep a stale Rp. +*/ + role =DFP_EN_CMD ; + rp_current =EN_80UA_180UA_CUR_SOURCE ; +break ; +default : +return -EINVAL ; + } + +mutex_lock (&port->lock); + +if (role ==DFP_EN_CMD ) { + ret =regmap_update_bits (port->regmap, + port->base +TYPEC_CFG_2_REG , +EN_80UA_180UA_CUR_SOURCE , + rp_current); +if (ret) + goto out; + } + + ret =gen1_typec_set_power_role (port, role); + +out: +mutex_unlock (&port->lock); +return ret; +} + +static int gen1_typec_set_polarity (struct tcpc_dev *tcpc, +enum typec_cc_polarity polarity) +{ +/* USB PHY orientation is handled outside this PMIC Type-C block. */ +return 0 ; +} + +static int gen1_typec_set_vconn (struct tcpc_dev *tcpc,bool on) +{ +struct pmic_typec *tcpm =tcpc_to_tcpm (tcpc); +struct gen1_typec_port *port = tcpm->pmic_typec_port; +unsigned int status4, orientation, mask, val; +int ret; + +mutex_lock (&port->lock); + + ret =regmap_read (port->regmap, port->base + +TYPEC_STATUS_4_REG , &status4); +if (ret) + goto out; + +/* VCONN is driven on the inactive CC pin. */ + orientation = (status4 &CC_ORIENTATION ) ? +0 :VCONN_EN_ORIENTATION ; + +if (on) { + mask =VCONN_EN_ORIENTATION |VCONN_EN_VALUE ; + val = orientation |VCONN_EN_VALUE ; + }else { + mask =VCONN_EN_VALUE ; + val =0 ; + } + + ret =regmap_update_bits (port->regmap, + port->base +TYPEC_SW_CTRL_REG , + mask, val); + +out: +mutex_unlock (&port->lock); +return ret; +} + +static int gen1_typec_start_toggling (struct tcpc_dev *tcpc, +enum typec_port_type port_type, +enum typec_cc_status cc) +{ +struct pmic_typec *tcpm =tcpc_to_tcpm (tcpc); +struct gen1_typec_port *port = tcpm->pmic_typec_port; +unsigned int role; +unsigned int try_src =0 ; +unsigned int try_snk =0 ; +int ret; + +switch (port_type) { +case TYPEC_PORT_SRC : + role =DFP_EN_CMD ; +break ; +case TYPEC_PORT_SNK : + role =UFP_EN_CMD ; +break ; +case TYPEC_PORT_DRP : + role =0 ; +/* +* Like the PM8150B backend, keep hardware Try.SNK enabled +* while TCPM owns the policy state machine. +*/ + try_snk =EN_TRYSINK_MODE ; +break ; +default : +return -EINVAL ; + } + +mutex_lock (&port->lock); + + ret =regmap_update_bits (port->regmap, + port->base +TYPEC_CFG_2_REG , +EN_TRY_SOURCE_MODE , try_src); +if (ret) + goto out; + + ret =regmap_update_bits (port->regmap, + port->base +TYPEC_CFG_3_REG , +EN_TRYSINK_MODE , try_snk); +if (ret) + goto out; + +/* Disable first so the state machine restarts toggling. */ + ret =gen1_typec_set_power_role (port,TYPEC_DISABLE_CMD ); +if (ret) + goto out; + + ret =gen1_typec_set_power_role (port, role); + +out: +mutex_unlock (&port->lock); +return ret; +} + +static irqreturn_t gen1_typec_irq (int irq,void *data) +{ +struct gen1_typec_port *port = data; +unsigned int status4; +bool vbus; +bool vbus_changed = false; + +/* +* GEN1 exposes a single aggregate Type-C change interrupt. Always +* notify TCPM of CC changes. Only generate a VBUS event when the +* hardware VBUS state changes, or on the first observation so TCPM +* can establish the initial vSafe0V state. +*/ +mutex_lock (&port->lock); + +if (!regmap_read (port->regmap, port->base + +TYPEC_STATUS_4_REG , &status4)) { +if (status4 &TYPEC_VBUS_ERROR ) +dev_warn_ratelimited (port->dev,"Type-C VBUS error\n" ); + + vbus = !!(status4 &TYPEC_VBUS_STATUS ); + +if (!port->vbus_valid || vbus != port->vbus_present) { + port->vbus_present = vbus; + port->vbus_valid = true; + vbus_changed = true; + } + } + +mutex_unlock (&port->lock); + +if (port->tcpm_port) { +if (vbus_changed) +tcpm_vbus_change (port->tcpm_port); + +tcpm_cc_change (port->tcpm_port); + } + +return IRQ_HANDLED ; +} + +static int gen1_typec_port_start (struct pmic_typec *tcpm, +struct tcpm_port *tcpm_port) +{ +struct gen1_typec_port *port = tcpm->pmic_typec_port; +unsigned int irq_mask; +int ret; + +/* +* TYPE_C_OR_U_USB == 0 selects the Type-C state machine on GEN1. +*/ + ret =regmap_update_bits (port->regmap, + port->base +TYPEC_CFG_REG , +TYPEC_OR_U_USB ,0 ); +if (ret) +return ret; + +/* +* GEN1 exposes a single aggregate type-c-change interrupt, the +* handler re-reads TYPEC_STATUS_4 to find out what changed. +*/ + irq_mask =CCSTATE_CHANGE_INT_EN |DEBOUNCE_DONE_INT_EN | +VBUS_ASSERT_INT_EN |VBUS_DEASSERT_INT_EN | +VBUS_ERROR_INT_EN ; + + ret =regmap_write (port->regmap, + port->base +TYPEC_INTRPT_ENB_REG , + irq_mask); +if (ret) +return ret; + +/* Select software control for VCONN, initially disabled. */ + ret =regmap_update_bits (port->regmap, + port->base +TYPEC_SW_CTRL_REG , +VCONN_EN_SRC |VCONN_EN_VALUE , +VCONN_EN_SRC ); +if (ret) +return ret; + + port->tcpm_port = tcpm_port; +enable_irq (port->irq); + +return 0 ; +} + +static void gen1_typec_port_stop (struct pmic_typec *tcpm) +{ +struct gen1_typec_port *port = tcpm->pmic_typec_port; + +disable_irq (port->irq); + port->tcpm_port =NULL ; +} + +int qcom_pmic_typec_gen1_port_probe (struct platform_device *pdev, +struct pmic_typec *tcpm, +const struct pmic_typec_port_resources *res, +struct regmap *regmap, +u32 base) +{ +struct device *dev = &pdev->dev; +struct gen1_typec_port *port; +struct fwnode_handle *connector; +int ret; + +if (!res->nr_irqs || res->nr_irqs >PMIC_TYPEC_MAX_IRQS ) +return -EINVAL ; + + port =devm_kzalloc (dev,sizeof (*port),GFP_KERNEL ); +if (!port) +return -ENOMEM ; + + connector =device_get_named_child_node (dev,"connector" ); +if (!connector) +return -EINVAL ; + + port->vbus =devm_of_regulator_get_optional (dev, +to_of_node (connector), +"vbus" ); +fwnode_handle_put (connector); +if (IS_ERR (port->vbus)) { +if (PTR_ERR (port->vbus) != -ENODEV ) +return PTR_ERR (port->vbus); + port->vbus =NULL ; + } + + port->irq =platform_get_irq_byname (pdev, + res->irq_params[0 ].irq_name); +if (port->irq <0 ) +return port->irq; + + port->dev = dev; + port->regmap = regmap; + port->base = base; +mutex_init (&port->lock); + + ret =devm_request_threaded_irq (dev, port->irq,NULL , + gen1_typec_irq, +IRQF_ONESHOT |IRQF_NO_AUTOEN , + res->irq_params[0 ].irq_name, port); +if (ret) +return ret; + + tcpm->pmic_typec_port = port; + + tcpm->tcpc.get_vbus = gen1_typec_get_vbus; + tcpm->tcpc.set_vbus = gen1_typec_set_vbus; + tcpm->tcpc.get_cc = gen1_typec_get_cc;
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port_gen1.c line 605
Quoted 10 lines
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port_gen1.c new file +10
-0+ tcpm->tcpc.set_cc = gen1_typec_set_cc; + tcpm->tcpc.set_polarity = gen1_typec_set_polarity; + tcpm->tcpc.set_vconn = gen1_typec_set_vconn; + tcpm->tcpc.start_toggling = gen1_typec_start_toggling; + + tcpm->port_start = gen1_typec_port_start; + tcpm->port_stop = gen1_typec_port_stop; + +return 0 ; +}
This probe function is 1:1 with the existing code for a number of lines => functional decompositon and code reuse - breaking out if/where it is warranted.
So that's my overall comment here - code sharing except where it cannot be sustained which implies a shared data-structure, consistent type of locks and IMO consistent taking and releasing of those locks.
set_vbus could surely have a generic function where we represent the _logic_ of what we mean better/consistently instead of clone/own and potentially substantial differentation between the two schemes in the one driver.
Quoted 22 lines
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port_gen1.h new file +15
-0@@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef __QCOM_PMIC_TYPEC_PORT_GEN1_H__ +#define __QCOM_PMIC_TYPEC_PORT_GEN1_H__ + +#include "qcom_pmic_typec_port.h" + +extern const struct pmic_typec_port_resources gen1_port_res; + +int qcom_pmic_typec_gen1_port_probe (struct platform_device *pdev, +struct pmic_typec *tcpm, +const struct pmic_typec_port_resources *res, +struct regmap *regmap, +u32 base); + +#endif /* __QCOM_PMIC_TYPEC_PORT_GEN1_H__ */
Re: [PATCH RFC 06/12] usb: typec: qcom: Add gen1 Type-C port support
Quoted 36 lines · Bryan O'Donoghue
Quoted 35 lines · On 26/09/2026 13:40, David Heidelberg via B4 Relay wrote:
From: David Heidelberg <[email protected]>
Add a port backend for the first generation of the Qualcomm PMIC Type-C block, found on PM660 and PMI8998.
On gen1 the Type-C CC logic is part of the charger's USBIN peripheral (base
0x1300) instead of the standalone Type-C peripheral used by PM8150B and later PMICs. All Type-C events (CC state change, tCCDebounce done, VBUS change and error) are signalled through a single aggregate "type-c-change" interrupt, the handler re-readsTYPEC_STATUS_4to find out what changed. The PD PHY is register compatible with PM8150B and is reused as is.Differences to the PM8150B backend:
-get_cc()returns-EBUSYuntil the hardware reports tCCDebounce done, instead of using a software debounce.
- As a source, only the default and 1.5A Rp can be advertised, 3.0A requests are advertised as 1.5A.
- The PBS workaround of the downstream SMB2 driver (TM_IO_DTEST4_SEL) is applied on every power role change.VBUS sourcing is optional and only used when the connector provides a vbus-supply, as the charger doesn't expose a VBUS regulator yet.
Assisted-by LLMCo-developed-by Alexey Minnekhanov <[email protected]>Signed-off-by Alexey Minnekhanov <[email protected]>Signed-off-by David Heidelberg <[email protected]>---
drivers/usb/typec/tcpm/qcom/Makefile | 1 + drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c | 9 + .../typec/tcpm/qcom/qcom_pmic_typec_port_gen1.c | 605 +++++++++++++++++++++ .../typec/tcpm/qcom/qcom_pmic_typec_port_gen1.h | 15 +4 files changed, 630 insertions(+)
[...]
Quoted 7 lines
Quoted 7 lines
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port_gen1.c new file +7
-0+/* +* Failure of this workaround write is non-fatal and +* we can continue with the role transition. +*/ +static void gen1_typec_pbs_wa (struct gen1_typec_port *port,bool sink) +{ + unsigned int val = sink ? 0 : PBS_CRUDE_SENSOR_ENABLE;
Quoted 8 lines
Quoted 6 lines
+ int ret;
+
+ ret =regmap_write(port->regmap, port->base + + MISC_BASE_OFFSET + TM_IO_DTEST4_SEL, val); + if (!ret)
+ return;Why would the write fail and why wouldn't that be a critical case if the write did fail ?
Heya Bryan,
thanks a lot for reviewing the series. For the rest notes, I'll incorporate that and/or think about it later. Here to quickly answer to this note,
this one quirk is definitely NOT REQUIRED. Originally, I was testing the driver without it on sdm845 devices, and everything worked without it just fine. I ASSUME in some situation or with some devices combination it may come handy, thus likely if it fails, not much usually happens (and clanker was suggesting to port this one from downstream, so I did).
David
[...]
Bryan O'Donoghue
maintainerRe: [PATCH RFC 06/12] usb: typec: qcom: Add gen1 Type-C port support
Quoted 59 lines · David Heidelberg
Quoted 37 lines · Bryan O'Donoghue
Quoted 36 lines · On 26/09/2026 13:40, David Heidelberg via B4 Relay wrote:
From: David Heidelberg <[email protected]>
Add a port backend for the first generation of the Qualcomm PMIC Type-C block, found on PM660 and PMI8998.
On gen1 the Type-C CC logic is part of the charger's USBIN peripheral (base
0x1300) instead of the standalone Type-C peripheral used by PM8150B and later PMICs. All Type-C events (CC state change, tCCDebounce done, VBUS change and error) are signalled through a single aggregate "type-c-change" interrupt, the handler re-readsTYPEC_STATUS_4to find out what changed. The PD PHY is register compatible with PM8150B and is reused as is.Differences to the PM8150B backend:
-get_cc()returns-EBUSYuntil the hardware reports tCCDebounce done, instead of using a software debounce.
- As a source, only the default and 1.5A Rp can be advertised, 3.0A requests are advertised as 1.5A.
- The PBS workaround of the downstream SMB2 driver (TM_IO_DTEST4_SEL) is applied on every power role change.VBUS sourcing is optional and only used when the connector provides a vbus-supply, as the charger doesn't expose a VBUS regulator yet.
Assisted-by LLMCo-developed-by Alexey Minnekhanov <[email protected]>Signed-off-by Alexey Minnekhanov <[email protected]>Signed-off-by David Heidelberg <[email protected]>---
drivers/usb/typec/tcpm/qcom/Makefile | 1 + drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c | 9 + .../typec/tcpm/qcom/qcom_pmic_typec_port_gen1.c | 605 ++++++++++
+++++++++++
.../typec/tcpm/qcom/qcom_pmic_typec_port_gen1.h | 15 +4 files changed, 630 insertions(+)[...]
Quoted 7 lines
Quoted 7 lines
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port_gen1.c new file +7
-0+/* +* Failure of this workaround write is non-fatal and +* we can continue with the role transition. +*/ +static void gen1_typec_pbs_wa (struct gen1_typec_port *port,bool sink) +{ + unsigned int val = sink ? 0 : PBS_CRUDE_SENSOR_ENABLE;Quoted 8 lines
Quoted 6 lines
+ int ret;
+
+ ret =regmap_write(port->regmap, port->base + + MISC_BASE_OFFSET + TM_IO_DTEST4_SEL, val); + if (!ret)
+ return;Why would the write fail and why wouldn't that be a critical case if the write did fail ?
Heya Bryan,
Quoted 7 lines
thanks a lot for reviewing the series. For the rest notes, I'll incorporate that and/or think about it later. Here to quickly answer to this note,
this one quirk is definitely NOT REQUIRED. Originally, I was testing the driver without it on sdm845 devices, and everything worked without it just fine. I ASSUME in some situation or with some devices combination it may come handy, thus likely if it fails, not much usually happens (and clanker was suggesting to port this one from downstream, so I did).
David
[...]
I ran this code though an LLM and it is babbling about the "shape" of things to hand you LoL.
Anyway the pattern matching part flagged this:
"Write outside the node's reg. base + MISC_BASE_OFFSET + TM_IO_DTEST4_SEL is 0x16e9, the MISC peripheral. 03 declares reg = <USBIN>, <PDPHY> only."
Worth also verifying.
---
bod
Re: [PATCH RFC 06/12] usb: typec: qcom: Add gen1 Type-C port support
Quoted 68 lines · Bryan O'Donoghue
Quoted 59 lines · David Heidelberg
Quoted 37 lines · Bryan O'Donoghue
Quoted 36 lines · On 26/09/2026 13:40, David Heidelberg via B4 Relay wrote:
From: David Heidelberg <[email protected]>
Add a port backend for the first generation of the Qualcomm PMIC Type-C block, found on PM660 and PMI8998.
On gen1 the Type-C CC logic is part of the charger's USBIN peripheral (base
0x1300) instead of the standalone Type-C peripheral used by PM8150B and later PMICs. All Type-C events (CC state change, tCCDebounce done, VBUS change and error) are signalled through a single aggregate "type-c-change" interrupt, the handler re-readsTYPEC_STATUS_4to find out what changed. The PD PHY is register compatible with PM8150B and is reused as is.Differences to the PM8150B backend:
-get_cc()returns-EBUSYuntil the hardware reports tCCDebounce done, instead of using a software debounce.
- As a source, only the default and 1.5A Rp can be advertised, 3.0A requests are advertised as 1.5A.
- The PBS workaround of the downstream SMB2 driver (TM_IO_DTEST4_SEL) is applied on every power role change.VBUS sourcing is optional and only used when the connector provides a vbus-supply, as the charger doesn't expose a VBUS regulator yet.
Assisted-by LLMCo-developed-by Alexey Minnekhanov <[email protected]>Signed-off-by Alexey Minnekhanov <[email protected]>Signed-off-by David Heidelberg <[email protected]>---
drivers/usb/typec/tcpm/qcom/Makefile | 1 + drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c | 9 + .../typec/tcpm/qcom/qcom_pmic_typec_port_gen1.c | 605 ++++++++++ ++++++
+++++
.../typec/tcpm/qcom/qcom_pmic_typec_port_gen1.h | 15 +4 files changed, 630 insertions(+)[...]
Quoted 7 lines
Quoted 7 lines
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port_gen1.c new file +7
-0+/* +* Failure of this workaround write is non-fatal and +* we can continue with the role transition. +*/ +static void gen1_typec_pbs_wa (struct gen1_typec_port *port,bool sink) +{ + unsigned int val = sink ? 0 : PBS_CRUDE_SENSOR_ENABLE;Quoted 8 lines
Quoted 6 lines
+ int ret;
+
+ ret =regmap_write(port->regmap, port->base + + MISC_BASE_OFFSET + TM_IO_DTEST4_SEL, val); + if (!ret)
+ return;Why would the write fail and why wouldn't that be a critical case if the write did fail ?
Heya Bryan,
Quoted 7 lines
thanks a lot for reviewing the series. For the rest notes, I'll incorporate that and/or think about it later. Here to quickly answer to this note,
this one quirk is definitely NOT REQUIRED. Originally, I was testing the driver without it on sdm845 devices, and everything worked without it just fine. I ASSUME in some situation or with some devices combination it may come handy, thus likely if it fails, not much usually happens (and clanker was suggesting to port this one from downstream, so I did).
David
[...]
Quoted 7 lines
I ran this code though an LLM and it is babbling about the "shape" of things to hand you LoL.
Anyway the pattern matching part flagged this:
"Write outside the node's reg. base +
MISC_BASE_OFFSET+TM_IO_DTEST4_SELis0x16e9, the MISC peripheral. 03 declares reg = <USBIN>, <PDPHY> only."Worth also verifying.
Yup, I explicitly split the addr into MISC_BASE_OFFSET, as it's pretty much outside of this block range (same reason why I haven't sent the vbus patches for qcom smbx charger).
Maybe Konrad with more insight can tell more about it. In the Type-C submission I can pretty much confidently drop it (if it'll need separate driver) and still assure users get expected functionality.
David
Quoted 3 lines
---
bod
Re: [PATCH RFC 06/12] usb: typec: qcom: Add gen1 Type-C port support
In reply to Bryan O'DonoghueQuoted 99 lines · Bryan O'Donoghue
Quoted 85 lines · On 26/09/2026 13:40, David Heidelberg via B4 Relay wrote:
From: David Heidelberg <[email protected]>
Add a port backend for the first generation of the Qualcomm PMIC Type-C block, found on PM660 and PMI8998.
On gen1 the Type-C CC logic is part of the charger's USBIN peripheral (base
0x1300) instead of the standalone Type-C peripheral used by PM8150B and later PMICs. All Type-C events (CC state change, tCCDebounce done, VBUS change and error) are signalled through a single aggregate "type-c-change" interrupt, the handler re-readsTYPEC_STATUS_4to find out what changed. The PD PHY is register compatible with PM8150B and is reused as is.Differences to the PM8150B backend:
-get_cc()returns-EBUSYuntil the hardware reports tCCDebounce done, instead of using a software debounce.
- As a source, only the default and 1.5A Rp can be advertised, 3.0A requests are advertised as 1.5A.
- The PBS workaround of the downstream SMB2 driver (TM_IO_DTEST4_SEL) is applied on every power role change.VBUS sourcing is optional and only used when the connector provides a vbus-supply, as the charger doesn't expose a VBUS regulator yet.
Assisted-by LLMCo-developed-by Alexey Minnekhanov <[email protected]>Signed-off-by Alexey Minnekhanov <[email protected]>Signed-off-by David Heidelberg <[email protected]>---
drivers/usb/typec/tcpm/qcom/Makefile | 1 + drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c | 9 + .../typec/tcpm/qcom/qcom_pmic_typec_port_gen1.c | 605 +++++++++++++++++++++ .../typec/tcpm/qcom/qcom_pmic_typec_port_gen1.h | 15 +4 files changed, 630 insertions(+)drivers/usb/typec/tcpm/qcom/Makefile +0
-0@@ -1,7 +1,8 @@ # SPDX-License-Identifier: GPL-2.0 #obj-$(CONFIG_TYPEC_QCOM_PMIC) += qcom_pmic_tcpm.o qcom_pmic_tcpm-y += qcom_pmic_typec.o \
qcom_pmic_typec_port.o \
+ qcom_pmic_typec_port_gen1.o \
qcom_pmic_typec_pdphy.o \
qcom_pmic_typec_pdphy_stub.o \drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c +7
-0@@ -12,16 +12,17 @@ #include <linux/slab.h> #include <linux/usb/tcpm.h> #include <drm/bridge/aux-bridge.h> #include "qcom_pmic_typec.h" #include "qcom_pmic_typec_pdphy.h" #include "qcom_pmic_typec_port.h" +#include "qcom_pmic_typec_port_gen1.h" typedef int (*pmic_typec_port_probe_fn)(struct platform_device *pdev, struct pmic_typec *tcpm, const struct pmic_typec_port_resources *res, struct regmap *regmap, u32 base); struct pmic_typec_resources { const struct pmic_typec_pdphy_resources *pdphy_res;@@ -134,31 +135,39 @@ static void qcom_pmic_typec_remove(struct platform_device *pdev) struct pmic_typec *tcpm = platform_get_drvdata(pdev); tcpm->pdphy_stop(tcpm); tcpm->port_stop(tcpm); tcpm_unregister_port(tcpm->tcpm_port); fwnode_handle_put(tcpm->tcpc.fwnode); } +static const struct pmic_typec_resources gen1_typec_res = { + .pdphy_res = &pm8150b_pdphy_res, + .port_res = &gen1_port_res, + .port_probe = qcom_pmic_typec_gen1_port_probe, +}; + static const struct pmic_typec_resources pm8150b_typec_res = { .pdphy_res = &pm8150b_pdphy_res, .port_res = &pm8150b_port_res, .port_probe = qcom_pmic_typec_port_probe, };drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c static void qcom_pmic_typec_remove(struct · line 162
Quoted 10 lines
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c +2
-0static const struct pmic_typec_resources pmi632_typec_res = { /* PD PHY not present */ .port_res = &pm8150b_port_res, .port_probe = qcom_pmic_typec_port_probe, }; static const struct of_device_id qcom_pmic_typec_table[] = { + { .compatible = "qcom,pm660-typec", .data = &gen1_typec_res }, { .compatible = "qcom,pm8150b-typec", .data = &pm8150b_typec_res }, { .compatible = "qcom,pmi632-typec", .data = &pmi632_typec_res }, + { .compatible = "qcom,pmi8998-typec", .data = &gen1_typec_res },I think this should be
Quoted 6 lines
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c static void qcom_pmic_typec_remove(struct platform_device *pdev)
Quoted 4 lines
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c +2
-0+ { .compatible = "qcom,pm660-typec", .data = &pm660_typec_res }, { .compatible = "qcom,pm8150b-typec", .data = &pm8150b_typec_res }, { .compatible = "qcom,pmi632-typec", .data = &pmi632_typec_res }, + { .compatible = "qcom,pmi8998-typec", .data = &pmi8998_typec_res },Since I'm not sure "gen1" is a real thing and besides, I see this gen1/gen2/gen3 stuff in CAMSS and it means almost nothing. The silicon version is the salient thing.
Best I can do is GenZ.
But now seriously, I hoped someone from Qualcomm will chime in and tells me how is this type-c block generation properly called.
David
[...]
Re: [PATCH RFC 06/12] usb: typec: qcom: Add gen1 Type-C port support
Quoted 40 lines · David Heidelberg
Quoted 39 lines · Bryan O'Donoghue
Quoted 25 lines · On 26/09/2026 13:40, David Heidelberg via B4 Relay wrote:
From: David Heidelberg <[email protected]>
Add a port backend for the first generation of the Qualcomm PMIC Type-C block, found on PM660 and PMI8998.
On gen1 the Type-C CC logic is part of the charger's USBIN peripheral (base
0x1300) instead of the standalone Type-C peripheral used by PM8150B and later PMICs. All Type-C events (CC state change, tCCDebounce done, VBUS change and error) are signalled through a single aggregate "type-c-change" interrupt, the handler re-readsTYPEC_STATUS_4to find out what changed. The PD PHY is register compatible with PM8150B and is reused as is.Differences to the PM8150B backend:
-get_cc()returns-EBUSYuntil the hardware reports tCCDebounce done, instead of using a software debounce.
- As a source, only the default and 1.5A Rp can be advertised, 3.0A requests are advertised as 1.5A.
- The PBS workaround of the downstream SMB2 driver (TM_IO_DTEST4_SEL) is applied on every power role change.VBUS sourcing is optional and only used when the connector provides a vbus-supply, as the charger doesn't expose a VBUS regulator yet.
Quoted 5 lines
static const struct
of_device_idqcom_pmic_typec_table[] = { + { .compatible = "qcom,pm660-typec", .data =&gen1_typec_res}, { .compatible = "qcom,pm8150b-typec", .data =&pm8150b_typec_res}, { .compatible = "qcom,pmi632-typec", .data =&pmi632_typec_res}, + { .compatible = "qcom,pmi8998-typec", .data =&gen1_typec_res},I think this should be
Quoted 4 lines
+ { .compatible = "qcom,pm660-typec", .data =
&pm660_typec_res}, { .compatible = "qcom,pm8150b-typec", .data =&pm8150b_typec_res}, { .compatible = "qcom,pmi632-typec", .data =&pmi632_typec_res}, + { .compatible = "qcom,pmi8998-typec", .data =&pmi8998_typec_res},
Quoted 7 lines
Quoted 3 lines
Since I'm not sure "gen1" is a real thing and besides, I see this gen1/gen2/gen3 stuff in CAMSS and it means almost nothing. The silicon version is the salient thing.
Best I can do is GenZ.
But now seriously, I hoped someone from Qualcomm will chime in and tells me how is this type-c block generation properly called.
Just use PMIC name, please. It's the easiest and the simplest option.
Signature · 2 lines
With best wishes Dmitry
RFC PATCH 7/12 arm64: dts: qcom: pm660: Add USB Type-C port controller node
In reply to David HeidelbergFrom: Alexey Minnekhanov <[email protected]>
Add the PM660 Type-C port controller and PD PHY device node.
As on PMI8998, the Type-C CC logic is part of the charger's USBIN peripheral at 0x1300, the PD PHY is at 0x1700. The node uses the 'type-c-change' interrupt from the USBIN peripheral for CC state notifications, plus the 8 PD PHY interrupts, including fr-swap.
The node is disabled by default; individual boards enable it and provide the USB-C connector description with PD capabilities and port graph.
--- arch/arm64/boot/dts/qcom/pm660.dtsi | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
arch/arm64/boot/dts/qcom/pm660.dtsi +27 -0
@@ -85,16 +85,43 @@ pm660_charger: charger@1000 { io-channels = <&pm660_rradc 3>, <&pm660_rradc 4>; io-channel-names = "usbin_i", "usbin_v"; status = "disabled"; }; + pm660_typec: typec@1300 { + compatible = "qcom,pm660-typec"; + reg = <0x1300>, + <0x1700>; + + interrupts = <0x0 0x13 0x7 IRQ_TYPE_EDGE_RISING>, + <0x0 0x17 0x0 IRQ_TYPE_EDGE_RISING>, + <0x0 0x17 0x1 IRQ_TYPE_EDGE_RISING>, + <0x0 0x17 0x2 IRQ_TYPE_EDGE_RISING>, + <0x0 0x17 0x3 IRQ_TYPE_EDGE_RISING>, + <0x0 0x17 0x4 IRQ_TYPE_EDGE_RISING>, + <0x0 0x17 0x5 IRQ_TYPE_EDGE_RISING>, + <0x0 0x17 0x6 IRQ_TYPE_EDGE_RISING>, + <0x0 0x17 0x7 IRQ_TYPE_EDGE_RISING>; + interrupt-names = "type-c-change", + "sig-tx", + "sig-rx", + "msg-tx", + "msg-rx", + "msg-tx-failed", + "msg-tx-discarded", + "msg-rx-discarded", + "fr-swap"; + + status = "disabled"; + }; + pm660_temp: temp-alarm@2400 { compatible = "qcom,spmi-temp-alarm"; reg = <0x2400>; interrupts = <0x0 0x24 0x0 IRQ_TYPE_EDGE_RISING>; io-channels = <&pm660_adc ADC5_DIE_TEMP>; io-channel-names = "thermal"; #thermal-sensor-cells = <0>; };
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH RFC 07/12] arm64: dts: qcom: pm660: Add USB Type-C port controller node
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 9 lines
From: Alexey Minnekhanov <[email protected]>
Add the PM660 Type-C port controller and PD PHY device node.
As on PMI8998, the Type-C CC logic is part of the charger's USBIN peripheral at
0x1300, the PD PHY is at0x1700. The node uses the 'type-c-change' interrupt from the USBIN peripheral for CC state notifications, plus the 8 PD PHY interrupts, including fr-swap.
Quoted 6 lines
The node is disabled by default; individual boards enable it and provide the USB-C connector description with PD capabilities and port graph.
Assisted-by LLMSigned-off-by Alexey Minnekhanov <[email protected]>Signed-off-by David Heidelberg <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=7
Re: [PATCH RFC 07/12] arm64: dts: qcom: pm660: Add USB Type-C port controller node
In reply to David HeidelbergQuoted 58 lines · On 26/09/2026 13:40, David Heidelberg via B4 Relay wrote:
From: Alexey Minnekhanov <[email protected]>
Add the PM660 Type-C port controller and PD PHY device node.
As on PMI8998, the Type-C CC logic is part of the charger's USBIN peripheral at
0x1300, the PD PHY is at0x1700. The node uses the 'type-c-change' interrupt from the USBIN peripheral for CC state notifications, plus the 8 PD PHY interrupts, including fr-swap.The node is disabled by default; individual boards enable it and provide the USB-C connector description with PD capabilities and port graph.
Assisted-by LLMSigned-off-by Alexey Minnekhanov <[email protected]>Signed-off-by David Heidelberg <[email protected]>--- arch/arm64/boot/dts/qcom/pm660.dtsi | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)arch/arm64/boot/dts/qcom/pm660.dtsi +25
-0@@ -85,16 +85,43 @@ pm660_charger: charger@1000 { io-channels = <&pm660_rradc 3>, <&pm660_rradc 4>; io-channel-names = "usbin_i", "usbin_v"; status = "disabled"; }; + pm660_typec: typec@1300 { + compatible = "qcom,pm660-typec"; + reg = <0x1300>, + <0x1700>; + + interrupts = <0x0 0x13 0x7 IRQ_TYPE_EDGE_RISING>, + <0x0 0x17 0x0 IRQ_TYPE_EDGE_RISING>, + <0x0 0x17 0x1 IRQ_TYPE_EDGE_RISING>, + <0x0 0x17 0x2 IRQ_TYPE_EDGE_RISING>, + <0x0 0x17 0x3 IRQ_TYPE_EDGE_RISING>, + <0x0 0x17 0x4 IRQ_TYPE_EDGE_RISING>, + <0x0 0x17 0x5 IRQ_TYPE_EDGE_RISING>, + <0x0 0x17 0x6 IRQ_TYPE_EDGE_RISING>, + <0x0 0x17 0x7 IRQ_TYPE_EDGE_RISING>; + interrupt-names = "type-c-change", + "sig-tx", + "sig-rx", + "msg-tx", + "msg-rx", + "msg-tx-failed", + "msg-tx-discarded", + "msg-rx-discarded", + "fr-swap"; + + status = "disabled";
arch/arm64/boot/dts/qcom/pm660.dtsi pm660_charger: charger@1000 { · line 127
Quoted 10 lines
arch/arm64/boot/dts/qcom/pm660.dtsi +2
-0+ }; + pm660_temp: temp-alarm@2400 { compatible = "qcom,spmi-temp-alarm"; reg = <0x2400>; interrupts = <0x0 0x24 0x0 IRQ_TYPE_EDGE_RISING>; io-channels = <&pm660_adc ADC5_DIE_TEMP>; io-channel-names = "thermal"; #thermal-sensor-cells = <0>; };
RFC PATCH 8/12 arm64: dts: qcom: pmi8998: Add USB Type-C port controller node
In reply to David HeidelbergAdd the pmi8998 Type-C port controller and PD PHY device node.
The Type-C CC logic is at USBIN base 0x1300 and the PD PHY is at 0x1700. The node uses the 'type-c-change' interrupt from the USBIN peripheral for CC state notifications, plus the 8 PD PHY interrupts, including fr-swap.
The node is disabled by default; individual boards enable it and provide the USB-C connector description with PD capabilities and port graph.
--- arch/arm64/boot/dts/qcom/pmi8998.dtsi | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
arch/arm64/boot/dts/qcom/pmi8998.dtsi +27 -0
@@ -24,16 +24,43 @@ pmi8998_charger: charger@1000 { io-channels = <&pmi8998_rradc 3>, <&pmi8998_rradc 4>; io-channel-names = "usbin_i", "usbin_v"; status = "disabled"; }; + pmi8998_typec: typec@1300 { + compatible = "qcom,pmi8998-typec"; + reg = <0x1300>, + <0x1700>; + + interrupts = <0x2 0x13 0x7 IRQ_TYPE_EDGE_RISING>, + <0x2 0x17 0x0 IRQ_TYPE_EDGE_RISING>, + <0x2 0x17 0x1 IRQ_TYPE_EDGE_RISING>, + <0x2 0x17 0x2 IRQ_TYPE_EDGE_RISING>, + <0x2 0x17 0x3 IRQ_TYPE_EDGE_RISING>, + <0x2 0x17 0x4 IRQ_TYPE_EDGE_RISING>, + <0x2 0x17 0x5 IRQ_TYPE_EDGE_RISING>, + <0x2 0x17 0x6 IRQ_TYPE_EDGE_RISING>, + <0x2 0x17 0x7 IRQ_TYPE_EDGE_RISING>; + interrupt-names = "type-c-change", + "sig-tx", + "sig-rx", + "msg-tx", + "msg-rx", + "msg-tx-failed", + "msg-tx-discarded", + "msg-rx-discarded", + "fr-swap"; + + status = "disabled"; + }; + pmi8998_gpios: gpio@c000 { compatible = "qcom,pmi8998-gpio", "qcom,spmi-gpio"; reg = <0xc000>; gpio-controller; gpio-ranges = <&pmi8998_gpios 0 0 14>; #gpio-cells = <2>; interrupt-controller; #interrupt-cells = <2>;
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH RFC 08/12] arm64: dts: qcom: pmi8998: Add USB Type-C port controller node
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 9 lines
From: David Heidelberg <[email protected]>
Add the pmi8998 Type-C port controller and PD PHY device node.
The Type-C CC logic is at USBIN base
0x1300and the PD PHY is at0x1700. The node uses the 'type-c-change' interrupt from the USBIN peripheral for CC state notifications, plus the 8 PD PHY interrupts, including fr-swap.
Quoted 5 lines
The node is disabled by default; individual boards enable it and provide the USB-C connector description with PD capabilities and port graph.
Assisted-by LLMSigned-off-by David Heidelberg <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=8
Re: [PATCH RFC 08/12] arm64: dts: qcom: pmi8998: Add USB Type-C port controller node
In reply to David HeidelbergQuoted 48 lines · On 26/09/2026 13:40, David Heidelberg via B4 Relay wrote:
From: David Heidelberg <[email protected]>
Add the pmi8998 Type-C port controller and PD PHY device node.
The Type-C CC logic is at USBIN base
0x1300and the PD PHY is at0x1700. The node uses the 'type-c-change' interrupt from the USBIN peripheral for CC state notifications, plus the 8 PD PHY interrupts, including fr-swap.The node is disabled by default; individual boards enable it and provide the USB-C connector description with PD capabilities and port graph.
Assisted-by LLMSigned-off-by David Heidelberg <[email protected]>--- arch/arm64/boot/dts/qcom/pmi8998.dtsi | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)arch/arm64/boot/dts/qcom/pmi8998.dtsi +17
-0@@ -24,16 +24,43 @@ pmi8998_charger: charger@1000 { io-channels = <&pmi8998_rradc 3>, <&pmi8998_rradc 4>; io-channel-names = "usbin_i", "usbin_v"; status = "disabled"; }; + pmi8998_typec: typec@1300 { + compatible = "qcom,pmi8998-typec"; + reg = <0x1300>, + <0x1700>; + + interrupts = <0x2 0x13 0x7 IRQ_TYPE_EDGE_RISING>, + <0x2 0x17 0x0 IRQ_TYPE_EDGE_RISING>, + <0x2 0x17 0x1 IRQ_TYPE_EDGE_RISING>, + <0x2 0x17 0x2 IRQ_TYPE_EDGE_RISING>, + <0x2 0x17 0x3 IRQ_TYPE_EDGE_RISING>, + <0x2 0x17 0x4 IRQ_TYPE_EDGE_RISING>, + <0x2 0x17 0x5 IRQ_TYPE_EDGE_RISING>, + <0x2 0x17 0x6 IRQ_TYPE_EDGE_RISING>, + <0x2 0x17 0x7 IRQ_TYPE_EDGE_RISING>; + interrupt-names = "type-c-change", + "sig-tx", + "sig-rx",
arch/arm64/boot/dts/qcom/pmi8998.dtsi pmi8998_charger: charger@1000 { · line 58
Quoted 10 lines
arch/arm64/boot/dts/qcom/pmi8998.dtsi +10
-0+ "msg-tx", + "msg-rx", + "msg-tx-failed", + "msg-tx-discarded", + "msg-rx-discarded", + "fr-swap"; + + status = "disabled"; + }; +
RFC PATCH 9/12 arm64: dts: qcom: sdm670-google-common: Enable USB Type-C port controller
In reply to David HeidelbergEnable the PM660 Type-C port controller with a USB-C connector description for the Google Pixel 3a (sargo) and Pixel 3a XL (bonito), which share the same USB-C hardware via this common dtsi.
The connector is configured as:
- Sink-only power role with a 5V/3A sink PDO
- Dual-role data with USB role switching
The VBUS output of the charger is not supported yet, so the port can't act as a power source. Describe it as sink-only until VBUS support lands, USB host mode is still reachable through a PD data role swap. Higher voltage PDOs are left out until the charger driver programs the allowed USBIN adapter voltage.
The Pixel 3a USB-C port is USB 2.0 only, so only the HS endpoint is wired to the DWC3 controller.
Switch the DWC3 controller from peripheral-only to OTG mode with usb-role-switch to allow the TCPM framework to control USB host/device role based on CC pin detection.
--- arch/arm64/boot/dts/qcom/sdm670-google-common.dtsi | 51 +++++++++++++++++++++- 1 file changed, 49 insertions(+), 2 deletions(-)
arch/arm64/boot/dts/qcom/sdm670-google-common.dtsi +49 -2
@@ -6,16 +6,17 @@ * Copyright (c) 2022, Richard Acayan. All rights reserved. */ #include <dt-bindings/gpio/gpio.h> #include <dt-bindings/input/input.h> #include <dt-bindings/leds/common.h> #include <dt-bindings/pinctrl/qcom,pmic-gpio.h> #include <dt-bindings/power/qcom-rpmpd.h> +#include <dt-bindings/usb/pd.h> #include "sdm670.dtsi" #include "pm660.dtsi" #include "pm660l.dtsi" /delete-node/ &mpss_region; /delete-node/ &venus_mem; /delete-node/ &wlan_msa_mem; /delete-node/ &cdsp_mem;
@@ -580,16 +581,56 @@ cam_vio_pin: cam-vio-state { power-source = <0>; }; }; &pm660_rradc { status = "okay"; }; +&pm660_typec { + vdd-pdphy-supply = <&vreg_l7b_3p125>; + + status = "okay"; + + connector { + compatible = "usb-c-connector"; + + /* + * Sink only for now, as the PM660 charger doesn't provide + * the VBUS output yet. Switch to the dual power role with + * source PDOs, try-power-role and vbus-supply once it is + * supported. + * + * Higher voltage sink PDOs will be added once the charger + * driver programs the allowed USBIN adapter voltage. + */ + power-role = "sink"; + data-role = "dual"; + self-powered; + + sink-pdos = <PDO_FIXED(5000, 3000, + PDO_FIXED_USB_COMM | + PDO_FIXED_DATA_SWAP)>; + op-sink-microwatt = <15000000>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + pm660_hs_in: endpoint { + remote-endpoint = <&usb_1_dwc3_hs>; + }; + }; + }; + }; +}; + &pm660l_flash { status = "okay"; led-0 { function = LED_FUNCTION_FLASH; color = <LED_COLOR_ID_WHITE>; led-sources = <1>, <2>; led-max-microamp = <500000>;
@@ -702,16 +743,22 @@ &usb_1_hsphy { }; &usb_1 { qcom,select-utmi-as-pipe-clk; status = "okay"; }; &usb_1_dwc3 { - /* Only peripheral works for now */ - dr_mode = "peripheral"; + dr_mode = "otg"; + usb-role-switch; /* Do not assume that sdm670.dtsi will never support USB 3.0 */ phys = <&usb_1_hsphy>; phy-names = "usb2-phy"; maximum-speed = "high-speed"; + + port { + usb_1_dwc3_hs: endpoint { + remote-endpoint = <&pm660_hs_in>; + }; + }; };
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH RFC 09/12] arm64: dts: qcom: sdm670-google-common: Enable USB Type-C port controller
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 19 lines
From: David Heidelberg <[email protected]>
Enable the PM660 Type-C port controller with a USB-C connector description for the Google Pixel 3a (sargo) and Pixel 3a XL (bonito), which share the same USB-C hardware via this common dtsi.
The connector is configured as:
- Sink-only power role with a 5V/3A sink PDO
- Dual-role data with USB role switchingThe VBUS output of the charger is not supported yet, so the port can't act as a power source. Describe it as sink-only until VBUS support lands, USB host mode is still reachable through a PD data role swap. Higher voltage PDOs are left out until the charger driver programs the allowed USBIN adapter voltage.
The Pixel 3a USB-C port is USB 2.0 only, so only the HS endpoint is wired to the DWC3 controller.
Quoted 6 lines
Switch the DWC3 controller from peripheral-only to OTG mode with usb-role-switch to allow the TCPM framework to control USB host/device role based on CC pin detection.
Assisted-by LLMSigned-off-by David Heidelberg <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=9
RFC PATCH 10/12 arm64: dts: qcom: sdm845-google-common: Enable USB Type-C port controller
In reply to David HeidelbergEnable the PMI8998 Type-C port controller with a USB-C connector description for the Google Pixel 3 (blueline) and Pixel 3 XL (crosshatch), which share the same USB-C hardware via this common dtsi.
The connector is configured as:
- Sink-only power role with a 5V/3A sink PDO
- Operating sink power 7.6W (matching downstream configuration)
- Dual-role data with USB role switching
The VBUS output of the charger is not supported yet, so the port can't act as a power source. Describe it as sink-only until VBUS support lands, USB host mode is still reachable through a PD data role swap. Higher voltage PDOs are left out until the charger driver programs the allowed USBIN adapter voltage.
DisplayPort Alt Mode is not advertised as Google disabled DP output in the Pixel 3 hardware design (downstream explicitly sets sde_dp to disabled and excludes it from the MDSS connector list).
Wire the USB-C connector port graph:
- port@0: DWC3 HS endpoint for USB role switching
- port@1: QMP combo PHY for USB SS orientation switching
Switch the DWC3 controller from peripheral-only to OTG mode with usb-role-switch to allow the TCPM framework to control USB host/device role based on CC pin detection.
--- arch/arm64/boot/dts/qcom/sdm845-google-common.dtsi | 59 +++++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/qcom/sdm845-google-common.dtsi +58 -1
@@ -2,16 +2,17 @@ /dts-v1/; #include <dt-bindings/arm/qcom,ids.h> #include <dt-bindings/dma/qcom-gpi.h> #include <dt-bindings/input/linux-event-codes.h> #include <dt-bindings/interrupt-controller/irq.h> #include <dt-bindings/regulator/qcom,rpmh-regulator.h> +#include <dt-bindings/usb/pd.h> #include "sdm845.dtsi" #include "pm8998.dtsi" #include "pmi8998.dtsi" /delete-node/ &mpss_region; /delete-node/ &venus_mem; /delete-node/ &cdsp_mem;
@@ -449,16 +450,63 @@ &pm8998_resin { }; &pmi8998_charger { monitored-battery = <&battery>; status = "okay"; }; +&pmi8998_typec { + status = "okay"; + + vdd-pdphy-supply = <&vreg_l24a_3p075>; + + connector { + compatible = "usb-c-connector"; + + /* + * Sink only for now, as the PMI8998 charger doesn't provide + * the VBUS output yet. Switch to the dual power role with + * source PDOs, try-power-role and vbus-supply once it is + * supported. + * + * Higher voltage sink PDOs will be added once the charger + * driver programs the allowed USBIN adapter voltage. + */ + power-role = "sink"; + data-role = "dual"; + self-powered; + + sink-pdos = <PDO_FIXED(5000, 3000, + PDO_FIXED_USB_COMM | + PDO_FIXED_DATA_SWAP)>; + op-sink-microwatt = <7600000>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + pmi8998_hs_in: endpoint { + remote-endpoint = <&usb_1_dwc3_hs>; + }; + }; + + port@1 { + reg = <1>; + pmi8998_typec_mux_in: endpoint { + remote-endpoint = <&usb_1_qmpphy_out>; + }; + }; + }; + }; +}; + &qupv3_id_0 { status = "okay"; }; &qupv3_id_1 { status = "okay"; };
@@ -549,17 +597,22 @@ &ufs_mem_phy { status = "okay"; }; &usb_1 { status = "okay"; }; &usb_1_dwc3 { - dr_mode = "peripheral"; + dr_mode = "otg"; + usb-role-switch; +}; + +&usb_1_dwc3_hs { + remote-endpoint = <&pmi8998_hs_in>; }; &usb_1_hsphy { vdd-supply = <&vreg_l1a_0p875>; vdda-pll-supply = <&vreg_l12a_1p8>; vdda-phy-dpdm-supply = <&vreg_l24a_3p075>; qcom,imp-res-offset-value = <8>;
@@ -572,16 +625,20 @@ &usb_1_hsphy { &usb_1_qmpphy { vdda-phy-supply = <&vreg_l1a_0p875>; vdda-pll-supply = <&vreg_l26a_1p2>; status = "okay"; }; +&usb_1_qmpphy_out { + remote-endpoint = <&pmi8998_typec_mux_in>; +}; + &venus { firmware-name = "qcom/sdm845/Google/blueline/venus.mbn"; status = "okay"; }; &wifi { vdd-0.8-cx-mx-supply = <&vreg_l5a_0p8>;
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH RFC 10/12] arm64: dts: qcom: sdm845-google-common: Enable USB Type-C port controller
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 19 lines
From: David Heidelberg <[email protected]>
Enable the PMI8998 Type-C port controller with a USB-C connector description for the Google Pixel 3 (blueline) and Pixel 3 XL (crosshatch), which share the same USB-C hardware via this common dtsi.
The connector is configured as:
- Sink-only power role with a 5V/3A sink PDO
- Operating sink power 7.6W (matching downstream configuration)
- Dual-role data with USB role switchingThe VBUS output of the charger is not supported yet, so the port can't act as a power source. Describe it as sink-only until VBUS support lands, USB host mode is still reachable through a PD data role swap. Higher voltage PDOs are left out until the charger driver programs the allowed [ ... ]
usb-role-switch to allow the TCPM framework to control USB host/device role based on CC pin detection.
Quoted 2 lines
Assisted-by LLMSigned-off-by David Heidelberg <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=10
RFC PATCH 11/12 arm64: dts: qcom: sdm845-oneplus-common: Enable USB Type-C port controller
In reply to David HeidelbergEnable the PMI8998 Type-C port controller with a USB-C connector description for the OnePlus 6 (enchilada) and OnePlus 6T (fajita), which share the same USB-C hardware via this common dtsi.
The connector is configured as:
- Sink-only power role with a 5V/3A sink PDO
- Dual-role data with USB role switching
The VBUS output of the charger is not supported yet, so the port can't act as a power source. Describe it as sink-only until VBUS support lands, USB host mode is still reachable through a PD data role swap.
Only the HS endpoint (port@0) is wired to the DWC3 controller since these devices use USB 2.0 only — the QMP USB3+DP combo PHY is not connected in the OnePlus 6/6T hardware design. Consequently, no DisplayPort Alt Mode is advertised and no SS orientation switching is needed.
Switch the DWC3 controller from peripheral-only to OTG mode with usb-role-switch to allow the TCPM framework to control USB host/device role based on CC pin detection.
--- .../arm64/boot/dts/qcom/sdm845-oneplus-common.dtsi | 48 +++++++++++++++++++++- 1 file changed, 46 insertions(+), 2 deletions(-)
arch/arm64/boot/dts/qcom/sdm845-oneplus-common.dtsi +46 -2
@@ -6,16 +6,17 @@ */ /dts-v1/; #include <dt-bindings/arm/qcom,ids.h> #include <dt-bindings/input/linux-event-codes.h> #include <dt-bindings/leds/common.h> #include <dt-bindings/regulator/qcom,rpmh-regulator.h> +#include <dt-bindings/usb/pd.h> #include <dt-bindings/sound/qcom,q6afe.h> #include <dt-bindings/sound/qcom,q6asm.h> #include "sdm845.dtsi" #include "sdm845-wcd9340.dtsi" #include "pm8998.dtsi" #include "pmi8998.dtsi"
@@ -639,16 +640,53 @@ pinconf { }; }; }; &pmi8998_charger { status = "okay"; }; +&pmi8998_typec { + status = "okay"; + + vdd-pdphy-supply = <&vreg_l24a_3p075>; + + connector { + compatible = "usb-c-connector"; + + /* + * Sink only for now, as the PMI8998 charger doesn't provide + * the VBUS output yet. Switch to the dual power role with + * source PDOs, try-power-role and vbus-supply once it is + * supported. + */ + power-role = "sink"; + data-role = "dual"; + self-powered; + + sink-pdos = <PDO_FIXED(5000, 3000, + PDO_FIXED_USB_COMM | + PDO_FIXED_DATA_SWAP)>; + op-sink-microwatt = <15000000>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + pmi8998_hs_in: endpoint { + remote-endpoint = <&usb_1_dwc3_hs>; + }; + }; + }; + }; +}; + &pmi8998_flash { status = "okay"; led-0 { function = LED_FUNCTION_FLASH; color = <LED_COLOR_ID_WHITE>; led-sources = <1>; led-max-microamp = <500000>;
@@ -929,28 +967,34 @@ &usb_1 { * disable USB3 clock requirement as the device only supports * USB2. */ qcom,select-utmi-as-pipe-clk; }; &usb_1_dwc3 { /* - * We don't have the capability to switch modes yet. + * The USB-C role is managed by the pmi8998 Type-C port controller + * via usb-role-switch. */ - dr_mode = "peripheral"; + dr_mode = "otg"; + usb-role-switch; /* fastest mode for USB 2 */ maximum-speed = "high-speed"; /* Remove USB3 phy as it's unused on this device. */ phys = <&usb_1_hsphy>; phy-names = "usb2-phy"; }; +&usb_1_dwc3_hs { + remote-endpoint = <&pmi8998_hs_in>; +}; + &usb_1_hsphy { status = "okay"; vdd-supply = <&vdda_usb1_ss_core>; vdda-pll-supply = <&vdda_qusb_hs0_1p8>; vdda-phy-dpdm-supply = <&vdda_qusb_hs0_3p1>; qcom,imp-res-offset-value = <8>;
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH RFC 11/12] arm64: dts: qcom: sdm845-oneplus-common: Enable USB Type-C port controller
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 20 lines
From: David Heidelberg <[email protected]>
Enable the PMI8998 Type-C port controller with a USB-C connector description for the OnePlus 6 (enchilada) and OnePlus 6T (fajita), which share the same USB-C hardware via this common dtsi.
The connector is configured as:
- Sink-only power role with a 5V/3A sink PDO
- Dual-role data with USB role switchingThe VBUS output of the charger is not supported yet, so the port can't act as a power source. Describe it as sink-only until VBUS support lands, USB host mode is still reachable through a PD data role swap.
Only the HS endpoint (port@0) is wired to the DWC3 controller since these devices use USB 2.0 only — the QMP USB3+DP combo PHY is not connected in the OnePlus 6/6T hardware design. Consequently, no DisplayPort Alt Mode is advertised and no SS orientation switching is needed.
Quoted 6 lines
Switch the DWC3 controller from peripheral-only to OTG mode with usb-role-switch to allow the TCPM framework to control USB host/device role based on CC pin detection.
Assisted-by LLMSigned-off-by David Heidelberg <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=11
RFC PATCH 12/12 arm64: dts: qcom: sdm845-shift-axolotl: Enable USB Type-C port controller
In reply to David HeidelbergEnable the PMI8998 Type-C port controller with a USB-C connector description for the SHIFT6mq:
- Sink-only power role with a 5V/3A sink PDO
- Dual-role data with USB role switching
The VBUS output of the charger is not supported yet, so the port can't act as a power source. Describe it as sink-only until VBUS support lands, USB host mode is still reachable through a PD data role swap. Higher voltage PDOs are left out until the charger driver programs the allowed USBIN adapter voltage.
Wire the USB-C connector port graph:
- port@0: DWC3 HS endpoint for USB role switching
- port@1: QMP combo PHY for SS lane orientation
Switch the DWC3 controller from peripheral-only to OTG mode with usb-role-switch to allow the TCPM framework to control USB host/device role based on CC pin detection.
DisplayPort Alt Mode is not advertised yet, it will be added together with enabling the DP controller (mdss_dp).
--- arch/arm64/boot/dts/qcom/sdm845-shift-axolotl.dts | 62 ++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/qcom/sdm845-shift-axolotl.dts +61 -1
@@ -6,16 +6,17 @@ */ /dts-v1/; #include <dt-bindings/arm/qcom,ids.h> #include <dt-bindings/gpio/gpio.h> #include <dt-bindings/leds/common.h> #include <dt-bindings/regulator/qcom,rpmh-regulator.h> +#include <dt-bindings/usb/pd.h> #include "sdm845.dtsi" #include "pm8998.dtsi" #include "pmi8998.dtsi" / { model = "SHIFT SHIFT6mq"; compatible = "shift,axolotl", "qcom,sdm845"; chassis-type = "handset";
@@ -654,16 +655,66 @@ led-1 { color = <LED_COLOR_ID_YELLOW>; led-sources = <2>; led-max-microamp = <100000>; flash-max-microamp = <1100000>; flash-max-timeout-us = <1280000>; }; }; +&pmi8998_typec { + status = "okay"; + + vdd-pdphy-supply = <&vreg_l24a_3p075>; + + connector { + compatible = "usb-c-connector"; + + /* + * Sink only for now, as the PMI8998 charger doesn't provide + * the VBUS output yet. Switch to the dual power role with + * source PDOs, try-power-role and vbus-supply once it is + * supported. + * + * Higher voltage sink PDOs will be added once the charger + * driver programs the allowed USBIN adapter voltage. + * + * DisplayPort Alt Mode will be added together with enabling + * the DP controller (mdss_dp). + */ + power-role = "sink"; + data-role = "dual"; + self-powered; + + sink-pdos = <PDO_FIXED(5000, 3000, + PDO_FIXED_USB_COMM | + PDO_FIXED_DATA_SWAP)>; + op-sink-microwatt = <15000000>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + pmi8998_hs_in: endpoint { + remote-endpoint = <&usb_1_dwc3_hs>; + }; + }; + + port@1 { + reg = <1>; + pmi8998_typec_mux_in: endpoint { + remote-endpoint = <&usb_1_qmpphy_out>; + }; + }; + }; + }; +}; + &qup_uart9_rx { drive-strength = <2>; bias-pull-up; }; &qup_uart9_tx { drive-strength = <2>; bias-disable;
@@ -855,17 +906,22 @@ &ufs_mem_phy { vdda-pll-supply = <&vdda_ufs1_1p2>; }; &usb_1 { status = "okay"; }; &usb_1_dwc3 { - dr_mode = "peripheral"; + dr_mode = "otg"; + usb-role-switch; +}; + +&usb_1_dwc3_hs { + remote-endpoint = <&pmi8998_hs_in>; }; &usb_1_hsphy { status = "okay"; vdd-supply = <&vreg_l1a_0p875>; vdda-phy-dpdm-supply = <&vreg_l24a_3p075>; vdda-pll-supply = <&vreg_l12a_1p8>;
@@ -873,16 +929,20 @@ &usb_1_hsphy { &usb_1_qmpphy { status = "okay"; vdda-phy-supply = <&vreg_l1a_0p875>; vdda-pll-supply = <&vreg_l26a_1p2>; }; +&usb_1_qmpphy_out { + remote-endpoint = <&pmi8998_typec_mux_in>; +}; + &venus { firmware-name = "qcom/sdm845/SHIFT/axolotl/venus.mbn"; status = "okay"; }; &wifi { vdd-0.8-cx-mx-supply = <&vreg_l5a_0p8>;
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH RFC 12/12] arm64: dts: qcom: sdm845-shift-axolotl: Enable USB Type-C port controller
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 22 lines
From: David Heidelberg <[email protected]>
Enable the PMI8998 Type-C port controller with a USB-C connector description for the SHIFT6mq:
- Sink-only power role with a 5V/3A sink PDO
- Dual-role data with USB role switchingThe VBUS output of the charger is not supported yet, so the port can't act as a power source. Describe it as sink-only until VBUS support lands, USB host mode is still reachable through a PD data role swap. Higher voltage PDOs are left out until the charger driver programs the allowed USBIN adapter voltage.
Wire the USB-C connector port graph:
- port@0: DWC3 HS endpoint for USB role switching
- port@1: QMP combo PHY for SS lane orientationSwitch the DWC3 controller from peripheral-only to OTG mode with usb-role-switch to allow the TCPM framework to control USB host/device role based on CC pin detection.
Quoted 5 lines
DisplayPort Alt Mode is not advertised yet, it will be added together with enabling the DP controller (
mdss_dp).Assisted-by LLMSigned-off-by David Heidelberg <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=12
Quoted 14 lines · On Sat, Sep 26, 2026 at 02:40:19PM +0200, David Heidelberg via B4 Relay wrote:
This series adds basic USB Type-C support for 1st gen devices, covering configurations that do not require VBUS power (e.g. devices using externally powered docks).
VBUS support will be added in a follow-up series after this one is merged. Supporting VBUS will likely require refactoring parts of the SMBX charger support, which is why it is not included here.
Tested with an externally powered dock station:
- Pixel 3 / 3 XL
- SHIFT 6mq
- OnePlus 6
Quoted 5 lines
Tested with an additional, not-yet-included VBUS patch for non-powered devices:
- Xiaomi Redmi Note 7
- Xiaomi Mi Pad 4
THis is very interesting, as it will also unblock DisplayPort support on devices from those generations.
One major comment. As we see, on SMB2 PMICs parts of the Type-C functionality are provided by the charger / FG device. I guess that on SMB5 PMICs we will get the same problem once somebody tries to implement additional charger features. Would it make sense to rework the PMIC TCPM driver to be a composite driver, taking several components via the existing Linux interface?
Quoted 8 lines
Credits to everyone who has contributed to Type-C enablement before:
Casey Connolly
Zachary Dry — LLM generation and testing
Max Furman — LLM generation and testingSigned-off-by David Heidelberg <[email protected]>
Signature · 2 lines
With best wishes Dmitry
Quoted 15 lines · Dmitry Baryshkov
Quoted 14 lines · On Sat, Sep 26, 2026 at 02:40:19PM +0200, David Heidelberg via B4 Relay wrote:
This series adds basic USB Type-C support for 1st gen devices, covering configurations that do not require VBUS power (e.g. devices using externally powered docks).
VBUS support will be added in a follow-up series after this one is merged. Supporting VBUS will likely require refactoring parts of the SMBX charger support, which is why it is not included here.
Tested with an externally powered dock station:
- Pixel 3 / 3 XL
- SHIFT 6mq
- OnePlus 6
Quoted 8 lines
Quoted 5 lines
Tested with an additional, not-yet-included VBUS patch for non-powered devices:
- Xiaomi Redmi Note 7
- Xiaomi Mi Pad 4THis is very interesting, as it will also unblock DisplayPort support on devices from those generations.
Yes, DP works with some minor adjustment there and there (going to be follow-up)
Quoted 8 lines
One major comment. As we see, on SMB2 PMICs parts of the Type-C functionality are provided by the charger / FG device. I guess that on SMB5 PMICs we will get the same problem once somebody tries to implement additional charger features. Would it make sense to rework the PMIC TCPM driver to be a composite driver, taking several components via the existing Linux interface?
As this gets decided from the QCOM side, I'm fine with whatever suits the hardware best.
David
Quoted 10 lines
Quoted 9 lines
Credits to everyone who has contributed to Type-C enablement before:
Casey Connolly
Zachary Dry — LLM generation and testing
Max Furman — LLM generation and testingSigned-off-by David Heidelberg <[email protected]>
Quoted 36 lines · David Heidelberg
Quoted 15 lines · Dmitry Baryshkov
Quoted 14 lines · On Sat, Sep 26, 2026 at 02:40:19PM +0200, David Heidelberg via B4 Relay wrote:
This series adds basic USB Type-C support for 1st gen devices, covering configurations that do not require VBUS power (e.g. devices using externally powered docks).
VBUS support will be added in a follow-up series after this one is merged. Supporting VBUS will likely require refactoring parts of the SMBX charger support, which is why it is not included here.
Tested with an externally powered dock station:
- Pixel 3 / 3 XL
- SHIFT 6mq
- OnePlus 6Quoted 8 lines
Quoted 5 lines
Tested with an additional, not-yet-included VBUS patch for non-powered devices:
- Xiaomi Redmi Note 7
- Xiaomi Mi Pad 4THis is very interesting, as it will also unblock DisplayPort support on devices from those generations.
Yes, DP works with some minor adjustment there and there (going to be follow-up)
Quoted 8 lines
One major comment. As we see, on SMB2 PMICs parts of the Type-C functionality are provided by the charger / FG device. I guess that on SMB5 PMICs we will get the same problem once somebody tries to implement additional charger features. Would it make sense to rework the PMIC TCPM driver to be a composite driver, taking several components via the existing Linux interface?
Quoted 2 lines
As this gets decided from the QCOM side, I'm fine with whatever suits the hardware best.
Bryan, as you are a maintainer of the PMIC-TCPM? Would the use of components be fine?
Signature · 2 lines
With best wishes Dmitry
Bryan O'Donoghue
maintainerQuoted 10 lines · Dmitry Baryshkov
Quoted 8 lines
Quoted 6 lines
One major comment. As we see, on SMB2 PMICs parts of the Type-C functionality are provided by the charger / FG device. I guess that on SMB5 PMICs we will get the same problem once somebody tries to implement additional charger features. Would it make sense to rework the PMIC TCPM driver to be a composite driver, taking several components via the existing Linux interface?
As this gets decided from the QCOM side, I'm fine with whatever suits the hardware best.
Bryan, as you are a maintainer of the PMIC-TCPM? Would the use of components be fine?
I mean maybe. Would it not make more sense to land the TCPM functionality and then look into adding charging moving then ?
i.e. finish off adding this piece first
---
bod
Quoted 9 lines · Bryan O'Donoghue
Quoted 8 lines · Dmitry Baryshkov
Quoted 8 lines
Quoted 6 lines
One major comment. As we see, on SMB2 PMICs parts of the Type-C functionality are provided by the charger / FG device. I guess that on SMB5 PMICs we will get the same problem once somebody tries to implement additional charger features. Would it make sense to rework the PMIC TCPM driver to be a composite driver, taking several components via the existing Linux interface?
As this gets decided from the QCOM side, I'm fine with whatever suits the hardware best.
Quoted 7 lines
Quoted 2 lines
Bryan, as you are a maintainer of the PMIC-TCPM? Would the use of components be fine?
I mean maybe. Would it not make more sense to land the TCPM functionality and then look into adding charging moving then ?
i.e. finish off adding this piece first
The problem is that we already have SMB2 charger, which accesses the same region. In theory it is possible to say that USB-C driver conflicts with the charger "for now". In practice, I think, it might be better to sort that out from the beginning. You didn't have this issue when working on PM8150B support since we never needed charger for that PMIC series.
But, then it's up to you and David.
Signature · 2 lines
With best wishes Dmitry
Quoted 16 lines · Dmitry Baryshkov
Quoted 15 lines · Bryan O'Donoghue
Quoted 10 lines · Dmitry Baryshkov
Quoted 8 lines
Quoted 6 lines
One major comment. As we see, on SMB2 PMICs parts of the Type-C functionality are provided by the charger / FG device. I guess that on SMB5 PMICs we will get the same problem once somebody tries to implement additional charger features. Would it make sense to rework the PMIC TCPM driver to be a composite driver, taking several components via the existing Linux interface?
As this gets decided from the QCOM side, I'm fine with whatever suits the hardware best.
Bryan, as you are a maintainer of the PMIC-TCPM? Would the use of components be fine?
I mean maybe. Would it not make more sense to land the TCPM functionality and then look into adding charging moving then ?
Quoted 8 lines
Quoted 1 line
i.e. finish off adding this piece first
The problem is that we already have SMB2 charger, which accesses the same region. In theory it is possible to say that USB-C driver conflicts with the charger "for now". In practice, I think, it might be better to sort that out from the beginning. You didn't have this issue when working on PM8150B support since we never needed charger for that PMIC series.
I looked into the smbx vs Type-C overlaps.
I see that charger DCIN (0x1400) is mostly mirrors (both address and values) the register set of USBIN (0x1300), thus I assume charger accessing these registers is correct.
Type-C driver accesses 0x1300 but mostly different registers (with some exception of initialization and smbx.c 'FIXME: This will be handled by the type-c driver').
So that leads me to the conclusion that smbx should continue to access 0x1300 range, while Type-C must access the range. Only things which needs to be moved from smbx to type-c is the type-c initialization.
Do I get it correctly?
Thanks
David
Quoted 3 lines
But, then it's up to you and David.