linux-postmarketos-omap: fix n900 battery & charger (MR 4871)

Two changes are already upstream:
 * Battery: fix reporting of full state
     - https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/drivers/power/supply?id=8fbb11162504f2de167a8ccd2d2c55a849d2c5ea
 * Charger: report online state
     - https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/drivers/power/supply?h=next-20240301&id=9a451f1b028e116d037a93bf13eb8f8620994205

 * The other change (950mA charger current limit) will be included starting
   with 6.9-rc1. We previously had it in pmOS but it was dropped during the
   transition to a common OMAP kernel
    - https://lore.kernel.org/linux-devicetree/ZeBB1GYb31UAW886@tp440p.steeds.sam/T/#t
This commit is contained in:
Sicelo A. Mhlongo 2024-02-28 19:03:13 +02:00 committed by Clayton Craft
parent 05fe8d4015
commit cab1114ce2
No known key found for this signature in database
GPG key ID: 4A4CED6D7EDF950A
4 changed files with 137 additions and 1 deletions

View file

@ -0,0 +1,50 @@
From a65f118ddeb53a6bf09d2986bdf688dbb297cdb5 Mon Sep 17 00:00:00 2001
From: "Sicelo A. Mhlongo" <absicsz@gmail.com>
Date: Sat, 24 Feb 2024 21:53:04 +0200
Subject: [PATCH] power: supply: bq27xxx: Report charge full state correctly
When reporting the charging status, the existing code reports the battery
as full only when the reported current flowing is exactly 0mA, which is
unlikely in practice.
Fix the reporting by giving priority to the battery's full state
indication/flag.
Tested on the Nokia N900 with bq27200 fuel gauge.
Signed-off-by: Sicelo A. Mhlongo <absicsz@gmail.com>
---
drivers/power/supply/bq27xxx_battery.c | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/drivers/power/supply/bq27xxx_battery.c b/drivers/power/supply/bq27xxx_battery.c
index 1c4a9d137744..810f6eb468ad 100644
--- a/drivers/power/supply/bq27xxx_battery.c
+++ b/drivers/power/supply/bq27xxx_battery.c
@@ -1816,17 +1816,14 @@ static int bq27xxx_battery_current_and_status(
val_curr->intval = curr;
if (val_status) {
- if (curr > 0) {
+ if (bq27xxx_battery_is_full(di, flags))
+ val_status->intval = POWER_SUPPLY_STATUS_FULL;
+ else if (curr > 0)
val_status->intval = POWER_SUPPLY_STATUS_CHARGING;
- } else if (curr < 0) {
+ else if (curr < 0)
val_status->intval = POWER_SUPPLY_STATUS_DISCHARGING;
- } else {
- if (bq27xxx_battery_is_full(di, flags))
- val_status->intval = POWER_SUPPLY_STATUS_FULL;
- else
- val_status->intval =
- POWER_SUPPLY_STATUS_NOT_CHARGING;
- }
+ else
+ val_status->intval = POWER_SUPPLY_STATUS_NOT_CHARGING;
}
return 0;
--
2.43.0

View file

@ -0,0 +1,47 @@
From 6e9d3c99b8090a022224f216f299b531771a2f89 Mon Sep 17 00:00:00 2001
From: "Sicelo A. Mhlongo" <absicsz@gmail.com>
Date: Sat, 24 Feb 2024 23:06:24 +0200
Subject: [PATCH] power: supply: bq2415x_charger: report online status
Provide the Online property. This chip does not have specific flags to
indicate the presence of an input voltage, but this is implied by all valid
charging states. Fault states also only occur when VBUS is present, so set
Online true for those as well.
Signed-off-by: Sicelo A. Mhlongo <absicsz@gmail.com>
---
drivers/power/supply/bq2415x_charger.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/drivers/power/supply/bq2415x_charger.c b/drivers/power/supply/bq2415x_charger.c
index 6a4798a62588..7b93ba20348a 100644
--- a/drivers/power/supply/bq2415x_charger.c
+++ b/drivers/power/supply/bq2415x_charger.c
@@ -991,6 +991,7 @@ static enum power_supply_property bq2415x_power_supply_props[] = {
/* TODO: maybe add more power supply properties */
POWER_SUPPLY_PROP_STATUS,
POWER_SUPPLY_PROP_MODEL_NAME,
+ POWER_SUPPLY_PROP_ONLINE,
};
static int bq2415x_power_supply_get_property(struct power_supply *psy,
@@ -1017,6 +1018,16 @@ static int bq2415x_power_supply_get_property(struct power_supply *psy,
case POWER_SUPPLY_PROP_MODEL_NAME:
val->strval = bq->model;
break;
+ case POWER_SUPPLY_PROP_ONLINE:
+ /* VBUS is present for all charging and fault states,
+ * except the 'Ready' state.
+ */
+ ret = bq2415x_exec_command(bq, BQ2415X_CHARGE_STATUS);
+ if (ret < 0)
+ return ret;
+ else
+ val->intval = ret > 0;
+ break;
default:
return -EINVAL;
}
--
2.43.0

View file

@ -0,0 +1,33 @@
From 5ecf87e2f723fddf7437427678156288537b3525 Mon Sep 17 00:00:00 2001
From: Arthur Demchenkov <spinal.by@gmail.com>
Date: Wed, 28 Feb 2024 10:20:56 +0200
Subject: [PATCH] ARM: dts: n900: set charge current limit to 950mA
The vendor kernel used 950mA as the default. The same value works fine on
the mainline Linux kernel, and has been tested extensively under Maemo
Leste [1] and postmarketOS, who have been using it for a number of years.
[1] https://github.com/maemo-leste/n9xx-linux/commit/fbc4ce7a84e59215914a8981afe918002b191493
Signed-off-by: Arthur Demchenkov <spinal.by@gmail.com>
Signed-off-by: Sicelo A. Mhlongo <absicsz@gmail.com>
---
arch/arm/boot/dts/ti/omap/omap3-n900.dts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm/boot/dts/ti/omap/omap3-n900.dts b/arch/arm/boot/dts/ti/omap/omap3-n900.dts
index d33485341251..07c5b963af78 100644
--- a/arch/arm/boot/dts/ti/omap/omap3-n900.dts
+++ b/arch/arm/boot/dts/ti/omap/omap3-n900.dts
@@ -754,7 +754,7 @@ bq24150a: bq24150a@6b {
ti,current-limit = <100>;
ti,weak-battery-voltage = <3400>;
ti,battery-regulation-voltage = <4200>;
- ti,charge-current = <650>;
+ ti,charge-current = <950>;
ti,termination-current = <100>;
ti,resistor-sense = <68>;
--
2.43.0

View file

@ -4,7 +4,7 @@
pkgname=linux-postmarketos-omap
pkgver=6.6.3
pkgrel=1
pkgrel=2
pkgdesc="Mainline kernel fork for OMAP devices"
arch="armv7"
url="https://kernel.org/"
@ -38,11 +38,14 @@ source="
0004-arm-dts-Add-espresso10-support.patch
0005-Add-TWL6030-power-driver-with-minimal-support-for-power-off.patch
0006-Add-TWL6030-power-button-support-to-twl-pwrbutton.patch
0007-power-supply-bq27xxx-Report-charge-full-state-correc.patch
0008-hsi-ssi_port-force-pio-path.patch
0009-n900-dts-volume-keys.patch
0010-ARM-dts-disable-twl-off-idle-configuration-for-N900.patch
0011-bq27xxx_battery-map-edv1-to-low-battery-capacity.patch
0012-bq27xxx_battery-add-voltage-based-capacity-estimatio.patch
0013-power-supply-bq2415x_charger-report-online-status.patch
0014-ARM-dts-n900-set-charge-current-limit-to-950mA.patch
"
builddir="$srcdir/linux-$_kernver"
replaces="linux-samsung-espresso3g linux-nokia-n900"
@ -80,9 +83,12 @@ fe4307a6af41913a7e5d59288b563865116797d3272e0570faff4532e198831e764e0067f53afdd3
f0bb41630d8e08adcffa433f3c82047e8787c96b7cc7301eb80bf5e5298010c136cd10c756278fb2331d66dde33d6a13128420f5af022b117f9e3ddb23070934 0004-arm-dts-Add-espresso10-support.patch
9dc84421cbc2ea7c2c37847d8704ff46dd4a485485bfa4a671167fdef4ac6f53a4e8f787aa774f3748299c374e7c7dc5d36fd4ba9b1a1a9697e0526f2bf3ece4 0005-Add-TWL6030-power-driver-with-minimal-support-for-power-off.patch
63d3030006c8af3cbba6967cf4cce87c80992f98f80205a9fac3714a295ce9dd706515252b8ab07d147b315769d856ba9ba435e365caac106ed1ca84b5f7876c 0006-Add-TWL6030-power-button-support-to-twl-pwrbutton.patch
be04653f0eb35e6abb5f9a288dbe82da9d9c6f8e7995c49e42436043dc71091b25513add986499abfdb0bb0c4f1e89b95eb95245be2e704dda13dd8093d97bf6 0007-power-supply-bq27xxx-Report-charge-full-state-correc.patch
c3af9715b3559c2d593f4fcfa078730722c7deeec132c5b83e085ff4d9815d85ef349384097c580efe1bbc37c60f42e18ef559f0abccfe236080670e4403fa77 0008-hsi-ssi_port-force-pio-path.patch
b98ce806b3d5a0122086e4c9670639174470ff6d29851c60258cc5d699ce9a479dbf4996b24299fc075d25e9fe8f6b1250fafdff742deea0ddeaf53d342a9d72 0009-n900-dts-volume-keys.patch
66abb5548910ad369608b08200f5835d5a8526c04cc3617221ef546f3e3d22cd944db91dc6727a5c26a102b24d8ef1306ea01254c9c382759afced91b31747ef 0010-ARM-dts-disable-twl-off-idle-configuration-for-N900.patch
6680b264db0c992826f9da0078256ba20ffae3de26a77978106b94499d96e72ed90d9a35bb42be38bae1e798e7ddf068e3c5e7fe63462b3bbad5031195622192 0011-bq27xxx_battery-map-edv1-to-low-battery-capacity.patch
cd91f0bb59e466c517b498a549357325be884bb1884986e593fef905a6210872024e0cab179df03833dfc6e8d1221441fa384466ae8227d82f6e70b22fce655c 0012-bq27xxx_battery-add-voltage-based-capacity-estimatio.patch
0dc58fa43f760b5601e5eace815ef8fb37f38cb6130a7997514dc92c1785ca5ee5eb104042999f7ba026166723981a0d87e37dfef4e9081d2c158fe9f0951a6a 0013-power-supply-bq2415x_charger-report-online-status.patch
a11493d762b8f1ee90384e1d2baba7c6b7b37f4c11a8e6a876c1476de52b44a8f5a93db2bcd0fe68bb7e91dd54c76396b46727f8e94fc4aad1754feed3822061 0014-ARM-dts-n900-set-charge-current-limit-to-950mA.patch
"