pmaports/device/archived/linux-xiaomi-wt88047-downstream/smb1360-dump-wt88047.patch
Stefan Hansson fb7f99efe2
device: rename unmaintained to archived (MR 5046)
Unmaintained is a name which on multiple occasions have seen lead to
confusion with people having the impression that unmaintained is for all
unmaintained devices, which is not how we're really using it. Many
devices in testing do not actually have a maintainer, yet there has been
no push to move these out of there and into unmaintained.

I think this is a result of that unmaintained was introduced not to keep
unmaintained ports but rather a place to store ports that have a better
replacement but where the inferior one still holds some sort of value,
such as for debugging purposes. These ports also are not necessarily
entirely unmaintained and see more fixes than many ports in testing.

While one approach to solving this problem could be to simply moving all
unmaintained ports to unmaintained, I think this comes with some
problems: It would require an initial effort to figure out which ports
are indeed unmaintained and which just don't have a maintained noted in
the package, and given how many ports there are in testing this would be
a big endeavour. It would also require continuous work on moving ports
into unmaintained as the maintainers go silent if we are to keep testing
and unmaintained's state consistent with reality. Additionally, just
because a port doesn't have a maintainer on paper doens't mean that
there aren't people who aren't willing to fix it up if there are issues
that arise.

As such, I think the way to go is renaming unmaintained to better
reflect the original intent. Thanks to Luca Weiss for suggesting
"archive", and to Arnav Singh for suggesting that "archived" would match
the other category names better.
2024-05-15 17:07:51 +02:00

80 lines
2.4 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.
(Note: Separate patch needed for wt88047 because it uses a slightly custom
smb1360-charger-fg driver...)
diff --git a/drivers/power/Makefile b/drivers/power/Makefile
index 3f93c7636c8..24e48c337e4 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-wt88047.c b/drivers/power/smb1360-charger-fg-wt88047.c
index fa03089b8b7..73ccd8d059e 100644
--- a/drivers/power/smb1360-charger-fg-wt88047.c
+++ b/drivers/power/smb1360-charger-fg-wt88047.c
@@ -3452,6 +3452,38 @@ static int smb1360_jeita_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_all(struct smb1360_chip *chip)
+{
+ int ret;
+
+ mutex_lock(&chip->read_write_lock);
+ smb1360_dump(chip->client);
+ mutex_unlock(&chip->read_write_lock);
+
+ 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_hw_init(struct smb1360_chip *chip)
{
int rc;
@@ -3460,6 +3492,9 @@ static int smb1360_hw_init(struct smb1360_chip *chip)
smb1360_check_feature_support(chip);
+ /* Dump initial registers */
+ smb1360_dump_all(chip);
+
rc = smb1360_enable_volatile_writes(chip);
if (rc < 0) {
dev_err(chip->dev, "Couldn't configure for volatile rc = %d\n",
@@ -3787,6 +3822,8 @@ static int smb1360_hw_init(struct smb1360_chip *chip)
return rc;
}
+ /* Dump final registers */
+ smb1360_dump_all(chip);
return rc;
}