93 lines
2.7 KiB
Diff
93 lines
2.7 KiB
Diff
|
Dump all known registers of the SMB1360 battery/charging chip.
|
||
|
The same output can be generated with the mainline driver which allows verifying
|
||
|
if all the registers are set correctly.
|
||
|
|
||
|
diff --git a/drivers/power/Makefile b/drivers/power/Makefile
|
||
|
index b8ae7ae0ef7..b88d1905a3c 100644
|
||
|
--- a/drivers/power/Makefile
|
||
|
+++ b/drivers/power/Makefile
|
||
|
@@ -1,6 +1,7 @@
|
||
|
ccflags-$(CONFIG_POWER_SUPPLY_DEBUG) := -DDEBUG
|
||
|
|
||
|
power_supply-y := power_supply_core.o
|
||
|
+power_supply-y += smb1360-dump.o
|
||
|
power_supply-$(CONFIG_SYSFS) += power_supply_sysfs.o
|
||
|
power_supply-$(CONFIG_LEDS_TRIGGERS) += power_supply_leds.o
|
||
|
|
||
|
diff --git a/drivers/power/smb1360-charger-fg.c b/drivers/power/smb1360-charger-fg.c
|
||
|
index 7931b6df9be..249b9825550 100644
|
||
|
--- a/drivers/power/smb1360-charger-fg.c
|
||
|
+++ b/drivers/power/smb1360-charger-fg.c
|
||
|
@@ -4347,12 +4347,50 @@ static int smb1360_hw_init(struct smb1360_chip *chip)
|
||
|
return rc;
|
||
|
}
|
||
|
|
||
|
+extern void smb1360_dump(struct i2c_client *client);
|
||
|
+extern void smb1360_dump_fg_scratch(struct i2c_client *fg_client);
|
||
|
+extern void smb1360_dump_fg(struct i2c_client *client);
|
||
|
+
|
||
|
+static void smb1360_dump_locked(struct smb1360_chip *chip)
|
||
|
+{
|
||
|
+ mutex_lock(&chip->read_write_lock);
|
||
|
+ smb1360_dump(chip->client);
|
||
|
+ mutex_unlock(&chip->read_write_lock);
|
||
|
+}
|
||
|
+
|
||
|
+static void smb1360_dump_fg_access(struct smb1360_chip *chip)
|
||
|
+{
|
||
|
+ int ret;
|
||
|
+
|
||
|
+ ret = smb1360_enable_fg_access(chip);
|
||
|
+ if (ret)
|
||
|
+ return;
|
||
|
+
|
||
|
+ mutex_lock(&chip->read_write_lock);
|
||
|
+ smb1360_dump_fg_scratch(chip->client);
|
||
|
+
|
||
|
+ /* Do cool hacks to access FG I2C address instead */
|
||
|
+ chip->fg_access_type = FG_ACCESS_CFG;
|
||
|
+ smb1360_select_fg_i2c_address(chip);
|
||
|
+
|
||
|
+ chip->client->addr = chip->fg_i2c_addr;
|
||
|
+ smb1360_dump_fg(chip->client);
|
||
|
+ chip->client->addr = chip->default_i2c_addr;
|
||
|
+ mutex_unlock(&chip->read_write_lock);
|
||
|
+
|
||
|
+ smb1360_disable_fg_access(chip);
|
||
|
+ smb1360_check_cycle_stretch(chip);
|
||
|
+}
|
||
|
+
|
||
|
static int smb1360_delayed_hw_init(struct smb1360_chip *chip)
|
||
|
{
|
||
|
int rc;
|
||
|
|
||
|
pr_debug("delayed hw init start!\n");
|
||
|
|
||
|
+ /* Dump initial FG registers */
|
||
|
+ smb1360_dump_fg_access(chip);
|
||
|
+
|
||
|
if (chip->otp_hard_jeita_config) {
|
||
|
rc = smb1360_hard_jeita_otp_init(chip);
|
||
|
if (rc) {
|
||
|
@@ -4386,6 +4424,10 @@ static int smb1360_delayed_hw_init(struct smb1360_chip *chip)
|
||
|
}
|
||
|
|
||
|
pr_debug("delayed hw init complete!\n");
|
||
|
+
|
||
|
+ /* Dump final registers */
|
||
|
+ smb1360_dump_locked(chip);
|
||
|
+ smb1360_dump_fg_access(chip);
|
||
|
return rc;
|
||
|
}
|
||
|
|
||
|
@@ -4945,6 +4987,9 @@ static int smb1360_probe(struct i2c_client *client,
|
||
|
INIT_WORK(&chip->jeita_hysteresis_work,
|
||
|
smb1360_jeita_hysteresis_work);
|
||
|
|
||
|
+ /* Dump initial registers */
|
||
|
+ smb1360_dump_locked(chip);
|
||
|
+
|
||
|
pr_debug("default_i2c_addr=%x\n", chip->default_i2c_addr);
|
||
|
smb1360_otp_backup_pool_init(chip);
|
||
|
rc = smb1360_hw_init(chip);
|