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);
		}
	}
}
static void power_supply_callback(struct power_supply *psy)
{
	int vbatt = 0;
	if (bcl_hit_shutdown_voltage)
		return;
	if (0 != bcl_get_battery_voltage(&vbatt))
		return;
	if (vbatt <= gbcl->btm_vph_low_thresh) {
		/*relay the notification to charger ic driver*/
		bcl_config_vph_adc(gbcl, BCL_LOW_THRESHOLD_TYPE_MIN);
	} else if ((vbatt  > gbcl->btm_vph_low_thresh) &&
		(vbatt <= gbcl->btm_vph_high_thresh))
		bcl_config_vph_adc(gbcl, BCL_LOW_THRESHOLD_TYPE);
	else
		bcl_config_vph_adc(gbcl, BCL_HIGH_THRESHOLD_TYPE);
}
static int bcl_resume(struct device *dev)
{
	struct bcl_context *bcl = dev_get_drvdata(dev);
	int vbatt = 0;
	if (bcl->bcl_monitor_type == BCL_IBAT_MONITOR_TYPE &&
		bcl->bcl_mode == BCL_DEVICE_ENABLED) {
		bcl->btm_mode = BCL_VPH_MONITOR_MODE;
		bcl_get_battery_voltage(&vbatt);
		if (vbatt <= gbcl->btm_vph_low_thresh) {
			/*relay the notification to charger ic driver*/
			bcl_config_vph_adc(gbcl, BCL_LOW_THRESHOLD_TYPE_MIN);
		} else if ((vbatt  > gbcl->btm_vph_low_thresh) &&
			(vbatt <= gbcl->btm_vph_high_thresh))
			bcl_config_vph_adc(gbcl, BCL_LOW_THRESHOLD_TYPE);
		else
			bcl_config_vph_adc(gbcl, BCL_HIGH_THRESHOLD_TYPE);
	}
	return 0;
}
/*
 * BCL iavail calculation and trigger notification to user space
 * if iavail cross threshold
 */
static void bcl_calculate_iavail_trigger(void)
{
	int iavail_ma = 0;
	int vbatt_mv;
	int rbatt_mohm;
	bool threshold_cross = false;

	if (!gbcl) {
		pr_err("called before initialization\n");
		return;
	}

	if (bcl_get_battery_voltage(&vbatt_mv))
		return;

	if (bcl_get_resistance(&rbatt_mohm))
		return;

	iavail_ma = (vbatt_mv - gbcl->bcl_vbat_min) * 1000 / rbatt_mohm;

	gbcl->bcl_rbat_mohm = rbatt_mohm;
	gbcl->bcl_vbat_mv = vbatt_mv;
	gbcl->bcl_iavail = iavail_ma;

	pr_debug("iavail %d, vbatt %d rbatt %d\n", iavail_ma, vbatt_mv,
			rbatt_mohm);

	if ((gbcl->bcl_threshold_mode[BCL_HIGH_THRESHOLD_TYPE] ==
				BCL_IAVAIL_THRESHOLD_ENABLED)
		&& (iavail_ma >=
		gbcl->bcl_threshold_value_ma[BCL_HIGH_THRESHOLD_TYPE]))
		threshold_cross = true;
	else if ((gbcl->bcl_threshold_mode[BCL_LOW_THRESHOLD_TYPE]
				== BCL_IAVAIL_THRESHOLD_ENABLED)
		&& (iavail_ma <=
		gbcl->bcl_threshold_value_ma[BCL_LOW_THRESHOLD_TYPE]))
		threshold_cross = true;

	if (threshold_cross)
		sysfs_notify(&gbcl->dev->kobj, NULL, "type");
}