From nobody Mon Sep 28 21:08:50 2026 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (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 100963F5BDE for ; Mon, 17 Aug 2026 10:15:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786961708; cv=none; b=hosiJjUVpcxBmRr4uQK/SSjs58vNLZOMBBYJ0NWEYW2EYsSyUIFDpw1ZKdU0gLd0zoYzLnGnyJABMNmUdtivsf9In/wDP9u96IdpqplVCiCBj+aVesWd8J7fnMFojZsnv0XwVpISx8wLgGP9TdrADX7RqAGsE5qYEQou8hUorc0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786961708; c=relaxed/simple; bh=f5l2YBiHkReBw6mWMyjaq6Gvj9uLpAZQHQ7JL9lOPpM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=quhGwcmD+zfdMyVJ0iJ1QGwGZZL3c2uTBOeeEec2IzHeDnU9sqUk0QXm2JrfepM8aCQiR+xAHEa4S0nlMYiJcoJ+uv04WkCBlEQCjKD56jJQOEf3fL9sEgPr+kdTwk+1zCXoRSjp2RfHN/Efq6YqUHMbJuGXTdaqu5noB56R+ME= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre.com header.i=@baylibre.com header.b=Qxqtvd7r; arc=none smtp.client-ip=209.85.128.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre.com header.i=@baylibre.com header.b="Qxqtvd7r" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-4953de5be0aso23863905e9.0 for ; Mon, 17 Aug 2026 03:15:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre.com; s=google; t=1786961703; x=1787566503; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=NsOh5BrhIIUs/llyHwp9VM8wWS+EomkE8Zt9vFaD5xw=; b=Qxqtvd7rT81y/Y0ZH0wCx1SqG12II1z7nkNE5YwiVTFiutRPLCbVbNIFy+xfZKwhF0 RUU/PivdVAvv60LgQdBI7pPuDJQTbIMyjoNoaTGpTMj7Qm/wColgA7UlO4DrFZE+5IeJ tFpmg75DCah+k9xhJG30AYANlAB3LlrqtFBPUHd8Y9psZx/9mdkF3UbFNB6Wxki4v4ya 25jaWp6f+Bg4Nhqy1UFEW2iDkaXXOSHn1s3yxm8QbMgYUCehZ8ItY4ircR34Hs5X/Htp Eq09VrOuZOXVx6urMarjS6YlKQrE+Pq9Vliks3NJKaNprPIurc4FNyikYg/gGyDmuPkE 3Xcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786961703; x=1787566503; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=NsOh5BrhIIUs/llyHwp9VM8wWS+EomkE8Zt9vFaD5xw=; b=Xvmv7oMeKn0Yn5Y1vg0zsgHsL6Ou6ZwpOhrblj6qwHiyX1dcAxi5uJqIflZ1bh3uCZ NFa4tyRd2jpvkLaNWnGKL9eDdOfxJ7DU4rlo4JohWhJsje4dlVDSRZ24Lspg7sR7sJru ps5QL3U3SH83VZXOkTsJ580DOZ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VNoDB0DkfUFIS X-Received: by 2002:a7b:c015:0:b0:499:80d0:8b73 with SMTP id 5b1f17b1804b1-49987927ebfmr303753805e9.4.1786961703220; Mon, 17 Aug 2026 03:15:03 -0700 (PDT) Received: from silence.. ([46.10.240.40]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4999d06167csm29542255e9.3.2026.08.17.03.15.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Aug 2026 03:15:02 -0700 (PDT) From: Stoyan Bogdanov To: jbrunet@baylibre.com, linux@roeck-us.net, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, corbet@lwn.net, skhan@linuxfoundation.org Cc: linux-hwmon@vger.kernel.org, devicetree@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Stoyan Bogdanov Subject: [PATCH v7 1/3] hwmon: (pmbus/tps25990): Rework driver for multi-device support Date: Mon, 17 Aug 2026 13:14:43 +0300 Message-ID: <20260817101455.3526260-2-sbogdanov@baylibre.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260817101455.3526260-1-sbogdanov@baylibre.com> References: <20260817101455.3526260-1-sbogdanov@baylibre.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Rework existing implementation to allow adding support for new devices to the existing driver. chip_id is used to identify the current device and differentiate logic where needed. Changes include: - Add an enum listing supported chips - Add a structure to hold per-device m, b, R coefficients Signed-off-by: Stoyan Bogdanov --- drivers/hwmon/pmbus/tps25990.c | 123 +++++++++++++++++++-------------- 1 file changed, 70 insertions(+), 53 deletions(-) diff --git a/drivers/hwmon/pmbus/tps25990.c b/drivers/hwmon/pmbus/tps25990.c index 9d318e6509ab..7634ac743025 100644 --- a/drivers/hwmon/pmbus/tps25990.c +++ b/drivers/hwmon/pmbus/tps25990.c @@ -47,6 +47,15 @@ PK_MIN_AVG_RST_AVG | \ PK_MIN_AVG_RST_MIN) =20 +enum chips { + tps25990, +}; + +struct tps25990_data { + struct pmbus_driver_info info; + enum chips chip_id; +}; + /* * Arbitrary default Rimon value: 1kOhm * This correspond to an overcurrent limit of 55A, close to the specified = limit @@ -337,63 +346,65 @@ static const struct regulator_desc tps25990_reg_desc[= ] =3D { }; #endif =20 -static const struct pmbus_driver_info tps25990_base_info =3D { - .pages =3D 1, - .format[PSC_VOLTAGE_IN] =3D direct, - .m[PSC_VOLTAGE_IN] =3D 5251, - .b[PSC_VOLTAGE_IN] =3D 0, - .R[PSC_VOLTAGE_IN] =3D -2, - .format[PSC_VOLTAGE_OUT] =3D direct, - .m[PSC_VOLTAGE_OUT] =3D 5251, - .b[PSC_VOLTAGE_OUT] =3D 0, - .R[PSC_VOLTAGE_OUT] =3D -2, - .format[PSC_TEMPERATURE] =3D direct, - .m[PSC_TEMPERATURE] =3D 140, - .b[PSC_TEMPERATURE] =3D 32100, - .R[PSC_TEMPERATURE] =3D -2, - /* - * Current and Power measurement depends on the ohm value - * of Rimon. m is multiplied by 1000 below to have an integer - * and -3 is added to R to compensate. - */ - .format[PSC_CURRENT_IN] =3D direct, - .m[PSC_CURRENT_IN] =3D 9538, - .b[PSC_CURRENT_IN] =3D 0, - .R[PSC_CURRENT_IN] =3D -6, - .format[PSC_POWER] =3D direct, - .m[PSC_POWER] =3D 4901, - .b[PSC_POWER] =3D 0, - .R[PSC_POWER] =3D -7, - .func[0] =3D (PMBUS_HAVE_VIN | - PMBUS_HAVE_VOUT | - PMBUS_HAVE_VMON | - PMBUS_HAVE_IIN | - PMBUS_HAVE_PIN | - PMBUS_HAVE_TEMP | - PMBUS_HAVE_STATUS_VOUT | - PMBUS_HAVE_STATUS_IOUT | - PMBUS_HAVE_STATUS_INPUT | - PMBUS_HAVE_STATUS_TEMP | - PMBUS_HAVE_SAMPLES), - .read_word_data =3D tps25990_read_word_data, - .write_word_data =3D tps25990_write_word_data, - .read_byte_data =3D tps25990_read_byte_data, - .write_byte_data =3D tps25990_write_byte_data, +static const struct pmbus_driver_info tps25990_base_info[] =3D { + [tps25990] =3D { + .pages =3D 1, + .format[PSC_VOLTAGE_IN] =3D direct, + .m[PSC_VOLTAGE_IN] =3D 5251, + .b[PSC_VOLTAGE_IN] =3D 0, + .R[PSC_VOLTAGE_IN] =3D -2, + .format[PSC_VOLTAGE_OUT] =3D direct, + .m[PSC_VOLTAGE_OUT] =3D 5251, + .b[PSC_VOLTAGE_OUT] =3D 0, + .R[PSC_VOLTAGE_OUT] =3D -2, + .format[PSC_TEMPERATURE] =3D direct, + .m[PSC_TEMPERATURE] =3D 140, + .b[PSC_TEMPERATURE] =3D 32100, + .R[PSC_TEMPERATURE] =3D -2, + /* + * Current and Power measurement depends on the ohm value + * of Rimon. m is multiplied by 1000 below to have an integer + * and -3 is added to R to compensate. + */ + .format[PSC_CURRENT_IN] =3D direct, + .m[PSC_CURRENT_IN] =3D 9538, + .b[PSC_CURRENT_IN] =3D 0, + .R[PSC_CURRENT_IN] =3D -6, + .format[PSC_POWER] =3D direct, + .m[PSC_POWER] =3D 4901, + .b[PSC_POWER] =3D 0, + .R[PSC_POWER] =3D -7, + .func[0] =3D (PMBUS_HAVE_VIN | + PMBUS_HAVE_VOUT | + PMBUS_HAVE_VMON | + PMBUS_HAVE_IIN | + PMBUS_HAVE_PIN | + PMBUS_HAVE_TEMP | + PMBUS_HAVE_STATUS_VOUT | + PMBUS_HAVE_STATUS_IOUT | + PMBUS_HAVE_STATUS_INPUT | + PMBUS_HAVE_STATUS_TEMP | + PMBUS_HAVE_SAMPLES), + .read_word_data =3D tps25990_read_word_data, + .write_word_data =3D tps25990_write_word_data, + .read_byte_data =3D tps25990_read_byte_data, + .write_byte_data =3D tps25990_write_byte_data, =20 #if IS_ENABLED(CONFIG_SENSORS_TPS25990_REGULATOR) - .reg_desc =3D tps25990_reg_desc, - .num_regulators =3D ARRAY_SIZE(tps25990_reg_desc), + .reg_desc =3D tps25990_reg_desc, + .num_regulators =3D ARRAY_SIZE(tps25990_reg_desc), #endif + }, }; =20 static const struct i2c_device_id tps25990_i2c_id[] =3D { - { .name =3D "tps25990" }, - { } + { .name =3D "tps25990", .driver_data =3D tps25990 }, + {} }; MODULE_DEVICE_TABLE(i2c, tps25990_i2c_id); =20 static const struct of_device_id tps25990_of_match[] =3D { - { .compatible =3D "ti,tps25990" }, + { .compatible =3D "ti,tps25990", .data =3D (void *)tps25990 }, {} }; MODULE_DEVICE_TABLE(of, tps25990_of_match); @@ -401,8 +412,9 @@ MODULE_DEVICE_TABLE(of, tps25990_of_match); static int tps25990_probe(struct i2c_client *client) { struct device *dev =3D &client->dev; - struct pmbus_driver_info *info; + struct tps25990_data *data; const char *propname; + enum chips chip_id; u32 rimon; int ret; =20 @@ -415,15 +427,20 @@ static int tps25990_probe(struct i2c_client *client) rimon =3D TPS25990_DEFAULT_RIMON; } =20 - info =3D devm_kmemdup(dev, &tps25990_base_info, sizeof(*info), GFP_KERNEL= ); - if (!info) + chip_id =3D (enum chips)(unsigned long)i2c_get_match_data(client); + + data =3D devm_kzalloc(dev, sizeof(struct tps25990_data), GFP_KERNEL); + if (!data) return -ENOMEM; =20 + data->info =3D tps25990_base_info[chip_id]; + data->chip_id =3D chip_id; + /* Adapt the current and power scale for each instance */ - tps25990_set_m(&info->m[PSC_CURRENT_IN], rimon); - tps25990_set_m(&info->m[PSC_POWER], rimon); + tps25990_set_m(&data->info.m[PSC_CURRENT_IN], rimon); + tps25990_set_m(&data->info.m[PSC_POWER], rimon); =20 - return pmbus_do_probe(client, info); + return pmbus_do_probe(client, &data->info); } =20 static struct i2c_driver tps25990_driver =3D { --=20 2.43.0 From nobody Mon Sep 28 21:08:50 2026 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (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 C2E5B3F7A9F for ; Mon, 17 Aug 2026 10:15:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786961708; cv=none; b=YR4e/jA+3EWbqZ9/Ai1DWr8TQj31hnMlTSiO7k4AT5Mtu+dC5Bf6zjY2zQO3WOCTSm9EOjuCc4C+UkPUBbTaUWaCPcI13H2lZ+5ztc/H+tgILsbyX/wQpn9A8MvHDoQRjOABniHHRyKC8uVbzvApClBIlFjHpvWjEHo7p1NZwIA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786961708; c=relaxed/simple; bh=3DzBepA5OaBxS3rEqzaa//JlAmU/tnAvZdNl+JJosYM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=m9Bejunms7LcEM4OYdIdbqfGNm3sn53fM9PZ7idwef7ogE2q6xcwK6xJpOwJwXRat1WOyQ8qfPMgM63PBBsBoJwdLREnN1xZmxZh68gKUs0MDA5FA21dCfyRdbGFDnXrCBU0Gncd4Y/mPCT0ZQGO+ZD1xotWPKkjZsQbT7tcR5M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre.com header.i=@baylibre.com header.b=TJ5iRcym; arc=none smtp.client-ip=209.85.128.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre.com header.i=@baylibre.com header.b="TJ5iRcym" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-4998e0916faso15119285e9.2 for ; Mon, 17 Aug 2026 03:15:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre.com; s=google; t=1786961705; x=1787566505; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=r1aINRhdCxbmlFp0SOoS/8BQxCjj22TF2jiFyvu2ZRU=; b=TJ5iRcymvPvgCwbT4ggwBvIwopS347JUMjptTsUE1KGh/hNhsuF7f/WeIh/ZsQb1lK 49zX+3sRTKgZFUumC0bnYbyQgeqoXTGqDXqhrBWB0E161KNaHC2IBl2y+QepRT4wgzz0 dxalwafQZ5mFcTPYOXIn0vAxwRy30NXGXDAbf3+koCLphv9t67riL3pqKYIBr4MLKNKi XiUHlGcpORPVxzfRc3SQM07ToWi7IIJRyl5W0Xg8LzJvlhZs2INlbU51QHeKM7IImFnB lk33dCzHKFM5ElYhCpKfNvMkVOl9aJwFgfwjkdE5UnSJbfMbU6KcBFkam1zgXPTaxeO8 Y1lQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786961705; x=1787566505; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=r1aINRhdCxbmlFp0SOoS/8BQxCjj22TF2jiFyvu2ZRU=; b=ZfS82pIl4vm4WUDAIT1zVrwHSbHc2otSbKp3rrlEIqDtAuIkcMyCKW1SKdrLUll76c fcd9WI1O4TYm76GbdrfTYTG31HOUyJA4VNUDnLVcDiIyO2uLV5tZFnQD6o74l3HbgNSS XXRenz1ySLy2h3LH/bCAkeFpxnEv4Y77W8fmPYwpKJZrc3X2aJRy8i3/XyXvsYxb1Q1m w8f1zBStywhFSPLV4G1lST8qhE3a7L0Y2vqTDYcwVhEVUMy7qA965YgrB7nTHaWNmFGk QX+/xAMKG7J6h3SEpzUI0rskC509gt0pMzS/lRDq7v0WJ2uTyLsBylmH+7l6nWsmLnaF MDQw== X-Forwarded-Encrypted: i=1; AHgh+Ro+ishIemaU+NMYPrmCJsML9crufCyxttIm3DBiXSTBxN7k8VHp00qr3/MLfdakGAg6WcQrhC2UCu7nt60=@vger.kernel.org X-Gm-Message-State: AOJu0Yxs/sfPF4lv5fqHE5WJ2Bs0+AMC0fonOfXnFlfD/EUOoCxDdfaN N9x2/5Mvh2x8issY7frGyhCOWqLZD1fSK2nM+myyzQKQodVn9paVL2JizQ0UMDXLCNE= X-Gm-Gg: AR+sD132GtyWh8+wGtFiRBX8nj3ChvtKEMWxOFq1qxqlC6wTZqb6rNIw1Qh7wEh0dOT KIJ3J2zjh5eUSERKkurqCdKcSI9fJrj6UiTNeGufsq+DFjCDdy9BPu4j2jdUhgfaIH/QNtbAeXD S34smc9wLRiVpXe3jM2MbkTn6q0AkOfYHAVsdNvFPzYKAVj4l6AVQ3qu9EkpHZB+2na82tA9I9/ E9IuZyiDpxnLy1U59bdud65sN9CeK1v6i27cAjkV6xLkn1ai1NC5Z7mt0bwXxHDanEhkrFOEJGu 7Gy2fuii4uZeYiF7OICK6ey7LRH6n7Icfl85/g9oOWUSKaLGjYIKqLMOVXo78bwY3IKS6okUagj 8kGu3G+ZSL19cHOB7cvUk55X7558xoa1calhpF6KWVteXDgzyJSaH2hSVhhUeoGMIfovFrlSC1h CWLrgjlwMNSHm1Bw4fmecxcTPCm/HdCK2P64p1ZdgAM9w8u6+/OoUuYHac0wqteGuyrgxZmupuU eo0GEw9UjypcFYqtEMJ/O9Dgt8GZHpoijqwY08lDWdA+/ri1kJ5J9nAYGB10qBFMlszWvv2DPBg 8O/O/5OR4xuE+uxUel/sv/hKpM0EwBlK7Gt6dLRb X-Received: by 2002:a05:600c:4690:b0:498:2b1f:e0c6 with SMTP id 5b1f17b1804b1-499879af606mr341527175e9.18.1786961705026; Mon, 17 Aug 2026 03:15:05 -0700 (PDT) Received: from silence.. ([46.10.240.40]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4999d06167csm29542255e9.3.2026.08.17.03.15.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Aug 2026 03:15:04 -0700 (PDT) From: Stoyan Bogdanov To: jbrunet@baylibre.com, linux@roeck-us.net, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, corbet@lwn.net, skhan@linuxfoundation.org Cc: linux-hwmon@vger.kernel.org, devicetree@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Stoyan Bogdanov , Krzysztof Kozlowski Subject: [PATCH v7 2/3] dt-bindings: hwmon: pmbus/tps25990: Add TPS1689 Date: Mon, 17 Aug 2026 13:14:44 +0300 Message-ID: <20260817101455.3526260-3-sbogdanov@baylibre.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260817101455.3526260-1-sbogdanov@baylibre.com> References: <20260817101455.3526260-1-sbogdanov@baylibre.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add device compatible support for TPS1689 Signed-off-by: Stoyan Bogdanov Acked-by: Krzysztof Kozlowski --- .../devicetree/bindings/hwmon/pmbus/ti,tps25990.yaml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/hwmon/pmbus/ti,tps25990.yaml= b/Documentation/devicetree/bindings/hwmon/pmbus/ti,tps25990.yaml index f4115870e450..63ccb67576df 100644 --- a/Documentation/devicetree/bindings/hwmon/pmbus/ti,tps25990.yaml +++ b/Documentation/devicetree/bindings/hwmon/pmbus/ti,tps25990.yaml @@ -5,18 +5,20 @@ $id: http://devicetree.org/schemas/hwmon/pmbus/ti,tps25990.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# =20 -title: Texas Instruments TPS25990 Stackable eFuse +title: Texas Instruments Stackable eFuses =20 maintainers: - Jerome Brunet =20 description: - The TI TPS25990 is an integrated, high-current circuit + The TI TPS25990 and TPS1689 are integrated, high-current circuit protection and power management device with PMBUS interface =20 properties: compatible: - const: ti,tps25990 + enum: + - ti,tps1689 + - ti,tps25990 =20 reg: maxItems: 1 --=20 2.43.0 From nobody Mon Sep 28 21:08:50 2026 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (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 A73643F824B for ; Mon, 17 Aug 2026 10:15:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786961714; cv=none; b=ZBbm92VHF3LNXj5JcPg7Mz06vkUBucf2cpEouvAl2SBCBuQMGsJ4Qtej9HRea7+H2aSkvFr9COBuKCUAmI9uwlDBDXIwkVQHfNa84ENropLSrmnuJtFAMJhMFZGQDhq9+PrfCOCiSC76CfLsHKGl9M1VXQsdO6pD4MdNTW4MFT8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786961714; c=relaxed/simple; bh=cl6IXKUS593kRSvJMvuLwkLWuyMba6O4c1F1EXzKBvU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nGSyOLJcO6+SUfYWmKKgxOl9RRwDTkTxH7SL3cg2FqBJ6+jFz/rn9IMMkfnX8mem0gm54Eoojao5N5eviMxUjYN36sr3HXRkVHxUdkkzkJucyg0Ew4qS7c8ogXCJoaXMRksf/8btaiLZE5NnBkN1UsCDMV9NO0Gvo68Gqdde/1M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre.com header.i=@baylibre.com header.b=lrqnWAYO; arc=none smtp.client-ip=209.85.128.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre.com header.i=@baylibre.com header.b="lrqnWAYO" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-493b966dd74so21113425e9.3 for ; Mon, 17 Aug 2026 03:15:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre.com; s=google; t=1786961707; x=1787566507; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=iOxzGmMal27EeaJMwS+enIkrJ4wpyBeUYl/DuJWKH74=; b=lrqnWAYOtzPOD7nJWFCrIn690t3Jgz0WtUASxW/GtjcKMaLHSz2LzlcBn5wdjU0Y5f 7+uvGUdtPldnVmiMdPz9I1HL5auiclBGkmxGRbAnVDU87hgK3r28B/muhgbhCogIp8XE ucun7GY5KDRnmMi9Ajae4ATcuflKd/ZUwGXWyayVIYwV/50l3ay0nnvJ4Y/fDDmco0OE fqx+0mVAcp27yZ4gv9vSkkUJcTdH9QCT8cn0JP3ZMfsDLIMqhcUQm3dfKRmxq3EoM1fx +FB3s/zcQUKo7i4jARtsjX8idtdHJLveDWM2RLaIQEnr4aH8FymOEK+uqPTIL2WZVhYA 8LBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786961707; x=1787566507; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=iOxzGmMal27EeaJMwS+enIkrJ4wpyBeUYl/DuJWKH74=; b=no4OPax4KbMKLIdDsp/YgJi81yleriAeMHVXnNV7kLQde2pHopejXj0N0t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XyaFEA9XqrIuE0XWjp99TeAZTI3fw1GCloPZ09lqyxQTweyfknxEil4l3j/MolQtN9qSYIC KurexjaJWNqsB0DQv1vrJc22B6BQ2k9Iw3e19VvC X-Received: by 2002:a05:600c:5299:b0:493:aa0a:45ad with SMTP id 5b1f17b1804b1-4998d7aeb77mr283748675e9.2.1786961706896; Mon, 17 Aug 2026 03:15:06 -0700 (PDT) Received: from silence.. ([46.10.240.40]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4999d06167csm29542255e9.3.2026.08.17.03.15.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Aug 2026 03:15:06 -0700 (PDT) From: Stoyan Bogdanov To: jbrunet@baylibre.com, linux@roeck-us.net, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, corbet@lwn.net, skhan@linuxfoundation.org Cc: linux-hwmon@vger.kernel.org, devicetree@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Stoyan Bogdanov Subject: [PATCH v7 3/3] hwmon: (pmbus/tps25990): Add TPS1689 support Date: Mon, 17 Aug 2026 13:14:45 +0300 Message-ID: <20260817101455.3526260-4-sbogdanov@baylibre.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260817101455.3526260-1-sbogdanov@baylibre.com> References: <20260817101455.3526260-1-sbogdanov@baylibre.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Extend the existing TPS25990 driver to support the TPS1689 eFuse, as both devices share the same command interface and functionality. Update the documentation to include TPS1689 support. Signed-off-by: Stoyan Bogdanov --- Documentation/hwmon/tps25990.rst | 15 ++-- drivers/hwmon/pmbus/tps25990.c | 126 ++++++++++++++++++++++++++++--- 2 files changed, 124 insertions(+), 17 deletions(-) diff --git a/Documentation/hwmon/tps25990.rst b/Documentation/hwmon/tps2599= 0.rst index 04faec780d26..e8bc9a550bda 100644 --- a/Documentation/hwmon/tps25990.rst +++ b/Documentation/hwmon/tps25990.rst @@ -9,26 +9,31 @@ Supported chips: =20 Prefix: 'tps25990' =20 - * Datasheet + Datasheet: Publicly available at Texas Instruments website: https://ww= w.ti.com/lit/gpn/tps25990 =20 - Publicly available at Texas Instruments website: https://www.ti.com/li= t/gpn/tps25990 + * TI TPS1689 + + Prefix: 'tps1689' + + Datasheet: Publicly available at Texas Instruments website: https://ww= w.ti.com/lit/gpn/tps1689 =20 Author: =20 Jerome Brunet + Stoyan Bogdanov =20 Description ----------- =20 -This driver implements support for TI TPS25990 eFuse. +This driver implements support for TI TPS25990 and TI TPS1689 eFuse chips. This is an integrated, high-current circuit protection and power management device with PMBUS interface =20 -Device compliant with: +Devices are compliant with: =20 - PMBus rev 1.3 interface. =20 -Device supports direct format for reading input voltages, +Devices supports direct format for reading input voltages, output voltage, input current, input power and temperature. =20 Due to the specificities of the chip, all history reset attributes diff --git a/drivers/hwmon/pmbus/tps25990.c b/drivers/hwmon/pmbus/tps25990.c index 7634ac743025..0d5c99053f23 100644 --- a/drivers/hwmon/pmbus/tps25990.c +++ b/drivers/hwmon/pmbus/tps25990.c @@ -47,7 +47,14 @@ PK_MIN_AVG_RST_AVG | \ PK_MIN_AVG_RST_MIN) =20 +#define TPS1689_VIN_OV_RANGE_SEL_MASK GENMASK(7, 6) +#define TPS1689_VIN_VOV_MASK GENMASK(5, 0) +#define TPS1689_VIN_SCALING 251 +#define TPS1689_VIN_VOV_STEP_MV 250 +#define TPS1689_VIN_RANGE_SPAN_MV 16000 + enum chips { + tps1689, tps25990, }; =20 @@ -105,6 +112,8 @@ static int tps25990_mfr_write_protect_get(struct i2c_cl= ient *client) static int tps25990_read_word_data(struct i2c_client *client, int page, int phase, int reg) { + const struct pmbus_driver_info *info =3D pmbus_get_driver_info(client); + struct tps25990_data *data =3D container_of(info, struct tps25990_data, i= nfo); int ret; =20 switch (reg) { @@ -193,9 +202,18 @@ static int tps25990_read_word_data(struct i2c_client *= client, ret =3D pmbus_read_word_data(client, page, phase, reg); if (ret < 0) break; - ret =3D DIV_ROUND_CLOSEST(ret * TPS25990_VIN_OVF_NUM, - TPS25990_VIN_OVF_DIV); - ret +=3D TPS25990_VIN_OVF_OFF; + if (data->chip_id =3D=3D tps25990) { + ret =3D DIV_ROUND_CLOSEST(ret * TPS25990_VIN_OVF_NUM, + TPS25990_VIN_OVF_DIV); + ret +=3D TPS25990_VIN_OVF_OFF; + } else if (data->chip_id =3D=3D tps1689) { + int rng =3D (FIELD_GET(TPS1689_VIN_OV_RANGE_SEL_MASK, ret) + 1) * + TPS1689_VIN_RANGE_SPAN_MV; + int vov =3D FIELD_GET(TPS1689_VIN_VOV_MASK, ret) * TPS1689_VIN_VOV_STEP= _MV; + + ret =3D DIV_ROUND_CLOSEST(rng + vov - TPS1689_VIN_RANGE_SPAN_MV, + TPS1689_VIN_SCALING); + } break; =20 case PMBUS_IIN_OC_FAULT_LIMIT: @@ -238,6 +256,8 @@ static int tps25990_read_word_data(struct i2c_client *c= lient, static int tps25990_write_word_data(struct i2c_client *client, int page, int reg, u16 value) { + const struct pmbus_driver_info *info =3D pmbus_get_driver_info(client); + struct tps25990_data *data =3D container_of(info, struct tps25990_data, i= nfo); int ret; =20 switch (reg) { @@ -249,26 +269,52 @@ static int tps25990_write_word_data(struct i2c_client= *client, case PMBUS_OT_WARN_LIMIT: case PMBUS_OT_FAULT_LIMIT: case PMBUS_PIN_OP_WARN_LIMIT: - value >>=3D TPS25990_8B_SHIFT; + value =3D clamp_val((s16)value, 0, S16_MAX) >> TPS25990_8B_SHIFT; value =3D clamp_val(value, 0, 0xff); ret =3D pmbus_write_word_data(client, page, reg, value); break; =20 case PMBUS_VIN_OV_FAULT_LIMIT: - value -=3D TPS25990_VIN_OVF_OFF; - value =3D DIV_ROUND_CLOSEST(((unsigned int)value) * TPS25990_VIN_OVF_DIV, - TPS25990_VIN_OVF_NUM); - value =3D clamp_val(value, 0, 0xf); + if ((s16)value < 0) + return -EINVAL; + + if (data->chip_id =3D=3D tps25990) { + int tmp =3D (int)value - TPS25990_VIN_OVF_OFF; + + tmp =3D clamp_val(tmp, 0, INT_MAX); + value =3D DIV_ROUND_CLOSEST((unsigned int)tmp * TPS25990_VIN_OVF_DIV, + TPS25990_VIN_OVF_NUM); + value =3D clamp_val(value, 0, 0xf); + } else if (data->chip_id =3D=3D tps1689) { + u32 scaled_value =3D value * TPS1689_VIN_SCALING + TPS1689_VIN_RANGE_SP= AN_MV; + u32 rng_idx =3D scaled_value / TPS1689_VIN_RANGE_SPAN_MV; + u32 ov_set; + + rng_idx =3D clamp_val(rng_idx, 1, + FIELD_MAX(TPS1689_VIN_OV_RANGE_SEL_MASK) + 1); + ov_set =3D scaled_value - (TPS1689_VIN_RANGE_SPAN_MV * rng_idx); + ov_set =3D min_t(u32, ov_set / TPS1689_VIN_VOV_STEP_MV, + FIELD_MAX(TPS1689_VIN_VOV_MASK)); + value =3D FIELD_PREP(TPS1689_VIN_OV_RANGE_SEL_MASK, rng_idx - 1) | + FIELD_PREP(TPS1689_VIN_VOV_MASK, ov_set); + } ret =3D pmbus_write_word_data(client, page, reg, value); break; =20 - case PMBUS_IIN_OC_FAULT_LIMIT: - value -=3D TPS25990_IIN_OCF_OFF; - value =3D DIV_ROUND_CLOSEST(((unsigned int)value) * TPS25990_IIN_OCF_DIV, + case PMBUS_IIN_OC_FAULT_LIMIT: { + int tmp; + + if ((s16)value < 0) + return -EINVAL; + + tmp =3D (int)value - TPS25990_IIN_OCF_OFF; + tmp =3D clamp_val(tmp, 0, INT_MAX); + value =3D DIV_ROUND_CLOSEST((unsigned int)tmp * TPS25990_IIN_OCF_DIV, TPS25990_IIN_OCF_NUM); value =3D clamp_val(value, 0, 0x3f); ret =3D pmbus_write_byte_data(client, page, TPS25990_VIREF, value); break; + } =20 case PMBUS_VIRT_SAMPLES: value =3D clamp_val(value, 1, 1 << PK_MIN_AVG_AVG_CNT); @@ -347,6 +393,60 @@ static const struct regulator_desc tps25990_reg_desc[]= =3D { #endif =20 static const struct pmbus_driver_info tps25990_base_info[] =3D { + [tps1689] =3D { + .pages =3D 1, + .format[PSC_VOLTAGE_IN] =3D direct, + .m[PSC_VOLTAGE_IN] =3D 3984, + .b[PSC_VOLTAGE_IN] =3D -63750, + .R[PSC_VOLTAGE_IN] =3D -3, + .format[PSC_VOLTAGE_OUT] =3D direct, + .m[PSC_VOLTAGE_OUT] =3D 1166, + .b[PSC_VOLTAGE_OUT] =3D 0, + .R[PSC_VOLTAGE_OUT] =3D -2, + .format[PSC_TEMPERATURE] =3D direct, + .m[PSC_TEMPERATURE] =3D 140, + .b[PSC_TEMPERATURE] =3D 32103, + .R[PSC_TEMPERATURE] =3D -2, + /* + * Current and Power measurement depends on the ohm value + * of Rimon. m is multiplied by 1000 below to have an integer + * and -3 is added to R to compensate. + */ + .format[PSC_CURRENT_IN] =3D direct, + .m[PSC_CURRENT_IN] =3D 9548, + .b[PSC_CURRENT_IN] =3D 0, + .R[PSC_CURRENT_IN] =3D -6, + .format[PSC_CURRENT_OUT] =3D direct, + .m[PSC_CURRENT_OUT] =3D 24347, + .b[PSC_CURRENT_OUT] =3D 0, + .R[PSC_CURRENT_OUT] =3D -3, + .format[PSC_POWER] =3D direct, + .m[PSC_POWER] =3D 2775, + .b[PSC_POWER] =3D 0, + .R[PSC_POWER] =3D -4, + .func[0] =3D (PMBUS_HAVE_VIN | + PMBUS_HAVE_VOUT | + PMBUS_HAVE_VMON | + PMBUS_HAVE_IIN | + PMBUS_HAVE_IOUT | + PMBUS_HAVE_PIN | + PMBUS_HAVE_TEMP | + PMBUS_HAVE_STATUS_VOUT | + PMBUS_HAVE_STATUS_IOUT | + PMBUS_HAVE_STATUS_INPUT | + PMBUS_HAVE_STATUS_TEMP | + PMBUS_HAVE_SAMPLES), + + .read_word_data =3D tps25990_read_word_data, + .write_word_data =3D tps25990_write_word_data, + .read_byte_data =3D tps25990_read_byte_data, + .write_byte_data =3D tps25990_write_byte_data, + +#if IS_ENABLED(CONFIG_SENSORS_TPS25990_REGULATOR) + .reg_desc =3D tps25990_reg_desc, + .num_regulators =3D ARRAY_SIZE(tps25990_reg_desc), +#endif + }, [tps25990] =3D { .pages =3D 1, .format[PSC_VOLTAGE_IN] =3D direct, @@ -389,7 +489,6 @@ static const struct pmbus_driver_info tps25990_base_inf= o[] =3D { .write_word_data =3D tps25990_write_word_data, .read_byte_data =3D tps25990_read_byte_data, .write_byte_data =3D tps25990_write_byte_data, - #if IS_ENABLED(CONFIG_SENSORS_TPS25990_REGULATOR) .reg_desc =3D tps25990_reg_desc, .num_regulators =3D ARRAY_SIZE(tps25990_reg_desc), @@ -398,12 +497,14 @@ static const struct pmbus_driver_info tps25990_base_i= nfo[] =3D { }; =20 static const struct i2c_device_id tps25990_i2c_id[] =3D { + { .name =3D "tps1689", .driver_data =3D tps1689 }, { .name =3D "tps25990", .driver_data =3D tps25990 }, {} }; MODULE_DEVICE_TABLE(i2c, tps25990_i2c_id); =20 static const struct of_device_id tps25990_of_match[] =3D { + { .compatible =3D "ti,tps1689", .data =3D (void *)tps1689 }, { .compatible =3D "ti,tps25990", .data =3D (void *)tps25990 }, {} }; @@ -438,6 +539,7 @@ static int tps25990_probe(struct i2c_client *client) =20 /* Adapt the current and power scale for each instance */ tps25990_set_m(&data->info.m[PSC_CURRENT_IN], rimon); + tps25990_set_m(&data->info.m[PSC_CURRENT_OUT], rimon); tps25990_set_m(&data->info.m[PSC_POWER], rimon); =20 return pmbus_do_probe(client, &data->info); --=20 2.43.0