From nobody Mon Jun 8 07:26:03 2026 Received: from m16.mail.163.com (m16.mail.163.com [220.197.31.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E654237AA74; Fri, 5 Jun 2026 02:05:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=220.197.31.3 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780625160; cv=none; b=JXMBBniy48h17IY6yNbrg1/UUqDTa+xc+2kKkdtFF+rPOKgXInjJEi5ONiROwI2q6ogo1kCKM6tBVVLh3yBWbcOv4TbBXwLK+q08k1XRskxZVgHMEOeg0rQscfoLSwi2W3GpWLRF8jpwq+bee+m0IhcZa1qJA23Bg+PPwfY0/7w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780625160; c=relaxed/simple; bh=hKtJBj6NbpM+g6kmjkW4KSom4gFoNvlMbMdPkKuqkbg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Fv8ZRuKdEr29LiU4ecZ0M5L0WRD+JljltnBoEzUssMGi0qRQP38qjEAKYXf8nz51EHAYXZx0V/Uj7SvQdLB9eaymZEtkCRTGsYVPBv9nsZPM/BBGeYFU8YMh6HiDFKlJ1vEgteBargag3qAOvpcRPB9nypxaHdExP7PUpNV/Z1U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b=T1CCDkZS; arc=none smtp.client-ip=220.197.31.3 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="T1CCDkZS" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=PQ iPGhl1R3XE1rfbgWoU/FE0wGrBbGWg/k63y7WgUeQ=; b=T1CCDkZS+/npucgaCG xUdlWIVEbPtWBrqvWdF4fSDqw0dMVEuRQoccHchWFJk2YJDKEU2ZYrVv/XF5p8HJ i69+i/aqOd5p/wohAVCc4dp9xylh3O2JjbYU+FqAYejm69dwUdwBk6u2L+zq7jGB IEM7vOrYQtNYEo682zJIhA+2k= Received: from ZM.localdomain (unknown []) by gzga-smtp-mtada-g1-0 (Coremail) with SMTP id _____wAXVW_FLiJq4ffOBQ--.62174S3; Fri, 05 Jun 2026 10:05:03 +0800 (CST) From: Ziming Zhu To: Guenter Roeck Cc: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jonathan Corbet , Shuah Khan , linux-hwmon@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Ziming Zhu Subject: [PATCH 1/3] dt-bindings: hwmon: pmbus: Add bindings for Silergy SQ24860 Date: Fri, 5 Jun 2026 10:04:48 +0800 Message-Id: <20260605020450.89638-2-zmzhu0630@163.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20260605020450.89638-1-zmzhu0630@163.com> References: <20260605020450.89638-1-zmzhu0630@163.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 X-CM-TRANSID: _____wAXVW_FLiJq4ffOBQ--.62174S3 X-Coremail-Antispam: 1Uf129KBjvJXoWxJr18KF18uF15Xr4kWFy3Arb_yoW8Kw1DpF Z5uF9rJr48XryxWw47GFykZ3W5Zr1kAa1j9r9xJw1SyF98XFsYvrZIkrW5XF1UCr10yFy3 ZFWqyryxt3s7Cr7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jbID7UUUUU= X-CM-SenderInfo: x2p2x3aqwtiqqrwthudrp/xtbC6A-h2moiLs8JFQAA3p Content-Type: text/plain; charset="utf-8" From: Ziming Zhu Add devicetree binding documentation for the Silergy SQ24860 eFuse. The device is a PMBus hardware monitoring device which reports voltage, current, power, and temperature telemetry. The board-specific IMON resistor value is described with silergy,rimon-micro-ohms. Signed-off-by: Ziming Zhu --- .../bindings/hwmon/pmbus/silergy,sq24860.yaml | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/pmbus/silergy,s= q24860.yaml diff --git a/Documentation/devicetree/bindings/hwmon/pmbus/silergy,sq24860.= yaml b/Documentation/devicetree/bindings/hwmon/pmbus/silergy,sq24860.yaml new file mode 100644 index 000000000000..03ef82c11e1a --- /dev/null +++ b/Documentation/devicetree/bindings/hwmon/pmbus/silergy,sq24860.yaml @@ -0,0 +1,74 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- + +$id: http://devicetree.org/schemas/hwmon/pmbus/silergy,sq24860.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Silergy SQ24860 eFuse + +maintainers: + - Ziming Zhu + +description: + The Silergy SQ24860 is an integrated, high-current circuit protection and + power management device with PMBus interface. + +properties: + compatible: + const: silergy,sq24860 + + reg: + maxItems: 1 + + silergy,rimon-micro-ohms: + description: + Micro-ohms value of the resistance installed between the IMON pin and + the ground reference. + + interrupts: + description: PMBus SMBAlert interrupt. + maxItems: 1 + + regulators: + type: object + description: + List of regulators provided by this controller. + + properties: + vout: + $ref: /schemas/regulator/regulator.yaml# + type: object + unevaluatedProperties: false + + additionalProperties: false + +required: + - compatible + - reg + - silergy,rimon-micro-ohms + +additionalProperties: false + +examples: + - | + + i2c { + #address-cells =3D <1>; + #size-cells =3D <0>; + + hw-monitor@40 { + compatible =3D "silergy,sq24860"; + reg =3D <0x40>; + + interrupt-parent =3D <&gpio>; + interrupts =3D <42 8>; + silergy,rimon-micro-ohms =3D <1600000000>; + + regulators { + cpu0_vout: vout { + regulator-name =3D "main_cpu0"; + }; + }; + }; + }; --=20 2.25.1 From nobody Mon Jun 8 07:26:03 2026 Received: from m16.mail.163.com (m16.mail.163.com [117.135.210.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AEAA8386557; Fri, 5 Jun 2026 02:05:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=117.135.210.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780625159; cv=none; b=W4xAx+CFOkWPClTgE7ygkZNyL22/vmw61GRimpLxTnN7AMLkCJpf8/9LxoBIQ72ZlCdkzJ9AGQFAvAVOdgLTrzsxQdv2zVUHXxPT/ygJpKLqQdPvpUbV5KB+3zfNa1oR1xVGHN0Ni7hYsNkKsZFcF72B2Co/k40QFIZ/gQY/pHs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780625159; c=relaxed/simple; bh=UM85B0rEdPJ2moYmUAGZByMDufgqE+ZcumoLLhkgjD4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=FISiepFeakOULPGLujS0m4ukHSLclrwUSqUt0CCG4GZOpdqM+UwJVlSraDTKed8zrnqz6wtW8XeXTcY7v8PRAUmbCSVRa1NLaqkDRHQhOOuGp3fGeoszRGahxXeqUlE6mvF3HqgS4PY7RzvR8zdlteifo8z85muORTxoHUCm0ho= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b=Ya64j6SL; arc=none smtp.client-ip=117.135.210.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="Ya64j6SL" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=V0 8e/2my9cw4LC+CmGVf7RUTqngf6xy+3fpI1QiQy+I=; b=Ya64j6SLhy/Blt5NJ4 v4hfZpol7HLpLZrrDa0f0aKOocUJoi09JyDlj/YwwLCAXDFhN/H1xaFGqbYRMVK+ dWGDyo7Xg249KRTYxZPTl/087+/xkyM8TFsveSODMy61B3+jMpr+Xm6PY46WAspB tSDPnCQ1l4vkVvb9JykEzDaok= Received: from ZM.localdomain (unknown []) by gzga-smtp-mtada-g1-0 (Coremail) with SMTP id _____wAXVW_FLiJq4ffOBQ--.62174S4; Fri, 05 Jun 2026 10:05:05 +0800 (CST) From: Ziming Zhu To: Guenter Roeck Cc: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jonathan Corbet , Shuah Khan , linux-hwmon@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Ziming Zhu Subject: [PATCH 2/3] hwmon: pmbus: Add support for Silergy SQ24860 Date: Fri, 5 Jun 2026 10:04:49 +0800 Message-Id: <20260605020450.89638-3-zmzhu0630@163.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20260605020450.89638-1-zmzhu0630@163.com> References: <20260605020450.89638-1-zmzhu0630@163.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 X-CM-TRANSID: _____wAXVW_FLiJq4ffOBQ--.62174S4 X-Coremail-Antispam: 1Uf129KBjvAXoW3uF15Ary7uFWktFW3Gr1rZwb_yoW8GFy5Wo ZxWFyIq3WkJr1UCrZY9F4I9FySqF4UXw1kAa13trsFgay3tF1Y9Fy3Aw4Yq3W7JF4rZw4D Zay8AFyFy39rtw15n29KB7ZKAUJUUUU8529EdanIXcx71UUUUU7v73VFW2AGmfu7bjvjm3 AaLaJ3UbIYCTnIWIevJa73UjIFyTuYvjxU7iiSDUUUU X-CM-SenderInfo: x2p2x3aqwtiqqrwthudrp/xtbCwBHi22oiLtHE0wAA3I Content-Type: text/plain; charset="utf-8" From: Ziming Zhu Add PMBus hwmon support for the Silergy SQ24860 eFuse. The driver reports input voltage, output voltage, auxiliary voltage, input current, input power, and temperature. It also exposes peak, average, and minimum history attributes, sample count configuration, and maps the manufacturer-specific VIREF register to the generic input over-current fault limit attribute. The IMON resistor value is read from the silergy,rimon-micro-ohms device property and used to configure the input current calibration gain. Signed-off-by: Ziming Zhu --- drivers/hwmon/pmbus/Kconfig | 19 ++ drivers/hwmon/pmbus/Makefile | 1 + drivers/hwmon/pmbus/sq24860.c | 423 ++++++++++++++++++++++++++++++++++ 3 files changed, 443 insertions(+) create mode 100644 drivers/hwmon/pmbus/sq24860.c diff --git a/drivers/hwmon/pmbus/Kconfig b/drivers/hwmon/pmbus/Kconfig index 8f4bff375ecb..a905b5af137c 100644 --- a/drivers/hwmon/pmbus/Kconfig +++ b/drivers/hwmon/pmbus/Kconfig @@ -612,6 +612,25 @@ config SENSORS_STEF48H28 This driver can also be built as a module. If so, the module will be called stef48h28. =20 +config SENSORS_SQ24860 + tristate "Silergy SQ24860" + help + If you say yes here you get hardware monitoring support for Silergy + SQ24860 eFuse. + + This driver can also be built as a module. If so, the module will + be called sq24860. + +config SENSORS_SQ24860_REGULATOR + bool "Regulator support for SQ24860" + depends on SENSORS_SQ24860 && REGULATOR + default SENSORS_SQ24860 + help + If you say yes here you get regulator support for Silergy SQ24860. + The regulator is registered through the PMBus regulator framework and + can be used to control the output exposed by the device. + This option is only useful if regulator framework support is needed. + config SENSORS_STPDDC60 tristate "ST STPDDC60" help diff --git a/drivers/hwmon/pmbus/Makefile b/drivers/hwmon/pmbus/Makefile index 7129b62bc00f..86bc93c6c091 100644 --- a/drivers/hwmon/pmbus/Makefile +++ b/drivers/hwmon/pmbus/Makefile @@ -60,6 +60,7 @@ obj-$(CONFIG_SENSORS_PM6764TR) +=3D pm6764tr.o obj-$(CONFIG_SENSORS_PXE1610) +=3D pxe1610.o obj-$(CONFIG_SENSORS_Q54SJ108A2) +=3D q54sj108a2.o obj-$(CONFIG_SENSORS_STEF48H28) +=3D stef48h28.o +obj-$(CONFIG_SENSORS_SQ24860) +=3D sq24860.o obj-$(CONFIG_SENSORS_STPDDC60) +=3D stpddc60.o obj-$(CONFIG_SENSORS_TDA38640) +=3D tda38640.o obj-$(CONFIG_SENSORS_TPS25990) +=3D tps25990.o diff --git a/drivers/hwmon/pmbus/sq24860.c b/drivers/hwmon/pmbus/sq24860.c new file mode 100644 index 000000000000..1c3b2bf2a026 --- /dev/null +++ b/drivers/hwmon/pmbus/sq24860.c @@ -0,0 +1,423 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// Copyright (c) 2024. +// Author: Ziming Zhu +#include +#include +#include +#include +#include +#include +#include +#include + +#include "pmbus.h" + +#define SQ24860_IIN_CAL_GAIN 0x38 +#define SQ24860_READ_VAUX 0xd0 +#define SQ24860_READ_VIN_MIN 0xd1 +#define SQ24860_READ_VIN_PEAK 0xd2 +#define SQ24860_READ_IIN_PEAK 0xd4 +#define SQ24860_READ_PIN_PEAK 0xd5 +#define SQ24860_READ_TEMP_AVG 0xd6 +#define SQ24860_READ_TEMP_PEAK 0xd7 +#define SQ24860_READ_VOUT_MIN 0xda +#define SQ24860_READ_VIN_AVG 0xdc +#define SQ24860_READ_VOUT_AVG 0xdd +#define SQ24860_READ_IIN_AVG 0xde +#define SQ24860_READ_PIN_AVG 0xdf +#define SQ24860_VIREF 0xe0 +#define SQ24860_PK_MIN_AVG 0xea +#define PK_MIN_AVG_RST_PEAK BIT(7) +#define PK_MIN_AVG_RST_AVG BIT(6) +#define PK_MIN_AVG_RST_MIN BIT(5) +#define PK_MIN_AVG_AVG_CNT GENMASK(2, 0) +#define SQ24860_MFR_WRITE_PROTECT 0xf8 +#define SQ24860_UNLOCKED BIT(7) + +#define SQ24860_8B_SHIFT 2 +#define SQ24860_IIN_OCF_NUM 1000000 +#define SQ24860_IIN_OCF_DIV 129278 +#define SQ24860_IIN_OCF_OFF 165 + +#define PK_MIN_AVG_RST_MASK (PK_MIN_AVG_RST_PEAK | \ + PK_MIN_AVG_RST_AVG | \ + PK_MIN_AVG_RST_MIN) + +/* + * Arbitrary default Rimon value: 1.6kOhm + */ +#define SQ24860_DEFAULT_RIMON 1600000000 +#define SQ24860_DEFAULT_GIMON 18180 + +#define SQ24860_VAUX_DIV 20 + +static int sq24860_write_iin_cal_gain(struct i2c_client *client, u32 rimon= , u32 gimon) +{ + u64 temp =3D (u64)6400 * 1000000000 * 1000; + u16 word =3D temp / ((u64)rimon * gimon); + int ret =3D i2c_smbus_write_word_data(client, SQ24860_IIN_CAL_GAIN, + word); + return ret; +} + +static int sq24860_mfr_write_protect_set(struct i2c_client *client, + u8 protect) +{ + u8 val; + + switch (protect) { + case 0: + val =3D 0xa2; + break; + case PB_WP_ALL: + val =3D 0x0; + break; + default: + return -EINVAL; + } + + return pmbus_write_byte_data(client, -1, SQ24860_MFR_WRITE_PROTECT, + val); +} + +static int sq24860_mfr_write_protect_get(struct i2c_client *client) +{ + int ret =3D pmbus_read_byte_data(client, -1, SQ24860_MFR_WRITE_PROTECT); + + if (ret < 0) + return ret; + + return (ret & SQ24860_UNLOCKED) ? 0 : PB_WP_ALL; +} + +static int sq24860_read_word_data(struct i2c_client *client, + int page, int phase, int reg) +{ + int ret; + + switch (reg) { + case PMBUS_VIRT_READ_VIN_MAX: + ret =3D pmbus_read_word_data(client, page, phase, + SQ24860_READ_VIN_PEAK); + break; + + case PMBUS_VIRT_READ_VIN_MIN: + ret =3D pmbus_read_word_data(client, page, phase, + SQ24860_READ_VIN_MIN); + break; + + case PMBUS_VIRT_READ_VIN_AVG: + ret =3D pmbus_read_word_data(client, page, phase, + SQ24860_READ_VIN_AVG); + break; + + case PMBUS_VIRT_READ_VOUT_MIN: + ret =3D pmbus_read_word_data(client, page, phase, + SQ24860_READ_VOUT_MIN); + break; + + case PMBUS_VIRT_READ_VOUT_AVG: + ret =3D pmbus_read_word_data(client, page, phase, + SQ24860_READ_VOUT_AVG); + break; + + case PMBUS_VIRT_READ_IIN_AVG: + ret =3D pmbus_read_word_data(client, page, phase, + SQ24860_READ_IIN_AVG); + break; + + case PMBUS_VIRT_READ_IIN_MAX: + ret =3D pmbus_read_word_data(client, page, phase, + SQ24860_READ_IIN_PEAK); + break; + + case PMBUS_VIRT_READ_TEMP_AVG: + ret =3D pmbus_read_word_data(client, page, phase, + SQ24860_READ_TEMP_AVG); + break; + + case PMBUS_VIRT_READ_TEMP_MAX: + ret =3D pmbus_read_word_data(client, page, phase, + SQ24860_READ_TEMP_PEAK); + break; + + case PMBUS_VIRT_READ_PIN_AVG: + ret =3D pmbus_read_word_data(client, page, phase, + SQ24860_READ_PIN_AVG); + break; + + case PMBUS_VIRT_READ_PIN_MAX: + ret =3D pmbus_read_word_data(client, page, phase, + SQ24860_READ_PIN_PEAK); + break; + + case PMBUS_VIRT_READ_VMON: + ret =3D pmbus_read_word_data(client, page, phase, + SQ24860_READ_VAUX); + if (ret < 0) + break; + ret =3D DIV_ROUND_CLOSEST(ret, SQ24860_VAUX_DIV); + break; + + case PMBUS_VIN_UV_WARN_LIMIT: + case PMBUS_VIN_UV_FAULT_LIMIT: + case PMBUS_VIN_OV_WARN_LIMIT: + case PMBUS_VIN_OV_FAULT_LIMIT: + case PMBUS_VOUT_UV_WARN_LIMIT: + case PMBUS_IIN_OC_WARN_LIMIT: + case PMBUS_OT_WARN_LIMIT: + case PMBUS_OT_FAULT_LIMIT: + case PMBUS_PIN_OP_WARN_LIMIT: + /* + * These registers provide an 8 bits value instead of a + * 10bits one. Just shifting twice the register value is + * enough to make the sensor type conversion work, even + * if the datasheet provides different m, b and R for + * those. + */ + ret =3D pmbus_read_word_data(client, page, phase, reg); + if (ret < 0) + break; + ret <<=3D SQ24860_8B_SHIFT; + break; + + case PMBUS_IIN_OC_FAULT_LIMIT: + /* + * VIREF directly sets the over-current limit at which the eFuse + * will turn the FET off and trigger a fault. Expose it through + * this generic property instead of a manufacturer specific one. + */ + ret =3D pmbus_read_byte_data(client, page, SQ24860_VIREF); + if (ret < 0) + break; + ret =3D DIV_ROUND_CLOSEST(ret * SQ24860_IIN_OCF_NUM, + SQ24860_IIN_OCF_DIV); + ret +=3D SQ24860_IIN_OCF_OFF; + break; + + case PMBUS_VIRT_SAMPLES: + ret =3D pmbus_read_byte_data(client, page, SQ24860_PK_MIN_AVG); + if (ret < 0) + break; + ret =3D 1 << FIELD_GET(PK_MIN_AVG_AVG_CNT, ret); + break; + + case PMBUS_VIRT_RESET_TEMP_HISTORY: + case PMBUS_VIRT_RESET_VIN_HISTORY: + case PMBUS_VIRT_RESET_IIN_HISTORY: + case PMBUS_VIRT_RESET_PIN_HISTORY: + case PMBUS_VIRT_RESET_VOUT_HISTORY: + ret =3D 0; + break; + + default: + ret =3D -ENODATA; + break; + } + + return ret; +} + +static int sq24860_write_word_data(struct i2c_client *client, + int page, int reg, u16 value) +{ + int ret; + + switch (reg) { + case PMBUS_VIN_UV_WARN_LIMIT: + case PMBUS_VIN_UV_FAULT_LIMIT: + case PMBUS_VIN_OV_WARN_LIMIT: + case PMBUS_VIN_OV_FAULT_LIMIT: + case PMBUS_VOUT_UV_WARN_LIMIT: + case PMBUS_IIN_OC_WARN_LIMIT: + case PMBUS_OT_WARN_LIMIT: + case PMBUS_OT_FAULT_LIMIT: + case PMBUS_PIN_OP_WARN_LIMIT: + value >>=3D SQ24860_8B_SHIFT; + value =3D clamp_val(value, 0, 0xff); + ret =3D pmbus_write_word_data(client, page, reg, value); + break; + + case PMBUS_IIN_OC_FAULT_LIMIT: + value -=3D SQ24860_IIN_OCF_OFF; + value =3D DIV_ROUND_CLOSEST(((unsigned int)value) * SQ24860_IIN_OCF_DIV, + SQ24860_IIN_OCF_NUM); + value =3D clamp_val(value, 0, 0x3f); + ret =3D pmbus_write_byte_data(client, page, SQ24860_VIREF, value); + break; + + case PMBUS_VIRT_SAMPLES: + value =3D clamp_val(value, 1, 1 << PK_MIN_AVG_AVG_CNT); + value =3D ilog2(value); + ret =3D pmbus_update_byte_data(client, page, SQ24860_PK_MIN_AVG, + PK_MIN_AVG_AVG_CNT, + FIELD_PREP(PK_MIN_AVG_AVG_CNT, value)); + break; + + case PMBUS_VIRT_RESET_TEMP_HISTORY: + case PMBUS_VIRT_RESET_VIN_HISTORY: + case PMBUS_VIRT_RESET_IIN_HISTORY: + case PMBUS_VIRT_RESET_PIN_HISTORY: + case PMBUS_VIRT_RESET_VOUT_HISTORY: + /* + * SQ24860 has history resets based on MIN/AVG/PEAK instead of per + * sensor type. Exposing this quirk in hwmon is not desirable so + * reset MIN, AVG and PEAK together. Even is there effectively only + * one reset, which resets everything, expose the 5 entries so + * userspace is not required map a sensor type to another to trigger + * a reset + */ + ret =3D pmbus_update_byte_data(client, 0, SQ24860_PK_MIN_AVG, + PK_MIN_AVG_RST_MASK, + PK_MIN_AVG_RST_MASK); + break; + + default: + ret =3D -ENODATA; + break; + } + + return ret; +} + +static int sq24860_read_byte_data(struct i2c_client *client, + int page, int reg) +{ + int ret; + + switch (reg) { + case PMBUS_WRITE_PROTECT: + ret =3D sq24860_mfr_write_protect_get(client); + break; + + default: + ret =3D -ENODATA; + break; + } + + return ret; +} + +static int sq24860_write_byte_data(struct i2c_client *client, + int page, int reg, u8 byte) +{ + int ret; + + switch (reg) { + case PMBUS_WRITE_PROTECT: + ret =3D sq24860_mfr_write_protect_set(client, byte); + break; + + default: + ret =3D -ENODATA; + break; + } + + return ret; +} + +#if IS_ENABLED(CONFIG_SENSORS_SQ24860_REGULATOR) +static const struct regulator_desc sq24860_reg_desc[] =3D { + PMBUS_REGULATOR_ONE_NODE("vout"), +}; +#endif + +static const struct pmbus_driver_info sq24860_base_info =3D { + .pages =3D 1, + .format[PSC_VOLTAGE_IN] =3D direct, + .m[PSC_VOLTAGE_IN] =3D 64, + .b[PSC_VOLTAGE_IN] =3D 0, + .R[PSC_VOLTAGE_IN] =3D 0, + .format[PSC_VOLTAGE_OUT] =3D direct, + .m[PSC_VOLTAGE_OUT] =3D 64, + .b[PSC_VOLTAGE_OUT] =3D 0, + .R[PSC_VOLTAGE_OUT] =3D 0, + .format[PSC_TEMPERATURE] =3D direct, + .m[PSC_TEMPERATURE] =3D 1, + .b[PSC_TEMPERATURE] =3D 0, + .R[PSC_TEMPERATURE] =3D 0, + /* + * 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 16, + .b[PSC_CURRENT_IN] =3D 0, + .R[PSC_CURRENT_IN] =3D 0, + .format[PSC_POWER] =3D direct, + .m[PSC_POWER] =3D 2, + .b[PSC_POWER] =3D 0, + .R[PSC_POWER] =3D 0, + .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 sq24860_read_word_data, + .write_word_data =3D sq24860_write_word_data, + .read_byte_data =3D sq24860_read_byte_data, + .write_byte_data =3D sq24860_write_byte_data, + +#if IS_ENABLED(CONFIG_SENSORS_SQ24860_REGULATOR) + .reg_desc =3D sq24860_reg_desc, + .num_regulators =3D ARRAY_SIZE(sq24860_reg_desc), +#endif +}; + +static const struct i2c_device_id sq24860_i2c_id[] =3D { + { "sq24860" }, + {} +}; +MODULE_DEVICE_TABLE(i2c, sq24860_i2c_id); + +static const struct of_device_id sq24860_of_match[] =3D { + { .compatible =3D "silergy,sq24860" }, + {} +}; +MODULE_DEVICE_TABLE(of, sq24860_of_match); + +static int sq24860_probe(struct i2c_client *client) +{ + struct device *dev =3D &client->dev; + struct pmbus_driver_info *info; + u32 rimon =3D SQ24860_DEFAULT_RIMON; + u32 gimon =3D SQ24860_DEFAULT_GIMON; + int ret; + + ret =3D device_property_read_u32(dev, "silergy,rimon-micro-ohms", &rimon); + if (ret < 0 && ret !=3D -EINVAL) + return dev_err_probe(dev, ret, "failed to get rimon\n"); + + ret =3D sq24860_write_iin_cal_gain(client, rimon, gimon); + if (ret < 0) + return dev_err_probe(&client->dev, ret, + "Failed to set gain\n"); + info =3D devm_kmemdup(dev, &sq24860_base_info, sizeof(*info), GFP_KERNEL); + if (!info) + return -ENOMEM; + + return pmbus_do_probe(client, info); +} + +static struct i2c_driver sq24860_driver =3D { + .driver =3D { + .name =3D "sq24860", + .of_match_table =3D sq24860_of_match, + }, + .probe =3D sq24860_probe, + .id_table =3D sq24860_i2c_id, +}; +module_i2c_driver(sq24860_driver); + +MODULE_AUTHOR("Ziming Zhu "); +MODULE_DESCRIPTION("PMBUS driver for SQ24860 eFuse"); +MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS("PMBUS"); --=20 2.25.1 From nobody Mon Jun 8 07:26:03 2026 Received: from m16.mail.163.com (m16.mail.163.com [117.135.210.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7D97B3932EE; Fri, 5 Jun 2026 02:05:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=117.135.210.2 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780625155; cv=none; b=mrlTgIWGe3izuK+FeK/rzaywvkJ7G6lFLPqC+ks9ZPSduI+HsnuWSGlQrRnJHcKSULVGtwveuPdbYrvPxUnJaHajvUv/lEK1B05ZNGmGsPqK+twU7shI72u7JN7vH9jTqDCKJStHRCX7tRo0opA570SOuUycS56TX+X0zV9hTLI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780625155; c=relaxed/simple; bh=ncAsXFcYB9+tI8BWusAz1SdAtp4v42J/790HGF41wik=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=pH2ektN4josYh/Nz1VVHjg0JbgqVaRS8W1HGZLot26VO5doKjA5rMaPLvsO2w9hWOs377YYUulKko5yvemPpsNRoEpHO3F+9BZbPhlhOEXf0WOI/uLA5Z6q57cq3JkTICNVvAcXXNNmWYWrX67Dc7IUFV/GwpWAmYlImpY4S0Bk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b=GjMWQdsM; arc=none smtp.client-ip=117.135.210.2 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="GjMWQdsM" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=X9 /TiF/Qz6KbmWNEuOOERR0ARs9jh9FBZxL+cbHl9U4=; b=GjMWQdsMwjMg1Rm+82 +BvRxCskvX+IzNA24SYHKbQh8x1uB7PicsgjynBkGfW7qhludKKHQRk00WGUHeHa XSm+rLzwJTJeakFAlon4nslWSsFRi+T6jTb1+OJ3aCHxNVs1HTpqGsGdenuJl67d npJMObgiOveiNkzhUfn3aPXD8= Received: from ZM.localdomain (unknown []) by gzga-smtp-mtada-g1-0 (Coremail) with SMTP id _____wAXVW_FLiJq4ffOBQ--.62174S5; Fri, 05 Jun 2026 10:05:06 +0800 (CST) From: Ziming Zhu To: Guenter Roeck Cc: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jonathan Corbet , Shuah Khan , linux-hwmon@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Ziming Zhu Subject: [PATCH 3/3] hwmon: Add documentation for SQ24860 Date: Fri, 5 Jun 2026 10:04:50 +0800 Message-Id: <20260605020450.89638-4-zmzhu0630@163.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20260605020450.89638-1-zmzhu0630@163.com> References: <20260605020450.89638-1-zmzhu0630@163.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 X-CM-TRANSID: _____wAXVW_FLiJq4ffOBQ--.62174S5 X-Coremail-Antispam: 1Uf129KBjvJXoWxJF1DXry3Kw47urW5KFW8Crg_yoWruw4UpF 93GrySkw1UXrW7WFW3tw18Zr45Gay8Ar43AF1kJryrZFn8Ar1vkrnrKF13Ja4DKrn5AFWr KF4UtrWUJw4jkFJanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07Ud9N-UUUUU= X-CM-SenderInfo: x2p2x3aqwtiqqrwthudrp/xtbC6BLi22oiLtIJbwAA3R Content-Type: text/plain; charset="utf-8" From: Ziming Zhu Document the supported sysfs attributes for the Silergy SQ24860 PMBus hwmon driver. Signed-off-by: Ziming Zhu Tested-by: Randy Dunlap --- Documentation/hwmon/index.rst | 1 + Documentation/hwmon/sq24860.rst | 96 +++++++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+) create mode 100644 Documentation/hwmon/sq24860.rst diff --git a/Documentation/hwmon/index.rst b/Documentation/hwmon/index.rst index 8b655e5d6b68..1888905cd234 100644 --- a/Documentation/hwmon/index.rst +++ b/Documentation/hwmon/index.rst @@ -242,6 +242,7 @@ Hardware Monitoring Kernel Drivers smsc47m192 smsc47m1 sparx5-temp + sq24860 spd5118 stpddc60 surface_fan diff --git a/Documentation/hwmon/sq24860.rst b/Documentation/hwmon/sq24860.= rst new file mode 100644 index 000000000000..7029f612e1b9 --- /dev/null +++ b/Documentation/hwmon/sq24860.rst @@ -0,0 +1,96 @@ +.. SPDX-License-Identifier: GPL-2.0 + +Kernel driver sq24860 +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +Supported chips: + + * Silergy SQ24860 + + Prefix: 'sq24860' + +Author: + + Ziming Zhu + +Description +------------ + +This driver implements support for the Silergy SQ24860 eFuse. The device i= s an +integrated circuit protection and power management device with a PMBus +interface. + +The device supports direct format for reading input voltage, output voltag= e, +auxiliary voltage, input current, input power, and temperature. + +The current and power measurement scale depends on the resistor connected +between the IMON pin and ground. The resistor value can be configured with= the +``sy,rimon-micro-ohms`` device tree property. See +``Documentation/devicetree/bindings/hwmon/pmbus/silergy,sq24860.yaml`` for= details. + +Due to the specificities of the chip, all history reset attributes are tied +together. Resetting the history of one sensor resets the history of all se= nsors. + +Sysfs entries +------------- + +The following attributes are supported. Limits are read-write; all other +attributes are read-only. + +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D +in1_label "vin" +in1_input Measured input voltage. +in1_average Average measured input voltage. +in1_min Minimum input voltage limit. +in1_lcrit Critical low input voltage limit. +in1_max Maximum input voltage limit. +in1_crit Critical high input voltage limit. +in1_min_alarm Input voltage low warning alarm. +in1_lcrit_alarm Input voltage low fault alarm. +in1_max_alarm Input voltage high warning alarm. +in1_crit_alarm Input voltage high fault alarm. +in1_highest Historical maximum input voltage. +in1_lowest Historical minimum input voltage. +in1_reset_history Write any value to reset history. + +in2_label "vmon" +in2_input Measured auxiliary input voltage. + +in3_label "vout1" +in3_input Measured output voltage. +in3_average Average measured output voltage. +in3_min Minimum output voltage limit. +in3_min_alarm Output voltage low alarm. +in3_lowest Historical minimum output voltage. +in3_reset_history Write any value to reset history. + +curr1_label "iin" +curr1_input Measured input current. +curr1_average Average measured input current. +curr1_max Maximum input current warning limit. +curr1_crit Critical input over-current fault limit. +curr1_max_alarm Input current warning alarm. +curr1_crit_alarm Input over-current fault alarm. +curr1_highest Historical maximum input current. +curr1_reset_history Write any value to reset history. + +power1_label "pin" +power1_input Measured input power. +power1_average Average measured input power. +power1_max Maximum input power warning limit. +power1_alarm Input power warning alarm. +power1_input_highest Historical maximum input power. +power1_reset_history Write any value to reset history. + +temp1_input Measured temperature. +temp1_average Average measured temperature. +temp1_max Maximum temperature warning limit. +temp1_crit Critical temperature fault limit. +temp1_max_alarm Temperature warning alarm. +temp1_crit_alarm Temperature fault alarm. +temp1_highest Historical maximum temperature. +temp1_reset_history Write any value to reset history. + +samples Number of samples used for average values. +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D + --=20 2.25.1