コード例 #1
0
/* judge power off or not by current_avg */
static int adc_get_current_average(struct i2c_client *client)
{
	struct sec_fuelgauge_info *fuelgauge =
				i2c_get_clientdata(client);
	union power_supply_propval value_bat;
	union power_supply_propval value_chg;
	int vcell, soc, curr_avg;

	psy_do_property("sec-charger", get,
		POWER_SUPPLY_PROP_CURRENT_NOW, value_chg);
	psy_do_property("battery", get,
		POWER_SUPPLY_PROP_HEALTH, value_bat);
	vcell = adc_get_vcell(client);
	soc = adc_get_soc(client) / 100;

	/* if 0% && under 3.4v && low power charging(1000mA), power off */
	if (!fuelgauge->pdata->is_lpm() && (soc <= 0) && (vcell < 3400) &&
			((value_chg.intval < 1000) ||
			((value_bat.intval == POWER_SUPPLY_HEALTH_OVERHEAT) ||
			(value_bat.intval == POWER_SUPPLY_HEALTH_COLD)))) {
		dev_info(&client->dev, "%s: SOC(%d), Vnow(%d), Inow(%d)\n",
			__func__, soc, vcell, value_chg.intval);
		curr_avg = -1;
	} else {
		curr_avg = value_chg.intval;
	}

	return curr_avg;
}
コード例 #2
0
static void adc_monitor_work(struct work_struct *work)
{
	struct sec_fuelgauge_info *fuelgauge =
		container_of(work, struct sec_fuelgauge_info,
		info.monitor_work.work);

	fuelgauge->info.current_now = adc_get_current(fuelgauge->client);
	fuelgauge->info.voltage_now = adc_get_vcell(fuelgauge->client);
	if (fuelgauge->info.reset_percentage)
		adc_reset_voltage_avg(fuelgauge->client,
			fuelgauge->info.voltage_now,
			fuelgauge->info.reset_percentage);
	fuelgauge->info.voltage_avg = adc_get_avg_vcell(fuelgauge->client);
	if (fuelgauge->info.reset_percentage) {
		adc_reset_voltage_ocv(fuelgauge->client,
			fuelgauge->info.voltage_avg);
		fuelgauge->info.reset_percentage = 0;
	}
	fuelgauge->info.voltage_ocv = adc_get_ocv(fuelgauge->client);
	fuelgauge->info.current_avg =
		adc_get_current_average(fuelgauge->client);
	fuelgauge->info.capacity = adc_get_soc(fuelgauge->client);

	dev_info(&fuelgauge->client->dev,
		"%s:Vnow(%dmV),Vavg(%dmV),Vocv(%dmV),"
		"Inow(%dmA),Iavg(%dmA),SOC(%d%%)\n", __func__,
		fuelgauge->info.voltage_now, fuelgauge->info.voltage_avg,
		fuelgauge->info.voltage_ocv, fuelgauge->info.current_now,
		fuelgauge->info.current_avg, fuelgauge->info.capacity);

	if (fuelgauge->pdata->monitor_initial_count)
		schedule_delayed_work(&fuelgauge->info.monitor_work, HZ);
	else
		schedule_delayed_work(&fuelgauge->info.monitor_work,
			HZ * get_battery_data(fuelgauge).monitor_polling_time);

	if (fuelgauge->info.is_init) {
		fuelgauge->info.is_init--;
		adc_get_reset_percentage(fuelgauge);
	}

	/* save time of monitor */
	do_gettimeofday(&(fuelgauge->info.last_vcell_check_time));
}
コード例 #3
0
static void adc_monitor_work(struct work_struct *work)
{
	struct sec_fuelgauge_info *fuelgauge =
		container_of(work, struct sec_fuelgauge_info,
		info.monitor_work.work);

	fuelgauge->info.voltage_now = adc_get_vcell(fuelgauge->client);
	fuelgauge->info.voltage_avg = adc_get_avg_vcell(fuelgauge->client);
	fuelgauge->info.voltage_ocv = adc_get_ocv(fuelgauge->client);
	fuelgauge->info.current_now = adc_get_current(fuelgauge->client);
	fuelgauge->info.current_avg =
		adc_get_current_average(fuelgauge->client);
	fuelgauge->info.capacity = adc_get_soc(fuelgauge->client);

	dev_info(&fuelgauge->client->dev,
		"%s:Vnow(%dmV),Vavg(%dmV),Vocv(%dmV),"
		"Inow(%dmA),Iavg(%dmA),SOC(%d%%)\n", __func__,
		fuelgauge->info.voltage_now, fuelgauge->info.voltage_avg,
		fuelgauge->info.voltage_ocv, fuelgauge->info.current_now,
		fuelgauge->info.current_avg, fuelgauge->info.capacity);

	schedule_delayed_work(&fuelgauge->info.monitor_work,
		HZ * get_battery_data(fuelgauge).monitor_polling_time);
}