* [PATCH v2 0/4] usb: typec: qcom-pmic-typec: properly tear down port on remove and shutdown
@ 2026-11-25 11:04 Neil Armstrong
2026-11-25 11:04 ` [PATCH v2 1/4] usb: typec: qcom-pmic-typec: pdphy: disable the PD PHY on stop Neil Armstrong
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Neil Armstrong @ 2026-11-25 11:04 UTC (permalink / raw)
To: Bryan O'Donoghue, Heikki Krogerus, Greg Kroah-Hartman,
Guenter Roeck, Casey Connolly
Cc: linux-arm-msm, linux-usb, Neil Armstrong
The current driver doesn't leave the port in the same
state as found when probing, and leaves the port enabled
on system shutdown.
Loosely depends on [1].
[1] https://lore.kernel.org/all/20261125-topic-tcpm-core-fixes-v2-0-aede2a3471f4@linaro.org/
Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
---
Changes in v2:
- Add Fixes and review tags
- Also disable on remove
- New patch: switch to SNK_ONLY before DISABLE when disabling port
- New patch: detach the port on probe
- Link to v1: https://patch.msgid.link/20261120-topic-tcpm-qcom-fixes-v1-0-9a152f906fba@linaro.org
To: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
To: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Guenter Roeck <linux@roeck-us.net>
To: Casey Connolly <casey.connolly@linaro.org>
Cc: linux-arm-msm@vger.kernel.org
Cc: linux-usb@vger.kernel.org
---
Neil Armstrong (4):
usb: typec: qcom-pmic-typec: pdphy: disable the PD PHY on stop
usb: typec: qcom-pmic-typec: detach the port on shutdown
usb: typec: qcom-pmic-typec: switch to SNK_ONLY before DISABLE when disabling port
usb: typec: qcom-pmic-typec: detach the port on probe
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c | 12 ++++++++
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.h | 1 +
.../usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c | 2 +-
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c | 32 ++++++++++++++++++++++
4 files changed, 46 insertions(+), 1 deletion(-)
---
base-commit: 3dd8c790a7b7027abdd568e36db5e82ffaea7c77
change-id: 20261120-topic-tcpm-qcom-fixes-c9ce1e65c570
Best regards,
--
Neil Armstrong <neil.armstrong@linaro.org>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 1/4] usb: typec: qcom-pmic-typec: pdphy: disable the PD PHY on stop
2026-11-25 11:04 [PATCH v2 0/4] usb: typec: qcom-pmic-typec: properly tear down port on remove and shutdown Neil Armstrong
@ 2026-11-25 11:04 ` Neil Armstrong
2026-11-30 12:24 ` Heikki Krogerus
2026-11-25 11:04 ` [PATCH v2 2/4] usb: typec: qcom-pmic-typec: detach the port on shutdown Neil Armstrong
` (2 subsequent siblings)
3 siblings, 1 reply; 6+ messages in thread
From: Neil Armstrong @ 2026-11-25 11:04 UTC (permalink / raw)
To: Bryan O'Donoghue, Heikki Krogerus, Greg Kroah-Hartman,
Guenter Roeck, Casey Connolly
Cc: linux-arm-msm, linux-usb, Neil Armstrong
qcom_pmic_typec_pdphy_stop() only terminates the ongoing transmission and
clears the RX frame filter, the PD PHY itself stays enabled.
Use qcom_pmic_typec_pdphy_disable() so the PD PHY is also turned off
before its supply is released, leaving it in the same state as before
qcom_pmic_typec_pdphy_start().
Assisted-by: LLM
Fixes: a4422ff22142 ("usb: typec: qcom: Add Qualcomm PMIC Type-C driver")
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
---
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c
index 435e07659d65..08cf65951796 100644
--- a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c
+++ b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c
@@ -545,7 +545,7 @@ static void qcom_pmic_typec_pdphy_stop(struct pmic_typec *tcpm)
cancel_work_sync(&pmic_typec_pdphy->reset_work);
- qcom_pmic_typec_pdphy_reset_on(pmic_typec_pdphy);
+ qcom_pmic_typec_pdphy_disable(pmic_typec_pdphy);
regulator_disable(pmic_typec_pdphy->vdd_pdphy);
}
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v2 2/4] usb: typec: qcom-pmic-typec: detach the port on shutdown
2026-11-25 11:04 [PATCH v2 0/4] usb: typec: qcom-pmic-typec: properly tear down port on remove and shutdown Neil Armstrong
2026-11-25 11:04 ` [PATCH v2 1/4] usb: typec: qcom-pmic-typec: pdphy: disable the PD PHY on stop Neil Armstrong
@ 2026-11-25 11:04 ` Neil Armstrong
2026-11-25 11:04 ` [PATCH v2 3/4] usb: typec: qcom-pmic-typec: switch to SNK_ONLY before DISABLE when disabling port Neil Armstrong
2026-11-25 11:04 ` [PATCH v2 4/4] usb: typec: qcom-pmic-typec: detach the port on probe Neil Armstrong
3 siblings, 0 replies; 6+ messages in thread
From: Neil Armstrong @ 2026-11-25 11:04 UTC (permalink / raw)
To: Bryan O'Donoghue, Heikki Krogerus, Greg Kroah-Hartman,
Guenter Roeck, Casey Connolly
Cc: linux-arm-msm, linux-usb, Neil Armstrong
On reboot or power off the port is left as is: a source partner keeps
the negotiated contract, possibly above 5V, and a sink partner stays
powered by the OTG boost while nothing services the port anymore.
Add a shutdown callback stopping the port and the PD PHY, unregistering
the TCPM port, which turns VBUS and VCONN off, and finally disabling the
Type-C block so the partner sees a detach. Also disable on remove.
Assisted-by: LLM
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
---
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c | 12 ++++++++++++
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.h | 1 +
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c | 11 +++++++++++
3 files changed, 24 insertions(+)
diff --git a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c
index 58d1e6aae637..be7508936796 100644
--- a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c
+++ b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c
@@ -132,6 +132,17 @@ 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);
+ tcpm->port_disable(tcpm);
+}
+
+static void qcom_pmic_typec_shutdown(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);
+ tcpm->port_disable(tcpm);
}
static const struct pmic_typec_resources pm8150b_typec_res = {
@@ -158,6 +169,7 @@ static struct platform_driver qcom_pmic_typec_driver = {
},
.probe = qcom_pmic_typec_probe,
.remove = qcom_pmic_typec_remove,
+ .shutdown = qcom_pmic_typec_shutdown,
};
module_platform_driver(qcom_pmic_typec_driver);
diff --git a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.h b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.h
index 3c75820c9187..0818582fe850 100644
--- a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.h
+++ b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.h
@@ -20,6 +20,7 @@ struct pmic_typec {
int (*port_start)(struct pmic_typec *tcpm,
struct tcpm_port *tcpm_port);
void (*port_stop)(struct pmic_typec *tcpm);
+ void (*port_disable)(struct pmic_typec *tcpm);
};
#define tcpc_to_tcpm(_tcpc_) container_of(_tcpc_, struct pmic_typec, tcpc)
diff --git a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c
index d433fc3e7e56..710acdb9689b 100644
--- a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c
+++ b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c
@@ -701,6 +701,16 @@ static void qcom_pmic_typec_port_stop(struct pmic_typec *tcpm)
disable_delayed_work_sync(&pmic_typec_port->cc_debounce_dwork);
}
+static void qcom_pmic_typec_port_disable(struct pmic_typec *tcpm)
+{
+ struct pmic_typec_port *pmic_typec_port = tcpm->pmic_typec_port;
+
+ /* Present neither Rp nor Rd, so a connected partner detects a detach */
+ regmap_write(pmic_typec_port->regmap,
+ pmic_typec_port->base + TYPEC_MODE_CFG_REG,
+ TYPEC_DISABLE_CMD);
+}
+
int qcom_pmic_typec_port_probe(struct platform_device *pdev,
struct pmic_typec *tcpm,
const struct pmic_typec_port_resources *res,
@@ -781,6 +791,7 @@ int qcom_pmic_typec_port_probe(struct platform_device *pdev,
tcpm->port_start = qcom_pmic_typec_port_start;
tcpm->port_stop = qcom_pmic_typec_port_stop;
+ tcpm->port_disable = qcom_pmic_typec_port_disable;
return 0;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v2 3/4] usb: typec: qcom-pmic-typec: switch to SNK_ONLY before DISABLE when disabling port
2026-11-25 11:04 [PATCH v2 0/4] usb: typec: qcom-pmic-typec: properly tear down port on remove and shutdown Neil Armstrong
2026-11-25 11:04 ` [PATCH v2 1/4] usb: typec: qcom-pmic-typec: pdphy: disable the PD PHY on stop Neil Armstrong
2026-11-25 11:04 ` [PATCH v2 2/4] usb: typec: qcom-pmic-typec: detach the port on shutdown Neil Armstrong
@ 2026-11-25 11:04 ` Neil Armstrong
2026-11-25 11:04 ` [PATCH v2 4/4] usb: typec: qcom-pmic-typec: detach the port on probe Neil Armstrong
3 siblings, 0 replies; 6+ messages in thread
From: Neil Armstrong @ 2026-11-25 11:04 UTC (permalink / raw)
To: Bryan O'Donoghue, Heikki Krogerus, Greg Kroah-Hartman,
Guenter Roeck, Casey Connolly
Cc: linux-arm-msm, linux-usb, Neil Armstrong
Disabling it straight from DRP mode can trigger an over-voltage fault on
the VBUS boost, so switch it first to sink only mode for 2ms, then present
neither Rp nor Rd, so a connected partner detects a detach in a safe way.
Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
---
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c
index 710acdb9689b..f125ac722e8b 100644
--- a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c
+++ b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c
@@ -705,6 +705,16 @@ static void qcom_pmic_typec_port_disable(struct pmic_typec *tcpm)
{
struct pmic_typec_port *pmic_typec_port = tcpm->pmic_typec_port;
+ /*
+ * Disabling the Type-C block straight from DRP mode can trigger
+ * a VBUS boost over-voltage fault, so go through sink only mode first.
+ */
+ regmap_write(pmic_typec_port->regmap,
+ pmic_typec_port->base + TYPEC_MODE_CFG_REG,
+ EN_SNK_ONLY);
+
+ usleep_range(2000, 3000);
+
/* Present neither Rp nor Rd, so a connected partner detects a detach */
regmap_write(pmic_typec_port->regmap,
pmic_typec_port->base + TYPEC_MODE_CFG_REG,
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v2 4/4] usb: typec: qcom-pmic-typec: detach the port on probe
2026-11-25 11:04 [PATCH v2 0/4] usb: typec: qcom-pmic-typec: properly tear down port on remove and shutdown Neil Armstrong
` (2 preceding siblings ...)
2026-11-25 11:04 ` [PATCH v2 3/4] usb: typec: qcom-pmic-typec: switch to SNK_ONLY before DISABLE when disabling port Neil Armstrong
@ 2026-11-25 11:04 ` Neil Armstrong
3 siblings, 0 replies; 6+ messages in thread
From: Neil Armstrong @ 2026-11-25 11:04 UTC (permalink / raw)
To: Bryan O'Donoghue, Heikki Krogerus, Greg Kroah-Hartman,
Guenter Roeck, Casey Connolly
Cc: linux-arm-msm, linux-usb, Neil Armstrong
The Type-C block may have been left attached by the bootloader, force a
detach longer than tPDDebounce so the partner and TCPM start from a known
state.
Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
---
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c
index f125ac722e8b..a33903fedfb7 100644
--- a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c
+++ b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c
@@ -803,6 +803,17 @@ int qcom_pmic_typec_port_probe(struct platform_device *pdev,
tcpm->port_stop = qcom_pmic_typec_port_stop;
tcpm->port_disable = qcom_pmic_typec_port_disable;
+ /*
+ * The Type-C block may have been left attached by the bootloader,
+ * force a detach longer than tPDDebounce so the partner and TCPM
+ * start from a known state.
+ */
+ regmap_write(pmic_typec_port->regmap,
+ pmic_typec_port->base + TYPEC_MODE_CFG_REG,
+ TYPEC_DISABLE_CMD);
+
+ msleep(200);
+
return 0;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2 1/4] usb: typec: qcom-pmic-typec: pdphy: disable the PD PHY on stop
2026-11-25 11:04 ` [PATCH v2 1/4] usb: typec: qcom-pmic-typec: pdphy: disable the PD PHY on stop Neil Armstrong
@ 2026-11-30 12:24 ` Heikki Krogerus
0 siblings, 0 replies; 6+ messages in thread
From: Heikki Krogerus @ 2026-11-30 12:24 UTC (permalink / raw)
To: Neil Armstrong
Cc: Bryan O'Donoghue, Greg Kroah-Hartman, Guenter Roeck,
Casey Connolly, linux-arm-msm, linux-usb
On Wed, Nov 25, 2026 at 12:04:17PM +0100, Neil Armstrong wrote:
> qcom_pmic_typec_pdphy_stop() only terminates the ongoing transmission and
> clears the RX frame filter, the PD PHY itself stays enabled.
>
> Use qcom_pmic_typec_pdphy_disable() so the PD PHY is also turned off
> before its supply is released, leaving it in the same state as before
> qcom_pmic_typec_pdphy_start().
>
> Assisted-by: LLM
> Fixes: a4422ff22142 ("usb: typec: qcom: Add Qualcomm PMIC Type-C driver")
> Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
> Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> ---
> drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c
> index 435e07659d65..08cf65951796 100644
> --- a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c
> +++ b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c
> @@ -545,7 +545,7 @@ static void qcom_pmic_typec_pdphy_stop(struct pmic_typec *tcpm)
>
> cancel_work_sync(&pmic_typec_pdphy->reset_work);
>
> - qcom_pmic_typec_pdphy_reset_on(pmic_typec_pdphy);
> + qcom_pmic_typec_pdphy_disable(pmic_typec_pdphy);
>
> regulator_disable(pmic_typec_pdphy->vdd_pdphy);
> }
>
> --
> 2.34.1
>
--
heikki
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-11-30 12:24 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-25 11:04 [PATCH v2 0/4] usb: typec: qcom-pmic-typec: properly tear down port on remove and shutdown Neil Armstrong
2026-11-25 11:04 ` [PATCH v2 1/4] usb: typec: qcom-pmic-typec: pdphy: disable the PD PHY on stop Neil Armstrong
2026-11-30 12:24 ` Heikki Krogerus
2026-11-25 11:04 ` [PATCH v2 2/4] usb: typec: qcom-pmic-typec: detach the port on shutdown Neil Armstrong
2026-11-25 11:04 ` [PATCH v2 3/4] usb: typec: qcom-pmic-typec: switch to SNK_ONLY before DISABLE when disabling port Neil Armstrong
2026-11-25 11:04 ` [PATCH v2 4/4] usb: typec: qcom-pmic-typec: detach the port on probe Neil Armstrong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox