Exemplo n.º 1
0
static int bq27541_battery_get_property(struct power_supply *psy,
					enum power_supply_property psp,
					union power_supply_propval *val)
{
	int ret = 0;
	
	struct bq27541_device_info *di = to_bq27541_device_info(psy);
	DBG("Enter:%s %d psp= %d\n",__FUNCTION__,__LINE__,psp);
	
	switch (psp) {

	case POWER_SUPPLY_PROP_STATUS:
		ret = bq27541_battery_status(di, val);
		break;
	case POWER_SUPPLY_PROP_VOLTAGE_NOW:
	case POWER_SUPPLY_PROP_PRESENT:
		val->intval = bq27541_battery_voltage(di);
		if (psp == POWER_SUPPLY_PROP_PRESENT){
			val->intval = val->intval <= 0 ? 0 : 1;
		}
		break;
	case POWER_SUPPLY_PROP_CURRENT_NOW:
		val->intval = bq27541_battery_current(di);
		break;
	case POWER_SUPPLY_PROP_CAPACITY:
		if (di->power_down == 1){      // < 3.4V    power down ,capacity = 0;
			val->intval = 0;
		}else {
			val->intval = bq27541_battery_rsoc(di);
		}
		break;

	case POWER_SUPPLY_PROP_TEMP:
		val->intval = bq27541_battery_temperature(di);
		break;

	case POWER_SUPPLY_PROP_TECHNOLOGY:
		val->intval = POWER_SUPPLY_TECHNOLOGY_LION;	
		break;
	case POWER_SUPPLY_PROP_HEALTH:
		ret = bq27541_health_status(di, val);
		break;
	case POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW:
		ret = bq27541_battery_time(di, BQ27x00_REG_TTE, val);
		break;
	case POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG:
		ret = bq27541_battery_time(di, BQ27x00_REG_TTECP, val);
		break;
	case POWER_SUPPLY_PROP_TIME_TO_FULL_NOW:
		ret = bq27541_battery_time(di, BQ27x00_REG_TTF, val);
		break;
	
	default:
		return -EINVAL;
	}

	return ret;
}
Exemplo n.º 2
0
static int bq27541_get_battery_temperature(void)
{
	return bq27541_battery_temperature(bq27541_di);
}
Exemplo n.º 3
0
static int bq27541_battery_get_property(struct power_supply *psy,
					enum power_supply_property psp,
					union power_supply_propval *val)
{
	int ret = 0;
	
	struct bq27541_device_info *di = to_bq27541_device_info(psy);
	DBG("Enter:%s %d psp= %d\n",__FUNCTION__,__LINE__,psp);

	switch (psp)
	{
	case POWER_SUPPLY_PROP_STATUS:
		ret = bq27541_battery_status(di, val);
		break;
	case POWER_SUPPLY_PROP_VOLTAGE_NOW:
		val->intval = bq27541_battery_voltage(di);
		break;
	case POWER_SUPPLY_PROP_PRESENT:
		#if 0
		val->intval = bq27541_battery_voltage(di);
		if (psp == POWER_SUPPLY_PROP_PRESENT){
			val->intval = val->intval <= 0 ? 0 : 1;
		}
		#else
		val->intval = 1;
		#endif
		break;
	case POWER_SUPPLY_PROP_CURRENT_NOW:
		val->intval = bq27541_battery_current(di);
		break;
	case POWER_SUPPLY_PROP_CAPACITY:
		val->intval = bq27541_battery_rsoc(di);
		break;

	case POWER_SUPPLY_PROP_TEMP:
		val->intval = bq27541_battery_temperature(di);
#if defined(CONFIG_CHARGER_LIMITED_BY_TEMP)
			if(1 == charge_en_flags)
				temp_val = val->intval;
#endif

		break;

	case POWER_SUPPLY_PROP_TECHNOLOGY:
		val->intval = POWER_SUPPLY_TECHNOLOGY_LION;	
		break;
	case POWER_SUPPLY_PROP_HEALTH:
		ret = bq27541_health_status(di, val);
		break;
	case POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW:
		ret = bq27541_battery_time(di, BQ27x00_REG_TTE, val);
		break;
	case POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG:
		ret = bq27541_battery_time(di, BQ27x00_REG_TTECP, val);
		break;
	case POWER_SUPPLY_PROP_TIME_TO_FULL_NOW:
		ret = bq27541_battery_time(di, BQ27x00_REG_TTF, val);
		break;
	
	default:
		return -EINVAL;
	}

	return ret;
}