void select_charging_curret_bcct(void)
{
/*[388754]select charging current min of normal charging current and limit charging current by liming.zhu at 20150625 bigen*/
	select_charging_curret();
       g_temp_CC_value = min(g_temp_CC_value,g_temp_CC_value_limit);

	battery_log(BAT_LOG_CRTI, "[BATTERY]  [select_charging_curret_bcct]  g_temp_CC_value=%d,g_temp_CC_value_limit=%d\r\n",
			    g_temp_CC_value,g_temp_CC_value_limit);
/*[388754]select charging current min of normal charging current and limit charging current by liming.zhu at 20150625 end*/				
	/* done on set_bat_charging_current_limit */
}
PMU_STATUS BAT_PreChargeModeAction(void)
{
	battery_log(BAT_LOG_CRTI, "[BATTERY] Pre-CC mode charge, timer=%d on %d !!\n\r",
			    BMT_status.PRE_charging_time, BMT_status.total_charging_time);

	BMT_status.PRE_charging_time += BAT_TASK_PERIOD;
	BMT_status.CC_charging_time = 0;
	BMT_status.TOPOFF_charging_time = 0;
	BMT_status.total_charging_time += BAT_TASK_PERIOD;

	select_charging_curret();
	ulc_cv_charging_current = g_temp_CC_value;
	ulc_cv_charging_current_flag = KAL_FALSE;

	if (BMT_status.UI_SOC == 100) {
		BMT_status.bat_charging_state = CHR_BATFULL;
		BMT_status.bat_full = KAL_TRUE;
		g_charging_full_reset_bat_meter = KAL_TRUE;
	} else if (BMT_status.bat_vol > batt_cust_data.v_pre2cc_thres) {
		BMT_status.bat_charging_state = CHR_CC;
	}

#if defined(CONFIG_MTK_PUMP_EXPRESS_SUPPORT)//defined(MTK_LINEAR_CHARGER_NO_DISCHARGE)    
	// no disable charging
#else
	{
		kal_bool charging_enable = KAL_FALSE;

		/*Charging 9s and discharging 1s : start */
		battery_charging_control(CHARGING_CMD_ENABLE, &charging_enable);
		msleep(1000);
	}
#endif

	charging_current_calibration();
	pchr_turn_on_charging();

	return PMU_STATUS_OK;
}
Пример #3
0
static void pchr_turn_on_charging (void)
{
#if !defined(MTK_JEITA_STANDARD_SUPPORT) 
	BATTERY_VOLTAGE_ENUM cv_voltage;
#endif	
	kal_uint32 charging_enable = KAL_TRUE;

    if ( BMT_status.bat_charging_state == CHR_ERROR ) 
    {
        battery_xlog_printk(BAT_LOG_CRTI, "[BATTERY] Charger Error, turn OFF charging !\n");

		charging_enable = KAL_FALSE;
        
    }
    else if( (g_platform_boot_mode==META_BOOT) || (g_platform_boot_mode==ADVMETA_BOOT) )
    {   
        battery_xlog_printk(BAT_LOG_CRTI, "[BATTERY] In meta or advanced meta mode, disable charging.\n");    
        charging_enable = KAL_FALSE;
    }
    else
    {
        /*HW initialization*/
        battery_charging_control(CHARGING_CMD_INIT,NULL);
		
	    battery_xlog_printk(BAT_LOG_FULL, "charging_hw_init\n" );

        /* Set Charging Current */			
        if (g_bcct_flag == 1)
        {
            select_charging_curret_bcct();

            battery_xlog_printk(BAT_LOG_FULL, "[BATTERY] select_charging_curret_bcct !\n");
        }
        else
        {
            select_charging_curret();

            battery_xlog_printk(BAT_LOG_FULL, "[BATTERY] select_charging_curret !\n");
        }
        
        if( g_temp_CC_value == CHARGE_CURRENT_0_00_MA || g_temp_input_CC_value == CHARGE_CURRENT_0_00_MA)
        {
        
			charging_enable = KAL_FALSE;
						
            battery_xlog_printk(BAT_LOG_CRTI, "[BATTERY] charging current is set 0mA, turn off charging !\r\n");
        }
        else
        {    
            #ifdef TEMPERATURE_CONTROL_CHARGING 
			battery_xlog_printk(BAT_LOG_CRTI, "[BATTERY]battery temperature = %d, [%d,%d]\r\n", 
			BMT_status.temperature,g_temp_CC_value,g_temp_input_CC_value);
		if (BMT_status.temperature <= CURRENT_LIMIT_BOUNDARY_TEMPERATURE) //ckt guoyi add CKT low temperature(0-10) protect 2014-3-19
		{
                //g_temp_CC_value = g_temp_CC_value>AC_LESS_N_DEGRESS_CHARGER_CURRENT?AC_LESS_N_DEGRESS_CHARGER_CURRENT:g_temp_CC_value;
                //g_temp_input_CC_value = g_temp_input_CC_value>AC_LESS_N_DEGRESS_CHARGER_CURRENT?AC_LESS_N_DEGRESS_CHARGER_CURRENT:g_temp_input_CC_value;
                g_temp_CC_value =AC_LESS_N_DEGRESS_CHARGER_CURRENT;
                g_temp_input_CC_value = AC_LESS_N_DEGRESS_CHARGER_CURRENT;

                battery_charging_control(CHARGING_CMD_SET_INPUT_CURRENT,&g_temp_input_CC_value);
                battery_charging_control(CHARGING_CMD_SET_CURRENT,&g_temp_CC_value);
                
                cv_voltage = MIN_CURRENT_LIMIT_BOUNDARY_BATTERY; 
                battery_charging_control(CHARGING_CMD_SET_CV_VOLTAGE,&cv_voltage);

                battery_xlog_printk(BAT_LOG_CRTI, "[BATTERY] charging  input_current= %d mA,  current is set to %d mA, CKT battery temperature(0-10) protect !\r\n", g_temp_input_CC_value / 100 , g_temp_CC_value / 100);
		}
		else
		{
                     #ifdef HIGH_BATTERY_VOLTAGE_SUPPORT
                     //g_temp_input_CC_value = g_temp_input_CC_value>AC_LESS_N_NORMAL_CHARGER_CURRENT?AC_LESS_N_NORMAL_CHARGER_CURRENT:g_temp_input_CC_value;
                     //g_temp_CC_value = g_temp_CC_value>AC_LESS_N_NORMAL_CHARGER_CURRENT?AC_LESS_N_NORMAL_CHARGER_CURRENT:g_temp_CC_value;
                     g_temp_input_CC_value = AC_LESS_N_NORMAL_CHARGER_CURRENT;
                     g_temp_CC_value = AC_LESS_N_NORMAL_CHARGER_CURRENT;
                     #endif
			
       		battery_charging_control(CHARGING_CMD_SET_INPUT_CURRENT,&g_temp_input_CC_value);
			battery_charging_control(CHARGING_CMD_SET_CURRENT,&g_temp_CC_value);

                   battery_xlog_printk(BAT_LOG_CRTI, "[BATTERY] charging input_current= %d mA, current is set to %d mA, CKT battery temperature(10-45) protect !\r\n", g_temp_input_CC_value / 100 , g_temp_CC_value / 100);
                   
			/*Set CV Voltage*/
			#if !defined(MTK_JEITA_STANDARD_SUPPORT)            
	            cv_voltage = MAX_CURRENT_LIMIT_BOUNDARY_BATTERY;
		    battery_charging_control(CHARGING_CMD_SET_CV_VOLTAGE,&cv_voltage);
			#endif
		}
            #else
			battery_xlog_printk(BAT_LOG_CRTI, "[BATTERY] [>10]temperature = %d, [%d,%d]\r\n", 
				BMT_status.temperature,
				g_temp_CC_value,
				g_temp_input_CC_value);
			
       		battery_charging_control(CHARGING_CMD_SET_INPUT_CURRENT,&g_temp_input_CC_value);
			battery_charging_control(CHARGING_CMD_SET_CURRENT,&g_temp_CC_value);

			/*Set CV Voltage*/
			#if !defined(MTK_JEITA_STANDARD_SUPPORT)            
                #ifdef HIGH_BATTERY_VOLTAGE_SUPPORT
                    cv_voltage = BATTERY_VOLT_04_340000_V;
                #else
	            cv_voltage = BATTERY_VOLT_04_200000_V;
                #endif            
		    battery_charging_control(CHARGING_CMD_SET_CV_VOLTAGE,&cv_voltage);
			#endif
		#endif
        }
    }
	
	/* enable/disable charging */
  	battery_charging_control(CHARGING_CMD_ENABLE,&charging_enable);
	
	battery_xlog_printk(BAT_LOG_CRTI, "[BATTERY] pchr_turn_on_charging(), enable =%d !\r\n", charging_enable);
}
static void pchr_turn_on_charging(void)
{
#if !defined(CONFIG_MTK_JEITA_STANDARD_SUPPORT)
	BATTERY_VOLTAGE_ENUM cv_voltage;
#endif
	kal_uint32 charging_enable = KAL_TRUE;

	battery_log(BAT_LOG_FULL, "[BATTERY] pchr_turn_on_charging()!\r\n");

	if (BMT_status.bat_charging_state == CHR_ERROR) {
		battery_log(BAT_LOG_CRTI, "[BATTERY] Charger Error, turn OFF charging !\n");

		charging_enable = KAL_FALSE;
	} else if ((g_platform_boot_mode == META_BOOT) || (g_platform_boot_mode == ADVMETA_BOOT)) {
		battery_log(BAT_LOG_CRTI,
				    "[BATTERY] In meta or advanced meta mode, disable charging.\n");
		charging_enable = KAL_FALSE;
	} else {
		/*HW initialization */
		battery_log(BAT_LOG_FULL, "charging_hw_init\n");
		battery_charging_control(CHARGING_CMD_INIT, NULL);

#if defined(CONFIG_MTK_PUMP_EXPRESS_SUPPORT)
		battery_pump_express_algorithm_start();
#endif

		/* Set Charging Current */
		if (get_usb_current_unlimited()) {
			g_temp_CC_value = batt_cust_data.ac_charger_current;
			battery_log(BAT_LOG_FULL, "USB_CURRENT_UNLIMITED, use AC_CHARGER_CURRENT\n" );
		} else {
			if (g_bcct_flag == 1) {
				battery_log(BAT_LOG_FULL,
					    "[BATTERY] select_charging_curret_bcct !\n");
				select_charging_curret_bcct();
			} else {
				battery_log(BAT_LOG_FULL, "[BATTERY] select_charging_current !\n");
				select_charging_curret();
			}
		}

		if (g_temp_CC_value == CHARGE_CURRENT_0_00_MA) {
			charging_enable = KAL_FALSE;
			battery_log(BAT_LOG_CRTI,
					"[BATTERY] charging current is set 0mA, turn off charging !\r\n");
		} else {
#if defined(CONFIG_MTK_PUMP_EXPRESS_SUPPORT)
			if(ta_check_ta_control == KAL_FALSE)
#endif	
			{
				if(ulc_cv_charging_current_flag == KAL_TRUE)
					battery_charging_control(CHARGING_CMD_SET_CURRENT,&ulc_cv_charging_current);
				else
					battery_charging_control(CHARGING_CMD_SET_CURRENT,&g_temp_CC_value);
			}

			/* Set CV */
#if !defined(CONFIG_MTK_JEITA_STANDARD_SUPPORT)
	if(batt_cust_data.high_battery_voltage_support)
			cv_voltage = BATTERY_VOLT_04_350000_V;
	else
			cv_voltage = BATTERY_VOLT_04_200000_V;

			battery_charging_control(CHARGING_CMD_SET_CV_VOLTAGE, &cv_voltage);
#endif
		}
	}

	/* enable/disable charging */
	battery_log(BAT_LOG_CRTI, "[BATTERY] pchr_turn_on_charging(), enable =%d \r\n",
			    charging_enable);
	battery_charging_control(CHARGING_CMD_ENABLE, &charging_enable);


}
Пример #5
0
static void pchr_turn_on_charging (void)
{
	BATTERY_VOLTAGE_ENUM cv_voltage;
	kal_uint32 charging_enable = KAL_TRUE;

    if ( BMT_status.bat_charging_state == CHR_ERROR ) 
    {
        battery_xlog_printk(BAT_LOG_CRTI, "[BATTERY] Charger Error, turn OFF charging !\n");

		charging_enable = KAL_FALSE;
        
    }
    else if( (get_boot_mode()==META_BOOT) || (get_boot_mode()==ADVMETA_BOOT) )
    {   
        battery_xlog_printk(BAT_LOG_CRTI, "[BATTERY] In meta or advanced meta mode, disable charging.\n");    
        charging_enable = KAL_FALSE;
    }
    else
    {
        /*HW initialization*/
        battery_charging_control(CHARGING_CMD_INIT,NULL);
		
	    battery_xlog_printk(BAT_LOG_FULL, "charging_hw_init\n" );

        /* Set Charging Current */			
        if (g_bcct_flag == 1)
        {
            select_charging_curret_bcct();

            battery_xlog_printk(BAT_LOG_FULL, "[BATTERY] select_charging_curret_bcct !\n");
        }
        else
        {
            select_charging_curret();

            battery_xlog_printk(BAT_LOG_FULL, "[BATTERY] select_charging_curret !\n");
        }
        
        if( g_temp_CC_value == CHARGE_CURRENT_0_00_MA || g_temp_input_CC_value == CHARGE_CURRENT_0_00_MA)
        {
        
			charging_enable = KAL_FALSE;
						
            battery_xlog_printk(BAT_LOG_CRTI, "[BATTERY] charging current is set 0mA, turn off charging !\r\n");
        }
        else
        {    
       		battery_charging_control(CHARGING_CMD_SET_INPUT_CURRENT,&g_temp_input_CC_value);
			battery_charging_control(CHARGING_CMD_SET_CURRENT,&g_temp_CC_value);

			/*Set CV Voltage*/
			#if defined(MTK_JEITA_STANDARD_SUPPORT)
           		cv_voltage = select_jeita_cv();
			#else            
	            cv_voltage = BATTERY_VOLT_04_200000_V;
			#endif

			/*Set CV Voltage*/
		    battery_charging_control(CHARGING_CMD_SET_CV_VOLTAGE,&cv_voltage);
        }
    }
	
	/* enable/disable charging */
  	battery_charging_control(CHARGING_CMD_ENABLE,&charging_enable);
	
	battery_xlog_printk(BAT_LOG_CRTI, "[BATTERY] pchr_turn_on_charging(), enable =%d !\r\n", charging_enable);
}
Пример #6
0
static void pchr_turn_on_charging (void)
{
#if !defined(MTK_JEITA_STANDARD_SUPPORT) 
	BATTERY_VOLTAGE_ENUM cv_voltage;
#endif	
	kal_uint32 charging_enable = KAL_TRUE;

    if ( BMT_status.bat_charging_state == CHR_ERROR ) 
    {
        battery_xlog_printk(BAT_LOG_CRTI, "[BATTERY] Charger Error, turn OFF charging !\n");

		charging_enable = KAL_FALSE;
        
    }
    else if( (g_platform_boot_mode==META_BOOT) || (g_platform_boot_mode==ADVMETA_BOOT) )
    {   
        battery_xlog_printk(BAT_LOG_CRTI, "[BATTERY] In meta or advanced meta mode, disable charging.\n");    
        charging_enable = KAL_FALSE;
    }
    else
    {
        /*HW initialization*/
        battery_charging_control(CHARGING_CMD_INIT,NULL);
		
	    battery_xlog_printk(BAT_LOG_FULL, "charging_hw_init\n" );

        /* Set Charging Current */			
        if (g_bcct_flag == 1)
        {
            select_charging_curret_bcct();

            battery_xlog_printk(BAT_LOG_FULL, "[BATTERY] select_charging_curret_bcct !\n");
        }
        else
        {
            select_charging_curret();

            battery_xlog_printk(BAT_LOG_FULL, "[BATTERY] select_charging_curret !\n");
        }
        
        if( g_temp_CC_value == CHARGE_CURRENT_0_00_MA || g_temp_input_CC_value == CHARGE_CURRENT_0_00_MA)
        {
        
			charging_enable = KAL_FALSE;
						
            battery_xlog_printk(BAT_LOG_CRTI, "[BATTERY] charging current is set 0mA, turn off charging !\r\n");
        }
        else
        {    
       		battery_charging_control(CHARGING_CMD_SET_INPUT_CURRENT,&g_temp_input_CC_value);
			battery_charging_control(CHARGING_CMD_SET_CURRENT,&g_temp_CC_value);

			/*Set CV Voltage*/
			#if !defined(MTK_JEITA_STANDARD_SUPPORT)            
                #ifdef HIGH_BATTERY_VOLTAGE_SUPPORT
                    cv_voltage = BATTERY_VOLT_04_340000_V;
                #else
	            cv_voltage = BATTERY_VOLT_04_200000_V;
                #endif            
		    battery_charging_control(CHARGING_CMD_SET_CV_VOLTAGE,&cv_voltage);
			#endif
        }
    }
	
	/* enable/disable charging */
  	battery_charging_control(CHARGING_CMD_ENABLE,&charging_enable);
	
	battery_xlog_printk(BAT_LOG_CRTI, "[BATTERY] pchr_turn_on_charging(), enable =%d !\r\n", charging_enable);
	//<Begin> <Add FTM battery charging leds control> <20131107> <mickal.ma>
	if(get_boot_mode() == FACTORY_BOOT || get_boot_mode() == RECOVERY_BOOT){
	    if(charging_enable){
		    if (BMT_status.UI_SOC >= 100) {
                mt65xx_leds_brightness_set(0/*MT65XX_LED_TYPE_RED*/, 0/*LED_OFF*/);
                mt65xx_leds_brightness_set(1/*MT65XX_LED_TYPE_GREEN*/, 255/*LED_FULL*/);
                mt65xx_leds_brightness_set(2/*MT65XX_LED_TYPE_BLUE*/, 0/*LED_OFF*/);
		    } else {
                mt65xx_leds_brightness_set(0/*MT65XX_LED_TYPE_RED*/, 255/*LED_FULL*/);
                mt65xx_leds_brightness_set(1/*MT65XX_LED_TYPE_GREEN*/, 0/*LED_OFF*/);
                mt65xx_leds_brightness_set(2/*MT65XX_LED_TYPE_BLUE*/, 0/*LED_OFF*/);
            }		
		
	    }
	}
	//<End> <Add FTM battery charging leds control> <20131107> <mickal.ma>
}
Пример #7
0
static void pchr_turn_on_charging (void)
{
#if !defined(MTK_JEITA_STANDARD_SUPPORT)
    BATTERY_VOLTAGE_ENUM cv_voltage;
#endif
    kal_uint32 charging_enable = KAL_TRUE;

#if defined(MTK_DUAL_INPUT_CHARGER_SUPPORT)
    if(KAL_TRUE == BMT_status.charger_exist)
        charging_enable = KAL_TRUE;
    else
        charging_enable = KAL_FALSE;
#endif

    if ( BMT_status.bat_charging_state == CHR_ERROR )
    {
        battery_xlog_printk(BAT_LOG_CRTI, "[BATTERY] Charger Error, turn OFF charging !\n");

        charging_enable = KAL_FALSE;

    }
    else if( (g_platform_boot_mode==META_BOOT) || (g_platform_boot_mode==ADVMETA_BOOT) )
    {
        battery_xlog_printk(BAT_LOG_CRTI, "[BATTERY] In meta or advanced meta mode, disable charging.\n");
        charging_enable = KAL_FALSE;
    }
    else
    {
        /*HW initialization*/
        battery_charging_control(CHARGING_CMD_INIT,NULL);

        battery_xlog_printk(BAT_LOG_FULL, "charging_hw_init\n" );

#if defined(MTK_PUMP_EXPRESS_PLUS_SUPPORT)
        battery_pump_express_algorithm_start();
#endif

        /* Set Charging Current */
        if (get_usb_current_unlimited()) {
            g_temp_input_CC_value = AC_CHARGER_CURRENT;
            g_temp_CC_value = AC_CHARGER_CURRENT;
            battery_xlog_printk(BAT_LOG_FULL, "USB_CURRENT_UNLIMITED, use AC_CHARGER_CURRENT\n" );
        }
        else {
            if (g_bcct_flag == 1)
            {
                select_charging_curret_bcct();

                battery_xlog_printk(BAT_LOG_FULL, "[BATTERY] select_charging_curret_bcct !\n");
            }
            else
            {
                select_charging_curret();

                battery_xlog_printk(BAT_LOG_FULL, "[BATTERY] select_charging_curret !\n");
            }
        }
//modify by willcai 2014-5-29 begin
#ifdef X2_CHARGING_STANDARD_SUPPORT
        lenovo_get_charging_curret(&g_temp_CC_value);
#endif
//end
        battery_xlog_printk(BAT_LOG_CRTI, "[BATTERY] Default CC mode charging : %d, input current = %d\r\n", g_temp_CC_value,g_temp_input_CC_value);
        if( g_temp_CC_value == CHARGE_CURRENT_0_00_MA || g_temp_input_CC_value == CHARGE_CURRENT_0_00_MA)
        {

            charging_enable = KAL_FALSE;

            battery_xlog_printk(BAT_LOG_CRTI, "[BATTERY] charging current is set 0mA, turn off charging !\r\n");
        }
        else
        {
            battery_charging_control(CHARGING_CMD_SET_INPUT_CURRENT,&g_temp_input_CC_value);
            battery_charging_control(CHARGING_CMD_SET_CURRENT,&g_temp_CC_value);

            /*Set CV Voltage*/
#if !defined(MTK_JEITA_STANDARD_SUPPORT)
#ifdef HIGH_BATTERY_VOLTAGE_SUPPORT
            cv_voltage = BATTERY_VOLT_04_340000_V;
#else
            cv_voltage = BATTERY_VOLT_04_200000_V;
#endif
            battery_charging_control(CHARGING_CMD_SET_CV_VOLTAGE,&cv_voltage);
#endif
        }
    }

    /* enable/disable charging */
    battery_charging_control(CHARGING_CMD_ENABLE,&charging_enable);

    battery_xlog_printk(BAT_LOG_FULL, "[BATTERY] pchr_turn_on_charging(), enable =%d !\r\n", charging_enable);
}