Created
December 19, 2019 12:47
-
-
Save rk779/8bfbc120e9e15266a8b0f6e52d3567bb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/arch/arm/boot/dts/qcom/sdm660-qrd.dtsi b/arch/arm/boot/dts/qcom/sdm660-qrd.dtsi | |
index 73a80b844812..ad23d099560a 100644 | |
--- a/arch/arm/boot/dts/qcom/sdm660-qrd.dtsi | |
+++ b/arch/arm/boot/dts/qcom/sdm660-qrd.dtsi | |
@@ -272,10 +272,12 @@ | |
qcom,battery-thermal-coefficients = [9d 50 ff]; | |
}; | |
-&pm660_haptics { | |
+/* Huaqin modify for TT1308440 by liunianliang at 2019/05/27 start */ | |
+/*&pm660_haptics { | |
qcom,wave-play-rate-us = <4255>; | |
qcom,vmax-mv = <1800>; | |
-}; | |
+};*/ | |
+/* Huaqin modify for TT1308440 by liunianliang at 2019/05/27 end */ | |
&i2c_2 { | |
status = "ok"; | |
diff --git a/drivers/gpu/msm/kgsl_pwrctrl.c b/drivers/gpu/msm/kgsl_pwrctrl.c | |
index b5476b06176a..ac10f5baa5f2 100644 | |
--- a/drivers/gpu/msm/kgsl_pwrctrl.c | |
+++ b/drivers/gpu/msm/kgsl_pwrctrl.c | |
@@ -2785,7 +2785,8 @@ static int _suspend(struct kgsl_device *device) | |
if ((device->state == KGSL_STATE_NONE) || | |
(device->state == KGSL_STATE_INIT) || | |
(device->state == KGSL_STATE_SUSPEND)) | |
- goto done; | |
+ //goto done; | |
+ return ret; | |
/* drain to prevent from more commands being submitted */ | |
device->ftbl->drain(device); | |
@@ -2802,7 +2803,7 @@ static int _suspend(struct kgsl_device *device) | |
if (ret) | |
goto err; | |
-done: | |
+//done: | |
kgsl_pwrctrl_set_state(device, KGSL_STATE_SUSPEND); | |
return ret; | |
diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c | |
index 885f689ac870..f2e3fdf385cc 100644 | |
--- a/drivers/media/usb/uvc/uvc_driver.c | |
+++ b/drivers/media/usb/uvc/uvc_driver.c | |
@@ -1019,11 +1019,19 @@ static int uvc_parse_standard_control(struct uvc_device *dev, | |
return -EINVAL; | |
} | |
- /* Make sure the terminal type MSB is not null, otherwise it | |
- * could be confused with a unit. | |
+ /* | |
+ * Reject invalid terminal types that would cause issues: | |
+ * | |
+ * - The high byte must be non-zero, otherwise it would be | |
+ * confused with a unit. | |
+ * | |
+ * - Bit 15 must be 0, as we use it internally as a terminal | |
+ * direction flag. | |
+ * | |
+ * Other unknown types are accepted. | |
*/ | |
type = get_unaligned_le16(&buffer[4]); | |
- if ((type & 0xff00) == 0) { | |
+ if ((type & 0x7f00) == 0 || (type & 0x8000) != 0) { | |
uvc_trace(UVC_TRACE_DESCR, "device %d videocontrol " | |
"interface %d INPUT_TERMINAL %d has invalid " | |
"type 0x%04x, skipping\n", udev->devnum, | |
diff --git a/drivers/power/supply/qcom/fg-core.h b/drivers/power/supply/qcom/fg-core.h | |
index 076cd49e6dd5..d50c9e20d87f 100644 | |
--- a/drivers/power/supply/qcom/fg-core.h | |
+++ b/drivers/power/supply/qcom/fg-core.h | |
@@ -31,6 +31,23 @@ | |
#include <linux/types.h> | |
#include <linux/uaccess.h> | |
#include <linux/pmic-voter.h> | |
+//Huaqin add by jianghao at 2019/05/13 start | |
+#define BAT_HEALTH_NUMBER_MAX 21 | |
+struct BAT_HEALTH_DATA{ | |
+ int magic; | |
+ int bat_current; | |
+ unsigned long long bat_current_avg; | |
+ unsigned long long accumulate_time; //second | |
+ unsigned long long accumulate_current; //uA | |
+ int bat_health; | |
+ unsigned long start_time; | |
+ unsigned long end_time; | |
+}; | |
+struct BAT_HEALTH_DATA_BACKUP{ | |
+ char date[20]; | |
+ int health; | |
+}; | |
+//Huaqin add by jianghao at 2019/05/13 end | |
#define fg_dbg(chip, reason, fmt, ...) \ | |
do { \ | |
diff --git a/drivers/power/supply/qcom/qpnp-fg-gen3.c b/drivers/power/supply/qcom/qpnp-fg-gen3.c | |
index 0857a7651ddd..b7d906974be8 100644 | |
--- a/drivers/power/supply/qcom/qpnp-fg-gen3.c | |
+++ b/drivers/power/supply/qcom/qpnp-fg-gen3.c | |
@@ -22,6 +22,13 @@ | |
#include <linux/qpnp/qpnp-revid.h> | |
#include "fg-core.h" | |
#include "fg-reg.h" | |
+//Huaqin add by jianghao at 2019/05/13 start | |
+#include <linux/proc_fs.h> | |
+#include <linux/mm.h> | |
+#include <linux/syscalls.h> | |
+#include <linux/reboot.h> | |
+#include <linux/rtc.h> | |
+//Huaqin add by jianghao at 2019/05/13 end | |
//Huaqin add by tangqingyong at 2017/02/02 start | |
#include <linux/switch.h> | |
@@ -149,7 +156,82 @@ | |
#define RECHARGE_VBATT_THR_v2_OFFSET 1 | |
#define FLOAT_VOLT_v2_WORD 16 | |
#define FLOAT_VOLT_v2_OFFSET 2 | |
+//Huaqin add by jianghao at 2019/05/13 start | |
+ | |
+#define CYCLE_COUNT_DATA_MAGIC 0x85 | |
+#define CYCLE_COUNT_FILE_NAME "/batinfo/.bs" | |
+#define BAT_PERCENT_FILE_NAME "/batinfo/Batpercentage" | |
+#define BAT_SAFETY_FILE_NAME "/batinfo/bat_safety" | |
+#define CYCLE_COUNT_SD_FILE_NAME "/sdcard/.bs" | |
+#define BAT_PERCENT_SD_FILE_NAME "/sdcard/Batpercentage" | |
+#define BAT_CYCLE_SD_FILE_NAME "/sdcard/Batcyclecount" | |
+#define CYCLE_COUNT_DATA_OFFSET 0x0 | |
+#define FILE_OP_READ 0 | |
+#define FILE_OP_WRITE 1 | |
+ | |
+#define BATTERY_HEALTH_UPGRADE_TIME 1 //ASUS_BS battery health upgrade | |
+#define BATTERY_METADATA_UPGRADE_TIME 60 //ASUS_BS battery health upgrade | |
+#define BAT_HEALTH_DATA_OFFSET 0x0 | |
+#define BAT_HEALTH_DATA_MAGIC 0x86 | |
+#define BAT_HEALTH_DATA_BACKUP_MAGIC 0x87 | |
+#define ZS630KL_DESIGNED_CAPACITY 4750 //mAh //Design Capcaity *0.95 = 4750 | |
+#define BAT_HEALTH_DATA_FILE_NAME "/sdcard/bat_health" | |
+#define BAT_HEALTH_DATA_SD_FILE_NAME "/sdcard/.bh" | |
+#define BAT_HEALTH_START_LEVEL 70 | |
+#define BAT_HEALTH_END_LEVEL 100 | |
+static bool g_bathealth_initialized = false; | |
+static bool g_bathealth_trigger = false; | |
+static bool g_last_bathealth_trigger = false; | |
+static bool g_health_debug_enable = true; | |
+static bool g_health_upgrade_enable = true; | |
+static int g_health_upgrade_index = 0; | |
+static int g_health_upgrade_start_level = BAT_HEALTH_START_LEVEL; | |
+static int g_health_upgrade_end_level = BAT_HEALTH_END_LEVEL; | |
+static int g_health_upgrade_upgrade_time = BATTERY_HEALTH_UPGRADE_TIME; | |
+static int g_bat_health_avg; | |
+ | |
+static struct BAT_HEALTH_DATA g_bat_health_data = { | |
+ .magic = BAT_HEALTH_DATA_MAGIC, | |
+ .bat_current = 0, | |
+ .bat_current_avg = 0, | |
+ .accumulate_time = 0, | |
+ .accumulate_current = 0, | |
+ .bat_health = 0 | |
+}; | |
+static struct BAT_HEALTH_DATA_BACKUP g_bat_health_data_backup[BAT_HEALTH_NUMBER_MAX] = { | |
+ {"", 0}, | |
+ {"", 0}, | |
+ {"", 0}, | |
+ {"", 0}, | |
+ {"", 0}, | |
+ {"", 0}, | |
+ {"", 0}, | |
+ {"", 0}, | |
+ {"", 0}, | |
+ {"", 0}, | |
+ {"", 0}, | |
+ {"", 0}, | |
+ {"", 0}, | |
+ {"", 0}, | |
+ {"", 0}, | |
+ {"", 0}, | |
+ {"", 0}, | |
+ {"", 0}, | |
+ {"", 0}, | |
+ {"", 0}, | |
+ {"", 0} | |
+}; | |
+struct delayed_work battery_health_work; | |
+struct delayed_work battery_metadata_work; | |
+struct fg_chip *g_fg = NULL; | |
+ | |
+#define pr_fmt(fmt) "FG: %s: " fmt, __func__ | |
+#define BAT_TAG "[BAT][BMS]" | |
+#define ERROR_TAG "[ERR]" | |
+#define BAT_DBG(fmt, ...) printk(KERN_INFO BAT_TAG " %s: " fmt, __func__, ##__VA_ARGS__) | |
+#define BAT_DBG_E(fmt, ...) printk(KERN_ERR BAT_TAG " %s: " fmt, __func__, ##__VA_ARGS__) | |
+//Huaqin add by jianghao at 2019/05/13 end | |
static int fg_decode_voltage_15b(struct fg_sram_param *sp, | |
enum fg_sram_param_id id, int val); | |
static int fg_decode_value_16b(struct fg_sram_param *sp, | |
@@ -1889,8 +1971,10 @@ static int fg_charge_full_update(struct fg_chip *chip) | |
fg_dbg(chip, FG_STATUS, "Terminated charging @ SOC%d\n", | |
msoc); | |
} | |
- } else if ((msoc_raw <= recharge_soc || !chip->charge_done) | |
- && chip->charge_full) { | |
+/* Huaqin modify for ZQL1650-750 optimize discharge capacity jump 1% by fangaijun at 2018/03/29 start*/ | |
+ } else if ((msoc_raw <= recharge_soc || !chip->charge_done) && chip->charge_full) { | |
+ printk("enter fg_charge_full_update1\n"); | |
+/* Huaqin modify for ZQL1650-750 optimize discharge capacity jump 1% by fangaijun at 2018/03/29 end*/ | |
if (chip->dt.linearize_soc) { | |
chip->delta_soc = FULL_CAPACITY - msoc; | |
@@ -4843,6 +4927,285 @@ static int fg_parse_slope_limit_coefficients(struct fg_chip *chip) | |
return 0; | |
} | |
+//Huaqin add by jianghao at 2019/05/13 start | |
+static int file_op(const char *filename, loff_t offset, char *buf, int length, int operation) | |
+{ | |
+ int filep; | |
+ mm_segment_t old_fs; | |
+ | |
+ old_fs = get_fs(); | |
+ set_fs(KERNEL_DS); | |
+ | |
+ if(FILE_OP_READ == operation) | |
+ filep= sys_open(filename, O_RDONLY | O_CREAT | O_SYNC, 0666); | |
+ else if(FILE_OP_WRITE == operation) | |
+ filep= sys_open(filename, O_RDWR | O_CREAT | O_SYNC, 0666); | |
+ else { | |
+ pr_err("Unknown partition op err!\n"); | |
+ return -1; | |
+ } | |
+ if(filep < 0) { | |
+ pr_err("open %s err! error code:%d\n", filename, filep); | |
+ return -1; | |
+ } | |
+ else | |
+ fg_dbg(g_fg, FG_STATUS, "open %s success!\n", filename); | |
+ | |
+ sys_lseek(filep, offset, SEEK_SET); | |
+ if(FILE_OP_READ == operation) | |
+ sys_read(filep, buf, length); | |
+ else if(FILE_OP_WRITE == operation) { | |
+ sys_write(filep, buf, length); | |
+ sys_fsync(filep); | |
+ } | |
+ set_fs(old_fs); | |
+ sys_close(filep); | |
+ return length; | |
+} | |
+ | |
+static void battery_health_data_reset(void){ | |
+ g_bat_health_data.bat_current = 0; | |
+ g_bat_health_data.bat_current_avg = 0; | |
+ g_bat_health_data.accumulate_time = 0; | |
+ g_bat_health_data.accumulate_current = 0; | |
+ g_bat_health_data.start_time = 0; | |
+ g_bat_health_data.end_time = 0; | |
+ g_bathealth_trigger = false; | |
+ g_last_bathealth_trigger = false; | |
+} | |
+ | |
+extern int batt_health_csc_backup(void); | |
+static int resotre_bat_health(void) | |
+{ | |
+ int i=0, rc = 0; | |
+ | |
+ memset(&g_bat_health_data_backup,0,sizeof(struct BAT_HEALTH_DATA_BACKUP)*BAT_HEALTH_NUMBER_MAX); | |
+ | |
+ /* Read cycle count data from emmc */ | |
+ rc = file_op(BAT_HEALTH_DATA_FILE_NAME, BAT_HEALTH_DATA_OFFSET, | |
+ (char*)&g_bat_health_data_backup, sizeof(struct BAT_HEALTH_DATA_BACKUP)*BAT_HEALTH_NUMBER_MAX, FILE_OP_READ); | |
+ if(rc < 0) { | |
+ pr_err("Read bat health file failed!\n"); | |
+ return -1; | |
+ } | |
+ | |
+ BAT_DBG("index(%d)\n", g_bat_health_data_backup[0].health); | |
+ for(i=1; i<BAT_HEALTH_NUMBER_MAX;i++){ | |
+ BAT_DBG("%s %d",g_bat_health_data_backup[i].date, g_bat_health_data_backup[i].health); | |
+ } | |
+ | |
+ g_health_upgrade_index = g_bat_health_data_backup[0].health; | |
+ g_bathealth_initialized = true; | |
+ | |
+ batt_health_csc_backup(); | |
+ return 0; | |
+} | |
+ | |
+static int backup_bat_health(void) | |
+{ | |
+ int bat_health, rc; | |
+ struct timespec ts; | |
+ struct rtc_time tm; | |
+ int health_t; | |
+ int count=0, i=0; | |
+ unsigned long long bat_health_accumulate=0; | |
+ | |
+ getnstimeofday(&ts); | |
+ rtc_time_to_tm(ts.tv_sec,&tm); | |
+ | |
+ bat_health = g_bat_health_data.bat_health; | |
+ | |
+ if(g_health_upgrade_index == BAT_HEALTH_NUMBER_MAX-1){ | |
+ g_health_upgrade_index = 1; | |
+ }else{ | |
+ g_health_upgrade_index++; | |
+ } | |
+ | |
+ sprintf(g_bat_health_data_backup[g_health_upgrade_index].date, "%d-%02d-%02d %02d:%02d:%02d", tm.tm_year+1900,tm.tm_mon+1, tm.tm_mday,tm.tm_hour,tm.tm_min,tm.tm_sec); | |
+ g_bat_health_data_backup[g_health_upgrade_index].health = bat_health; | |
+ g_bat_health_data_backup[0].health = g_health_upgrade_index; | |
+ | |
+ BAT_DBG("===== Health history ====\n"); | |
+ for(i=1;i<BAT_HEALTH_NUMBER_MAX;i++){ | |
+ if(g_bat_health_data_backup[i].health!=0){ | |
+ count++; | |
+ bat_health_accumulate += g_bat_health_data_backup[i].health; | |
+ printk("%s %02d:%d\n",__FUNCTION__,i,g_bat_health_data_backup[i].health); | |
+ } | |
+ } | |
+ BAT_DBG(" ========================\n"); | |
+ if(count==0){ | |
+ BAT_DBG("battery health value is empty\n"); | |
+ return -1; | |
+ } | |
+ health_t = bat_health_accumulate*10/count; | |
+ g_bat_health_avg = (int)(health_t + 5)/10; | |
+ g_bat_health_data_backup[g_health_upgrade_index].health = g_bat_health_avg; | |
+ | |
+ rc = file_op(BAT_HEALTH_DATA_FILE_NAME, BAT_HEALTH_DATA_OFFSET, | |
+ (char *)&g_bat_health_data_backup, sizeof(struct BAT_HEALTH_DATA_BACKUP)*BAT_HEALTH_NUMBER_MAX, FILE_OP_WRITE); | |
+ if(rc<0){ | |
+ pr_err("%s:Write file:%s err!\n", __FUNCTION__, BAT_HEALTH_DATA_FILE_NAME); | |
+ } | |
+ | |
+ return rc; | |
+} | |
+ | |
+int batt_health_csc_backup(void){ | |
+ int rc=0, i=0; | |
+ struct BAT_HEALTH_DATA_BACKUP buf[BAT_HEALTH_NUMBER_MAX]; | |
+ char buf2[BAT_HEALTH_NUMBER_MAX][30]; | |
+ | |
+ memset(&buf,0,sizeof(struct BAT_HEALTH_DATA_BACKUP)*BAT_HEALTH_NUMBER_MAX); | |
+ memset(&buf2,0,sizeof(char)*BAT_HEALTH_NUMBER_MAX*30); | |
+ | |
+ rc = file_op(BAT_HEALTH_DATA_FILE_NAME, BAT_HEALTH_DATA_OFFSET, | |
+ (char*)&buf, sizeof(struct BAT_HEALTH_DATA)*BAT_HEALTH_NUMBER_MAX, FILE_OP_READ); | |
+ if(rc < 0) { | |
+ BAT_DBG_E("Read bat health file failed!\n"); | |
+ return rc; | |
+ } | |
+ | |
+ for(i=1;i<BAT_HEALTH_NUMBER_MAX;i++){ | |
+ if(buf[i].health!=0){ | |
+ sprintf(&buf2[i-1][0], "%s [%d]\n", buf[i].date, buf[i].health); | |
+ } | |
+ } | |
+ | |
+ rc = file_op(BAT_HEALTH_DATA_SD_FILE_NAME, BAT_HEALTH_DATA_OFFSET, | |
+ (char *)&buf2, sizeof(char)*BAT_HEALTH_NUMBER_MAX*30, FILE_OP_WRITE); | |
+ if(rc < 0 ) | |
+ BAT_DBG_E("Write bat health file failed!\n"); | |
+ | |
+ | |
+ BAT_DBG("Done! \n"); | |
+ return rc; | |
+} | |
+ | |
+static void fg_get_online_status(struct fg_chip *chip){ | |
+ int rc; | |
+ union power_supply_propval prop = {0, }; | |
+ int online = 0; | |
+ | |
+ if (usb_psy_initialized(chip)) { | |
+ rc = power_supply_get_property(chip->usb_psy, | |
+ POWER_SUPPLY_PROP_ONLINE, &prop); | |
+ if (rc < 0) { | |
+ pr_err("Couldn't read usb ONLINE prop rc=%d\n", rc); | |
+ return; | |
+ } | |
+ | |
+ online = online || prop.intval; | |
+ } | |
+ | |
+ if (pc_port_psy_initialized(chip)) { | |
+ rc = power_supply_get_property(chip->pc_port_psy, | |
+ POWER_SUPPLY_PROP_ONLINE, &prop); | |
+ if (rc < 0) { | |
+ pr_err("Couldn't read pc_port ONLINE prop rc=%d\n", rc); | |
+ return; | |
+ } | |
+ | |
+ online = online || prop.intval; | |
+ } | |
+ | |
+ if (dc_psy_initialized(chip)) { | |
+ rc = power_supply_get_property(chip->dc_psy, | |
+ POWER_SUPPLY_PROP_ONLINE, &prop); | |
+ if (rc < 0) { | |
+ pr_err("Couldn't read dc ONLINE prop rc=%d\n", rc); | |
+ return; | |
+ } | |
+ | |
+ online = online || prop.intval; | |
+ } | |
+ chip->online_status = online; | |
+} | |
+ | |
+extern unsigned long asus_qpnp_rtc_read_time(void); | |
+ | |
+static void update_battery_health(struct fg_chip *chip){ | |
+ int bat_capacity, bat_current, delta_p; | |
+ unsigned long T; | |
+ int health_t; | |
+ | |
+ if(g_health_upgrade_enable != true){ | |
+ return; | |
+ } | |
+ | |
+ if(g_bathealth_initialized != true){ | |
+ resotre_bat_health(); | |
+ return; | |
+ } | |
+ | |
+ fg_get_online_status(chip); | |
+ if(!chip->online_status){ | |
+ if(g_last_bathealth_trigger == true){ | |
+ battery_health_data_reset(); | |
+ } | |
+ return; | |
+ } | |
+ | |
+ fg_get_prop_capacity(chip, &bat_capacity); | |
+ | |
+ if(bat_capacity == g_health_upgrade_start_level && g_bat_health_data.start_time == 0){ | |
+ g_bathealth_trigger = true; | |
+ g_bat_health_data.start_time = asus_qpnp_rtc_read_time(); | |
+ } | |
+ if(bat_capacity > g_health_upgrade_end_level){ | |
+ g_bathealth_trigger = false; | |
+ } | |
+ if(g_last_bathealth_trigger == false && g_bathealth_trigger == false){ | |
+ return; | |
+ } | |
+ | |
+ if( g_bathealth_trigger ){ | |
+ //if(g_screen_on == true){ | |
+ // return; | |
+ //} | |
+ fg_get_battery_current(chip, &bat_current); | |
+ | |
+ g_bat_health_data.accumulate_time += g_health_upgrade_upgrade_time; | |
+ g_bat_health_data.bat_current = -bat_current; | |
+ g_bat_health_data.accumulate_current += g_bat_health_data.bat_current; | |
+ g_bat_health_data.bat_current_avg = g_bat_health_data.accumulate_current/g_bat_health_data.accumulate_time; | |
+ | |
+ if(g_health_debug_enable) | |
+ BAT_DBG("accumulate_time(%llu), accumulate_current(%llu), bat_current(%d), bat_current_avg(%llu), bat_capacity(%d)", g_bat_health_data.accumulate_time, g_bat_health_data.accumulate_current/1000, g_bat_health_data.bat_current/1000, g_bat_health_data.bat_current_avg/1000, bat_capacity); | |
+ if(bat_capacity >= g_health_upgrade_end_level){ | |
+ g_bat_health_data.end_time = asus_qpnp_rtc_read_time(); | |
+ delta_p = g_health_upgrade_end_level - g_health_upgrade_start_level; | |
+ T = g_bat_health_data.end_time - g_bat_health_data.start_time; | |
+ health_t = (g_bat_health_data.bat_current_avg*T)*10/(unsigned long long)(ZS630KL_DESIGNED_CAPACITY*delta_p)/(unsigned long long)360; | |
+ g_bat_health_data.bat_health = (int)((health_t + 5)/10); | |
+ | |
+ BAT_DBG("battery health = (%d,%d), T(%lu), bat_current_avg(%llu)", g_bat_health_data.bat_health, g_bat_health_avg, T, g_bat_health_data.bat_current_avg/1000); | |
+ backup_bat_health(); | |
+ batt_health_csc_backup(); | |
+ BAT_DBG("battery health = (%d,%d), T(%lu), bat_current_avg(%llu)", g_bat_health_data.bat_health, g_bat_health_avg, T, g_bat_health_data.bat_current_avg/1000); | |
+ | |
+ battery_health_data_reset(); | |
+ }else{ | |
+ //do nothing | |
+ } | |
+ }else{ | |
+ battery_health_data_reset(); | |
+ } | |
+ g_last_bathealth_trigger = g_bathealth_trigger; | |
+} | |
+ | |
+void battery_health_upgrade_data_polling(int time) { | |
+ cancel_delayed_work(&battery_health_work); | |
+ schedule_delayed_work(&battery_health_work, time * HZ); | |
+} | |
+ | |
+void battery_health_worker(struct work_struct *work) | |
+{ | |
+ update_battery_health(g_fg); | |
+ battery_health_upgrade_data_polling(g_health_upgrade_upgrade_time); // update each hour | |
+} | |
+ | |
+//Huaqin add by jianghao at 2019/05/13 end | |
static int fg_parse_ki_coefficients(struct fg_chip *chip) | |
{ | |
struct device_node *node = chip->dev->of_node; | |
@@ -5418,6 +5781,13 @@ static int fg_gen3_probe(struct platform_device *pdev) | |
INIT_WORK(&chip->status_change_work, status_change_work); | |
INIT_DELAYED_WORK(&chip->ttf_work, ttf_work); | |
INIT_DELAYED_WORK(&chip->sram_dump_work, sram_dump_work); | |
+//Huaqin add by jianghao at 2019/05/13 start | |
+ g_fg = chip; | |
+ INIT_DELAYED_WORK(&battery_health_work, battery_health_worker); //battery_health_work | |
+ battery_health_data_reset(); | |
+ | |
+ schedule_delayed_work(&battery_health_work, 30 * HZ); //battery_health_work | |
+//Huaqin add by jianghao at 2019/05/13 end | |
INIT_WORK(&chip->esr_filter_work, esr_filter_work); | |
alarm_init(&chip->esr_filter_alarm, ALARM_BOOTTIME, | |
fg_esr_filter_alarm_cb); | |
diff --git a/drivers/rtc/qpnp-rtc.c b/drivers/rtc/qpnp-rtc.c | |
index bafcebb810de..5c3140f18778 100644 | |
--- a/drivers/rtc/qpnp-rtc.c | |
+++ b/drivers/rtc/qpnp-rtc.c | |
@@ -226,6 +226,51 @@ rtc_rw_fail: | |
return rc; | |
} | |
+//Huaqin add by jianghao at 2019/05/13 start | |
+struct qpnp_rtc *asus_rtc_dd; | |
+unsigned long asus_qpnp_rtc_read_time(void) | |
+{ | |
+ int rc = -1; | |
+ u8 value[4], reg; | |
+ unsigned long secs; | |
+ | |
+ if(!asus_rtc_dd){ | |
+ pr_err("asus rtc add is NULL!\n"); | |
+ return rc; | |
+ } | |
+ | |
+ rc = qpnp_read_wrapper(asus_rtc_dd, value, | |
+ asus_rtc_dd->rtc_base + REG_OFFSET_RTC_READ, | |
+ NUM_8_BIT_RTC_REGS); | |
+ if (rc) { | |
+ pr_err("Read from RTC reg failed\n"); | |
+ return rc; | |
+ } | |
+ /* | |
+ * Read the LSB again and check if there has been a carry over | |
+ * If there is, redo the read operation | |
+ */ | |
+ rc = qpnp_read_wrapper(asus_rtc_dd, ®, | |
+ asus_rtc_dd->rtc_base + REG_OFFSET_RTC_READ, 1); | |
+ if (rc) { | |
+ pr_err("Read from RTC reg failed\n"); | |
+ return rc; | |
+ } | |
+ if (reg < value[0]) { | |
+ rc = qpnp_read_wrapper(asus_rtc_dd, value, | |
+ asus_rtc_dd->rtc_base + REG_OFFSET_RTC_READ, | |
+ NUM_8_BIT_RTC_REGS); | |
+ if (rc) { | |
+ pr_err("Read from RTC reg failed\n"); | |
+ return rc; | |
+ } | |
+ } | |
+ | |
+ secs = TO_SECS(value); | |
+ return secs; | |
+} | |
+//Huaqin add by jianghao at 2019/05/13 end | |
+ | |
static int | |
qpnp_rtc_read_time(struct device *dev, struct rtc_time *tm) | |
{ | |
@@ -496,6 +541,9 @@ static int qpnp_rtc_probe(struct platform_device *pdev) | |
dev_err(&pdev->dev, "Couldn't get parent's regmap\n"); | |
return -EINVAL; | |
} | |
+//Huaqin add by jianghao at 2019/05/13 start | |
+ asus_rtc_dd = rtc_dd; | |
+//Huaqin add by jianghao at 2019/05/13 end | |
/* Get the rtc write property */ | |
rc = of_property_read_u32(pdev->dev.of_node, "qcom,qpnp-rtc-write", |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment