Exemple #1
0
 static kal_uint32 charging_set_current(void *data)
 {
 	kal_uint32 status = STATUS_OK;
	kal_uint32 set_chr_current;
	kal_uint32 array_size;
	kal_uint32 register_value;
	kal_uint32 current_value = *(kal_uint32 *)data;
	//kal_uint32 current_high_flag = 0;
	
	array_size = GETARRAYNUM(CS_VTH);
	if (current_value <=190000)
	{
	    set_chr_current = bmt_find_closest_level(CS_VTH, array_size, current_value);
	    register_value = charging_parameter_to_value(CS_VTH, array_size ,set_chr_current);
		current_high_flag = 0x0;
	} else {
	    set_chr_current = bmt_find_closest_level(CS_VTH, array_size, current_value - 160000);
	    register_value = charging_parameter_to_value(CS_VTH, array_size ,set_chr_current);
		current_high_flag = 0x1;
	}

	//current set by SW and disable automatic charge current
	//ncp1854_set_aicl_en(0x0); //disable AICL
	//set which register first? mmz
	ncp1854_set_ichg_high(current_high_flag);
	ncp1854_set_ichg(register_value);       	
	
	return status;
 } 	
Exemple #2
0
 static kal_uint32 charging_set_input_current(void *data)
 {
 	kal_uint32 status = STATUS_OK;
	kal_uint32 set_chr_current;
	kal_uint32 array_size;
	kal_uint32 register_value;
	kal_uint32 current_value = *(kal_uint32 *)data;
    
	if (current_value < 60000)
	{
	    array_size = GETARRAYNUM(INPUT_CS_VTH);
	    set_chr_current = bmt_find_closest_level(INPUT_CS_VTH, array_size, current_value);
	    register_value = charging_parameter_to_value(INPUT_CS_VTH, array_size ,set_chr_current);	
	    ncp1854_set_iinlim(register_value);
	    ncp1854_set_iinlim_ta(0x0);
	} else {
	    array_size = GETARRAYNUM(INPUT_CS_VTH_TA);
	    set_chr_current = bmt_find_closest_level(INPUT_CS_VTH_TA, array_size, current_value);
	    register_value = charging_parameter_to_value(INPUT_CS_VTH_TA, array_size ,set_chr_current);	
	    //lenovo-sw mahj2 modify for register begin from 0x0001 at 20150106 Begin
	    register_value += 1;
	    //lenovo-sw mahj2 modify for register begin from 0x0001 at 20150106 End
	    ncp1854_set_iinlim_ta(register_value);
	}
        
	//ncp1854_set_iinset_pin_en(0x0); //Input current limit and AICL control by I2C
	ncp1854_set_iinlim_en(0x1); //enable input current limit
	//ncp1854_set_aicl_en(0x0); //disable AICL

	return status;
 }
 static kal_uint32 charging_set_input_current(void *data)
 {
 	kal_uint32 status = STATUS_OK;
	kal_uint32 set_chr_current;
	kal_uint32 array_size;
	kal_uint32 register_value;

    if(*(kal_uint32 *)data > CHARGE_CURRENT_500_00_MA)
    {
/*lenovo-sw weiweij modified for changing input current to 3A*/    
        register_value = 0x7;
/*lenovo-sw weiweij modified for changing input current to 3A end*/
    }
/*	else if(*data==CHARGE_CURRENT_MAX)
	{
		register_value = 0x6;
	}*/
    else
    {
    	array_size = GETARRAYNUM(INPUT_CS_VTH);
    	set_chr_current = bmt_find_closest_level(INPUT_CS_VTH, array_size, *(kal_uint32 *)data);
    	register_value = charging_parameter_to_value(INPUT_CS_VTH, array_size ,set_chr_current);	
    }
    
    bq24250_set_iinlim(register_value);

	return status;
 } 	
Exemple #4
0
static kal_uint32 charging_set_input_current(void *data)
{
    kal_uint32 status = STATUS_OK;
    kal_uint32 current_value = *(kal_uint32 *)data;
    kal_uint32 set_chr_current;
    kal_uint32 array_size;
    kal_uint32 register_value;

    if(current_value >= CHARGE_CURRENT_2500_00_MA)
    {
        register_value = 0x6;
    }
    else if(current_value == CHARGE_CURRENT_1000_00_MA)
    {
        register_value = 0x4;
    }
    else
    {
        array_size = GETARRAYNUM(INPUT_CS_VTH);
        set_chr_current = bmt_find_closest_level(INPUT_CS_VTH, array_size, current_value);
        register_value = charging_parameter_to_value(INPUT_CS_VTH, array_size ,set_chr_current);
    }

    bq24261_set_in_limit(register_value);

    return status;
}     
 static kal_uint32 charging_set_current(void *data)
 {
 	kal_uint32 status = STATUS_OK;
	kal_uint32 set_chr_current;
	kal_uint32 array_size;
	kal_uint32 register_value;
	kal_uint32 current_value = *(kal_uint32 *)data;

	if(current_value <= CHARGE_CURRENT_350_00_MA)
	{
		fan5405_set_io_level(1);
	}
	else
	{
		fan5405_set_io_level(0);
		array_size = GETARRAYNUM(CS_VTH);
		set_chr_current = bmt_find_closest_level(CS_VTH, array_size, current_value);
		register_value = charging_parameter_to_value(CS_VTH, array_size ,set_chr_current);
		if(register_value > 6)
		{
		    register_value = 6;
		}
		fan5405_set_iocharge(register_value);
	}
	return status;
 } 	
static kal_uint32 charging_get_current(void *data)
{
    kal_uint32 status = STATUS_OK;
    kal_uint32 array_size;
    
    array_size = GETARRAYNUM(CS_VTH);
    *(kal_uint32 *)data = bmt_find_closest_level(CS_VTH, array_size, *(kal_uint32 *)data);
    
    return status;
}  
static DCL_STATUS bmt_get_the_less_nearest_current(void *data)
{
	DCL_STATUS status = STATUS_OK;
	DCL_UINT32 array_size;
	
	array_size = GETARRAYNUM(chr_CS_VTH);
	*(DCL_UINT32 *)data = bmt_find_closest_level(chr_CS_VTH, array_size, *(DCL_UINT32 *)data);
	
	return status;
}
Exemple #8
0
void BL_HV_detection_init(void)
{
#if defined(__BMT_2_0_ARCHITECTURE__)
	DCL_BOOL chr_hv_enable = DCL_TRUE;
	#if defined(DRV_BMT_HIGH_VCHG_ADAPTIVE_CHARGE_CURRENT_SUPPORT)
	kal_uint32 hv_voltage = CHR_VCHARGER_HV_HIGH;
	#else
	kal_uint32 hv_voltage = CHR_VCHARGER_HW_HIGH;
	#endif


	/*trigger HW Charger OVP before backlight on*/
	bl_chr_control_handler(BMT_BL_CHARGING_CMD_SET_HV_VOLTAGE, &hv_voltage);
	bl_chr_control_handler(BMT_BL_CHARGING_CMD_SET_HV_ENABLE, &chr_hv_enable);

	

#else
	DCL_UINT32 voltage;
	DCL_HANDLE pmu_handle;
	PMU_CTRL_CHR_GET_HV_DETECTION_VOLTAGE_LIST hv_voltage_list;
	PMU_CTRL_CHR_SET_HV_DETECTION_VOLTAGE hv_voltage;
	DCL_STATUS  status;

	DclPMU_Initialize();

	pmu_handle = DclPMU_Open(DCL_PMU, FLAGS_NONE);
	status=DclPMU_Control(pmu_handle, CHR_GET_HV_DETECTION_VOLTAGE_LIST, (
DCL_CTRL_DATA_T *)&hv_voltage_list);

	if(status==STATUS_UNSUPPORTED)
	{
		//drv_trace1(TRACE_GROUP_10, BMT_PMU_DO_NOT_SUPPORT_TRC, 0);
		return;
	}

#if defined(DRV_BMT_HIGH_VCHG_ADAPTIVE_CHARGE_CURRENT_SUPPORT)
		voltage=CHR_VCHARGER_HV_HIGH;
#else
#if defined(CHR_HW_VCHARGER_HIGH)
		voltage=CHR_HW_VCHARGER_HIGH;
#else
		voltage=CHR_VCHARGER_HIGH;
#endif //#if defined(CHR_HW_VCHARGER_HIGH)
#endif

	hv_voltage.voltage=(PMU_VOLTAGE_ENUM)bmt_find_closest_level(hv_voltage_list.pVoltageList
		,hv_voltage_list.number,(DCL_UINT32)voltage);
	
	DclPMU_Control(pmu_handle, CHR_SET_HV_DETECTION_VOLTAGE, (DCL_CTRL_DATA_T *)&hv_voltage);
	DclPMU_Close(pmu_handle);   

#endif //#if defined(__BMT_2_0_ARCHITECTURE__)

}
static DCL_STATUS bmt_find_and_set_the_nearest_current(void *data)
{
	DCL_STATUS status = STATUS_OK;
	DCL_UINT32 set_chr_current;
	DCL_UINT32 array_size;
	DCL_UINT16 register_value;
	
	array_size = GETARRAYNUM(chr_CS_VTH);
	set_chr_current = bmt_find_closest_level(chr_CS_VTH, array_size, *(DCL_UINT32 *)data);
	register_value = bmt_parameter_to_value(chr_CS_VTH, array_size ,set_chr_current);
	status = bmt_set_register_value(RG_CS_VTH_OFFSET,RG_CS_VTH_MASK,register_value<<RG_CS_VTH_SHIFT);

	return status;
}
static kal_uint32 charging_set_current(void *data)
{
    kal_uint32 status = STATUS_OK;
    kal_uint32 set_chr_current;
    kal_uint32 array_size;
    kal_uint32 register_value;
    
    array_size = GETARRAYNUM(CS_VTH);
    set_chr_current = bmt_find_closest_level(CS_VTH, array_size, *(kal_uint32 *)data);
    register_value = charging_parameter_to_value(CS_VTH, array_size ,set_chr_current);
    pmic_set_register_value(PMIC_RG_CS_VTH,register_value);	

    return status;
}     
static DCL_STATUS bmt_find_and_set_the_nearest_charger_high_voltage(void *data)
{
	DCL_STATUS status = STATUS_OK;
	DCL_UINT32 set_hv_voltage;
	DCL_UINT32 array_size;
	DCL_UINT16 register_value;
	DCL_UINT32 voltage = *(DCL_UINT32*)(data);
	
	array_size = GETARRAYNUM(chr_VCDT_HV_VTH);
	set_hv_voltage = bmt_find_closest_level(chr_VCDT_HV_VTH, array_size, voltage);
	register_value = bmt_parameter_to_value(chr_VCDT_HV_VTH, array_size ,set_hv_voltage);
	bmt_set_register_value(RG_VCDT_HV_VTH_OFFSET,RG_VCDT_HV_VTH_MASK,register_value<<RG_VCDT_HV_VTH_SHIFT);

	return status;
}
static kal_uint32 charging_set_input_current_bq24196(void *data)
{
	kal_uint32 status = STATUS_OK;
	kal_uint32 set_chr_current;
	kal_uint32 array_size;
	kal_uint32 register_value;

	array_size = GETARRAYNUM(INPUT_CS_VTH_BQ24196);
	set_chr_current = bmt_find_closest_level(INPUT_CS_VTH_BQ24196, array_size, *(kal_uint32 *)data);
	register_value = charging_parameter_to_value(INPUT_CS_VTH_BQ24196, array_size ,set_chr_current);

	bq24196_set_iinlim(register_value);

	return status;
}
static kal_uint32 charging_set_hv_threshold(void *data)
{
	kal_uint32 status = STATUS_OK;
	kal_uint32 set_hv_voltage;
	kal_uint32 array_size;
	kal_uint16 register_value;
	kal_uint32 voltage = *(kal_uint32*)(data);

	array_size = GETARRAYNUM(VCDT_HV_VTH);
	set_hv_voltage = bmt_find_closest_level(VCDT_HV_VTH, array_size, voltage);
	register_value = charging_parameter_to_value(VCDT_HV_VTH, array_size ,set_hv_voltage);
	mt6325_upmu_set_rg_vcdt_hv_vth(register_value);

	return status;
}
static kal_uint32 charging_set_current(void *data)
{
	kal_uint32 status = STATUS_OK;
	kal_uint32 set_chr_current;
	kal_uint32 array_size;
	kal_uint32 register_value;
	kal_uint32 current_value = *(kal_uint32 *)data;

	array_size = GETARRAYNUM(CS_VTH);
	set_chr_current = bmt_find_closest_level(CS_VTH, array_size, current_value);
	register_value = charging_parameter_to_value(CS_VTH, array_size ,set_chr_current);
	bq24196_set_ichg(register_value);		

	return status;
} 	
Exemple #15
0
 static kal_uint32 charging_set_cv_voltage(void *data)
 {
 	kal_uint32 status = STATUS_OK;
	kal_uint16 register_value;
	kal_uint32 cv_value = *(kal_uint32 *)(data);	
	kal_uint32 array_size;
	kal_uint32 set_chr_cv;	
	
	array_size = GETARRAYNUM(VBAT_CV_VTH);
	set_chr_cv = bmt_find_closest_level(VBAT_CV_VTH, array_size, cv_value);
	
	register_value = charging_parameter_to_value(VBAT_CV_VTH, GETARRAYNUM(VBAT_CV_VTH), set_chr_cv);


#if 0
    ncp1854_set_ctrl_vbat(register_value);
#else
    //PCB workaround
    if(mt6325_upmu_get_swcid() == PMIC6325_E1_CID_CODE)
    {
        ncp1854_set_ctrl_vbat(0x14); //3.8v
        battery_xlog_printk(BAT_LOG_CRTI,"[charging_set_cv_voltage] set low CV by 6325 E1\n");
    }
    else
    {
        if(is_mt6311_exist())
        {
            if(mt6311_get_chip_id()==PMIC6311_E1_CID_CODE)
            {
                ncp1854_set_ctrl_vbat(0x14); //3.8v
                battery_xlog_printk(BAT_LOG_CRTI,"[charging_set_cv_voltage] set low CV by 6311 E1\n");
            }
            else
            {
                ncp1854_set_ctrl_vbat(register_value);
            }
        }
        else
        {
            ncp1854_set_ctrl_vbat(register_value);
        } 
    }  

#endif

	return status;
 } 	
static kal_uint32 charging_set_input_current(void *data)
{
    kal_uint32 status = STATUS_OK;
    kal_uint32 set_chr_current;
    kal_uint32 array_size;
    kal_uint32 register_value;
    
    //20130604, Quick charging by Tim
    mt6333_set_rg_input_cc_reg(1);
    
    array_size = GETARRAYNUM(INPUT_CS_VTH);
    set_chr_current = bmt_find_closest_level(INPUT_CS_VTH, array_size, *(kal_uint32 *)data);
    register_value = charging_parameter_to_value(INPUT_CS_VTH, array_size ,set_chr_current);  
    
    mt6333_set_rg_ich_sel(register_value);

    return status;
} 	
static kal_uint32 charging_set_current(void *data)
{
     kal_uint32 status = STATUS_OK;
    kal_uint32 set_chr_current;
    kal_uint32 array_size;
    kal_uint32 register_value;
    kal_uint32 current_value = *(kal_uint32 *)data;

    array_size = GETARRAYNUM(CS_VTH);
    set_chr_current = bmt_find_closest_level(CS_VTH, array_size, current_value);
    register_value = charging_parameter_to_value(CS_VTH, array_size ,set_chr_current);

#if defined(CONFIG_MTK_FPGA)     
#else 
    // HW not support
#endif

    return status;
}     
Exemple #18
0
void bmt_find_and_set_the_nearest_charger_high_voltage(DCL_UINT32 voltage)
{
	PMU_CTRL_CHR_GET_HV_DETECTION_VOLTAGE_LIST hv_voltage_list;
	PMU_CTRL_CHR_SET_HV_DETECTION_VOLTAGE hv_voltage;
	DCL_STATUS  status;
	
	status=DclPMU_Control(bmt_PmuHandler, CHR_GET_HV_DETECTION_VOLTAGE_LIST, (DCL_CTRL_DATA_T *)&hv_voltage_list);

	if(status==STATUS_UNSUPPORTED)
	{
		drv_trace1(TRACE_GROUP_10, BMT_PMU_DO_NOT_SUPPORT_TRC, 0);
		return;
	}

	hv_voltage.voltage=(PMU_VOLTAGE_ENUM)bmt_find_closest_level(hv_voltage_list.pVoltageList
		,hv_voltage_list.number,(DCL_UINT32)voltage);
	
	DclPMU_Control(bmt_PmuHandler, CHR_SET_HV_DETECTION_VOLTAGE, (DCL_CTRL_DATA_T *)&hv_voltage);

}
Exemple #19
0
void bmt_find_and_set_the_nearest_current(PMU_CHR_CURRENT_ENUM SetCurrent)
{
	
	PMU_CTRL_CHR_GET_CHR_CURRENT_LIST get_chr_current_list;
	PMU_CTRL_CHR_SET_CHR_CURRENT set_chr_current;
	DCL_STATUS  status;
	
	status=DclPMU_Control(bmt_PmuHandler, CHR_GET_CHR_CURRENT_LIST, (DCL_CTRL_DATA_T *)&get_chr_current_list);

	if(status==STATUS_UNSUPPORTED)
	{
		drv_trace1(TRACE_GROUP_10, BMT_PMU_DO_NOT_SUPPORT_TRC, 1);
		return;
	}

	set_chr_current.current=(PMU_CHR_CURRENT_ENUM)bmt_find_closest_level(get_chr_current_list.pCurrentList
		,get_chr_current_list.number,(DCL_UINT32)SetCurrent);

	drv_trace1(TRACE_GROUP_10, BMT_FIND_AND_SET_THE_NEAREST_CURRENT_TRC, set_chr_current.current);
	DclPMU_Control(bmt_PmuHandler, CHR_SET_CHR_CURRENT, (DCL_CTRL_DATA_T *)&set_chr_current);
}
 static kal_uint32 charging_set_input_current(void *data)
 {
 	kal_uint32 status = STATUS_OK;
	kal_uint32 set_chr_current;
	kal_uint32 array_size;
	kal_uint32 register_value;

    if(*(kal_uint32 *)data > CHARGE_CURRENT_500_00_MA)
    {
        register_value = 0x3;
    }
    else
    {
    	array_size = GETARRAYNUM(INPUT_CS_VTH);
    	set_chr_current = bmt_find_closest_level(INPUT_CS_VTH, array_size, *(kal_uint32 *)data);
    	register_value = charging_parameter_to_value(INPUT_CS_VTH, array_size ,set_chr_current);	
    }
    
    fan5405_set_input_charging_current(register_value);

	return status;
 } 	
Exemple #21
0
static kal_uint32 charging_set_current(void *data)
{
    kal_uint32 status = STATUS_OK;
    kal_uint32 set_chr_current;
    kal_uint32 array_size;
    kal_uint32 register_value;
    kal_uint32 current_value = *(kal_uint32 *)data;
    printk(KERN_EMERG "%s:**********current_value %d***************\n", __func__, current_value);
    if(current_value <= CHARGE_CURRENT_350_00_MA)
    {
        bq24158_set_io_level(1);
    }
    else
    {
        bq24158_set_io_level(0);
        array_size = GETARRAYNUM(CS_VTH);
        set_chr_current = bmt_find_closest_level(CS_VTH, array_size, current_value);
        printk(KERN_EMERG "%s:**********set_chr_current %d***************\n", __func__, set_chr_current);

        register_value = charging_parameter_to_value(CS_VTH, array_size ,set_chr_current);
        bq24158_set_iocharge(register_value);
    }
    return status;
}
static kal_uint32 charging_set_cv_voltage(void *data)
{
	kal_uint32 status = STATUS_OK;
	kal_uint32 array_size;
	kal_uint32 set_cv_voltage;
	kal_uint16 register_value;
	kal_uint32 cv_value = *(kal_uint32 *)(data);	
	static kal_int16 pre_register_value = -1;

	#if defined(HIGH_BATTERY_VOLTAGE_SUPPORT)
	//highest of voltage will be 4.3V, because powerpath limitation
	if(cv_value >= BATTERY_VOLT_04_300000_V)
		cv_value = 4304000;
	#endif

	//use nearest value
	if(BATTERY_VOLT_04_200000_V == cv_value)
		cv_value = 4208000;

	array_size = GETARRAYNUM(VBAT_CV_VTH);
	set_cv_voltage = bmt_find_closest_level(VBAT_CV_VTH, array_size, cv_value);
	register_value = charging_parameter_to_value(VBAT_CV_VTH, array_size, set_cv_voltage);

	//PCB workaround
	if(mt6325_upmu_get_swcid() == PMIC6325_E1_CID_CODE)
	{
		#if defined(CV_E1_INTERNAL)
		bq24196_set_vreg(0x1F);//4.0v
		#else
		bq24196_set_vreg(0x14);//3.8v
		#endif
		battery_log(BAT_LOG_CRTI, "[charging_set_cv_voltage] set low CV by 6325 E1\n");
	}
	else
	{
		if(is_mt6311_exist())
		{
			if(mt6311_get_chip_id()==PMIC6311_E1_CID_CODE)
			{
				#if defined(CV_E1_INTERNAL)
				bq24196_set_vreg(0x1F);//4.0v
				#else
				bq24196_set_vreg(0x14);//3.8v
				#endif
				battery_log(BAT_LOG_CRTI, "[charging_set_cv_voltage] set low CV by 6311 E1\n");
			}
			else
			{
				if (pre_register_value != register_value) {
						battery_log(BAT_LOG_CRTI, "[charging_set_cv_voltage] disable charging\n");
						bq24196_set_chg_config(0);
				}

				bq24196_set_vreg(register_value);
				if (pre_register_value != register_value)
					bq24196_set_chg_config(1);

				pre_register_value = register_value;
			}
		}
		else
		{
			bq24196_set_vreg(register_value);
		}
	}

	return status;
}