From nobody Thu Apr 2 19:00:04 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 5EB012DAFAA for ; Thu, 12 Feb 2026 08:45:08 +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=1770885910; cv=none; b=tVIDAr8EbqcAf4WqsLJR1Uwjv0u/vnKySKCOkBuOQn6y5b22F7LNbbLyzrQI1dq+qPuYWi4timiFP7HAyHy/P3xzGezPx3uktJ+H/jbppkX/i6CpwxgZcOWCC0OlVPuGXBp0lSBs+qiuuzgfH0w8Y6HRO1ejp4KyZoMshF6zy5E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770885910; c=relaxed/simple; bh=YyC1CK1Y2Fvjls9CuaZF57EXC6WMtRU1R+QXUnGT26I=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Ts5cdcumnkb181TywhLFmlDrHhUURHrxQxSGWk8dlgU5St4+RsQaVo36NR/vRKuc78jP1yOeOBl5/j2l9B1hmgZIV6hxyWR3mimrQoetwz9I/RMazDtSjp2eyiojklKZTJ1TwSuZ0hmtXbS1IsLCjN6IlXBK1GRuUwmoBRjr91w= 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.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=oWHsWpFG; 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.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="oWHsWpFG" Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-4801d7c72a5so48705485e9.0 for ; Thu, 12 Feb 2026 00:45:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1770885907; x=1771490707; 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=DGKbNkKJVLFEXXGNNWjbALlWAOl0xKwEaw4+6dFOIGI=; b=oWHsWpFG/u2fS/XqUGB6xJ6/0u7nPSUJ+kPwdXUOqqbXyoym06T6Jo2MgkiCHnPMmR Ka0UlJhOm1ub9qIKktWsxZbxT4yX572I1mAWvpdXQCuq7jkQEqeu9C3t1bTbrcgOewwz eRqFHEJ063Q/vVa8dOhspxMpKxrBHoByJqeuUiP+Go58nr7QQWqVm6lYxTbw7zmNT3In Nsr1Yy5sf4FzLDLCrVZBQhQfWlDawPGo7hetbn/4p8SyvavxW5AB2X1nQPm2YOTli47g C7yyQcDV09bBSOGbej4B5i859VXs/7bR8WI0udn8Sj/pmJSHE8y8OqVSE6JqpsYLbZFL 9PAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770885907; x=1771490707; 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=DGKbNkKJVLFEXXGNNWjbALlWAOl0xKwEaw4+6dFOIGI=; b=DOdXsBveAUscShuW4N4Fku+3EbAYL0qNQBKcyC4FHgqWlAv4PMlAV/Ga1Jnbu6jggA vB+kK9Wr0aN5615IFooGLxkXKqDDCAX0/0aYXhaxww0jR6sACpfRks5wOhgl0FdEVAUS iltzI/0O+TUN9djqF94DxPKi1S/381nrMbicm8rN/Z1zSSvHRoGstzq042h0on/tsG5I r3C+q7xQ1GQYGbSa+X0aHBAA57lqcbFEW+56u7fv6rP/V4ePBcHVPYV4I6jsPpCoErUm xiYD/NuxBYp3Xiuthfqz1hsKxP4d1ee5MEjMtPCFOqSO2msDgWx8wLbY+JnnLPfiE1pu tgtQ== X-Forwarded-Encrypted: i=1; AJvYcCV1kRGuoGYCsY/WqeATWgwUaE9r5rfXbH9anm5dfn+72NQw+yLTlqul2Q1G06KMMaS/s4QfHNu7K79UEGI=@vger.kernel.org X-Gm-Message-State: AOJu0Yz9i1ro7JT70s08yBGnemd6CNECIMystTwp5W31WQW6BRI4+waT S81tvbBGTcIB2CT9qzh58K3XMvAWUAAVSghZXekWrNzGyqr1Eph80G3uklh3HjtK6QA= X-Gm-Gg: AZuq6aJoF7aB50BYDEfmqEhCE3WfgDsEJReSCKKsJ/SuU7p0l+VcHAZEDVFCa6CguCu P1Cm+tEVhD+R7sfKZwuLqR1EYlR8GhEPaLbf3PDCYJUBO1UZ7zb/mS7JLIY4QD3PjaQV8kC99G2 1UIPVujp1u5Hc08KxP5kbbHF/dSvrwu+vScm9IHBH/FsCIVROLzSzE2AhrNooHrPnL4nvjtC7jR nZZM9FYZ6PEViXVKKG4uBzWAs5Cgqw/vB3wNw0xggt0xzCa8TXaekgfrkwWJqVS+/KdeAXgYN7X Yz+nCK3rCrtvnetMwytCA7K3BoXUu7CuOQVUaXuhr6y5rHd38f/JrB0yzLwT4ymbJCHiPF9pQ34 fC26+tengiJe0upx/P8GfkzAlbN1xavc8CnCTIAMqreJPWTm57PQrIBEgl2V/On3SPeThYd/DIL EuyatLU297xoRdTZravAEQYpu7/m+jhf6c91IjB0P198t3CnQZCrNGyWwB13YYtP0/i0V/xEpYn H8vdIubhg== X-Received: by 2002:a05:600c:5287:b0:476:d494:41d2 with SMTP id 5b1f17b1804b1-48365716538mr25217415e9.29.1770885906700; Thu, 12 Feb 2026 00:45:06 -0800 (PST) Received: from silence.. ([46.10.240.40]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4835dd0e15bsm82753705e9.13.2026.02.12.00.45.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Feb 2026 00:45:06 -0800 (PST) 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 v1 1/3] hwmon: (pmbus/tps25990): Rework TPS25990 non standatd direct conversion Date: Thu, 12 Feb 2026 10:45:00 +0200 Message-Id: <20260212084502.1795-2-sbogdanov@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260212084502.1795-1-sbogdanov@baylibre.com> References: <20260212084502.1795-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 for calculation of direct format conversion for TPS25990. With this implamentation is leveraged code reusability for non standard parameters. - Add enum for parameter - Add m, b, R structure to hold value per device - Add data structure to hold for pmbus_driver_info and local_direct_values - Conversion functions are implemented according to formula from TPS25990 datasheet - Remove previously used defines replace with structure Signed-off-by: Stoyan Bogdanov --- drivers/hwmon/pmbus/tps25990.c | 115 +++++++++++++++++++++++++-------- 1 file changed, 88 insertions(+), 27 deletions(-) diff --git a/drivers/hwmon/pmbus/tps25990.c b/drivers/hwmon/pmbus/tps25990.c index c13edd7e1abf..268e361b6fd3 100644 --- a/drivers/hwmon/pmbus/tps25990.c +++ b/drivers/hwmon/pmbus/tps25990.c @@ -36,17 +36,58 @@ #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 tps25990_parameters { + TPS25990_VIN_OVF =3D 0, /* VIN over volatage fault */ + TPS25990_IIN_OCF, /* IIN Over currect fault */ + TPS25590_DIRECT_VALUES_MAX, /* Max value ensure there enough space */ +}; + +struct local_direct_value { + int m[TPS25590_DIRECT_VALUES_MAX]; /* mantissa for direct data format */ + int b[TPS25590_DIRECT_VALUES_MAX]; /* offset */ + int R[TPS25590_DIRECT_VALUES_MAX]; /* exponent */ +}; + +struct tps25990_data { + struct pmbus_driver_info *info; + struct local_direct_value *info_local; +}; + +static int tps25990_raw_to_value(struct i2c_client *client, int param, int= raw) +{ + struct tps25990_data *data =3D (struct tps25990_data *)of_device_get_matc= h_data(&client->dev); + struct local_direct_value *info_local =3D data->info_local; + + /* Formula : X =3D (Y / 10^R - b) / m */ + if (info_local->R[param] >=3D 0) + raw /=3D int_pow(10, info_local->R[param]); + else + raw *=3D int_pow(10, -info_local->R[param]); + + return DIV_ROUND_CLOSEST(raw - info_local->b[param], info_local->m[param]= ); +} + +static unsigned int tps25990_value_to_raw(struct i2c_client *client, int p= aram, int val) +{ + struct tps25990_data *data =3D (struct tps25990_data *)of_device_get_matc= h_data(&client->dev); + struct local_direct_value *info_local =3D data->info_local; + + /* Formula : Y =3D ( m * X + b) * 10^R */ + val =3D (long)val * info_local->m[param] + info_local->b[param]; + + if (info_local->R[param] >=3D 0) + val *=3D int_pow(10, info_local->R[param]); + else + val =3D DIV_ROUND_CLOSEST(val, int_pow(10, -info_local->R[param])); + + return val; +} + /* * Arbitrary default Rimon value: 1kOhm * This correspond to an overcurrent limit of 55A, close to the specified = limit @@ -184,9 +225,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_raw_to_value(client, TPS25990_VIN_OVF, ret); break; =20 case PMBUS_IIN_OC_FAULT_LIMIT: @@ -198,9 +237,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_raw_to_value(client, TPS25990_IIN_OCF, ret); break; =20 case PMBUS_VIRT_SAMPLES: @@ -246,17 +283,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_value_to_raw(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_value_to_raw(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,7 +370,16 @@ static const struct regulator_desc tps25990_reg_desc[]= =3D { }; #endif =20 -static const struct pmbus_driver_info tps25990_base_info =3D { +struct local_direct_value tps25590_local_info =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 { .pages =3D 1, .format[PSC_VOLTAGE_IN] =3D direct, .m[PSC_VOLTAGE_IN] =3D 5251, @@ -386,14 +428,19 @@ static const struct pmbus_driver_info tps25990_base_i= nfo =3D { #endif }; =20 +struct tps25990_data data_tps25990 =3D { + .info =3D &tps25990_base_info, + .info_local =3D &tps25590_local_info, +}; + static const struct i2c_device_id tps25990_i2c_id[] =3D { - { "tps25990" }, + { .name =3D "tps25990", .driver_data =3D (kernel_ulong_t)&data_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 &data_tps25990 }, {} }; MODULE_DEVICE_TABLE(of, tps25990_of_match); @@ -401,23 +448,37 @@ 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; u32 rimon =3D TPS25990_DEFAULT_RIMON; + struct pmbus_driver_info *info_get; + struct local_direct_value *info_local_get; int ret; =20 ret =3D device_property_read_u32(dev, "ti,rimon-micro-ohms", &rimon); if (ret < 0 && ret !=3D -EINVAL) return dev_err_probe(dev, ret, "failed to get rimon\n"); =20 - info =3D devm_kmemdup(dev, &tps25990_base_info, sizeof(*info), GFP_KERNEL= ); - if (!info) + data =3D (struct tps25990_data *)of_device_get_match_data(dev); + if (!data) + return -ENOTSUP; + + info_get =3D data->info; + /* Make copy of pmbus_info and replace it to preserve original values */ + data->info =3D devm_kmemdup(dev, info_get, sizeof(*info_get), GFP_KERNEL); + if (!data->info) + return -ENOMEM; + + info_local_get =3D data->info_local; + /* Make copy of pmbus_info and replace it to preserve original values */ + data->info_local =3D devm_kmemdup(dev, info_local_get, sizeof(*info_local= _get), GFP_KERNEL); + if (!data->info_local) return -ENOMEM; =20 /* 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.34.1 From nobody Thu Apr 2 19:00:04 2026 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.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 5B3402C08DB for ; Thu, 12 Feb 2026 08:45:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770885910; cv=none; b=qRT1ogC+hqhUmM9leKKSG6ePg1pjsAHoAY1aYNa00mWxYQXpBuPqbJCO6RY9Xsop2ynzmIXgx169aGVfFW2BTYUyrvdZdUgbMwawvkUiGgNgCWzweHxv8P+4OZP+NjuV6YaoaKE/hKYGJkFpTHlGrhfwYhU+oViP7f/Lm4gf4A4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770885910; c=relaxed/simple; bh=S4LjTcY8WIdOz/Fa9CMVBB3lEWE7ucfcbiatZtIUpyw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=amibkQ/2nyJVnAqHqX11R5rQTo0k6rJGJzgdY95/4wLNQJZSL8tqyLLDaJR9FK/mPKvjl4Vg5eYVyrQLCy24z4ZdocEpkzbtwHYCcyFmkwkKQaH0/72R4i1S1Zx/IIDRyzXZu87zaC12+YJ+E6ShyLY4b4Xymai9wqENAb5F25o= 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.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=DoRu0aph; arc=none smtp.client-ip=209.85.128.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.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="DoRu0aph" Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-47ee937ecf2so17827975e9.0 for ; Thu, 12 Feb 2026 00:45:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1770885908; x=1771490708; 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=2NGh5IYyCcy/eOuT/iqO1H2zbkd7MZApIvvP1+BGFLo=; b=DoRu0aphxfMikLEkIws/gZ35AFAAaWq50/8p/ZB3104FdVmD5QkUvLccyEFLbs0JCV dI79B4H/pkuoUWFy72hZ0J06XCkQZPkDLqcI0QrNZM9JQn01FgqfodRKsVJ5XdW651EH WUMeViR+kCkUytG7nyxYOze/8yXBYF9Bi/r/wpCPBMUeiVZySfrYRhmS8IhpF9Gg4Cd1 +K9lnwc2guj77uAYJsQ02ilAa60L3Oo1xtiVA11hTLoz2OBLwqAuJJvVh36eYdYlYc4q P9olHw5Hz+pkazv+l7oVHbbbxpRdT1ZqfZaffvlmpWtkLcnwPl3DkdySR+4LeK3xxCjw gmHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770885908; x=1771490708; 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=2NGh5IYyCcy/eOuT/iqO1H2zbkd7MZApIvvP1+BGFLo=; b=J0o4TPiyZ6aRgTnCZupQEaQCrfRAoyL1p4RifAmvEM6n05ol4Opy6WT9142Qb/Rt1d bZL9o8NbuCHB4JKMQYw3wdSe/hhLC2wW8+wVr+Xo3QB+Q9FxroLUk8LGeG6dKYJOkF9y M3J8GjE4YstGOKfF5KwicbugINiH4c12qNel8Cs01hK62H8B9jVuzxd3wWxu+hNJIJ7z 9/zva+OTPfT6uLc81bwZD6quVbsQzVYBDON2IskBxfk+YBu5QM5OSmCX3TUVMGbVwg35 Sumx0wuURtpKJjvK+AGsuwrMWmMm0dluRa4wE6mZEq1KMrgnxQzpzLOdswYFfw8tiVME 36og== X-Forwarded-Encrypted: i=1; AJvYcCVmaiV1e6lpJVD+mfL9Qdaf7vhKbjiRBEWk0Zh2abl0jK8wNjv9uwTJfaL97zZd0VjaYu2eja1yUeBYQYI=@vger.kernel.org X-Gm-Message-State: AOJu0Yx9ZrT7jVwWo7Wqsoc4sgvCid1YDnf0Os0q+96qgzodvTi+9TRx k6iVkn3aBNRrNKbmA0Z9Wd049dp1HOBqlZHqgkx1N8OjSRQGRvjlfPpmwL7f8+GSONs= X-Gm-Gg: AZuq6aLV5Hxl+XE+0X+Ly4hHx2+ltddcC8Nrb/ePg7mYNndcNh2dDoV4bhsWvYZc4cH zEPdD5Jmhbxbo30EHPAmfRUU/swHuE5Yxt/2OOuefxoc76uJk4xrOYiIj/yFGlGFLEqVAU6dJuN cP+bqkqiHHbimL2SAd8xJFDufbm06f1dCgICjhMWQsyXOPEf/CEHNjfszg0xxJ+uXPImke23zRR LiZEhPD5A1NiwSC41tilSOqw7GrM+38HN0/1rSTG0Xg1WuJup/dKTw+TGt2ck+MpXCzDQAWbxID URvdFfLxTACXYBPJsXkWIRFfKaBxpBYgCC8N6gQx+EhaL4mIrGXW+zLl5wRCm4etG13RTd5XmWE utzWJpcWge08E/HmjVIibCEMTt8jnWu3uPnO4FfmWOkG5R0DFLEz0ci2SQovIJbedB/GjPOwC1P KjKX+1sutaM6V2J/2NpuPvFTHgDEUA0sGgothV6JHN1O3hWRUbXBdpONLG2oNOhefq50CvJBGG2 teynye42w== X-Received: by 2002:a05:600c:4e4f:b0:47d:333d:99c with SMTP id 5b1f17b1804b1-483660425a9mr22340565e9.18.1770885907761; Thu, 12 Feb 2026 00:45:07 -0800 (PST) Received: from silence.. ([46.10.240.40]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4835dd0e15bsm82753705e9.13.2026.02.12.00.45.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Feb 2026 00:45:07 -0800 (PST) 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 v1 2/3] dt-bindings: hwmon: pmbus/tps1689: Add TPS1689 support Date: Thu, 12 Feb 2026 10:45:01 +0200 Message-Id: <20260212084502.1795-3-sbogdanov@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260212084502.1795-1-sbogdanov@baylibre.com> References: <20260212084502.1795-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 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/hwmon/pmbus/ti,tps25990.yaml= b/Documentation/devicetree/bindings/hwmon/pmbus/ti,tps25990.yaml index f4115870e450..973ee00c2c49 100644 --- a/Documentation/devicetree/bindings/hwmon/pmbus/ti,tps25990.yaml +++ b/Documentation/devicetree/bindings/hwmon/pmbus/ti,tps25990.yaml @@ -16,7 +16,9 @@ description: =20 properties: compatible: - const: ti,tps25990 + enum: + - ti,tps1689 + - ti,tps25990 =20 reg: maxItems: 1 --=20 2.34.1 From nobody Thu Apr 2 19:00:04 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 74F612DC792 for ; Thu, 12 Feb 2026 08:45: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=1770885912; cv=none; b=G1UbMhQs9iUK2ajNOep0vUIA0K47vg0Kb+5yUxcF26WCE0SKf1oYN/qJSCkKjxYjOHCfPCIwLnhktKL22h7tmgZyb0SnsW26/r1XrVX5NyPxE9bA64+LxMRCXC7ow3AKmFCzzp6YZuvtNO5RXiLvOJgsDqLrhZvWeIDdPFpHzfg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770885912; c=relaxed/simple; bh=c4T0y/hzZHDuIAz/fbVwxQ6Q4j0rUNvQhG2sxxLl4ak=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JjoMPhVjwr/cNMYPPBNhK44WODHOD9zF6rfh8zY/iQqoALfxyP+UToW8CAeFUn2bt/2tM2zG0784GagDEi4YFn70jD3CS3n/wbJXrzqLtQg1izUnzjAHCCC0qZF/qlkn7PacUeFwe2kX/I1GPBHjtmPHtKolCRRAw1moShVph0k= 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.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=RJY4P9tC; 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.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="RJY4P9tC" Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-4801c2fae63so62945685e9.2 for ; Thu, 12 Feb 2026 00:45:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1770885909; x=1771490709; 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=4pKMLu2vrVoz0ZANHaXBigtawgekohjYcNvHVashll8=; b=RJY4P9tCmNGoU7tLbopsCk9p4SX11tZ9UCCWKGQmw0ZMcm/LSPGdzZOSE2VvJ09ArE 68s6nrSi+BDicSnp5YNo1QeOPZxcxxXWBJGTFYQgPRqWLk5ufHZqlrA7NjrG8yRqEQA8 EyVH4k1iQeq/GEKwtqscqjd8d2AFQ5rO8OSKDir7wHX60WT38/xne9ZDVwB92pOKBAZ0 KCQyTMf3RX98zA61KYMf9v/RqGvpzLA79GO1hDnAYMUc5Wea6rqVsFRA0hnXAXeYV6wX ZsISslqHe491IjKGlspWHqi65W2C//fdgt20z+++p/jMHOfA/jTyWjV3F+xBYpQf557S xjBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770885909; x=1771490709; 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=4pKMLu2vrVoz0ZANHaXBigtawgekohjYcNvHVashll8=; b=aItERv2gT+p7s9ohWwKHasoOLLOdHkDQO7B8dSTUnD8P+Df/nWw42+dQbqf/7ltiZk fYOPD4qHXppFbWtETPR7AxIf+IGCOtWvecHxQLTcQdpmKMDBstdw/oXqt+KBOmVmCsp4 NxGyt1SBCSdECazjdrXCQ6r89A/3dg5Kr4SMtne2eSrNiZUV6woBHHeVDyvv6GLOiQlq eBnditStaxoQFMUBGy2K02f7zr/4P7A5aURQ1jowaAjjOsKv+EbkWqv+zXbgAh7EyhWr hbuu2snQH5EvPPTY11u9VGKr6GaXe9RP+Atdj4nR4X3BMsAMY+lOaek0+CwlzIs21BSO RP7g== X-Forwarded-Encrypted: i=1; AJvYcCWyXBUmrchmCIM6KE3M7AYFyektQtzffrLgFjBVczpxP9aiHEoZpxR+Ub+gO2/nL8UPh4jp6zwLiBO+rTk=@vger.kernel.org X-Gm-Message-State: AOJu0YzZFdFL99Flr4eKmPsuZKv319jcYLroUDmzkuRWJCvtMueX70pr v3tpQNQ1bvXi9krgRH2x6zZZ/BScfdu9vOrKMWzoaqcTlKKb3i0sz7MzNKWAsnqYHPk= X-Gm-Gg: AZuq6aK+RpDiydCeZt6NTSfUF6rmvS3m0YKFq3racvptvIUTosjN8wczBjTuMSbovRq pbPRMEY2/U8NhW1KoX52r8THFuWmKfzENO9SyiHSuH7/ogydCgPgdq+pHATCzU3vZvBjO+Zx7H5 fT7L6HH+YpfoGmU3Cof+QaO2MnGsLIeBiDaXOZDvnD7xMSTuuxp99zG25K0tcfLMw7VF1AdImCA GO7RHd2H0ApXcgiahbK3FvdwS3jJVi8Ji2v9lSNa/SyUpOyxEPbQia5YJdEiVVLHg9eNg0LWZHS AFeY7/KlkbKFp1Edvg/i5PsFeKbIVKOKDZ45mERs5PMRro2Ws+ddLqvTfcqg+d2Vaxw0ERsCn1/ T2DSTqqGkkrZ4pifHFyMylvc2hoYDdPdLOZK2uY2yMUTDHZQq7GRHP7g2mHIvy9NnJwU9O8amvv g38jLfgoxdXtN+978jp62ZCF+/tDKV62xL2/w5xI1YQt++WtJcncpYIX4kRJ0/LojMaJNmxw3aX Wq9af9igw== X-Received: by 2002:a05:600c:848d:b0:479:35e7:a0e3 with SMTP id 5b1f17b1804b1-48365716033mr24734255e9.30.1770885908815; Thu, 12 Feb 2026 00:45:08 -0800 (PST) Received: from silence.. ([46.10.240.40]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4835dd0e15bsm82753705e9.13.2026.02.12.00.45.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Feb 2026 00:45:08 -0800 (PST) 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 v1 3/3] hwmon: (pmbus/tps1689): Add TPS1689 support Date: Thu, 12 Feb 2026 10:45:02 +0200 Message-Id: <20260212084502.1795-4-sbogdanov@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260212084502.1795-1-sbogdanov@baylibre.com> References: <20260212084502.1795-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 tps25990 existing driver to support tps1689 eFuse, since they are sharing command interface and functionality Update documentation for tps1689 Signed-off-by: Stoyan Bogdanov --- Documentation/hwmon/tps25990.rst | 15 ++++--- drivers/hwmon/pmbus/tps25990.c | 70 ++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+), 5 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 268e361b6fd3..3d4056724303 100644 --- a/drivers/hwmon/pmbus/tps25990.c +++ b/drivers/hwmon/pmbus/tps25990.c @@ -370,6 +370,15 @@ static const struct regulator_desc tps25990_reg_desc[]= =3D { }; #endif =20 +struct local_direct_value tps1689_local_info =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, +}; + struct local_direct_value tps25590_local_info =3D { .m[TPS25990_VIN_OVF] =3D 10163, .b[TPS25990_VIN_OVF] =3D -30081, @@ -379,6 +388,60 @@ struct local_direct_value tps25590_local_info =3D { .R[TPS25990_IIN_OCF] =3D -6, }; =20 +static struct pmbus_driver_info tps1689_base_info =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 +}; + static struct pmbus_driver_info tps25990_base_info =3D { .pages =3D 1, .format[PSC_VOLTAGE_IN] =3D direct, @@ -428,18 +491,25 @@ static struct pmbus_driver_info tps25990_base_info = =3D { #endif }; =20 +struct tps25990_data data_tps1689 =3D { + .info =3D &tps1689_base_info, + .info_local =3D &tps1689_local_info, +}; + struct tps25990_data data_tps25990 =3D { .info =3D &tps25990_base_info, .info_local =3D &tps25590_local_info, }; =20 static const struct i2c_device_id tps25990_i2c_id[] =3D { + { .name =3D "tps1689", .driver_data =3D (kernel_ulong_t)&data_tps1689 }, { .name =3D "tps25990", .driver_data =3D (kernel_ulong_t)&data_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 &data_tps1689 }, { .compatible =3D "ti,tps25990", .data =3D &data_tps25990 }, {} }; --=20 2.34.1