#
3a3acf83 |
| 17-Aug-2024 |
Artur Weber <aweber.kernel@gmail.com> |
power: supply: max17042_battery: Fix SOC threshold calc w/ no current sense
Commit 223a3b82834f ("power: supply: max17042_battery: use VFSOC for capacity when no rsns") made it so that capacity on s
power: supply: max17042_battery: Fix SOC threshold calc w/ no current sense
Commit 223a3b82834f ("power: supply: max17042_battery: use VFSOC for capacity when no rsns") made it so that capacity on systems without current sensing would be read from VFSOC instead of RepSOC. However, the SOC threshold calculation still read RepSOC to get the SOC regardless of the current sensing option state.
Fix this by applying the same conditional to determine which register should be read.
This also seems to be the intended behavior as per the datasheet - SOC alert config value in MiscCFG on setups without current sensing is set to a value of 0b11, indicating SOC alerts being generated based on VFSOC, instead of 0b00 which indicates SOC alerts being generated based on RepSOC.
This fixes an issue on the Galaxy S3/Midas boards, where the alert interrupt would be constantly retriggered, causing high CPU usage on idle (around ~12%-15%).
Fixes: e5f3872d2044 ("max17042: Add support for signalling change in SOC") Signed-off-by: Artur Weber <aweber.kernel@gmail.com> Reviewed-by: Henrik Grimler <henrik@grimler.se> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Link: https://lore.kernel.org/r/20240817-max17042-soc-threshold-fix-v1-1-72b45899c3cc@gmail.com Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
show more ...
|
#
c06a65ac |
| 20-Jul-2023 |
Przemyslaw Chwiala <przemekchwiala@gmail.com> |
power: supply: max17042_battery: Do not use CONFIG_ prefix in regular C code
Using CONFIG_ prefix for macros is not a good practice. Use CONFIG_ prefix in Kconfig only.
Signed-off-by: Przemyslaw Ch
power: supply: max17042_battery: Do not use CONFIG_ prefix in regular C code
Using CONFIG_ prefix for macros is not a good practice. Use CONFIG_ prefix in Kconfig only.
Signed-off-by: Przemyslaw Chwiala <przemekchwiala@gmail.com> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Reviewed-by: Lukas Bulwahn <lukas.bulwahn@gmail.com> Link: https://lore.kernel.org/r/20230720123102.154699-1-przemekchwiala@gmail.com Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
show more ...
|
#
fe20b1dc |
| 17-May-2023 |
Uwe Kleine-König <u.kleine-koenig@pengutronix.de> |
power: supply: Switch i2c drivers back to use .probe()
After commit b8a1a4cd5a98 ("i2c: Provide a temporary .probe_new() call-back type"), all drivers being converted to .probe_new() and then 03c835
power: supply: Switch i2c drivers back to use .probe()
After commit b8a1a4cd5a98 ("i2c: Provide a temporary .probe_new() call-back type"), all drivers being converted to .probe_new() and then 03c835f498b5 ("i2c: Switch .probe() to not take an id parameter") convert back to (the new) .probe() to be able to eventually drop .probe_new() from struct i2c_driver.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
show more ...
|
#
1269774a |
| 15-Apr-2023 |
Hans de Goede <hdegoede@redhat.com> |
power: supply: max17042_battery: Refactor max17042_external_power_changed()
max17042_external_power_changed() is a wrapper around "power_supply_changed(psy);" and it has the same prototype.
Remove
power: supply: max17042_battery: Refactor max17042_external_power_changed()
max17042_external_power_changed() is a wrapper around "power_supply_changed(psy);" and it has the same prototype.
Remove it, replacing it with making the external_power_changed callback directly point to power_supply_changed.
Cc: Marek Szyprowski <m.szyprowski@samsung.com> Cc: Sebastian Krzyszkowiak <sebastian.krzyszkowiak@puri.sm> Cc: Purism Kernel Team <kernel@puri.sm> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
show more ...
|
#
d9ac265b |
| 18-Nov-2022 |
Uwe Kleine-König <u.kleine-koenig@pengutronix.de> |
power: supply: max17042_battery: Convert to i2c's .probe_new()
.probe_new() doesn't get the i2c_device_id * parameter, so determine that explicitly in the probe function.
Signed-off-by: Uwe Kleine-
power: supply: max17042_battery: Convert to i2c's .probe_new()
.probe_new() doesn't get the i2c_device_id * parameter, so determine that explicitly in the probe function.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
show more ...
|
#
e5372503 |
| 18-Feb-2022 |
Christophe JAILLET <christophe.jaillet@wanadoo.fr> |
power: supply: max17042_battery: Use devm_work_autocancel()
Use devm_work_autocancel() instead of hand-writing it. This saves a few lines of code.
Signed-off-by: Christophe JAILLET <christophe.jail
power: supply: max17042_battery: Use devm_work_autocancel()
Use devm_work_autocancel() instead of hand-writing it. This saves a few lines of code.
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
show more ...
|
#
e660dbb6 |
| 14-Sep-2021 |
Sebastian Krzyszkowiak <sebastian.krzyszkowiak@puri.sm> |
power: supply: max17042_battery: Prevent int underflow in set_soc_threshold
max17042_set_soc_threshold gets called with offset set to 1, which means that minimum threshold value would underflow once
power: supply: max17042_battery: Prevent int underflow in set_soc_threshold
max17042_set_soc_threshold gets called with offset set to 1, which means that minimum threshold value would underflow once SOC got down to 0, causing invalid alerts from the gauge.
Fixes: e5f3872d2044 ("max17042: Add support for signalling change in SOC") Cc: <stable@vger.kernel.org> Signed-off-by: Sebastian Krzyszkowiak <sebastian.krzyszkowiak@puri.sm> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
show more ...
|
#
0cf48167 |
| 14-Sep-2021 |
Sebastian Krzyszkowiak <sebastian.krzyszkowiak@puri.sm> |
power: supply: max17042_battery: Clear status bits in interrupt handler
The gauge requires us to clear the status bits manually for some alerts to be properly dismissed. Previously the IRQ was confi
power: supply: max17042_battery: Clear status bits in interrupt handler
The gauge requires us to clear the status bits manually for some alerts to be properly dismissed. Previously the IRQ was configured to react only on falling edge, which wasn't technically correct (the ALRT line is active low), but it had a happy side-effect of preventing interrupt storms on uncleared alerts from happening.
Fixes: 7fbf6b731bca ("power: supply: max17042: Do not enforce (incorrect) interrupt trigger type") Cc: <stable@vger.kernel.org> Signed-off-by: Sebastian Krzyszkowiak <sebastian.krzyszkowiak@puri.sm> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
show more ...
|
#
d0c27c92 |
| 29-Sep-2021 |
Henrik Grimler <henrik@grimler.se> |
power: supply: max17042_battery: fix typo in MAX17042_IAvg_empty
Datasheet gives the name IAvg_empty, not LAvg_empty.
Signed-off-by: Henrik Grimler <henrik@grimler.se> Reviewed-by: Hans de Goede <h
power: supply: max17042_battery: fix typo in MAX17042_IAvg_empty
Datasheet gives the name IAvg_empty, not LAvg_empty.
Signed-off-by: Henrik Grimler <henrik@grimler.se> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
show more ...
|
#
223a3b82 |
| 29-Sep-2021 |
Henrik Grimler <henrik@grimler.se> |
power: supply: max17042_battery: use VFSOC for capacity when no rsns
On Galaxy S3 (i9300/i9305), which has the max17047 fuel gauge and no current sense resistor (rsns), the RepSOC register does not
power: supply: max17042_battery: use VFSOC for capacity when no rsns
On Galaxy S3 (i9300/i9305), which has the max17047 fuel gauge and no current sense resistor (rsns), the RepSOC register does not provide an accurate state of charge value. The reported value is wrong, and does not change over time. VFSOC however, which uses the voltage fuel gauge to determine the state of charge, always shows an accurate value.
For devices without current sense, VFSOC is already used for the soc-alert (0x0003 is written to MiscCFG register), so with this change the source of the alert and the PROP_CAPACITY value match.
Fixes: 359ab9f5b154 ("power_supply: Add MAX17042 Fuel Gauge Driver") Cc: <stable@vger.kernel.org> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com> Suggested-by: Wolfgang Wiedmeyer <wolfgit@wiedmeyer.de> Signed-off-by: Henrik Grimler <henrik@grimler.se> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
show more ...
|
#
eaa2c490 |
| 16-Aug-2021 |
Sebastian Krzyszkowiak <sebastian.krzyszkowiak@puri.sm> |
power: supply: max17042_battery: log SOC threshold using debug log level
There's no need to print a message on every change in battery percentage on regular log levels.
Signed-off-by: Sebastian Krz
power: supply: max17042_battery: log SOC threshold using debug log level
There's no need to print a message on every change in battery percentage on regular log levels.
Signed-off-by: Sebastian Krzyszkowiak <sebastian.krzyszkowiak@puri.sm> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
show more ...
|
#
4bf00434 |
| 16-Aug-2021 |
Sebastian Krzyszkowiak <sebastian.krzyszkowiak@puri.sm> |
power: supply: max17042_battery: more robust chip type checks
Prepared by checking the datasheets of max17042, max17047/50 and max170455 for differences in register maps.
Signed-off-by: Sebastian K
power: supply: max17042_battery: more robust chip type checks
Prepared by checking the datasheets of max17042, max17047/50 and max170455 for differences in register maps.
Signed-off-by: Sebastian Krzyszkowiak <sebastian.krzyszkowiak@puri.sm> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
show more ...
|
#
ed0d0a05 |
| 16-Aug-2021 |
Sebastian Krzyszkowiak <sebastian.krzyszkowiak@puri.sm> |
power: supply: max17042_battery: fix typo in MAx17042_TOFF
Signed-off-by: Sebastian Krzyszkowiak <sebastian.krzyszkowiak@puri.sm> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
|
#
1e4f30ea |
| 16-Aug-2021 |
Sebastian Krzyszkowiak <sebastian.krzyszkowiak@puri.sm> |
power: supply: max17042_battery: clean up MAX17055_V_empty
This register is same as in MAX17047 and MAX17050, so there's no need for custom casing it.
Signed-off-by: Sebastian Krzyszkowiak <sebasti
power: supply: max17042_battery: clean up MAX17055_V_empty
This register is same as in MAX17047 and MAX17050, so there's no need for custom casing it.
Signed-off-by: Sebastian Krzyszkowiak <sebastian.krzyszkowiak@puri.sm> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
show more ...
|
#
22b6907c |
| 16-Aug-2021 |
Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com> |
power: supply: max17042: remove duplicated STATUS bit defines
All bits of STATUS register are already defined (see STATUS_SMN_BIT and further) so there is no need to define status SoC threshold min/
power: supply: max17042: remove duplicated STATUS bit defines
All bits of STATUS register are already defined (see STATUS_SMN_BIT and further) so there is no need to define status SoC threshold min/max values one more time.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
show more ...
|
#
54784ffa |
| 16-Aug-2021 |
Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com> |
power: supply: max17042: handle fails of reading status register
Reading status register can fail in the interrupt handler. In such case, the regmap_read() will not store anything useful under pass
power: supply: max17042: handle fails of reading status register
Reading status register can fail in the interrupt handler. In such case, the regmap_read() will not store anything useful under passed 'val' variable and random stack value will be used to determine type of interrupt.
Handle the regmap_read() failure to avoid handling interrupt type and triggering changed power supply event based on random stack value.
Fixes: 39e7213edc4f ("max17042_battery: Support regmap to access device's registers") Cc: <stable@vger.kernel.org> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
show more ...
|
#
4415e4ce |
| 27-Jul-2021 |
Nikita Travkin <nikita@trvn.ru> |
power: supply: max17042_battery: Add support for MAX77849 Fuel-Gauge
MAX77849 is a combined fuel-gauge, charger and MUIC IC. Notably, fuel-gauge has dedicated i2c lines and seems to be fully compati
power: supply: max17042_battery: Add support for MAX77849 Fuel-Gauge
MAX77849 is a combined fuel-gauge, charger and MUIC IC. Notably, fuel-gauge has dedicated i2c lines and seems to be fully compatible with max17047. Add new compatible for it reusing max17047 code paths.
Signed-off-by: Nikita Travkin <nikita@trvn.ru> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
show more ...
|
#
7fbf6b73 |
| 26-May-2021 |
Krzysztof Kozlowski <krzk@kernel.org> |
power: supply: max17042: Do not enforce (incorrect) interrupt trigger type
Interrupt line can be configured on different hardware in different way, even inverted. Therefore driver should not enforc
power: supply: max17042: Do not enforce (incorrect) interrupt trigger type
Interrupt line can be configured on different hardware in different way, even inverted. Therefore driver should not enforce specific trigger type - edge falling - but instead rely on Devicetree to configure it.
The Maxim 17047/77693 datasheets describe the interrupt line as active low with a requirement of acknowledge from the CPU therefore the edge falling is not correct.
The interrupt line is shared between PMIC and RTC driver, so using level sensitive interrupt is here especially important to avoid races. With an edge configuration in case if first PMIC signals interrupt followed shortly after by the RTC, the interrupt might not be yet cleared/acked thus the second one would not be noticed.
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
show more ...
|
#
37ad56aa |
| 23-Mar-2021 |
Bhaskar Chowdhury <unixbhaskar@gmail.com> |
power: supply: max17042: Trivial spelling fixes
Few trivial spelling fixes.
Signed-off-by: Bhaskar Chowdhury <unixbhaskar@gmail.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co
power: supply: max17042: Trivial spelling fixes
Few trivial spelling fixes.
Signed-off-by: Bhaskar Chowdhury <unixbhaskar@gmail.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
show more ...
|
#
5225371e |
| 25-Nov-2020 |
Sebastian Krzyszkowiak <sebastian.krzyszkowiak@puri.sm> |
power: supply: max17042_battery: Export charge termination current property
The value is there, so let's export it.
Signed-off-by: Sebastian Krzyszkowiak <sebastian.krzyszkowiak@puri.sm> Signed-off
power: supply: max17042_battery: Export charge termination current property
The value is there, so let's export it.
Signed-off-by: Sebastian Krzyszkowiak <sebastian.krzyszkowiak@puri.sm> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
show more ...
|
#
6dcfa009 |
| 25-Nov-2020 |
Sebastian Krzyszkowiak <sebastian.krzyszkowiak@puri.sm> |
power: supply: max17042_battery: Take r_sns value into account in charge_counter
The default r_sns value was hardcoded there, so let's change it to the actually configured one.
Signed-off-by: Sebas
power: supply: max17042_battery: Take r_sns value into account in charge_counter
The default r_sns value was hardcoded there, so let's change it to the actually configured one.
Signed-off-by: Sebastian Krzyszkowiak <sebastian.krzyszkowiak@puri.sm> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
show more ...
|
#
9e39ef14 |
| 25-Nov-2020 |
Sebastian Krzyszkowiak <sebastian.krzyszkowiak@puri.sm> |
power: supply: max17042_battery: Improve accuracy of current_now and current_avg readings
Dividing 1562500 by r_sns value usually doesn't result in an integer.
Signed-off-by: Sebastian Krzyszkowiak
power: supply: max17042_battery: Improve accuracy of current_now and current_avg readings
Dividing 1562500 by r_sns value usually doesn't result in an integer.
Signed-off-by: Sebastian Krzyszkowiak <sebastian.krzyszkowiak@puri.sm> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
show more ...
|
#
4b0a56e6 |
| 25-Nov-2020 |
Sebastian Krzyszkowiak <sebastian.krzyszkowiak@puri.sm> |
power: supply: max17042_battery: Fix current_{avg,now} hiding with no current sense
When current sense is disabled, max17042_no_current_sense_psy_desc gets used which ignores two last properties fro
power: supply: max17042_battery: Fix current_{avg,now} hiding with no current sense
When current sense is disabled, max17042_no_current_sense_psy_desc gets used which ignores two last properties from the list.
Fixes: 21b01cc879cc ("power: supply: max17042_battery: Add support for the TTE_NOW prop") Reported-by: Timon Baetz <timon.baetz@protonmail.com> Signed-off-by: Sebastian Krzyszkowiak <sebastian.krzyszkowiak@puri.sm> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
show more ...
|
#
21b01cc8 |
| 30-Mar-2020 |
Geordan Neukum <gneukum1@gmail.com> |
power: supply: max17042_battery: Add support for the TTE_NOW prop
The max170{42,47,50,55} family of fuel gauges all provide time-to-empty estimation. As such, let's export this as a property.
Signe
power: supply: max17042_battery: Add support for the TTE_NOW prop
The max170{42,47,50,55} family of fuel gauges all provide time-to-empty estimation. As such, let's export this as a property.
Signed-off-by: Geordan Neukum <gneukum1@gmail.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
show more ...
|
#
bc90705b |
| 14-Dec-2019 |
Angus Ainslie (Purism) <angus@akkea.ca> |
power: supply: max17042: add MAX17055 support
The MAX17055 is very similar to the MAX17042 so extend the driver.
Signed-off-by: Angus Ainslie (Purism) <angus@akkea.ca> Reviewed-by: Krzysztof Kozlow
power: supply: max17042: add MAX17055 support
The MAX17055 is very similar to the MAX17042 so extend the driver.
Signed-off-by: Angus Ainslie (Purism) <angus@akkea.ca> Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
show more ...
|