From nobody Mon Jun 8 06:38:20 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 59FF9407592; Fri, 5 Jun 2026 06:31:53 +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=1780641117; cv=none; b=kbkJCKWRTDfyhrA+iRz6nv1cqnGmRP97pBJZwc0/uTvq98UaBeg8FIZ2a64TEXJCj3VaWr9KyGIgVWH0Y/PKzC/ZfR6214gd11qWnQwOsWQvgxRR0lDNGvXkTSuDB7uHwuOS2aQSv6UY8sHSJontu+UD00PzyVubsdvq9Bxy9BY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780641117; c=relaxed/simple; bh=hKtJBj6NbpM+g6kmjkW4KSom4gFoNvlMbMdPkKuqkbg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=dn3rW1/+jUdYnFcwieJs8ctlWZhjBv6Zj6O+/znG6w2Nn58DRyq1Vbd26nW+FS/8DlpOfCLw4cBHjcblzhl6XGwci4VSoC+Rz6/W4mqmagtCtVX1ZHkdXOBee8mg+eY+sKRJKeiglVd5ZVKdZ4oMHe7EI5skLpZ/x1luFyA13qk= 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=g2U8A9g2; 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="g2U8A9g2" 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=g2U8A9g2S2tEs91pqU RYd9y9qFCXAkJktT5ZkS+iQArE6fTTJmyxvOXxnV1HKugnkUuW3qlWMboeL2QmoM zwjI83at4KiDakmDUtQIEHTUU0ScXoSMrNFKw5Clf+hjz9GaH3hJ6TLRfXkHsTiW he0wUCOF/Io+eGTzID9o+JgGM= Received: from ZM.localdomain (unknown []) by gzga-smtp-mtada-g0-0 (Coremail) with SMTP id _____wDnl3AjbSJqJU+5BQ--.9698S3; Fri, 05 Jun 2026 14:31: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 v2 1/3] dt-bindings: hwmon: pmbus: Add bindings for Silergy SQ24860 Date: Fri, 5 Jun 2026 14:30:40 +0800 Message-Id: <20260605063042.91776-2-zmzhu0630@163.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20260605063042.91776-1-zmzhu0630@163.com> References: <20260605063042.91776-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: _____wDnl3AjbSJqJU+5BQ--.9698S3 X-Coremail-Antispam: 1Uf129KBjvJXoWxJr18KF18uF15Xr4kWFy3Arb_yoW8Kw1DpF Z5uF9rJr48XryxWw47GFykZ3W5Zr1kAa1j9r9xJw1SyF98XFsYvrZIkrW5XF1UCr10yFy3 ZFWqyryxt3s7Cr7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07je-erUUUUU= X-CM-SenderInfo: x2p2x3aqwtiqqrwthudrp/xtbCwAyJgmoibSzT1wAA3K 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 Reviewed-by: Conor Dooley --- .../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 06:38:20 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 C104D3BE17F; Fri, 5 Jun 2026 06:31:49 +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=1780641113; cv=none; b=PPQD9ANJ/QM9l/VgPB2g6UN9AcDwgzaoTa1KH/i9QeuicXk6UgKjFt0YQCoKQ/GUw4v3PSGV8KD6EFt2jApyVOx8UJiVh/HpxcH39nFefiml+rmLLDuSeHSHatRzJNMJttA0SmTikUVeUfIHCTws8WVVCc0/G1LWQPFZRcEm22A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780641113; c=relaxed/simple; bh=ZkaKSj1sIBBmrPxL5MhUzMnTGuEwm/aZUPBZgt/sn+M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kqN764sHsQFlivPObWqxdDIAj2BKoXAg3LK6l4ULrFn7AiLZHJk/nE7HYP/tHG8AVBRY3KD5WvuNNX8exEPB2sT5/G6JlPgzCzmFD4ApTHmfL+T0CtUN3vwQcegTYsr1zd00DJpbjht6mksWaP4udL4pjJq6FwXE7emVpfNNhiU= 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=g6SRAOrl; 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="g6SRAOrl" 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=b6 bD5JGmZAuaAqoyerXrIWZg13tUwHx6xRH5sbjBwA0=; b=g6SRAOrlTeKdeltJnW IDWd891bQ1EaOu67nnVwqbA6CcevDwaFdUe/OzBVLoiY5P5k7QDrTYjyx2mpi0o6 VU4PBdCmW3Jr+OQ80nlBnA46j4wgqM550J3wlW+E0o1eY1SXhamFXScIK38+q4B/ fX6sHwyBW0PZPR9nWPFj5iU0A= Received: from ZM.localdomain (unknown []) by gzga-smtp-mtada-g0-0 (Coremail) with SMTP id _____wDnl3AjbSJqJU+5BQ--.9698S4; Fri, 05 Jun 2026 14:31:10 +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 v2 2/3] hwmon: pmbus: Add support for Silergy SQ24860 Date: Fri, 5 Jun 2026 14:30:41 +0800 Message-Id: <20260605063042.91776-3-zmzhu0630@163.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20260605063042.91776-1-zmzhu0630@163.com> References: <20260605063042.91776-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: _____wDnl3AjbSJqJU+5BQ--.9698S4 X-Coremail-Antispam: 1Uf129KBjvAXoW3uF15Ary7uFWktFW3Gr1rZwb_yoW8GFW3Go ZxWFyIq3WDJr1UCrZY9r4I9FySqF4UXw1kAa13trsFgay3tF1Y9Fy3Aw4Yq3W7JF4rZw4D Zay0yFyFy39rtw15n29KB7ZKAUJUUUU8529EdanIXcx71UUUUU7v73VFW2AGmfu7bjvjm3 AaLaJ3UbIYCTnIWIevJa73UjIFyTuYvjxUc75rDUUUU X-CM-SenderInfo: x2p2x3aqwtiqqrwthudrp/xtbCwA6JgmoibS7T-wAA3i 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 | 432 ++++++++++++++++++++++++++++++++++ 3 files changed, 452 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..43a2cb542169 --- /dev/null +++ b/drivers/hwmon/pmbus/sq24860.c @@ -0,0 +1,432 @@ +// 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) +#define SQ24860_MAX_SAMPLES BIT(FIELD_MAX(PK_MIN_AVG_AVG_CNT)) +/* + * 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; + u64 denom; + u64 word; + + if (!rimon || !gimon) + return -EINVAL; + + denom =3D (u64)rimon * gimon; + word =3D div_u64(temp, denom); + if (word > U16_MAX) + return -ERANGE; + + return i2c_smbus_write_word_data(client, SQ24860_IIN_CAL_GAIN, + (u16)word); +} + +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 BIT(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, SQ24860_MAX_SAMPLES); + 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 measurements depend on the calibration gain + * programmed from the board-specific IMON resistor value. + */ + .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 06:38:20 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 59F5C40758F; Fri, 5 Jun 2026 06:31:53 +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=1780641116; cv=none; b=jA900WpbYBTy8O63xc8Scktf0FQIc3fmAnoNCjne57wZAPJ1ue1BtrmBltx9merTuJAyOZs7zhdK8WaMypQtM4nlMpcKW42yujV+CDzCpEaMaNqdbDXQr874VHkj/UstfhDscIjT2MgrhozjMcxqzDajEOJdx1AWhqQ3nG8cDfQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780641116; c=relaxed/simple; bh=wfZixIpM8oc/drRUVburnx4hJviXARDaeGZECaDZ1Wg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kaxiLNdp5w6hfKC70/3A3FrPNex7Sn5tGQroCMvfuibgjrzXFhJvls2a+38l5rNazxXjgoEXaJbYyvchA0/NSA3rbNHp07nbXplYGB4uXhU45519BJjjaOn+iLJsBwmL++pIFJkiEi0ZdJJ7/E8gs1FISHQDbCCZSf5XhsbvsLY= 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=WT7HMdhl; 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="WT7HMdhl" 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=Z8 Nptqq4wNOfaE1HQs8SON1B5R40ZYajOMIfxodq8oE=; b=WT7HMdhlLmkQJCGlf5 CdapN8i2810AkwUAdFkrJ+5QJUd6qiVB8Je+AeLNRn4jMc7VizHoVkKRl1YxKimj nLSpLmSqe+CkX1t4HVyvbWX/6kfQPsTmmXEmt2OnjEkEoYafc9SXuXmEF1x6do6C FyCEkIbnqqzFDgn4NRVMSsHEg= Received: from ZM.localdomain (unknown []) by gzga-smtp-mtada-g0-0 (Coremail) with SMTP id _____wDnl3AjbSJqJU+5BQ--.9698S5; Fri, 05 Jun 2026 14:31:11 +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 v2 3/3] hwmon: Add documentation for SQ24860 Date: Fri, 5 Jun 2026 14:30:42 +0800 Message-Id: <20260605063042.91776-4-zmzhu0630@163.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20260605063042.91776-1-zmzhu0630@163.com> References: <20260605063042.91776-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: _____wDnl3AjbSJqJU+5BQ--.9698S5 X-Coremail-Antispam: 1Uf129KBjvJXoWxJF1DXry3Kw47urW5KFW8Crg_yoWruw4xpF 93GrySkw1UXrW7WFW3tw18Zr45Gay8Ar43AF1kJryrZFn8Ar1vkrnrKr13Ja4DKrn5AFWr KF4UtrWUJw4jkFJanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07UZAwsUUUUU= X-CM-SenderInfo: x2p2x3aqwtiqqrwthudrp/xtbCwBCKg2oibTDULAAA30 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 --- 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..f0182b955d8a --- /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 +``silergy,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