From nobody Fri Apr 3 09:28:51 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 E1873335097; Wed, 18 Feb 2026 21:59:23 +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=1771451964; cv=none; b=MNYXbkS49noA8gWSnhOdZNZdEznlZm0gyBw0jqynMmHHwvSK1Bb4UHe5pmo4i2OT/RioCx4eivOukf2TWBzgBeH7wvzM3wkHb3h5vNFYsMS8nXifoWfhxS2Io3w5zDxH3hYbs0eoVzrTlQG9vJdr0rU1EeV0Zs1nfh7u8FHOD5E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771451964; c=relaxed/simple; bh=5U7L/WTZmt9SXXIboQvo6iEiAWNT+LVn722PCjM2SoE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=mggMmIqQXIH0ss6SDC3WtYc8LzNN7ZGE/uOXcpX8ZehGXsP/obx4UOgd1WnEkJXGPSqDb5gACDzeq94A0ojsHNVtqloDMZoseCYC1Rnh6ia4rzjZ/jN5Ik7v0jOqUzNZ2rvHgC6NLwMjLEyd738mW8mPNEaMt7eDZ56iqUrsHuU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Z1uJsEtO; 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="Z1uJsEtO" Received: by smtp.kernel.org (Postfix) with ESMTPS id A1EF7C2BCB0; Wed, 18 Feb 2026 21:59:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1771451963; bh=5U7L/WTZmt9SXXIboQvo6iEiAWNT+LVn722PCjM2SoE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=Z1uJsEtO0EqgdXIukzCGscuT20ArcTKsdxYihd+r/E2X744i49ey9sKa7xEl4WurC sOwIQNDrHHzH1fdyCh4M/fAHO+CY7UkpEO0rSE/37aPoTrGSDBEGdqRDd8X6/cCCVs MWz+XwWqH3+kG4Ol6G4r9Uc2thpW8oprWQZZ8PvRLiREZRgSApjBD4eugb4xr9og7r M5hb4/uOAadw+Le5rdNOOCPoikllsCPTjvqueUhekFZnB+zWS9NdvunV618G0HQD1Z s/eQyd85pLpXRq+uRP5kLJ6PaOwfWx359Q/0ZyZAKUXuCgohho+0GJB+xXW8Thn0ka 3g1xEGICbawcQ== 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 98ED1E9A04E; Wed, 18 Feb 2026 21:59:23 +0000 (UTC) From: Amit Sunil Dhamne via B4 Relay Date: Wed, 18 Feb 2026 21:59:14 +0000 Subject: [PATCH v7 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: <20260218-max77759-charger-v7-6-e8d907ce69c5@google.com> References: <20260218-max77759-charger-v7-0-e8d907ce69c5@google.com> In-Reply-To: <20260218-max77759-charger-v7-0-e8d907ce69c5@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 , Mark Brown , Matti Vaittinen , Andrew Morton 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=1771451962; l=4043; i=amitsd@google.com; s=20241031; h=from:subject:message-id; bh=uZk9qfSWv4kN+EgweqrzKq0M0KWOUf2Zux+k8glvduw=; b=LeyfbPuzzBsNlLUcBhWOWYjV9+YmIEFHOJUKs3FfJS/UY+lAYFSPdVjfZWRgQ+N8tq6KlONMX kmdtEnvnyuMAlwAlFnq6YwQCDoGtsaYeBjudIGEQRbV5qgT4pgoQ4MW 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.371.g1d285c8824-goog