static int bq2416x_check_battery_temperature_threshold(void)
{
    int battery_temperature = 0;

    battery_temperature = bq27510_battery_temperature(g_battery_measure_by_bq27510_device);
    //battery_temperature = battery_temperature/TEMPERATURE_MULTIPLE;
    if (battery_temperature < BQ2416x_COLD_BATTERY_THRESHOLD) {
        return BATTERY_HEALTH_TEMPERATURE_OVERLOW;

    } else if((battery_temperature >= BQ2416x_COLD_BATTERY_THRESHOLD)
        && (battery_temperature <  BQ2416x_COOL_BATTERY_THRESHOLD)){
        return BATTERY_HEALTH_TEMPERATURE_LOW;

    } else if ((battery_temperature >= BQ2416x_COOL_BATTERY_THRESHOLD)
        && (battery_temperature < (BQ2416x_WARM_BATTERY_THRESHOLD - BQ2416x_TEMPERATURE_OFFSET))){
       return BATTERY_HEALTH_TEMPERATURE_NORMAL;

    } else if ((battery_temperature >= (BQ2416x_WARM_BATTERY_THRESHOLD - BQ2416x_TEMPERATURE_OFFSET))
        && (battery_temperature < BQ2416x_WARM_BATTERY_THRESHOLD)){
        return BATTERY_HEALTH_TEMPERATURE_NORMAL_HIGH;

    } else if ((battery_temperature >= BQ2416x_WARM_BATTERY_THRESHOLD)
        && (battery_temperature < BQ2416x_HOT_BATTERY_THRESHOLD)){
        return BATTERY_HEALTH_TEMPERATURE_HIGH;

    } else if (battery_temperature >= BQ2416x_HOT_BATTERY_THRESHOLD){
       return BATTERY_HEALTH_TEMPERATURE_OVERHIGH;

    } else {
       return BATTERY_HEALTH_TEMPERATURE_NORMAL;
    }
}
static int bq27510_battery_get_property(struct power_supply *psy,
					enum power_supply_property psp,
					union power_supply_propval *val)
{
	int ret = 0;
	struct bq27510_device_info *di = to_bq27510_device_info(psy);
	DBG("Enter:%s %d psp= %d\n",__FUNCTION__,__LINE__,psp);
	
	switch (psp) {
	
	case POWER_SUPPLY_PROP_STATUS:
		ret = bq27510_battery_status(di, val);
		break;
	case POWER_SUPPLY_PROP_VOLTAGE_NOW:
	case POWER_SUPPLY_PROP_PRESENT:
		val->intval = bq27510_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 = bq27510_battery_current(di);
		break;
	case POWER_SUPPLY_PROP_CAPACITY:
		val->intval = bq27510_battery_rsoc(di);
		break;
	case POWER_SUPPLY_PROP_TEMP:
		val->intval = bq27510_battery_temperature(di);
		break;
	case POWER_SUPPLY_PROP_TECHNOLOGY:
		val->intval = POWER_SUPPLY_TECHNOLOGY_LION;	
		break;
	case POWER_SUPPLY_PROP_HEALTH:
		ret = bq27510_health_status(di, val);
		break;
	case POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW:
		ret = bq27510_battery_time(di, BQ27x00_REG_TTE, val);
		break;
	case POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG:
		ret = bq27510_battery_time(di, BQ27x00_REG_TTECP, val);
		break;
	case POWER_SUPPLY_PROP_TIME_TO_FULL_NOW:
		ret = bq27510_battery_time(di, BQ27x00_REG_TTF, val);
		break;
	default:
		return -EINVAL;
	}

	return ret;
}
static void qt1060_timer_work_func(struct work_struct *work)
{
    int cal = 0, new_tmp = 0, delta = 0;
    long sesc, nsesc;
    struct qt1060_data *qt1060 =
        container_of(work, struct qt1060_data, timer_work);
    sesc = 60;
    nsesc = 0;
    new_tmp = bq27510_battery_temperature(g_battery_measure_by_bq27510_device);
    delta = new_tmp >= old_tmp? (new_tmp - old_tmp):( old_tmp - new_tmp);
    if( delta >= 50)
    {
        cal = qt1060_write(qt1060->client, QT1060_CMD_CALIBRATE, 1);
        if (cal)
        {
            dev_err(&qt1060->client->dev, "failed to calibrate device\n");
        }
        dev_info(&qt1060->client->dev,"QT1060 calibrate the chip for tempreture changeed!\n");
    }
    old_tmp = new_tmp;
    hrtimer_start(&qt1060->timer, ktime_set(sesc, nsesc), HRTIMER_MODE_REL);
}
/*small current charging(100mA) when low battery voltage or low battery temprature*/
static void
bq2416x_low_current_charge(struct bq2416x_device_info *di)
{
	int battery_voltage = 0;
	int battery_temperature = 0;
	if (!is_bq27510_battery_exist(g_battery_measure_by_bq27510_device))
		return;

		battery_voltage = bq27510_battery_voltage(g_battery_measure_by_bq27510_device);
		battery_temperature = bq27510_battery_temperature(g_battery_measure_by_bq27510_device);

		if (battery_temperature < BQ2416x_COLD_BATTERY_THRESHOLD){
			dev_dbg(di->dev, "battery temp less than -10 degree,disable charging\n");
			di->enable_ce = DISABLE_CE;
			if (di->charger_source == POWER_SUPPLY_TYPE_MAINS){
			   if(di->calling_limit){
					di->cin_limit = CURRENT_AC_LIMIT_IN_800;
			   }
			   else{
					di->cin_limit = CURRENT_AC_LIMIT_IN;
			   }
			}

			else
				di->cin_limit = CURRENT_USB_LIMIT_IN;
		}
		else if ((battery_temperature >= BQ2416x_COLD_BATTERY_THRESHOLD)
			&& (battery_temperature < BQ2416x_COOL_BATTERY_THRESHOLD)){
			/*battery temp is between -10 and 0 degree,or battery voltage is less than 3.0V*/
			di->enable_low_chg = ENABLE_LOW_CHG;/*enable low charge,100mA charging*/
			bq2416x_config_safety_reg(di);
			if (di->charger_source == POWER_SUPPLY_TYPE_MAINS){
			   if(di->calling_limit){
					di->cin_limit = CURRENT_AC_LIMIT_IN_800;
			   }
			   else{
					di->cin_limit = CURRENT_AC_LIMIT_IN;
			   }
			}
			else
				di->cin_limit = CURRENT_USB_LIMIT_IN;
			if(battery_voltage < BQ2416x_LOW_TEMP_TERM_VOLTAGE){
				di->enable_ce = ENABLE_CE;
			}
			else{
				di->enable_ce = DISABLE_CE;
			}
		}
		else if ((battery_temperature >= BQ2416x_COOL_BATTERY_THRESHOLD)
		    && (battery_temperature < (BQ2416x_WARM_BATTERY_THRESHOLD - TEMPERATURE_OFFSET))){
			/*battery temp is between 00 and 50 degree,normal charge*/
			di->enable_low_chg = DISABLE_LOW_CHG;/*normal charge*/
			bq2416x_config_safety_reg(di);
			di->enable_ce = ENABLE_CE;
			if (di->charger_source == POWER_SUPPLY_TYPE_MAINS){
			   if(di->calling_limit){
					di->cin_limit = CURRENT_AC_LIMIT_IN_800;
			   }
			   else{
					di->cin_limit = CURRENT_AC_LIMIT_IN;
				}
			}
			else
				di->cin_limit = CURRENT_USB_LIMIT_IN;
		}
		else if ((battery_temperature >= BQ2416x_WARM_BATTERY_THRESHOLD)
		    && (battery_temperature < BQ2416x_HOT_BATTERY_THRESHOLD )){
			/*battery temp is between 00 and 50 degree,normal charge*/
			di->enable_low_chg = DISABLE_LOW_CHG;/*normal charge*/
			bq2416x_config_safety_reg(di);
			di->enable_ce = ENABLE_CE;
			if (di->charger_source == POWER_SUPPLY_TYPE_MAINS)
				di->cin_limit = CURRENT_AC_LIMIT_IN_800;
			else
				di->cin_limit = CURRENT_USB_LIMIT_IN;
		}
		else if (battery_temperature >= BQ2416x_HOT_BATTERY_THRESHOLD)
		{
			dev_dbg(di->dev, "battery temp more than 50 degree,disable charging\n");
			di->enable_ce = DISABLE_CE;
			if (di->charger_source == POWER_SUPPLY_TYPE_MAINS)
				di->cin_limit = CURRENT_AC_LIMIT_IN_800;
			else
				di->cin_limit = CURRENT_USB_LIMIT_IN;
		}
		else{
			di->cin_limit = di->cin_limit;

		}
		di->enable_ce = (di->enable_ce | di->factory_flag);
		bq2416x_config_control_reg(di);
	return;
}