Beispiel #1
1
static void type_det_work(struct work_struct *work)
{
	DBG("[JIWON] type_det_work start\n");

	if(headset_status == 1)
	{
	    if(gpio_get_value(headset_sw_data->hook_gpio) == 0) 
	    {
			headset_type = HUB_HEADPHONE;
			//DBG("[JIWON] type_det_work : HUB_HEADPHONE\n");
		}
		else
		{
			headset_type = HUB_HEADSET;
			//DBG("[JIWON] type_det_work : HUB_HEADSET\n");		
		}
	}
	else
	{
		headset_type = HUB_NONE;
#if defined(CONFIG_PRODUCT_LGE_KU5900)||defined(CONFIG_PRODUCT_LGE_P970) || defined(CONFIG_PRODUCT_LGE_LU6800) // 20100814 [email protected], dmb ant detect [START_LGE]		
	//nothing
#elif defined(CONFIG_PRODUCT_LGE_HUB) // [email protected] : Mach_Hub use external ant for dmb
		headset_sw_data->dmb_ant_detected = 0;
		set_dmb_status(headset_sw_data->dmb_ant_detected);	//[email protected]		
#endif		
	}


#if defined(CONFIG_PRODUCT_LGE_KU5900) ||defined(CONFIG_PRODUCT_LGE_P970)|| defined(CONFIG_PRODUCT_LGE_LU6800) 	// 20100814 [email protected], dmb ant detect [START_LGE]
	//nothing
#elif defined(CONFIG_PRODUCT_LGE_HUB) // [email protected] : Mach_Hub use external ant for dmb
//	msleep(100);
    if(system_rev > 3 && gpio_get_value(headset_sw_data->dmb_ant_gpio) == 1) 
    {
		DBG("[LUCKYJUN77] type_det_work : dmb_ant detected\n");
		headset_type = HUB_NONE;
		headset_sw_data->dmb_ant_detected = 1;
		set_dmb_status(headset_sw_data->dmb_ant_detected);	//[email protected]		
//		switch_set_state(&headset_sw_data->sdev, headset_type);		
//		return;
	}
#endif	// 20100814 [email protected], dmb ant detect [START_LGE]

#if defined(CONFIG_PRODUCT_LGE_KU5900) ||defined(CONFIG_PRODUCT_LGE_P970)|| defined(CONFIG_PRODUCT_LGE_LU6800) // 20100814 [email protected], dmb ant detect [START_LGE]
		if(headset_type == HUB_NONE)
		{
	#ifdef USE_LDOBIAS			
			gpio_direction_output(MIC_BIAS_LDO, 0);
			gpio_set_value(MIC_BIAS_LDO, 0);
	#else
			hub_headsetdet_bias(0);
	#endif
		}
#else
	if(system_rev <= 3)	//revB case
	{
    if(headset_type == HUB_NONE)
		hub_headsetdet_bias(0);
	}
	else 
	{
		if(headset_type == HUB_NONE && headset_sw_data->dmb_ant_detected == 0)
		{
			hub_headsetdet_bias(0);
		}
	}
#endif	// 20100814 [email protected], dmb ant detect [START_LGE]
	
 /* 20110215 [email protected] for EarJack & Hook Action [START] */
   if(headset_type == 1) 
   	{	   
    	IsHeadsetInserted=1;
    	DBG("[JIWON] type_det_work : IsHeadsetInserted=1\n");
   	}
   else
   	{
    	IsHeadsetInserted=0;
	    DBG("[JIWON] type_det_work : IsHeadsetInserted=0\n");
   	}
 /* 20110215 [email protected] for EarJack & Hook Action [END] */
  
	switch_set_state(&headset_sw_data->sdev, headset_type);

// 20100608 [email protected], headset event inform for hdmi [START_LGE]
#if defined(CONFIG_PRODUCT_LGE_LU6800)
	if(is_hdmi_enabled() == 1)
	{
		if(headset_type == HUB_NONE)
			Hdmi_setAudioMute(0);
		else
			Hdmi_setAudioMute(1);
	}
#endif
// 20100608 [email protected], headset event inform for hdmi [END_LGE]
	// 20110425 [email protected] detect headset during sleep [START]
	set_wakelock(0);	
	// 20110425 [email protected] detect headset during sleep [END]

}
/*****************************************************************
* function:    dbg_cfg_write
* description:
*  recieve the configuer of the user.
******************************************************************/
static ssize_t dbg_cfg_write(struct file *filp, const char __user *buffer,
	size_t count, loff_t *ppos)
{
	int index = 0;

	memset(g_ctemp, 0, MX_BUF_LEN);

	if (copy_from_user(g_ctemp, buffer, count)) {
		pr_info("error!\n");
		return -EFAULT;
	}

	if (sscanf(g_ctemp, "%d", &index))
		g_usavedcfg = index;
	else
		pr_info("ERRR~\n");

	pr_info("%s %d, g_usavedcfg=%x\n", __func__, __LINE__, g_usavedcfg);

	/*suspend print enable*/
	if (DEBG_SUSPEND_PRINTK & g_usavedcfg)
		console_suspend_enabled = 0;
	else
		console_suspend_enabled = 1;

	if (DEBG_SUSPEND_WAKELOCK & g_usavedcfg)
		set_wakelock(1);
	else
		set_wakelock(0);

	*ppos += count;

	return count;
}
Beispiel #3
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_local(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 */
	//usif_switch_ctrl(USIF_AP);
	/* Connect CP USB to MUIC UART */
	//dp3t_switch_ctrl(DP3T_CP_USB);		// [email protected]

	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_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 UART_TX, UART_RX*/
	ret = muic_i2c_write_byte_local(SW_CONTROL, DP_UART | DM_UART);

	/* Turn on charger IC with FACTORY mode */
	charging_ic_set_factory_mode();

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

	/* wake lock for the factory mode */
	set_wakelock(1);

	return ret;
}
Beispiel #4
0
static irqreturn_t headset_int_handler(int irq, void *dev_id)
{
	struct headset_switch_data *switch_data =
	    (struct headset_switch_data *)dev_id;

	IsHeadsetInserted=0; /* 20110215 [email protected] for EarJack & Hook Action */
	DBG("[JIWON] headset_int_handler: IsHeadsetInserted = 0 \n");
	// 20110425 [email protected] detect headset during sleep [START]	
	set_wakelock(1);
	// 20110425 [email protected] detect headset during sleep [END]

	schedule_work(&switch_data->work);
	return IRQ_HANDLED;
}
Beispiel #5
0
static irqreturn_t muic_interrupt_handler(s32 irq, void *data){

	printk(KERN_WARNING "[MUIC] muic_interrupt_handler(): muic_mode = %s\n",
		name_muic_mode[(s32)muic_mode]);

	set_wakelock(1);

	if (muic_device == TS5USBA33402)
		schedule_delayed_work(&muic_wq, msecs_to_jiffies(70));
	else
		schedule_delayed_work(&muic_wq, msecs_to_jiffies(250));//HZ / 10);

	return IRQ_HANDLED;
}
Beispiel #6
0
void usif_switch_ctrl(TYPE_USIF_MODE mode){

/* 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 ;
	}	
    /* 20110113 [email protected] check muic driver init. state [END] */
/* LGE_CHANGE_END 2011-03-16 [email protected] */    	

    /* gpio output mode setting */
    gpio_direction_output(USIF_IN_1_GPIO, 0);

    /* gpio data setting */
	if(mode == USIF_AP){
		gpio_set_value(USIF_IN_1_GPIO, 0);
// START [email protected] 2011/04/16 LAB1_FW : JUSTIN_FOTA_FIX {
		printk(KERN_WARNING "[MUIC] usif_switch_ctrl( USIF_AP )\n");
		dp3t_switch_ctrl(DP3T_NC);
		set_wakelock(1);
		fota_ing = 1;
// END [email protected] 2011/04/16 LAB1_FW }
	}
// START [email protected] 2011/04/16 LAB1_FW : JUSTIN_FOTA_FIX {
	else if( fota_ing )
	{
		// do nothing.
		printk(KERN_WARNING "[MUIC] usif_switch_ctrl : do nothing!\n");
	}
// END [email protected] 2011/04/16 LAB1_FW }

	else if(mode == USIF_DP3T){
// START [email protected] 2011/04/16 LAB1_FW : JUSTIN_FOTA_FIX {
		printk(KERN_WARNING "[MUIC] usif_switch_ctrl( USIF_DP3T )\n");
		if( !fota_ing )
		{
			printk(KERN_WARNING "[MUIC] usif_switch_ctrl() : fota_ing != 1\n");
// END [email protected] 2011/04/16 LAB1_FW }
			gpio_set_value(USIF_IN_1_GPIO, 1);
		}
	}
	else{
		/* Just keep the current path */
	}
	usif_mode = mode;
}
/*****************************************************************
* function:    lowpm_test_probe
* description:
*  driver interface.
******************************************************************/
static int lowpm_test_probe(struct platform_device *pdev)
{
	int status = 0;
	struct dentry *pdentry;

	pr_info("[%s] %d enter.\n", __func__, __LINE__);

	g_suspended = 0;

	/*default timer0 wakeup time 500ms*/
	g_utimer_inms = 200;

	/*default rtc wakeup time in 1s*/
	g_urtc_ins = 1;

	map_sysregs();

	wake_lock_init(&lowpm_wake_lock, WAKE_LOCK_SUSPEND, "lowpm_test");

#ifndef CONFIG_HISI_SR_DEBUG_SLEEP
	set_wakelock(1);
#endif

	pdentry = debugfs_create_dir("lowpm_test", NULL);
	if (!pdentry) {
		pr_info("%s %d error can not create debugfs lowpm_test.\n", __func__, __LINE__);
		return -ENOMEM;
	}

	(void) debugfs_create_file("clk", S_IRUSR, pdentry, NULL, &debug_clk_fops);

	(void) debugfs_create_file("pmu", S_IRUSR, pdentry, NULL, &debug_pmu_fops);

	(void) debugfs_create_file("io", S_IRUSR, pdentry, NULL, &dbg_iomux_fops);

	(void) debugfs_create_file("cfg", S_IRUSR, pdentry, NULL, &dbg_cfg_fops);

	(void) debugfs_create_file("timer", S_IRUSR, pdentry, NULL, &dbg_timer_fops);

	(void) debugfs_create_file("rtc", S_IRUSR, pdentry, NULL, &dbg_rtc_fops);

	(void) debugfs_create_file("debug_sr", S_IRUSR, pdentry, NULL, &dbg_pm_status_fops);

	pr_info("[%s] %d leave.\n", __func__, __LINE__);

	return status;
}
Beispiel #8
0
/* Initialize MUIC, i.e., the CONTROL_1,2 and SW_CONTROL registers.
 * 1) Prepare to sense INT_STAT and STATUS bits.
 * 2) Open MUIC paths. -> To keep the path from uboot setting, remove this stage.
 */
void muic_initialize(TYPE_RESET reset){

	s32 ret;

	printk(KERN_WARNING "[MUIC] muic_initialize()\n");

	if (reset) {
		if (muic_i2c_read_byte_local(DEVICE_ID, &muic_device) < 0) {
			printk(KERN_ERR "[MUIC] Device detection falied! Set default device.\n");
			muic_device = TS5USBA33402;
		}
		muic_device &= 0xf0;
		printk(KERN_INFO "[MUIC] Device : %s\n", (muic_device == MAX14526) ? "MAX14526" : "TSUSBA33402");
	}
	else {
		// Clear Default Switch Position (0x03=0x24)
		ret = muic_i2c_write_byte_local(SW_CONTROL, DP_OPEN | DM_OPEN);
	}

	if (muic_device == MAX14526) {
//		ret = muic_i2c_write_byte_local(CONTROL_1, MID_200 | MADC_EN);
//		ret = muic_i2c_write_byte_local(CONTROL_2, MINT_EN);
	}
	else {
		/* Reset MUIC - Disable all */
		if(reset){
			ret = muic_i2c_write_byte_local(CONTROL_1, 0x00);
			ret = muic_i2c_write_byte_local(CONTROL_2, MUSB_DET_DIS);// USB_DET_DIS is neg enabled
		}

		ret = muic_i2c_write_byte_local(CONTROL_1, MID_200 | MSEMREN);
		ret = muic_i2c_write_byte_local(CONTROL_2, MCHG_TYP);

		if(reset)
			msleep(250);
		else
			msleep(70);

		/* Enable interrupt (INT_EN = 1). Keep other bits the same */
		ret = muic_i2c_write_byte_local(CONTROL_2, MINT_EN | MCHG_TYP);
	}

	/* Default setting : CP_UART to DP3T Switch. */
	//usif_switch_ctrl(USIF_DP3T);		// [email protected]

	set_wakelock(0);
}
Beispiel #9
0
s32 muic_AP_UART_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);
	/* Connect AP UART to MUIC UART */

	// [email protected] ICS temp
	//gpio_direction_output(GPIO_IFX_USB_VBUS_EN, 1); // IFX_VBUS_EN --> GPIO_IFX_USB_VBUS_EN
	//gpio_direction_output(GPIO_DP3T_IN_1, 1);	// DP3T_IN_1_GPIO--> GPIO_DP3T_IN_1
	//gpio_direction_output(GPIO_DP3T_IN_2, 1); // DP3T_IN_2_GPIO --> GPIO_DP3T_IN_2
	
	
	//dp3t_switch_ctrl(DP3T_AP_UART);		// [email protected]

	if (muic_device == MAX14526) {
		/* ID_200, VLDO 2.6V, ADC Enable, Charge Pump.*/
		ret = muic_i2c_write_byte_local(CONTROL_1, MID_200 | MADC_EN | MCP_EN);
	}
	else {
		/* ID_200, VLDO 2.6V, SEMREN on. ADC is auto.*/
		ret = muic_i2c_write_byte_local(CONTROL_1, MID_200 | MSEMREN);
	}
	/* Connect DP, DM to UART_TX, UART_RX*/
	ret = muic_i2c_write_byte_local(SW_CONTROL, DP_UART | DM_UART);

	/* Turn on charger IC with FACTORY mode */
	charging_ic_set_factory_mode();

	muic_mode = MUIC_AP_UART;
	printk(KERN_WARNING "[MUIC] muic_distinguish_vbus_accessory(): AP_UART\n");

	set_wakelock(0);

	return ret;
}
Beispiel #10
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;
}
Beispiel #11
0
s32 muic_CP_UART_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 DP3T */
	usif_switch_ctrl(USIF_DP3T);
	/* Connect CP UART to MUIC UART */
	dp3t_switch_ctrl(DP3T_CP_UART);

	if (muic_device == MAX14526) {
		/* ID_200, VLDO 2.6V, ADC is auto, Charge Pump.*/
		ret = muic_i2c_write_byte(CONTROL_1, MID_200 | MADC_EN | MCP_EN);
	}
	else {
		/* ID_200, VLDO 2.6V, SEMREN on. ADC is auto.*/
		ret = muic_i2c_write_byte(CONTROL_1, MID_200 | MSEMREN);
	}

	/* Connect DP, DM to UART_TX, UART_RX*/
	ret = muic_i2c_write_byte(SW_CONTROL, DP_UART | DM_UART);

	/* Turn on charger IC with FACTORY mode */
	charging_ic_set_factory_mode();

	muic_mode = MUIC_CP_UART;
	printk(KERN_WARNING "[MUIC] muic_distinguish_vbus_accessory(): CP_UART\n");

	/* wake lock for the factory mode */
/* LGE_CHANG_START 2011-03-30 [email protected] wakelock on when AT command sequence by CP UART */
	set_wakelock(1);
/* LGE_CHANGE_END 2011-03-30 [email protected] */

	return ret;
}
Beispiel #12
0
static irqreturn_t muic_interrupt_handler(s32 irq, void *data){

	printk(KERN_WARNING "[MUIC] muic_interrupt_handler(): muic_mode = %s\n",
		name_muic_mode[(s32)muic_mode]);

printk("[MUIC] muic_interrupt_handler(): muic_mode = %s\n",
        name_muic_mode[(s32)muic_mode]);


	set_wakelock(1);
//[START] [email protected] , 120727, When TA cable connected. not appear slow-charging Icon.
    cancel_delayed_work(&muic_wq);
//[END] [email protected] , 120727, When TA cable connected. not appear slow-charging Icon.
	if (muic_device == TS5USBA33402)
		schedule_delayed_work(&muic_wq, msecs_to_jiffies(70));
	else
		schedule_delayed_work(&muic_wq, msecs_to_jiffies(250));//HZ / 10);

	return IRQ_HANDLED;
}
Beispiel #13
0
/* B-Prj Power off charging [[email protected]] 2010-12-15 */
ssize_t muic_store_wake_lock(struct device *dev,
			  struct device_attribute *attr,
			  const char *buf,
			  size_t count)
{
	int value = 0;

    	printk(KERN_INFO "[MUIC] muic_store_wake_lock \n");

	if (!count) {
		return -EINVAL;
	}

	value = simple_strtoul(buf, NULL, 10);
    	if (value >2 )
		return -EINVAL;

	printk(KERN_INFO "[MUIC]wake_lock=%d\n",value);
	set_wakelock(value);
	return count;
}
Beispiel #14
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;
}
Beispiel #15
0
static int headsetdet_probe(struct platform_device *pdev)
{
	struct gpio_switch_platform_data *pdata = pdev->dev.platform_data;
	struct headset_switch_data *switch_data;
	int ret = 0;
	struct input_dev *ip_dev;  

	if (!pdata)
		return -EBUSY;
	switch_data = kzalloc(sizeof(struct headset_switch_data), GFP_KERNEL);
	if (!switch_data)
		return -ENOMEM;

	// 20110425 [email protected] detect headset during sleep [START]
	/* wake lock for headset detection */
	wake_lock_init(&headset_wlock.wake_lock, WAKE_LOCK_SUSPEND, "headset_det");
	set_wakelock(0);		
	// 20110425 [email protected] detect headset during sleep [END]

	switch_data->sdev.name = pdata->name;
	switch_data->gpio = pdata->gpio;
	switch_data->name_on = pdata->name_on;
	switch_data->name_off = pdata->name_off;
	switch_data->state_on = pdata->state_on;
	switch_data->state_off = pdata->state_off;
	switch_data->sdev.print_state = switch_gpio_print_state;

         switch_data->hook_gpio = HOOK_ADC_GPIO;
    
#if defined(CONFIG_PRODUCT_LGE_KU5900)||defined(CONFIG_PRODUCT_LGE_P970) || defined(CONFIG_PRODUCT_LGE_LU6800)	// 20100814 [email protected], dmb ant detect [START_LGE]
	//nothing
#elif defined(CONFIG_PRODUCT_LGE_HUB) // [email protected] : Mach_Hub use external ant for dmb
	switch_data->dmb_ant_gpio = 164;
	switch_data->dmb_ant_detected = 0;
#endif	// 20100814 [email protected], dmb ant detect [END_LGE]

    ret = switch_dev_register(&switch_data->sdev);
	if (ret < 0)
		goto err_switch_dev_register;

	omap_mux_init_gpio(switch_data->gpio, OMAP_PIN_INPUT_PULLDOWN | OMAP_PIN_OFF_WAKEUPENABLE);	//20101004 [email protected], ear sense wakable setting

#if 1	//20101109 [email protected], hook key wakable setting
	omap_mux_init_gpio(switch_data->hook_gpio, OMAP_PIN_INPUT_PULLUP | OMAP_PIN_OFF_WAKEUPENABLE);	
#endif

	ret = gpio_request(switch_data->gpio, pdev->name);

	ret = gpio_request(switch_data->hook_gpio, pdev->name);

#if defined(CONFIG_PRODUCT_LGE_KU5900)||defined(CONFIG_PRODUCT_LGE_P970) || defined(CONFIG_PRODUCT_LGE_LU6800) // 20100814 [email protected], dmb ant detect [START_LGE]
	//nothing
#else
	ret = gpio_request(switch_data->dmb_ant_gpio, pdev->name);
#endif	// 20100814 [email protected], dmb ant detect [END_LGE]

	if (ret < 0)
		goto err_request_gpio;

	ret = gpio_direction_input(switch_data->gpio);

	ret = gpio_direction_input(switch_data->hook_gpio);

#if defined(CONFIG_PRODUCT_LGE_KU5900)||defined(CONFIG_PRODUCT_LGE_P970) || defined(CONFIG_PRODUCT_LGE_HUB)// 20100814 [email protected], dmb ant detect [START_LGE]
	//nothing
#else
//--[[ LGE_UBIQUIX_MODIFIED_START : [email protected] [2011.08.11] - GPIO direction input error fixed.
	ret = gpio_request(switch_data->dmb_ant_gpio, pdev->name);
	if (ret < 0)
		goto err_request_gpio;
//--]] LGE_UBIQUIX_MODIFIED_END : [email protected] [2011.08.11]- GPIO direction input error fixed.

	ret = gpio_direction_input(switch_data->dmb_ant_gpio);
#endif	// 20100814 [email protected], dmb ant detect [END_LGE]

	if (ret < 0)
		goto err_set_gpio_input;

    ip_dev = input_allocate_device();
    
	switch_data->ip_dev = ip_dev;

	switch_data->ip_dev->name = "Hookkey";	//20100830, [email protected], define the input dev name
	
	set_bit(EV_SYN, switch_data->ip_dev->evbit);
	set_bit(EV_KEY, switch_data->ip_dev->evbit);
	set_bit(KEY_HOOK, switch_data->ip_dev->keybit); 	//for short pressed hook key
		
	ret = input_register_device(switch_data->ip_dev);
	    
	INIT_WORK(&switch_data->work, headset_det_work);
    INIT_DELAYED_WORK(&switch_data->delayed_work, type_det_work);
	INIT_DELAYED_WORK(&switch_data->hook_delayed_work, hook_det_work);

	switch_data->irq = gpio_to_irq(switch_data->gpio);
	switch_data->hook_irq = gpio_to_irq(switch_data->hook_gpio);
// 20100814 [email protected], dmb ant detect [START_LGE]	
#if defined(CONFIG_PRODUCT_LGE_KU5900) ||defined(CONFIG_PRODUCT_LGE_P970)
	//nothing
#else
	switch_data->dmb_ant_irq = gpio_to_irq(switch_data->dmb_ant_gpio);	// 20100814 [email protected], dmb ant gpio [START_LGE]
#endif	
// 20100814 [email protected], dmb ant detect [END_LGE]
	
	if (switch_data->irq < 0) {
		ret = switch_data->irq;
		goto err_detect_irq_num_failed;
	}

#if 1		//20101004 [email protected], ear sense wakable setting
	/* Make the interrupt on wake up OMAP which is in suspend mode */		
	ret = enable_irq_wake(switch_data->irq);		
	if(ret < 0){
		DBG(KERN_INFO "[LUCKYJUN77] EAR SENSE 170 wake up source setting failed!\n");
		disable_irq_wake(switch_data->irq);
		return -ENOSYS;
	}
#endif			

#if 1		//20101109 [email protected], hook key wakable setting
	/* Make the interrupt on wake up OMAP which is in suspend mode */		
	ret = enable_irq_wake(switch_data->hook_irq);		
	if(ret < 0){
		DBG(KERN_INFO "[LUCKYJUN77] Hook key 163 wake up source setting failed!\n");
		disable_irq_wake(switch_data->hook_irq);
		return -ENOSYS;
	}
#endif			



	ret = request_irq(switch_data->irq, headset_int_handler,
			  IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, pdev->name, switch_data);
	if (ret < 0)
		goto err_request_irq;

    ret = request_irq(switch_data->hook_irq, headset_hook_int_handler,
			  IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, "headset_hook", switch_data);
	if (ret < 0)
		goto err_request_irq;
			  
// 20100825 [email protected], mic bias LDO control test [START_LGE]
#if 1
	omap_mux_init_gpio(MIC_BIAS_LDO, OMAP_PIN_OUTPUT);
	ret = gpio_request(MIC_BIAS_LDO,  pdev->name);
	if(ret < 0) {	
		DBG("can't get hub Mic bias LDO enable GPIO\n");
		goto err_request_gpio;
	}
#endif
// 20100825 [email protected], mic bias LDO control test [END_LGE]

// 20100814 [email protected], dmb ant detect [START_LGE]
#if defined(CONFIG_PRODUCT_LGE_KU5900) || defined(CONFIG_PRODUCT_LGE_LU6800)||defined(CONFIG_PRODUCT_LGE_P970)
	//nothing
#else
    ret = request_irq(switch_data->dmb_ant_irq, dmb_ant_int_handler,
			  IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, "dmb_ant", switch_data);
#endif
// 20100814 [email protected], dmb ant detect [END_LGE]

	/* Perform initial detection */
	headset_sw_data = switch_data;

	headset_sw_data->is_suspend = 0;	//resume
	
	headset_det_work(&switch_data->work);

// 20100603 [email protected], headset suspend/resume [START_LGE]
#ifdef CONFIG_HAS_EARLYSUSPEND
	switch_data->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 2;
	switch_data->early_suspend.suspend = headsetdet_early_suspend;
	switch_data->early_suspend.resume = headsetdet_late_resume;
	register_early_suspend(&switch_data->early_suspend);
#endif
// 20100603 [email protected], headset suspend/resume [END_LGE]	

	return 0;

err_request_irq:
err_detect_irq_num_failed:
err_set_gpio_input:
	gpio_free(switch_data->gpio);
err_request_gpio:
    switch_dev_unregister(&switch_data->sdev);
err_switch_dev_register:
	kfree(switch_data);

	return ret;
}
Beispiel #16
0
/* LGE_UPDATE_S [[email protected]] 2010-12-01, modify detection scheme */
static void muic_device_none_detect(void)
{
	u8 reg_value;
	u8 status_value;
	s32 ret;
	
	if ((key_col == 3) && (key_row == 0)) // Volume up
		key_was_pressed = 1;
	else if ((key_col == 3) && (key_row == 1)) // Volume down
		key_was_pressed = 2;

	printk(KERN_WARNING "[MUIC] Device_None_Detect int_stat_val = 0x%x\n",int_stat_val);

/* LGE_CHANGE_S [[email protected]] 2010-12-14, CP retain mode */
#ifdef CP_RETAIN	
	if (is_cp_retained)
	{
		//muic_CP_USB_set();
		muic_set_mode(MUIC_CP_USB);
	}
	// IDNO=0100? 130Kohm :: CP UART MODE
	else if(((int_stat_val & MIDNO) == 0x04)
			|| (hidden_menu_switching == 7)) {
/* LGE_CHANGE_E [[email protected]] 2011-01-06, CP retain mode */
#elif defined(USB_RETAIN) /* 2012.05.15, [email protected], USB retain mode. */
	ret = muic_i2c_read_byte_local(INT_STAT, &status_value);
	if(ret < 0)
		printk("[MUIC] [%s-%d] muic_i2c_read_byte_local Fail [ret = %d]\n", __func__, __LINE__, ret);
	else
		printk("[MUIC] [%s-%d] INT_STAT Value is 0x%x / MVBUS bit is %d\n", __func__, __LINE__, 
																	status_value, ((status_value & MVBUS) >> 4));
	if (usb_retained == CP_RETAINED)
	{
		//muic_CP_USB_set();
		if((status_value & MVBUS)) {
			printk("[MUIC] [%s-%d] muic_set_mode(MUIC_CP_USB)\n", __func__, __LINE__);
			muic_set_mode(MUIC_CP_USB);
		}
	}
	else if (usb_retained == AP_RETAINED)
	{
		//muic_AP_USB_set();
		if((status_value & MVBUS)) {
			printk("[MUIC] [%s-%d] muic_set_mode(MUIC_AP_USB)\n", __func__, __LINE__);
            muic_set_mode(MUIC_AP_USB);
		}
	}
    // IDNO=0100? 130Kohm :: CP UART MODE
    else if(((int_stat_val & MIDNO) == 0x04)
            || (hidden_menu_switching == 7)) {

#else		
	if(((int_stat_val & MIDNO) == 0x04)
			|| (hidden_menu_switching == 7)) {
#endif	
		//muic_CP_UART_set();
		muic_set_mode(MUIC_CP_UART);	// [email protected]
	}
	// IDNO=0010? 56Kohm  :: CP USB MODE
	else if (((int_stat_val & MIDNO ) == 0x02) || (hidden_menu_switching == 9)){
		if (key_was_pressed == 2)
			//muic_AP_UART_set();
			muic_set_mode(MUIC_AP_UART);	// [email protected]
		else
			//muic_CP_USB_set();
			muic_set_mode(MUIC_CP_USB);	// [email protected]
	}
	// LGE_UPDATE_S [[email protected]] 2010-12-12, for 910K factory download
	// IDNO=1010? 910Kohm :: CP USB MODE
#ifdef 	CABLE_DETECT_910K	
	else if ((int_stat_val & MIDNO ) == 0x0a) {
		//muic_CP_USB_set();
		muic_set_mode(MUIC_CP_USB);	// [email protected]
	}
	else if ((int_stat_val & MIDNO ) == 0x09) {
		//muic_CP_USB_set();
		muic_set_mode(MUIC_CP_USB);	// [email protected]
	}
#endif
#if 0
	// CHGDET=1?  :: HIGH CURRENT USB or TA?
	else if (int_stat_val & MCHGDET) {
		muic_distinguish_charger();
	}
#endif
	// VBUS=1?  :: TA or AP USB?
	else if (int_stat_val & MVBUS) {
		if (muic_device == MAX14526) {
			// COMP2 to H-Z / COMN1 to C1COMP (0x03=0x23)
			muic_i2c_write_byte_local(SW_CONTROL, 0x23);

			msleep(3);

			// Read STATUS_REG (0x05)
			muic_i2c_read_byte_local(STATUS, &reg_value);

			if (reg_value & 0x01 ) {
				// Dedicated Charger(TA) Detected
				// COMP2 to H-Z / COMN1 to H-Z (0x03=0x24)
				muic_i2c_write_byte_local(SW_CONTROL, DP_OPEN | DM_OPEN);

				charging_ic_set_ta_mode();

				muic_mode = MUIC_NA_TA;
				muic_set_mode(MUIC_NA_TA);		// [email protected] 20120502 MUIC re-work
				printk(KERN_WARNING "[MUIC] Charger detected\n");
			}
			else if (reg_value & 0x80 ) {
				// Dedicated Charger(TA) Detected
				muic_i2c_write_byte_local(SW_CONTROL, DP_OPEN | DM_OPEN);

				charging_ic_set_ta_mode();

				muic_mode = MUIC_NA_TA;
				muic_set_mode(MUIC_NA_TA);
				printk(KERN_WARNING "[MUIC] NA_TA Charger detected\n");
			}
			else if (reg_value & 0x40 ) {
				// Dedicated Charger(TA) Detected
				muic_i2c_write_byte_local(SW_CONTROL, DP_OPEN | DM_OPEN);

				charging_ic_set_ta_mode();

				muic_mode = MUIC_LG_TA;
				muic_set_mode(MUIC_LG_TA);
				printk(KERN_WARNING "[MUIC] LG_TA Charger detected\n");
			}
			else {	// USB Detected
// LGE_UPDATE_S 20110521 [[email protected]] block CP usb for commercial version
#if 0
				if (key_was_pressed == 2)
					//muic_CP_USB_set();
					muic_set_mode(MUIC_CP_USB);	// [email protected]
				else
#endif /* #if 0 */
// LGE_UPDATE_S 20110521 [[email protected]] block CP usb for commercial version
					//muic_AP_USB_set();
					muic_set_mode(MUIC_AP_USB);	// [email protected]
			}
		}
		else { 	// USB Detected
// LGE_UPDATE_S 20110521 [[email protected]] block CP usb for commercial version
#if 0
			if (key_was_pressed == 2)
				//muic_CP_USB_set();
				muic_set_mode(MUIC_CP_USB);	// [email protected]	
			else
#endif /* #if 0 */
// LGE_UPDATE_S 20110521 [[email protected]] block CP usb for commercial version
				//muic_AP_USB_set();
				muic_set_mode(MUIC_AP_USB);	// [email protected]
		}
	}
	else {
		// Accessory Not Supported
		muic_mode = MUIC_NONE;
	}

	key_was_pressed = 0;
}

s32 muic_device_detection(s32 upon_irq)
{
/* 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] */
	// Read INT_STAT_REG (0x04)
	muic_i2c_read_byte_local(INT_STAT, &int_stat_val);
	printk(KERN_INFO "[MUIC] INT_STAT = %x\n", int_stat_val);

	switch (muic_mode)
	{
	case MUIC_NONE:
	case MUIC_UNKNOWN:
		muic_device_none_detect();
		break;

	// CP UART Mode
	case MUIC_CP_UART:
	case MUIC_AP_UART:
		if ((int_stat_val & MIDNO) == 0x0b) {
			muic_mode = MUIC_NONE;
		}
		else {
			muic_device_none_detect();
		}
		break;

	// TA Mode
	case MUIC_NA_TA:
	case MUIC_LG_TA:
	case MUIC_TA_1A:
	case MUIC_INVALID_CHG:
		if ((int_stat_val & MVBUS) == 0) {
			// Exit Charger Mode
			muic_mode = MUIC_NONE;
		}
		else {
			// Bug fix: charger detect interrupt 2 times
			set_wakelock(0);
		}
		break;

	// USB Mode
	case MUIC_AP_USB:
			android_USB_disconnect(); // for usb disconnect event
	case MUIC_CP_USB:
		if ((int_stat_val & MVBUS) == 0){
			// Exit USB Mode
			muic_mode = MUIC_NONE;
		}
		else {
			muic_device_none_detect();
		}
		break;

	default:
		muic_mode = MUIC_NONE;
		break;
	}

	if (muic_mode == MUIC_NONE) {
		muic_initialize(DEFAULT);
		printk(KERN_INFO "[MUIC] muic none\n");
		charging_ic_deactive();
		printk(KERN_INFO "[MUIC] charging_ic_deactive()\n");
		muic_set_mode(MUIC_NONE);		// [email protected] 20120502 MUIC re-work
	}

	charger_state_update_by_other();

	return 0;
}
EXPORT_SYMBOL(muic_device_detection);
/* LGE_UPDATE_E [[email protected]] 2010-12-01, modify detection scheme */

static void muic_wq_func(struct work_struct *muic_wq){
	s32 ret = 0;
	printk(KERN_INFO "[MUIC] muic_wq_func()\n");
	ret = muic_device_detection(UPON_IRQ);
}
Beispiel #17
0
/* Distinguish charger type.
 * This function is called *ONLY IF* INT_STAT's CHGDET == 1, i.e., a charger is detected.
 *
 * Chargers becomes to use the default MUIC setting
 * because the detection always happens only after the MUIC_NONE mode
 * which leads the default MUIC setting.
 * Thus, we don't need to explictly set MUIC registers here.
 */
s32 muic_distinguish_charger(void){

	s32 ret = 0;

	/* Enable charger IC in TA mode */
	charging_ic_set_ta_mode();

	/* Connect AP UART to MUIC UART */
	dp3t_switch_ctrl(DP3T_AP_UART);

	/* 
	 *	LGE_UPDATE 20110425 [[email protected]] change IDNO for detecting LG_TA
	 *
	 *	IDNO == 0x05(0101) 180 KOhm. LG TA : Standard usb cable
	 *	IDNO == 0x06(0110) 240 KOhm. LG TA : Docomo accessaary usb cable
	 *	IDNO == 0x0b(1011) OPEN. TA charger
	 *	There is no ADC value of MUIC table for 220KOhm
	 * 	so, we need to double check 180 KOhm and 220 KOhm
	 */
	if ((int_stat_val & MIDNO) == 0x05 || (int_stat_val & MIDNO) == 0x06 || (int_stat_val & MIDNO) == 0x0b) {
		muic_mode = MUIC_LG_TA;
		printk(KERN_WARNING "[MUIC] muic_distinguish_charger(): MUIC_LG_TA\n");
		set_wakelock(0);
		return ret;
	}

	if (muic_device == MAX14526) {
		/* Prepare for reading charger type */
		ret = muic_i2c_write_byte(CONTROL_2, MINT_EN | MCHG_TYP);
		/* LGE_UPDATE_S [[email protected]] 2010-12-01, interrupt clear in TA detection */
		msleep(70);
		ret = muic_i2c_read_byte(INT_STAT, &status_val);
		/* LGE_UPDATE_E [[email protected]] 2010-12-01, interrupt clear in TA detection */
	}

	/* Read STATUS */
	ret = muic_i2c_read_byte(STATUS, &status_val);
	if (ret < 0) {
		printk(KERN_INFO "[MUIC] STATUS reading failed\n");
		muic_mode = MUIC_UNKNOWN;
		key_was_pressed = 0; // from HUB 
		set_wakelock(0);
		return ret;
	}

	printk(KERN_INFO "[MUIC] STATUS = %x\n", status_val);

	/* DCPORT == 1. Dedicated Charger */
	if ((status_val & MDCPORT) != 0) {
		muic_mode = MUIC_NA_TA;
		printk(KERN_WARNING "[MUIC] muic_distinguish_charger(): MUIC_NA_TA\n");
	}
	/* CHPORT == 1. HCHH */
	else if ((status_val & MCHPORT) != 0) {
		muic_mode = MUIC_HCHH;
		printk(KERN_WARNING "[MUIC] muic_distinguish_charger(): MUIC_HCHH\n");
	}
	/* DCPORT == 0 && CHPORT == 0. Definitely INVALID_CHG */
	else {
		muic_mode = MUIC_INVALID_CHG;
		printk(KERN_WARNING "[MUIC] muic_distinguish_charger(): MUIC_INVALID_CHG\n");
	}

	set_wakelock(0);
	return ret;
}
Beispiel #18
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;
}
Beispiel #19
0
/* Initialize MUIC, i.e., the CONTROL_1,2 and SW_CONTROL registers.
 * 1) Prepare to sense INT_STAT and STATUS bits.
 * 2) Open MUIC paths. -> To keep the path from uboot setting, remove this stage.
 */
void muic_initialize(TYPE_RESET reset){

	s32 ret;

	printk(KERN_WARNING "[MUIC] muic_initialize()\n");

	if (reset) {
		ret = muic_i2c_write_byte(SW_CONTROL, DP_OPEN | DM_OPEN); // 20110915, [email protected], Debug USB recognition at reboot.

		if (muic_i2c_read_byte(DEVICE_ID, &muic_device) < 0) {
			printk(KERN_ERR "[MUIC] Device detection falied! Set default device.\n");
			muic_device = TS5USBA33402;
		}
		muic_device &= 0xf0;
		printk(KERN_INFO "[MUIC] Device : %s\n", (muic_device == MAX14526) ? "MAX14526" : "TSUSBA33402");
	}
	else {
		// Clear Default Switch Position (0x03=0x24)
		ret = muic_i2c_write_byte(SW_CONTROL, DP_OPEN | DM_OPEN);
	}

	if (muic_device == MAX14526) {
		ret = muic_i2c_write_byte(CONTROL_1, MID_200 | MADC_EN);
		ret = muic_i2c_write_byte(CONTROL_2, MINT_EN);
	}
	else {
		/* Reset MUIC - Disable all */
		if(reset){
			ret = muic_i2c_write_byte(CONTROL_1, 0x00);
			ret = muic_i2c_write_byte(CONTROL_2, MUSB_DET_DIS);// USB_DET_DIS is neg enabled
		}

		/* comments from the case of HUB
		* Initialize MUIC - Default setting.
		*
		* CONTROL_1:
		* 
		* 	ID_2P2 	= 0. Enable to distinguish MUIC_EARMIC from MUIC_TV_OUT_LOAD and MUIC_OTG.
		* 		     Enable for MUIC_EARMIC operation.
		*	ID_620 	= 0. Enable only to distinguish MUIC_TV_OUT_LOAD from MUIC_OTG.
		*	ID_200 	= 1.
		*	VLDO 	= 0. Enable to apply 2.3V for MUIC_EARMIC operation.
		*	SEMREN 	= 1.
		*	ADC_EN 	= 0. Because it is automatically enabled upon any change in ID resistor.
		*	CP_EN 	= 0. Enalbe for USB 2.0 (MUIC_AP_USB, MUIC_CP_USB, and MUIC_OTG).
		*		     Enable for Audio charge pump (MUIC_EARMIC, MUIC_TV_OUT_LOAD).
		* 
		* CONTROL_2: 
		*
		* 	INTPOL 	= 0.
		* 	INT_EN	= 1.
		* 	MIC_LP	= 0.
		* 	CP_AUD 	= 1. Disable for Audio operation (MUIC_EARMIC, MUIC_TV_OUT_LOAD).
		* 	CHG_TYP	= 1.
		* 	USB_DET_DIS = 0. Negative enabled.
		*
		* SW_CONTROL: 
		*
		* 	MIC_ON	= 0. Enable for MUIC_EARMIC and MUIC_TV_OUT_LOAD.
		* 	DP	= 111 (open).
		* 	DM	= 111 (open).
		*/
		ret = muic_i2c_write_byte(CONTROL_1, MID_200 | MSEMREN);
		ret = muic_i2c_write_byte(CONTROL_2, MCHG_TYP);

		/* comments from the case of HUB
		* The initialization time for the facility to set STATUS register's
		* DCPORT and CHPORT = 250msec since CHG_TYP on.
		* The initialization times for the facilities to set INT_STAT register bits
		* since CONTROL_1, 2 settings are much shorter (< 70msec).
		* The settle down time for INT_STAT and STATUS register bits
		* since an interrupt occurs = 70msec.
		* 
		* Thus,
		* we need to wait 250msec if we enable CHG_TYP from its inactive state.
		* And, we need to wait just 70msec for all other cases including
		* interrupt and CONTROL register settings.
		*/
		if(reset)
			msleep(250);
		else
			msleep(70);

		/* Enable interrupt (INT_EN = 1). Keep other bits the same */
		ret = muic_i2c_write_byte(CONTROL_2, MINT_EN | MCHG_TYP);
	}

	/* Default setting : CP_UART to DP3T Switch. */
	usif_switch_ctrl(USIF_DP3T);

	set_wakelock(0);
	return;
}
Beispiel #20
0
/* Distinguish charger type.
 * This function is called *ONLY IF* INT_STAT's CHGDET == 1, i.e., a charger is detected.
 *
 * Chargers becomes to use the default MUIC setting
 * because the detection always happens only after the MUIC_NONE mode
 * which leads the default MUIC setting.
 * Thus, we don't need to explictly set MUIC registers here.
 */
s32 muic_distinguish_charger(void){

	s32 ret = 0;

	/* Enable charger IC in TA mode */
	charging_ic_set_ta_mode();

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

	/* Connect AP UART to MUIC UART */
	//dp3t_switch_ctrl(DP3T_AP_UART);			// [email protected]

	/* IDNO == 0x05 180K. LG TA */
	if ((int_stat_val & MIDNO) == 0x05 || (int_stat_val & MIDNO) == 0x0b) {
		muic_mode = MUIC_LG_TA;
		muic_set_mode(MUIC_LG_TA);		// [email protected] 20120502 MUIC re-work
		printk(KERN_WARNING "[MUIC] muic_distinguish_charger(): MUIC_LG_TA\n");
		set_wakelock(0);
		return ret;
	}

	if (muic_device == MAX14526) {
		/* Prepare for reading charger type */
		ret = muic_i2c_write_byte_local(CONTROL_2, MINT_EN | MCHG_TYP);
		/* LGE_UPDATE_S [[email protected]] 2010-12-01, interrupt clear in TA detection */
		msleep(70);
		ret = muic_i2c_read_byte_local(INT_STAT, &status_val);
		/* LGE_UPDATE_E [[email protected]] 2010-12-01, interrupt clear in TA detection */
	}

	/* Read STATUS */
	ret = muic_i2c_read_byte_local(STATUS, &status_val);
	if (ret < 0) {
		printk(KERN_INFO "[MUIC] STATUS reading failed\n");
		muic_mode = MUIC_UNKNOWN;
		muic_set_mode(MUIC_UNKNOWN);		// [email protected] 20120502 MUIC re-work
		set_wakelock(0);
		return ret;
	}

	printk(KERN_INFO "[MUIC] STATUS = %x\n", status_val);

	/* DCPORT == 1. Dedicated Charger */
	if ((status_val & MDCPORT) != 0) {
		muic_mode = MUIC_NA_TA;
		muic_set_mode(MUIC_NA_TA);		// [email protected] 20120502 MUIC re-work
		printk(KERN_WARNING "[MUIC] muic_distinguish_charger(): MUIC_NA_TA\n");
	}
	/* CHPORT == 1. HCHH */
	else if ((status_val & MCHPORT) != 0) {
		muic_mode = MUIC_TA_1A;
		muic_set_mode(MUIC_TA_1A);		// [email protected] 20120502 MUIC re-work
		printk(KERN_WARNING "[MUIC] muic_distinguish_charger(): MUIC_TA_1A\n");
	}
	/* DCPORT == 0 && CHPORT == 0. Definitely INVALID_CHG */
	else {
		muic_mode = MUIC_INVALID_CHG;
		muic_set_mode(MUIC_INVALID_CHG);		// [email protected] 20120502 MUIC re-work
		printk(KERN_WARNING "[MUIC] muic_distinguish_charger(): MUIC_INVALID_CHG\n");
	}

	set_wakelock(0);
	return ret;
}
Beispiel #21
0
s32 muic_device_detection(s32 upon_irq)
{
/* 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] */
	// Read INT_STAT_REG (0x04)
	muic_i2c_read_byte(INT_STAT, &int_stat_val);
	printk(KERN_INFO "[MUIC] INT_STAT = %x\n", int_stat_val);

	switch (muic_mode)
	{
	case MUIC_NONE:
	case MUIC_UNKNOWN:
		muic_device_none_detect();
		break;

	// CP UART Mode
	case MUIC_CP_UART:
	case MUIC_AP_UART:
		if ((int_stat_val & MIDNO) == 0x0b) {
			muic_mode = MUIC_NONE;
		}
		else {
			muic_device_none_detect();
		}
		break;

	// TA Mode
	case MUIC_NA_TA:
	case MUIC_LG_TA:
	case MUIC_HCHH:
	case MUIC_INVALID_CHG:
		if ((int_stat_val & MVBUS) == 0) {
			// Exit Charger Mode
			muic_mode = MUIC_NONE;
		}
		else {
			// Bug fix: charger detect interrupt 2 times
			set_wakelock(0);
		}
		break;

	// USB Mode
	case MUIC_AP_USB:
	case MUIC_CP_USB:
		if ((int_stat_val & MVBUS) == 0){
			// Exit USB Mode
			muic_mode = MUIC_NONE;
		}
		else {
			muic_device_none_detect();
		}
		break;

	default:
		muic_mode = MUIC_NONE;
		break;
	}

	if (muic_mode == MUIC_NONE) {
		muic_initialize(DEFAULT);
		printk(KERN_INFO "[MUIC] muic none\n");
		charging_ic_deactive();
		printk(KERN_INFO "[MUIC] charging_ic_deactive()\n");
	}

	charger_state_update_by_other();

	return 0;
}
Beispiel #22
0
static void headset_det_work(struct work_struct *work)
{
	headset_status = gpio_get_value(headset_sw_data->gpio); 

	if(headset_status == 0)
	{
#if defined(CONFIG_PRODUCT_LGE_KU5900) || defined(CONFIG_PRODUCT_LGE_LU6800)||defined(CONFIG_PRODUCT_LGE_P970)
	#ifdef USE_LDOBIAS	
		gpio_direction_output(MIC_BIAS_LDO, 0);
		gpio_set_value(MIC_BIAS_LDO, 0);
	#else
		hub_headsetdet_bias(0);
	#endif
#elif defined(CONFIG_PRODUCT_LGE_HUB)
	#ifdef USE_LDOBIAS	
		gpio_direction_output(MIC_BIAS_LDO, 0);
		gpio_set_value(MIC_BIAS_LDO, 0);
	#endif
		hub_headsetdet_bias(0);
#endif
//For_Resume_Speed		DBG("[LUCKYJUN77] headset_det_work : headset_type = HUB_NONE\n");
		DBG("[LUCKYJUN77] headset_det_work : headset_type = HUB_NONE\n");

		headset_type = HUB_NONE;
		switch_set_state(&headset_sw_data->sdev, headset_type);
		#if defined(CONFIG_OMAP2_DSS_HDMI)  
		if(is_hdmi_enabled() == 1)
		{
			DBG("(headset_det_work == Hdmi_setAudioMute(0)\n");
			Hdmi_setAudioMute(0);
		}
	    #endif
	// 20110425 [email protected] detect headset during sleep [START]		
		set_wakelock(0);		
	// 20110425 [email protected] detect headset during sleep [END]		
		return;		
	}
	
	msleep(100);

#if defined(CONFIG_PRODUCT_LGE_KU5900) || defined(CONFIG_PRODUCT_LGE_LU6800)||defined(CONFIG_PRODUCT_LGE_P970)
	#ifdef USE_LDOBIAS	
		gpio_direction_output(MIC_BIAS_LDO, 1);
		gpio_set_value(MIC_BIAS_LDO, 1);
	#else
		hub_headsetdet_bias(1);// LGE_B_S 20101217 [email protected], porting
	#endif
#elif defined(CONFIG_PRODUCT_LGE_HUB)
	#ifdef USE_LDOBIAS	
		gpio_direction_output(MIC_BIAS_LDO, 1);
		gpio_set_value(MIC_BIAS_LDO, 1);
	#endif
		hub_headsetdet_bias(1);// LGE_B_S 20101217 [email protected], porting

#endif

#if defined(CONFIG_PRODUCT_LGE_KU5900)||defined(CONFIG_PRODUCT_LGE_P970) || defined(CONFIG_PRODUCT_LGE_LU6800)	// 20100814 [email protected], dmb ant detect [START_LGE]
	//nothing
#elif defined(CONFIG_PRODUCT_LGE_HUB)
   if(system_rev > 3 && gpio_get_value(headset_sw_data->dmb_ant_gpio) == 1) 
    {
		DBG("[LUCKYJUN77] headset_det_work : dmb_ant detected\n");
		headset_sw_data->dmb_ant_detected = 1;
		set_dmb_status(headset_sw_data->dmb_ant_detected);	//[email protected]
		headset_type = HUB_NONE;
		return;
	}
#endif	
	DBG("[LUCKYJUN77] headset_det_work : dmb_ant detected\n");

	schedule_delayed_work(&headset_sw_data->delayed_work,	msecs_to_jiffies(type_detection_tim));
	
}