From nobody Tue Dec 16 23:10:20 2025 Received: from m16.mail.163.com (m16.mail.163.com [117.135.210.5]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3E53E28B404; Tue, 6 May 2025 05:39:01 +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=1746509945; cv=none; b=kjJY9w76bGDXJlavl5jeb5+YmgL4nzzPeyXbzSpMLbix7WgdjvEvbF6nYdveG46jrmbgQ5uB6v1s5oK0Kwb+ozvWFzivq5hZ21NI999MZYxZ7PxUyZyqQ4BMOFHD9I4qXL+Fo5KSu649Fsa8bRVqSaiP9A8b81yjsQLI30GTu/w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746509945; c=relaxed/simple; bh=VqaefWIeeAWB8AF8A6vwJaER/pKdcIdNGd5Xi4YlzC0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=E7ZYWpJS9TEyHyUJ+Op84zUu7j7OEGtVpa/EKb8ZrwYHGtY/dCa5ynTqomVp/g+1i3d/ArFqcC2xlI9ukb5WX/ly/AORnE+pQoYvxTD16JJUUJT+1RMMcBE84w0cboQeLMrq4q04IMILAsQ+uT5bbUzSrYwqQKMN51u6CJVzFp4= 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=iQdv+nBk; 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="iQdv+nBk" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=AqqRBuCmSkqKBix9v4 uiNk3uih1aJj44EwU4vrNzXFQ=; b=iQdv+nBkRg2YU97jYPbe0Xnf+m+Wjnp2ul qOwqs8EkspQG20LI7GW3eXLI4e+xUgrbzW2SO2ktVcxRkxfnsAkJY0ELi4dYEOTE ASHBZSUrYvWCIZAdtDkDp3+KCzQhiICGKcaQcxnAtzUoDSQCq/7nQBws2kto9ErX g7dVho2M8= Received: from localhost.localdomain (unknown []) by gzga-smtp-mtada-g1-3 (Coremail) with SMTP id _____wBHxSpEoBloZ2M1Ew--.50689S3; Tue, 06 May 2025 13:38:18 +0800 (CST) From: Wenliang Yan To: linux@roeck-us.net, Christophe JAILLET , Jean Delvare Cc: Wenliang Yan , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jonathan Corbet , linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, derek.lin@silergycorp.com, miguel.lee@silergycorp.com, chris.ho@silergycorp.com, eason.liao@silergycorp.com Subject: [PATCH v7 1/4] hwmon:(ina238)Add ina238_config to save configurations for different chips Date: Tue, 6 May 2025 01:37:38 -0400 Message-Id: <20250506053741.4837-2-wenliang202407@163.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20250506053741.4837-1-wenliang202407@163.com> References: <20250506053741.4837-1-wenliang202407@163.com> X-CM-TRANSID: _____wBHxSpEoBloZ2M1Ew--.50689S3 X-Coremail-Antispam: 1Uf129KBjvJXoWxXw1kWr4rWr1fuw48WF15Jwb_yoWrCrWrpF Z3Ga45JrWUXF4aga9xta97uFn8Kwn7Jr17Kr47Ww1S9F1kWry0kFZrKF1UAFsrKr95XF4I yry8tryrCwnFv3DanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0pEk9NDUUUUU= X-CM-SenderInfo: xzhqzxhdqjjiisuqlqqrwthudrp/1tbibgFF02gZnfc1tgABsg Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add structure ina238_config to store proprietary properties for different chips to meet different chip adaptations Signed-off-by: Wenliang Yan --- v6->v7:Maintain the previous changes v5->v6:Split the patch, this patch add a structure with the following conte= nts:=20 1. 'has_power_highest' is used to determine whether peak power can be detected (New features for SQ52206) 2. 'has_energy' is used to determine non-energy detection energy consumption (new feature for SQ52206) 3. 'temp_shift' is used to distinguish the data bits of the temperature register 4. 'power_calculate_factor' is used to calculate power 5. 'config_default' is used to save the initial configuration 6. 'bus_voltage_lsb' is used to save the least significant bit corresponding to bus voltage 7. 'temp_lsb' is used tosave the least significant bit corresponding to temperature Configure the architecture content for ina237 and ina238 respectively to lay the foundation for subsequent adaptation to new chips. drivers/hwmon/ina238.c | 57 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 52 insertions(+), 5 deletions(-) diff --git a/drivers/hwmon/ina238.c b/drivers/hwmon/ina238.c index 2d9f12f68d50..c8d6bd3041b3 100644 --- a/drivers/hwmon/ina238.c +++ b/drivers/hwmon/ina238.c @@ -102,7 +102,20 @@ static const struct regmap_config ina238_regmap_config= =3D { .val_bits =3D 16, }; =20 +enum ina238_ids { ina238, ina237 }; + +struct ina238_config { + bool has_power_highest; /* chip detection power peak */ + bool has_energy; /* chip detection energy */ + u8 temp_shift; /* fixed parameters for temp calculate */ + u32 power_calculate_factor; /* fixed parameters for power calculate */ + u16 config_default; /* Power-on default state */ + int bus_voltage_lsb; /* use for temperature calculate, uV/lsb */ + int temp_lsb; /* use for temperature calculate */ +}; + struct ina238_data { + const struct ina238_config *config; struct i2c_client *client; struct mutex config_lock; struct regmap *regmap; @@ -110,6 +123,27 @@ struct ina238_data { int gain; }; =20 +static const struct ina238_config ina238_config[] =3D { + [ina238] =3D { + .has_energy =3D false, + .has_power_highest =3D false, + .temp_shift =3D 4, + .power_calculate_factor =3D 20, + .config_default =3D INA238_CONFIG_DEFAULT, + .bus_voltage_lsb =3D INA238_BUS_VOLTAGE_LSB, + .temp_lsb =3D INA238_DIE_TEMP_LSB, + }, + [ina237] =3D { + .has_energy =3D false, + .has_power_highest =3D false, + .temp_shift =3D 4, + .power_calculate_factor =3D 20, + .config_default =3D INA238_CONFIG_DEFAULT, + .bus_voltage_lsb =3D INA238_BUS_VOLTAGE_LSB, + .temp_lsb =3D INA238_DIE_TEMP_LSB, + }, +}; + static int ina238_read_reg24(const struct i2c_client *client, u8 reg, u32 = *val) { u8 data[3]; @@ -536,14 +570,20 @@ static int ina238_probe(struct i2c_client *client) struct device *dev =3D &client->dev; struct device *hwmon_dev; struct ina238_data *data; + enum ina238_ids chip; int config; int ret; =20 + chip =3D (uintptr_t)i2c_get_match_data(client); + data =3D devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); if (!data) return -ENOMEM; =20 data->client =3D client; + /* set the device type */ + data->config =3D &ina238_config[chip]; + mutex_init(&data->config_lock); =20 data->regmap =3D devm_regmap_init_i2c(client, &ina238_regmap_config); @@ -570,7 +610,7 @@ static int ina238_probe(struct i2c_client *client) } =20 /* Setup CONFIG register */ - config =3D INA238_CONFIG_DEFAULT; + config =3D data->config->config_default; if (data->gain =3D=3D 1) config |=3D INA238_CONFIG_ADCRANGE; /* ADCRANGE =3D 1 is /1 */ ret =3D regmap_write(data->regmap, INA238_CONFIG, config); @@ -616,15 +656,22 @@ static int ina238_probe(struct i2c_client *client) } =20 static const struct i2c_device_id ina238_id[] =3D { - { "ina238" }, + { "ina237", ina237 }, + { "ina238", ina238 }, { } }; MODULE_DEVICE_TABLE(i2c, ina238_id); =20 static const struct of_device_id __maybe_unused ina238_of_match[] =3D { - { .compatible =3D "ti,ina237" }, - { .compatible =3D "ti,ina238" }, - { }, + { + .compatible =3D "ti,ina237", + .data =3D (void *)ina237 + }, + { + .compatible =3D "ti,ina238", + .data =3D (void *)ina238 + }, + { } }; MODULE_DEVICE_TABLE(of, ina238_of_match); =20 --=20 2.17.1 From nobody Tue Dec 16 23:10:20 2025 Received: from m16.mail.163.com (m16.mail.163.com [220.197.31.5]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D28DE27F17E; Tue, 6 May 2025 05:39:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=220.197.31.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746509966; cv=none; b=I66Ur9MwwI0HBQD738QP9RchnG5gi4o7ZGnqDnDoye12x+yEihf5fCBoDWTKvrAKFbzx2vp4BG2UUvxAM4UtvB/lqKpaBzFRifjjFmfKHVXHM4SmvRjAotuflrKnttVNOdkE4Nb5RJnklQVY+REGKnY0nxYuC+0lkNGeBiuQYYM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746509966; c=relaxed/simple; bh=Iu853oJ10IKHTPyf/QniE0pyPeiYOUpdPsBizc/ICww=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=TtpoP0GD2rX6xOWwBr6rVyayjE1YCrU7HpjZRZDw3owNltDnYjvMcEcYwCFLL3Q7MPvmYnoj+ENRYi6KKTcEozuS3JBIJAq0BE1UwYTHPJWL8xNT95HNxmyIvpa5BEE/UBlGT3mbAUgf3rs6tGdR/Y1fqiM3vMiQXbaC/dVaa3M= 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=bNAWBAUQ; arc=none smtp.client-ip=220.197.31.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="bNAWBAUQ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=KdfptK1YCbegOuFP5s 5wFBBAXhpnHZfvK0674BR0rAQ=; b=bNAWBAUQbo3bTN8gSE9Mq0k+T69+6G+6ba fTJ5IHiL6FdiYnBEpJDVNvD+n7fK0Im4VvowCiX6zwNS1AcadKtkTXnQsZQn1TpK D7VIflydaWq+O05H8UvCXNxVtLuQACtdzmM9QjAVA9sccLFbmm8nM+QvEyFYnukr XXL6FazR4= Received: from localhost.localdomain (unknown []) by gzga-smtp-mtada-g1-3 (Coremail) with SMTP id _____wBHxSpEoBloZ2M1Ew--.50689S4; Tue, 06 May 2025 13:38:21 +0800 (CST) From: Wenliang Yan To: linux@roeck-us.net, Christophe JAILLET , Jean Delvare Cc: Wenliang Yan , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jonathan Corbet , linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, derek.lin@silergycorp.com, miguel.lee@silergycorp.com, chris.ho@silergycorp.com, eason.liao@silergycorp.com Subject: [PATCH v7 2/4] hwmon:(ina238)Add support for SQ52206 Date: Tue, 6 May 2025 01:37:39 -0400 Message-Id: <20250506053741.4837-3-wenliang202407@163.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20250506053741.4837-1-wenliang202407@163.com> References: <20250506053741.4837-1-wenliang202407@163.com> X-CM-TRANSID: _____wBHxSpEoBloZ2M1Ew--.50689S4 X-Coremail-Antispam: 1Uf129KBjvJXoW3Cr47uw1UXw4fGrW5AFWfAFb_yoWkGrW7pF ZxJayfKr4UJFWxW393tr48uF13Gwn7Gr47Ar4kWw1fZFs8J34vvFy2qF4FvFW3K34rZF45 Jr1kt3y5CwsFyw7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0JUb0edUUUUU= X-CM-SenderInfo: xzhqzxhdqjjiisuqlqqrwthudrp/xtbBDRJF02gZn3wSKQABsh Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add support for SQ52206 to the Ina238 driver. Add registers, increase compatibility, add compatibility programs for multiple chips. Signed-off-by: Wenliang Yan --- v6->v7:Maintain the previous changes v5->v6:Split the patch, this patch add support for SQ52206: 1.Incorporate four additional registers to the original register set of SQ52206 beyond INA238. 2.The ADC measurement range of SQ52206 is divided into 1/2/4, so change the configuration of INA238_ADC_CONFIG. 3.Add an introduction note to the power and energy formulas 4.Configure the properties of SQ52206 5.Add a 40 bit data reading function to prepare for energy reading. 6.Add peak power reading and add HWMON_P_INPUT_HIGHEST for power. 7.Energy attributes are 5bytes wide, so modified the function for energy1_input to use u64. Current_LSB is 1mA/lsb, so the SQ52206's Energy calculation formula is Energy (mJ) =3D 16 * 0.24 * register value * 1 * 20000 / rshunt / 4 * gain, where 20000 is the default resistance value. 4 is the default gain of 4, 20000*gain/ (rshunt*4) indicates the conversion ratio based on the actual resistance value and the gain ratio. 16 and 0.24 are fixed parameters. 'data->config->power_calculate_factor/100 =3D=3D 0.24'. 8.Add a corresponding compatible to the driver. Documentation/hwmon/ina238.rst | 15 +++++ drivers/hwmon/ina238.c | 113 ++++++++++++++++++++++++++++++--- 2 files changed, 120 insertions(+), 8 deletions(-) diff --git a/Documentation/hwmon/ina238.rst b/Documentation/hwmon/ina238.rst index d9f479984420..d1b93cf8627f 100644 --- a/Documentation/hwmon/ina238.rst +++ b/Documentation/hwmon/ina238.rst @@ -14,6 +14,12 @@ Supported chips: Datasheet: https://www.ti.com/lit/gpn/ina238 =20 + * Silergy SQ52206 + + Prefix: 'SQ52206' + + Addresses: I2C 0x40 - 0x4f + Author: Nathan Rossi =20 Description @@ -54,3 +60,12 @@ temp1_input Die temperature measurement (mC) temp1_max Maximum die temperature threshold (mC) temp1_max_alarm Maximum die temperature alarm =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=3D + +Additional sysfs entries for sq52206 +------------------------------------ + +=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=3D +energy1_input Energy measurement (mJ) + +power1_input_highest Peak Power (uW) +=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=3D diff --git a/drivers/hwmon/ina238.c b/drivers/hwmon/ina238.c index c8d6bd3041b3..1bf4c850b04d 100644 --- a/drivers/hwmon/ina238.c +++ b/drivers/hwmon/ina238.c @@ -21,11 +21,14 @@ #define INA238_CONFIG 0x0 #define INA238_ADC_CONFIG 0x1 #define INA238_SHUNT_CALIBRATION 0x2 +#define SQ52206_SHUNT_TEMPCO 0x3 #define INA238_SHUNT_VOLTAGE 0x4 #define INA238_BUS_VOLTAGE 0x5 #define INA238_DIE_TEMP 0x6 #define INA238_CURRENT 0x7 #define INA238_POWER 0x8 +#define SQ52206_ENERGY 0x9 +#define SQ52206_CHARGE 0xa #define INA238_DIAG_ALERT 0xb #define INA238_SHUNT_OVER_VOLTAGE 0xc #define INA238_SHUNT_UNDER_VOLTAGE 0xd @@ -33,9 +36,12 @@ #define INA238_BUS_UNDER_VOLTAGE 0xf #define INA238_TEMP_LIMIT 0x10 #define INA238_POWER_LIMIT 0x11 +#define SQ52206_POWER_PEAK 0x20 #define INA238_DEVICE_ID 0x3f /* not available on INA237 */ =20 #define INA238_CONFIG_ADCRANGE BIT(4) +#define SQ52206_CONFIG_ADCRANGE_HIGH BIT(4) +#define SQ52206_CONFIG_ADCRANGE_LOW BIT(3) =20 #define INA238_DIAG_ALERT_TMPOL BIT(7) #define INA238_DIAG_ALERT_SHNTOL BIT(6) @@ -44,12 +50,13 @@ #define INA238_DIAG_ALERT_BUSUL BIT(3) #define INA238_DIAG_ALERT_POL BIT(2) =20 -#define INA238_REGISTERS 0x11 +#define INA238_REGISTERS 0x20 =20 #define INA238_RSHUNT_DEFAULT 10000 /* uOhm */ =20 /* Default configuration of device on reset. */ #define INA238_CONFIG_DEFAULT 0 +#define SQ52206_CONFIG_DEFAULT 0x0005 /* 16 sample averaging, 1052us conversion time, continuous mode */ #define INA238_ADC_CONFIG_DEFAULT 0xfb6a /* Configure alerts to be based on averaged value (SLOWALERT) */ @@ -87,14 +94,19 @@ * shunt =3D 0x4000 / (819.2 * 10^6) / 0.001 =3D 20000 uOhms (with 1mA/ls= b) * * Current (mA) =3D register value * 20000 / rshunt / 4 * gain - * Power (W) =3D 0.2 * register value * 20000 / rshunt / 4 * gain + * Power (mW) =3D 0.2 * register value * 20000 / rshunt / 4 * gain + * (Specific for SQ52206) + * Power (mW) =3D 0.24 * register value * 20000 / rshunt / 4 * gain + * Energy (mJ) =3D 16 * 0.24 * register value * 20000 / rshunt / 4 * gain */ #define INA238_CALIBRATION_VALUE 16384 #define INA238_FIXED_SHUNT 20000 =20 #define INA238_SHUNT_VOLTAGE_LSB 5 /* 5 uV/lsb */ #define INA238_BUS_VOLTAGE_LSB 3125 /* 3.125 mV/lsb */ -#define INA238_DIE_TEMP_LSB 125 /* 125 mC/lsb */ +#define INA238_DIE_TEMP_LSB 1250000 /* 125.0000 mC/lsb */ +#define SQ52206_BUS_VOLTAGE_LSB 3750 /* 3.75 mV/lsb */ +#define SQ52206_DIE_TEMP_LSB 78125 /* 7.8125 mC/lsb */ =20 static const struct regmap_config ina238_regmap_config =3D { .max_register =3D INA238_REGISTERS, @@ -102,7 +114,7 @@ static const struct regmap_config ina238_regmap_config = =3D { .val_bits =3D 16, }; =20 -enum ina238_ids { ina238, ina237 }; +enum ina238_ids { ina238, ina237, sq52206 }; =20 struct ina238_config { bool has_power_highest; /* chip detection power peak */ @@ -142,6 +154,15 @@ static const struct ina238_config ina238_config[] =3D { .bus_voltage_lsb =3D INA238_BUS_VOLTAGE_LSB, .temp_lsb =3D INA238_DIE_TEMP_LSB, }, + [sq52206] =3D { + .has_energy =3D true, + .has_power_highest =3D true, + .temp_shift =3D 0, + .power_calculate_factor =3D 24, + .config_default =3D SQ52206_CONFIG_DEFAULT, + .bus_voltage_lsb =3D SQ52206_BUS_VOLTAGE_LSB, + .temp_lsb =3D SQ52206_DIE_TEMP_LSB, + }, }; =20 static int ina238_read_reg24(const struct i2c_client *client, u8 reg, u32 = *val) @@ -160,6 +181,24 @@ static int ina238_read_reg24(const struct i2c_client *= client, u8 reg, u32 *val) return 0; } =20 +static int ina238_read_reg40(const struct i2c_client *client, u8 reg, u64 = *val) +{ + u8 data[5]; + u32 low; + int err; + + /* 40-bit register read */ + err =3D i2c_smbus_read_i2c_block_data(client, reg, 5, data); + if (err < 0) + return err; + if (err !=3D 5) + return -EIO; + low =3D (data[1] << 24) | (data[2] << 16) | (data[3] << 8) | data[4]; + *val =3D ((long long)data[0] << 32) | low; + + return 0; +} + static int ina238_read_in(struct device *dev, u32 attr, int channel, long *val) { @@ -330,6 +369,17 @@ static int ina238_read_power(struct device *dev, u32 a= ttr, long *val) if (err) return err; =20 + /* Fixed 1mA lsb, scaled by 1000000 to have result in uW */ + power =3D div_u64(regval * 1000ULL * INA238_FIXED_SHUNT * + data->gain, 20 * data->rshunt); + /* Clamp value to maximum value of long */ + *val =3D clamp_val(power, 0, LONG_MAX); + break; + case hwmon_power_input_highest: + err =3D ina238_read_reg24(data->client, SQ52206_POWER_PEAK, ®val); + if (err) + return err; + /* Fixed 1mA lsb, scaled by 1000000 to have result in uW */ power =3D div_u64(regval * 1000ULL * INA238_FIXED_SHUNT * data->gain, 20 * data->rshunt); @@ -437,6 +487,25 @@ static int ina238_write_temp(struct device *dev, u32 a= ttr, long val) return regmap_write(data->regmap, INA238_TEMP_LIMIT, regval); } =20 +static ssize_t energy1_input_show(struct device *dev, + struct device_attribute *da, char *buf) +{ + struct ina238_data *data =3D dev_get_drvdata(dev); + int ret; + u64 regval; + u64 energy; + + ret =3D ina238_read_reg40(data->client, SQ52206_ENERGY, ®val); + if (ret) + return ret; + + /* result in mJ */ + energy =3D div_u64(regval * INA238_FIXED_SHUNT * data->gain * 16 * + data->config->power_calculate_factor, 4 * 100 * data->rshunt); + + return sysfs_emit(buf, "%llu\n", energy); +} + static int ina238_read(struct device *dev, enum hwmon_sensor_types type, u32 attr, int channel, long *val) { @@ -486,6 +555,9 @@ static umode_t ina238_is_visible(const void *drvdata, enum hwmon_sensor_types type, u32 attr, int channel) { + const struct ina238_data *data =3D drvdata; + bool has_power_highest =3D data->config->has_power_highest; + switch (type) { case hwmon_in: switch (attr) { @@ -513,6 +585,10 @@ static umode_t ina238_is_visible(const void *drvdata, return 0444; case hwmon_power_max: return 0644; + case hwmon_power_input_highest: + if (has_power_highest) + return 0444; + return 0; default: return 0; } @@ -546,7 +622,8 @@ static const struct hwmon_channel_info * const ina238_i= nfo[] =3D { HWMON_C_INPUT), HWMON_CHANNEL_INFO(power, /* 0: power */ - HWMON_P_INPUT | HWMON_P_MAX | HWMON_P_MAX_ALARM), + HWMON_P_INPUT | HWMON_P_MAX | + HWMON_P_MAX_ALARM | HWMON_P_INPUT_HIGHEST), HWMON_CHANNEL_INFO(temp, /* 0: die temperature */ HWMON_T_INPUT | HWMON_T_MAX | HWMON_T_MAX_ALARM), @@ -564,6 +641,15 @@ static const struct hwmon_chip_info ina238_chip_info = =3D { .info =3D ina238_info, }; =20 +/* energy attributes are 5 bytes wide so we need u64 */ +static DEVICE_ATTR_RO(energy1_input); + +static struct attribute *ina238_attrs[] =3D { + &dev_attr_energy1_input.attr, + NULL, +}; +ATTRIBUTE_GROUPS(ina238); + static int ina238_probe(struct i2c_client *client) { struct ina2xx_platform_data *pdata =3D dev_get_platdata(&client->dev); @@ -604,14 +690,19 @@ static int ina238_probe(struct i2c_client *client) /* load shunt gain value */ if (device_property_read_u32(dev, "ti,shunt-gain", &data->gain) < 0) data->gain =3D 4; /* Default of ADCRANGE =3D 0 */ - if (data->gain !=3D 1 && data->gain !=3D 4) { + if (data->gain !=3D 1 && data->gain !=3D 2 && data->gain !=3D 4) { dev_err(dev, "invalid shunt gain value %u\n", data->gain); return -EINVAL; } =20 /* Setup CONFIG register */ config =3D data->config->config_default; - if (data->gain =3D=3D 1) + if (chip =3D=3D sq52206) { + if (data->gain =3D=3D 1) + config |=3D SQ52206_CONFIG_ADCRANGE_HIGH; /* ADCRANGE =3D 10/11 is /1 */ + else if (data->gain =3D=3D 2) + config |=3D SQ52206_CONFIG_ADCRANGE_LOW; /* ADCRANGE =3D 01 is /2 */ + } else if (data->gain =3D=3D 1) config |=3D INA238_CONFIG_ADCRANGE; /* ADCRANGE =3D 1 is /1 */ ret =3D regmap_write(data->regmap, INA238_CONFIG, config); if (ret < 0) { @@ -645,7 +736,8 @@ static int ina238_probe(struct i2c_client *client) =20 hwmon_dev =3D devm_hwmon_device_register_with_info(dev, client->name, dat= a, &ina238_chip_info, - NULL); + data->config->has_energy ? + ina238_groups : NULL); if (IS_ERR(hwmon_dev)) return PTR_ERR(hwmon_dev); =20 @@ -658,6 +750,7 @@ static int ina238_probe(struct i2c_client *client) static const struct i2c_device_id ina238_id[] =3D { { "ina237", ina237 }, { "ina238", ina238 }, + { "sq52206", sq52206 }, { } }; MODULE_DEVICE_TABLE(i2c, ina238_id); @@ -671,6 +764,10 @@ static const struct of_device_id __maybe_unused ina238= _of_match[] =3D { .compatible =3D "ti,ina238", .data =3D (void *)ina238 }, + { + .compatible =3D "silergy,sq52206", + .data =3D (void *)sq52206 + }, { } }; MODULE_DEVICE_TABLE(of, ina238_of_match); --=20 2.17.1 From nobody Tue Dec 16 23:10:20 2025 Received: from m16.mail.163.com (m16.mail.163.com [117.135.210.2]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CC2D128FAA3; Tue, 6 May 2025 05:39:06 +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=1746509950; cv=none; b=IeDrJHJI6f6B+wRkkkoH3lJREALj8M0NmLloHBC4S7AqIWER3JCHVBa9r+btEYpceZx0G2jgd9GaqtVVTsAfixs7HUoof5z9nniSba1RkxhfpCXrEfdTziFGb2Xrg8lusToyKm0hwqYYLwvxHh1CF2Vi1LGLmtntXGKJMcZHHqo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746509950; c=relaxed/simple; bh=73JQ0cfLtt7JnE+ORWyecKvkI3I3a0yP4J+IjMgnjgM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=Er6E0lWWu9pnmUyENQhrvxhRXI14Gql5LJUqQxgFA0wddvJ5xUgDF998ALvXaNckMgCTECyyn2diq7uCyuyZApUtwRwlv/nLf2M/Jyxl8MSucz9NS441yUwhtSB/UDcI4VN/mgvAFTLdPC5hZktNQdT7fSd3Dl12Ej1ECnVWd4Y= 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=lLDU8xzb; 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="lLDU8xzb" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=os95zONOU8hpFhyM09 sQt1NPe9aID5cEX5Mdkp5AzmM=; b=lLDU8xzbX9V6DR1d8K+fvPkNaNs2N+yBHS I0Au+ww05ruRwIjB8lO+R6DPqUMb0NeCnnFfJak/7bqithzMvh2aYcfpt7utJbck ZubZaJaw1HIzeZNalYeWCW5rIUX/2IizpyQ/oKrihns78yWZmVe4KP91akTKbBdR QRPiqxd6o= Received: from localhost.localdomain (unknown []) by gzga-smtp-mtada-g1-3 (Coremail) with SMTP id _____wBHxSpEoBloZ2M1Ew--.50689S5; Tue, 06 May 2025 13:38:25 +0800 (CST) From: Wenliang Yan To: linux@roeck-us.net, Christophe JAILLET , Jean Delvare Cc: Wenliang Yan , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jonathan Corbet , linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, derek.lin@silergycorp.com, miguel.lee@silergycorp.com, chris.ho@silergycorp.com, eason.liao@silergycorp.com Subject: [PATCH v7 3/4] hwmon:(ina238)Modify the calculation formula to adapt to different chips Date: Tue, 6 May 2025 01:37:40 -0400 Message-Id: <20250506053741.4837-4-wenliang202407@163.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20250506053741.4837-1-wenliang202407@163.com> References: <20250506053741.4837-1-wenliang202407@163.com> X-CM-TRANSID: _____wBHxSpEoBloZ2M1Ew--.50689S5 X-Coremail-Antispam: 1Uf129KBjvJXoWxKF48Zry7GF1DKF4DZryUGFg_yoWxZF47pF y5Can8Gr18tw17WrnFkr4xuF15Xwn7GwnxAr97KwnavFn0k34v9rW5tFWrZrW3JwsxXF48 t34UtrWYkwsFyaUanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0zRFfO7UUUUU= X-CM-SenderInfo: xzhqzxhdqjjiisuqlqqrwthudrp/1tbibh9F02gZnfc2mwAAsR Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Modify the calculation formula to adapt to different chips. Signed-off-by: Wenliang Yan --- v6->v7:Maintain the previous changes v5->v6:Split the patch, this patch introduce the principle of the formula: 1.shunt voltage reading and writing calculate *val =3D (regval * INA238_SHUNT_VOLTAGE_LSB) * data->gain / (1000 * 4); regval =3D (regval * 1000 * 4) / (INA238_SHUNT_VOLTAGE_LSB * data->gain); Solves the situation where gain=3D2 exists 2.power reading and writing calculate power =3D div_u64(regval * 1000ULL * INA238_FIXED_SHUNT * data->gain * data->config->power_calculate_factor, 4 * 100 * data->rshunt); Since the 'data->config->power_calculate_factor' parameter values of differ= ent chips are different, the formula is modified. Current_LSB is 1mA/lsb, so the SQ52206's Energy calculation formula is Power (uW) =3D 0.24(0.2) * register value * 1000 * 20000 / rshunt / 4 * gai= n, where 20000 is the default resistance value. 4 is the default gain of 4, 20000*gain/ (rshunt*4) indicates the conversion ratio based on the actual resistance value and the gain ratio. 0.24(0.2) is fixed parameters. 'data->config->power_calculate_factor/100 =3D=3D 0.24(0.2)'. 3.read temp calculate *val =3D div_s64(((s64)((s16)regval) >> data->config->temp_shift) * (s64)data->config->temp_lsb, 10000); Since the 'data->config->temp_shift' parameter values of different chips are different, the formula is modified. Cast the parameter regval type s64 to avoid overflows resulting in calculat= ion errors. 4.writr temp calculate regval =3D clamp_val(val, -40000, 125000); Limiting the size of written data prevents overflows that can cause calcula= tion error drivers/hwmon/ina238.c | 47 +++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/drivers/hwmon/ina238.c b/drivers/hwmon/ina238.c index 1bf4c850b04d..7a96b68d4d20 100644 --- a/drivers/hwmon/ina238.c +++ b/drivers/hwmon/ina238.c @@ -270,10 +270,10 @@ static int ina238_read_in(struct device *dev, u32 att= r, int channel, regval =3D (s16)regval; if (channel =3D=3D 0) /* gain of 1 -> LSB / 4 */ - *val =3D (regval * INA238_SHUNT_VOLTAGE_LSB) / - (1000 * (4 - data->gain + 1)); + *val =3D (regval * INA238_SHUNT_VOLTAGE_LSB) * + data->gain / (1000 * 4); else - *val =3D (regval * INA238_BUS_VOLTAGE_LSB) / 1000; + *val =3D (regval * data->config->bus_voltage_lsb) / 1000; break; case hwmon_in_max_alarm: case hwmon_in_min_alarm: @@ -298,8 +298,8 @@ static int ina238_write_in(struct device *dev, u32 attr= , int channel, case 0: /* signed value, clamp to max range +/-163 mV */ regval =3D clamp_val(val, -163, 163); - regval =3D (regval * 1000 * (4 - data->gain + 1)) / - INA238_SHUNT_VOLTAGE_LSB; + regval =3D (regval * 1000 * 4) / + (INA238_SHUNT_VOLTAGE_LSB * data->gain); regval =3D clamp_val(regval, S16_MIN, S16_MAX); =20 switch (attr) { @@ -315,7 +315,7 @@ static int ina238_write_in(struct device *dev, u32 attr= , int channel, case 1: /* signed value, positive values only. Clamp to max 102.396 V */ regval =3D clamp_val(val, 0, 102396); - regval =3D (regval * 1000) / INA238_BUS_VOLTAGE_LSB; + regval =3D (regval * 1000) / data->config->bus_voltage_lsb; regval =3D clamp_val(regval, 0, S16_MAX); =20 switch (attr) { @@ -370,8 +370,8 @@ static int ina238_read_power(struct device *dev, u32 at= tr, long *val) return err; =20 /* Fixed 1mA lsb, scaled by 1000000 to have result in uW */ - power =3D div_u64(regval * 1000ULL * INA238_FIXED_SHUNT * - data->gain, 20 * data->rshunt); + power =3D div_u64(regval * 1000ULL * INA238_FIXED_SHUNT * data->gain * + data->config->power_calculate_factor, 4 * 100 * data->rshunt); /* Clamp value to maximum value of long */ *val =3D clamp_val(power, 0, LONG_MAX); break; @@ -381,8 +381,8 @@ static int ina238_read_power(struct device *dev, u32 at= tr, long *val) return err; =20 /* Fixed 1mA lsb, scaled by 1000000 to have result in uW */ - power =3D div_u64(regval * 1000ULL * INA238_FIXED_SHUNT * - data->gain, 20 * data->rshunt); + power =3D div_u64(regval * 1000ULL * INA238_FIXED_SHUNT * data->gain * + data->config->power_calculate_factor, 4 * 100 * data->rshunt); /* Clamp value to maximum value of long */ *val =3D clamp_val(power, 0, LONG_MAX); break; @@ -395,8 +395,8 @@ static int ina238_read_power(struct device *dev, u32 at= tr, long *val) * Truncated 24-bit compare register, lower 8-bits are * truncated. Same conversion to/from uW as POWER register. */ - power =3D div_u64((regval << 8) * 1000ULL * INA238_FIXED_SHUNT * - data->gain, 20 * data->rshunt); + power =3D div_u64((regval << 8) * 1000ULL * INA238_FIXED_SHUNT * data->g= ain * + data->config->power_calculate_factor, 4 * 100 * data->rshunt); /* Clamp value to maximum value of long */ *val =3D clamp_val(power, 0, LONG_MAX); break; @@ -428,8 +428,8 @@ static int ina238_write_power(struct device *dev, u32 a= ttr, long val) * register. */ regval =3D clamp_val(val, 0, LONG_MAX); - regval =3D div_u64(val * 20ULL * data->rshunt, - 1000ULL * INA238_FIXED_SHUNT * data->gain); + regval =3D div_u64(val * 4 * 100 * data->rshunt, data->config->power_calc= ulate_factor * + 1000ULL * INA238_FIXED_SHUNT * data->gain); regval =3D clamp_val(regval >> 8, 0, U16_MAX); =20 return regmap_write(data->regmap, INA238_POWER_LIMIT, regval); @@ -446,17 +446,17 @@ static int ina238_read_temp(struct device *dev, u32 a= ttr, long *val) err =3D regmap_read(data->regmap, INA238_DIE_TEMP, ®val); if (err) return err; - - /* Signed, bits 15-4 of register, result in mC */ - *val =3D ((s16)regval >> 4) * INA238_DIE_TEMP_LSB; + /* Signed, result in mC */ + *val =3D div_s64(((s64)((s16)regval) >> data->config->temp_shift) * + (s64)data->config->temp_lsb, 10000); break; case hwmon_temp_max: err =3D regmap_read(data->regmap, INA238_TEMP_LIMIT, ®val); if (err) return err; - - /* Signed, bits 15-4 of register, result in mC */ - *val =3D ((s16)regval >> 4) * INA238_DIE_TEMP_LSB; + /* Signed, result in mC */ + *val =3D div_s64(((s64)((s16)regval) >> data->config->temp_shift) * + (s64)data->config->temp_lsb, 10000); break; case hwmon_temp_max_alarm: err =3D regmap_read(data->regmap, INA238_DIAG_ALERT, ®val); @@ -480,9 +480,10 @@ static int ina238_write_temp(struct device *dev, u32 a= ttr, long val) if (attr !=3D hwmon_temp_max) return -EOPNOTSUPP; =20 - /* Signed, bits 15-4 of register */ - regval =3D (val / INA238_DIE_TEMP_LSB) << 4; - regval =3D clamp_val(regval, S16_MIN, S16_MAX) & 0xfff0; + /* Signed */ + regval =3D clamp_val(val, -40000, 125000); + regval =3D div_s64(val*10000, data->config->temp_lsb) << data->config->te= mp_shift; + regval =3D clamp_val(regval, S16_MIN, S16_MAX) & (0xffff << data->config-= >temp_shift); =20 return regmap_write(data->regmap, INA238_TEMP_LIMIT, regval); } --=20 2.17.1 From nobody Tue Dec 16 23:10:20 2025 Received: from m16.mail.163.com (m16.mail.163.com [117.135.210.2]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 661CE27BF9A; Tue, 6 May 2025 05:39:04 +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=1746509948; cv=none; b=IajYhBsBAYeFRXRvam01W4eVPjy5ev2de9fVNSsEHuFQm0ShERMC767PNdcnZ3sXFIXIX2lBTQQyjqN5eEJtf10AeFAIJREoZDkz/EU3eqC765t/pwJrGaiGk+K2iNnhWMMwagwfnNNPvlk+v+hjepnFAlCoZpI7kvMlnEKSdbU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746509948; c=relaxed/simple; bh=jS6WcRUZ5LMlqt/v3lxpcWGgtkNFOwJfvXYwfqfFbi4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=abdFgEBTpdt6u9n9fNkiUWgrCkEX0RF/ZazA7fCtLHpNmgRyxRYeiTDKPVJC2MO6oundOMxFJZP6vol4NRJvp+EeUAR0tDTx7xo/Yh4JyAu7gPT/kLG1ZO/YIO6GTUx0TjTgj7/4vcP06t+g5IHRNtJX0nzmGRHoZSNfSFWr5Z8= 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=fIRgVAd3; 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="fIRgVAd3" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=SEKm99PurVmtrNTupP 5Lg3cHjShnygrGqkE6bVv/E7I=; b=fIRgVAd3fMVfzNtZrUHMKm4X5GSFt8lgWi 9njtbfBxHMQhvRTM4ntJlB65BvfuWlTqWy8Ys+YmtCU90kEmfBKhadOclNKvdA8a fQGUsQvJVLZCBWOVCnU2xkf61BfP7bcQdkIpdaBhmJb0GfKbfztdrjwQtoXTCEyU WkyuG1TeM= Received: from localhost.localdomain (unknown []) by gzga-smtp-mtada-g1-3 (Coremail) with SMTP id _____wBHxSpEoBloZ2M1Ew--.50689S6; Tue, 06 May 2025 13:38:28 +0800 (CST) From: Wenliang Yan To: linux@roeck-us.net, Jean Delvare , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: Wenliang Yan , Jonathan Corbet , linux-hwmon@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, christophe.jaillet@wanadoo.fr, derek.lin@silergycorp.com, miguel.lee@silergycorp.com, chris.ho@silergycorp.com, eason.liao@silergycorp.com Subject: [PATCH v7 4/4] dt-bindings:Add SQ52206 to ina2xx devicetree bindings Date: Tue, 6 May 2025 01:37:41 -0400 Message-Id: <20250506053741.4837-5-wenliang202407@163.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20250506053741.4837-1-wenliang202407@163.com> References: <20250506053741.4837-1-wenliang202407@163.com> X-CM-TRANSID: _____wBHxSpEoBloZ2M1Ew--.50689S6 X-Coremail-Antispam: 1Uf129KBjvJXoW7CF18Kr4fWF45uF4UWF43Awb_yoW8XF17p3 9xCF1jqryFqF13u3y7t3Z5G34Uu3Wv9F48KF1DJr1a93WkZa4Fq39xKr18Kr17Cr1fZFWf uFn2grW8X340yaUanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0pRVnmiUUUUU= X-CM-SenderInfo: xzhqzxhdqjjiisuqlqqrwthudrp/1tbiMAZF02gZnOxMHwAAsy Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add the sq52206 compatible to the ina2xx.yaml Signed-off-by: Wenliang Yan Acked-by: Conor Dooley --- Add the meaning of 'shunt-gain' in SQ52206. v6->v7: Change 'silergy,sy24655' to 'silergy,sq52206' so that the make dt_binding_check' command can be successfully passed v5->v6:add content to meet the update requirements of the ina2xx.yaml Documentation/devicetree/bindings/hwmon/ti,ina2xx.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Documentation/devicetree/bindings/hwmon/ti,ina2xx.yaml b/Docum= entation/devicetree/bindings/hwmon/ti,ina2xx.yaml index bc03781342c0..d1fb7b9abda0 100644 --- a/Documentation/devicetree/bindings/hwmon/ti,ina2xx.yaml +++ b/Documentation/devicetree/bindings/hwmon/ti,ina2xx.yaml @@ -19,6 +19,7 @@ description: | properties: compatible: enum: + - silergy,sq52206 - silergy,sy24655 - ti,ina209 - ti,ina219 @@ -58,6 +59,9 @@ properties: shunt voltage, and a value of 4 maps to ADCRANGE=3D0 such that a wid= er voltage range is used. =20 + For SQ52206,the shunt-gain value 1 mapps to ADCRANGE=3D10/11, the va= lue 2 + mapps to ADCRANGE=3D01, and the value 4 mapps to ADCRANGE=3D00. + The default value is device dependent, and is defined by the reset v= alue of PGA/ADCRANGE in the respective configuration registers. $ref: /schemas/types.yaml#/definitions/uint32 @@ -97,6 +101,7 @@ allOf: compatible: contains: enum: + - silergy,sq52206 - silergy,sy24655 - ti,ina209 - ti,ina219 --=20 2.17.1