static void power_supply_callback(struct power_supply *psy) { static struct power_supply *bms_psy; union power_supply_propval ret = {0,}; int battery_percentage; enum bcl_threshold_state prev_soc_state; if (gbcl->bcl_mode != BCL_DEVICE_ENABLED) { pr_debug("BCL is not enabled\n"); return; } if (!bms_psy) bms_psy = power_supply_get_by_name("bms"); if (bms_psy) { battery_percentage = bms_psy->get_property(bms_psy, POWER_SUPPLY_PROP_CAPACITY, &ret); battery_percentage = ret.intval; battery_soc_val = battery_percentage; pr_debug("Battery SOC reported:%d", battery_soc_val); prev_soc_state = bcl_soc_state; bcl_soc_state = (battery_soc_val <= soc_low_threshold) ? BCL_LOW_THRESHOLD : BCL_HIGH_THRESHOLD; if (bcl_soc_state == prev_soc_state) return; if (bcl_hotplug_enabled) schedule_work(&bcl_hotplug_work); update_cpu_freq(); } }
static void bcl_vph_notify(enum bcl_threshold_state thresh_type) { if (bcl_hotplug_enabled) schedule_work(&bcl_hotplug_work); bcl_vph_state = thresh_type; update_cpu_freq(); }
static void battery_monitor_work(struct work_struct *work) { int vbatt; struct bcl_context *bcl = container_of(work, struct bcl_context, battery_monitor_work); if (gbcl->bcl_mode == BCL_DEVICE_ENABLED) { bcl->btm_mode = BCL_VPH_MONITOR_MODE; update_cpu_freq(); bcl_handle_hotplug(); bcl_get_battery_voltage(&vbatt); pr_debug("vbat is %d\n", vbatt); if (bcl_vph_state == BCL_LOW_THRESHOLD) { if (vbatt <= gbcl->btm_vph_low_thresh) { /*relay the notification to charger ic driver*/ if (bcl->btm_charger_ic_low_thresh == gbcl->btm_vph_adc_param.low_thr) { bcl_hit_shutdown_voltage = true; } else bcl_config_vph_adc(gbcl, BCL_LOW_THRESHOLD_TYPE_MIN); } else bcl_config_vph_adc(gbcl, BCL_HIGH_THRESHOLD_TYPE); } else { bcl_config_vph_adc(gbcl, BCL_LOW_THRESHOLD_TYPE); } } }