From: Alexander Koskovich <AKoskovich@pm.me>
To: Bryan O'Donoghue <bryan.odonoghue@linaro.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Heikki Krogerus <heikki.krogerus@linux.intel.com>
Cc: linux-arm-msm@vger.kernel.org, linux-usb@vger.kernel.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
Alexander Koskovich <akoskovich@pm.me>
Subject: [PATCH RFC 2/2] usb: typec: qcom: Add support for shared USBIN VBUS detection
Date: Sun, 08 Mar 2026 23:20:35 +0000 [thread overview]
Message-ID: <20260308-qcom-typec-shared-vbus-v1-2-7d574b91052a@pm.me> (raw)
In-Reply-To: <20260308-qcom-typec-shared-vbus-v1-0-7d574b91052a@pm.me>
On devices with multiple USB-C ports whose VBUS lines are wired to a
single shared USBIN input on the PM8150B PMIC (e.g. ASUS ROG Phone 3), the
Type-C port controller cannot distinguish which port is providing VBUS.
In practice this shows up as being unable to use the affected Type-C port
while the other port is connected to a device providing VBUS such as a PC
or charger.
Add support for an optional vbus-detect-gpios property that allows the
Type-C port controller to read VBUS state from a per-port GPIO instead of
the shared USBIN input. When present, the driver also bypasses VSAFE0V
checks and switches DRP toggling to TRY_SRC to avoid false source
detection caused by VBUS present on USBIN from another port.
Signed-off-by: Alexander Koskovich <akoskovich@pm.me>
---
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c | 46 +++++++++++++++++++++-
1 file changed, 44 insertions(+), 2 deletions(-)
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 8051eaa46991..c338e26651b0 100644
--- a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c
+++ b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c
@@ -5,6 +5,7 @@
#include <linux/delay.h>
#include <linux/err.h>
+#include <linux/gpio/consumer.h>
#include <linux/interrupt.h>
#include <linux/kernel.h>
#include <linux/mod_devicetable.h>
@@ -176,6 +177,8 @@ struct pmic_typec_port {
bool vbus_enabled;
struct mutex vbus_lock; /* VBUS state serialization */
+ struct gpio_desc *vbus_detect_gpio;
+
int cc;
bool debouncing_cc;
struct delayed_work cc_debounce_dwork;
@@ -277,7 +280,12 @@ static int qcom_pmic_typec_port_vbus_detect(struct pmic_typec_port *pmic_typec_p
{
struct device *dev = pmic_typec_port->dev;
unsigned int misc;
- int ret;
+ int ret, vbus;
+
+ if (pmic_typec_port->vbus_detect_gpio) {
+ vbus = gpiod_get_value_cansleep(pmic_typec_port->vbus_detect_gpio);
+ return vbus;
+ }
ret = regmap_read(pmic_typec_port->regmap,
pmic_typec_port->base + TYPEC_MISC_STATUS_REG,
@@ -307,6 +315,13 @@ static int qcom_pmic_typec_port_vbus_toggle(struct pmic_typec_port *pmic_typec_p
if (ret)
return ret;
+ /*
+ * On devices with multiple ports sharing USBIN, VBUS from another
+ * port prevents VSAFE0V from being reached.
+ */
+ if (pmic_typec_port->vbus_detect_gpio)
+ return 0;
+
val = TYPEC_SM_VBUS_VSAFE0V;
}
@@ -589,7 +604,14 @@ static int qcom_pmic_typec_port_start_toggling(struct tcpc_dev *tcpc,
mode = EN_SNK_ONLY;
break;
case TYPEC_PORT_DRP:
- mode = EN_TRY_SNK;
+ /*
+ * VBUS from another port makes EN_TRY_SNK falsely detect
+ * a source. Start as Rp to reliably find sinks.
+ */
+ if (pmic_typec_port->vbus_detect_gpio)
+ mode = EN_TRY_SRC;
+ else
+ mode = EN_TRY_SNK;
break;
}
@@ -677,6 +699,20 @@ static int qcom_pmic_typec_port_start(struct pmic_typec *tcpm,
if (ret)
goto done;
+ /*
+ * On devices with multiple USB-C ports sharing USBIN, bypass
+ * VSAFE0V so SRC attachment can complete despite VBUS being
+ * present on USBIN from another port.
+ */
+ if (pmic_typec_port->vbus_detect_gpio) {
+ ret = regmap_update_bits(pmic_typec_port->regmap,
+ pmic_typec_port->base + TYPEC_EXIT_STATE_CFG_REG,
+ BYPASS_VSAFE0V_DURING_ROLE_SWAP,
+ BYPASS_VSAFE0V_DURING_ROLE_SWAP);
+ if (ret)
+ goto done;
+ }
+
pmic_typec_port->tcpm_port = tcpm_port;
for (i = 0; i < pmic_typec_port->nr_irqs; i++)
@@ -724,6 +760,12 @@ int qcom_pmic_typec_port_probe(struct platform_device *pdev,
if (IS_ERR(pmic_typec_port->vdd_vbus))
return PTR_ERR(pmic_typec_port->vdd_vbus);
+ pmic_typec_port->vbus_detect_gpio = devm_gpiod_get_optional(dev, "vbus-detect",
+ GPIOD_IN);
+ if (IS_ERR(pmic_typec_port->vbus_detect_gpio))
+ return dev_err_probe(dev, PTR_ERR(pmic_typec_port->vbus_detect_gpio),
+ "failed to get vbus-detect GPIO\n");
+
pmic_typec_port->dev = dev;
pmic_typec_port->base = base;
pmic_typec_port->regmap = regmap;
--
2.53.0
next prev parent reply other threads:[~2026-03-08 23:20 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-08 23:20 [PATCH RFC 0/2] usb: typec: qcom: Add shared USBIN VBUS detection via GPIO Alexander Koskovich
2026-03-08 23:20 ` [PATCH RFC 1/2] dt-bindings: usb: qcom,pmic-typec: Document vbus-detect-gpios property Alexander Koskovich
2026-03-11 23:02 ` Bryan O'Donoghue
2026-03-16 10:15 ` Konrad Dybcio
2026-03-12 2:34 ` Dmitry Baryshkov
2026-03-12 2:59 ` Alexander Koskovich
2026-03-08 23:20 ` Alexander Koskovich [this message]
2026-03-11 13:01 ` [PATCH RFC 2/2] usb: typec: qcom: Add support for shared USBIN VBUS detection Konrad Dybcio
2026-03-11 14:39 ` Bryan O'Donoghue
2026-03-11 16:24 ` Alexander Koskovich
2026-03-11 23:05 ` Bryan O'Donoghue
2026-03-12 6:18 ` Alexander Koskovich
2026-03-11 14:50 ` [PATCH RFC 0/2] usb: typec: qcom: Add shared USBIN VBUS detection via GPIO Bryan O'Donoghue
2026-03-11 17:37 ` Alexander Koskovich
2026-03-11 23:00 ` Bryan O'Donoghue
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260308-qcom-typec-shared-vbus-v1-2-7d574b91052a@pm.me \
--to=akoskovich@pm.me \
--cc=bryan.odonoghue@linaro.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=heikki.krogerus@linux.intel.com \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=robh@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®