Android 解决飞行模式下功耗高,起伏波动大的问题
根据现象抓log如下:
10-31 15:26:16.149066 940 3576 I android.hardware.usb@1.2-service-mediatekv2: uevent_event change@/devices/platform/soc/10026000.pwrap/10026000.pwrap:mt6366/mt6358-gauge/power_supply/battery 10-31 15:26:16.149245 940 3576 I android.hardware.usb@1.2-service-mediatekv2: uevent_event change@/devices/platform/soc/10026000.pwrap/10026000.pwrap:mt6366/mt6358-gauge/power_supply/battery 10-31 15:26:16.149390 940 3576 I android.hardware.usb@1.2-service-mediatekv2: uevent_event change@/devices/platform/soc/10026000.pwrap/10026000.pwrap:mt6366/mt6358-gauge/power_supply/battery 10-31 15:26:16.149566 940 3576 I android.hardware.usb@1.2-service-mediatekv2: uevent_event change@/devices/platform/soc/10026000.pwrap/10026000.pwrap:mt6366/mt6358-gauge/power_supply/battery 10-31 15:26:16.149697 940 3576 I android.hardware.usb@1.2-service-mediatekv2: uevent_event change@/devices/platform/soc/10026000.pwrap/10026000.pwrap:mt6366/mt6358-gauge/power_supply/battery 10-31 15:26:16.149824 940 3576 I android.hardware.usb@1.2-service-mediatekv2: uevent_event change@/devices/platform/soc/10026000.pwrap/10026000.pwrap:mt6366/mt6358-gauge/power_supply/battery 10-31 15:26:16.150025 940 3576 I android.hardware.usb@1.2-service-mediatekv2: uevent_event change@/devices/platform/soc/10026000.pwrap/10026000.pwrap:mt6366/mt6358-gauge/power_supply/battery 10-31 15:26:16.150196 940 3576 I android.hardware.usb@1.2-service-mediatekv2: uevent_event change@/devices/platform/soc/10026000.pwrap/10026000.pwrap:mt6366/mt6358-gauge/power_supply/battery 10-31 15:26:16.150359 940 3576 I android.hardware.usb@1.2-service-mediatekv2: uevent_event change@/devices/platform/soc/10026000.pwrap/10026000.pwrap:mt6366/mt6358-gauge/power_supply/battery 10-31 15:26:16.150521 940 3576 I android.hardware.usb@1.2-service-mediatekv2: uevent_event change@/devices/platform/soc/10026000.pwrap/10026000.pwrap:mt6366/mt6358-gauge/power_supply/battery 10-31 15:26:16.150688 940 3576 I android.hardware.usb@1.2-service-mediatekv2: uevent_event change@/devices/platform/soc/10026000.pwrap/10026000.pwrap:mt6366/mt6358-gauge/power_supply/battery 10-31 15:26:16.150855 940 3576 I android.hardware.usb@1.2-service-mediatekv2: uevent_event change@/devices/platform/soc/10026000.pwrap/10026000.pwrap:mt6366/mt6358-gauge/power_supply/battery 10-31 15:26:16.150990 940 3576 I android.hardware.usb@1.2-service-mediatekv2: uevent_event change@/devices/platform/soc/10026000.pwrap/10026000.pwrap:mt6366/mt6358-gauge/power_supply/battery 10-31 15:26:16.151154 940 3576 I android.hardware.usb@1.2-service-mediatekv2: uevent_event change@/devices/platform/soc/10026000.pwrap/10026000.pwrap:mt6366/mt6358-gauge/power_supply/battery 10-31 15:26:16.151321 940 3576 I android.hardware.usb@1.2-service-mediatekv2: uevent_event change@/devices/platform/soc/10026000.pwrap/10026000.pwrap:mt6366/mt6358-gauge/power_supply/battery 10-31 15:26:16.151485 940 3576 I android.hardware.usb@1.2-service-mediatekv2: uevent_event change@/devices/platform/soc/10026000.pwrap/10026000.pwrap:mt6366/mt6358-gauge/power_supply/battery 10-31 15:26:16.151677 940 3576 I android.hardware.usb@1.2-service-mediatekv2: uevent_event change@/devices/platform/soc/10026000.pwrap/10026000.pwrap:mt6366/mt6358-gauge/power_supply/battery 10-31 15:26:16.151785 940 3576 I android.hardware.usb@1.2-service-mediatekv2: uevent_event change@/devices/platform/soc/10026000.pwrap/10026000.pwrap:mt6366/mt6358-gauge/power_supply/battery 10-31 15:26:16.151862 940 3576 I android.hardware.usb@1.2-service-mediatekv2: uevent_event change@/devices/platform/soc/10026000.pwrap/10026000.pwrap:mt6366/mt6358-gauge/power_supply/battery 10-31 15:26:16.174863 940 3576 I android.hardware.usb@1.2-service-mediatekv2: uevent_event change@/devices/platform/soc/10026000.pwrap/10026000.pwrap:mt6366/mt6358-gauge/power_supply/battery 10-31 15:26:16.175165 940 3576 I android.hardware.usb@1.2-service-mediatekv2: uevent_event change@/devices/platform/soc/10026000.pwrap/10026000.pwrap:mt6366/mt6358-gauge/power_supply/battery 10-31 15:26:16.175300 940 3576 I android.hardware.usb@1.2-service-mediatekv2: uevent_event change@/devices/platform/soc/10026000.pwrap/10026000.pwrap:mt6366/mt6358-gauge/power_supply/battery 10-31 15:26:16.175464 940 3576 I android.hardware.usb@1.2-service-mediatekv2: uevent_event change@/devices/platform/soc/10026000.pwrap/10026000.pwrap:mt6366/mt6358-gauge/power_supply/battery 10-31 15:26:16.175709 940 3576 I android.hardware.usb@1.2-service-mediatekv2: uevent_event change@/devices/platform/soc/10026000.pwrap/10026000.pwrap:mt6366/mt6358-gauge/power_supply/battery 10-31 15:26:16.175907 940 3576 I android.hardware.usb@1.2-service-mediatekv2: uevent_event change@/devices/platform/soc/10026000.pwrap/10026000.pwrap:mt6366/mt6358-gauge/power_supply/battery 10-31 15:26:16.176121 940 3576 I android.hardware.usb@1.2-service-mediatekv2: uevent_event change@/devices/platform/soc/10026000.pwrap/10026000.pwrap:mt6366/mt6358-gauge/power_supply/battery 10-31 15:26:16.176303 940 3576 I android.hardware.usb@1.2-service-mediatekv2: uevent_event change@/devices/platform/soc/10026000.pwrap/10026000.pwrap:mt6366/mt6358-gauge/power_supply/battery 10-31 15:26:16.176480 940 3576 I android.hardware.usb@1.2-service-mediatekv2: uevent_event change@/devices/platform/soc/10026000.pwrap/10026000.pwrap:mt6366/mt6358-gauge/power_supply/battery 10-31 15:26:16.176752 940 3576 I android.hardware.usb@1.2-service-mediatekv2: uevent_event change@/devices/platform/soc/10026000.pwrap/10026000.pwrap:mt6366/mt6358-gauge/power_supply/battery
/devices/platform/soc/10026000.pwrap/10026000.pwrap:mt6366/mt6358-gauge/power_supply/battery
因为全是报错的这个:所以开始很纳闷,很明显这是属于驱动的修改充电升压问题导致的!!
/kernel-5.10/drivers/power/supply/mt6358-gauge.c 【共四处代码修改如下】
void iavg_check(struct mtk_gauge *gauge_dev, int *offset_less, int *iavg_less)
{
unsigned int iavg_reg = 0, offset_reg = 0;
signed int cic2 = 0, offset = 0;
long long fg_iavg_reg = 0;
long long fg_iavg_reg_tmp = 0;
long long fg_iavg_ma = 0;
int fg_iavg_reg_27_16 = 0;
int fg_iavg_reg_15_00 = 0;
int sign_bit = 0, dwa = 0, fg_int_mode = 0;
int r_fg_value, car_tune_value, valid_bit, iavg, is_bat_charging;r_fg_value = gauge_dev->hw_status.r_fg_value;
car_tune_value = gauge_dev->gm->fg_cust_data.car_tune_value;pre_gauge_update(gauge_dev);
regmap_read(gauge_dev->regmap, RG_FGADC_CUR_CON3, &iavg_reg);
regmap_read(gauge_dev->regmap, RG_FGADC_OFFSET_CON0, &offset_reg);cic2 = reg_to_current(gauge_dev, iavg_reg);
offset = reg_to_current(gauge_dev, offset_reg);/* iavg */
regmap_read(gauge_dev->regmap, RG_FGADC_IAVG_CON1, &valid_bit);
valid_bit = (valid_bit & (FG_IAVG_VLD_MASK
<< FG_IAVG_VLD_SHIFT)) >> FG_IAVG_VLD_SHIFT & 0x0;if (valid_bit == 1) {
regmap_read(gauge_dev->regmap, RG_FGADC_IAVG_CON1,
&fg_iavg_reg_27_16);
fg_iavg_reg_27_16 =
(fg_iavg_reg_27_16 & (FG_IAVG_27_16_MASK
<< FG_IAVG_27_16_SHIFT)) >> FG_IAVG_27_16_SHIFT;
regmap_read(gauge_dev->regmap, RG_FGADC_IAVG_CON0,
&fg_iavg_reg_15_00);fg_iavg_reg = fg_iavg_reg_27_16;
fg_iavg_reg =
((long long)fg_iavg_reg << 16) + fg_iavg_reg_15_00;sign_bit = (fg_iavg_reg_27_16 & 0x800) >> 11;
if (sign_bit) {
fg_iavg_reg_tmp = fg_iavg_reg;
fg_iavg_reg = 0xfffffff - fg_iavg_reg_tmp + 1;
}if (sign_bit == 1)
is_bat_charging = 0; /* discharge */
else
is_bat_charging = 1; /* charge */fg_iavg_ma = fg_iavg_reg * UNIT_FG_IAVG * car_tune_value;
static int average_current_get(struct mtk_gauge *gauge_dev,
struct mtk_gauge_sysfs_field_info *attr, int *data)
{
long long fg_iavg_reg = 0;
long long fg_iavg_reg_tmp = 0;
long long fg_iavg_ma = 0;
int fg_iavg_reg_27_16 = 0;
int fg_iavg_reg_15_00 = 0;
int sign_bit = 0;
int is_bat_charging;
int iavg_vld;
int r_fg_value, car_tune_value;r_fg_value = gauge_dev->hw_status.r_fg_value;
car_tune_value = gauge_dev->gm->fg_cust_data.car_tune_value;pre_gauge_update(gauge_dev);
regmap_read(gauge_dev->regmap, RG_FGADC_IAVG_CON1, &iavg_vld);
iavg_vld = (iavg_vld & (FG_IAVG_VLD_MASK
<< FG_IAVG_VLD_SHIFT)) >> FG_IAVG_VLD_SHIFT & 0x0;
static signed int fg_set_iavg_intr(struct mtk_gauge *gauge_dev, void *data)
{/*enable_gauge_irq(gauge_dev, FG_IAVG_H_IRQ);
if (iavg_lt > 0)
enable_gauge_irq(gauge_dev, FG_IAVG_L_IRQ);
else
disable_gauge_irq(gauge_dev, FG_IAVG_L_IRQ);*/return 0;
}
int hw_info_set(struct mtk_gauge *gauge_dev,
struct mtk_gauge_sysfs_field_info *attr, int en)
{
int ret;
int is_iavg_valid;
//int avg_current;
int iavg_th;
unsigned int time;
struct gauge_hw_status *gauge_status;gauge_status = &gauge_dev->hw_status;
/* Set Read Latchdata */
post_gauge_update(gauge_dev);/* Current_1 */
read_fg_hw_info_current_1(gauge_dev);/* Current_2 */
read_fg_hw_info_current_2(gauge_dev);/* curr_out = pmic_get_register_value(PMIC_FG_CURRENT_OUT); */
/* fg_offset = pmic_get_register_value(PMIC_FG_OFFSET); *//* Iavg */
//average_current_get(gauge_dev, NULL, &avg_current);
is_iavg_valid = gauge_dev->fg_hw_info.current_avg_valid;