Ejemplo n.º 1
0
int muic_set_mhl_mode(struct muic_client_device *mcdev)// (struct i2c_client *client)
{
	struct i2c_client *client = tsu5611; //to_i2c_client(%mcdev->dev);// i2c_verify_client(&mcdev->dev); 

	dev_info(&client->dev, "muic: %s entry.\n", __func__);
#if 0
	/* 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_NC);
#endif
	//muic_i2c_write_byte(SW_CONTROL, COMP2_TO_DP2 | COMN1_TO_DN1);
	muic_i2c_write_byte(client, SW_CONTROL, COMP2_TO_HZ | COMN1_TO_HZ);

  	/* Enable 200K, Charger Pump, and ADC (0x01=0x13) */
	//muic_i2c_write_byte(CONTROL_1, ID_200 | SEMREN | CP_EN);
#if 0
	MHL_On(1);
#endif

//	muic_set_mode(MUIC_MHL);
}
void muic_set_mhl_mode_detect(void)
{

	printk("[MUIC] muic_set_mhl_mode_detect entry. \n");

	/* 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_NC);

    //muic_i2c_write_byte(SW_CONTROL, COMP2_TO_DP2 | COMN1_TO_DN1); 
	muic_i2c_write_byte(SW_CONTROL, COMP2_TO_HZ | COMN1_TO_HZ);

	
  	/* Enable 200K, Charger Pump, and ADC (0x01=0x13) */
   	//muic_i2c_write_byte(CONTROL_1, ID_200 | SEMREN | CP_EN);  

	MHL_On(1);

	muic_path = MUIC_MHL; 

  
}
Ejemplo n.º 3
0
static int SII9234B_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id)
{
	//SII_DEV_DBG("");

	struct SII9234_state *state;

	state = kzalloc(sizeof(struct SII9234_state), GFP_KERNEL);
	if (state == NULL) {		
		printk("failed to allocate memory \n");
		return -ENOMEM;
	}
	
	state->client = client;
	i2c_set_clientdata(client, state);
	
	/* rest of the initialisation goes here. */
	
	printk("SII9234B attach success!!!\n");

	SII9234B_i2c_client = client;

	SII9234B_i2cprobe_status = 1;
	if(( SII9234_i2cprobe_status == 1) && ( SII9234A_i2cprobe_status == 1) 
		&& ( SII9234B_i2cprobe_status == 1) && ( SII9234C_i2cprobe_status == 1))
	{
		SII9234_i2c_status = 1;
		MHL_On(false);
	}

	printk("ksw sii9234_i2c_read(sii9234_i2c_client, 0x02) = %x\n", SII9234_i2c_read(SII9234B_i2c_client, 0x4C));
	
	return 0;

}
Ejemplo n.º 4
0
static void sii9234_adc_work_func(struct work_struct *work)
{
  int   acc_adc;
  bool  adc_mhl_detected;
  
	acc_adc = batt_read_adc(CHANNEL_ADC_ACC, NULL);
	pr_info("%s: acc_adc=%d\n", __func__, acc_adc);

	if(acc_adc >= 0 && acc_adc <= 70)
	{
	  adc_mhl_detected = true;
	}
	else
	{
	  adc_mhl_detected = false;
	}

	if(old_adc_mhl_detected != adc_mhl_detected)
	{
	  pr_info("%s: adc_mhl_detected=%d,%d\n", __func__, adc_mhl_detected,adc_detect_safe_count);
	  
    if(++adc_detect_safe_count > 2)
    {
      old_adc_mhl_detected = adc_mhl_detected;
      adc_detect_safe_count = 0;

      if(adc_mhl_detected)
      {
        MHL_On(true);
      }
      else
      {
        MHL_On(false);
      }
    }
  }
  else
  {
    adc_detect_safe_count = 0;
  }

  if(!old_adc_mhl_detected)
	hrtimer_start(&sii9234_adc_timer,
		ns_to_ktime(250000000/*500ms*/), HRTIMER_MODE_REL);
}
Ejemplo n.º 5
0
bool mhl_cable_connect(void)
{
	int r;
	
		MHL_DEV_INFO("%s: in\n ", __func__);
//		pantech_hdmi_cable_detect(0);/*definitely off hdmi */
		MHL_Set_Cable_State(MHL_CABLE_CONNCET);
		mhl_power_ctrl(1);	
		msleep(10);				
		MHL_On(1);
//		MHL_Cable_On(1);

		MHL_En_Control(1) ;// switch-MHL		

		MHL_DEV_INFO( "!!!!!!!![SKY_MHL]%s MHL cable Connect\n",__func__);


	r = wait_event_timeout(mhl_disconnect_wait_queue, get_mhl_status()==MHL_CABLE_CONNECT ,msecs_to_jiffies(200));
	MHL_DEV_INFO("get_mhl_status = %d", get_mhl_status());
	MHL_DEV_INFO("get_mhl_rgnd_status=%d\n", get_mhl_rgnd_status());
	MHL_DEV_INFO("get_mhl_power_mode=%d\n", get_mhl_power_mode());
		if (!r && get_mhl_status() != MHL_CABLE_CONNECT)
		{
			wait_event_timeout(mhl_disconnect_wait_queue, 0 ,msecs_to_jiffies(100));
			pr_err("get_mhl_status = %d", get_mhl_status());
			if (!get_mhl_power_mode()){
				pr_err("mhl is not ready to be operated\n");
				MHL_DEV_INFO(" get_mhl_rgnd_status=%d", get_mhl_rgnd_status());
				mhl_cable_disconnect();
				return false;
			}
			
		}

	
	r = wait_event_timeout(mhl_disconnect_wait_queue, get_mhl_status()==MHL_DISCOVERY_SUCCESS ,msecs_to_jiffies(1500));

		if (!r && get_mhl_status()!= MHL_DISCOVERY_SUCCESS )
		{
			pr_err("get_mhl_status = %d", get_mhl_status()); /* for debug */		
			queue_delayed_work(mhl_ctrl_connect_work_queue, &mhl_ctrl_connect_work,10);
			return false;
		}

 return true;
}
Ejemplo n.º 6
0
//[[email protected]] - moved muic_ti.c to here
void muic_set_mhl_mode_detect(void) 
{ 

	DBG("[MUIC] muic_set_mhl_mode_detect entry. \n"); 

	/* Connect CP UART signals to AP */ 
	usif_switch_ctrl(USIF_AP); 
	/* 109 		 * AP USB does not pass through DP3T. 110		 
	 * Just connect AP UART to MUIC UART.  111		  */

	dp3t_switch_ctrl(DP3T_NC);

	//muic_i2c_write_byte(SW_CONTROL, COMP2_TO_DP2 | COMN1_TO_DN1);  //Path USB
	muic_i2c_write_byte(SW_CONTROL, COMP2_TO_HZ | COMN1_TO_HZ); //Path OPEN


	/* Enable 200K, Charger Pump, and ADC (0x01=0x13) */ 
	//muic_i2c_write_byte(CONTROL_1, ID_200 | SEMREN | CP_EN);   

	MHL_On(1); 

	//muic_mode = MUIC_MHL;  //[[email protected]] - Set by caller. NOT here.
}
Ejemplo n.º 7
0
void mhl_cable_disconnect(void)
{

	
	MHL_DEV_INFO("%s: in\n ", __func__);	
	
		if(MHL_Get_Cable_State()){
			
					MHL_DEV_INFO("%s: really in!!!!!! in\n ", __func__);	
					MHL_Set_Cable_State(MHL_CABLE_DISCONNCET);	
					set_mhl_ctrled_hpd_state(false);
					MHL_Cable_On(0);
					MHL_On(0);
					mhl_power_ctrl(0);
					MHL_En_Control(0) ;// switch-MHL
		//			pantech_hdmi_cable_detect(0);
					MHL_DEV_INFO( "[SKY_MHL]%s MHL cable disConnect \n",__func__);
		
	
		}
		


}
Ejemplo n.º 8
0
void mhl_cable_connect(struct work_struct *work)
{

	if (HDMI_INP_ND(0x0000) & 0x00000001)
	{
		mhl_power_ctrl(1);	
		msleep(10);
				MHL_On(1);
					
				MHL_En_Control(1) ;// switch-MHL
				MHL_Set_Cable_State(MHL_CABLE_CONNCET);
	#ifdef MHL_DEBUG
		printk(KERN_ERR "[SKY_MHL]%s MHL cable Connect \n",__func__);
	#endif
	return;
	}
	else
	{		
		schedule_delayed_work(&sii9244_cable_connect_work.work, msecs_to_jiffies(100));
	}
	
	
 return;
}
Ejemplo n.º 9
0
s32 muic_max14526_detect_accessory(s32 upon_irq)
{
	s32 ret = 0;

	u8 int_stat_value;
		
	/* Upon an MUIC IRQ (MUIC_INT_N falls),
	 * wait 70ms before reading INT_STAT and STATUS.
	 * After the reads, MUIC_INT_N returns to high
	 * (but the INT_STAT and STATUS contents will be held).
	 *
	 * Do this only if muic_max14526_detect_accessory() was called upon IRQ. */
	muic_mdelay(250);
	
	/* Reads INT_STAT */
	ret = muic_i2c_read_byte(INT_STAT, &int_stat_value);
	printk(KERN_WARNING "[MUIC] muic_max14526_detect_accessory, int_stat_value = 0x%02x \n", int_stat_value);
	
	if (ret < 0) {
		printk(KERN_INFO "[MUIC] INT_STAT reading failed\n");
		muic_mode = MUIC_UNKNOWN;
		charging_mode = CHARGING_UNKNOWN;
		return ret;
	}
    
	/* Branches according to the previous muic_mode */
	switch (muic_mode) {

	/* MUIC_UNKNOWN is reached in two cases both do not have nothing to do with IRQ.
	 * First, at the initialization time where the muic_mode is not available yet.
	 * Second, whenever the current muic_mode detection is failed.
	 */
	case MUIC_UNKNOWN :

	/* If the previous muic_mode was MUIC_NONE,
	 * the only possible condition for a MUIC IRQ is plugging in an accessory.
	 */
	case MUIC_NONE :
		set_max14526_muic_mode(int_stat_value);           
		break;

	/* If the previous muic_mode was MUIC_NA_TA, MUIC_LG_TA, MUIC_TA_1A, MUIC_INVALID_CHG,
	 * MUIC_AP_UART, MUIC_CP_UART, MUIC_AP_USB, MUIC_OTG, or MUIC_CP_USB,
	 * the only possible condition for a MUIC IRQ is plugging out the accessory.
	 * 
	 * In this case, initialize MUIC and wait an IRQ.
	 * We don't need to wait 250msec because this is not an erronous case
	 * (we need to reset the facility to set STATUS for an erronous case and
	 * have to wait 250msec) and, if this is not an erronous case, the facility
	 * was already initialized at the system booting.
	 */
	case MUIC_NA_TA:
	case MUIC_TA_1A:
	case MUIC_INVALID_CHG :
	case MUIC_LG_TA :
	case MUIC_AP_UART :
	case MUIC_CP_UART :
	case MUIC_AP_USB :
	case MUIC_CP_USB :
		if ((int_stat_value & V_VBUS) != 0) {					// V_VBUS == 1
			set_max14526_muic_mode(int_stat_value);
		} else if ((int_stat_value & IDNO) == IDNO_1011) {	// V_VBUS == 0
			charging_mode = CHARGING_NONE;
			muic_mode = MUIC_NONE;
		} else
			set_max14526_muic_mode(int_stat_value);
		break;

#if defined(CONFIG_MHL_TX_SII9244)
	case MUIC_MHL :
			printk(KERN_WARNING "[MUIC] Detect step3  MHL \n");
			if ((int_stat_value & V_VBUS) == 0) {    
				MHL_On(0);
			muic_mode = MUIC_NONE;
			charging_mode = CHARGING_NONE;
		}
		
		if( ((int_stat_value & V_VBUS) != 0) && (!gpio_get_value(GPIO_MHL_SEL)) && ((int_stat_value & IDNO) == IDNO_0000) )
		{
			MHL_On(1);	//re-enable MHL
			muic_mode = MUIC_MHL;
			charging_mode = CHARGING_USB;
		}
		break;
#endif
		
	default:
		printk(KERN_WARNING "[MUIC] Failed to detect an accessory. Try again!");
		muic_mode = MUIC_UNKNOWN;
		charging_mode = CHARGING_UNKNOWN;
		ret = -1;
		break;
	}	

	
	printk(KERN_WARNING "[MUIC] muic_max14526_detect_accessory, muic_mode = %s (%d) \n", muic_mode_str[muic_mode], muic_mode );

	if (muic_mode == MUIC_UNKNOWN || muic_mode == MUIC_NONE) {
		muic_init_max14526(RESET);
		gpio_set_value(IFX_USB_VBUS_EN_GPIO, 0);
        printk(KERN_INFO "[MUIC] charging_ic_deactive()\n");
    }

	

	return ret;
}
s32 muic_ts5usba33402_detect_accessory(s32 upon_irq)
{
	s32 ret = 0;

	u8 int_stat_value;

	muic_mdelay(70);
		
	/* Read INT_STAT */
	ret = muic_i2c_read_byte(INT_STAT, &int_stat_value);
	printk("[MUIC] muic_ts5usba33402_detect_accessory, int_stat_value:0x%02x \n", int_stat_value);
	
	if (ret < 0) {
		printk(KERN_INFO "[MUIC] INT_STAT reading failed\n");
		muic_path = MUIC_UNKNOWN;
		charging_mode = muic_path;
		//set_muic_charger_detected();

		return ret;
	}

	/* Branch according to the previous muic_path */
	switch (muic_path) {
	/* 
	 * MUIC_UNKNOWN is reached in two cases both do not have nothing to do with IRQ.
	 * First, at the initialization time where the muic_path is not available yet.
	 * Second, whenever the current muic_path detection is failed.
	 */
	case MUIC_UNKNOWN :

	/*
	 * If the previous muic_path was MUIC_NONE,
	 * the only possible condition for a MUIC IRQ is plugging in an accessory.
	 */
	case MUIC_NONE :
		set_ts5usba33402_muic_path(int_stat_value);
		break;

	/* 
	 * If the previous muic_path was MUIC_NA_TA, MUIC_LG_TA, MUIC_TA_1A, MUIC_INVALID_CHG,
	 * MUIC_AP_UART, MUIC_CP_UART, MUIC_AP_USB, MUIC_OTG, or MUIC_CP_USB,
	 * the only possible condition for a MUIC IRQ is plugging out the accessory.
	 * 
	 * In this case, initialize MUIC and wait an IRQ.
	 * We don't need to wait 250msec because this is not an erronous case
	 * (we need to reset the facility to set STATUS for an erronous case and
	 * have to wait 250msec) and, if this is not an erronous case, the facility
	 * was already initialized at the system booting.
	 */
	case MUIC_AP_UART :
	case MUIC_CP_UART :
		if ((int_stat_value & IDNO) == IDNO_1011) {	        
			muic_i2c_write_byte(SW_CONTROL, COMP2_TO_HZ | COMN1_TO_HZ);	
	        muic_path = MUIC_NONE;
			charging_mode = CHARGING_NONE;
	    }       
		break;
		
	case MUIC_NA_TA :
	case MUIC_LG_TA :
	case MUIC_TA_1A :
	case MUIC_INVALID_CHG :
		if (((int_stat_value & VBUS) == 0) || ((int_stat_value & CHGDET) == 0)) {	         
	        muic_path = MUIC_NONE;
			charging_mode = CHARGING_NONE;
        }
		break;
		
	case MUIC_AP_USB :
	case MUIC_CP_USB :
		if ((int_stat_value & VBUS) == 0) {         
      		/* USB host removed */
      		muic_path = MUIC_NONE;
			charging_mode = CHARGING_NONE;
    	}
		break;

#if defined (CONFIG_CX2_MHL_TX_SII9244) 
	case MUIC_MHL :
		printk(KERN_WARNING "[MUIC] Detect step3  mhl \n");
		if ((int_stat_value & VBUS) == 0) {    
			MHL_On(0);
			muic_path = MUIC_NONE;
		}
		break;
#endif

		
	default :
		printk(KERN_WARNING "[MUIC] Failed to detect an accessory. Try again!");
		muic_path = MUIC_UNKNOWN;
		charging_mode = CHARGING_NONE;
		ret = -1;
	}	

	printk(KERN_WARNING "[MUIC] muic_ts5usba33402_detect_accessory, muic_path = %s\n", muic_path_str[muic_path]);

	if (muic_path == MUIC_UNKNOWN || muic_path == MUIC_NONE){
		muic_init_ts5usba33402(RESET);
		gpio_set_value(IFX_USB_VBUS_EN_GPIO, 0);
        printk(KERN_INFO "[MUIC] charging_ic_deactive()\n");
    }
	//set_muic_charger_detected();
	
	return ret;
} 
Ejemplo n.º 11
0
static int SII9234C_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id)
{
	int ret;
	//SII_DEV_DBG("");

	struct SII9234_state *state;

	state = kzalloc(sizeof(struct SII9234_state), GFP_KERNEL);
	if (state == NULL) {		
		printk("failed to allocate memory \n");
		return -ENOMEM;
	}
	
	state->client = client;
	i2c_set_clientdata(client, state);
	
	/* rest of the initialisation goes here. */
	
	printk("SII9234C attach success!!!\n");

	SII9234C_i2c_client = client;

	SII9234C_i2cprobe_status = 1;
	if(( SII9234_i2cprobe_status == 1) && ( SII9234A_i2cprobe_status == 1) 
		&& ( SII9234B_i2cprobe_status == 1) && ( SII9234C_i2cprobe_status == 1))
	{
		SII9234_i2c_status = 1;
		MHL_On(false);
	}
#if 0
	/* Initialize GPIO 30 (IRQ_MHL_INT).
	* Check if other driver already occupied it.
	*/
	ret = gpio_request(IRQ_MHL_INT, "IRQ MHL INT");
	if(ret < 0){
		printk(KERN_INFO "[MHL] GPIO 30 IRQ_MHL_INT is already occupied by other driver!\n");
		return -ENOSYS;
	}

	/* Initialize GPIO direction before use or IRQ setting */
	ret = gpio_direction_input(IRQ_MHL_INT);
	if(ret < 0){
		printk(KERN_INFO "[MHL] GPIO 30 IRQ_MHL_INT direction initialization failed!\n");
		return -ENOSYS;
	}
#endif
	sii9234_wq = create_singlethread_workqueue("sii9234_wq");
	INIT_WORK(&SiI9234_int_work,SiI9234_interrupt_event_work);

	set_irq_type(IRQ_MHL_INT, IRQ_TYPE_EDGE_FALLING);
	ret = request_threaded_irq( IRQ_MHL_INT , 
		NULL, mhl_int_irq_handler, IRQF_DISABLED	, "mhl_int", (void*)state);
	if (ret < 0) 
	{
		printk("unable to request irq mhl_int err:: %d\n", ret);
		return ret;
	}		
	
	sii9234_wq = create_singlethread_workqueue("sii9234_wq");
	INIT_WORK(&SiI9234_int_work,SiI9234_interrupt_event_work);

/*
	ret = request_irq(IRQ_MHL_WAKE_UP, mhl_wake_up_irq_handler, IRQF_DISABLED, "mhl_wake_up", (void *) state); // check and study here...
	if (ret) 
	{
		printk("unable to request irq mhl_wake_up err:: %d\n", ret);
		return ret;
	}		
	

	ret = request_irq(IRQ_MHL_HPD, mhl_hpd_irq_handler, IRQ_TYPE_EDGE_BOTH  , "mhl_hpd", mhl_hpd_irq_handler);  
	if (ret) 
	{
		printk("unable to request irq mhl_int err:: %d\n", ret);
		return ret;
	}		
	printk("MHL HPD request successful \n");
*/
	//sii9234_cfg_power(1); Unnecessary supply  the current during boot up time.
	mhl_i2c_client_info();
	printk("ksw sii9234_i2c_read(sii9234_i2c_client, 0x02) = %x\n", SII9234_i2c_read(SII9234C_i2c_client, 0x07));

#ifdef TIMER_ACC_ADC 
  hrtimer_init(&sii9234_adc_timer,CLOCK_MONOTONIC,HRTIMER_MODE_REL);
  sii9234_adc_timer.function = sii9234_adctimer_func;
  sii9234_adc_wq = create_singlethread_workqueue("sii9234_adc_wq");

  if (!sii9234_adc_wq) {
		pr_err("%s: could not create workqueue sii9234_adc_wq\n", __func__);
	}
  INIT_WORK(&sii9234_adc_work,sii9234_adc_work_func);
	hrtimer_start(&sii9234_adc_timer,
		ns_to_ktime(500000000/*500ms*/), HRTIMER_MODE_REL);

#endif
	
	return 0;

}
Ejemplo n.º 12
0
static int SII9234_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id)
{
	//SII_DEV_DBG("");
	//int retval;

	struct SII9234_state *state;

	struct class *mhl_class;
	struct device *mhl_dev;
	int usb_switch;

	state = kzalloc(sizeof(struct SII9234_state), GFP_KERNEL);
	if (state == NULL) {		
		printk("failed to allocate memory \n");
		return -ENOMEM;
	}
	
	state->client = client;
	i2c_set_clientdata(client, state);


	
	/* rest of the initialisation goes here. */
	
	printk("SII9234 attach success!!!\n");

	SII9234_i2c_client = client;

	MHL_i2c_init = 1;

	mhl_class = class_create(THIS_MODULE, "mhl");
	if (IS_ERR(mhl_class))
	{
		pr_err("Failed to create class(mhl)!\n");
	}

	mhl_dev = device_create(mhl_class, NULL, 0, NULL, "mhl_dev");
	if (IS_ERR(mhl_dev))
	{
		pr_err("Failed to create device(mhl_dev)!\n");
	}

	if (device_create_file(mhl_dev, &dev_attr_MHD_file) < 0)
		printk("Failed to create device file(%s)!\n", dev_attr_MHD_file.attr.name);

	SII9234_i2cprobe_status = 1;
	if(( SII9234_i2cprobe_status == 1) && ( SII9234A_i2cprobe_status == 1) 
		&& ( SII9234B_i2cprobe_status == 1) && ( SII9234C_i2cprobe_status == 1))
	{
		SII9234_i2c_status = 1;
		MHL_On(false);
	}

	printk("ksw sii9234_i2c_read(sii9234_i2c_client, 0x02) = %x\n", SII9234_i2c_read(SII9234_i2c_client, 0x02));
	usb_switch = gpio_get_value(GPIO_MHL_SEL);
	printk("ksw mhl_sel_gpio_value = 0x%x\n", usb_switch);
	


	
	return 0;

}
Ejemplo n.º 13
0
void is_mhl_cable(struct work_struct *work)
{
	
	struct pm8xxx_adc_chan_result result;
	int rc=0;
	int try_max=0;
	do
	{
	   rc = pm8xxx_adc_mpp_config_read(PM8XXX_AMUX_MPP_3, ADC_MPP_1_AMUX6, &result);
	   try_max++;
	}while(rc && try_max<20);
	#ifdef MHL_DEBUG
	   printk("%s: cable_mv %lld\n ", __func__, result.physical);
	#endif
#if ((BOARD_VER>=TP10 && BOARD_VER<TP20) && (defined(CONFIG_MACH_MSM8960_EF45K) || defined(CONFIG_MACH_MSM8960_EF46L) || defined(CONFIG_MACH_MSM8960_EF47S)))
	if (!MHL_Get_Cable_State() && (mhlsii9244_adc_value > 15000	&& mhlsii9244_adc_value< 50000))
#elif (BOARD_VER>=TP20 && (defined(CONFIG_MACH_MSM8960_EF45K) || defined(CONFIG_MACH_MSM8960_EF46L) || defined(CONFIG_MACH_MSM8960_EF47S)))
	if (!MHL_Get_Cable_State() && (mhlsii9244_adc_value> 22000	&&mhlsii9244_adc_value < 50000))		
#else /*(defined(CONFIG_MACH_MSM8960_VEGAPVW) || defined(CONFIG_MACH_MSM8960_VEGAPKDDI))*/
	if (!MHL_Get_Cable_State() && (mhlsii9244_adc_valuel< 300000))
#endif
	{
	
		sii9244_cfg_power(0);
		
			pantech_hdmi_cable_detect(1);


	schedule_delayed_work(&sii9244_cable_connect_work.work, msecs_to_jiffies(100));

	mhlsii9244_adc_value = 0;

}
#if ((BOARD_VER>=TP10 && BOARD_VER<TP20) && (defined(CONFIG_MACH_MSM8960_EF45K) || defined(CONFIG_MACH_MSM8960_EF46L) || defined(CONFIG_MACH_MSM8960_EF47S)))
	else if (MHL_Get_Cable_State() && (result.physical < 15000 ||  result.physical > 50000))
#elif (BOARD_VER>=TP20 && (defined(CONFIG_MACH_MSM8960_EF45K) || defined(CONFIG_MACH_MSM8960_EF46L) || defined(CONFIG_MACH_MSM8960_EF47S)))
	else if (MHL_Get_Cable_State() && (result.physical < 22000 ||  result.physical > 50000))
#else /*(defined(CONFIG_MACH_MSM8960_VEGAPVW) || defined(CONFIG_MACH_MSM8960_VEGAPKDDI))*/
	else if (MHL_Get_Cable_State() && (result.physical > 300000))
#endif

{
	if ( get_mhl_status()== MHL_RSEN_LOW)
{
			pantech_hdmi_cable_detect(0);


				MHL_On(0);
			//	mhl_power_ctrl(0);	
						MHL_En_Control(0) ;// switch-MHL
						MHL_Set_Cable_State(MHL_CABLE_DISCONNCET);
			#ifdef MHL_DEBUG
				printk(KERN_ERR "[SKY_MHL]%s MHL cable disConnect \n",__func__);
			#endif
				sii9244_cfg_power_init();
	}
	
}
#if (BOARD_VER>=TP20 && (defined(CONFIG_MACH_MSM8960_EF45K) || defined(CONFIG_MACH_MSM8960_EF46L) || defined(CONFIG_MACH_MSM8960_EF47S)))
		if (!MHL_Get_Cable_State() && (mhlsii9244_adc_value<22000))
	{
				if (is_mhl_mode())
			{
				sii9244_cfg_power(0);
				
				pantech_hdmi_cable_detect(1);


				schedule_delayed_work(&sii9244_cable_connect_work.work, msecs_to_jiffies(100));

				mhlsii9244_adc_value = 0;
				set_flag_mhl_mode(0);
			}
	}
#endif
	return ;

}
Ejemplo n.º 14
0
s32 muic_ts5usba33402_detect_accessory(s32 upon_irq)
{
	s32 ret = 0;

	u8 int_stat_value;
	
	/*
	 * Upon an MUIC IRQ (MUIC_INT_N falls),
	 * wait 70ms before reading INT_STAT and STATUS.
	 * After the reads, MUIC_INT_N returns to high
	 * (but the INT_STAT and STATUS contents will be held).
	 *
	 * Do this only if muic_ts5usba33402_detect_accessory() was called upon IRQ. 
	 */
	//if (upon_irq) {
		muic_mdelay(70);
	//}	

	
	/* Read INT_STAT */
	ret = muic_i2c_read_byte(INT_STAT, &int_stat_value);
	printk("[MUIC] muic_ts5usba33402_detect_accessory, int_stat_value:0x%02x \n", int_stat_value);

	if (ret < 0) {
		printk(KERN_INFO "[MUIC] INT_STAT reading failed\n");
		muic_mode = MUIC_UNKNOWN;
		charging_mode = CHARGING_UNKNOWN;
		//                                                                                 
		//set_muic_charger_detected();

		return ret;
	}
   // muic_set_device_none_detect(int_stat_value); 		  

	/* Branch according to the previous muic_mode */
	switch (muic_mode) {

	/* 
	 * MUIC_UNKNOWN is reached in two cases both do not have nothing to do with IRQ.
	 * First, at the initialization time where the muic_mode is not available yet.
	 * Second, whenever the current muic_mode detection is failed.
	 */
	case MUIC_UNKNOWN :

	/*
	 * If the previous muic_mode was MUIC_NONE,
	 * the only possible condition for a MUIC IRQ is plugging in an accessory.
	 */
	case MUIC_NONE :
		set_ts5usba33402_muic_mode(int_stat_value);
		break;

	/* 
	 * If the previous muic_mode was MUIC_NA_TA, MUIC_LG_TA, MUIC_TA_1A, MUIC_INVALID_CHG,
	 * MUIC_AP_UART, MUIC_CP_UART, MUIC_AP_USB, MUIC_OTG, or MUIC_CP_USB,
	 * the only possible condition for a MUIC IRQ is plugging out the accessory.
	 * 
	 * In this case, initialize MUIC and wait an IRQ.
	 * We don't need to wait 250msec because this is not an erronous case
	 * (we need to reset the facility to set STATUS for an erronous case and
	 * have to wait 250msec) and, if this is not an erronous case, the facility
	 * was already initialized at the system booting.
	 */
	case MUIC_AP_UART :
	case MUIC_CP_UART :
		if ((int_stat_value & IDNO) == IDNO_1011) {	        
			muic_i2c_write_byte(SW_CONTROL, COMP2_TO_HZ | COMN1_TO_HZ);
	        muic_mode = MUIC_NONE;			
			charging_mode = CHARGING_NONE;
	    }       

		break;
		
	case MUIC_NA_TA :
	case MUIC_LG_TA :
	case MUIC_TA_1A :
	case MUIC_INVALID_CHG :
		if (((int_stat_value & V_VBUS) == 0) || ((int_stat_value & CHGDET) == 0)) {	         
	        muic_mode = MUIC_NONE;				
			charging_mode = CHARGING_NONE;
        }

		break;
		
	case MUIC_AP_USB :
	case MUIC_CP_USB :
		/* 
		 * Check if V_VBUS == 0 && IDNO == 0x1011 (open).
		 * If so, it's MUIC_NONE.
		 * Otherwise, it's an erronous situation. MUIC_UNKNOWN.
		 */

        if((int_stat_value & IDNO) == IDNO_0010)
        {
            muic_mode = MUIC_CP_USB;
        }
        else if ((int_stat_value & IDNO) == IDNO_0100)
        {
            muic_mode = MUIC_CP_UART;
        }
		else if ((int_stat_value & V_VBUS) == 0) {         
      		/* USB Host Removed */
      		muic_mode = MUIC_NONE;				
			charging_mode = CHARGING_NONE;
    	}
		break;
#if defined(CONFIG_MHL_TX_SII9244)
	case MUIC_MHL :
			printk(KERN_WARNING "[MUIC] Detect step3  MHL \n");
			if ((int_stat_value & V_VBUS) == 0) {    
					MHL_On(0);
			muic_mode = MUIC_NONE;
			charging_mode = CHARGING_NONE;
		}
			break;
#endif
		
	default:
		printk(KERN_WARNING "[MUIC] Failed to detect an accessory. Try again!");
		muic_mode = MUIC_UNKNOWN;
		charging_mode = CHARGING_NONE;
		ret = -1;
		break;
	}	

	if(muic_mode == MUIC_UNKNOWN || muic_mode == MUIC_NONE){
		muic_init_ts5usba33402(RESET);
		gpio_set_value(IFX_USB_VBUS_EN_GPIO, 0);
        printk(KERN_INFO "[MUIC] charging_ic_deactive()\n");
    }
	//                                           
	//                                                                                                   

	printk( "[MUIC] muic_ts5usba33402_detect_accessory, muic_mode = %s (%d) \n", muic_mode_str[muic_mode], muic_mode);
	return ret;
}