From nobody Fri Oct 2 04:27:59 2026 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (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 6CAFB3F0774 for ; Wed, 5 Aug 2026 09:04:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785920656; cv=none; b=FQIbdEnpWV9eRVyezzlZHfPD+bqwElgZuqsA7kGue8jcPjLEQ7Np8oNnZPhJoWBMMO6DBUn4ZsoVJ3dsxMdvKtNha1C08fIpY8gK0tZReggqTx3wAm/PMeiPusQh/a8oCBstfbfN66GIVUKOPc9HrRSLwKTepBDMz8V4JdXSBRc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785920656; c=relaxed/simple; bh=f5l2YBiHkReBw6mWMyjaq6Gvj9uLpAZQHQ7JL9lOPpM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Rc6oz0vPc/IY/2G8WNb+/2xRN8ZjDMJV4PGHmy67ornQOKmfusWKwnO0yBmzD89FI+DTDYpoZ6iw4NQXBRlNtOiTJ0i/pybnpzPgpI0iQztpYaIKO55HuyYNbt8cVxXqedl71LbW0P7VRK2jDwUT4MlsZTOf2R4oE7tczm/43Ms= 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=ZxseBF7P; arc=none smtp.client-ip=209.85.128.50 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="ZxseBF7P" Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-4980dc26022so6527665e9.1 for ; Wed, 05 Aug 2026 02:04:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre.com; s=google; t=1785920649; x=1786525449; 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=ZxseBF7PgYTecxQsK3HuLYWtyDyD2bHjpG7safwnSxdKzYfYpRqZaC4d55SWdNkFUH 8zfbCUsuTXU+eB+AUZfFKHS1XD1t+EMAsmlNgliftHRfIWxXJ3IBXAgsNsuE1qUB3t65 RTxtlmjioeZAOvU2TXvIa3/r6MKX/rBFThvux3JC4A9ZGDkzZCM3un/4YTU+a7IZI0CR /W9QA184NvHGvUbpyxwKH1uTo9U1mMNH86VVnzK28FVkNUQLLT4dG52/2i08tME2a8aT 5z5SqtOL1ieOEBRhEo+Qkc7HXE5Pa3vh0rzdUR1qFSScqDe4TnbFwlCZh7Y3K2oRQkbu NbHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785920649; x=1786525449; 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=kt3QLflbmnM3wxFar9WHR+IBC/xz3BSIlUmZkhl5FhO3cbD4GuH4dUcy0ppF+6COVw Xyx47TZUF8AzRHOl7Fhrd2bXnu5jzFHTQBKGZWIRxiGwr16KK3hR2gj294L76qOGV90V bmOi2WCjenfV1mTT9iWsJkafM5tJRCbx6GietgUx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ba2:b0:493:b6ee:fcb7 with SMTP id 5b1f17b1804b1-4994e7d3434mr34191405e9.14.1785920648698; Wed, 05 Aug 2026 02:04:08 -0700 (PDT) Received: from silence.. ([46.10.240.40]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4994e99319bsm34082105e9.3.2026.08.05.02.04.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2026 02:04:07 -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 v6 1/3] hwmon: (pmbus/tps25990): Rework driver for multi-device support Date: Wed, 5 Aug 2026 12:03:55 +0300 Message-ID: <20260805090400.2059006-2-sbogdanov@baylibre.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260805090400.2059006-1-sbogdanov@baylibre.com> References: <20260805090400.2059006-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 Fri Oct 2 04:27:59 2026 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (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 6063F3F12C2 for ; Wed, 5 Aug 2026 09:04:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785920657; cv=none; b=O0nXOF3+7XGO61MjHLJ29mGXvQTP6GxCyHUPt5GH/TdNrl3Yx37phqZWcKY0+RfrD3sPTQISihPIEr4nrGKNXyXNUaOTgpcgf+Q73JFFDCVWfDKjI8ejBNNWCjmQ2IgvjfXfGY/gPObqDzXiyduI+1wM2Lw/u8JAOLKw/zxVW68= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785920657; c=relaxed/simple; bh=3DzBepA5OaBxS3rEqzaa//JlAmU/tnAvZdNl+JJosYM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pjhRzC8hXqnFgEsZjnpxnHRUEBvP7LXaFT039rgKp0Z3WkCjiq2TUW3oetAbqCQGxX3KktucQU5wHbvnWwoFRJgYdHU+ZWxPSr17As4bHE65M2eydP1kCmQPRq824BEL+y3Y3pQFZP9AsJWlxOQvQyf/uqYaPgXKhIN78e9UwTQ= 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=EtsLWIxm; arc=none smtp.client-ip=209.85.128.50 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="EtsLWIxm" Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-493b966dd74so4168515e9.3 for ; Wed, 05 Aug 2026 02:04:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre.com; s=google; t=1785920651; x=1786525451; 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=EtsLWIxm90bqO0pNwLeOvny9TOKms0H7hvq1lu3sCTDQrNN+6zn8FAxJKxvvIlhPIP 5O5QXsakOEdFJxL1gd2z1ytNTKD4Ar1k3oXVzOOjoOGjvp2EfaZyioD928DMa52xfNO5 yOBhIVShmHuK1ioSNmnaKxP8SAj9DDFAHq0L+AhPqPThjD309BcLpJcQbT+3e4ZQo/Kk mUWPxHo5JfirnW4ssQ9DdlWaAouXGryAkqng+9FzQzdmR2t7xGYjmo37c4mpoxce6/lV 0vabw0bE8+L1ec7Y1vlGSLkwk8twkwhu+3pjj+YD81iTFBTxTW7EH7XNoFIvOLPdAuPU BSYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785920651; x=1786525451; 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=FgX0DU3IuyPEY4n+iQX7OyYrENRRiOn9HFQrvUyAR5t8b/bLeollNBvGghJwPULPCi E22SG/3fZIhji2VLaLAPZfFhQGAgBCxRUEMiu+xUPrVO53xA+szCD5wWaHTO/5q6NE/i Y1bNA9JhvGP7z5J38yo2RSoG5SNbRthhKqkSHcG3P3ijyOF1Np2ornD3Na//M9RvXRdq 6ct+8rSYIjbS/UtJ5fhdmEXsfWlvvNkqlWwzSPfbfXvA7cYlnxq4KJnpgXTEd09gzE/x /iHMDuCcRqFW+BEJL+E5+wq+zzPNJRJYxWDyx5ZLuNbSKv27Yu6It0btHuL+OQkASU4B t8WQ== X-Forwarded-Encrypted: i=1; AHgh+Rrfq6LYlXrhz44n+uz4+OxxBO0tzk73LwcHFoJfAbCw/79pOKec4qZLOlml+qJhxMZ9bOGmZJah7cVxRB8=@vger.kernel.org X-Gm-Message-State: AOJu0YyuXkb0Napquq4PalFTOv1o6eOWJ25sFWkMeQe5ZDe0B/HmwAJ1 1iQ/TQn4VVukaIctCkApjPeMcItUiNlRy2qKBDo0KCS6Ro4mG4MdzaNLM9Q8O5TLaXE= X-Gm-Gg: AR+sD11laMgLWZu4AqtMZyl9hyQYyRZ5sE614Pqx5saBj6YSw74IBKc2HGPV5FfSdyx i+w3zl3a5Tesyz7Cbu1nqdRM1sTNHS5c+DY8Sy/Qc+x+urlKfbIiD7q8KhEIRV5gfzdru4q47i9 LyTv1H1yEQbne1X3yhJdFQ2AXxmjo4lDswFMN9zdpZGSchQqwbrGHoTktHR9iLFUEhBqGw1plXF K1GeFqGHtxzGIgR7HBHw9pIjr3nXJsRsPvl76fHUHQ9GTZO07n2Az5eD8fLdt8x12mZ9tLDPZ2m EDCmsZ88NzI3/E0lS66t0Af4+gjDfNx/0C1Ld0hI17q5sXiJuVYZJVwGOa/UtuxvXqzN12NzFCJ PUc/Vpl6BFYZV8REVUvgVEt/wh+lVI8z1+kW1J92oYZtFQbSUwuKKnwrgVQbDNydETvX/rmulpE Vs1zd8IbLvIEpgxb+sDN1IBsy4L9JgdUYDgIdAa24WlK2fTi7ETLWYbCRFapVKrMlN4nSNA1gov KbUpIjchQCLh9mUoSlJkqMifM3dr4kYf6mR/s1UrfPLVnsLmrgh0d1IHcVa0+tlXo0y4jWyLDdh D3mNe+0SO7OUTrPYffsbVru2r0sq9A== X-Received: by 2002:a05:600d:8483:b0:498:1371:6612 with SMTP id 5b1f17b1804b1-4994e7a70aemr44104035e9.6.1785920650758; Wed, 05 Aug 2026 02:04:10 -0700 (PDT) Received: from silence.. ([46.10.240.40]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4994e99319bsm34082105e9.3.2026.08.05.02.04.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2026 02:04:10 -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 v6 2/3] dt-bindings: hwmon: pmbus/tps25990: Add TPS1689 Date: Wed, 5 Aug 2026 12:03:56 +0300 Message-ID: <20260805090400.2059006-3-sbogdanov@baylibre.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260805090400.2059006-1-sbogdanov@baylibre.com> References: <20260805090400.2059006-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 Fri Oct 2 04:27:59 2026 Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.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 375063F0AA6 for ; Wed, 5 Aug 2026 09:04:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785920663; cv=none; b=NW8gG9bhJULEr4ph/wTReisim+tQ/LZ0+0J918RM8fwvaPNY4bGiKIIsBsXIPIyD+zm7l16rEX7y5j0ZfsvPbzykm5NLHVengAaTo3CLgcffdtMMFKA2aZvYprctdRBaRBmURxXqULuTV+qZjW2R7uElhqapcs4Z2kKIGK/SQGQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785920663; c=relaxed/simple; bh=szaMRTU+Zc37ZMSKJAfhvlWzAFBia28AJQiOz4Mp840=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fD1tqc/A1Q2jHM4UZJknmmfagSI0g/oUJgu7QJCcvguYC3YhhGr83xJee6wygikdS9GWBhGNX0VHFttawuEGqshCKKl+wu4AHUJUiIqkafHN7BjQ+M8tgPV1UcT/vSVcVrx/m99+AXUdxRu6nksukCEjaAxVspqnT4JAEOpACyI= 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=ABQjrXAK; arc=none smtp.client-ip=209.85.128.43 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="ABQjrXAK" Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-496bb7cdf51so8263855e9.2 for ; Wed, 05 Aug 2026 02:04:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre.com; s=google; t=1785920653; x=1786525453; 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=h4tn8Gp0RSKaHrUjo2zWoNmBQth+dfFwqaEytCzyX04=; b=ABQjrXAKN/nYS84ske6BvRE5NouubEX/t9mlwXP7IDcpNFsU94wa+XtgF1qACtV8QB pV5ZAnPoqWqvh/8kDk9Q29gF72KQs38xS2KCf1WU+tlDDrOBnBtwXdSNJ6zM62WFG1s9 XUt4l/nBiw/6JQ41+FM7eMfy/kpa8GUQPC0zP7+70Wtf2BluTz8dY6ld6mBX5LV8dF/Z XBF2U3FG+1zoDypuQf/CzMIV6d5Y+8DoM9JqpwoR9F/+VR9JLgzBU/6h7QYIpHdDsBoU HRuRRHrz//c29wAZ6qQQ8hnpiMu5/mBX4BMebwVEvjoBeqqPn+3D0bm9dGqy29IUzoDO HPbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785920653; x=1786525453; 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=h4tn8Gp0RSKaHrUjo2zWoNmBQth+dfFwqaEytCzyX04=; b=atUvlrT5oixI8o3+BoZPFHClV9WirttpHWmGqf40eRKXta7uPP65/2Cx3nuibXYLvW gqGEqkpOaSENFmoxE5sBj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2RfQR0hSHhmVT9CQFKb9a9x/tOv8Xt2Jb0MQ MkluuaLG6dBFtjHMYemvthvH/pKQHw== X-Received: by 2002:a05:600c:4692:b0:498:162a:dbda with SMTP id 5b1f17b1804b1-4994e714b73mr45253615e9.5.1785920652804; Wed, 05 Aug 2026 02:04:12 -0700 (PDT) Received: from silence.. ([46.10.240.40]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4994e99319bsm34082105e9.3.2026.08.05.02.04.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2026 02:04:12 -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 v6 3/3] hwmon: (pmbus/tps25990): Add TPS1689 support Date: Wed, 5 Aug 2026 12:03:57 +0300 Message-ID: <20260805090400.2059006-4-sbogdanov@baylibre.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260805090400.2059006-1-sbogdanov@baylibre.com> References: <20260805090400.2059006-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 | 106 ++++++++++++++++++++++++++++--- 2 files changed, 107 insertions(+), 14 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..a91ea8f33b29 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) { + ret =3D DIV_ROUND_CLOSEST( + ((FIELD_GET(TPS1689_VIN_OV_RANGE_SEL_MASK, ret) + 1) * + TPS1689_VIN_RANGE_SPAN_MV) + + (FIELD_GET(TPS1689_VIN_VOV_MASK, ret) * + TPS1689_VIN_VOV_STEP_MV - TPS1689_VIN_RANGE_SPAN_MV), + TPS1689_VIN_SCALING); + } break; =20 case PMBUS_IIN_OC_FAULT_LIMIT: @@ -208,7 +226,7 @@ static int tps25990_read_word_data(struct i2c_client *c= lient, if (ret < 0) break; ret =3D DIV_ROUND_CLOSEST(ret * TPS25990_IIN_OCF_NUM, - TPS25990_IIN_OCF_DIV); + TPS25990_IIN_OCF_DIV); ret +=3D TPS25990_IIN_OCF_OFF; break; =20 @@ -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) { @@ -255,10 +275,23 @@ static int tps25990_write_word_data(struct i2c_client= *client, 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 (data->chip_id =3D=3D tps25990) { + value -=3D TPS25990_VIN_OVF_OFF; + value =3D DIV_ROUND_CLOSEST(((unsigned int)value) * TPS25990_VIN_OVF_DI= V, + 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 tmp_scaled_value =3D scaled_value; + u8 ov_rng_sel =3D 0; + u32 ov_set =3D 0; + + ov_rng_sel =3D tmp_scaled_value / TPS1689_VIN_RANGE_SPAN_MV; + ov_set =3D tmp_scaled_value - (TPS1689_VIN_RANGE_SPAN_MV * ov_rng_sel); + value =3D FIELD_PREP(TPS1689_VIN_OV_RANGE_SEL_MASK, ov_rng_sel - 1) | + FIELD_PREP(TPS1689_VIN_VOV_MASK, + (ov_set / TPS1689_VIN_VOV_STEP_MV)); + } ret =3D pmbus_write_word_data(client, page, reg, value); break; =20 @@ -347,6 +380,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 +476,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 +484,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 }, {} }; --=20 2.43.0