Loading drivers/power/supply/power_supply_sysfs.c +2 −0 Original line number Diff line number Diff line Loading @@ -311,6 +311,8 @@ static struct device_attribute power_supply_attrs[] = { POWER_SUPPLY_ATTR(hw_current_max), POWER_SUPPLY_ATTR(real_type), POWER_SUPPLY_ATTR(pr_swap), POWER_SUPPLY_ATTR(cc_step), POWER_SUPPLY_ATTR(cc_step_sel), /* Local extensions of type int64_t */ POWER_SUPPLY_ATTR(charge_counter_ext), /* Properties of type `const char *' */ Loading drivers/power/supply/qcom/fg-core.h +29 −5 Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ #define SRAM_WRITE "fg_sram_write" #define PROFILE_LOAD "fg_profile_load" #define DELTA_SOC "fg_delta_soc" #define TTF_PRIMING "fg_ttf_priming" /* Delta BSOC irq votable reasons */ #define DELTA_BSOC_IRQ_VOTER "fg_delta_bsoc_irq" Loading Loading @@ -82,6 +83,8 @@ #define BATT_THERM_NUM_COEFFS 3 #define MAX_CC_STEPS 20 /* Debug flag definitions */ enum fg_debug_flag { FG_IRQ = BIT(0), /* Show interrupts */ Loading Loading @@ -241,6 +244,11 @@ enum esr_timer_config { NUM_ESR_TIMERS, }; enum ttf_mode { TTF_MODE_NORMAL = 0, TTF_MODE_QNOVO, }; /* DT parameters for FG device */ struct fg_dt_props { bool force_load_profile; Loading Loading @@ -323,16 +331,31 @@ struct fg_irq_info { }; struct fg_circ_buf { int arr[20]; int arr[10]; int size; int head; }; struct fg_cc_step_data { int arr[MAX_CC_STEPS]; int sel; }; struct fg_pt { s32 x; s32 y; }; struct ttf { struct fg_circ_buf ibatt; struct fg_circ_buf vbatt; struct fg_cc_step_data cc_step; struct mutex lock; int mode; int last_ttf; s64 last_ms; }; static const struct fg_pt fg_ln_table[] = { { 1000, 0 }, { 2000, 693 }, Loading Loading @@ -372,6 +395,7 @@ struct fg_chip { struct power_supply *usb_psy; struct power_supply *dc_psy; struct power_supply *parallel_psy; struct power_supply *pc_port_psy; struct iio_channel *batt_id_chan; struct iio_channel *die_temp_chan; struct fg_irq_info *irqs; Loading @@ -388,9 +412,9 @@ struct fg_chip { struct fg_cyc_ctr_data cyc_ctr; struct notifier_block nb; struct fg_cap_learning cl; struct ttf ttf; struct mutex bus_lock; struct mutex sram_rw_lock; struct mutex batt_avg_lock; struct mutex charge_full_lock; u32 batt_soc_base; u32 batt_info_base; Loading @@ -403,6 +427,7 @@ struct fg_chip { int prev_charge_status; int charge_done; int charge_type; int online_status; int last_soc; int last_batt_temp; int health; Loading Loading @@ -430,10 +455,8 @@ struct fg_chip { struct delayed_work profile_load_work; struct work_struct status_change_work; struct work_struct cycle_count_work; struct delayed_work batt_avg_work; struct delayed_work ttf_work; struct delayed_work sram_dump_work; struct fg_circ_buf ibatt_circ_buf; struct fg_circ_buf vbatt_circ_buf; }; /* Debugfs data structures are below */ Loading Loading @@ -496,6 +519,7 @@ extern bool is_qnovo_en(struct fg_chip *chip); extern void fg_circ_buf_add(struct fg_circ_buf *buf, int val); extern void fg_circ_buf_clr(struct fg_circ_buf *buf); extern int fg_circ_buf_avg(struct fg_circ_buf *buf, int *avg); extern int fg_circ_buf_median(struct fg_circ_buf *buf, int *median); extern int fg_lerp(const struct fg_pt *pts, size_t tablesize, s32 input, s32 *output); #endif drivers/power/supply/qcom/fg-util.c +37 −1 Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ * GNU General Public License for more details. */ #include <linux/sort.h> #include "fg-core.h" void fg_circ_buf_add(struct fg_circ_buf *buf, int val) Loading @@ -21,7 +22,9 @@ void fg_circ_buf_add(struct fg_circ_buf *buf, int val) void fg_circ_buf_clr(struct fg_circ_buf *buf) { memset(buf, 0, sizeof(*buf)); buf->size = 0; buf->head = 0; memset(buf->arr, 0, sizeof(buf->arr)); } int fg_circ_buf_avg(struct fg_circ_buf *buf, int *avg) Loading @@ -39,6 +42,39 @@ int fg_circ_buf_avg(struct fg_circ_buf *buf, int *avg) return 0; } static int cmp_int(const void *a, const void *b) { return *(int *)a - *(int *)b; } int fg_circ_buf_median(struct fg_circ_buf *buf, int *median) { int *temp; if (buf->size == 0) return -ENODATA; if (buf->size == 1) { *median = buf->arr[0]; return 0; } temp = kmalloc_array(buf->size, sizeof(*temp), GFP_KERNEL); if (!temp) return -ENOMEM; memcpy(temp, buf->arr, buf->size * sizeof(*temp)); sort(temp, buf->size, sizeof(*temp), cmp_int, NULL); if (buf->size % 2) *median = temp[buf->size / 2]; else *median = (temp[buf->size / 2 - 1] + temp[buf->size / 2]) / 2; kfree(temp); return 0; } int fg_lerp(const struct fg_pt *pts, size_t tablesize, s32 input, s32 *output) { int i; Loading drivers/power/supply/qcom/qpnp-fg-gen3.c +383 −143 File changed.Preview size limit exceeded, changes collapsed. Show changes include/linux/power_supply.h +2 −0 Original line number Diff line number Diff line Loading @@ -249,6 +249,8 @@ enum power_supply_property { POWER_SUPPLY_PROP_HW_CURRENT_MAX, POWER_SUPPLY_PROP_REAL_TYPE, POWER_SUPPLY_PROP_PR_SWAP, POWER_SUPPLY_PROP_CC_STEP, POWER_SUPPLY_PROP_CC_STEP_SEL, /* Local extensions of type int64_t */ POWER_SUPPLY_PROP_CHARGE_COUNTER_EXT, /* Properties of type `const char *' */ Loading Loading
drivers/power/supply/power_supply_sysfs.c +2 −0 Original line number Diff line number Diff line Loading @@ -311,6 +311,8 @@ static struct device_attribute power_supply_attrs[] = { POWER_SUPPLY_ATTR(hw_current_max), POWER_SUPPLY_ATTR(real_type), POWER_SUPPLY_ATTR(pr_swap), POWER_SUPPLY_ATTR(cc_step), POWER_SUPPLY_ATTR(cc_step_sel), /* Local extensions of type int64_t */ POWER_SUPPLY_ATTR(charge_counter_ext), /* Properties of type `const char *' */ Loading
drivers/power/supply/qcom/fg-core.h +29 −5 Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ #define SRAM_WRITE "fg_sram_write" #define PROFILE_LOAD "fg_profile_load" #define DELTA_SOC "fg_delta_soc" #define TTF_PRIMING "fg_ttf_priming" /* Delta BSOC irq votable reasons */ #define DELTA_BSOC_IRQ_VOTER "fg_delta_bsoc_irq" Loading Loading @@ -82,6 +83,8 @@ #define BATT_THERM_NUM_COEFFS 3 #define MAX_CC_STEPS 20 /* Debug flag definitions */ enum fg_debug_flag { FG_IRQ = BIT(0), /* Show interrupts */ Loading Loading @@ -241,6 +244,11 @@ enum esr_timer_config { NUM_ESR_TIMERS, }; enum ttf_mode { TTF_MODE_NORMAL = 0, TTF_MODE_QNOVO, }; /* DT parameters for FG device */ struct fg_dt_props { bool force_load_profile; Loading Loading @@ -323,16 +331,31 @@ struct fg_irq_info { }; struct fg_circ_buf { int arr[20]; int arr[10]; int size; int head; }; struct fg_cc_step_data { int arr[MAX_CC_STEPS]; int sel; }; struct fg_pt { s32 x; s32 y; }; struct ttf { struct fg_circ_buf ibatt; struct fg_circ_buf vbatt; struct fg_cc_step_data cc_step; struct mutex lock; int mode; int last_ttf; s64 last_ms; }; static const struct fg_pt fg_ln_table[] = { { 1000, 0 }, { 2000, 693 }, Loading Loading @@ -372,6 +395,7 @@ struct fg_chip { struct power_supply *usb_psy; struct power_supply *dc_psy; struct power_supply *parallel_psy; struct power_supply *pc_port_psy; struct iio_channel *batt_id_chan; struct iio_channel *die_temp_chan; struct fg_irq_info *irqs; Loading @@ -388,9 +412,9 @@ struct fg_chip { struct fg_cyc_ctr_data cyc_ctr; struct notifier_block nb; struct fg_cap_learning cl; struct ttf ttf; struct mutex bus_lock; struct mutex sram_rw_lock; struct mutex batt_avg_lock; struct mutex charge_full_lock; u32 batt_soc_base; u32 batt_info_base; Loading @@ -403,6 +427,7 @@ struct fg_chip { int prev_charge_status; int charge_done; int charge_type; int online_status; int last_soc; int last_batt_temp; int health; Loading Loading @@ -430,10 +455,8 @@ struct fg_chip { struct delayed_work profile_load_work; struct work_struct status_change_work; struct work_struct cycle_count_work; struct delayed_work batt_avg_work; struct delayed_work ttf_work; struct delayed_work sram_dump_work; struct fg_circ_buf ibatt_circ_buf; struct fg_circ_buf vbatt_circ_buf; }; /* Debugfs data structures are below */ Loading Loading @@ -496,6 +519,7 @@ extern bool is_qnovo_en(struct fg_chip *chip); extern void fg_circ_buf_add(struct fg_circ_buf *buf, int val); extern void fg_circ_buf_clr(struct fg_circ_buf *buf); extern int fg_circ_buf_avg(struct fg_circ_buf *buf, int *avg); extern int fg_circ_buf_median(struct fg_circ_buf *buf, int *median); extern int fg_lerp(const struct fg_pt *pts, size_t tablesize, s32 input, s32 *output); #endif
drivers/power/supply/qcom/fg-util.c +37 −1 Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ * GNU General Public License for more details. */ #include <linux/sort.h> #include "fg-core.h" void fg_circ_buf_add(struct fg_circ_buf *buf, int val) Loading @@ -21,7 +22,9 @@ void fg_circ_buf_add(struct fg_circ_buf *buf, int val) void fg_circ_buf_clr(struct fg_circ_buf *buf) { memset(buf, 0, sizeof(*buf)); buf->size = 0; buf->head = 0; memset(buf->arr, 0, sizeof(buf->arr)); } int fg_circ_buf_avg(struct fg_circ_buf *buf, int *avg) Loading @@ -39,6 +42,39 @@ int fg_circ_buf_avg(struct fg_circ_buf *buf, int *avg) return 0; } static int cmp_int(const void *a, const void *b) { return *(int *)a - *(int *)b; } int fg_circ_buf_median(struct fg_circ_buf *buf, int *median) { int *temp; if (buf->size == 0) return -ENODATA; if (buf->size == 1) { *median = buf->arr[0]; return 0; } temp = kmalloc_array(buf->size, sizeof(*temp), GFP_KERNEL); if (!temp) return -ENOMEM; memcpy(temp, buf->arr, buf->size * sizeof(*temp)); sort(temp, buf->size, sizeof(*temp), cmp_int, NULL); if (buf->size % 2) *median = temp[buf->size / 2]; else *median = (temp[buf->size / 2 - 1] + temp[buf->size / 2]) / 2; kfree(temp); return 0; } int fg_lerp(const struct fg_pt *pts, size_t tablesize, s32 input, s32 *output) { int i; Loading
drivers/power/supply/qcom/qpnp-fg-gen3.c +383 −143 File changed.Preview size limit exceeded, changes collapsed. Show changes
include/linux/power_supply.h +2 −0 Original line number Diff line number Diff line Loading @@ -249,6 +249,8 @@ enum power_supply_property { POWER_SUPPLY_PROP_HW_CURRENT_MAX, POWER_SUPPLY_PROP_REAL_TYPE, POWER_SUPPLY_PROP_PR_SWAP, POWER_SUPPLY_PROP_CC_STEP, POWER_SUPPLY_PROP_CC_STEP_SEL, /* Local extensions of type int64_t */ POWER_SUPPLY_PROP_CHARGE_COUNTER_EXT, /* Properties of type `const char *' */ Loading