From nobody Tue Dec 2 01:27:29 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2CBE02C21EB; Sun, 23 Nov 2025 08:36:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763886985; cv=none; b=rx1Y5j4CWy1qAzmN7YVHx4JaB1YBPTBPfN8ClV4txWoRZ7qyfdynrb5gn+nK8zHhHUpEnyyLGvqynoUPFHZ03mIuLELYh0ST+Htw4LF5rk1K4tm0EAuCMdI+UdDaQorecBz8f2rvqpKrpKAB7+zHvpZTw4VYir9uC6A2JTadDeo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763886985; c=relaxed/simple; bh=NSXCge/2gK6HdCYnUhX0JsiC+V4/sPRuifzpNu302Ko=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=PHxk0WO0bn2Lf6FKwW9xT6n9Zo+BzXAnhpOloTW1b2ucy9R4ZokIuKb9ccd8jdiVtr+tca4jHVj0vpwZkIDYq5vHL4ap7WoUs8mZol5wCW4us6Oj/7TtJ2wMWosyApc4X61AcxB+9qvV12x3u8MIyPlyR2Al6MATQiV9wrHnGZU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=MDDOfLXj; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="MDDOfLXj" Received: by smtp.kernel.org (Postfix) with ESMTPS id BAC6BC2BC87; Sun, 23 Nov 2025 08:36:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1763886984; bh=NSXCge/2gK6HdCYnUhX0JsiC+V4/sPRuifzpNu302Ko=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=MDDOfLXjbmK38iMwtpv6T+bQBMaPpsLpgMksu5fELVHyZ820IvLrQnw+PZH0wa83y wnb2Ykq+mVTRaPXV9J2FpJDH2S6FWJQ42WWb1CWRq5NdkM7nVCiDLHOOYzk30KY3m5 CPCcikTJO8F8Qg1e18utO4Xvk5dSYfgGVpm4hNnNEhdtQL7YY/96vbfMGEaqzsbmGA 3gsSackEVWpGLUrbFdWOdXM4ZXXiv/O44vEvMHsVm4309As/yAtJcSfDbkwCFQAyEa iGDlczPC2/iDwa/LX3sFRS7ArN4IqpnojB7LbMlzF+JA6y0ql2z4ASyobZKg/bJyDH WPX44rAYqnPxA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id AE24DCFA46B; Sun, 23 Nov 2025 08:36:24 +0000 (UTC) From: Amit Sunil Dhamne via B4 Relay Date: Sun, 23 Nov 2025 08:35:53 +0000 Subject: [PATCH 6/6] usb: typec: tcpm/tcpci_maxim: deprecate WAR for setting charger mode Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251123-max77759-charger-v1-6-6b2e4b8f7f54@google.com> References: <20251123-max77759-charger-v1-0-6b2e4b8f7f54@google.com> In-Reply-To: <20251123-max77759-charger-v1-0-6b2e4b8f7f54@google.com> To: Sebastian Reichel , Rob Herring , Krzysztof Kozlowski , Conor Dooley , =?utf-8?q?Andr=C3=A9_Draszik?= , Lee Jones , Greg Kroah-Hartman , Badhri Jagan Sridharan , Heikki Krogerus , Peter Griffin , Tudor Ambarus , Alim Akhtar Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, RD Babiera , Kyle Tso , Amit Sunil Dhamne X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1763886983; l=3355; i=amitsd@google.com; s=20241031; h=from:subject:message-id; bh=/TCo7ex1368Y86Fyq12+zxO0JMAaguRjxNQAlVy2Xs4=; b=AbMrYbmLH+QdUL9CL7s7kJK/2G1npTiYCzh32EVJI3e7OLGe8+jBNNLdNv4i9tXM4szINi7cR 4GPEFAgPppFBIjWh14daHEhdhLZRZLO/6tuefrflLnuJBp85smrtfj/ X-Developer-Key: i=amitsd@google.com; a=ed25519; pk=wD+XZSST4dmnNZf62/lqJpLm7fiyT8iv462zmQ3H6bI= X-Endpoint-Received: by B4 Relay for amitsd@google.com/20241031 with auth_id=262 X-Original-From: Amit Sunil Dhamne Reply-To: amitsd@google.com From: Amit Sunil Dhamne TCPCI maxim driver directly writes to the charger's register space to set charger mode depending on the power role. As MAX77759 chg driver exists, this WAR is not required. Instead, use a regulator interface to set OTG Boost mode. Signed-off-by: Amit Sunil Dhamne --- drivers/usb/typec/tcpm/tcpci_maxim.h | 1 + drivers/usb/typec/tcpm/tcpci_maxim_core.c | 48 +++++++++++++++++++++------= ---- 2 files changed, 34 insertions(+), 15 deletions(-) diff --git a/drivers/usb/typec/tcpm/tcpci_maxim.h b/drivers/usb/typec/tcpm/= tcpci_maxim.h index b33540a42a95..6c82a61efe46 100644 --- a/drivers/usb/typec/tcpm/tcpci_maxim.h +++ b/drivers/usb/typec/tcpm/tcpci_maxim.h @@ -60,6 +60,7 @@ struct max_tcpci_chip { struct tcpm_port *port; enum contamiant_state contaminant_state; bool veto_vconn_swap; + struct regulator *otg_reg; }; =20 static inline int max_tcpci_read16(struct max_tcpci_chip *chip, unsigned i= nt reg, u16 *val) diff --git a/drivers/usb/typec/tcpm/tcpci_maxim_core.c b/drivers/usb/typec/= tcpm/tcpci_maxim_core.c index 19f638650796..6d819a762fa1 100644 --- a/drivers/usb/typec/tcpm/tcpci_maxim_core.c +++ b/drivers/usb/typec/tcpm/tcpci_maxim_core.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -202,32 +203,49 @@ static void process_rx(struct max_tcpci_chip *chip, u= 16 status) tcpm_pd_receive(chip->port, &msg, rx_type); } =20 +static int get_otg_regulator_handle(struct max_tcpci_chip *chip) +{ + if (IS_ERR_OR_NULL(chip->otg_reg)) { + chip->otg_reg =3D devm_regulator_get_exclusive(chip->dev, + "otg-vbus"); + if (IS_ERR_OR_NULL(chip->otg_reg)) { + dev_err(chip->dev, + "Failed to get otg regulator handle"); + return -ENODEV; + } + } + + return 0; +} + static int max_tcpci_set_vbus(struct tcpci *tcpci, struct tcpci_data *tdat= a, bool source, bool sink) { struct max_tcpci_chip *chip =3D tdata_to_max_tcpci(tdata); - u8 buffer_source[2] =3D {MAX_BUCK_BOOST_OP, MAX_BUCK_BOOST_SOURCE}; - u8 buffer_sink[2] =3D {MAX_BUCK_BOOST_OP, MAX_BUCK_BOOST_SINK}; - u8 buffer_none[2] =3D {MAX_BUCK_BOOST_OP, MAX_BUCK_BOOST_OFF}; - struct i2c_client *i2c =3D chip->client; int ret; =20 - struct i2c_msg msgs[] =3D { - { - .addr =3D MAX_BUCK_BOOST_SID, - .flags =3D i2c->flags & I2C_M_TEN, - .len =3D 2, - .buf =3D source ? buffer_source : sink ? buffer_sink : buffer_none, - }, - }; - if (source && sink) { dev_err(chip->dev, "Both source and sink set\n"); return -EINVAL; } =20 - ret =3D i2c_transfer(i2c->adapter, msgs, 1); + ret =3D get_otg_regulator_handle(chip); + if (ret) { + /* + * Regulator is not necessary for sink only applications. Return + * success in cases where sink mode is being modified. + */ + return source ? ret : 1; + } + + if (source) { + if (!regulator_is_enabled(chip->otg_reg)) + ret =3D regulator_enable(chip->otg_reg); + } else { + if (regulator_is_enabled(chip->otg_reg)) + ret =3D regulator_disable(chip->otg_reg); + } =20 - return ret < 0 ? ret : 1; + return ret < 0 ? ret : 1; } =20 static void process_power_status(struct max_tcpci_chip *chip) --=20 2.52.0.rc2.455.g230fcf2819-goog