mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mark Brown <broonie@kernel.org>
To: Liam Girdwood <lgirdwood@gmail.com>
Cc: linux-kernel@vger.kernel.org,
	Markus Reichl <m.reichl@fivetechno.de>,
	 Mark Brown <broonie@kernel.org>
Subject: [PATCH 2/8] regulator: mp8859: Validate and log device identifier information
Date: Sun, 25 Feb 2024 14:59:28 +0000	[thread overview]
Message-ID: <20240225-regulator-mp8859-v1-2-68ee2c839ded@kernel.org> (raw)
In-Reply-To: <20240225-regulator-mp8859-v1-0-68ee2c839ded@kernel.org>

Ensure that we are talking to a device which reports the expected ID
register information and log the OTP and revision information for
diagnostic purposes.

Signed-off-by: Mark Brown <broonie@kernel.org>
---
 drivers/regulator/mp8859.c | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/drivers/regulator/mp8859.c b/drivers/regulator/mp8859.c
index 689b56680d93..b07bc63a25cb 100644
--- a/drivers/regulator/mp8859.c
+++ b/drivers/regulator/mp8859.c
@@ -147,12 +147,46 @@ static int mp8859_i2c_probe(struct i2c_client *i2c)
 	struct regulator_config config = {.dev = &i2c->dev};
 	struct regmap *regmap = devm_regmap_init_i2c(i2c, &mp8859_regmap);
 	struct regulator_dev *rdev;
+	unsigned int val, rev;
 
 	if (IS_ERR(regmap)) {
 		ret = PTR_ERR(regmap);
 		dev_err(&i2c->dev, "regmap init failed: %d\n", ret);
 		return ret;
 	}
+
+	ret = regmap_read(regmap, MP8859_MFR_ID_REG, &val);
+	if (ret != 0) {
+		dev_err(&i2c->dev, "Failed to read manufacturer ID: %d\n", ret);
+		return ret;
+	}
+	if (val != 0x9) {
+		dev_err(&i2c->dev, "Manufacturer ID %x != 9\n", val);
+		return -EINVAL;
+	}
+
+	ret = regmap_read(regmap, MP8859_DEV_ID_REG, &val);
+	if (ret != 0) {
+		dev_err(&i2c->dev, "Failed to read device ID: %d\n", ret);
+		return ret;
+	}
+	if (val != 0x58) {
+		dev_err(&i2c->dev, "Manufacturer ID %x != 0x58\n", val);
+		return -EINVAL;
+	}
+
+	ret = regmap_read(regmap, MP8859_IC_REV_REG, &rev);
+	if (ret != 0) {
+		dev_err(&i2c->dev, "Failed to read device revision: %d\n", ret);
+		return ret;
+	}
+	ret = regmap_read(regmap, MP8859_ID1_REG, &val);
+	if (ret != 0) {
+		dev_err(&i2c->dev, "Failed to read device ID1: %d\n", ret);
+		return ret;
+	}
+	dev_info(&i2c->dev, "MP8859-%04d revision %d\n", val, rev);
+
 	rdev = devm_regulator_register(&i2c->dev, &mp8859_regulators[0],
 					&config);
 

-- 
2.39.2


  parent reply	other threads:[~2024-02-25 15:00 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-25 14:59 [PATCH 0/8] regulator: mp8859: Cleanups and enhancements Mark Brown
2024-02-25 14:59 ` [PATCH 1/8] regulator: mp8859: Specify register accessibility and enable caching Mark Brown
2024-02-25 14:59 ` Mark Brown [this message]
2024-02-25 14:59 ` [PATCH 3/8] regulator: mp8859: Support enable control Mark Brown
2024-02-25 14:59 ` [PATCH 4/8] regulator: mp8859: Support mode operations Mark Brown
2024-02-25 14:59 ` [PATCH 5/8] regulator: mp8859: Support active discharge control Mark Brown
2024-02-25 14:59 ` [PATCH 6/8] regulator: mp8859: Support status and error readback Mark Brown
2024-02-25 14:59 ` [PATCH 7/8] regulator: mp8859: Report slew rate Mark Brown
2024-02-25 14:59 ` [PATCH 8/8] regulator: mp8859: Implement set_current_limit() Mark Brown
2024-02-26  8:14 ` [PATCH 0/8] regulator: mp8859: Cleanups and enhancements Markus Reichl
2024-02-27 11:31 ` Mark Brown

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=20240225-regulator-mp8859-v1-2-68ee2c839ded@kernel.org \
    --to=broonie@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m.reichl@fivetechno.de \
    /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

all inboxes | Powered by JetHome®