コード例 #1
0
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);
		}
	}
}
コード例 #2
0
static void bcl_periph_mode_set(enum bcl_device_mode mode)
{
	int ret = 0;

	if (mode == BCL_DEVICE_ENABLED) {
		power_supply_callback(&bcl_psy);
		ret = power_supply_register(gbcl->dev, &bcl_psy);
		if (ret < 0) {
			pr_err("Unable to register bcl_psy rc = %d\n", ret);
			return;
		}
		ret = msm_bcl_set_threshold(BCL_PARAM_CURRENT, BCL_HIGH_TRIP,
			&gbcl->ibat_high_thresh);
		if (ret) {
			pr_err("Error setting Ibat high threshold. err:%d\n",
				ret);
			return;
		}
		ret = msm_bcl_set_threshold(BCL_PARAM_CURRENT, BCL_LOW_TRIP,
			&gbcl->ibat_low_thresh);
		if (ret) {
			pr_err("Error setting Ibat low threshold. err:%d\n",
				ret);
			return;
		}
		ret = msm_bcl_set_threshold(BCL_PARAM_VOLTAGE, BCL_LOW_TRIP,
			 &gbcl->vbat_low_thresh);
		if (ret) {
			pr_err("Error setting Vbat low threshold. err:%d\n",
				ret);
			return;
		}
		ret = msm_bcl_set_threshold(BCL_PARAM_VOLTAGE, BCL_HIGH_TRIP,
			 &gbcl->vbat_high_thresh);
		if (ret) {
			pr_err("Error setting Vbat high threshold. err:%d\n",
				ret);
			return;
		}
		ret = msm_bcl_enable();
		if (ret) {
			pr_err("Error enabling BCL\n");
			return;
		}
		gbcl->btm_mode = BCL_VPH_MONITOR_MODE;
	} else {
		power_supply_unregister(&bcl_psy);
		ret = msm_bcl_disable();
		if (ret) {
			pr_err("Error disabling BCL\n");
			return;
		}
		gbcl->btm_mode = BCL_MONITOR_DISABLED;
		bcl_soc_state = BCL_THRESHOLD_DISABLED;
		bcl_vph_notify(BCL_HIGH_THRESHOLD);
		bcl_ibat_notify(BCL_LOW_THRESHOLD);
		bcl_handle_hotplug(NULL);
	}
}