int n_comp;
};
+struct ntc_data *data_ntc = NULL;
+
#if defined(CONFIG_OF) && IS_ENABLED(CONFIG_IIO)
static int ntc_adc_iio_read(struct ntc_thermistor_platform_data *pdata)
{
return sprintf(buf, "%d\n", get_temp_mc(data, ohm));
}
+int ntc_show_batt_temp()
+{
+ int ohm;
+ int temp;
+
+ if (data_ntc == NULL) {
+ pr_err("%s data is NULL!\n", __func__);
+ return 250;
+ }
+ ohm = ntc_thermistor_get_ohm(data_ntc);
+ if (ohm < 0)
+ return ohm;
+ temp = get_temp_mc(data_ntc, ohm) / 100;
+ if (temp == BATT_NTC100K_ORIGINAL_TEMP) {
+ temp = BATT_NTC100K_NOW_TEMP;
+ }
+
+ return temp;
+}
+EXPORT_SYMBOL_GPL(ntc_show_batt_temp);
+
static SENSOR_DEVICE_ATTR(temp1_type, S_IRUGO, ntc_show_type, NULL, 0);
static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, ntc_show_temp, NULL, 0);
pdev_id = of_id ? of_id->data : platform_get_device_id(pdev);
data->pdata = pdata;
+ data_ntc = data;
switch (pdev_id->driver_data) {
case TYPE_NCPXXWB473:
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)
{
#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