Beispiel #1
0
static int bq27410_battery_temperature(struct bq27410_device_info *di)
{
	int ret;
	int temp = 0;
	u8 buf[2] ={0};

	if(virtual_battery_enable == 1)
		return 125/*258*/;

	ret = bq27410_read(di->client,BQ27410_REG_TEMP,buf,2);
	if (ret<0) {
		dev_err(di->dev, "error reading temperature\n");
		return ret;
	}

	temp = get_unaligned_le16(buf);
	//temp = 5 * temp / 2;
	temp = temp - 2731;  //K

	DBG("Enter:%s %d--temp = %d\n",__FUNCTION__,__LINE__,temp);

#if defined(CONFIG_CHARGER_LIMITED_BY_TEMP)
		if((temp >= 450) && (0 == charge_en_flags)){
			bq24196_charge_disable();
			charge_en_flags = 1;
		}else if((temp <= 400) && (1 == charge_en_flags)){
			bq24196_charge_en();
			charge_en_flags = 0;
		}
#endif
	return temp;
}
Beispiel #2
0
static int bq27541_battery_temperature(struct bq27541_device_info *di)
{
	int ret;
	int temp = 0;
	u8 buf[2] ={0};

#if defined (CONFIG_NO_BATTERY_IC)
	return 258;
#endif
	if(virtual_battery_enable == 1)
		return 125/*258*/;

	ret = bq27541_read(di->client,BQ27x00_REG_TEMP,buf,2);
	if (ret<0) {
		dev_err(di->dev, "error reading temperature\n");
		return ret;
	}
	temp = get_unaligned_le16(buf);
	temp = temp - 2731;  //K
	DBG("Enter:%s %d--temp = %d\n",__FUNCTION__,__LINE__,temp);
#if defined(CONFIG_CHARGER_LIMITED_BY_TEMP)
	if((temp >= DIS_CHARGING_TEMP) && (0 == charge_en_flags)){
		bq24196_charge_disable();
		charge_en_flags = 1;
	}else if((temp <= EN_CHARGING_TEMP) && (1 == charge_en_flags)){
		bq24196_charge_en();
		charge_en_flags = 0;
	}
#endif
//	rk29_pm_power_off();
	return temp;
}
static int bq24196_chg_charge_en(int enable)
{	
	return bq24196_charge_en(bq24196_di,enable);
}