From nobody Mon Feb 9 19:53:53 2026 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 B2732374758; Tue, 3 Feb 2026 22:51:16 +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=1770159076; cv=none; b=pgUDfrSqbXoT4aR+6iSx4uiSOZd+AkSm5FW5w/2ttREcaHwZ/M+71bjTHAqZ/kvXarwvUac61nzsjGCAMGyPRAMEkZfJSsTjwMF34fBYOJw3qs3KNHcCpsIUk5qz0hwrJ+VxITQudjW45d4pP99cB/Y/muBZYvc2EtMJ5CGE1QA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770159076; c=relaxed/simple; bh=x5l6L76bIyObE98V1AMZSCPiXBprN9x6wKcuM4vyGCs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qz58mHroMLRsPLfOz8DYxlRxUpX9WG9rgTdmRUtlfl6DOKCaGgxhoht1TVrXP02V75NCuDpw0Jw1JCB8Xct8pl/Oy2lgCmwKD7HXxNCVeguRgtLOZH9dS1rAv2y+hx3yyRd3DGGZwYbmYuY+ls/k9O+2+MhQf5z0CaXzs0rld84= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZZx1Iq7h; 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="ZZx1Iq7h" Received: by smtp.kernel.org (Postfix) with ESMTPS id 95631C19425; Tue, 3 Feb 2026 22:51:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1770159076; bh=x5l6L76bIyObE98V1AMZSCPiXBprN9x6wKcuM4vyGCs=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=ZZx1Iq7hdeQwip2aOnYmX4gspMBunrojV4zhw1+QkWgVCCXcY2HcMO2f3RLDPV6e5 tjfufeZyyziUvcectEsxuubPaUoEDwuUPvJREJ8eLra51BeLjQeaINLxj+QdvSJ818 9XDecjIv69F0XvWW6u26ketPyk45rZDcy8R3tATDJQrQ0Vf+BvkeTN1taNJfVhh6LW wE7grJ1hWVxdJI1La9hkHOyFkI9mYnvv13x5HXh9BhrvCp3YomjHutB4V4+OjfHWDz D5TdNpRvhlNNazCcQvONvbCHDtddgfco6K0iTnLXEvRv+DMMFPt7+eXo+/GAcubPS0 b0EQSySoUVU3Q== 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 85722E8B37E; Tue, 3 Feb 2026 22:51:16 +0000 (UTC) From: Amit Sunil Dhamne via B4 Relay Date: Tue, 03 Feb 2026 22:50:31 +0000 Subject: [PATCH v5 5/5] 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: <20260203-max77759-charger-v5-5-b50395376a5f@google.com> References: <20260203-max77759-charger-v5-0-b50395376a5f@google.com> In-Reply-To: <20260203-max77759-charger-v5-0-b50395376a5f@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.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1770159075; l=4047; i=amitsd@google.com; s=20241031; h=from:subject:message-id; bh=DVhKKtAmFJeTde3lBLRKS7iTM2jYoSejns4c8Q7KrrM=; b=b0GO3q1YufX0GQelLtqZNXAOGw6l83elJv47namzZa5QOjjUjJ2hMMY/Pbsbe0+J0pd85DTbg 3NPQKZB5AevBcaCB7cBaBEI7zOGiBDb0w89cvkYwb/OQ3kuzCU8lDH7 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 source vbus when typec is in source power mode. In other power modes, this regulator will be turned off if active. Signed-off-by: Amit Sunil Dhamne Reviewed-by: Heikki Krogerus Reviewed-by: Andr=C3=A9 Draszik --- drivers/usb/typec/tcpm/tcpci_maxim.h | 1 + drivers/usb/typec/tcpm/tcpci_maxim_core.c | 54 +++++++++++++++++++--------= ---- 2 files changed, 34 insertions(+), 21 deletions(-) diff --git a/drivers/usb/typec/tcpm/tcpci_maxim.h b/drivers/usb/typec/tcpm/= tcpci_maxim.h index b33540a42a953dc6d8197790ee4af3b6f52791ce..b314606eb0f67ddbc80d8760244= aa6dee61bebc1 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 *vbus_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 19f63865079658fb2a446dc390262d141b940e9a..e9e2405c5ca036e28c307088d4b= 785726834e71f 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 @@ -35,12 +36,6 @@ */ #define TCPC_RECEIVE_BUFFER_LEN 32 =20 -#define MAX_BUCK_BOOST_SID 0x69 -#define MAX_BUCK_BOOST_OP 0xb9 -#define MAX_BUCK_BOOST_OFF 0 -#define MAX_BUCK_BOOST_SOURCE 0xa -#define MAX_BUCK_BOOST_SINK 0x5 - static const struct regmap_range max_tcpci_tcpci_range[] =3D { regmap_reg_range(0x00, 0x95) }; @@ -202,32 +197,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_vbus_regulator_handle(struct max_tcpci_chip *chip) +{ + if (IS_ERR_OR_NULL(chip->vbus_reg)) { + chip->vbus_reg =3D devm_regulator_get_exclusive(chip->dev, + "vbus"); + if (IS_ERR_OR_NULL(chip->vbus_reg)) { + dev_err(chip->dev, + "Failed to get vbus 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_vbus_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->vbus_reg)) + ret =3D regulator_enable(chip->vbus_reg); + } else { + if (regulator_is_enabled(chip->vbus_reg)) + ret =3D regulator_disable(chip->vbus_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.53.0.rc2.204.g2597b5adb4-goog