1
1
mirror of https://github.com/NixOS/mobile-nixos.git synced 2024-12-18 05:21:47 +03:00
mobile-nixos/devices/asus-z00t/kernel/0003-qpnp-bms-shut-up.patch
2020-04-09 22:27:15 -04:00

484 lines
19 KiB
Diff

From 34384694159d1c1eaf76cd017dce6ceb87977d34 Mon Sep 17 00:00:00 2001
From: Samuel Dionne-Riel <samuel@dionne-riel.com>
Date: Thu, 9 Apr 2020 01:57:07 -0400
Subject: [PATCH 3/3] qpnp bms: shut up!
---
drivers/power/qpnp-vm-bms.c | 124 ++++++++++++++++++------------------
1 file changed, 62 insertions(+), 62 deletions(-)
diff --git a/drivers/power/qpnp-vm-bms.c b/drivers/power/qpnp-vm-bms.c
index f245b5a6018b5..2f983b55a45df 100644
--- a/drivers/power/qpnp-vm-bms.c
+++ b/drivers/power/qpnp-vm-bms.c
@@ -291,7 +291,7 @@ int get_driver_soc(void){
if(the_chip)
rc = the_chip->calculated_soc;
else
- printk("the_chip is not ready\n");
+ pr_debug("the_chip is not ready\n");
return rc;
}
@@ -1017,7 +1017,7 @@ static int lookup_soc_ocv(struct qpnp_bms_chip *chip, int ocv_uv, int batt_temp)
soc_acc = DIV_ROUND_CLOSEST(100 * (soc_ocv - soc_uuc),
(100 - soc_uuc));
- printk("fcc=%d acc=%d soc_final=%d soc_uuc=%d soc_acc=%d current_now=%d iavg_ma=%d\n",
+ pr_debug("fcc=%d acc=%d soc_final=%d soc_uuc=%d soc_acc=%d current_now=%d iavg_ma=%d\n",
fcc, acc, soc_final, soc_uuc,
soc_acc, chip->current_now / 1000, iavg_ma);
g_bms_fcc = fcc;
@@ -1036,7 +1036,7 @@ static int lookup_soc_ocv(struct qpnp_bms_chip *chip, int ocv_uv, int batt_temp)
soc_final = bound_soc(soc_final);
- printk("soc_final=%d soc_ocv=%d soc_cutoff=%d ocv_uv=%u batt_temp=%d\n",
+ pr_debug("soc_final=%d soc_ocv=%d soc_cutoff=%d ocv_uv=%u batt_temp=%d\n",
soc_final, soc_ocv, soc_cutoff, ocv_uv, batt_temp);
return soc_final;
@@ -1416,7 +1416,7 @@ static int scale_soc_while_chg(struct qpnp_bms_chip *chip, int chg_time_sec,
* value from prev_soc to the new soc based on a charge time
* weighted average
*/
- printk("cts=%d catch_up_sec=%d\n", chg_time_sec, catch_up_sec);
+ pr_debug("cts=%d catch_up_sec=%d\n", chg_time_sec, catch_up_sec);
if (catch_up_sec == 0)
return new_soc;
@@ -1427,7 +1427,7 @@ static int scale_soc_while_chg(struct qpnp_bms_chip *chip, int chg_time_sec,
+ chg_time_sec * new_soc;
scaled_soc = numerator / catch_up_sec;
- printk("cts=%d new_soc=%d prev_soc=%d scaled_soc=%d\n",
+ pr_debug("cts=%d new_soc=%d prev_soc=%d scaled_soc=%d\n",
chg_time_sec, new_soc, prev_soc, scaled_soc);
return scaled_soc;
@@ -1588,7 +1588,7 @@ int transition_cur(int init, int pass, bool chg){
if(chg == (pass < sec))
rc = init - 1;
else rc = init;
- printk("passing_time_sec:%d, cur_shift:%d\n",pass, rc);
+ pr_debug("passing_time_sec:%d, cur_shift:%d\n",pass, rc);
return rc;
}
@@ -1773,7 +1773,7 @@ static int mapping_for_full_status(int last_soc)
if (!batLow) {
if (result == 0) {
ASUSEvtlog("[BAT] Low Voltage\n");
- printk("[BAT] Low Voltage\n");
+ pr_debug("[BAT] Low Voltage\n");
power_supply_changed(&the_chip->bms_psy);
batLow = true;
}
@@ -1811,7 +1811,7 @@ static void calculate_catch_up_time(int soc, struct qpnp_bms_chip *chip, bool re
(soc - chip->last_soc)*num2*SOC_CATCHUP_SEC_PER_PERCENT/num;
else
chip->catch_up_time_sec = num2*SOC_CATCHUP_SEC_MAX/num;
- printk("CAT%s=%d\n",reduce?"(reduced)":"",chip->catch_up_time_sec);
+ pr_debug("CAT%s=%d\n",reduce?"(reduced)":"",chip->catch_up_time_sec);
}
@@ -1939,17 +1939,17 @@ static int report_vm_bms_soc(struct qpnp_bms_chip *chip)
check_recharge_condition(chip);
}
- printk("last_soc=%d calculated_soc=%d soc=%d time_since_last_change=%d\n",
+ pr_debug("last_soc=%d calculated_soc=%d soc=%d time_since_last_change=%d\n",
chip->last_soc, chip->calculated_soc,
soc, time_since_last_change_sec);
//BSP Ben do not report soc which is far too differ from shutdown_soc before boot_completed
if(boot_completed==0 && (!g_Charger_mode)){
- printk("%s:[bms]boot_completed not yet\n",__func__);
+ pr_debug("%s:[bms]boot_completed not yet\n",__func__);
if(chip->last_soc < 15 && chip->shutdown_soc_invalid ==0){
if(abs(chip->last_soc - chip->shutdown_soc) > 3){
- printk("%s:[bms]last_soc<%d> and shutdown_soc<%d> difference too large!\n",__func__,chip->last_soc,chip->shutdown_soc);
+ pr_debug("%s:[bms]last_soc<%d> and shutdown_soc<%d> difference too large!\n",__func__,chip->last_soc,chip->shutdown_soc);
if(chip->last_soc > chip->shutdown_soc)
{
chip->last_soc = chip->shutdown_soc + 3;
@@ -1961,9 +1961,9 @@ static int report_vm_bms_soc(struct qpnp_bms_chip *chip)
}
}
- //printk("%s:[bms]before mapping last_soc = <%d>\n",__func__,chip->last_soc);
+ //pr_debug("%s:[bms]before mapping last_soc = <%d>\n",__func__,chip->last_soc);
result_soc = mapping_for_full_status(chip->last_soc);
- printk("%s:[bms]Reported result_soc=%d\n",__func__ ,result_soc);
+ pr_debug("%s:[bms]Reported result_soc=%d\n",__func__ ,result_soc);
/*
* Backup the actual ocv (last_ocv_uv) and not the
* last_soc-interpolated ocv. This makes sure that
@@ -1990,7 +1990,7 @@ static int report_state_of_charge(struct qpnp_bms_chip *chip)
if(soc < 1 && boot_completed==0 && (!g_Charger_mode))
{
soc = 1;
- printk("boot_completed no yet, don't report batt level = 0\n");
+ pr_debug("boot_completed no yet, don't report batt level = 0\n");
}
mutex_unlock(&chip->last_soc_mutex);
@@ -2212,7 +2212,7 @@ static int calculate_soc_from_voltage(struct qpnp_bms_chip *chip)
}
chip->prev_voltage_based_soc = voltage_based_soc;
- printk("%s: vbat used = %duv, Calculated voltage based soc=%d\n", __func__, vbat_uv, voltage_based_soc);
+ pr_debug("%s: vbat used = %duv, Calculated voltage based soc=%d\n", __func__, vbat_uv, voltage_based_soc);
if (voltage_based_soc == 100)
if (chip->dt.cfg_report_charger_eoc)
@@ -2473,7 +2473,7 @@ static int qpnp_vm_bms_power_set_property(struct power_supply *psy,
case POWER_SUPPLY_PROP_VOLTAGE_OCV:
cancel_delayed_work_sync(&chip->monitor_soc_work);
chip->last_ocv_uv = val->intval;
- printk("%s: last_ocv_uv = %d\n", __FUNCTION__, chip->last_ocv_uv);
+ pr_debug("%s: last_ocv_uv = %d\n", __FUNCTION__, chip->last_ocv_uv);
schedule_delayed_work(&chip->monitor_soc_work, 0);
break;
case POWER_SUPPLY_PROP_HI_POWER:
@@ -2555,7 +2555,7 @@ static void batid_poweroff_work(struct work_struct *work)
if (chip->batt_pres_addr) {
rc = qpnp_read_wrapper(chip, &batt_pres,
chip->batt_pres_addr, 1);
- printk("batid_poweroff_works:%x\n",batt_pres);
+ pr_debug("batid_poweroff_works:%x\n",batt_pres);
if (!rc && ((batt_pres & 0x03) == 0x03))
present = true;
else
@@ -2565,7 +2565,7 @@ static void batid_poweroff_work(struct work_struct *work)
smb358_charging_toggle(FLAGS, false);
do_msm_poweroff();
}else
- printk("skip batid_poweroff_works:%d\n",present);
+ pr_debug("skip batid_poweroff_works:%d\n",present);
}
static void battery_insertion_check(struct qpnp_bms_chip *chip)
@@ -2574,18 +2574,18 @@ static void battery_insertion_check(struct qpnp_bms_chip *chip)
//BSP Ben shutdown when plug out battery
if (chip->battery_present != present) {
- printk("shadow_sts=%d status=%d\n",
+ pr_debug("shadow_sts=%d status=%d\n",
chip->battery_present, present);
if (chip->battery_present != -EINVAL) {
if (present) {
/* new battery inserted */
bms_new_battery_setup(chip);
setup_vbat_monitoring(chip);
- printk("New battery inserted!\n");
+ pr_debug("New battery inserted!\n");
} else {
/* battery removed */
//reset_vbat_monitoring(chip);
- printk("Battery removed\n");
+ pr_debug("Battery removed\n");
/* BSP Ben
* Shutdown when plug out batt
*/
@@ -2939,7 +2939,7 @@ static int read_shutdown_ocv_soc(struct qpnp_bms_chip *chip)
chip->base + BMS_SOC_REG, rc);
return -EINVAL;
}
- printk("stored_soc:%d\n",stored_soc);
+ pr_debug("stored_soc:%d\n",stored_soc);
if (!stored_soc || stored_soc == SOC_INVALID) {
chip->shutdown_soc = SOC_INVALID;
chip->shutdown_ocv = OCV_INVALID;
@@ -3003,12 +3003,12 @@ static void adjust_pon_ocv(struct qpnp_bms_chip *chip, int batt_temp)
die_temp = (int)result.physical / 100;
current_ma = interpolate_current_comp(die_temp);
delta_uv = rbatt_mohm * current_ma;
- printk("PON OCV changed from %d to %d pc=%d rbatt=%d current_ma=%d die_temp=%d batt_temp=%d delta_uv=%d\n",
+ pr_debug("PON OCV changed from %d to %d pc=%d rbatt=%d current_ma=%d die_temp=%d batt_temp=%d delta_uv=%d\n",
chip->last_ocv_uv, chip->last_ocv_uv + delta_uv, pc,
rbatt_mohm, current_ma, die_temp, batt_temp, delta_uv);
chip->last_ocv_uv += delta_uv;
- printk("%s: last_ocv_uv = %d\n", __FUNCTION__, chip->last_ocv_uv);
+ pr_debug("%s: last_ocv_uv = %d\n", __FUNCTION__, chip->last_ocv_uv);
}
}
@@ -3051,18 +3051,18 @@ static void compare_and_choose(struct qpnp_bms_chip *chip,int ocv, int soc,int t
//read reg:PON_PON_REASON1
rc = spmi_ext_register_readl(chip->spmi->ctrl, chip->spmi->sid,
0x00000808, &reg, 1);
- printk("reg:%d\n",reg);
+ pr_debug("reg:%d\n",reg);
if(reg==chgm_by_ac || reg== reboot_with_cable ||
reg==reboot_from_chgm || chip->warm_reset){
- printk("est ocv is better\n");
+ pr_debug("est ocv is better\n");
chip->last_ocv_uv = ocv;
chip->calculated_soc = soc;
return;
}
else if(reg==reboot_no_cable || reg==pwr_on_no_cable || reg==reboot_smpl ||
reg==reboot_rtc){
- printk("hw ocv is better\n");
+ pr_debug("hw ocv is better\n");
return;
}
@@ -3070,10 +3070,10 @@ static void compare_and_choose(struct qpnp_bms_chip *chip,int ocv, int soc,int t
if(abs(chip->calculated_soc - soc) > thd){
chip->last_ocv_uv = ocv;
chip->calculated_soc = soc;
- printk("est. v.s. hw --> est ocv\n");
+ pr_debug("est. v.s. hw --> est ocv\n");
}
else{
- printk("est. v.s. hw --> hw ocv\n");
+ pr_debug("est. v.s. hw --> hw ocv\n");
}
}
@@ -3085,18 +3085,18 @@ static void using_shutdown_data(struct qpnp_bms_chip *chip, int batt_temp){
/*BSP david:re-calculate soc to prevent state be overwrited*/
chip->calculated_soc = lookup_soc_ocv(chip, chip->last_ocv_uv, batt_temp);
g_mapping_state = BMS_FULL;
- printk("%s: set mapping state to full\n", __func__);
+ pr_debug("%s: set mapping state to full\n", __func__);
}
- printk("using shutdown ocv\n");
+ pr_debug("using shutdown ocv\n");
}
static void whether_apply_shutdown_data(struct qpnp_bms_chip *chip, int batt_temp, int thd){
if(abs(chip->calculated_soc - chip->shutdown_soc) < thd){
- printk("soc delta < adopt_shutdown_soc_thd:%d\n",thd);
+ pr_debug("soc delta < adopt_shutdown_soc_thd:%d\n",thd);
using_shutdown_data(chip, batt_temp);
}
else
- printk("using pon for thd:%d, take it as new battery\n",thd);
+ pr_debug("using pon for thd:%d, take it as new battery\n",thd);
}
static void check_est_region_and_compare(struct qpnp_bms_chip *chip, int batt_temp){
@@ -3114,18 +3114,18 @@ static int calculate_initial_soc(struct qpnp_bms_chip *chip)
spmi_ext_register_readl(chip->spmi->ctrl, chip->spmi->sid,
0x00000808, &reg, 1);
- printk("reg:%d\n",reg);
+ pr_debug("reg:%d\n",reg);
//inok = inok_status();
- //printk("inok_status: %s\n",inok? "HIGH":"LOW");
+ //pr_debug("inok_status: %s\n",inok? "HIGH":"LOW");
//----Add power off reason
spmi_ext_register_readl(chip->spmi->ctrl, chip->spmi->sid,
0x0000080C, &reg, 1);
- printk("Poff_Reason1:%x\n",reg);
+ pr_debug("Poff_Reason1:%x\n",reg);
spmi_ext_register_readl(chip->spmi->ctrl, chip->spmi->sid,
0x0000080D, &reg, 1);
- printk("Poff_Reason2:%x\n",reg);
+ pr_debug("Poff_Reason2:%x\n",reg);
//---------------------
rc = get_batt_therm(chip, &batt_temp);
@@ -3144,7 +3144,7 @@ static int calculate_initial_soc(struct qpnp_bms_chip *chip)
if (chip->workaround_flag & WRKARND_PON_OCV_COMP)
adjust_pon_ocv(chip, batt_temp);
- printk("HW OCV INFO:\n");
+ pr_debug("HW OCV INFO:\n");
chip->calculated_soc = lookup_soc_ocv(chip,chip->last_ocv_uv, batt_temp);
rc = read_shutdown_ocv_soc(chip);
@@ -3158,11 +3158,11 @@ static int calculate_initial_soc(struct qpnp_bms_chip *chip)
}
if(inok){
est_ocv += est_without_cable_compensation_mv;
- printk("compensate est_ocv for %d mv\n",
+ pr_debug("compensate est_ocv for %d mv\n",
est_without_cable_compensation_mv);
}
- printk("est. OCV INFO:\n");
+ pr_debug("est. OCV INFO:\n");
est_soc = lookup_soc_ocv(chip, est_ocv, batt_temp);
compare_and_choose(chip,est_ocv, est_soc, HW_and_est_thd);
@@ -3174,11 +3174,11 @@ static int calculate_initial_soc(struct qpnp_bms_chip *chip)
using_shutdown_data(chip, batt_temp);
}
else if(reg& chgm_by_ac){
- printk("case for charger mode by ac.\n");
+ pr_debug("case for charger mode by ac.\n");
using_shutdown_data(chip, batt_temp);
}
else if(chip->calculated_soc < soc_adopt_low_thd){
- printk("case for chosen and shutdown are low\n");
+ pr_debug("case for chosen and shutdown are low\n");
if(chip->shutdown_soc < chip->calculated_soc)
using_shutdown_data(chip, batt_temp);
}
@@ -3186,7 +3186,7 @@ static int calculate_initial_soc(struct qpnp_bms_chip *chip)
check_est_region_and_compare(chip, batt_temp);
}
else
- printk("shutdown soc invalid, using pon ocv\n");
+ pr_debug("shutdown soc invalid, using pon ocv\n");
//lazy
@@ -3416,7 +3416,7 @@ static int vm_bms_open(struct inode *inode, struct file *file)
}
chip->bms_dev_open = true;
file->private_data = chip;
- printk("%s: BMS device opened\n", __FUNCTION__);
+ pr_debug("%s: BMS device opened\n", __FUNCTION__);
/*BSP david: use vm bms soc when bms device is opened*/
chip->dt.cfg_use_voltage_soc = false;
mutex_unlock(&chip->bms_device_mutex);
@@ -3534,7 +3534,7 @@ static int64_t read_battery_id(struct qpnp_bms_chip *chip)
LR_MUX2_BAT_ID, rc);
return rc;
}
- printk("%s: adc_code = %d, measurement = %lld, physical = %lld\n",
+ pr_debug("%s: adc_code = %d, measurement = %lld, physical = %lld\n",
__FUNCTION__,
result.adc_code,
result.measurement,
@@ -4082,7 +4082,7 @@ static ssize_t battery_status_proc_write(struct file *filp, const char __user *b
val = (int)simple_strtol(messages, NULL, 10);
- printk("[BAT][BATT][Proc]battery status Proc File: %d\n", val);
+ pr_debug("[BAT][BATT][Proc]battery status Proc File: %d\n", val);
return len;
}
@@ -4099,9 +4099,9 @@ void static create_battery_status_proc_file(void)
battery_status_proc_file = proc_create(battery_status_PROC_FILE, 0644, NULL, &battery_status_fops);
if (battery_status_proc_file) {
- printk("[BAT][BATT][Proc]proc file create sucessed!\n");
+ pr_debug("[BAT][BATT][Proc]proc file create sucessed!\n");
} else{
- printk("[BAT][BATT][Proc]proc file create failed!\n");
+ pr_debug("[BAT][BATT][Proc]proc file create failed!\n");
}
}
/*ASUS_BSP kerwin add iic test interface*/
@@ -4137,9 +4137,9 @@ static ssize_t boot_completed_proc_write(struct file *filp, const char __user *b
val = (int)simple_strtol(messages, NULL, 10);
- printk("[BAT][Proc][Prop]boot_completed_prop: %d\n", val);
+ pr_debug("[BAT][Proc][Prop]boot_completed_prop: %d\n", val);
if(val){
- printk("[BAT][Proc][Prop]set boot_completed to 1 \n");
+ pr_debug("[BAT][Proc][Prop]set boot_completed to 1 \n");
boot_completed = 1;
if (the_chip->bms_psy_registered)
power_supply_changed(&the_chip->bms_psy);
@@ -4159,9 +4159,9 @@ void static create_boot_completed_proc_file(void)
boot_completed_proc_file = proc_create(boot_completed_PROC_FILE, 0644, NULL, &boot_completed_fops);
if (boot_completed_proc_file) {
- printk("[BAT][Proc][Prop]boot_completed_prop create sucessed!\n");
+ pr_debug("[BAT][Proc][Prop]boot_completed_prop create sucessed!\n");
} else{
- printk("[BAT][Proc][Prop]boot_completed_prop file create failed!\n");
+ pr_debug("[BAT][Proc][Prop]boot_completed_prop file create failed!\n");
}
}
/*ASUS_BSP Ben add system property "sys.boot_completed" interface*/
@@ -4184,7 +4184,7 @@ static int gaugeIC_status_proc_read(struct seq_file *buf, void *v)
ret = 0;
seq_printf(buf, "%s\n%s\n", str_err,gauge_version);
} else{
- printk("[BAT]%s: voltage = %d\n", __FUNCTION__, vbat_uv);
+ pr_debug("[BAT]%s: voltage = %d\n", __FUNCTION__, vbat_uv);
ret = 1;
seq_printf(buf, "%s\n%s\n", str_ok,gauge_version);
}
@@ -4213,7 +4213,7 @@ static ssize_t gaugeIC_status_proc_write(struct file *filp, const char __user *b
val = (int)simple_strtol(messages, NULL, 10);
- printk("[BAT][GAUGE][Proc]gaugeIC Proc File: %d\n", val);
+ pr_debug("[BAT][GAUGE][Proc]gaugeIC Proc File: %d\n", val);
return len;
}
@@ -4230,9 +4230,9 @@ void static create_gaugeIC_status_proc_file(void)
gaugeIC_status_proc_file = proc_create(gaugeIC_status_PROC_FILE, 0644, NULL, &gaugeIC_status_fops);
if (gaugeIC_status_proc_file) {
- printk("[BAT][GAUGE][Proc]proc file create sucessed!\n");
+ pr_debug("[BAT][GAUGE][Proc]proc file create sucessed!\n");
} else{
- printk("[BAT][GAUGE][Proc]proc file create failed!\n");
+ pr_debug("[BAT][GAUGE][Proc]proc file create failed!\n");
}
}
/*---ASUS_BSP David BMMI Adb Interface---*/
@@ -4305,7 +4305,7 @@ static int qpnp_vm_bms_probe(struct spmi_device *spmi)
pr_err("Error reading warm reset status rc=%d\n", rc);
return rc;
}
- printk("qpnp_pon_is_warm_reset:%d\n",rc);
+ pr_debug("qpnp_pon_is_warm_reset:%d\n",rc);
chip->warm_reset = !!rc;
rc = parse_spmi_dt_properties(chip, spmi);
@@ -4403,7 +4403,7 @@ static int qpnp_vm_bms_probe(struct spmi_device *spmi)
batt_dev.name = "battery";
batt_dev.print_name = batt_switch_name;
if (switch_dev_register(&batt_dev) < 0) {
- printk("%s: fail to register battery switch\n", __FUNCTION__);
+ pr_debug("%s: fail to register battery switch\n", __FUNCTION__);
}
the_chip = chip;
calculate_initial_soc(chip);
@@ -4600,7 +4600,7 @@ static void process_resume_data(struct qpnp_bms_chip *chip)
if(abs_tmp > changing_thd_H){
count++;
- printk("%s:deviation(skip): %d, hw ocv: %d, last ocv: %d\n",
+ pr_debug("%s:deviation(skip): %d, hw ocv: %d, last ocv: %d\n",
__FUNCTION__,temp, chip->last_ocv_uv, old_ocv);
}
@@ -4617,12 +4617,12 @@ static void process_resume_data(struct qpnp_bms_chip *chip)
if(abs_tmp<=changing_thd_H&&abs_tmp>changing_thd_L)
chip->last_ocv_uv = (chip->last_ocv_uv + old_ocv)/2;
- printk("%s:last_ocv_uv = %d, result_last_ocv_uv%s%s = %d\n",
+ pr_debug("%s:last_ocv_uv = %d, result_last_ocv_uv%s%s = %d\n",
__FUNCTION__,old_ocv,
(abs_tmp>changing_thd_H)?"(chasing)":"",
(abs_tmp<=changing_thd_H&&abs_tmp>changing_thd_L)?"(reduce)":"",
chip->last_ocv_uv);
- printk("%s:ocv_deviation = %d\n",__FUNCTION__,temp);
+ pr_debug("%s:ocv_deviation = %d\n",__FUNCTION__,temp);
ocv_updated = true;
/* new OCV, clear suspended data */
@@ -4650,7 +4650,7 @@ static void process_resume_data(struct qpnp_bms_chip *chip)
pm_stay_awake(chip->dev);
}
- printk("%s:reset count\n",__FUNCTION__);
+ pr_debug("%s:reset count\n",__FUNCTION__);
chip->suspend_data_valid = false;
mutex_unlock(&chip->bms_data_mutex);
}
--
2.23.1