mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-29 22:02:02 +00:00
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>
This commit is contained in:
parent
b65e9149bd
commit
6c848d772e
1 changed files with 34 additions and 0 deletions
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue