1
1
mirror of https://github.com/NixOS/mobile-nixos.git synced 2024-12-17 21:11:34 +03:00
mobile-nixos/devices/asus-z00t/kernel/0002-asus_battery-shut-up.patch
2020-04-09 22:27:15 -04:00

342 lines
13 KiB
Diff

From 28b97cca57f7c4c37cb4076fdf161133ec53c3cd Mon Sep 17 00:00:00 2001
From: Samuel Dionne-Riel <samuel@dionne-riel.com>
Date: Thu, 9 Apr 2020 01:56:36 -0400
Subject: [PATCH 2/3] asus_battery: shut up!
---
drivers/power/asus_battery.h | 6 +++
drivers/power/smb358-charger.c | 78 +++++++++++++++++-----------------
2 files changed, 45 insertions(+), 39 deletions(-)
diff --git a/drivers/power/asus_battery.h b/drivers/power/asus_battery.h
index 85ba4668b6e2d..6c3e6b13eb8ac 100644
--- a/drivers/power/asus_battery.h
+++ b/drivers/power/asus_battery.h
@@ -33,9 +33,15 @@ extern int setSMB358Charger(int usb_state);
#define LOW_TEMPERATURE_TO_STOP_CHARGING (0)
#define BATTERY_TAG "<BATT>"
+#if 0
#define BAT_DBG(...) printk(KERN_INFO BATTERY_TAG __VA_ARGS__)
#define BAT_DBG_L(level, ...) printk(level BATTERY_TAG __VA_ARGS__)
#define BAT_DBG_E(...) printk(KERN_ERR BATTERY_TAG __VA_ARGS__)
+#else
+#define BAT_DBG(...) pr_debug(KERN_INFO BATTERY_TAG __VA_ARGS__)
+#define BAT_DBG_L(level, ...) pr_debug(level BATTERY_TAG __VA_ARGS__)
+#define BAT_DBG_E(...) pr_debug(KERN_ERR BATTERY_TAG __VA_ARGS__)
+#endif
#define BYTETOBINARYPATTERN "%d%d%d%d-%d%d%d%db"
#define BYTETOBINARY(byte) \
diff --git a/drivers/power/smb358-charger.c b/drivers/power/smb358-charger.c
index 40720d6a8fd82..8c03df49f9961 100644
--- a/drivers/power/smb358-charger.c
+++ b/drivers/power/smb358-charger.c
@@ -1410,7 +1410,7 @@ static ssize_t battID_read_proc_write(struct file *filp, const char __user *buff
}
val = (int)simple_strtol(messages, NULL, 10);
- printk("[BAT][CHG][SMB][Proc]%s: %d\n", __FUNCTION__, val);
+ BAT_DBG("[BAT][CHG][SMB][Proc]%s: %d\n", __FUNCTION__, val);
return len;
}
@@ -1433,9 +1433,9 @@ static void create_battID_read_proc_file(void)
struct proc_dir_entry *battID_read_proc_file = proc_create("driver/battID_read", 0666, NULL, &battID_read_fops);
if (battID_read_proc_file) {
- printk("[BAT][CHG][SMB][Proc]battID_read create ok!\n");
+ BAT_DBG("[BAT][CHG][SMB][Proc]battID_read create ok!\n");
} else{
- printk("[BAT][CHG][SMB][Proc]battID_read create failed!\n");
+ BAT_DBG("[BAT][CHG][SMB][Proc]battID_read create failed!\n");
}
return;
}
@@ -1808,7 +1808,7 @@ static inline int get_battery_temperature(int *tempr)
if (!ret)
*tempr = val.intval;
else
- printk("%s: using fake temperature: 250\n", __FUNCTION__);
+ BAT_DBG("%s: using fake temperature: 250\n", __FUNCTION__);
return ret;
}
static inline int get_battery_rsoc(int *rsoc)
@@ -2362,7 +2362,7 @@ static int smb358_soc_detect_batt_tempr(int usb_state)
}
if(JEITA_Flag){
if(reg != usb_in_current){
- printk("%s is in JEITA_flag=1\n",__FUNCTION__);
+ BAT_DBG("%s is in JEITA_flag=1\n",__FUNCTION__);
if(reg < usb_in_current){ /* from small to big_Input_Current */
smb358_OptiCharge_Toggle(false);
ret = smb358_masked_write(smb358_dev,CHG_OTH_CURRENT_CTRL_REG,CFG_CURRENT_LIMIT_SMB358_MASK,
@@ -2384,7 +2384,7 @@ static int smb358_soc_detect_batt_tempr(int usb_state)
}
}else{//JEITA_flag false usb_in limit =2000mA
if(reg != usb_in_current){
- printk("%s is in JEITA_flag=0\n",__FUNCTION__);
+ BAT_DBG("%s is in JEITA_flag=0\n",__FUNCTION__);
smb358_OptiCharge_Toggle(false);
ret=smb358_masked_write(smb358_dev, CHG_OTH_CURRENT_CTRL_REG,CFG_CURRENT_LIMIT_SMB358_MASK,
usb_in_current);
@@ -2423,7 +2423,7 @@ finish:
} else{
pr_err("%s: fail to request power supply changed\n", __FUNCTION__);
}
- printk("%s aicl_time=%d\n",__FUNCTION__,aicl_time);
+ BAT_DBG("%s aicl_time=%d\n",__FUNCTION__,aicl_time);
return aicl_time;
}
@@ -2660,7 +2660,7 @@ finish:
} else{
pr_err("%s: fail to request power supply changed\n", __FUNCTION__);
}
- printk("%s aicl_time=%d\n",__FUNCTION__,aicl_time);
+ BAT_DBG("%s aicl_time=%d\n",__FUNCTION__,aicl_time);
return aicl_time;
}
@@ -2897,7 +2897,7 @@ finish:
} else{
pr_err("%s: fail to request power supply changed\n", __FUNCTION__);
}
- printk("%s aicl_time=%d\n",__FUNCTION__,aicl_time);
+ BAT_DBG("%s aicl_time=%d\n",__FUNCTION__,aicl_time);
return aicl_time;
}
@@ -3204,7 +3204,7 @@ void aicl_dete_worker(struct work_struct *dat)
BAT_DBG_E("%s: fail to read charger voltage reg\n", __FUNCTION__);
return ;
}
- printk("%s CHG_CURRENT_CTRL_REG=%#x\n",__FUNCTION__,reg);
+ BAT_DBG("%s CHG_CURRENT_CTRL_REG=%#x\n",__FUNCTION__,reg);
usb_state = g_usb_state;
/*BSP david: don't need to do any config if no cable!*/
@@ -3243,7 +3243,7 @@ void aicl_dete_worker(struct work_struct *dat)
CHG_OTH_CURRENT_CTRL_REG,
CFG_CURRENT_LIMIT_SMB358_MASK,
CFG_CURRENT_LIMIT_SMB358_VALUE_1000);
- printk("normal charger\n");
+ BAT_DBG("normal charger\n");
}
}
}
@@ -3259,17 +3259,17 @@ void aicl_dete_worker(struct work_struct *dat)
} else {
aicl_time=smb358_soc_detect_batt_tempr(usb_state);
}
- printk("%s:aicl_time=%d\n",__FUNCTION__,aicl_time);
+ BAT_DBG("%s:aicl_time=%d\n",__FUNCTION__,aicl_time);
skip_jeita:
g_last_aicl_time = current_kernel_time();
//smb358_update_aicl_work(60);
if (aicl_time==60) {
- printk("%s:queue_delayed_work 60s\n",__FUNCTION__);
+ BAT_DBG("%s:queue_delayed_work 60s\n",__FUNCTION__);
queue_delayed_work(chrgr_work_queue,
&aicl_dete_work,
60*HZ);
} else if (aicl_time==5) {
- printk("%s:queue_delayed_work 5s\n",__FUNCTION__);
+ BAT_DBG("%s:queue_delayed_work 5s\n",__FUNCTION__);
//smb358_update_aicl_work(5);
queue_delayed_work(chrgr_work_queue,
&aicl_dete_work,
@@ -3295,7 +3295,7 @@ void asus_polling_data(struct work_struct *dat)
schedule_delayed_work(&SetBatRTCWorker, 0);
}
} else{
- printk("%s: gauge not ready yet, delay 5s!\n", __FUNCTION__);
+ BAT_DBG("%s: gauge not ready yet, delay 5s!\n", __FUNCTION__);
//smb358_polling_battery_data_work(5);
schedule_delayed_work(&battery_poll_data_work, 5 * HZ);
}
@@ -3379,7 +3379,7 @@ struct wake_lock UsbCable_Lock;
static DEFINE_SPINLOCK(bat_alarm_slock);
static enum alarmtimer_restart batAlarm_handler(struct alarm *alarm, ktime_t now)
{
- printk("[BAT][alarm]batAlarm triggered\n");
+ BAT_DBG("[BAT][alarm]batAlarm triggered\n");
return ALARMTIMER_NORESTART;
}
void BatTriggeredSetRTC(struct work_struct *dat)
@@ -3490,7 +3490,7 @@ int setSMB358Charger(int usb_state)
if( usb_state != CABLE_OUT )
g_usb_state = usb_state;
}
- printk(KERN_EMERG "setSMB358Charger usb_state:%d\n",usb_state);
+ BAT_DBG(KERN_EMERG "setSMB358Charger usb_state:%d\n",usb_state);
if (usb_state >= 0 && usb_state <= 7) {
BAT_DBG("%s:%s\n", __FUNCTION__, usb_status_str[usb_state]);
}
@@ -3689,7 +3689,7 @@ static ssize_t ChargerRegDump_write_proc(struct file *filp, const char __user *b
}
val = (int)simple_strtol(messages, NULL, 10);
- printk("[BAT][CHG][SMB][Proc]%s: %d\n", __FUNCTION__, val);
+ BAT_DBG("[BAT][CHG][SMB][Proc]%s: %d\n", __FUNCTION__, val);
return len;
}
@@ -3712,9 +3712,9 @@ static void create_ChargerRegDump_proc_file(void)
struct proc_dir_entry *ChargerReg_proc_file = proc_create("driver/Charger_Reg_Dump", 0666, NULL, &ChargerRegDump_fops);
if (ChargerReg_proc_file) {
- printk("[BAT][Proc]%s sucessed!\n", __FUNCTION__);
+ BAT_DBG("[BAT][Proc]%s sucessed!\n", __FUNCTION__);
} else{
- printk("[BAT][Proc]%s failed!\n", __FUNCTION__);
+ BAT_DBG("[BAT][Proc]%s failed!\n", __FUNCTION__);
}
return;
@@ -3757,14 +3757,14 @@ static void smb358_set_pinctrl(void)
key_pinctrl = devm_pinctrl_get(smb358_dev->dev);
set_state = pinctrl_lookup_state(key_pinctrl, "smb358_nfc_disable_active");
ret = pinctrl_select_state(key_pinctrl, set_state);
- printk("%s: pinctrl_select_state = %d\n", __FUNCTION__, ret);
+ BAT_DBG("%s: pinctrl_select_state = %d\n", __FUNCTION__, ret);
}
static int smb358_inok_gpio_init(struct smb358_charger *smb)
{
int ret, irq;
- printk("%s: gp_inok = %d\n", __FUNCTION__, gp_inok);
+ BAT_DBG("%s: gp_inok = %d\n", __FUNCTION__, gp_inok);
if ((!gpio_is_valid(gp_inok))) {
- printk("%s: gp_inok is not valid!\n", __FUNCTION__);
+ BAT_DBG("%s: gp_inok is not valid!\n", __FUNCTION__);
goto fail;
}
/*BSP david: set pinctrl to enable inok gpio*/
@@ -3776,7 +3776,7 @@ static int smb358_inok_gpio_init(struct smb358_charger *smb)
}
ret = gpio_request_one(gp_inok, GPIOF_IN, "smb358_inok");
if (ret < 0) {
- printk("%s: request INOK gpio fail!\n", __FUNCTION__);
+ BAT_DBG("%s: request INOK gpio fail!\n", __FUNCTION__);
goto fail;
}
irq = gpio_to_irq(gp_inok);
@@ -3840,7 +3840,7 @@ static ssize_t chargerIC_status_proc_write(struct file *filp, const char __user
}
val = (int)simple_strtol(messages, NULL, 10);
- printk("[BAT][CHG][SMB][Proc]ChargerIC Proc File: %d\n", val);
+ BAT_DBG("[BAT][CHG][SMB][Proc]ChargerIC Proc File: %d\n", val);
return len;
}
@@ -3908,7 +3908,7 @@ static ssize_t batt_current_proc_write(struct file *filp, const char __user *buf
}
val = (int)simple_strtol(messages, NULL, 10);
- printk("[BAT][CHG][SMB][Proc]batt_current Proc File: %d\n", val);
+ BAT_DBG("[BAT][CHG][SMB][Proc]batt_current Proc File: %d\n", val);
return len;
}
@@ -3975,7 +3975,7 @@ static ssize_t batt_voltage_proc_write(struct file *filp, const char __user *buf
}
val = (int)simple_strtol(messages, NULL, 10);
- printk("[BAT][CHG][SMB][Proc]batt_voltage Proc File: %d\n", val);
+ BAT_DBG("[BAT][CHG][SMB][Proc]batt_voltage Proc File: %d\n", val);
return len;
}
@@ -4029,13 +4029,13 @@ static ssize_t charger_limit_enable_proc_write(struct file *filp, const char __u
g_charging_toggle_for_charging_limit = true;
charger_suspend_for_charging_limit = false;
/* turn on charging limit in eng mode */
- printk("[BAT][CHG][SMB][Proc]charger_limit_enable:%d\n", 1);
+ BAT_DBG("[BAT][CHG][SMB][Proc]charger_limit_enable:%d\n", 1);
} else if (buff[0] == '0') {
eng_charging_limit = false;
g_charging_toggle_for_charging_limit = true;
charger_suspend_for_charging_limit = false;
/* turn off charging limit in eng mode */
- printk("[BAT][CHG][SMB][Proc]charger_limit_enable:%d\n", 0);
+ BAT_DBG("[BAT][CHG][SMB][Proc]charger_limit_enable:%d\n", 0);
}
//kerwin for charger limit
@@ -4044,7 +4044,7 @@ static ssize_t charger_limit_enable_proc_write(struct file *filp, const char __u
charger_limit_setting=10;
else if(charger_limit_setting>100)
charger_limit_setting=100;
- printk("[BAT][CHG][SMB][Proc]charger_limit_setting:%d\n", charger_limit_setting);
+ BAT_DBG("[BAT][CHG][SMB][Proc]charger_limit_setting:%d\n", charger_limit_setting);
smb358_update_aicl_work(0);
return len;
}
@@ -4067,9 +4067,9 @@ static void create_charger_limit_enable_proc_file(void)
struct proc_dir_entry *charger_limit_enable_proc_file = proc_create("driver/charger_limit_enable", 0666, NULL, &charger_limit_enable_fops);
if (charger_limit_enable_proc_file) {
- printk("[BAT][CHG][SMB][Proc]charger_limit_enable create ok!\n");
+ BAT_DBG("[BAT][CHG][SMB][Proc]charger_limit_enable create ok!\n");
} else{
- printk("[BAT][CHG][SMB][Proc]charger_limit_enable create failed!\n");
+ BAT_DBG("[BAT][CHG][SMB][Proc]charger_limit_enable create failed!\n");
}
return;
}
@@ -4085,7 +4085,7 @@ static int smb358_charger_probe(struct i2c_client *client,
struct device *dev = &client->dev;
struct device_node *np = dev->of_node;
- printk("%s++\n", __FUNCTION__);
+ BAT_DBG("%s++\n", __FUNCTION__);
usb_psy = power_supply_get_by_name("usb");
if (!usb_psy) {
dev_dbg(&client->dev, "USB psy not found; deferring probe\n");
@@ -4124,19 +4124,19 @@ static int smb358_charger_probe(struct i2c_client *client,
return ret;
gp_sdio_2_clk = of_get_named_gpio(np, "qcom,otg-gpio", 0);
gp_inok = of_get_named_gpio(np, "qcom,inok-gpio", 0);
- printk("%s: gp_sdio_2_clk = %d\n", __FUNCTION__, gp_sdio_2_clk);
+ BAT_DBG("%s: gp_sdio_2_clk = %d\n", __FUNCTION__, gp_sdio_2_clk);
if ((!gpio_is_valid(gp_sdio_2_clk))) {
- printk("%s: gp_sdio_2_clk is not valid!\n", __FUNCTION__);
+ BAT_DBG("%s: gp_sdio_2_clk is not valid!\n", __FUNCTION__);
return -EINVAL;
}
ret = gpio_request(gp_sdio_2_clk, "smb358_otg");
if (ret < 0) {
- printk("%s: request CHG_OTG gpio fail!\n", __FUNCTION__);
+ BAT_DBG("%s: request CHG_OTG gpio fail!\n", __FUNCTION__);
}
gpio_direction_output(gp_sdio_2_clk, 0);
if (ret < 0) {
- printk("%s: set direction of CHG_OTG gpio fail!\n", __FUNCTION__);
+ BAT_DBG("%s: set direction of CHG_OTG gpio fail!\n", __FUNCTION__);
}
wake_lock_init(&inok_wakelock,
@@ -4151,7 +4151,7 @@ static int smb358_charger_probe(struct i2c_client *client,
//BSP Ben add adapter_id for 5w (BZ sku) porting
//adapter_id: 0 = 5w
// 1 = 10w
- printk("%s:ADAPTER_ID=<%d>\n",__func__,asus_project_ADAPTER_ID);
+ BAT_DBG("%s:ADAPTER_ID=<%d>\n",__func__,asus_project_ADAPTER_ID);
#if defined(ASUS_FACTORY_BUILD)
eng_charging_limit = false;
@@ -4193,7 +4193,7 @@ static int smb358_charger_probe(struct i2c_client *client,
}
}
smb358_polling_battery_data_work(0);
- printk("%s--\n", __FUNCTION__);
+ BAT_DBG("%s--\n", __FUNCTION__);
return 0;
}
--
2.23.1