From nobody Sun May 24 18:42:21 2026 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (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 91BD53A7F4C for ; Fri, 22 May 2026 08:24:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779438254; cv=none; b=aJStG4O0r2e+zD/ZdGNFXpeiSpMkBqys9xNouaVIQiXuO1WFPKaIrCd2M+IIM6ZLSk+hJSNQTbriJ9Awex+VjSwm6DKhg2YPGVJqJK8yyBTckmRYtMP2quZ+rXWlkd+JeDmkD44FBcbt7f6vjIjtB4MhodsWfW1Q+gm+n1/Q4gs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779438254; c=relaxed/simple; bh=hAFWwmeUdoIRPeHMu1R589WDqPZK2EVU2mJ5y87RrMc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BjdqDref5NPJiQ0oNTB0fsaiNqqcOYeeXcYYRCMzEs4sm0Opc2NyFzjOMzBo7ts0Yu1wrFyBZK+Qk6cQLAagqM0TONjdQHqFxODW76cJfWvhxgFERfXXkmF+ZFb/WBlQoLSWjp0FeboFZ8Lxb3LZkzz4G3+WIrpy09xm/uSB2ms= 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=HPkbXxLq; arc=none smtp.client-ip=209.85.128.47 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="HPkbXxLq" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-4903997fcb5so15705225e9.2 for ; Fri, 22 May 2026 01:24:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre.com; s=google; t=1779438251; x=1780043051; 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; bh=QkJvqH4tZQVXdYwb9TspsEPOaEailU+8tDMuNLsX0P4=; b=HPkbXxLq4LmOVT1sk7PX/ZTaIxNdi3yUj/AuSWO0lgJA62lNikVGRz8tqlnP1WFvxZ k0/ACAZWFxyIDYfjzaGPD3GjFS7bwTIfKyjZMpcLXLcr8sNFHiwU0+92SGw3Qr60AVVS v8gl2rxtTkOzs2lBe4tLQI5xdL/qSg2JW/vZPaPItH1woyzsEGj/UgE+KZzczQgWqhbO pdQTCnh/1mP79NN9PYsdc9jAVdDSGWpq4tTBwCrkRYRNcucUULAWlu1yj+RJ/KHuyrW/ NQFxkf8+O7VMiisCTDcK+piTgVvwgaq0FrJBCHovN8dbZGxIf2yBxpsqyTGPbWJN068e 0Omg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779438251; x=1780043051; 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; bh=QkJvqH4tZQVXdYwb9TspsEPOaEailU+8tDMuNLsX0P4=; b=IlkospIH8QxgpzzKbg89BTi2t1mSoACLEIZnSNHNwA+Lf+EwkNdyJegZn6gZZPDCVF wQfcscrvLql8Jdrk6ascOBakWNIWpK8FP6QyWudeLTkFmKf2G2dx7GiRrh6uTjVmCkZH W/UbVsQHJZSslDg1DTJSZ1afDU08WkE41ttkymzGJF6x4agQcYlO3r+cbmxvvR1ZGjSJ Aezx/YNbiRxHVsM+al2J09gOoVCaCPF65mfw1NISeylxzl6dQqSshXVOWz9RF2foFkRi tWZwCsdxV0Xjj7Mxv8BQmB3N8HRp/PgaPQb1WPcDIno/ZDhhiijSlxJ5JvxluwEpbpTm rYVA== X-Forwarded-Encrypted: i=1; AFNElJ/WlZKyJ7TdI5t/njQIXpN8hZjZuUi6B7v8616KpFkirIPrKhzfsRb9KhRo09JONN4QUJUmw6rIHGSZywc=@vger.kernel.org X-Gm-Message-State: AOJu0Ywpf1YLwgSFgtH9d2E8/KaVVjncqudSmT9eiyikJ6MkKJOc4ruu FruXKS6JcjCEleoqePIuWZqXH5asljqHDtQTRZByIBPMkab7JONosSgynN8/nCfZuKM= X-Gm-Gg: Acq92OHAq8VkZ9yxaJ9fpBzUwgjaS+wLCm0clKXNz7G0QYaeFtadYKcLZRmZnT+VLuH jhSZhvgxXN/2GtEfPCYYyNNR30DMxJIc/tIvB3uPyta7/iCtg7wYo/cT+rz6K9z2+MQUjXR68Bj 1qxrVGAkH6hzfgtJmqRA60+DBCGyvtxkF244Xl7DMF1Dp0XQ7S8w+tzCun3WwnlxWqcszUyzrDa p+TvhxsWH5r9OhonjVOotf0vq0g0SokM46XtC+KfxY6819deLyz5JFeHjrV2dAcOd5ktdSChlAT 5cviTOsT4PTTbpBsIwC99z0O6xPlh2joz1ssBlx6IaG1oPwemt5PCu6uEZXfuIhu6+qbNC8iseL 8vzZDZjdBHGG7mlSiT8XiocC2KGEnMc/hlSNGgfUuepMETAeCPqmdLmliYkyH3SceIB4b5mkxtL dA1wNExst78ev5fl6XDyJBd1KvnxyI80NyM6gEPXlRBxV70VBv1Okg/cvzdKd/C8KlOJ1jO3KK2 9lZsrrtg9Y= X-Received: by 2002:a05:600c:5488:b0:490:47e0:e13f with SMTP id 5b1f17b1804b1-49047e0e21bmr9122025e9.3.1779438250911; Fri, 22 May 2026 01:24:10 -0700 (PDT) Received: from silence.. ([46.10.240.40]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-45eb6c9f58dsm2398471f8f.5.2026.05.22.01.24.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 May 2026 01:24: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 Subject: [PATCH v4 1/4] hwmon: (pmbus) Add and export direct conversion calculation helpers Date: Fri, 22 May 2026 11:23:36 +0300 Message-ID: <20260522082349.2749970-2-sbogdanov@baylibre.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260522082349.2749970-1-sbogdanov@baylibre.com> References: <20260522082349.2749970-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" TPS25990 and upcoming TPS1689 need common computation APIs but the current implementation is static to TPS25990. As a preparation for TPS1689 support, split the math-only parts of pmbus_reg2data_direct() and pmbus_data2reg_direct() into separate helper functions: - pmbus_reg2data_direct_calc() - pmbus_data2reg_direct_calc() export them so the upcoming TPS1689 can use the same APIs. This has no behavioral change on TPS25990 while allowing TPS1689 to use the same. Signed-off-by: Stoyan Bogdanov --- drivers/hwmon/pmbus/pmbus.h | 2 ++ drivers/hwmon/pmbus/pmbus_core.c | 59 +++++++++++++++++++------------- 2 files changed, 38 insertions(+), 23 deletions(-) diff --git a/drivers/hwmon/pmbus/pmbus.h b/drivers/hwmon/pmbus/pmbus.h index 23e3eda58870..dd4fe7d9821d 100644 --- a/drivers/hwmon/pmbus/pmbus.h +++ b/drivers/hwmon/pmbus/pmbus.h @@ -578,5 +578,7 @@ DEFINE_GUARD(pmbus_lock, struct i2c_client *, pmbus_loc= k(_T), pmbus_unlock(_T)) int pmbus_update_fan(struct i2c_client *client, int page, int id, u8 config, u8 mask, u16 command); struct dentry *pmbus_get_debugfs_dir(struct i2c_client *client); +s64 pmbus_reg2data_direct_calc(s64 val, s64 b, s32 m, s32 R); +u16 pmbus_data2reg_direct_calc(s64 val, s64 b, s32 m, s32 R); =20 #endif /* PMBUS_H */ diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_c= ore.c index e8fdd799c71c..2eaac337eeab 100644 --- a/drivers/hwmon/pmbus/pmbus_core.c +++ b/drivers/hwmon/pmbus/pmbus_core.c @@ -817,6 +817,22 @@ static s64 pmbus_reg2data_linear(struct pmbus_data *da= ta, return val; } =20 +s64 pmbus_reg2data_direct_calc(s64 val, s64 b, s32 m, s32 R) +{ + while (R > 0) { + val *=3D 10; + R--; + } + while (R < 0) { + val =3D div_s64(val + 5LL, 10L); /* round closest */ + R++; + } + + val =3D div_s64(val - b, m); + return val; +} +EXPORT_SYMBOL_NS_GPL(pmbus_reg2data_direct_calc, "PMBUS"); + /* * Convert direct sensor values to milli- or micro-units * depending on sensor type. @@ -824,7 +840,7 @@ static s64 pmbus_reg2data_linear(struct pmbus_data *dat= a, static s64 pmbus_reg2data_direct(struct pmbus_data *data, struct pmbus_sensor *sensor) { - s64 b, val =3D (s16)sensor->data; + s64 b; s32 m, R; =20 m =3D data->info->m[sensor->class]; @@ -848,17 +864,7 @@ static s64 pmbus_reg2data_direct(struct pmbus_data *da= ta, b *=3D 1000; } =20 - while (R > 0) { - val *=3D 10; - R--; - } - while (R < 0) { - val =3D div_s64(val + 5LL, 10L); /* round closest */ - R++; - } - - val =3D div_s64(val - b, m); - return val; + return pmbus_reg2data_direct_calc((s16)sensor->data, b, m, R); } =20 /* @@ -1057,6 +1063,23 @@ static u16 pmbus_data2reg_linear(struct pmbus_data *= data, return (mantissa & 0x7ff) | ((exponent << 11) & 0xf800); } =20 +u16 pmbus_data2reg_direct_calc(s64 val, s64 b, s32 m, s32 R) +{ + val =3D val * m + b; + + while (R > 0) { + val *=3D 10; + R--; + } + while (R < 0) { + val =3D div_s64(val + 5LL, 10L); /* round closest */ + R++; + } + + return (u16)clamp_val(val, S16_MIN, S16_MAX); +} +EXPORT_SYMBOL_NS_GPL(pmbus_data2reg_direct_calc, "PMBUS"); + static u16 pmbus_data2reg_direct(struct pmbus_data *data, struct pmbus_sensor *sensor, s64 val) { @@ -1078,18 +1101,8 @@ static u16 pmbus_data2reg_direct(struct pmbus_data *= data, R -=3D 3; /* Adjust R and b for data in milli-units */ b *=3D 1000; } - val =3D val * m + b; =20 - while (R > 0) { - val *=3D 10; - R--; - } - while (R < 0) { - val =3D div_s64(val + 5LL, 10L); /* round closest */ - R++; - } - - return (u16)clamp_val(val, S16_MIN, S16_MAX); + return pmbus_data2reg_direct_calc(val, b, m, R); } =20 static u16 pmbus_data2reg_vid(struct pmbus_data *data, --=20 2.43.0 From nobody Sun May 24 18:42:21 2026 Received: from mail-ej1-f50.google.com (mail-ej1-f50.google.com [209.85.218.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 D9A5A3A874B for ; Fri, 22 May 2026 08:24:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779438256; cv=none; b=mC1l/r4RqJDK+gsiTZf6owL7EI0n64jBLwXWp/8yKCtOT3yg13da7zUDoW8D88F/QVd91DIbgx7UCAWYe6roCgjCQWT+mIbwnwSsByNr8AtgbNaGUg3S3jHIDA0gfMzRMy5B17Cwg+ZY6j4h3e2NTFybBE9YewtI6ay8QJQpZ7c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779438256; c=relaxed/simple; bh=F6h6fV01hp9PJV8gFlqtWxLuKwFUN4erj6TBZARNopo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dMobWuj8iy3ud0LVpbJU4dkGWhRyXcuPkbVWXvgffTqQVdZ7CoZvKolb6JV2K8ndwsFYuWWz1QGnJ1L/B4ADoUgzFEqkuKyP8H0tdE2EKfz9Kzb5/NuJm97KA2pAn2OD7EpRwf0JzivnajoZ32qSfagC3Q2xHylUHtlUVQO58aU= 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=AcbTH99/; arc=none smtp.client-ip=209.85.218.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="AcbTH99/" Received: by mail-ej1-f50.google.com with SMTP id a640c23a62f3a-bd3d7c29b4dso1038712566b.2 for ; Fri, 22 May 2026 01:24:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre.com; s=google; t=1779438253; x=1780043053; 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; bh=4Pc7v6T04K7etDmA+oCn6BtDAzikOAUdVkaaMS5hlOw=; b=AcbTH99/6iHgE/7yxgvQ3HDm+AbCOYLO28ysFxgAYY1s0L1+RSGMklYI4hBxsH2Kkt P7k0DUgTRjC2/fJcm4I98nPmhR34GpqXQhT5uzE1fHvwINDAxTQOgvmrsIJnusBlmyzh aYluIAhUCUBiYm0j2Qe9LgPb+nq0T2qeqeHv9bOi2S10IvXPN/8fk0T5Pn6bb+cP7z2U 5eEvjl6LTSgUDWhmZ2msFaMjHUWMkiq7yOLqc03HTqJmEKm6arF84Ace0JMNpaZ0hpPT rlbtoJkrAfkTyJlK4xSp5sIfb49SpReAmPe9JKsUcryWOl5IdeA690Q8lFNz4q0UUXMB xbOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779438253; x=1780043053; 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; bh=4Pc7v6T04K7etDmA+oCn6BtDAzikOAUdVkaaMS5hlOw=; b=NL/H0VDRj+a/B9DkX8zVK+xrLGCRTuiulFjAaE1TfKBTYpMgxfZW/HJZBulRZo/H+V Cb9xH1QRSLzkT8HN2NGPengoiOoo42eYVTFAyyeRT8kJ8S0mnnoSjhHCvceBK3CC713Z SHGTO6nt14nDeNwKQzy84dsvM3dHsYXePZzkWrEVSLUPRQ/onGe7I5zQ6u4NNHNK3d8O 3jU0sTRTsfbpuXiYmjclFy9WWGN8IlmaEIh7nnvR5efNCPTi+b1GeCVdVn+1GVeD2agR raf6DtdEaw1d27Uk74lqLF+w5pFAbwO5ksUV7m7K8Ea98c3BSaHZrutQNsGPIZb0YCUS TYIQ== X-Forwarded-Encrypted: i=1; AFNElJ//K2qFeAiPPpt/xlia7tSnhDIEhS0HArfNIu/7HFVMvj1i1c+KHddWYidCv0Txgk4bi/Jpl14mwyfUD9s=@vger.kernel.org X-Gm-Message-State: AOJu0YydYgfstDjldsJ13VEBuqIWZcbwOI9KP4z6VnWh7LPYtXf/K/iH 6MIFe7oAfKYEg4QCRxQ2iPezX5cpBbSy7xcuXgGGdqRvE/euN6V0XalTGijGYar3c+s= X-Gm-Gg: Acq92OExTheO/FZw57ZkviP8kagVlHOAMRVNSpHLMY+Xt8Mr1uNqwXkFel+Dzg7EzXh 5rulpRKAWrA6/LIW7c82GbOp6J5OEPwhtht4a6//N2CUnfAn11A4Lj+p8phdmLghCS8W7vz9zZr IC1N24WwVRPqGa0uv/dgJEM7bSslOT8LjSucQSgBb0ed8Tf5PNcop9M3eWlY7Mm50ZkrskiDg3a newYGaV8m3Tl4i3NREJA/OE8KbDO73QX63YQUlCDGTqB5FyZ7Cto9dr8hr7yKIyf+x/qpknNRA5 QO1Ou4R+S+cFn6mC07nPQ91ezAZksx8Lu7KKU73Jx7hxZ2mNhvtESoqUUGbk/jdPFLoNF4caHjB 3CaIgWy/Ml2t05412IpF1CHPM7AruPnpI4XSq5x7sdfPjUoHGAiSVAoT6QZxrsRp9/pYz5e9jxe Q8/ZJukT/mbovD8oe+zo4fGX0FdiOYaOJMTtsAaVE1Dc3l31ilxrP+qMfypVAnjkeATR+abVmna TKbtQmpBSM= X-Received: by 2002:a17:907:60cb:b0:bda:e47:70c6 with SMTP id a640c23a62f3a-bdd22944feamr174206766b.1.1779438252846; Fri, 22 May 2026 01:24:12 -0700 (PDT) Received: from silence.. ([46.10.240.40]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-45eb6c9f58dsm2398471f8f.5.2026.05.22.01.24.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 May 2026 01:24: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 v4 2/4] hwmon: (pmbus/tps25990): Rework TPS25990 direct conversion handling Date: Fri, 22 May 2026 11:23:37 +0300 Message-ID: <20260522082349.2749970-3-sbogdanov@baylibre.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260522082349.2749970-1-sbogdanov@baylibre.com> References: <20260522082349.2749970-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 the existing implementation of direct format conversion for TPS25990 non-standard parameters to improve code reusability and integration with the PMBus direct conversion helpers. Changes include: - Add an enum describing the supported parameters - Add structure to hold m, b, R per-device coefficients - Add data structures for pmbus_driver_info and local direct values - Use the generic PMBus conversion helpers: pmbus_reg2data_direct_calc() pmbus_data2reg_direct_calc() - Replace previously used defines with structured data This reduces duplicated conversion logic and makes handling of non-standard parameters more maintainable. Signed-off-by: Stoyan Bogdanov --- drivers/hwmon/pmbus/tps25990.c | 197 +++++++++++++++++++++------------ 1 file changed, 127 insertions(+), 70 deletions(-) diff --git a/drivers/hwmon/pmbus/tps25990.c b/drivers/hwmon/pmbus/tps25990.c index 05c6288ecafc..1e252844217b 100644 --- a/drivers/hwmon/pmbus/tps25990.c +++ b/drivers/hwmon/pmbus/tps25990.c @@ -36,17 +36,63 @@ #define TPS25990_UNLOCKED BIT(7) =20 #define TPS25990_8B_SHIFT 2 -#define TPS25990_VIN_OVF_NUM 525100 -#define TPS25990_VIN_OVF_DIV 10163 -#define TPS25990_VIN_OVF_OFF 155 -#define TPS25990_IIN_OCF_NUM 953800 -#define TPS25990_IIN_OCF_DIV 129278 -#define TPS25990_IIN_OCF_OFF 157 =20 #define PK_MIN_AVG_RST_MASK (PK_MIN_AVG_RST_PEAK | \ PK_MIN_AVG_RST_AVG | \ PK_MIN_AVG_RST_MIN) =20 +enum chips { + tps25990, +}; + +enum tps25990_parameters { + TPS25990_VIN_OVF =3D 0, /* VIN over volatage fault */ + TPS25990_IIN_OCF, /* IIN Over currect fault */ + TPS25990_DIRECT_VALUES_COUNT, +}; + +struct tps25990_local_direct_value { + int m[TPS25990_DIRECT_VALUES_COUNT]; /* mantissa */ + int b[TPS25990_DIRECT_VALUES_COUNT]; /* offset */ + int R[TPS25990_DIRECT_VALUES_COUNT]; /* exponent */ +}; + +struct tps25990_data { + struct pmbus_driver_info info; + struct tps25990_local_direct_value info_local; +}; + +static s64 tps25990_reg2data_direct(struct i2c_client *client, int param, = s32 raw) +{ + struct pmbus_driver_info *info =3D i2c_get_clientdata(client); + struct tps25990_data *data =3D container_of(info, struct tps25990_data, i= nfo); + struct tps25990_local_direct_value *info_local =3D &data->info_local; + s64 b, val; + s32 m, R; + + val =3D (s16)raw; + m =3D info_local->m[param]; + b =3D info_local->b[param]; + R =3D info_local->R[param]; + + return pmbus_reg2data_direct_calc(val, b, m, R); +} + +static u16 tps25990_data2reg_direct(struct i2c_client *client, int param, = s64 val) +{ + struct pmbus_driver_info *info =3D i2c_get_clientdata(client); + struct tps25990_data *data =3D container_of(info, struct tps25990_data, i= nfo); + struct tps25990_local_direct_value *info_local =3D &data->info_local; + s32 m, R; + s64 b; + + m =3D info_local->m[param]; + b =3D info_local->b[param]; + R =3D info_local->R[param]; + + return pmbus_data2reg_direct_calc(val, b, m, R); +} + /* * Arbitrary default Rimon value: 1kOhm * This correspond to an overcurrent limit of 55A, close to the specified = limit @@ -184,9 +230,7 @@ static int tps25990_read_word_data(struct i2c_client *c= lient, 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; + ret =3D tps25990_reg2data_direct(client, TPS25990_VIN_OVF, ret); break; =20 case PMBUS_IIN_OC_FAULT_LIMIT: @@ -198,9 +242,7 @@ static int tps25990_read_word_data(struct i2c_client *c= lient, ret =3D pmbus_read_byte_data(client, page, TPS25990_VIREF); if (ret < 0) break; - ret =3D DIV_ROUND_CLOSEST(ret * TPS25990_IIN_OCF_NUM, - TPS25990_IIN_OCF_DIV); - ret +=3D TPS25990_IIN_OCF_OFF; + ret =3D tps25990_reg2data_direct(client, TPS25990_IIN_OCF, ret); break; =20 case PMBUS_VIRT_SAMPLES: @@ -246,17 +288,13 @@ 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 tps25990_data2reg_direct(client, TPS25990_VIN_OVF, value); value =3D clamp_val(value, 0, 0xf); 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, - TPS25990_IIN_OCF_NUM); + value =3D tps25990_data2reg_direct(client, TPS25990_IIN_OCF, value); value =3D clamp_val(value, 0, 0x3f); ret =3D pmbus_write_byte_data(client, page, TPS25990_VIREF, value); break; @@ -337,63 +375,76 @@ 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 struct tps25990_local_direct_value tps25990_local_info[] =3D { + [tps25990] =3D { + .m[TPS25990_VIN_OVF] =3D 10163, + .b[TPS25990_VIN_OVF] =3D -30081, + .R[TPS25990_VIN_OVF] =3D -4, + .m[TPS25990_IIN_OCF] =3D 9538, + .b[TPS25990_IIN_OCF] =3D 0, + .R[TPS25990_IIN_OCF] =3D -6, + }, +}; + +static 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 { - { "tps25990" }, + { "tps25990", 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 +452,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 +467,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->info_local =3D tps25990_local_info[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 Sun May 24 18:42:21 2026 Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) (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 4C2C43A901F for ; Fri, 22 May 2026 08:24:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779438257; cv=none; b=TSZdRJdagtDmjklMJco5CWxYdWD/DDHrUOl2NHgEYMDr2f9Pffzkf5HSkEomBtJPAV0zLPBG0+3ZFOkruqZaWQZ7LA+jLjXTsQ1nM3/eojko4UZbfrvLG0iZbtNQuPc4cD/4erJgtUgcQVRWalnNTQxpJHfvmCqMKNw9B+nfcsw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779438257; c=relaxed/simple; bh=3DzBepA5OaBxS3rEqzaa//JlAmU/tnAvZdNl+JJosYM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=M7B15VQuqv3Wl1dVsV0HACJS5KQsKV5e9utWOmScEUoKE+pKRxIHiZjwHBKyKHQyTTMNhAjK0/tCqxrQGnBoO3j6D0LH25LtZErregNZF8RhTbCnOEgRIKj9LW+hiHLqSjkPFmklpdfTci957/kv1pwNVMS7Eoy4tZX8TV24Xfo= 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=XuRpK3F8; arc=none smtp.client-ip=209.85.221.46 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="XuRpK3F8" Received: by mail-wr1-f46.google.com with SMTP id ffacd0b85a97d-43d77f6092eso4116641f8f.2 for ; Fri, 22 May 2026 01:24:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre.com; s=google; t=1779438255; x=1780043055; 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; bh=r1aINRhdCxbmlFp0SOoS/8BQxCjj22TF2jiFyvu2ZRU=; b=XuRpK3F8JcOQENl+OadbHzE7Kd+lY/zVqGFNMXrcQ+dZ52ys3ewfzO2sgSTDeQjKZd z+jgJr+mHMapo0V2MWWsG5EC5xI2XXwUIDn2lyup35yORAIBiXmiQ+2lpMaQi4Y/ZO1w iv6cnTzOxpHXdOOcueuvPsbe5yoCpZnzAeCCGxxutjuNYUMiPPrmY0S2KUHhDLbW0u7n xq8Y0ELLjA14kNHgiEnvps7CJVKa3ofW4ucgsx5sQ4i1T4Rm948hlAlZtsKUBv0B6paJ 2XymPJSgpQZgm76TlzbTYNPDUsl1F4610p483KdPiU0PnDqZWpEpGfkRtujZOCHUwrRD 9ruw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779438255; x=1780043055; 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; bh=r1aINRhdCxbmlFp0SOoS/8BQxCjj22TF2jiFyvu2ZRU=; b=kw4sJZ2d5Ea7+LoM6xknIBkgOHNGAa6pOjoDTYTpIaaCQqJw14uEX19BkEec7r7HZD T5qSThnUEHn4lfdbDWo3vAf7mvChVnKWy2znryLQ3iJwuRPLdbZsJ3z3DEuoaXGHsq3y HlhneL1GWkjCY/Ub3cz/m9AGWsSahYD5WlZ/ZRb4j0EJd+wXcDkNyT7pwOTFE91FGIbw ytJfaMyvZVeS8/TW1jcqqU7FNzlB92OEYYqjWDXPv8BbKKgryVJdxfyXhMqLs82nHOWV x/4fkYPVhAtHJ3Ctqt4gEjFwtXqkH8p6iXRepJyJWXO7fQlpAcz1AR6Nrsm/+saoTn1I r1kw== X-Forwarded-Encrypted: i=1; AFNElJ+7T9YtVj/7VfugQ2MQtzuL/ZmpVN3RF759OQWHtnO5Abfw5KttJgPBVgukU0QiKDEnOxcytzvoNChskCw=@vger.kernel.org X-Gm-Message-State: AOJu0Yyr56I6SadsNCBqZxlyc+wG1MwQlzN4c8dvGi+06HQBfbvywlr/ rqeEIRYPxrrubxJ8sUkP2uyphZd/emHYHnpKyWJ0+z+1g5Rc2aWFF8z+hflQYocuR4Y= X-Gm-Gg: Acq92OFK+mY2GK5esvg46pdjNnkh+gDgf04hm5ACafDWzxWeEjO7ZXlyiF7IJBlqHb7 3ps7eGQAzI7wicsub/VaAOl/XSLoRb+SghoXyqPGzcROOoit1fPQhoVoVn/Iyc5auUuYJiuzQk/ eOoyN6S/gcE1Pe9JLsa6MKchbkxSDCpUEA1Uxpnydi+vXNSDLW6AtdkNAokI6Sry8j3xAaPdhUm UB6J4iHoL91vzQTDJ28up5z1BPYGO1IzLVWWfbZdPu67mJXpiY12kREVsUEOnGKzxi2Sdfm99NH nijE96bO58sydqLOS5CyYMtzsOjmaP7WTEeu551mSxHVpL50AKboKvhEsb6jh0ClBcSH5/PZ3iF d4pBfrb6Nakbtoc7/+GRL1vD62C3To/xNr0my2HIJfTdMoMd8EuF6bu92qCl5IcdfEX7gjnDqQu MYklkV8yGSlQzDgqBdCFJPI+LsMji6hH4z64eBnERW5HkSxj0iiKbN0CzR1nltyPnhlMw7GrL49 oTyBLuG9Jw= X-Received: by 2002:a05:6000:4905:b0:43d:7508:c9c9 with SMTP id ffacd0b85a97d-45eb38a66d6mr3096802f8f.27.1779438254651; Fri, 22 May 2026 01:24:14 -0700 (PDT) Received: from silence.. ([46.10.240.40]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-45eb6c9f58dsm2398471f8f.5.2026.05.22.01.24.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 May 2026 01:24:14 -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 v4 3/4] dt-bindings: hwmon: pmbus/tps25990: Add TPS1689 Date: Fri, 22 May 2026 11:23:38 +0300 Message-ID: <20260522082349.2749970-4-sbogdanov@baylibre.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260522082349.2749970-1-sbogdanov@baylibre.com> References: <20260522082349.2749970-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 Sun May 24 18:42:21 2026 Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) (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 303E53AA504 for ; Fri, 22 May 2026 08:24:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779438262; cv=none; b=dK0+sdRkWfXASBpmuDNHCXJyIPRoAGPFmKEJ3q8PXdfFNt6wVupHdqrsfNgEyllPIrx4U2JIPYYpQ7J5DIphekAiT0jzfDWZ746eeAEj1eCxlumk2eeuu3sv3OSl5Y8UJ1EKoGCKFOIiz5kSmdv7PzHNK/Y3seSbvMpGvDIQU14= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779438262; c=relaxed/simple; bh=nvoZzgLKNXyyA9Qu+BYUaw0xIV5oHjJo4xG/UZBMSUM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=X/+9YXQfNFTcGOuxM3J5GySbBE2ZC0tW4Xz5BaneJv5dN9ontscynfnYYdMlpGvCYddf+SHAyeWd84e84zeYKYN4H5zQvp0YsmzMX2VbINOdAWGDOGqWLM7BSnAhz6cZA2Vw8rJkOqaGDFHaOqRTj/OL1OfLZIfq7cgXSloEcks= 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=AbxvUWpp; arc=none smtp.client-ip=209.85.221.44 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="AbxvUWpp" Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-44dd5cb0f81so5430262f8f.0 for ; Fri, 22 May 2026 01:24:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre.com; s=google; t=1779438258; x=1780043058; 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; bh=ajkpOnllBA6VWst7K0wBn9ryhYnCMIs37638sf6d/vg=; b=AbxvUWppdP5P0d+4gGDx0lziNxJqIJdIz+W8+57Xg5rkV7OPXse9lIJchlVwYttu42 pruByG38vxeH6IbDfify+MvXDHvl8QeW0MOrkn9RT7KPLneBErQb6sZbwyrsac9IN3DA RJrmOuuKYpZE45/x3jNPmoZIZNdIqiL53m3Eb/pKq3M5CPee2yQvnZvov4gaH8O2wcbN J8WE4Gg7lOsf5fayKWjpfdgHYODbvPfnCCN0Q/H822MhytKa/hg02pfFNrLpKHqfdIh5 r0WlIInBemjeGQhJjndPNk1hD2x9wx+owcHtkuWRlZw/vRnjG6MYHEQdEjU0uQECHebW mBJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779438258; x=1780043058; 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; bh=ajkpOnllBA6VWst7K0wBn9ryhYnCMIs37638sf6d/vg=; b=BLnSvUcx47LMZ4orN/XuyjpPAJcPOEzZTOgLa4EPrH/S1YDhWPRaEHFCxysM4XpSrz knkYmdtuXrJeUMhNuCRBQ8+Yp6dQKJFCuI7Xr8WUvn6y7H4d7Gm/fM0BRQmnwr9wQDlx uZoH3RiYiH/XoL2qhjJn42yrNf2K78l+tNMR9p0SQUvwFDUMF1HXq0Rpf0oDF0RuZqEi pABr5QVezCNSDtdLn9T7jMd8KiwSNkHiccls9n7NGAb7wgd71gU+tDcgLQzDr+ALks9j y2lp5Lu5WznPuhNRJE5IQ9LfA8OIMNWs7wc2cu4RAngmUVCJdU+UxfqNdMMUeL/SUdDj DE+g== X-Forwarded-Encrypted: i=1; AFNElJ/9OPluy2g7E46a0w0UrHrcJ4SiGVOR56gd17f9bhh9VlmuRNRPVpxYUJvU+X1ClSLJP6DC08C+l8TIfpE=@vger.kernel.org X-Gm-Message-State: AOJu0Yw1VdxBxh+CriCEXfsLTP0fzQhgF3l7m+9Fh7yQ+msdEHI/tn90 ZXN7zlQy6V3mVJqjxwlWVmPUuChR2NAOl82zSO+10XnkyG9gRSBrIUIEqD8hBeO9YyE= X-Gm-Gg: Acq92OGOBfvKJ+YEOrBF3+Wzli2610QGVLPzpzo7pdAtCBmDC0I3vhhdW4E6oJYWl4Q B8ZoO2t2iUXDg0+/aebVKa2gzEdpRppgXbRuzhEHYGswYBPk5V+UfXxV3OOE51t68ij7G51Ghco KY0BxcxGXdkn7QlhZ4kUsk9oGJg6HqMDGpxpKXBqHPgw094T4GlRHtAXrJzE7Ct5w2Jv9ikAWPV YDXm89rdAmUbmwZ6Z1+jzu5z9HIG9z6IdDMj8OQcKTdpK9SyJ3P+U7ZiIokWKBWqwgNvSFC3/7R i6zpZEyCfrajeHpl8lIohwJLz4UUkjM2mWRzM6yfmtGc/bh/6o/zJT3vJdonaLNUqgIJR8DhLph zEm5BnALU47qtsIULydGBkq/Vl/HAJaGQbZCrLIp+r/b10zY7CsCw8VP13d4hog33ysyYUMvMXh HL35F1E3eRHIhAg5RN2f9qadrgfWEIh2yGWmehGzx288ZkKg9FbRlX/JtTRGJyfo0m1jqiEcqFg VE1HetJCBeM0rkxN/W8xQ== X-Received: by 2002:a05:6000:1889:b0:45e:8edc:dacc with SMTP id ffacd0b85a97d-45ea31ce398mr10002323f8f.27.1779438257542; Fri, 22 May 2026 01:24:17 -0700 (PDT) Received: from silence.. ([46.10.240.40]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-45eb6c9f58dsm2398471f8f.5.2026.05.22.01.24.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 May 2026 01:24:17 -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 v4 4/4] hwmon: (pmbus/tps25990): Add TPS1689 support Date: Fri, 22 May 2026 11:23:39 +0300 Message-ID: <20260522082349.2749970-5-sbogdanov@baylibre.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260522082349.2749970-1-sbogdanov@baylibre.com> References: <20260522082349.2749970-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 | 66 +++++++++++++++++++++++++++++++- 2 files changed, 74 insertions(+), 7 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 1e252844217b..720e134f1892 100644 --- a/drivers/hwmon/pmbus/tps25990.c +++ b/drivers/hwmon/pmbus/tps25990.c @@ -42,6 +42,7 @@ PK_MIN_AVG_RST_MIN) =20 enum chips { + tps1689, tps25990, }; =20 @@ -286,7 +287,6 @@ static int tps25990_write_word_data(struct i2c_client *= client, value =3D clamp_val(value, 0, 0xff); ret =3D pmbus_write_word_data(client, page, reg, value); break; - case PMBUS_VIN_OV_FAULT_LIMIT: value =3D tps25990_data2reg_direct(client, TPS25990_VIN_OVF, value); value =3D clamp_val(value, 0, 0xf); @@ -376,6 +376,14 @@ static const struct regulator_desc tps25990_reg_desc[]= =3D { #endif =20 static struct tps25990_local_direct_value tps25990_local_info[] =3D { + [tps1689] =3D { + .m[TPS25990_VIN_OVF] =3D 3984, + .b[TPS25990_VIN_OVF] =3D -63750, + .R[TPS25990_VIN_OVF] =3D -3, + .m[TPS25990_IIN_OCF] =3D 7111, + .b[TPS25990_IIN_OCF] =3D -2133, + .R[TPS25990_IIN_OCF] =3D -2, + }, [tps25990] =3D { .m[TPS25990_VIN_OVF] =3D 10163, .b[TPS25990_VIN_OVF] =3D -30081, @@ -387,6 +395,59 @@ static struct tps25990_local_direct_value tps25990_loc= al_info[] =3D { }; =20 static struct pmbus_driver_info tps25990_base_info[] =3D { + [tps1689] =3D { + .pages =3D 1, + .format[PSC_VOLTAGE_IN] =3D direct, + .m[PSC_VOLTAGE_IN] =3D 1166, + .b[PSC_VOLTAGE_IN] =3D 0, + .R[PSC_VOLTAGE_IN] =3D -2, + .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_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, @@ -429,7 +490,6 @@ static struct pmbus_driver_info tps25990_base_info[] = =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), @@ -438,12 +498,14 @@ static struct pmbus_driver_info tps25990_base_info[] = =3D { }; =20 static const struct i2c_device_id tps25990_i2c_id[] =3D { + { "tps1689", tps1689 }, { "tps25990", 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