(CR) [Kane]:kernel:modify ntc thermistor and add charge temp node
authorxuke <xuke@huaqin.com>
Fri, 9 Nov 2018 07:59:29 +0000 (15:59 +0800)
committerxiest1 <xiest1@lenovo.com>
Tue, 5 Nov 2019 09:29:55 +0000 (17:29 +0800)
Change-Id: I79a1e23f2a341e107626e21067bd65a4e52e3bcd

drivers/power/supply/power_supply_sysfs.c [changed mode: 0644->0755]
drivers/power/supply/s2mu106_fuelgauge.c
include/linux/power/s2mu106_fuelgauge.h

old mode 100644 (file)
new mode 100755 (executable)
index 5d5920ea94071ce88508c11f6b04444989b25355..b78fcfeb8e13a56f652feddd27c324f377ed303b 100644 (file)
@@ -321,6 +321,35 @@ static void s2mu106_alert_init(struct s2mu106_fuelgauge_data *fuelgauge)
        s2mu106_write_reg(fuelgauge->i2c, S2MU106_REG_IRQ_LVL, data);
 }
 
+static int s2mu106_get_batt_temperature(void){
+        struct file *fp;
+        mm_segment_t old_fs;
+        char buf[20] = {0};
+        loff_t pos = 0;
+        long int val = 0;
+
+        fp = filp_open(BATT_THERMAL_PATH, O_RDONLY, 0);
+        if (IS_ERR(fp)) {
+                pr_err("%s: file open failed\n", __func__);
+                return -EINVAL;
+        }
+
+        old_fs = get_fs();
+        set_fs(KERNEL_DS);
+        vfs_read(fp, buf, sizeof(buf), &pos);
+        if (kstrtol(buf, 10, &val) < 0) {
+                return -EINVAL;
+        }
+        set_fs(old_fs);
+        filp_close(fp, NULL);
+        val = val/100;
+        if (val == BATT_NTC100K_ORIGINAL_TEMP) {
+                val = BATT_NTC100K_NOW_TEMP;
+        }
+
+        return val;
+}
+
 static int s2mu106_set_temperature(struct s2mu106_fuelgauge_data *fuelgauge,
                        int temperature)
 {
index c8f88468419c52e79526a8a1e86b6d190191f01c..ea481b365ed204d9c84cc8a68c63b05d2ba5ee3f 100644 (file)
 
 #define S2MU106_REG_VM                 0x67
 
+#define BATT_THERMAL_PATH              "/sys/class/hwmon/hwmon1/temp1_input"
+#define BATT_NTC100K_ORIGINAL_TEMP             1250
+#define BATT_NTC100K_NOW_TEMP                  250
+
 enum {
        CURRENT_MODE = 0,
        LOW_SOC_VOLTAGE_MODE, // not used