Loading drivers/power/supply/qcom/batterydata-interface.c +4 −4 Original line number Diff line number Diff line Loading @@ -66,7 +66,7 @@ static long battery_data_ioctl(struct file *file, unsigned int cmd, switch (cmd) { case BPIOCXSOC: soc = interpolate_pc(battery->profile->pc_temp_ocv_lut, soc = interpolate_pc_bms(battery->profile->pc_temp_ocv_lut, bp.batt_temp, bp.ocv_uv / 1000); rc = put_user(soc, &bp_user->soc); if (rc) { Loading @@ -77,7 +77,7 @@ static long battery_data_ioctl(struct file *file, unsigned int cmd, bp.ocv_uv / 1000, bp.batt_temp, soc); break; case BPIOCXRBATT: rbatt_sf = interpolate_scalingfactor( rbatt_sf = interpolate_scalingfactor_bms( battery->profile->rbatt_sf_lut, bp.batt_temp, bp.soc); rc = put_user(rbatt_sf, &bp_user->rbatt_sf); Loading @@ -89,7 +89,7 @@ static long battery_data_ioctl(struct file *file, unsigned int cmd, bp.soc, bp.batt_temp, rbatt_sf); break; case BPIOCXSLOPE: slope = interpolate_slope(battery->profile->pc_temp_ocv_lut, slope = interpolate_slope_bms(battery->profile->pc_temp_ocv_lut, bp.batt_temp, bp.soc); rc = put_user(slope, &bp_user->slope); if (rc) { Loading @@ -100,7 +100,7 @@ static long battery_data_ioctl(struct file *file, unsigned int cmd, bp.soc, bp.batt_temp, slope); break; case BPIOCXFCC: fcc_mah = interpolate_fcc(battery->profile->fcc_temp_lut, fcc_mah = interpolate_fcc_bms(battery->profile->fcc_temp_lut, bp.batt_temp); rc = put_user(fcc_mah, &bp_user->fcc_mah); if (rc) { Loading drivers/power/supply/qcom/batterydata-lib.c +30 −30 Original line number Diff line number Diff line Loading @@ -15,7 +15,7 @@ #include <linux/module.h> #include <linux/batterydata-lib.h> int linear_interpolate(int y0, int x0, int y1, int x1, int x) int linear_interpolate_bms(int y0, int x0, int y1, int x1, int x) { if (y0 == y1 || x == x0) return y0; Loading @@ -25,7 +25,7 @@ int linear_interpolate(int y0, int x0, int y1, int x1, int x) return y0 + ((y1 - y0) * (x - x0) / (x1 - x0)); } static int interpolate_single_lut_scaled(struct single_row_lut *lut, static int interpolate_single_lut_scaled_bms(struct single_row_lut *lut, int x, int scale) { int i, result; Loading @@ -47,7 +47,7 @@ static int interpolate_single_lut_scaled(struct single_row_lut *lut, if (x == lut->x[i] * scale) { result = lut->y[i]; } else { result = linear_interpolate( result = linear_interpolate_bms( lut->y[i - 1], lut->x[i - 1] * scale, lut->y[i], Loading @@ -57,14 +57,14 @@ static int interpolate_single_lut_scaled(struct single_row_lut *lut, return result; } int interpolate_fcc(struct single_row_lut *fcc_temp_lut, int batt_temp) int interpolate_fcc_bms(struct single_row_lut *fcc_temp_lut, int batt_temp) { return interpolate_single_lut_scaled(fcc_temp_lut, return interpolate_single_lut_scaled_bms(fcc_temp_lut, batt_temp, DEGC_SCALE); } int interpolate_scalingfactor_fcc(struct single_row_lut *fcc_sf_lut, int interpolate_scalingfactor_fcc_bms(struct single_row_lut *fcc_sf_lut, int cycles) { /* Loading @@ -72,12 +72,12 @@ int interpolate_scalingfactor_fcc(struct single_row_lut *fcc_sf_lut, * that case return 100% */ if (fcc_sf_lut) return interpolate_single_lut_scaled(fcc_sf_lut, cycles, 1); return interpolate_single_lut_scaled_bms(fcc_sf_lut, cycles, 1); else return 100; } int interpolate_scalingfactor(struct sf_lut *sf_lut, int row_entry, int pc) int interpolate_scalingfactor_bms(struct sf_lut *sf_lut, int row_entry, int pc) { int i, scalefactorrow1, scalefactorrow2, scalefactor, rows, cols; int row1 = 0; Loading Loading @@ -124,7 +124,7 @@ int interpolate_scalingfactor(struct sf_lut *sf_lut, int row_entry, int pc) if (row_entry <= sf_lut->row_entries[i] * DEGC_SCALE) break; if (row_entry == sf_lut->row_entries[i] * DEGC_SCALE) { scalefactor = linear_interpolate( scalefactor = linear_interpolate_bms( sf_lut->sf[row1][i], sf_lut->percent[row1], sf_lut->sf[row2][i], Loading @@ -133,21 +133,21 @@ int interpolate_scalingfactor(struct sf_lut *sf_lut, int row_entry, int pc) return scalefactor; } scalefactorrow1 = linear_interpolate( scalefactorrow1 = linear_interpolate_bms( sf_lut->sf[row1][i - 1], sf_lut->row_entries[i - 1] * DEGC_SCALE, sf_lut->sf[row1][i], sf_lut->row_entries[i] * DEGC_SCALE, row_entry); scalefactorrow2 = linear_interpolate( scalefactorrow2 = linear_interpolate_bms( sf_lut->sf[row2][i - 1], sf_lut->row_entries[i - 1] * DEGC_SCALE, sf_lut->sf[row2][i], sf_lut->row_entries[i] * DEGC_SCALE, row_entry); scalefactor = linear_interpolate( scalefactor = linear_interpolate_bms( scalefactorrow1, sf_lut->percent[row1], scalefactorrow2, Loading @@ -158,7 +158,7 @@ int interpolate_scalingfactor(struct sf_lut *sf_lut, int row_entry, int pc) } /* get ocv given a soc -- reverse lookup */ int interpolate_ocv(struct pc_temp_ocv_lut *pc_temp_ocv, int interpolate_ocv_bms(struct pc_temp_ocv_lut *pc_temp_ocv, int batt_temp, int pc) { int i, ocvrow1, ocvrow2, ocv, rows, cols; Loading Loading @@ -199,7 +199,7 @@ int interpolate_ocv(struct pc_temp_ocv_lut *pc_temp_ocv, if (batt_temp <= pc_temp_ocv->temp[i] * DEGC_SCALE) break; if (batt_temp == pc_temp_ocv->temp[i] * DEGC_SCALE) { ocv = linear_interpolate( ocv = linear_interpolate_bms( pc_temp_ocv->ocv[row1][i], pc_temp_ocv->percent[row1], pc_temp_ocv->ocv[row2][i], Loading @@ -208,21 +208,21 @@ int interpolate_ocv(struct pc_temp_ocv_lut *pc_temp_ocv, return ocv; } ocvrow1 = linear_interpolate( ocvrow1 = linear_interpolate_bms( pc_temp_ocv->ocv[row1][i - 1], pc_temp_ocv->temp[i - 1] * DEGC_SCALE, pc_temp_ocv->ocv[row1][i], pc_temp_ocv->temp[i] * DEGC_SCALE, batt_temp); ocvrow2 = linear_interpolate( ocvrow2 = linear_interpolate_bms( pc_temp_ocv->ocv[row2][i - 1], pc_temp_ocv->temp[i - 1] * DEGC_SCALE, pc_temp_ocv->ocv[row2][i], pc_temp_ocv->temp[i] * DEGC_SCALE, batt_temp); ocv = linear_interpolate( ocv = linear_interpolate_bms( ocvrow1, pc_temp_ocv->percent[row1], ocvrow2, Loading @@ -232,7 +232,7 @@ int interpolate_ocv(struct pc_temp_ocv_lut *pc_temp_ocv, return ocv; } int interpolate_pc(struct pc_temp_ocv_lut *pc_temp_ocv, int interpolate_pc_bms(struct pc_temp_ocv_lut *pc_temp_ocv, int batt_temp, int ocv) { int i, j, pcj, pcj_minus_one, pc; Loading Loading @@ -262,7 +262,7 @@ int interpolate_pc(struct pc_temp_ocv_lut *pc_temp_ocv, if (ocv >= pc_temp_ocv->ocv[i][j]) { if (ocv == pc_temp_ocv->ocv[i][j]) return pc_temp_ocv->percent[i]; pc = linear_interpolate( pc = linear_interpolate_bms( pc_temp_ocv->percent[i], pc_temp_ocv->ocv[i][j], pc_temp_ocv->percent[i - 1], Loading @@ -288,7 +288,7 @@ int interpolate_pc(struct pc_temp_ocv_lut *pc_temp_ocv, if (pcj == 0 && is_between(pc_temp_ocv->ocv[i][j], pc_temp_ocv->ocv[i+1][j], ocv)) { pcj = linear_interpolate( pcj = linear_interpolate_bms( pc_temp_ocv->percent[i], pc_temp_ocv->ocv[i][j], pc_temp_ocv->percent[i + 1], Loading @@ -299,7 +299,7 @@ int interpolate_pc(struct pc_temp_ocv_lut *pc_temp_ocv, if (pcj_minus_one == 0 && is_between(pc_temp_ocv->ocv[i][j-1], pc_temp_ocv->ocv[i+1][j-1], ocv)) { pcj_minus_one = linear_interpolate( pcj_minus_one = linear_interpolate_bms( pc_temp_ocv->percent[i], pc_temp_ocv->ocv[i][j-1], pc_temp_ocv->percent[i + 1], Loading @@ -308,7 +308,7 @@ int interpolate_pc(struct pc_temp_ocv_lut *pc_temp_ocv, } if (pcj && pcj_minus_one) { pc = linear_interpolate( pc = linear_interpolate_bms( pcj_minus_one, pc_temp_ocv->temp[j-1] * DEGC_SCALE, pcj, Loading @@ -329,7 +329,7 @@ int interpolate_pc(struct pc_temp_ocv_lut *pc_temp_ocv, return 100; } int interpolate_slope(struct pc_temp_ocv_lut *pc_temp_ocv, int interpolate_slope_bms(struct pc_temp_ocv_lut *pc_temp_ocv, int batt_temp, int pc) { int i, ocvrow1, ocvrow2, rows, cols; Loading Loading @@ -385,14 +385,14 @@ int interpolate_slope(struct pc_temp_ocv_lut *pc_temp_ocv, pc_temp_ocv->percent[row2]); return slope; } ocvrow1 = linear_interpolate( ocvrow1 = linear_interpolate_bms( pc_temp_ocv->ocv[row1][i - 1], pc_temp_ocv->temp[i - 1] * DEGC_SCALE, pc_temp_ocv->ocv[row1][i], pc_temp_ocv->temp[i] * DEGC_SCALE, batt_temp); ocvrow2 = linear_interpolate( ocvrow2 = linear_interpolate_bms( pc_temp_ocv->ocv[row2][i - 1], pc_temp_ocv->temp[i - 1] * DEGC_SCALE, pc_temp_ocv->ocv[row2][i], Loading @@ -411,7 +411,7 @@ int interpolate_slope(struct pc_temp_ocv_lut *pc_temp_ocv, } int interpolate_acc(struct ibat_temp_acc_lut *ibat_acc_lut, int interpolate_acc_bms(struct ibat_temp_acc_lut *ibat_acc_lut, int batt_temp, int ibat) { int i, accrow1, accrow2, rows, cols; Loading Loading @@ -457,7 +457,7 @@ int interpolate_acc(struct ibat_temp_acc_lut *ibat_acc_lut, break; if (batt_temp == (ibat_acc_lut->temp[i] * DEGC_SCALE)) { acc = linear_interpolate( acc = linear_interpolate_bms( ibat_acc_lut->acc[row1][i], ibat_acc_lut->ibat[row1], ibat_acc_lut->acc[row2][i], Loading @@ -466,21 +466,21 @@ int interpolate_acc(struct ibat_temp_acc_lut *ibat_acc_lut, return acc; } accrow1 = linear_interpolate( accrow1 = linear_interpolate_bms( ibat_acc_lut->acc[row1][i - 1], ibat_acc_lut->temp[i - 1] * DEGC_SCALE, ibat_acc_lut->acc[row1][i], ibat_acc_lut->temp[i] * DEGC_SCALE, batt_temp); accrow2 = linear_interpolate( accrow2 = linear_interpolate_bms( ibat_acc_lut->acc[row2][i - 1], ibat_acc_lut->temp[i - 1] * DEGC_SCALE, ibat_acc_lut->acc[row2][i], ibat_acc_lut->temp[i] * DEGC_SCALE, batt_temp); acc = linear_interpolate(accrow1, acc = linear_interpolate_bms(accrow1, ibat_acc_lut->ibat[row1], accrow2, ibat_acc_lut->ibat[row2], Loading drivers/power/supply/qcom/qpnp-vm-bms.c +8 −7 Original line number Diff line number Diff line Loading @@ -953,9 +953,9 @@ static int lookup_soc_ocv(struct qpnp_bms_chip *chip, int ocv_uv, int batt_temp) int soc_ocv = 0, soc_cutoff = 0, soc_final = 0; int fcc, acc, soc_uuc = 0, soc_acc = 0, iavg_ma = 0; soc_ocv = interpolate_pc(chip->batt_data->pc_temp_ocv_lut, soc_ocv = interpolate_pc_bms(chip->batt_data->pc_temp_ocv_lut, batt_temp, ocv_uv / 1000); soc_cutoff = interpolate_pc(chip->batt_data->pc_temp_ocv_lut, soc_cutoff = interpolate_pc_bms(chip->batt_data->pc_temp_ocv_lut, batt_temp, chip->dt.cfg_v_cutoff_uv / 1000); soc_final = DIV_ROUND_CLOSEST(100 * (soc_ocv - soc_cutoff), Loading @@ -974,9 +974,9 @@ static int lookup_soc_ocv(struct qpnp_bms_chip *chip, int ocv_uv, int batt_temp) else iavg_ma = chip->current_now / 1000; fcc = interpolate_fcc(chip->batt_data->fcc_temp_lut, fcc = interpolate_fcc_bms(chip->batt_data->fcc_temp_lut, batt_temp); acc = interpolate_acc(chip->batt_data->ibat_acc_lut, acc = interpolate_acc_bms(chip->batt_data->ibat_acc_lut, batt_temp, iavg_ma); if (acc <= 0) { if (chip->last_acc) Loading Loading @@ -1249,7 +1249,8 @@ static int get_rbatt(struct qpnp_bms_chip *chip, int soc, int batt_temp) return rbatt_mohm; } scalefactor = interpolate_scalingfactor(chip->batt_data->rbatt_sf_lut, scalefactor = interpolate_scalingfactor_bms( chip->batt_data->rbatt_sf_lut, batt_temp, soc); rbatt_mohm = (rbatt_mohm * scalefactor) / 100; Loading Loading @@ -2847,7 +2848,7 @@ static int interpolate_current_comp(int die_temp) if (die_temp == (temp_curr_comp_lut[i].temp_decideg)) return temp_curr_comp_lut[i].current_ma; return linear_interpolate( return linear_interpolate_bms( temp_curr_comp_lut[i - 1].current_ma, temp_curr_comp_lut[i - 1].temp_decideg, temp_curr_comp_lut[i].current_ma, Loading @@ -2864,7 +2865,7 @@ static void adjust_pon_ocv(struct qpnp_bms_chip *chip, int batt_temp) if (rc) { pr_err("error reading adc channel=%d, rc=%d\n", DIE_TEMP, rc); } else { pc = interpolate_pc(chip->batt_data->pc_temp_ocv_lut, pc = interpolate_pc_bms(chip->batt_data->pc_temp_ocv_lut, batt_temp, chip->last_ocv_uv / 1000); /* * For pc < 2, use the rbatt of pc = 2. This is to avoid Loading include/linux/batterydata-lib.h +17 −17 Original line number Diff line number Diff line /* Copyright (c) 2012-2015, The Linux Foundation. All rights reserved. /* Copyright (c) 2012-2015, 2018, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and Loading Loading @@ -160,55 +160,55 @@ extern struct bms_battery_data oem_batt_data; extern struct bms_battery_data QRD_4v35_2000mAh_data; extern struct bms_battery_data qrd_4v2_1300mah_data; int interpolate_fcc(struct single_row_lut *fcc_temp_lut, int batt_temp); int interpolate_scalingfactor(struct sf_lut *sf_lut, int row_entry, int pc); int interpolate_scalingfactor_fcc(struct single_row_lut *fcc_sf_lut, int interpolate_fcc_bms(struct single_row_lut *fcc_temp_lut, int batt_temp); int interpolate_scalingfactor_bms(struct sf_lut *sf_lut, int row_entry, int pc); int interpolate_scalingfactor_fcc_bms(struct single_row_lut *fcc_sf_lut, int cycles); int interpolate_pc(struct pc_temp_ocv_lut *pc_temp_ocv, int interpolate_pc_bms(struct pc_temp_ocv_lut *pc_temp_ocv, int batt_temp_degc, int ocv); int interpolate_ocv(struct pc_temp_ocv_lut *pc_temp_ocv, int interpolate_ocv_bms(struct pc_temp_ocv_lut *pc_temp_ocv, int batt_temp_degc, int pc); int interpolate_slope(struct pc_temp_ocv_lut *pc_temp_ocv, int interpolate_slope_bms(struct pc_temp_ocv_lut *pc_temp_ocv, int batt_temp, int pc); int interpolate_acc(struct ibat_temp_acc_lut *ibat_acc_lut, int interpolate_acc_bms(struct ibat_temp_acc_lut *ibat_acc_lut, int batt_temp, int ibat); int linear_interpolate(int y0, int x0, int y1, int x1, int x); int linear_interpolate_bms(int y0, int x0, int y1, int x1, int x); #else static inline int interpolate_fcc(struct single_row_lut *fcc_temp_lut, static inline int interpolate_fcc_bms(struct single_row_lut *fcc_temp_lut, int batt_temp) { return -EINVAL; } static inline int interpolate_scalingfactor(struct sf_lut *sf_lut, static inline int interpolate_scalingfactor_bms(struct sf_lut *sf_lut, int row_entry, int pc) { return -EINVAL; } static inline int interpolate_scalingfactor_fcc( static inline int interpolate_scalingfactor_fcc_bms( struct single_row_lut *fcc_sf_lut, int cycles) { return -EINVAL; } static inline int interpolate_pc(struct pc_temp_ocv_lut *pc_temp_ocv, static inline int interpolate_pc_bms(struct pc_temp_ocv_lut *pc_temp_ocv, int batt_temp_degc, int ocv) { return -EINVAL; } static inline int interpolate_ocv(struct pc_temp_ocv_lut *pc_temp_ocv, static inline int interpolate_ocv_bms(struct pc_temp_ocv_lut *pc_temp_ocv, int batt_temp_degc, int pc) { return -EINVAL; } static inline int interpolate_slope(struct pc_temp_ocv_lut *pc_temp_ocv, static inline int interpolate_slope_bms(struct pc_temp_ocv_lut *pc_temp_ocv, int batt_temp, int pc) { return -EINVAL; } static inline int linear_interpolate(int y0, int x0, int y1, int x1, int x) static inline int linear_interpolate_bms(int y0, int x0, int y1, int x1, int x) { return -EINVAL; } static inline int interpolate_acc(struct ibat_temp_acc_lut *ibat_acc_lut, static inline int interpolate_acc_bms(struct ibat_temp_acc_lut *ibat_acc_lut, int batt_temp, int ibat) { return -EINVAL; Loading Loading
drivers/power/supply/qcom/batterydata-interface.c +4 −4 Original line number Diff line number Diff line Loading @@ -66,7 +66,7 @@ static long battery_data_ioctl(struct file *file, unsigned int cmd, switch (cmd) { case BPIOCXSOC: soc = interpolate_pc(battery->profile->pc_temp_ocv_lut, soc = interpolate_pc_bms(battery->profile->pc_temp_ocv_lut, bp.batt_temp, bp.ocv_uv / 1000); rc = put_user(soc, &bp_user->soc); if (rc) { Loading @@ -77,7 +77,7 @@ static long battery_data_ioctl(struct file *file, unsigned int cmd, bp.ocv_uv / 1000, bp.batt_temp, soc); break; case BPIOCXRBATT: rbatt_sf = interpolate_scalingfactor( rbatt_sf = interpolate_scalingfactor_bms( battery->profile->rbatt_sf_lut, bp.batt_temp, bp.soc); rc = put_user(rbatt_sf, &bp_user->rbatt_sf); Loading @@ -89,7 +89,7 @@ static long battery_data_ioctl(struct file *file, unsigned int cmd, bp.soc, bp.batt_temp, rbatt_sf); break; case BPIOCXSLOPE: slope = interpolate_slope(battery->profile->pc_temp_ocv_lut, slope = interpolate_slope_bms(battery->profile->pc_temp_ocv_lut, bp.batt_temp, bp.soc); rc = put_user(slope, &bp_user->slope); if (rc) { Loading @@ -100,7 +100,7 @@ static long battery_data_ioctl(struct file *file, unsigned int cmd, bp.soc, bp.batt_temp, slope); break; case BPIOCXFCC: fcc_mah = interpolate_fcc(battery->profile->fcc_temp_lut, fcc_mah = interpolate_fcc_bms(battery->profile->fcc_temp_lut, bp.batt_temp); rc = put_user(fcc_mah, &bp_user->fcc_mah); if (rc) { Loading
drivers/power/supply/qcom/batterydata-lib.c +30 −30 Original line number Diff line number Diff line Loading @@ -15,7 +15,7 @@ #include <linux/module.h> #include <linux/batterydata-lib.h> int linear_interpolate(int y0, int x0, int y1, int x1, int x) int linear_interpolate_bms(int y0, int x0, int y1, int x1, int x) { if (y0 == y1 || x == x0) return y0; Loading @@ -25,7 +25,7 @@ int linear_interpolate(int y0, int x0, int y1, int x1, int x) return y0 + ((y1 - y0) * (x - x0) / (x1 - x0)); } static int interpolate_single_lut_scaled(struct single_row_lut *lut, static int interpolate_single_lut_scaled_bms(struct single_row_lut *lut, int x, int scale) { int i, result; Loading @@ -47,7 +47,7 @@ static int interpolate_single_lut_scaled(struct single_row_lut *lut, if (x == lut->x[i] * scale) { result = lut->y[i]; } else { result = linear_interpolate( result = linear_interpolate_bms( lut->y[i - 1], lut->x[i - 1] * scale, lut->y[i], Loading @@ -57,14 +57,14 @@ static int interpolate_single_lut_scaled(struct single_row_lut *lut, return result; } int interpolate_fcc(struct single_row_lut *fcc_temp_lut, int batt_temp) int interpolate_fcc_bms(struct single_row_lut *fcc_temp_lut, int batt_temp) { return interpolate_single_lut_scaled(fcc_temp_lut, return interpolate_single_lut_scaled_bms(fcc_temp_lut, batt_temp, DEGC_SCALE); } int interpolate_scalingfactor_fcc(struct single_row_lut *fcc_sf_lut, int interpolate_scalingfactor_fcc_bms(struct single_row_lut *fcc_sf_lut, int cycles) { /* Loading @@ -72,12 +72,12 @@ int interpolate_scalingfactor_fcc(struct single_row_lut *fcc_sf_lut, * that case return 100% */ if (fcc_sf_lut) return interpolate_single_lut_scaled(fcc_sf_lut, cycles, 1); return interpolate_single_lut_scaled_bms(fcc_sf_lut, cycles, 1); else return 100; } int interpolate_scalingfactor(struct sf_lut *sf_lut, int row_entry, int pc) int interpolate_scalingfactor_bms(struct sf_lut *sf_lut, int row_entry, int pc) { int i, scalefactorrow1, scalefactorrow2, scalefactor, rows, cols; int row1 = 0; Loading Loading @@ -124,7 +124,7 @@ int interpolate_scalingfactor(struct sf_lut *sf_lut, int row_entry, int pc) if (row_entry <= sf_lut->row_entries[i] * DEGC_SCALE) break; if (row_entry == sf_lut->row_entries[i] * DEGC_SCALE) { scalefactor = linear_interpolate( scalefactor = linear_interpolate_bms( sf_lut->sf[row1][i], sf_lut->percent[row1], sf_lut->sf[row2][i], Loading @@ -133,21 +133,21 @@ int interpolate_scalingfactor(struct sf_lut *sf_lut, int row_entry, int pc) return scalefactor; } scalefactorrow1 = linear_interpolate( scalefactorrow1 = linear_interpolate_bms( sf_lut->sf[row1][i - 1], sf_lut->row_entries[i - 1] * DEGC_SCALE, sf_lut->sf[row1][i], sf_lut->row_entries[i] * DEGC_SCALE, row_entry); scalefactorrow2 = linear_interpolate( scalefactorrow2 = linear_interpolate_bms( sf_lut->sf[row2][i - 1], sf_lut->row_entries[i - 1] * DEGC_SCALE, sf_lut->sf[row2][i], sf_lut->row_entries[i] * DEGC_SCALE, row_entry); scalefactor = linear_interpolate( scalefactor = linear_interpolate_bms( scalefactorrow1, sf_lut->percent[row1], scalefactorrow2, Loading @@ -158,7 +158,7 @@ int interpolate_scalingfactor(struct sf_lut *sf_lut, int row_entry, int pc) } /* get ocv given a soc -- reverse lookup */ int interpolate_ocv(struct pc_temp_ocv_lut *pc_temp_ocv, int interpolate_ocv_bms(struct pc_temp_ocv_lut *pc_temp_ocv, int batt_temp, int pc) { int i, ocvrow1, ocvrow2, ocv, rows, cols; Loading Loading @@ -199,7 +199,7 @@ int interpolate_ocv(struct pc_temp_ocv_lut *pc_temp_ocv, if (batt_temp <= pc_temp_ocv->temp[i] * DEGC_SCALE) break; if (batt_temp == pc_temp_ocv->temp[i] * DEGC_SCALE) { ocv = linear_interpolate( ocv = linear_interpolate_bms( pc_temp_ocv->ocv[row1][i], pc_temp_ocv->percent[row1], pc_temp_ocv->ocv[row2][i], Loading @@ -208,21 +208,21 @@ int interpolate_ocv(struct pc_temp_ocv_lut *pc_temp_ocv, return ocv; } ocvrow1 = linear_interpolate( ocvrow1 = linear_interpolate_bms( pc_temp_ocv->ocv[row1][i - 1], pc_temp_ocv->temp[i - 1] * DEGC_SCALE, pc_temp_ocv->ocv[row1][i], pc_temp_ocv->temp[i] * DEGC_SCALE, batt_temp); ocvrow2 = linear_interpolate( ocvrow2 = linear_interpolate_bms( pc_temp_ocv->ocv[row2][i - 1], pc_temp_ocv->temp[i - 1] * DEGC_SCALE, pc_temp_ocv->ocv[row2][i], pc_temp_ocv->temp[i] * DEGC_SCALE, batt_temp); ocv = linear_interpolate( ocv = linear_interpolate_bms( ocvrow1, pc_temp_ocv->percent[row1], ocvrow2, Loading @@ -232,7 +232,7 @@ int interpolate_ocv(struct pc_temp_ocv_lut *pc_temp_ocv, return ocv; } int interpolate_pc(struct pc_temp_ocv_lut *pc_temp_ocv, int interpolate_pc_bms(struct pc_temp_ocv_lut *pc_temp_ocv, int batt_temp, int ocv) { int i, j, pcj, pcj_minus_one, pc; Loading Loading @@ -262,7 +262,7 @@ int interpolate_pc(struct pc_temp_ocv_lut *pc_temp_ocv, if (ocv >= pc_temp_ocv->ocv[i][j]) { if (ocv == pc_temp_ocv->ocv[i][j]) return pc_temp_ocv->percent[i]; pc = linear_interpolate( pc = linear_interpolate_bms( pc_temp_ocv->percent[i], pc_temp_ocv->ocv[i][j], pc_temp_ocv->percent[i - 1], Loading @@ -288,7 +288,7 @@ int interpolate_pc(struct pc_temp_ocv_lut *pc_temp_ocv, if (pcj == 0 && is_between(pc_temp_ocv->ocv[i][j], pc_temp_ocv->ocv[i+1][j], ocv)) { pcj = linear_interpolate( pcj = linear_interpolate_bms( pc_temp_ocv->percent[i], pc_temp_ocv->ocv[i][j], pc_temp_ocv->percent[i + 1], Loading @@ -299,7 +299,7 @@ int interpolate_pc(struct pc_temp_ocv_lut *pc_temp_ocv, if (pcj_minus_one == 0 && is_between(pc_temp_ocv->ocv[i][j-1], pc_temp_ocv->ocv[i+1][j-1], ocv)) { pcj_minus_one = linear_interpolate( pcj_minus_one = linear_interpolate_bms( pc_temp_ocv->percent[i], pc_temp_ocv->ocv[i][j-1], pc_temp_ocv->percent[i + 1], Loading @@ -308,7 +308,7 @@ int interpolate_pc(struct pc_temp_ocv_lut *pc_temp_ocv, } if (pcj && pcj_minus_one) { pc = linear_interpolate( pc = linear_interpolate_bms( pcj_minus_one, pc_temp_ocv->temp[j-1] * DEGC_SCALE, pcj, Loading @@ -329,7 +329,7 @@ int interpolate_pc(struct pc_temp_ocv_lut *pc_temp_ocv, return 100; } int interpolate_slope(struct pc_temp_ocv_lut *pc_temp_ocv, int interpolate_slope_bms(struct pc_temp_ocv_lut *pc_temp_ocv, int batt_temp, int pc) { int i, ocvrow1, ocvrow2, rows, cols; Loading Loading @@ -385,14 +385,14 @@ int interpolate_slope(struct pc_temp_ocv_lut *pc_temp_ocv, pc_temp_ocv->percent[row2]); return slope; } ocvrow1 = linear_interpolate( ocvrow1 = linear_interpolate_bms( pc_temp_ocv->ocv[row1][i - 1], pc_temp_ocv->temp[i - 1] * DEGC_SCALE, pc_temp_ocv->ocv[row1][i], pc_temp_ocv->temp[i] * DEGC_SCALE, batt_temp); ocvrow2 = linear_interpolate( ocvrow2 = linear_interpolate_bms( pc_temp_ocv->ocv[row2][i - 1], pc_temp_ocv->temp[i - 1] * DEGC_SCALE, pc_temp_ocv->ocv[row2][i], Loading @@ -411,7 +411,7 @@ int interpolate_slope(struct pc_temp_ocv_lut *pc_temp_ocv, } int interpolate_acc(struct ibat_temp_acc_lut *ibat_acc_lut, int interpolate_acc_bms(struct ibat_temp_acc_lut *ibat_acc_lut, int batt_temp, int ibat) { int i, accrow1, accrow2, rows, cols; Loading Loading @@ -457,7 +457,7 @@ int interpolate_acc(struct ibat_temp_acc_lut *ibat_acc_lut, break; if (batt_temp == (ibat_acc_lut->temp[i] * DEGC_SCALE)) { acc = linear_interpolate( acc = linear_interpolate_bms( ibat_acc_lut->acc[row1][i], ibat_acc_lut->ibat[row1], ibat_acc_lut->acc[row2][i], Loading @@ -466,21 +466,21 @@ int interpolate_acc(struct ibat_temp_acc_lut *ibat_acc_lut, return acc; } accrow1 = linear_interpolate( accrow1 = linear_interpolate_bms( ibat_acc_lut->acc[row1][i - 1], ibat_acc_lut->temp[i - 1] * DEGC_SCALE, ibat_acc_lut->acc[row1][i], ibat_acc_lut->temp[i] * DEGC_SCALE, batt_temp); accrow2 = linear_interpolate( accrow2 = linear_interpolate_bms( ibat_acc_lut->acc[row2][i - 1], ibat_acc_lut->temp[i - 1] * DEGC_SCALE, ibat_acc_lut->acc[row2][i], ibat_acc_lut->temp[i] * DEGC_SCALE, batt_temp); acc = linear_interpolate(accrow1, acc = linear_interpolate_bms(accrow1, ibat_acc_lut->ibat[row1], accrow2, ibat_acc_lut->ibat[row2], Loading
drivers/power/supply/qcom/qpnp-vm-bms.c +8 −7 Original line number Diff line number Diff line Loading @@ -953,9 +953,9 @@ static int lookup_soc_ocv(struct qpnp_bms_chip *chip, int ocv_uv, int batt_temp) int soc_ocv = 0, soc_cutoff = 0, soc_final = 0; int fcc, acc, soc_uuc = 0, soc_acc = 0, iavg_ma = 0; soc_ocv = interpolate_pc(chip->batt_data->pc_temp_ocv_lut, soc_ocv = interpolate_pc_bms(chip->batt_data->pc_temp_ocv_lut, batt_temp, ocv_uv / 1000); soc_cutoff = interpolate_pc(chip->batt_data->pc_temp_ocv_lut, soc_cutoff = interpolate_pc_bms(chip->batt_data->pc_temp_ocv_lut, batt_temp, chip->dt.cfg_v_cutoff_uv / 1000); soc_final = DIV_ROUND_CLOSEST(100 * (soc_ocv - soc_cutoff), Loading @@ -974,9 +974,9 @@ static int lookup_soc_ocv(struct qpnp_bms_chip *chip, int ocv_uv, int batt_temp) else iavg_ma = chip->current_now / 1000; fcc = interpolate_fcc(chip->batt_data->fcc_temp_lut, fcc = interpolate_fcc_bms(chip->batt_data->fcc_temp_lut, batt_temp); acc = interpolate_acc(chip->batt_data->ibat_acc_lut, acc = interpolate_acc_bms(chip->batt_data->ibat_acc_lut, batt_temp, iavg_ma); if (acc <= 0) { if (chip->last_acc) Loading Loading @@ -1249,7 +1249,8 @@ static int get_rbatt(struct qpnp_bms_chip *chip, int soc, int batt_temp) return rbatt_mohm; } scalefactor = interpolate_scalingfactor(chip->batt_data->rbatt_sf_lut, scalefactor = interpolate_scalingfactor_bms( chip->batt_data->rbatt_sf_lut, batt_temp, soc); rbatt_mohm = (rbatt_mohm * scalefactor) / 100; Loading Loading @@ -2847,7 +2848,7 @@ static int interpolate_current_comp(int die_temp) if (die_temp == (temp_curr_comp_lut[i].temp_decideg)) return temp_curr_comp_lut[i].current_ma; return linear_interpolate( return linear_interpolate_bms( temp_curr_comp_lut[i - 1].current_ma, temp_curr_comp_lut[i - 1].temp_decideg, temp_curr_comp_lut[i].current_ma, Loading @@ -2864,7 +2865,7 @@ static void adjust_pon_ocv(struct qpnp_bms_chip *chip, int batt_temp) if (rc) { pr_err("error reading adc channel=%d, rc=%d\n", DIE_TEMP, rc); } else { pc = interpolate_pc(chip->batt_data->pc_temp_ocv_lut, pc = interpolate_pc_bms(chip->batt_data->pc_temp_ocv_lut, batt_temp, chip->last_ocv_uv / 1000); /* * For pc < 2, use the rbatt of pc = 2. This is to avoid Loading
include/linux/batterydata-lib.h +17 −17 Original line number Diff line number Diff line /* Copyright (c) 2012-2015, The Linux Foundation. All rights reserved. /* Copyright (c) 2012-2015, 2018, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and Loading Loading @@ -160,55 +160,55 @@ extern struct bms_battery_data oem_batt_data; extern struct bms_battery_data QRD_4v35_2000mAh_data; extern struct bms_battery_data qrd_4v2_1300mah_data; int interpolate_fcc(struct single_row_lut *fcc_temp_lut, int batt_temp); int interpolate_scalingfactor(struct sf_lut *sf_lut, int row_entry, int pc); int interpolate_scalingfactor_fcc(struct single_row_lut *fcc_sf_lut, int interpolate_fcc_bms(struct single_row_lut *fcc_temp_lut, int batt_temp); int interpolate_scalingfactor_bms(struct sf_lut *sf_lut, int row_entry, int pc); int interpolate_scalingfactor_fcc_bms(struct single_row_lut *fcc_sf_lut, int cycles); int interpolate_pc(struct pc_temp_ocv_lut *pc_temp_ocv, int interpolate_pc_bms(struct pc_temp_ocv_lut *pc_temp_ocv, int batt_temp_degc, int ocv); int interpolate_ocv(struct pc_temp_ocv_lut *pc_temp_ocv, int interpolate_ocv_bms(struct pc_temp_ocv_lut *pc_temp_ocv, int batt_temp_degc, int pc); int interpolate_slope(struct pc_temp_ocv_lut *pc_temp_ocv, int interpolate_slope_bms(struct pc_temp_ocv_lut *pc_temp_ocv, int batt_temp, int pc); int interpolate_acc(struct ibat_temp_acc_lut *ibat_acc_lut, int interpolate_acc_bms(struct ibat_temp_acc_lut *ibat_acc_lut, int batt_temp, int ibat); int linear_interpolate(int y0, int x0, int y1, int x1, int x); int linear_interpolate_bms(int y0, int x0, int y1, int x1, int x); #else static inline int interpolate_fcc(struct single_row_lut *fcc_temp_lut, static inline int interpolate_fcc_bms(struct single_row_lut *fcc_temp_lut, int batt_temp) { return -EINVAL; } static inline int interpolate_scalingfactor(struct sf_lut *sf_lut, static inline int interpolate_scalingfactor_bms(struct sf_lut *sf_lut, int row_entry, int pc) { return -EINVAL; } static inline int interpolate_scalingfactor_fcc( static inline int interpolate_scalingfactor_fcc_bms( struct single_row_lut *fcc_sf_lut, int cycles) { return -EINVAL; } static inline int interpolate_pc(struct pc_temp_ocv_lut *pc_temp_ocv, static inline int interpolate_pc_bms(struct pc_temp_ocv_lut *pc_temp_ocv, int batt_temp_degc, int ocv) { return -EINVAL; } static inline int interpolate_ocv(struct pc_temp_ocv_lut *pc_temp_ocv, static inline int interpolate_ocv_bms(struct pc_temp_ocv_lut *pc_temp_ocv, int batt_temp_degc, int pc) { return -EINVAL; } static inline int interpolate_slope(struct pc_temp_ocv_lut *pc_temp_ocv, static inline int interpolate_slope_bms(struct pc_temp_ocv_lut *pc_temp_ocv, int batt_temp, int pc) { return -EINVAL; } static inline int linear_interpolate(int y0, int x0, int y1, int x1, int x) static inline int linear_interpolate_bms(int y0, int x0, int y1, int x1, int x) { return -EINVAL; } static inline int interpolate_acc(struct ibat_temp_acc_lut *ibat_acc_lut, static inline int interpolate_acc_bms(struct ibat_temp_acc_lut *ibat_acc_lut, int batt_temp, int ibat) { return -EINVAL; Loading