From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ed1-f43.google.com (mail-ed1-f43.google.com [209.85.208.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C96823B5830 for ; Thu, 12 Mar 2026 10:04:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773309887; cv=none; b=kkRSOdamMTvMiY2hilNeK/PTW3yPsf7HBeBeQrSfbW9dzdw32xAjPWFqpb0NEI9PG9fZ+tQ+fsVI+X2KFDfHkirVrY9CsGIQXENp2dWDeX0bNolCxRNJtGUrVbEKOgsqrml5auyuMeK4iyaC6AdrP24+TOjN0rQgMaX6UNOwV38= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773309887; c=relaxed/simple; bh=cNHwcyvjlqOn/sSK9BepZUE0uOreTt3cfgNnXEYhuwA=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=t7QkpJ2KN/QJvVC6onRVh1Ddtrpr1nm17LldEThc5/HTcKaR4i8MM3GznTHnSi4Zmdox7/he8Wc3ZNcDaoeajlCy3cyPR0K31nd6PcDk8kOEUNHd9YBIG+L6QQ0U1Z0IL0gYTlEHmsuPHkSapiSErB+nZ1GQ6AiGFPeCmgzT+tc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=mpQmvkcs; arc=none smtp.client-ip=209.85.208.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="mpQmvkcs" Received: by mail-ed1-f43.google.com with SMTP id 4fb4d7f45d1cf-660dcafc85aso1414545a12.0 for ; Thu, 12 Mar 2026 03:04:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1773309878; x=1773914678; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:content-language:from :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=+szYmIVQmnY3WCiXmubWFb8BEwrcKI82m+hDxFjwnOQ=; b=mpQmvkcsfWFSRVNp8jk32zicic75KC8/YK6azrgab+NAghob2HnuDNT1hwQRzATAgz UglhlVmkrtdGr5tVeHGfz3uG1nYwukjTmhhhoS1FUIbttCH4hyBj2mfKVy4nt542JYBE nm7iBxMabr/HTvMcgUxCmvBhzCoom9JpnkeexNoRKk//G5UY62CHKprob7jwQfk8iQ1K qvit+mXI04XbdEn7dInFfe+lRJpehfkPAj4xAMo4/3ckrG2ElzNaWqE4mof8AXexzPCa u9L0TwLFYeCAsfZS1f6HQhnKOIpK7hF2DPUGIjPFlKN4hyuWQ1RdB+z/Q02pseTnFIMS ER6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773309878; x=1773914678; h=content-transfer-encoding:in-reply-to:content-language:from :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=+szYmIVQmnY3WCiXmubWFb8BEwrcKI82m+hDxFjwnOQ=; b=WmgPM/pjtduxGPuSnFAqUEW9xYc7tX+ajVbka+aZfbiI0kRPefTI78YtNfLNL1s8Pn 8vQ2SwZjwUJYIo3ITa+LB1+Q1Mhwfl4sq0XT3E0MZJOm+ZvCTXVCk3122t+uPsZEV34K gT+txrDlMCJMvsyp8z7pQF05CZo5YTDtW7N3qFSmJ25oKO0QDDwxXLX/MuOpF37HOrHy SF2cC16SeszgrKfWuj5JOIdY+Gbc6Lv+fYahJcflquofxYmnfLkxwiFRRNwQeSG40vuC xVNyTt3zRRsv3CcNUvH5Kxctzf3O07swVuoKeLvR54UErZjtXDSFzPeTT+2gEk1BCijG ej/A== X-Forwarded-Encrypted: i=1; AJvYcCVh25dxyfZnbBn8IOvb3ZCeo/sDImzKznP634aQgzO9CYvyQH4z97j+HrkPN2JIRvu5MtFa+IbVDwx6Pvo=@vger.kernel.org X-Gm-Message-State: AOJu0YzYqderZ5RAVQb5eXs2AYGqdGKLZN4Evhs/BPhkpxPsjIPXIw5X AhFhHkVCyUzNq6Wdmdm77+wvgN8QtzF4tIVwczXSwIWd7KPtxjF+nl4jkj+dXBqvOug= X-Gm-Gg: ATEYQzyGXqbbZe4SSU8wDNozIvsyyL53oSvj2UwFtsMhUuisXp2Z3SQqzpExz5Kf5d/ z1+Yd+IyPw1olsaiuEfJDG0rhaWRlE4baqGb/o9ZxBCcU5U7YHdRTN5lCXMZVq5loFIFDGZvzGQ JLXX+VbaC1ZQijHX40DZxb2DoP4x3d6dKyLYn9a6kcc7cBnQfgL80B18rKgfgoDfsLxUR+DBNOg TTtX8u5Jy3fefV/tAmj2ZEe50K/+tPPgjbCFoAGAL/RHLS4i2ov90LAMfH8r3zFbqVnRa4vZ7+V VKJ4NuBLG+pYpxOjvC0JCRUboL9/6glsVa7i1dmA3yGoC5atc9mXUTHZ1tHjbYueuuxapJL2YNT 09t3W033xI0QY3MfWxjZ3wqC0j3XxFj/LfXgU0+hhYurwEo1ildFlvuRO7Q+AT2eh1iKICEW8zd 0r+pEhzgMhhu83p3Yx1WBD1GqUImTtA8IDLvgwhpzlA0y4 X-Received: by 2002:a05:6402:4445:b0:663:9739:6279 with SMTP id 4fb4d7f45d1cf-663973967f3mr240730a12.10.1773309877960; Thu, 12 Mar 2026 03:04:37 -0700 (PDT) Received: from [192.168.0.101] ([109.77.88.70]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-6634fdc8932sm427254a12.14.2026.03.12.03.04.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 12 Mar 2026 03:04:37 -0700 (PDT) Message-ID: <11a4c0e8-de4e-4c11-862b-0c58cad969f6@linaro.org> Date: Thu, 12 Mar 2026 10:04:35 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] usb: typec: qcom: Add support for per port VBUS detection To: Alexander Koskovich , Greg Kroah-Hartman , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Heikki Krogerus Cc: linux-arm-msm@vger.kernel.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org References: <20260312-qcom-typec-shared-vbus-v2-1-99ed9e500947@pm.me> From: Bryan O'Donoghue Content-Language: en-US In-Reply-To: <20260312-qcom-typec-shared-vbus-v2-1-99ed9e500947@pm.me> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 12/03/2026 06:16, Alexander Koskovich wrote: > This is required for devices (e.g. ASUS ROG Phone 3) where more than > one USB port can act as a sink and both share a single USBIN input on > the PMIC. > > Because the PM8150B uses USBIN to determine VBUS presence, a charger > connected to one port causes the PMIC to falsely detect VBUS on the > other port, preventing it from entering source mode. > > For example, plugging a charger into one port prevents using the other > port for a flash drive. > > Fix this by adding support for the vbus-gpios connector binding so the > driver can use an external GPIO for per-port VBUS presence detection > instead of the shared USBIN register. > > Signed-off-by: Alexander Koskovich > --- > Changes in v2: > - Dropped RFC prefix > - Remove redundant vbus-detect-gpios, instead use existing vbus-gpios from usb-connector (Dmitry) > - Updated cover to better describe scenario where this change is relevant > - Update comment for EN_TRY_SRC to make more sense > - Skip vSafe5V poll too not just vSafe0V > - return gpiod_get_value_cansleep (Konrad) > - regmap_update_bits -> regmap_set_bits (Konrad) > - Get vbus-gpios per connector (Konrad) > - Add bracket to if (IS_ERR(pmic_typec_port->vbus_detect_gpio)) (Bryan) > - Link to v1: https://lore.kernel.org/r/20260308-qcom-typec-shared-vbus-v1-0-7d574b91052a@pm.me > --- > drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c | 53 +++++++++++++++++++++- > 1 file changed, 52 insertions(+), 1 deletion(-) > > 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..a8f6687a3522 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 > #include > +#include > #include > #include > #include > @@ -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; > @@ -279,6 +282,9 @@ static int qcom_pmic_typec_port_vbus_detect(struct pmic_typec_port *pmic_typec_p > unsigned int misc; > int ret; > > + if (pmic_typec_port->vbus_detect_gpio) > + return gpiod_get_value_cansleep(pmic_typec_port->vbus_detect_gpio); > + > ret = regmap_read(pmic_typec_port->regmap, > pmic_typec_port->base + TYPEC_MISC_STATUS_REG, > &misc); > @@ -310,6 +316,13 @@ static int qcom_pmic_typec_port_vbus_toggle(struct pmic_typec_port *pmic_typec_p > val = TYPEC_SM_VBUS_VSAFE0V; > } > > + /* > + * On devices with multiple ports sharing USBIN, VBUS from another > + * port makes the USBIN-based vsafe polls unreliable. > + */ > + if (pmic_typec_port->vbus_detect_gpio) > + return 0; > + > /* Poll waiting for transition to required vSafe5V or vSafe0V */ > ret = regmap_read_poll_timeout(pmic_typec_port->regmap, > pmic_typec_port->base + TYPEC_SM_STATUS_REG, > @@ -589,7 +602,15 @@ 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; > + /* > + * With VBUS present on USBIN from another port, EN_TRY_SNK > + * keeps the port in sink mode. Use EN_TRY_SRC so the port > + * tries to source first. > + */ > + if (pmic_typec_port->vbus_detect_gpio) > + mode = EN_TRY_SRC; > + else > + mode = EN_TRY_SNK; > break; > } > > @@ -677,6 +698,19 @@ 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_set_bits(pmic_typec_port->regmap, > + pmic_typec_port->base + TYPEC_EXIT_STATE_CFG_REG, > + BYPASS_VSAFE0V_DURING_ROLE_SWAP); off-by-one once fixed: Reviewed-by: Bryan O'Donoghue