From 82366a47ca4384d9af26bcc9bab0e2909977c6d5 Mon Sep 17 00:00:00 2001 From: Douglas Teles Date: Thu, 2 Apr 2026 16:25:47 -0300 Subject: [PATCH] Update .gitignore to include log and pdf files; refine RK3326 device tree for improved power management --- .gitignore | 2 + .../RK3326/patches/linux/000-rk3326-dts.patch | 57 +++++-------- .../linux/010-rk817-battery-calibration.patch | 83 ++++++------------- 3 files changed, 48 insertions(+), 94 deletions(-) diff --git a/.gitignore b/.gitignore index 30dbf4175f..ce82387c15 100644 --- a/.gitignore +++ b/.gitignore @@ -36,6 +36,8 @@ mkpkg-temp .DS_Store .directory Thumbs.db +*.log +*.pdf # temp scripts (debug/install helpers) fix-debug.sh diff --git a/projects/ArchR/devices/RK3326/patches/linux/000-rk3326-dts.patch b/projects/ArchR/devices/RK3326/patches/linux/000-rk3326-dts.patch index 4ca185902f..78c4e279a2 100644 --- a/projects/ArchR/devices/RK3326/patches/linux/000-rk3326-dts.patch +++ b/projects/ArchR/devices/RK3326/patches/linux/000-rk3326-dts.patch @@ -1,8 +1,6 @@ -diff --git a/arch/arm64/boot/dts/rockchip/px30.dtsi b/arch/arm64/boot/dts/rockchip/px30.dtsi -index 9137dd76e72c..882b91d8468d 100644 ---- a/arch/arm64/boot/dts/rockchip/px30.dtsi -+++ b/arch/arm64/boot/dts/rockchip/px30.dtsi -@@ -20,6 +20,7 @@ / { +--- a/arch/arm64/boot/dts/rockchip/px30.dtsi 2026-04-02 16:22:14.377470397 -0300 ++++ b/arch/arm64/boot/dts/rockchip/px30.dtsi 2026-04-02 16:22:14.378455687 -0300 +@@ -20,6 +20,7 @@ #size-cells = <2>; aliases { @@ -10,55 +8,42 @@ index 9137dd76e72c..882b91d8468d 100644 i2c0 = &i2c0; i2c1 = &i2c1; i2c2 = &i2c2; -@@ -113,32 +114,36 @@ cpu0_opp_table: opp-table-0 { +@@ -112,9 +113,10 @@ + cpu0_opp_table: opp-table-0 { compatible = "operating-points-v2"; opp-shared; + rockchip,avs = <1>; - + - opp-600000000 { - opp-hz = /bits/ 64 <600000000>; -- opp-microvolt = <950000 950000 1350000>; + opp-408000000 { + opp-hz = /bits/ 64 <408000000>; -+ opp-microvolt = <950000 950000 1350000>; + opp-microvolt = <950000 950000 1350000>; clock-latency-ns = <40000>; opp-suspend; - }; - opp-816000000 { - opp-hz = /bits/ 64 <816000000>; -- opp-microvolt = <1050000 1050000 1350000>; -+ opp-microvolt = <1050000 1050000 1350000>; - clock-latency-ns = <40000>; - }; - opp-1008000000 { - opp-hz = /bits/ 64 <1008000000>; +@@ -129,15 +131,16 @@ opp-microvolt = <1175000 1175000 1350000>; clock-latency-ns = <40000>; }; - opp-1200000000 { - opp-hz = /bits/ 64 <1200000000>; +- opp-1200000000 { +- opp-hz = /bits/ 64 <1200000000>; - opp-microvolt = <1300000 1300000 1350000>; -+ opp-microvolt = <1300000 1300000 1350000>; ++ opp-1416000000 { ++ opp-hz = /bits/ 64 <1416000000>; ++ opp-microvolt = <1350000 1350000 1350000>; clock-latency-ns = <40000>; }; - opp-1296000000 { - opp-hz = /bits/ 64 <1296000000>; -- opp-microvolt = <1350000 1350000 1350000>; -+ opp-1416000000 { -+ opp-hz = /bits/ 64 <1416000000>; -+ opp-microvolt = <1350000 1350000 1350000>; -+ clock-latency-ns = <40000>; -+ }; + opp-1512000000 { + opp-hz = /bits/ 64 <1512000000>; -+ opp-microvolt = <1350000 1350000 1350000>; + opp-microvolt = <1350000 1350000 1350000>; clock-latency-ns = <40000>; + turbo-mode; }; }; - arm-pmu { -@@ -348,6 +339,32 @@ power-domain@PX30_PD_GPU { +@@ -348,6 +351,32 @@ }; }; @@ -91,7 +76,7 @@ index 9137dd76e72c..882b91d8468d 100644 pmugrf: syscon@ff010000 { compatible = "rockchip,px30-pmugrf", "syscon", "simple-mfd"; reg = <0x0 0xff010000 0x0 0x1000>; -@@ -1065,21 +1082,13 @@ nfc: nand-controller@ff3b0000 { +@@ -1065,22 +1094,14 @@ gpu_opp_table: opp-table-1 { compatible = "operating-points-v2"; @@ -109,18 +94,18 @@ index 9137dd76e72c..882b91d8468d 100644 - }; - opp-480000000 { - opp-hz = /bits/ 64 <480000000>; -- opp-microvolt = <1125000>; + opp-560000000 { + opp-hz = /bits/ 64 <560000000>; -+ opp-microvolt = <1125000>; -+ }; + opp-microvolt = <1125000>; + }; + opp-600000000 { + opp-hz = /bits/ 64 <600000000>; + opp-microvolt = <1150000>; - }; ++ }; }; -@@ -1091,10 +1096,25 @@ gpu: gpu@ff400000 { + gpu: gpu@ff400000 { +@@ -1091,10 +1112,25 @@ ; interrupt-names = "job", "mmu", "gpu"; clocks = <&cru SCLK_GPU>; diff --git a/projects/ArchR/devices/RK3326/patches/linux/010-rk817-battery-calibration.patch b/projects/ArchR/devices/RK3326/patches/linux/010-rk817-battery-calibration.patch index f00cb6c328..5eb79a3dde 100644 --- a/projects/ArchR/devices/RK3326/patches/linux/010-rk817-battery-calibration.patch +++ b/projects/ArchR/devices/RK3326/patches/linux/010-rk817-battery-calibration.patch @@ -1,57 +1,23 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Chris Morgan -Date: Thu, 26 Sep 2024 09:43:45 -0500 -Subject: [PATCH] power: supply: rk817: fix battery calibration and suspend - -Backport of two upstream patches from kernel 6.13: - - bded860c3110 ("power: supply: rk817: stop updating info in suspend") - - 1e5335d00707 ("power: supply: rk817: Update battery capacity calibration") - -The battery monitoring thread reads incorrect voltage values during -suspend, causing the calibration function to erroneously recalibrate -the full charge capacity or set SOC to 0. This results in the battery -percentage rapidly dropping to 0% even when the battery is still -charged. - -Fix 1: Cancel the monitoring thread during suspend so stale readings -are not collected while the system sleeps. - -Fix 2: Add voltage sanity checks (2.7V-4.45V) to the calibration -function, guard against no-battery-present, remove the problematic -automatic FCC recalibration on empty battery, and make CHARGE_FULL -writable from userspace for degraded battery support. - -Signed-off-by: Chris Morgan ---- - drivers/power/supply/rk817_charger.c | 112 ++++++++++++++++++--------- - 1 file changed, 74 insertions(+), 38 deletions(-) - -diff --git a/drivers/power/supply/rk817_charger.c b/drivers/power/supply/rk817_charger.c ---- a/drivers/power/supply/rk817_charger.c -+++ b/drivers/power/supply/rk817_charger.c -@@ -240,9 +240,32 @@ static int rk817_record_battery_nvram_values(struct rk817_charger *charger) +--- a/drivers/power/supply/rk817_charger.c 2026-04-02 16:24:36.709878954 -0300 ++++ b/drivers/power/supply/rk817_charger.c 2026-04-02 16:24:36.710727282 -0300 +@@ -240,9 +240,27 @@ static int rk817_bat_calib_cap(struct rk817_charger *charger) { struct rk808 *rk808 = charger->rk808; - int tmp, charge_now, charge_now_adc, volt_avg; + int charge_now, charge_now_adc; u8 bulk_reg[4]; - + + /* Don't do anything if there's no battery. */ + if (!charger->battery_present) + return 0; + + /* + * When resuming from suspend, sometimes the voltage value would be -+ * incorrect. BSP would simply wait two seconds and try reading the -+ * values again. Do not do any sort of calibration activity when the -+ * reported value is incorrect. The next scheduled update of battery -+ * values should then return valid data and the driver can continue. -+ * Use 2.7v as the sanity value because per the datasheet the PMIC -+ * can in no way support a battery voltage lower than this. BSP only -+ * checked for values too low, but adding a check for values -+ * too high just in case; the PMIC can in no way support -+ * voltages above 4.45v. ++ * incorrect. Do not do any sort of calibration activity when the ++ * reported value is incorrect. Use 2.7v as the sanity value because ++ * per the datasheet the PMIC can in no way support a battery voltage ++ * lower than this, and 4.45v as the upper bound. + */ + if ((charger->volt_avg_uv < 2700000) || (charger->volt_avg_uv > 4450000)) { + dev_dbg(charger->dev, @@ -61,12 +27,12 @@ diff --git a/drivers/power/supply/rk817_charger.c b/drivers/power/supply/rk817_c + } + /* Calibrate the soc and fcc on a fully charged battery */ - + if (charger->charge_status == CHARGE_FINISH && (!charger->soc_cal)) { -@@ -304,51 +327,6 @@ static int rk817_bat_calib_cap(struct rk817_charger *charger) +@@ -304,51 +322,6 @@ } } - + - /* - * Calibrate the fully charged capacity when we previously had a full - * battery (soc_cal = 1) and are now empty (at or below minimum design @@ -113,12 +79,12 @@ diff --git a/drivers/power/supply/rk817_charger.c b/drivers/power/supply/rk817_c - } - rk817_record_battery_nvram_values(charger); - + return 0; -@@ -648,6 +626,24 @@ static irqreturn_t rk817_plug_out_isr(int irq, void *cg) +@@ -648,6 +621,24 @@ return IRQ_HANDLED; } - + +static int rk817_bat_set_prop(struct power_supply *ps, + enum power_supply_property prop, + const union power_supply_propval *val) @@ -140,10 +106,10 @@ diff --git a/drivers/power/supply/rk817_charger.c b/drivers/power/supply/rk817_c static enum power_supply_property rk817_bat_props[] = { POWER_SUPPLY_PROP_PRESENT, POWER_SUPPLY_PROP_STATUS, -@@ -673,12 +669,25 @@ static enum power_supply_property rk817_chg_props[] = { +@@ -673,12 +664,25 @@ POWER_SUPPLY_PROP_VOLTAGE_AVG, }; - + +static int rk817_bat_prop_writeable(struct power_supply *psy, + enum power_supply_property psp) +{ @@ -156,7 +122,8 @@ diff --git a/drivers/power/supply/rk817_charger.c b/drivers/power/supply/rk817_c +} + static const struct power_supply_desc rk817_bat_desc = { - .name = "battery", +- .name = "rk817-battery", ++ .name = "battery", .type = POWER_SUPPLY_TYPE_BATTERY, .properties = rk817_bat_props, + .property_is_writeable = rk817_bat_prop_writeable, @@ -164,12 +131,12 @@ diff --git a/drivers/power/supply/rk817_charger.c b/drivers/power/supply/rk817_c .get_property = rk817_bat_get_prop, + .set_property = rk817_bat_set_prop, }; - + static const struct power_supply_desc rk817_chg_desc = { -@@ -1202,6 +1211,15 @@ static int rk817_charger_probe(struct platform_device *pdev) +@@ -1202,6 +1206,15 @@ return 0; } - + +static int __maybe_unused rk817_suspend(struct device *dev) +{ + struct rk817_charger *charger = dev_get_drvdata(dev); @@ -181,13 +148,13 @@ diff --git a/drivers/power/supply/rk817_charger.c b/drivers/power/supply/rk817_c + static int __maybe_unused rk817_resume(struct device *dev) { - -@@ -1213,7 +1231,7 @@ static int __maybe_unused rk817_resume(struct device *dev) + +@@ -1213,7 +1226,7 @@ return 0; } - + -static SIMPLE_DEV_PM_OPS(rk817_charger_pm, NULL, rk817_resume); +static SIMPLE_DEV_PM_OPS(rk817_charger_pm, rk817_suspend, rk817_resume); - + static struct platform_driver rk817_charger_driver = { .probe = rk817_charger_probe,