static int twl4030_usb_bci_battery_get_property(struct power_supply *psy,
					enum power_supply_property psp,
					union power_supply_propval *val)
{

		TYPE_MUIC_MODE muic_mode = MUIC_NONE;


	switch (psp) {
		case POWER_SUPPLY_PROP_ONLINE:
/* LGE_CHANGE_S [[email protected]] 2010-03-19 */
#if defined(CONFIG_HUB_MUIC)
			muic_mode = get_muic_mode();
			if ( muic_mode == MUIC_AP_USB)
				val->intval = 1;
			else
				val->intval = 0;
			break;
// [email protected] 20120502 MUIC re-work start
#elif defined(CONFIG_MUIC)
			muic_mode = muic_get_mode();
			if ( muic_mode == MUIC_AP_USB)
				val->intval = 1;
			else
				val->intval = 0;
			break;
// [email protected] 20120502 MUIC re-work end	
#endif
/* LGE_CHANGE_E [[email protected]] 2010-03-19 */
		default:
			return -EINVAL;
	}

	return 0;
}
Exemple #2
0
TYPE_MUIC_MODE get_muic_mode(void){
//[email protected] 20120502 MUIC re-work
#if defined(CONFIG_MUIC)
	return muic_get_mode();
#else
	return muic_mode;
//[email protected] 20120502 MUIC re-work
#endif
}
/** @brief  To check PIF connected for factory test mode
    @author [email protected]
    @date   2010.05.14
*/
static ssize_t pif_detect_show(struct device *dev,
			       struct device_attribute *attr,
			       char *buf)
{
	int ret, val;
#if defined(CONFIG_HUB_MUIC)
	ret = get_muic_mode();

	if(ret == MUIC_UNKNOWN) {
		val = -1;
	} else if (lcd_off_boot && !check_battery_present()) {
		val = 2;
	} else if (ret == MUIC_AP_UART) {
		val = 1;
	} else if ((ret == MUIC_CP_UART) || (ret == MUIC_CP_USB)) {
		val = 2;
	} else {
		val = 0;
	}
// [email protected] 20120502 MUIC re-work start	
#elif defined(CONFIG_MUIC)
	int muic_mode;
	muic_mode = muic_get_mode();

	if(muic_mode == MUIC_UNKNOWN) {
		val = -1;
	} else if (lcd_off_boot && !check_battery_present()) {
		val = 2;
	} else if (muic_mode == MUIC_AP_UART) {
		val = 1;
	} else if ((muic_mode == MUIC_CP_UART) || (muic_mode == MUIC_CP_USB)) {
		val = 2;
	} else {
		val = 0;
	}
// [email protected] 20120502 MUIC re-work end	
#endif
	sprintf(buf, "%d\n", val);
	return (ssize_t)(strlen(buf) + 1);
}
static int twl4030_ac_bci_battery_get_property(struct power_supply *psy,
					enum power_supply_property psp,
					union power_supply_propval *val)
{

	max8922_status chr_ic_status = CHARGING_IC_DEACTIVE;
	chr_ic_status = get_charging_ic_status();
	TYPE_MUIC_MODE muic_mode = MUIC_NONE;


	switch (psp) {
		case POWER_SUPPLY_PROP_ONLINE:
/* LGE_CHANGE_S [[email protected]] 2010-03-19 */
#if defined(CONFIG_HUB_MUIC)
			muic_mode = get_muic_mode();
			if ( muic_mode == MUIC_LG_TA || muic_mode == MUIC_NA_TA || muic_mode == MUIC_HCHH || muic_mode == MUIC_INVALID_CHG )
				val->intval = 1;
			else
				val->intval = 0;
			break;
// [email protected] 20120502 MUIC re-work start
#elif defined(CONFIG_MUIC)
			muic_mode = muic_get_mode();
			if ( muic_mode == MUIC_LG_TA || muic_mode == MUIC_NA_TA || muic_mode == MUIC_TA_1A || muic_mode == MUIC_INVALID_CHG && chr_ic_status != CHARGING_IC_DEACTIVE)
				val->intval = 1;
			else
				val->intval = 0;
			break;
// [email protected] 20120502 MUIC re-work end	
#endif
/* LGE_CHANGE_E [[email protected]] 2010-03-19 */
		default:
			return -EINVAL;
	}

	return 0;
}
static void set_battery_status(struct twl4030_bci_device_info *di)
{

// [email protected] 20120502 MUIC re-work start
#if defined(CONFIG_HUB_MUIC)
	TYPE_MUIC_MODE muic_mode = get_muic_mode();
#elif defined(CONFIG_MUIC)
	TYPE_MUIC_MODE muic_mode = muic_get_mode();
#endif
// [email protected] 20120502 MUIC re-work end

	// Set Power Resources
	switch (muic_mode) {
		case MUIC_AP_UART:
		case MUIC_CP_UART:
		case MUIC_CP_USB:
			di->charge_rsoc = POWER_SUPPLY_TYPE_UPS;
			wakeup_timer_seconds = 0;	// disable wakeup.
			break;
		case MUIC_NA_TA:
		case MUIC_LG_TA:
		case MUIC_TA_1A:
		case MUIC_INVALID_CHG:
			di->charge_rsoc = POWER_SUPPLY_TYPE_MAINS;
			wakeup_timer_seconds = 60;	// to wake up to monitor battery when charging mode
			break;
		case MUIC_AP_USB:
			di->charge_rsoc = POWER_SUPPLY_TYPE_USB;
			wakeup_timer_seconds = 0;	// disable wakeup. The phone will be wakeup because of wakelock
			break;
		default :
			di->charge_rsoc = POWER_SUPPLY_TYPE_BATTERY;
			wakeup_timer_seconds = 0;	// disable wakeup.
			if(di->battery_capacity <= 1)	// enable wakeup for monitoring power-off voltage
				wakeup_timer_seconds = 60;
		break;
	}
	
	// Set Charging Status
	if(di->charge_rsoc == POWER_SUPPLY_TYPE_UPS ||		// JIG
	   di->charge_rsoc == POWER_SUPPLY_TYPE_BATTERY) {	// Battery
		di->charge_status = POWER_SUPPLY_STATUS_DISCHARGING;
	} else {
		if(di->battery_present == 0) {			// Battery not present. Display as not charging
			di->charge_status = POWER_SUPPLY_STATUS_NOT_CHARGING;		
		} else if((di->temp_C < TEMP_CRITICAL_LOWER ||
			  di->temp_C > TEMP_CRITICAL_UPPER) &&
			  di->temp_control != UNLIMITED_TEMP_VAL) {	// 20120725, [email protected], Enable charging by fake mode.
			// Charging Stoped
			di->charge_status = POWER_SUPPLY_STATUS_NOT_CHARGING;
		} else if((di->temp_C < TEMP_LIMIT_LOWER ||
			  di->temp_C > TEMP_LIMIT_UPPER) &&
			  di->temp_control != UNLIMITED_TEMP_VAL) {	// 20120725, [email protected], Enable charging by fake mode.
			// Charging Limited
			di->charge_status = POWER_SUPPLY_STATUS_CHARGING;
		} else if(start_monitor||di->battery_capacity >= 100) {			// Charging FULL
			di->charge_status = POWER_SUPPLY_STATUS_FULL;
		} else {					// Normal Charging
			di->charge_status = POWER_SUPPLY_STATUS_CHARGING;
		}
	}

	/*ntyeongon.moon 2011-04-01 CP USB Charging mode [START]*/
	if((di->charge_status==POWER_SUPPLY_STATUS_DISCHARGING)
		&& power_supply_am_i_supplied(&di->bat)    )
    {
		di->charge_status = POWER_SUPPLY_STATUS_CHARGING;
	}
	/*ntyeongon.moon 2011-04-01 CP USB Charging mode [END]*/

}
static int twl4030_bci_battery_get_property(struct power_supply *psy,
					    enum power_supply_property psp,
					    union power_supply_propval *val)
{
	struct twl4030_bci_device_info *di;
#if defined(CONFIG_HUB_MUIC)
#else
	int status = 0;
#endif	
	max8922_status chr_ic_status = CHARGING_IC_DEACTIVE;
	chr_ic_status = get_charging_ic_status();

    TYPE_MUIC_MODE muic_mode = MUIC_NONE;


	di = to_twl4030_bci_device_info(psy);
/*
	switch (psp) {
		case POWER_SUPPLY_PROP_STATUS:
			val->intval = di->charge_status;
			return 0;
		default:
			break;
	}
*/
	switch (psp) {
		case POWER_SUPPLY_PROP_STATUS:
			val->intval = di->charge_status;
#if 0 //ntyeongon.moon 2011-03-16  full-charge status comes from soc level [START]
			if(di->voltage_uV > 4190) {		// QM Requested for Dummy Battery Test (LGP970)
				val->intval = POWER_SUPPLY_STATUS_FULL;
			}
#endif //ntyeongon.moon 2011-03-16  full-charge status comes from soc level [END]
			break;
		case POWER_SUPPLY_PROP_VOLTAGE_NOW:
			val->intval = di->voltage_uV;
			break;
		case POWER_SUPPLY_PROP_CURRENT_NOW:
			val->intval = di->current_uA;
			break;
		case POWER_SUPPLY_PROP_TEMP:
			if(di->battery_present == 0)		// No Battery or Dummy Battery
				val->intval = 200;
			// S[, 20120725, [email protected], Enable charging by fake mode.
			else if (di->temp_control == UNLIMITED_TEMP_VAL) 
			{
				if (di->temp_C > UNLIMITED_TEMP_HIGH)
					val->intval = UNLIMITED_TEMP_HIGH;
				else if (di->temp_C < UNLIMITED_TEMP_LOW)
					val->intval = UNLIMITED_TEMP_LOW;
				else
					val->intval = di->temp_C;
			}
			// E], 20120725, [email protected], Enable charging by fake mode.
			else
				val->intval = di->temp_C;
			break;
		case POWER_SUPPLY_PROP_ONLINE:
#if defined(CONFIG_HUB_MUIC)  || defined(CONFIG_MUIC)

			val->intval = di->charge_rsoc;
//2011-03-23 [email protected] get muic INT_STAT  VBUS [START_LGE]
			 if(!is_muic_mvbus_on()) val->intval = 0;
//2011-03-23 [email protected] get muic INT_STAT  VBUSVBUS [END_LGE]
			break;
#else
			status = twl4030bci_status();
			if ((status & AC_STATEC) == AC_STATEC)
				val->intval = POWER_SUPPLY_TYPE_MAINS;
			else if (usb_charger_flag)
				val->intval = POWER_SUPPLY_TYPE_USB;
			else
				val->intval = 0;
			break;
#endif  // CONFIG_HUB_MUIC
		case POWER_SUPPLY_PROP_PRESENT:
			val->intval = di->battery_present;
#if defined(CONFIG_HUB_MUIC)
			muic_mode = get_muic_mode();
			if(muic_mode == MUIC_CP_USB  ||		// JIG
			   muic_mode == MUIC_CP_UART ||
			   muic_mode == MUIC_AP_UART) {
				val->intval = 1;
			} else if(muic_mode == MUIC_NONE) {	// Dummy Battery
				val->intval = 1;
			}
// [email protected] 20120502 MUIC re-work start
#elif defined(CONFIG_MUIC)
			muic_mode = muic_get_mode();
			if(muic_mode == MUIC_CP_USB  ||		// JIG
			   muic_mode == MUIC_CP_UART ||
			   muic_mode == MUIC_AP_UART && 
			   chr_ic_status != CHARGING_IC_DEACTIVE) {
				val->intval = 1;
			} else if(muic_mode == MUIC_NONE) {	// Dummy Battery
				val->intval = 1;
			}
#else
	#error
// [email protected] 20120502 MUIC re-work end
#endif
            break;

		case POWER_SUPPLY_PROP_CAPACITY:
			#if defined(CONFIG_HUB_MUIC)
				muic_mode = get_muic_mode();
			#elif defined(CONFIG_MUIC)
				muic_mode = muic_get_mode();
			#endif
			val->intval = di->battery_capacity;
			printk("[BATTER] cap:%d , muic:%d \n",val->intval, muic_mode);
			// for Lockscreen sync with status bar
#if 0  //ntyeongon.moon 2011-03-16  full-charge status comes from soc level [START]
			if(di->charge_rsoc == POWER_SUPPLY_TYPE_MAINS ||
			   di->charge_rsoc == POWER_SUPPLY_TYPE_USB) {	// When Charging Mode
				if(di->charge_status == POWER_SUPPLY_STATUS_FULL) {
					val->intval = 100;
				} else if(di->battery_present == 1 &&	// Battery Present and not Full
					  val->intval == 100) {		// but battery level is 100%
					val->intval = 99;		// view as 99% for lockscreen
				} else if(di->voltage_uV > 4190) {	// QM Requested for Dummy Battery Test (LGP970)
					val->intval = 100;
				}
			}
#endif //ntyeongon.moon 2011-03-16  full-charge status comes from soc level [END]

			break;
			/* FIXME : It depends on H/W specific */
		case POWER_SUPPLY_PROP_HEALTH:
			if(!di->battery_present)
				val->intval = POWER_SUPPLY_HEALTH_UNKNOWN;
			else if(di->voltage_uV > 5000)				// Over voltage
				val->intval = POWER_SUPPLY_HEALTH_OVERVOLTAGE;
			else if(di->temp_C < TEMP_CRITICAL_LOWER)	// Cold
				val->intval = POWER_SUPPLY_HEALTH_COLD;
			else if(di->temp_C > TEMP_CRITICAL_UPPER)	// Hot
				val->intval = POWER_SUPPLY_HEALTH_OVERHEAT;
			else
				val->intval = POWER_SUPPLY_HEALTH_GOOD;
			break;
		case POWER_SUPPLY_PROP_TECHNOLOGY:
			val->intval = POWER_SUPPLY_TECHNOLOGY_LION;	// Fixed value : Li-ion
			break;

// S[, 20120725, [email protected], Enable charging by fake mode.
		case POWER_SUPPLY_PROP_TEMP_CONTROL:
//#ifdef CONFIG_MACH_LGE_CX2 // <-- not defined.
//			lge_dynamic_nvdata_read(LGE_NVDATA_DYNAMIC_CHARGING_TEMP_OFFSET, &temp_val, 1);
//
//			val->intval = (int)temp_val;
//#else
			val->intval = (int)di->temp_control;
//#endif
			break;
// E], 20120725, [email protected], Enable charging by fake mode.
		default:
			return -EINVAL;
	}
	return 0;
}
static int __devinit max14526_probe(struct i2c_client *client,
		const struct i2c_device_id *id)
{
	int ret = 0;
	TYPE_MUIC_MODE muic_mode;
	struct ts5usb_device *dev = NULL;
	struct muic_platform_data *pdata = client->dev.platform_data;

	dev_info(&client->dev, "muic: %s()\n", __func__);

	if (!pdata) {
		dev_err(&client->dev, "muic: %s: no platform data\n", __func__);
		return -EINVAL;
	}

	dev = kzalloc(sizeof(struct ts5usb_device), GFP_KERNEL);
	if (!dev) {
		dev_err(&client->dev, "muic: %s: no memory\n", __func__);
		return -ENOMEM;
	}

	dev->client = client;
	dev->gpio_int = pdata->gpio_int;
#if defined(CONFIG_MHL)
	dev->gpio_mhl = pdata->gpio_mhl;
	dev->gpio_ifx_vbus = pdata->gpio_ifx_vbus;
#endif
	dev->irq = client->irq;

	max14526 = client;

	/* Initializes gpio_165 (USIF1_SW). */
	ret = gpio_request(USIF_IN_1_GPIO, "USIF switch control GPIO");
	if (ret < 0) {
		printk(KERN_INFO "[MUIC] GPIO 165 USIF1_SW is already occupied by other driver!\n");
		/*
		 * We know board_cosmo.c:ifx_n721_configure_gpio() performs a gpio_request on this pin first.
		 * Because the prior gpio_request is also for the analog switch control, this is not a confliction.
		 */
		return -ENOSYS;
	}

	ret = gpio_direction_output(USIF_IN_1_GPIO, 0);
	if (ret < 0) {
		printk(KERN_INFO "[MUIC] gpio_16 USIF_IN_1_GPIO direction initialization failed!\n");
		return -ENOSYS;
	}

	/*  Initializes gpio_11 (OMAP_UART_SW) and gpio_12 (IFX_UART_SW) */
	ret = gpio_request(DP3T_IN_1_GPIO, "DP3T switch control 1 GPIO");
	if (ret < 0) {
		printk(KERN_INFO "[MUIC] GPIO 11 DP3T_IN_1_GPIO is already occupied by other driver!\n");
		return -ENOSYS;
	}

	ret = gpio_direction_output(DP3T_IN_1_GPIO, 0);
	if (ret < 0) {
		printk(KERN_INFO "[MUIC] gpio_11 DP3T_IN_1_GPIO direction initialization failed!\n");
		return -ENOSYS;
	}

	ret = gpio_request(DP3T_IN_2_GPIO, "DP3T switch control 2 GPIO");
	if (ret < 0) {
		printk(KERN_INFO "[MUIC] gpio_12 DP3T_IN_2_GPIO is already occupied by other driver!\n");
		return -ENOSYS;
	}

	ret = gpio_direction_output(DP3T_IN_2_GPIO, 0);
	if (ret < 0) {
		printk(KERN_INFO "[MUIC] gpio_12 DP3T_IN_2_GPIO direction initialization failed!\n");
		return -ENOSYS;
	}

	ret = gpio_request(IFX_USB_VBUS_EN_GPIO, "DP3T switch control 2 GPIO");
	if (ret < 0) {
		printk(KERN_INFO "[MUIC] gpio_55 IFX_USB_VBUS_EN_GPIO is already occupied by other driver!\n");
		return -ENOSYS;
	}

	ret = gpio_direction_output(IFX_USB_VBUS_EN_GPIO, 0);
	if (ret < 0) {
		printk(KERN_INFO "[MUIC] gpio_55 IFX_USB_VBUS_EN_GPIO direction initialization failed!\n");
		return -ENOSYS;
	}

	/*
	 * Initializes gpio_wk8 (MUIC_INT_N).
	 * Checks if other driver already occupied it.
	 */
	ret = gpio_request(dev->gpio_int, "MUIC IRQ GPIO");
	if (ret < 0) {
		dev_err(&client->dev, "muic: GPIO %d is already used\n",	dev->gpio_int);
		ret = -ENOSYS;
		goto err_gpio_request;
	}
	/* Initializes GPIO direction before use or IRQ setting */
	gpio_direction_input(dev->gpio_int);

	/* Registers MUIC work queue function */
	INIT_WORK(&dev->muic_wq, max14526_wq_func);

	/*
	 * Set up an IRQ line and enable the involved interrupt handler.
	 * From this point, a MUIC_INT_N can invoke muic_interrupt_handler().
	 * muic_interrupt_handler merely calls schedule_work() with muic_wq_func().
	 * muic_wq_func() actually performs the accessory detection.
	 */
	ret = request_irq(dev->irq, max14526_interrupt_handler,IRQF_TRIGGER_FALLING, "muic_irq", dev);
	if (ret < 0) 
	{
		dev_err(&client->dev, "muic: %s: request_irq failed!\n",__func__);
		goto err_request_irq;
	}

	//disable_irq_wake(gpio_to_irq(MUIC_INT));

	/* Prepares a human accessible method to control MUIC */
	//create_cosmo_muic_proc_file();

	/* Selects one of the possible muic chips */
	//muic_detect_device();

	wake_lock_init(&dev->muic_wake_lock, WAKE_LOCK_SUSPEND,"muic_wake_lock");

	ret = muic_device_register(&muic_dev, NULL);
	if (ret < 0) {
		dev_err(&client->dev, "muic: %s: muic_device_register failed\n",__func__);
		goto err_muic_device_register;
	}

	i2c_set_clientdata(client, dev);

	// hunsoo.lee
	printk("%s, registering ops\n", __func__);
	muic_client_dev_register(dev->client->name, dev, &max14526_ops);

	/* Initializes MUIC - Finally MUIC INT becomes enabled */
	if (BOOT_RECOVERY == muic_retain_mode) 
	{ /* Recovery mode */
		muic_mode = MUIC_CP_UART;
		muic_init_max14526(client, BOOTUP);
		dev_info(&client->dev, "muic: %s: first boot\n", __func__);
	}
	else 
	{
		muic_init_max14526(client, RESET);
		muic_max14526_detect_accessory(client, NOT_UPON_IRQ);
		muic_mode = muic_get_mode();
	}
	muic_set_mode(muic_mode);

	/* Makes the interrupt on MUIC INT wake up OMAP which is in suspend mode */
	ret = enable_irq_wake(dev->irq);
	if (ret < 0) {
		dev_err(&client->dev, "muic: GPIO %d wake up source setting failed!\n", dev->gpio_int);
		disable_irq_wake(dev->irq);
		goto err_irq_wake;
	}

	dev_info(&client->dev, "muic: muic_probe()\n");

	return ret;

err_irq_wake:
	muic_device_unregister(&muic_dev);
err_muic_device_register:
	wake_lock_destroy(&dev->muic_wake_lock);
	free_irq(dev->irq, dev);
err_request_irq:
	gpio_free(dev->gpio_int);
err_gpio_request:
	kfree(dev);

	return ret;
}
s32 muic_max14526_detect_accessory(struct i2c_client *client, s32 upon_irq)
{
	s32 ret = 0;
	s32 loop = 0;
	u8 int_stat_value=0;
	
	TYPE_MUIC_MODE muic_mode = muic_get_mode();
	struct ts5usb_device *dev = i2c_get_clientdata(client);
	/*
	 * Upon an MUIC IRQ (MUIC_INT_N falls),
	 * wait 70ms before reading INT_STATUS1 and STATUS.
	 * After the reads, MUIC_INT_N returns to high
	 * (but the INT_STATUS1 and STATUS contents will be held).
	 *
	 * Do this only if muic_max14526_detect_accessory() was called upon IRQ.
	 */
	if (upon_irq) {
		mdelay(70);
	}

	/* Read INT_STATUS1 */
	ret = muic_i2c_read_byte(client, INT_STAT, &int_stat_value);
	dev_info(&client->dev, "muic: %s: int_stat_value:0x%x :%d\n", __func__,	int_stat_value, muic_mode);

	if (ret < 0) {
		dev_info(&client->dev, "muic: INT_STATUS1 reading failed\n");
		muic_set_mode(MUIC_UNKNOWN);

		return ret;
	}

	switch (muic_mode) 
	{/* Branch according to the previous muic_mode */
		case MUIC_UNKNOWN :
		case MUIC_NONE :
			muic_set_device_none_detect(client, int_stat_value);
			break;

		case MUIC_AP_UART :
		case MUIC_CP_UART :
			dev_info(&client->dev, "muic: MUIC_AP_UART || MUIC_CP_UART\n");
			if(!(int_stat_value & VBUS)&&(IDNO_0010 == (int_stat_value & 0x0f)))
			{
				muic_set_mode(MUIC_CP_USB);
			} 
			else if (!(int_stat_value & VBUS))
			{
				muic_i2c_write_byte(client, SW_CONTROL, DP_UART | DM_UART);
				muic_set_mode(MUIC_NONE);
			}
			else
			{
				dev_info(&client->dev, "UART is not removed\n");
			}
			break;

		case MUIC_NA_TA :
		case MUIC_LG_TA :
		case MUIC_TA_1A :
		case MUIC_INVALID_CHG :
			dev_info(&client->dev, "muic: Detect step2\n");
			if (((int_stat_value & VBUS) == 0) ||((int_stat_value & CHGDET) == 0)) 
			{
				muic_set_mode(MUIC_NONE);
			}
			else
			{
				dev_info(&client->dev, "TA is not removed\n");
			}
			break;

		case MUIC_AP_USB :
			/* USB Host Removed */
			if((int_stat_value & VBUS) == 0)
			{
			android_USB_disconnect();// for usb disconnect event
			muic_set_mode(MUIC_NONE);
			}
			else
			{
				dev_info(&client->dev, "AP USB is not removed\n");
			}
			break;
			
		case MUIC_CP_USB :
			if((int_stat_value & VBUS) == 0)
			{
				muic_set_mode(MUIC_NONE);
			}
			else
			{
				dev_info(&client->dev, "CP USB is not removed\n");
			}
			break;
			
#if defined(CONFIG_MHL_TX_SII9244) || defined(CONFIG_MHL_TX_SII9244_LEGACY)
		case MUIC_MHL :
			dev_info(&client->dev, "muic: Detect step3  mhl \n");
			if ((int_stat_value & VBUS) == 0) {
				//MHL_On(0);
				muic_set_mode(MUIC_NONE);
			}
			break;
#endif
		default:
			dev_info(&client->dev, "muic: Failed to detect an accessory. Try again!");
			muic_set_mode(MUIC_UNKNOWN);
			ret = -1;
			break;
	}

	muic_mode = muic_get_mode();
	dev_info(&client->dev, "muic: muic_detection_mode=%d \n", muic_mode);

	if (muic_mode == MUIC_UNKNOWN || muic_mode == MUIC_NONE) {
#if defined(CONFIG_MHL) && defined(CONFIG_MHL_TX_MUIC_BUG_FIX)
		/* SJIT 2012-01-27 [[email protected]] P940 GB
		 * max14526 300ms delay side effect bug fixed test code
		 */
		if (Int_Status == Second_Int) {
			if (!gpio_get_value(dev->gpio_mhl)) {
				dev_info(&client->dev, "muic: wait for mhl switch completed\n");
				muic_init_max14526(client, DEFAULT);
				gpio_set_value(dev->gpio_ifx_vbus, 0);
			}
			else {
				dev_info(&client->dev, "muic: mhl switch not completed\n");
				while (!gpio_get_value(dev->gpio_mhl)) {
					udelay(500);
					muic_set_mode(MUIC_MHL);
//					MHL_On(0);
				}
				dev_info(&client->dev, "muic: mhl switch completed\n");
				muic_init_max14526(client, DEFAULT);
				gpio_set_value(dev->gpio_ifx_vbus, 0);
			}
		}
		else {
			muic_init_max14526(client, DEFAULT);
			gpio_set_value(dev->gpio_ifx_vbus, 0);
		}
#else
		muic_init_max14526(client, RESET);
		gpio_set_value(IFX_USB_VBUS_EN_GPIO, 0);
		//charging_ic_deactive();
		dev_info(&client->dev, "muic: charging_ic_deactive()\n");
#endif
	}

// LGE_CHANGES_S [[email protected]] 2012-03-19
#if defined(CONFIG_MAX8971_CHARGER)
	        if(muic_mode == MUIC_NA_TA || muic_mode == MUIC_LG_TA || muic_mode == MUIC_TA_1A)
		{
		        printk("[MUIC] max8971_start_charging TA\n");
		        max8971_start_charging(900);
									         }
		else if(muic_mode == MUIC_AP_USB)
		{
		        printk("[MUIC]max8971_start_charging USB\n");
		        max8971_start_charging(500);
										        }
		/* else if( muic_mode == MUIC_CP_USB || muic_mode ==  MUIC_CP_UART)
		{
		        printk("[MUIC] max8971_start_charging Factory\n");
		        max8971_start_charging(1550);
		}
		  */
		else if( muic_mode == MUIC_CP_USB )
		{
		 //printk("[MUIC] max8971_stop due to MUIC_CP_USB mode \n");
		        printk("[MUIC] max8971_start_charging Factory MUIC_CP_USB \n");
		        // max8971_start_charging(1550);
		        // max8971_stop_charging();
		        max8971_start_Factory_charging();
		}
		else if(  muic_mode ==  MUIC_CP_UART)
		{
		         printk("[MUIC] max8971_start_charging Factory MUIC_CP_UART \n");
	                //printk("[MUIC] max8971_stop due to MUIC_CP_UART mode \n");
	                // max8971_stop_charging();
	                // max8971_start_charging(1550);
	                 max8971_start_Factory_charging();
	        }
	        else if( muic_mode == MUIC_MHL)
	        {
	                printk("[MUIC] max8971_start_charging MHL\n");
	                max8971_start_charging(400);
	        }
	        else if( muic_mode == MUIC_NONE)
	        {
	                printk("[MUIC] max8971_stop_charging\n");
	                max8971_stop_charging();
		}
		else
		       printk("[MUIC] can not open muic mode\n");
		// LGE_CHANGES_E [[email protected]] 2012-03-19
#endif
	return ret;
}