示例#1
0
void set_charging_current_sub(void)
{
#ifdef CONFIG_LGE_BLOCK_CHARGING_MODE
	if ( 0 == get_block_charging_state() ) {
		printk(KERN_INFO "%s: Block Charging State\n", __func__);
		return ;
	}
#endif

	switch( get_ext_pwr_type() ) {
		case NO_CABLE:
			charging_ic_active_default();
			break;
		case LT_CABLE_56K:
		case LT_CABLE_130K:
		case LT_CABLE_910K:
			charging_ic_set_factory_mode();

			/* mbk_temp HW Request */
			setting_for_factory_mode_hw_req();
			break;
		case TA_CABLE:
		case FORGED_TA_CABLE:
			charging_ic_set_ta_mode();
			break;
		case USB_CABLE:
		case ABNORMAL_USB_100MA:
		case ABNORMAL_USB_400MA:
			charging_ic_set_usb_mode();
			break;
	}
	printk("[charging_msg] %s, External Power Type %d, charging_ic_status %d \n", __FUNCTION__, get_ext_pwr_type(), charging_ic_status);
	return ;
}
示例#2
0
s32 muic_AP_USB_set(void){

	s32 ret;
/* LGE_CHANGE_START 2011-03-16 [email protected] patch for Adb offline set and Mass Storage Driver detecting fail */    
	/* 20110113 [email protected] check muic driver init. state [START] */
	if(!muic_init_done){

		printk(KERN_WARNING "[MUIC] MUIC has not been initialized! Nothing will be done!!!.\n");
		return 0;
	}	
    /* 20110113 [email protected] check muic driver init. state [END] */
/* LGE_CHANGE_END 2011-03-16 [email protected] */

	/* Connect CP UART signals to AP */
	//usif_switch_ctrl(USIF_AP);

	/* AP USB does not pass through DP3T.
	 * Just connect AP UART to MUIC UART. */
	//dp3t_switch_ctrl(DP3T_AP_UART);		// [email protected]

	if (muic_device == MAX14526) {
		/* ID_200, VLDO 2.6V, ADC Enable,
		 * USB 2.0 also needs the charge pump (CP_EN) on.*/
		ret = muic_i2c_write_byte_local(CONTROL_1, MID_200 | MADC_EN | MCP_EN);
	}
	else {
		ret = muic_i2c_write_byte_local(SW_CONTROL, DP_OPEN | DM_OPEN);
		/* ID_200, VLDO 2.6V, SEMREN on. ADC is auto.
		 * USB 2.0 also needs the charge pump (CP_EN) on.*/
		ret = muic_i2c_write_byte_local(CONTROL_1, MID_200 | MSEMREN | MCP_EN);
	}
	/* Connect DP, DM to USB_DP, USB_DM */
	ret = muic_i2c_write_byte_local(SW_CONTROL, DP_USB | DM_USB);

	/* Turn on charger IC with TA mode */
	charging_ic_set_usb_mode();

	muic_mode = MUIC_AP_USB;
	printk(KERN_WARNING "[MUIC] muic_distinguish_vbus_accessory(): AP_USB\n");

	/* wake lock for usb connection */
	set_wakelock(1);

	return ret;
}
示例#3
0
void rt9536_charging_enable(unsigned int set_current, unsigned int enable)
{
    if (enable)
    {
        if ( set_current == AC_CHARGER_CURRENT )
            charging_ic_set_ta_mode();
        else if ( set_current == USB_CHARGER_CURRENT )
            charging_ic_set_usb_mode();
        else
            charging_ic_active_default();

        printk("[charger_rt9536] :: %s, current(%d), enable(%d)\n", __func__, set_current, enable);
    }
    else
    {
        charging_ic_deactive();
        printk("[charger_rt9536] :: %s, enable(%d)\n", __func__, enable);        
    }
    
}
示例#4
0
s32 muic_CP_USB_set(void){

	s32 ret;

/* LGE_CHANGE_START 2011-03-16 [email protected] patch for Adb offline set and Mass Storage Driver detecting fail */    	
	/* 20110113 [email protected] check muic driver init. state [START] */
	if(!muic_init_done){

		printk(KERN_WARNING "[MUIC] MUIC has not been initialized! Nothing will be done!!!.\n");
		return 0;
	}
	/* 20110113 [email protected] check muic driver init. state [END] */
/* LGE_CHANGE_END 2011-03-16 [email protected] */

// LGE_UPDATE_S 20110411 [[email protected]] force D+/D- open in CP side
	ret = muic_i2c_write_byte(SW_CONTROL, DP_OPEN | DM_OPEN);
	muic_udelay(100000);

	if(ret < 0)
		printk(KERN_WARNING "[MUIC] i2c write error for D+/D- open in muic_CP_USB_SET\n");
// LGE_UPDATE_E 20110411 [[email protected]] force D+/D- open in CP side

	/* Connect CP UART signals to AP */
   	/* CP <-> USIF_AP ?�결??CP ?�운로드 Fail 발생 */
    usif_switch_ctrl(USIF_DP3T);
	/* Connect CP USB to MUIC UART */
	dp3t_switch_ctrl(DP3T_CP_USB);

	if (muic_device == MAX14526) {
		/* ID_200, VLDO 2.6V, ADC is auto.
		 * USB 2.0 also needs the charge pump (CP_EN) on.*/
		ret = muic_i2c_write_byte(CONTROL_1, MID_200 | MADC_EN | MCP_EN);
	}
	else {
		if( MUIC_CP_USB != muic_mode ) {
			/* ID_200, VLDO 2.6V, SEMREN on. ADC is auto.
			 * USB 2.0 also needs the charge pump (CP_EN) on.*/
			ret = muic_i2c_write_byte(CONTROL_1, MID_200 | MSEMREN | MCP_EN);
		}
	}

	ret = muic_i2c_write_byte(SW_CONTROL, DP_USB | DM_USB);

	// S [email protected] ; add for charging mode when CP USB is slected
	int check_battery_present();
	if(check_battery_present()==1)
		charging_ic_set_usb_mode();
	else
		charging_ic_set_factory_mode();
	// E [email protected] ; add for charging mode when CP USB is slected

	muic_mode = MUIC_CP_USB;
	printk(KERN_ERR "[MUIC] muic_distinguish_vbus_accessory(): CP_USB\n");

// START [email protected] 2011/03/03 LAB1_FW : WAKELOCK_CASE_AT_CP_USB : Ref from LU3000 {
	if ( reset_status == 2 /* RESET_GLOBAL_SW_RESET */ ) {
        // If muic path is CP_USB, Reset cause is SW_RESET then WakeLock AP
		// wake lock for the factory mode
		if(0==the_wlock.wake_lock_on){
			wake_lock(&the_wlock.wake_lock);
			the_wlock.wake_lock_on=1;
			printk(KERN_WARNING "[MUIC] ====^^==== wake_lock_on=1 (locked)\n");
		}
	}
    else {
		/* wake lock off for the factory mode */
		set_wakelock(0);
    }
// END [email protected] 2011/03/03 LAB1_FW }

	return ret;
}
示例#5
0
s32 muic_AP_USB_set(void){

	s32 ret;
/* LGE_CHANGE_START 2011-03-16 [email protected] patch for Adb offline set and Mass Storage Driver detecting fail */    
	/* 20110113 [email protected] check muic driver init. state [START] */
	if(!muic_init_done){

		printk(KERN_WARNING "[MUIC] MUIC has not been initialized! Nothing will be done!!!.\n");
		return 0;
	}

    /* 20110113 [email protected] check muic driver init. state [END] */
/* LGE_CHANGE_END 2011-03-16 [email protected] */

	if(hidden_menu_switching == 8)	// if USB mode change AP_USB through Proc filesystem, force D+/D- open
	{
	        ret = muic_i2c_write_byte(SW_CONTROL, DP_OPEN | DM_OPEN);
	        muic_udelay(100000);

	        if(ret < 0)
	                printk(KERN_WARNING "[MUIC] i2c write error for D+/D- open in muic_CP_USB_SET\n");
	}

	/* Justin?�서 AP_UART�??�정??AP_USB ?�작 ?�함 */
    dp3t_switch_ctrl(DP3T_NC);

	if (muic_device == MAX14526) {
		/* ID_200, VLDO 2.6V, ADC Enable,
		 * USB 2.0 also needs the charge pump (CP_EN) on.*/
		ret = muic_i2c_write_byte(CONTROL_1, MID_200 | MADC_EN | MCP_EN);
	}
	else {


// START [email protected] 2011/03/10 LAB1_FW {
		if( MUIC_AP_USB != muic_mode ) 
		{
			ret = muic_i2c_write_byte(SW_CONTROL, DP_OPEN | DM_OPEN);
			/* ID_200, VLDO 2.6V, SEMREN on. ADC is auto.
			 * USB 2.0 also needs the charge pump (CP_EN) on.*/
			ret = muic_i2c_write_byte(CONTROL_1, MID_200 | MSEMREN | MCP_EN);
		}
// END [email protected] 2011/03/10 LAB1_FW }
	}

	/* Connect DP, DM to USB_DP, USB_DM */
	ret = muic_i2c_write_byte(SW_CONTROL, DP_USB | DM_USB);

	/* Turn on charger IC with TA mode */
	charging_ic_set_usb_mode();

	muic_mode = MUIC_AP_USB;
	printk(KERN_WARNING "[MUIC] muic_distinguish_vbus_accessory(): AP_USB\n");

	/* wake lock for usb connection */
	set_wakelock(1);

//	check_usb_reg(); /* 20111105, [email protected], for stable USB connection. */

	return ret;
}
static int set_battery_charging(struct twl4030_bci_device_info *di)
{
	int trickle_chg_max, trickle_chg_min, trickle_chg_timer_start;
	max8922_status chr_ic_status = get_charging_ic_status();
	
	if(di->battery_present == 0 || 						// No Battery State
		di->charge_rsoc == POWER_SUPPLY_TYPE_BATTERY) {	// No Charging Source
		start_monitor = 0;
		set_end_of_charge(0);
		set_charging_timer(0);
		return 0;
	}
	
	/*
	 * Recharging algorithm
     *  - High Temperature : up to 4.0V
     *  - Normal : up to 4.2V
     */
    // Set maximum charging voltage
    if((di->temp_C < TEMP_CRITICAL_LOWER ||
	   di->temp_C > TEMP_CRITICAL_UPPER) && // Critical Temperature! Must stop charging
	   di->temp_control != UNLIMITED_TEMP_VAL){ // 20120725, [email protected], Enable charging by fake mode.
		start_monitor = 0;
		set_end_of_charge(0);
		set_charging_timer(0);
		if (di->battery_present == 1)
        	charging_ic_deactive();
        return 0;
    } else if(di->temp_C < TEMP_LIMIT_LOWER ||
              di->temp_C > TEMP_LIMIT_UPPER) {	// Charging Limit
		trickle_chg_max = 4000;
		trickle_chg_timer_start = 3950;
		trickle_chg_min = 3900;
	} else {									// Normal Charging
		trickle_chg_max = 4220;					// to unintentional charging stop
		trickle_chg_timer_start = 4197;
		trickle_chg_min = 4140;
		if((di->previous_temp_C < TEMP_LIMIT_LOWER ||
		   di->previous_temp_C > TEMP_LIMIT_UPPER) &&
		   di->temp_control != UNLIMITED_TEMP_VAL) { // 20120725, [email protected], Enable charging by fake mode.
			start_monitor = 0;
			set_end_of_charge(0);
			set_charging_timer(0);
		}
	}

	// Deactive charger for protect overcharge & monitoring
	if(chr_ic_status != CHARGING_IC_DEACTIVE) {
		if(/*di->voltage_uV >= trickle_chg_max ||*/ charging_timeout() || end_of_charge) {
			// Battery Full Charged Once. Entering Trickle Charging Mode
			if(!charging_timeout())		// Do not stop charging when timeout occured
				charging_ic_deactive();	// It's not actually charged full.
			set_charging_timer(0);
			set_end_of_charge(0);
			if(start_monitor == 0) {
				printk(KERN_DEBUG "[Battery] Trickle Charging Start!\n");
				start_monitor = 1;
			}
		} else if(di->voltage_uV >= trickle_chg_timer_start) {
			set_charging_timer(1);
		}
	} else if(di->voltage_uV < trickle_chg_min) {	// active charger for recharging
		switch(di->charge_rsoc) {
			case POWER_SUPPLY_TYPE_MAINS:
				charging_ic_set_ta_mode();
				break;
			case POWER_SUPPLY_TYPE_USB:
				charging_ic_set_usb_mode();
				break;
			case POWER_SUPPLY_TYPE_UPS:
				charging_ic_set_factory_mode();
				break;
			default:
				break;
		}
	}
	return 0;
}