From nobody Thu Apr 2 20:20:27 2026 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (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 27FAD52F88 for ; Fri, 13 Feb 2026 00:15:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770941720; cv=none; b=VcOte1E3cxObcSCZ7/Pm8TnGfEHU/S7FEoDR1aWMnEl0ZLgFL46l0Ar3I3dk3QCh4HfcnV+6jxM9LKHeD3mWA3Rf+4ZRSWmmGycvJt47BwVmXIKnRy52YaquTkWRwBE8GzCdlJhejOSojfRoGABgNMcKc9+SqTOU5UYym3IZOCg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770941720; c=relaxed/simple; bh=MBxXvm9SN85wIbPQozevHNwhIzjPtliVSJlxB+6iP8A=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=jV9yp9O4xIVDHxQWgxWKpoX0TJMY4yaiIPYEYZNVXf4U3iRcyyl1TeeIY8HsbCp25FT1wWiEWhWJ6qyP2sRfnSicjHeMtp+M2uBNAmhyK83EAIQ2xV7dykULrCIIvxnDoIstinh+cEQIFQZ+Diw9mtsolw1IMpTHQZqgMNqd0mI= 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=DZ67Pj5r; arc=none smtp.client-ip=209.85.128.49 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="DZ67Pj5r" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-480142406b3so3048085e9.1 for ; Thu, 12 Feb 2026 16:15:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1770941718; x=1771546518; 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=nkpDAlBYfnDGxcVrWynzmo5K/OoXZi98TxFwnjNQDvI=; b=DZ67Pj5r2NRtJDLbAF9tPO3yboADCvKntmnCV3l2o5HoXxZ75Uj4Fd7+7+V/muCkwJ +v+6ssbzcnMjx3XharQrFOl6hhsYACYZCgUk0LY2QodGaIJe+clwHGOMnzo54k0zXHYQ pDYbOo9g+X+n3ArPujQ95PcaVVrAp23FnUMEBmXc5LoIEV01uapMz/hc1eWZl9S9DWzO ddcYq+yv9UcHEa1j1yuenQCglpBp5DV+5sIu0BZfKEzW0aAL76HKlPPcEsxdm/XAWc9B 4hXLKDfpid/OCcSH4seyE3WiMz4W+TjKnt+4nM9opoFKm8sEFAgwJ+ixbgvH2KnfhaOh Xr2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770941718; x=1771546518; 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=nkpDAlBYfnDGxcVrWynzmo5K/OoXZi98TxFwnjNQDvI=; b=Kiydph8K08S7BDoFHxbJY2Szj29lQirVcDQFtSicWJYRYWyh5UETcYD3Y1K7nbVnC8 ZcHV+z4tKq5ey5RQj2USQRlHGcGgb0/BR7ULfvdFvWMi3AGLyjAESQ3TNRyQHBWd83UA OOV0mMJPFUWsI57zpBlOppAq/L5zCIqVN93ug1AWTuyjguGqXXq/FByR6NxjMOJft21L wIumxBXQZrU1tdhAAHeenwrnUVIYsNZ10j2sOH3hZtRHuFx98zZxcNBqyQeHsRRfhzU5 xZKwFPp7E12w79im5TuY552ac6J9fbZzbDF3w7DWbM/H+h+5hz63QYJY+hVL4BhkHWAi d2Mg== X-Forwarded-Encrypted: i=1; AJvYcCWxnhTJApciugq1pbIKXdk3j6rWu7rEf+T+/Jc6nblMoTPpqnz3kMkEkCTHAeXSNuky8f52qHw1ZgcaYbM=@vger.kernel.org X-Gm-Message-State: AOJu0YyyDrsFniacF+RS+TThFDjOVtgXGLSJZjEk44UsbK7LG0eWas0p EeYKnyMMX8E6tWTGDHhPPNY9JDvWhJu3redk31H2d5STgLbwLCLr3l1Ekr6cmM07294= X-Gm-Gg: AZuq6aIQr64MMl0Z0026WWMVdmecGTr3B0+XGwopL2bZHvdBaw9514sbXzdWwnR6m4j p50y31RBB18x8pTwxeJXeChRVLzRj/I7ifAljqvxfBlP1cFo/231HzhKysivxgqYa+TxP4JDp5M QABoT4Adr9MfpH1mC0vuwjSk3AKUdHOzD6KNDU62iiCGYocVIWJKHePJ+MCXMFswBYILikqXLEN 6YYdtLKW0q59w5DDXfiV91ReUjHLKKxvgvB6x1pqUXC9zVD0ubpMqxCkBngJL2Ekv/KA0SItPsR /bK22w+U69mpYjXIWNfjhwV5FrKcETq8VYBBmKIf0rlVdi2TpUNGXByF2MqYYIoyvvrf2vGSH6p V4LYAN1h+3Q6y3sjo5flEYHnRq5UVwgqw53FjzcjLQU8nf948IuxoS8RKVZYPhT+5u/csEDuVa/ qelI1Wz3Bz1gPHA3XKzjCpqbJw0VErYDZ05wPw7ja5tfs+qm//meVQzLAk+z22e9Jds9yuqrpak lFD//awgQ== X-Received: by 2002:a05:600c:1381:b0:483:ea6:8767 with SMTP id 5b1f17b1804b1-48371098c8dmr12349945e9.36.1770941717627; Thu, 12 Feb 2026 16:15:17 -0800 (PST) Received: from silence.. ([46.10.240.40]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4835d99497asm234440945e9.6.2026.02.12.16.15.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Feb 2026 16:15:17 -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 v2 1/3] hwmon: (pmbus/tps25990): Rework TPS25990 non standatd direct conversion Date: Fri, 13 Feb 2026 02:14:06 +0200 Message-Id: <20260213001408.2454567-2-sbogdanov@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260213001408.2454567-1-sbogdanov@baylibre.com> References: <20260213001408.2454567-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..33f6367f797c 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 -EOPNOTSUPP; + + 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 20:20:27 2026 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (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 9582A17555 for ; Fri, 13 Feb 2026 00:15:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770941721; cv=none; b=PBPzQIX7UOcy6AglZs1sN6bIMYy7BrRU4uX64VxtMkNf80UH3qlNyEY6z/ahLzSJxoPV1kFeyCULk5FBoscrxlSpMbaV5HJjPVp9rZIjyw1LNTZDTs0c6HhfdTguFuep2Bz4sp/ZTopTTRvolc8Ik2iFbFlvdj7tQG2gcMkQQgo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770941721; c=relaxed/simple; bh=fUJ50nNqzEo25SE79AYPaMX7LUUHzTN5oOiZ4xAgcTU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=OvJI0kMkdQ7Bbgd7SxE5FZoPHyEu18LE3hzcqiRVtTq/KMBoE+viu1nfmTegAZ5g7T7NgLyyxexO8v7JL6glh9/Oz1ulPM/rr6N9j5jQZEmcRhD1iaf/wfc+NqmkwCYVeVX4qgB/s94fegAVmvI/WugFKq2ixODuyKQT5+B6YNw= 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=VBu6gF5l; arc=none smtp.client-ip=209.85.128.45 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="VBu6gF5l" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-482f2599980so4555245e9.0 for ; Thu, 12 Feb 2026 16:15:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1770941719; x=1771546519; 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=hkC79iRLW3tdZGeGE0h/zKnK7gWxEm2JpK3spSL5h0k=; b=VBu6gF5lDHN4wM2GSGIrQK7vnK2gc/Qx7krUJonGeQwGXeZZNKP0POuLpnQORloUtr qHlfXQxuCFYelrL40lwXfDfU8HmupjgQD+fhxjvYpsyd4hWFoFtgHodpCnOgC4FEoKWf fzhDdH7ibqYQw/7b+U3WiUY7iZI2nsdhegQVHTR3I+0QEKZECwpg/cf8A2ROEDeWUvJa T7oXXR92DkusBTuQQR2PTrsBPPXeyTkQqAql350qygPicr8tNgdcED97eHXHUzpXvTef GochuteDfIj6HcjB3pt8uLJE0rRNGNyOjPH2M+jwxTYSDpJtwq/HzlE8Ua7gLtWDdTK8 bXGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770941719; x=1771546519; 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=hkC79iRLW3tdZGeGE0h/zKnK7gWxEm2JpK3spSL5h0k=; b=ixMgj83t/KWLM4HHQf94YrJJSGnXo4TxVRwR46LxTFW8z6evcTjUj2oBJkrE5+qITy j8PJR3IHMLn/53VKqyPmlKakbklDEA9Mkirw6c2Vd/VGPNd0qyNC0WGxlM1JAzfufWIM N0qhQnaJ8swyfcJaCvYgVqkFOj/vMumHGJW2d7pY3OmVOAbgldgFrXt8wshAFzKKtPTA lsux64K1iaaOctUT1QVJspYeSTQC2bnyJO5jRRWZuw0O88A22ldZiHRXRnvM4QoBb0EJ IueBjuznbSoJxOK+FyyH0yomqR12YGmuyhLCMRQJ+ToJReoVQYdxp2YgELBHlfP40Bzp mNDg== X-Forwarded-Encrypted: i=1; AJvYcCXZp8yJuGfcN84lNpOTl9EXG5BuiiUAPPuXxmzTqINv51FoRID96X7sAldsUXLRHnVL+dlVlUj69OMe2kg=@vger.kernel.org X-Gm-Message-State: AOJu0YyQzCWmEAsZ4CxgxF+3LG0mTsgEZUUWpwpkynL9KmsJ+liFbnTZ GdVf+YAdpKFqXZxCSOLgNqGQo2edHMeZvbf9sE8zOfa5BjIKbisYHHt5VZm7atCcYm8= X-Gm-Gg: AZuq6aLOTGv4lu19s6vWy9HL08H9NipSUdwXbdl93e8NwlqvUoQC4qNcvFi1CoB5ro5 br4udkRffDd/b6W5yqkUobwpf9VN/IN6hL6ZnxF8mnM+uSwwKIbPag8fGEJMvacHVep5AkRxzj0 LoWiBYy1QuuLIUDHazOEqWv8pcsWuA3HmTC4giYrY+Gmks16oMio6q++jkgQFWJ8x21i6LtTxZ1 dDydGJiH2uMN2X7BZ0vSMRVC4mzwPEHqlyv7bZaaguOEbX/8e3rbGMPh84uMsbPs5bI2AmyMnjl em+WcMPCvIDT131lZHetHMh9Sa/s+di65XxoZxW5ywsJv8QbsOy769/gt0cLYkIzZ4zMYAPmcQy Qo0MeiV8LfAriRnB6GUsLz42H4WA+Dfznyy5aMiMAYQ+XdTfEqX/JHQ4URH1eofPNGV2lVwBIYg yklhSgt8rPrF3VLoOW4wGmOSgsGtj5uu4HVUDZi53M/yTsYNSzt4R61NshWKiw1WVmoR//u4146 0yRXqq0oQ== X-Received: by 2002:a05:600c:4fd4:b0:477:9814:6882 with SMTP id 5b1f17b1804b1-48370e18853mr16124895e9.5.1770941719083; Thu, 12 Feb 2026 16:15:19 -0800 (PST) Received: from silence.. ([46.10.240.40]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4835d99497asm234440945e9.6.2026.02.12.16.15.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Feb 2026 16:15:18 -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 , Krzysztof Kozlowski Subject: [PATCH v2 2/3] dt-bindings: hwmon: pmbus/tps1689: Add TPS1689 Date: Fri, 13 Feb 2026 02:14:07 +0200 Message-Id: <20260213001408.2454567-3-sbogdanov@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260213001408.2454567-1-sbogdanov@baylibre.com> References: <20260213001408.2454567-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 20:20:27 2026 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.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 ACC6D1D432D for ; Fri, 13 Feb 2026 00:15:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770941723; cv=none; b=osqh0OVOhPoM6YBV8V+8e1non2EXt3v0AeR3OuPuLvs6AVQfTI4IzHLXldPgdqyhVPfb+fILWK3IkoeLnio5fUeaUOFmNRfbiDmZ5Pflp7FAGETRa1eePK5n66gBvYAnQ4J1mp82ufinw1+chVrAS/vJZNW6eJwtJ7dpAPmtdXA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770941723; c=relaxed/simple; bh=1QKFWI4RjXLpuskxjhRHAeiImz6OuzoRskJ/lHHthpg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=b9GYLt4QlgZP1X5TgOZtfG0UXDpO8a+xQi0qLBlSsWqlVxhI8TZwnCwY5ojzEznr8pVsMc//SZpqhU9cRRDBDY93iwEH0pOEv5w+bM2EnuHB/szTNsqb9DFU1p1nmv6EhHbZgZZedo1o0+L/rRMv5P3C+26hnqw89SZ4N1LC5Iw= 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=qOiEEh0R; arc=none smtp.client-ip=209.85.128.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.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="qOiEEh0R" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-48371bb515eso1652235e9.1 for ; Thu, 12 Feb 2026 16:15:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1770941720; x=1771546520; 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=PSlv+TtmjbR3KEd39LSGtfFdiXlGzzelHhN9IPNFyGE=; b=qOiEEh0RzPKvXwIxWnRO29NDtqrcbh6pf0qg7F0ZjkibmkHGQo7MzqKVTOYhiasisK +zRyjBeo8M0e35bTIrU77FpG5joaOFWQ0J6lLPeWqZjOc+Hq+M530XK/crJ/LFOxgx+R khzLrQIJ+xforHX7k8mk3OA93liYpFce90HvPxdksCyb0w6FryUdSDj1pmWC3iMdF3Ht dyMLZc3H1MGVq3FM4oHf2ptcWirtzRvftxNNLu0aUVNYrdRUgFhOKgZCozswx4o950q7 NCpfgtVW1qmFbFD4FpgfCVHnlmTKC7gpFNIVcYG+I4ENv9b3bL3hgY0AZA/pH9XSgm/H TfbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770941720; x=1771546520; 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=PSlv+TtmjbR3KEd39LSGtfFdiXlGzzelHhN9IPNFyGE=; b=QlF1NPeSAr6Lwq4K+PwRo0/KFuZi1VUPD/G6I7Q7e/9wAzJe59AdhN9r5QwVMc/OW+ 50Fm+FSKtcTvnYsRZccoUDrtLj3xnZg4ob05X5MwAPg2Jp5xafR4dgfGWefdTBRpNn9N ct7owuzs3KVa6ScE+d3GEw3Nenh9/fgc6fdCWZHCJaDLLqarDWBZwtvhMqoP0fpbLUHL FQKqKGKaeeNkYVfFNmlMyKqWPfbJGFEBMyabby0j7rwdGxWev7VVzj/HyNs1kUFJCZp/ qWqZXrEOaHIpbgutxSg0Tb4cqJlPLQOL7tz5zYu7h+ZLZP3q1FHj+qUDxphWlWPImoeR a35A== X-Forwarded-Encrypted: i=1; AJvYcCVbnm2lXMVZyTtRx6KnChSSMrBZKm7DoELHbhwYuMjOC7ARCv32puigXblXHVRpPm4KJ5e64B0RcuxEqG8=@vger.kernel.org X-Gm-Message-State: AOJu0YwEaCyn1t9EIwDLPnNeEWCNH6pz0QGpum9kfrdQE+HsW3ccrxEI TY+etOuT/cSW6AE6L/QJ94jMz0zniLsCZ1ihREqvAfRJNt0ERlq69cXaI3uF1JMuFj0= X-Gm-Gg: AZuq6aLaaUQl/dMoUAtMDBfkuePUTvT3j8QWc1DJB5wPpOLTx6qVn8rQ7o0k4rrPYSj mf+l2xxuyvmpygLNxTUtn8lSMnn36hjGr2FK8bKJDFrPHjEc9IyEHSSROWpqk6eyc69EbTWpT5d 4D02eSz2ZswRLugkUXfJhZOu0OXeA9L0aiwtehNpfh7kEP3CpRO/pPY/UiFftp3f7ylA817Ygej fixDNgIrfbxSHLiaFlReFbcoYYWC6O0gBXFE7shpatffMtiP4J+5Ht8v74udXreTGEoGsw6uvYX RlWAsTCKlzjn+6Jw8bTlT6l4rjuOxQz++uA8M6EsvUJ54Ya+ewhp8so2t5bqk1GimwKspHP36ew jlDwRjUQYrYRyl/V6LHapvKjL4MVh6BI7T1i8nd2TflB0L05ZUezTL+CjRLaqwxQOD9eC+ojUrc rNV4lXnYe6vGTyz+IWO+XeiNCTheDPk+4x2U6J4yogKaThg1nepalUWklDv4JBohKiHGHWmXbH4 J1zVtjLvQ== X-Received: by 2002:a05:600c:34c3:b0:47d:73a4:45a7 with SMTP id 5b1f17b1804b1-4837103693emr15594065e9.24.1770941720202; Thu, 12 Feb 2026 16:15:20 -0800 (PST) Received: from silence.. ([46.10.240.40]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4835d99497asm234440945e9.6.2026.02.12.16.15.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Feb 2026 16:15:19 -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 v2 3/3] hwmon: (pmbus/tps1689): Add TPS1689 support Date: Fri, 13 Feb 2026 02:14:08 +0200 Message-Id: <20260213001408.2454567-4-sbogdanov@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260213001408.2454567-1-sbogdanov@baylibre.com> References: <20260213001408.2454567-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 33f6367f797c..c2da2b89fe2e 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