Implement 0012 72h standby battery optimizations and initramfs depmod hook

- Add patches/kernel/0012-msm8909-standby-wifi-wcd-panel-ldo-bms.patch, rebuild affected kernel/module artifacts and all six device DTS/DTB files (msm8916-wcd-analog s2/bias gating, wcn36xx offload_sync_work and healthy-RSSI screen_off_offload scan short-circuit, pm8916_bms_vm screen_off FORCE_S3 OCV mode, panel-mipi-dbi dc/reset low on blank, spi-qup runtime PM sleep pinctrl, PM8909 l1/l4 LDO seeding, and sdhci-msm vmmc/vqmmc set_load with regulator-allow-set-load on l8/l12), and switch msm8905-cam from direct APSS SPMI LDO6/LDO17 writes to RPM regulator consumer voting.

- Update standby power policy and compiled C daemons (WIFI_LISTEN_INTERVAL=8, WIFI_STANDBY_RAT=gsm with CS verification and fallback, 10-bananarchy-dpm.sh wifi-up/unpark-rat dispatch, 25 s boot QRTR wait and QMI DMS online recovery, pm8916_bms_vm screen_off sync, bananarchy-run-aligned dark-screen skip, bananarchy-dsds --sig-hysteresis, bananarchy-cover-idle wake_blank_timeout = 8, and scripts/test-standby-power-policy.py).

- Add overlay/rootfs/etc/boot-deploy/hooks/10-initramfs-depmod.sh to run depmod -b per staged initramfs cpio archive and eliminate Stage 2 udevd missing-module boot console errors, enforce .ko.zst-only module installs in apply-bananarchy-overlay.sh, stage Alpine 3.24 /usr/lib/{libz,libcrypto}.so* in rebuild-image.sh chroot with failure cleanup, and add initramfs cpio guards plus verified image hashes in scripts/check-rebuild.sh.

- Document all changes under Unreleased in CHANGELOG.md and synchronize AGENTS.md, MANUAL.md, and BATTERY-OPTIMIZATION-ANALYSIS.md.
This commit is contained in:
Luxferre committed 2026-11-15 14:46:50 +02:00
1 parent 9700949b28
commit fc5c4282f5
67 files changed
+67482 -65598

No files matched your search

+143 -40
View File
@@ -21,6 +21,7 @@
#include <linux/platform_device.h>
#include <linux/poll.h>
#include <linux/regmap.h>
#include <linux/regulator/consumer.h>
#include <linux/slab.h>
#include <linux/videodev2.h>
#include <linux/vmalloc.h>
@@ -51,11 +52,6 @@
#define CAM_OUT_FRAME_BYTES (CAM_OUT_STRIDE * CAM_OUT_HEIGHT)
#define CAM_MAX_MMAP_BUFS 4U
/* PM8909 USID 1 LDO6 (1.8V VIO/CSI) and LDO17 (2.85V VANA) enable registers */
#define PM8909_LDO6_EN_CTL 0x4546U
#define PM8909_LDO17_EN_CTL 0x5046U
#define PM8909_REG_EN_BIT 0x80U
/* PM8909 USID 1 WCD analog codec micbias1 (2.8V) and earpiece PA (+6 dB) */
#define PM8909_CDC_A_MICB_1_VAL 0xf141U
#define PM8909_CDC_A_RX_EAR_CTL 0xf1c0U
@@ -160,6 +156,8 @@ struct msm8905_cam_dev {
void __iomem *camss_base;
void __iomem *vbif_base;
struct regmap *usid1_regmap;
struct regulator *vdd_l6;
struct regulator *vdd_l17;
u8 *raw_dma_buf;
dma_addr_t raw_dma_phys;
@@ -172,6 +170,12 @@ struct msm8905_cam_dev {
bool streaming;
bool hw_initialized;
bool rotate_180;
bool l6_enabled;
bool l17_enabled;
bool spmi_saved;
bool micb1_val_saved;
u32 saved_ear_ctl;
u32 saved_micb1_val;
};
static struct msm8905_cam_dev *g_cam;
@@ -401,10 +405,114 @@ static void msm8905_cam_enable_clocks(struct msm8905_cam_dev *cam)
}
}
static void msm8905_cam_hw_deinit(struct msm8905_cam_dev *cam)
static void msm8905_cam_ensure_regulators(struct msm8905_cam_dev *cam)
{
struct regulator *reg;
if (!cam->vdd_l6) {
reg = regulator_get_optional(&cam->pdev->dev, "l6");
if (!IS_ERR(reg))
cam->vdd_l6 = reg;
}
if (!cam->vdd_l17) {
reg = regulator_get_optional(&cam->pdev->dev, "l17");
if (!IS_ERR(reg))
cam->vdd_l17 = reg;
}
}
static int msm8905_cam_regulators_enable(struct msm8905_cam_dev *cam)
{
int ret;
msm8905_cam_ensure_regulators(cam);
if (cam->vdd_l6 && !cam->l6_enabled) {
ret = regulator_enable(cam->vdd_l6);
if (ret)
return ret;
cam->l6_enabled = true;
}
if (cam->vdd_l17 && !cam->l17_enabled) {
ret = regulator_enable(cam->vdd_l17);
if (ret) {
if (cam->l6_enabled) {
regulator_disable(cam->vdd_l6);
cam->l6_enabled = false;
}
return ret;
}
cam->l17_enabled = true;
}
return 0;
}
static void msm8905_cam_regulators_disable(struct msm8905_cam_dev *cam)
{
if (cam->vdd_l17 && cam->l17_enabled) {
regulator_disable(cam->vdd_l17);
cam->l17_enabled = false;
}
if (cam->vdd_l6 && cam->l6_enabled) {
regulator_disable(cam->vdd_l6);
cam->l6_enabled = false;
}
}
static void msm8905_cam_spmi_restore(struct msm8905_cam_dev *cam)
{
if (!cam->usid1_regmap || !cam->spmi_saved)
return;
if (cam->micb1_val_saved) {
regmap_write(cam->usid1_regmap, PM8909_CDC_A_MICB_1_VAL,
cam->saved_micb1_val);
cam->micb1_val_saved = false;
}
regmap_update_bits(cam->usid1_regmap, PM8909_CDC_A_RX_EAR_CTL,
0x20U, cam->saved_ear_ctl);
cam->spmi_saved = false;
}
/* Shared power-down path for both hw_deinit and early hw_init failure */
static void msm8905_cam_hw_teardown_common(struct msm8905_cam_dev *cam)
{
ssize_t i;
/* Place sensor in hardware power-down and disable MCLK0 output */
cam_gpio_out(cam, GPIO_CAM_RESET, false);
cam_gpio_out(cam, GPIO_CAM_STANDBY, false);
cam_gpio_out(cam, GPIO_CAM_VDIG, false);
cam_gpio_cfg(cam, GPIO_CAM_MCLK0, 0x0001U);
/* Gate CAMSS branch clocks in reverse order */
for (i = (ssize_t)ARRAY_SIZE(camss_cbcr_offsets) - 1; i >= 0; i--) {
u32 off = camss_cbcr_offsets[i];
cam_w32(cam->gcc_base, off, cam_r32(cam->gcc_base, off) & ~1U);
}
wmb();
/* Gate CAMSS RCG roots (MCLK0 and CSI/VFE RCGs) */
cam_w32(cam->gcc_base, 0x52000U, 0x0U);
cam_w32(cam->gcc_base, 0x4e000U, 0x0U);
cam_w32(cam->gcc_base, 0x4f020U, 0x0U);
cam_w32(cam->gcc_base, 0x4e020U, 0x0U);
cam_w32(cam->gcc_base, 0x58000U, 0x0U);
cam_w32(cam->gcc_base, 0x5a000U, 0x0U);
/* Release SMMU vote clocks and power down VFE GDSC */
cam_w32(cam->gcc_base, 0x4500cU, cam_r32(cam->gcc_base, 0x4500cU) & ~0x3202U);
cam_w32(cam->gcc_base, 0x58034U, cam_r32(cam->gcc_base, 0x58034U) | 1U);
wmb();
msm8905_cam_spmi_restore(cam);
msm8905_cam_regulators_disable(cam);
cam->hw_initialized = false;
cam->streaming = false;
}
static void msm8905_cam_hw_deinit(struct msm8905_cam_dev *cam)
{
if (!cam->hw_initialized)
return;
@@ -414,34 +522,8 @@ static void msm8905_cam_hw_deinit(struct msm8905_cam_dev *cam)
gc23xx_stream_off(cam);
usleep_range(600, 900);
/* 2. Place sensor in hardware power-down and disable MCLK0 output */
cam_gpio_out(cam, GPIO_CAM_RESET, false);
cam_gpio_out(cam, GPIO_CAM_STANDBY, false);
cam_gpio_out(cam, GPIO_CAM_VDIG, false);
cam_gpio_cfg(cam, GPIO_CAM_MCLK0, 0x0001U);
/* 3. Gate CAMSS branch clocks in reverse order */
for (i = (ssize_t)ARRAY_SIZE(camss_cbcr_offsets) - 1; i >= 0; i--) {
u32 off = camss_cbcr_offsets[i];
cam_w32(cam->gcc_base, off, cam_r32(cam->gcc_base, off) & ~1U);
}
wmb();
/* 4. Gate CAMSS RCG roots (MCLK0 and CSI/VFE RCGs) */
cam_w32(cam->gcc_base, 0x52000U, 0x0U);
cam_w32(cam->gcc_base, 0x4e000U, 0x0U);
cam_w32(cam->gcc_base, 0x4f020U, 0x0U);
cam_w32(cam->gcc_base, 0x4e020U, 0x0U);
cam_w32(cam->gcc_base, 0x58000U, 0x0U);
cam_w32(cam->gcc_base, 0x5a000U, 0x0U);
/* 5. Release SMMU vote clocks and power down VFE GDSC */
cam_w32(cam->gcc_base, 0x4500cU, cam_r32(cam->gcc_base, 0x4500cU) & ~0x3202U);
cam_w32(cam->gcc_base, 0x58034U, cam_r32(cam->gcc_base, 0x58034U) | 1U);
wmb();
cam->hw_initialized = false;
cam->streaming = false;
/* 2. Power down GPIOs, clocks, VFE GDSC, and RPM/SPMI regulators */
msm8905_cam_hw_teardown_common(cam);
}
static int msm8905_cam_hw_init(struct msm8905_cam_dev *cam)
@@ -449,22 +531,37 @@ static int msm8905_cam_hw_init(struct msm8905_cam_dev *cam)
size_t i;
u16 chip_id;
u32 r;
int ret;
if (cam->hw_initialized) {
msm8905_cam_enable_clocks(cam);
return 0;
}
/* 1. Ensure PM8909 LDO6 (1.8V) and LDO17 (2.85V) are enabled */
/* 1. Enable RPM-owned PM8909 LDO6 (1.8V) and LDO17 (2.85V) plus codec rails */
ret = msm8905_cam_regulators_enable(cam);
if (ret)
return ret;
if (cam->usid1_regmap) {
regmap_update_bits(cam->usid1_regmap, PM8909_LDO6_EN_CTL,
PM8909_REG_EN_BIT, PM8909_REG_EN_BIT);
regmap_update_bits(cam->usid1_regmap, PM8909_LDO17_EN_CTL,
PM8909_REG_EN_BIT, PM8909_REG_EN_BIT);
unsigned int val = 0;
cam->saved_ear_ctl =
(regmap_read(cam->usid1_regmap, PM8909_CDC_A_RX_EAR_CTL, &val) == 0)
? (val & 0x20U)
: 0U;
if (regmap_read(cam->usid1_regmap, PM8909_CDC_A_MICB_1_VAL, &val) == 0) {
cam->saved_micb1_val = val;
cam->micb1_val_saved = true;
} else {
cam->micb1_val_saved = false;
}
cam->spmi_saved = true;
regmap_write(cam->usid1_regmap, PM8909_CDC_A_MICB_1_VAL, 0x60U);
regmap_update_bits(cam->usid1_regmap, PM8909_CDC_A_RX_EAR_CTL, 0x20U, 0x20U);
usleep_range(2000, 3000);
}
usleep_range(2000, 3000);
/* 2. Power on VFE GDSC and SMMU vote clocks */
cam_w32(cam->gcc_base, 0x58034U, cam_r32(cam->gcc_base, 0x58034U) & ~1U);
@@ -502,6 +599,7 @@ static int msm8905_cam_hw_init(struct msm8905_cam_dev *cam)
dev_err(&cam->pdev->dev,
"GalaxyCore chip ID mismatch: 0x%04x (expected 0x2395/0x2385/0x2365)\n",
chip_id);
msm8905_cam_hw_teardown_common(cam);
return -ENODEV;
}
cam->chip_id = chip_id;
@@ -1213,6 +1311,11 @@ static void __exit msm8905_cam_exit(void)
video_unregister_device(&cam->vdev);
v4l2_device_unregister(&cam->v4l2_dev);
msm8905_cam_hw_deinit(cam);
msm8905_cam_regulators_disable(cam);
if (cam->vdd_l17)
regulator_put(cam->vdd_l17);
if (cam->vdd_l6)
regulator_put(cam->vdd_l6);
iounmap(cam->vbif_base);
iounmap(cam->camss_base);
iounmap(cam->tlmm_base);