summaryrefslogtreecommitdiffstats
path: root/drivers/regulator/mp8859.c
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2024-02-25 15:59:28 +0100
committerMark Brown <broonie@kernel.org>2024-02-26 14:46:49 +0100
commit6c848d772eee0f03b72542f35e1a66469030390f (patch)
tree07f54e1247adac16197f2cf60fdb8fe0f00932c1 /drivers/regulator/mp8859.c
parentregulator: mp8859: Specify register accessibility and enable caching (diff)
downloadlinux-6c848d772eee0f03b72542f35e1a66469030390f.tar.xz
linux-6c848d772eee0f03b72542f35e1a66469030390f.zip
regulator: mp8859: Validate and log device identifier information
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. Tested-by: Markus Reichl <m.reichl@fivetechno.de> Signed-off-by: Mark Brown <broonie@kernel.org> Link: https://msgid.link/r/20240225-regulator-mp8859-v1-2-68ee2c839ded@kernel.org Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/regulator/mp8859.c')
-rw-r--r--drivers/regulator/mp8859.c34
1 files changed, 34 insertions, 0 deletions
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);