devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Wenliang Yan <wenliang202407@163.com>
To: linux@roeck-us.net, Jean Delvare <jdelvare@suse.com>
Cc: christophe.jaillet@wanadoo.fr, conor+dt@kernel.org,
	corbet@lwn.net, devicetree@vger.kernel.org, krzk+dt@kernel.org,
	linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org,
	robh@kernel.org, wenliang202407@163.com
Subject: [PATCH 2/8] hwmon:(ina3221)Add support for SQ52210
Date: Tue, 11 Nov 2025 03:05:40 -0500	[thread overview]
Message-ID: <20251111080546.32421-3-wenliang202407@163.com> (raw)
In-Reply-To: <20251111080546.32421-1-wenliang202407@163.com>

SQ52210 is compatible with INA3221, but also includes current registers,
power registers, and registers related to alerts.

Signed-off-by: Wenliang Yan <wenliang202407@163.com>
---
 drivers/hwmon/ina3221.c | 35 +++++++++++++++++++++++++++++++++--
 1 file changed, 33 insertions(+), 2 deletions(-)

diff --git a/drivers/hwmon/ina3221.c b/drivers/hwmon/ina3221.c
index 5ecc68dcf169..80c1bcc7edd7 100644
--- a/drivers/hwmon/ina3221.c
+++ b/drivers/hwmon/ina3221.c
@@ -34,6 +34,17 @@
 #define INA3221_SHUNT_SUM		0x0d
 #define INA3221_CRIT_SUM		0x0e
 #define INA3221_MASK_ENABLE		0x0f
+#define SQ52210_ALERT_CONFIG	0x12
+#define SQ52210_CALIBRATION		0x14
+#define SQ52210_CURRENT1		0x15
+#define SQ52210_CURRENT2		0x16
+#define SQ52210_CURRENT3		0x17
+#define SQ52210_POWER1			0x18
+#define SQ52210_POWER2			0x19
+#define SQ52210_POWER3			0x1A
+#define SQ52210_ALERT_LIMIT1	0x1B
+#define SQ52210_ALERT_LIMIT2	0x1C
+#define SQ52210_ALERT_LIMIT3	0x1D
 
 #define INA3221_CONFIG_MODE_MASK	GENMASK(2, 0)
 #define INA3221_CONFIG_MODE_POWERDOWN	0
@@ -108,8 +119,12 @@ struct ina3221_input {
 	bool summation_disable;
 };
 
+enum ina3221_ids { ina3221, sq52210 };
+
+
 /**
  * struct ina3221_data - device specific information
+ * @chip: Chip type identifier
  * @pm_dev: Device pointer for pm runtime
  * @regmap: Register map of the device
  * @fields: Register fields of the device
@@ -120,6 +135,8 @@ struct ina3221_input {
  * @single_shot: running in single-shot operating mode
  */
 struct ina3221_data {
+	enum ina3221_ids chip;
+
 	struct device *pm_dev;
 	struct regmap *regmap;
 	struct regmap_field *fields[F_MAX_FIELDS];
@@ -734,6 +751,7 @@ static const struct regmap_range ina3221_yes_ranges[] = {
 	regmap_reg_range(INA3221_CONFIG, INA3221_BUS3),
 	regmap_reg_range(INA3221_SHUNT_SUM, INA3221_SHUNT_SUM),
 	regmap_reg_range(INA3221_MASK_ENABLE, INA3221_MASK_ENABLE),
+	regmap_reg_range(SQ52210_ALERT_CONFIG, SQ52210_POWER3),
 };
 
 static const struct regmap_access_table ina3221_volatile_table = {
@@ -818,13 +836,18 @@ static int ina3221_probe(struct i2c_client *client)
 	struct device *dev = &client->dev;
 	struct ina3221_data *ina;
 	struct device *hwmon_dev;
+	enum ina3221_ids chip;
 	char name[32];
 	int i, ret;
 
+	chip = (uintptr_t)i2c_get_match_data(client);
+
 	ina = devm_kzalloc(dev, sizeof(*ina), GFP_KERNEL);
 	if (!ina)
 		return -ENOMEM;
 
+	ina->chip = chip;
+
 	ina->regmap = devm_regmap_init_i2c(client, &ina3221_regmap_config);
 	if (IS_ERR(ina->regmap)) {
 		dev_err(dev, "Unable to allocate register map\n");
@@ -996,13 +1019,21 @@ static DEFINE_RUNTIME_DEV_PM_OPS(ina3221_pm, ina3221_suspend, ina3221_resume,
 				 NULL);
 
 static const struct of_device_id ina3221_of_match_table[] = {
-	{ .compatible = "ti,ina3221", },
+	{
+		.compatible = "silergy,sq52210",
+		.data = (void *)sq52210
+	},
+	{
+		.compatible = "ti,ina3221",
+		.data = (void *)ina3221
+	},
 	{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, ina3221_of_match_table);
 
 static const struct i2c_device_id ina3221_ids[] = {
-	{ "ina3221" },
+	{ "ina3221", ina3221 },
+	{ "sq52210", sq52210 },
 	{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(i2c, ina3221_ids);
-- 
2.17.1


  parent reply	other threads:[~2025-11-11  8:06 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-11  8:05 [PATCH 0/8] (hwmon):(ina3221) Various improvement and add support for SQ52210 Wenliang Yan
2025-11-11  8:05 ` [PATCH 1/8] dt-binding:ti,ina3221:Add SQ52210 Wenliang Yan
2025-11-11  8:17   ` Krzysztof Kozlowski
2025-11-12  2:09     ` Wenliang Yan
2025-11-11  9:32   ` Rob Herring (Arm)
2025-11-12  2:08     ` Wenliang Yan
2025-11-13  2:03   ` Guenter Roeck
2025-11-14  6:44     ` Wenliang Yan
2025-11-11  8:05 ` Wenliang Yan [this message]
2025-11-11  8:05 ` [PATCH 3/8] hwmon:(ina3221)Support alert-type Wenliang Yan
2025-11-11  8:05 ` [PATCH 4/8] hwmon:(ina3221)Pre-calculate current and power LSB Wenliang Yan
2025-11-11  8:05 ` [PATCH 5/8] hwmon:(ina3221)Introduce power attribute and other characteristics of other attribute Wenliang Yan
2025-11-11  8:05 ` [PATCH 6/8] hwmon:(ina3221)Modify read/write functions for 'in' attribute Wenliang Yan
2025-11-12  3:58   ` kernel test robot
2025-11-13 17:16   ` Guenter Roeck
2025-11-14  7:36     ` [PATCH 1/8] dt-binding:ti,ina3221:Add SQ52210 Wenliang Yan
2025-11-11  8:05 ` [PATCH 7/8] hwmon:(ina3221)Support read/write functions for 'power' attribute Wenliang Yan
2025-11-13 17:18   ` Guenter Roeck
2025-11-14  7:41     ` [PATCH 1/8] dt-binding:ti,ina3221:Add SQ52210 Wenliang Yan
2025-11-11  8:05 ` [PATCH 8/8] hwmon:(ina3221)Support read/write functions for current_lcrict attribute Wenliang Yan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251111080546.32421-3-wenliang202407@163.com \
    --to=wenliang202407@163.com \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=conor+dt@kernel.org \
    --cc=corbet@lwn.net \
    --cc=devicetree@vger.kernel.org \
    --cc=jdelvare@suse.com \
    --cc=krzk+dt@kernel.org \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=robh@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).