/**********************************************************************
*    Name         : fsa9480_SetManualSW()
*    Description : Control FSA9480's Manual SW1 and SW2
*                        
*    Parameter   :
*                       @ valManualSw1 : the value to set SW1
*                       @ valManualSw2 : the value to set SW2
*    Return        : None
*
***********************************************************************/
void fsa9480_SetManualSW(unsigned char valManualSw1, unsigned char valManualSw2)
{
	unsigned char cont_reg, man_sw1, man_sw2;

	DEBUG_FSA9480("[FSA9480]%s \n", __func__);

	/*Set Manual switch*/
	fsa9480_write(fsa9480_i2c_client, REGISTER_MANUALSW1, valManualSw1);
	mdelay(20);

	fsa9480_write(fsa9480_i2c_client, REGISTER_MANUALSW2, valManualSw2);
	mdelay(20);

	/*when detached the cable, Control register automatically be restored.*/
	fsa9480_read(fsa9480_i2c_client, REGISTER_CONTROL, &cont_reg);
	mdelay(20);
	DEBUG_FSA9480("[FSA9480] fsa9480_SetManualSW : [Before]Control Register's value is %s\n",&cont_reg);

	/*set switching mode to MANUAL*/
	fsa9480_write(fsa9480_i2c_client, REGISTER_CONTROL, 0x1A);

	/* Read current setting value , manual sw1, manual sw2, control register.*/
	fsa9480_read(fsa9480_i2c_client, REGISTER_MANUALSW1, &man_sw1);
	mdelay(20);
	DEBUG_FSA9480("[FSA9480] fsa9480_SetManualSW : Manual SW1 Register's value is %s\n",&man_sw1);

	fsa9480_read(fsa9480_i2c_client, REGISTER_MANUALSW2, &man_sw2);
	mdelay(20);
	DEBUG_FSA9480("[FSA9480] fsa9480_SetManualSW : Manual SW2 Register's value is %s\n",&man_sw2);

	fsa9480_read(fsa9480_i2c_client, REGISTER_CONTROL, &cont_reg);
	DEBUG_FSA9480("[FSA9480] fsa9480_SetManualSW : [After]Control Register's value is %s\n",&cont_reg);
}
Exemple #2
0
void FSA9480_Enable_SPK(u8 enable)
{
    struct i2c_client *client = fsa9480_i2c_client;
    u8 data = 0;
    byte reg_value=0;
    byte reg_address=0x0D;

    if(enable)
    {
        DEBUG_FSA9480("FSA9480_Enable_SPK --- enable\n");
        msleep(10);
        Get_MAX8998_PM_ADDR(reg_address, &reg_value, 1); // read 0x0D register
        check_reg = reg_value;
        reg_value = ((0x2<<5)|reg_value);
        check_reg = reg_value;
        Set_MAX8998_PM_ADDR(reg_address,&reg_value,1);
        check_reg = reg_value;

        msleep(10);
        fsa9480_write(client, REGISTER_MANUALSW1, 0x90);	// D+/- switching by V_Audio_L/R in HW03
        msleep(10);
        fsa9480_write(client, REGISTER_CONTROL, 0x1A);	//manual switching

    }
}
// Called by switch sio driver
void mcirousb_usbpath_change(int usb_path)
{
	u8 pData;

	fsa9480_read(fsa9480_i2c_client, REGISTER_CONTROL, &pData);

	microusb_usbpath = usb_path;

	if(usb_path) { // CP USB
		if(pData != 0x1A) {
			//mdelay(10000);
			fsa9480_write(fsa9480_i2c_client, REGISTER_CONTROL, 0x1A);
			mdelay(1000);//mdelay(10000);

			fsa9480_write(fsa9480_i2c_client, REGISTER_MANUALSW1, 0x90);
			mdelay(10);

			fsa9480_write(fsa9480_i2c_client, REGISTER_MANUALSW2, 0x10);
			mdelay(10);
		}
	} else { // AP USB
		if(pData != 0x1E) {
			//mdelay(10000);
			fsa9480_write(fsa9480_i2c_client, REGISTER_CONTROL, 0x1E);
		}
	}
}
static void fsa9480_init(void)
{
	u8 data = 0;

	fsa9480_read(fsa9480_i2c_client, REGISTER_DEVICEID, &data);

	mdelay(10);

	fsa9480_write(fsa9480_i2c_client, REGISTER_CONTROL, 0x1E);

	mdelay(10);

	// Unmask attach/detach interrupt
	fsa9480_write(fsa9480_i2c_client, REGISTER_INTERRUPTMASK1, 0xFC);
	fsa9480_write(fsa9480_i2c_client, REGISTER_INTERRUPTMASK2, 0xFF);

	mdelay(10);

	// Mask CARKIT all interrupt
	fsa9480_write(fsa9480_i2c_client, REGISTER_CARKITMASK1, 0xFF);
	fsa9480_write(fsa9480_i2c_client, REGISTER_CARKITMASK2, 0xFF);

	mdelay(10);

	fsa9480_read(fsa9480_i2c_client, REGISTER_DEVICETYPE1, &fsa9480_device1);

	mdelay(10);

	fsa9480_read(fsa9480_i2c_client, REGISTER_DEVICETYPE2, &fsa9480_device2);
}
Exemple #5
0
static void FSA9480_ReadIntRegister(struct work_struct * work)
{
	u8 interrupt1 , device1, device2, temp;

	DEBUG_FSA9480("[FSA9480] %s\n", __func__);

	 fsa9480_read( REGISTER_INTERRUPT1, &interrupt1);
 	 msleep(5);
	
	 fsa9480_read( REGISTER_DEVICETYPE1, &device1);
 	 msleep(5);

	 fsa9480_read( REGISTER_DEVICETYPE2, &device2);

	 usb_state = (device2 << 8) | (device1 << 0);

	if((interrupt1 & FSA9480_INT1_ATTACH) ||
		(FSA9480_Get_JIG_Status() && maxim_lpm_chg_status()))
	{
		fsa9480_device1 = device1;
		fsa9480_device2 = device2;

		if(fsa9480_device1 != FSA9480_DEV_TY1_DED_CHG) {
				s3c_usb_cable(USB_CABLE_ATTACHED);
		}

		if(fsa9480_device1&FSA9480_DEV_TY1_CAR_KIT)
		{
			msleep(5);
			fsa9480_write( REGISTER_CARKITSTATUS, 0x02);

			msleep(5);
			fsa9480_read( REGISTER_CARKITINT1, &temp);
		}
	}

 	 msleep(5);

	 fsa9480_write( REGISTER_CONTROL, 0x1E);
	 fsa9480_write( REGISTER_INTERRUPTMASK1, 0xFC);

	 FSA9480_ProcessDevice(fsa9480_device1, fsa9480_device2, interrupt1);

	if((interrupt1 & FSA9480_INT1_DETACH) ||
		(FSA9480_Get_JIG_Status() && !maxim_lpm_chg_status()))
	{
		if(fsa9480_device1 != FSA9480_DEV_TY1_DED_CHG) {
				s3c_usb_cable(USB_CABLE_DETACHED);
		}

		fsa9480_device1 = 0;
		fsa9480_device2 = 0;
	}
	
	enable_irq(IRQ_FSA9480_INTB);
}
Exemple #6
0
static void fsa9480_chip_init(void)
{
	 u8 data = 0;

//Enable this code if the below fsa9480_write() becomes active.
//and make a synch with p1.c of SBL.
#if 0// def CONFIG_KERNEL_DEBUG_SEC
#if defined(CONFIG_TARGET_LOCALE_VZW) || defined(CONFIG_TARGET_LOCALE_SPR) 
	u8 skip_dummy = 0;

	unsigned int upload_code = __raw_readl(S5P_INFORM6);
	if((upload_code & KERNEL_SEC_UPLOAD_CAUSE_MASK) == BLK_UART_MSG_FOR_FACTRST_2ND_ACK) {
		skip_dummy = 1;
		upload_code &= (~KERNEL_SEC_UPLOAD_CAUSE_MASK);
		__raw_writel(upload_code , S5P_INFORM6);
	}

	if(skip_dummy == 0) {
        //iks.kim : fsa9480 reset blocked temporarily (charger detection problem)
		//fsa9480_write(&fsa9480_i2c_client, HIDDEN_REGISTER_MANUAL_OVERRDES1, 0x01); //RESET
	}
#endif
#endif //CONFIG_KERNEL_DEBUG_SEC


     //iks.kim : fsa9480 reset blocked temporarily (charger detection problem)
	 //fsa9480_write(&fsa9480_i2c_client, HIDDEN_REGISTER_MANUAL_OVERRDES1, 0x01); //RESET

	 mdelay(10);

	 fsa9480_read( REGISTER_DEVICEID, &data);

	 mdelay(10);
	
	 fsa9480_write( REGISTER_CONTROL, 0x1E);

	 mdelay(10);

	 fsa9480_write( REGISTER_INTERRUPTMASK1, 0xFC);

	 mdelay(10);

	 fsa9480_read( REGISTER_DEVICETYPE1, &fsa9480_device1);

	 mdelay(10);

	 fsa9480_read( REGISTER_DEVICETYPE2, &fsa9480_device2);

#ifdef CONFIG_TARGET_LOCALE_VZW
    /* update usb state */
    usb_state = (fsa9480_device2 << 8) | (fsa9480_device1 << 0);
#endif
	 
}
/**********************************************************************
*    Name         : fsa9480_SetAutoSWMode()
*    Description : Set FSA9480 with Auto Switching Mode.
*                        
*    Parameter   : None
*                       @ 
*                       @ 
*    Return        : None
*
***********************************************************************/
void fsa9480_SetAutoSWMode(void)
{
	DEBUG_FSA9480("[FSA9480]%s\n ", __func__);

	/*set Auto Swithing mode */
	fsa9480_write(fsa9480_i2c_client, REGISTER_CONTROL, 0x1E);
}
Exemple #8
0
void FSA9480_Set_ID_Switch(int sel)
{
	u8 data = 0;
	
	printk("[FSA9480] %s: select (%d)\n", __func__, sel);

	fsa9480_read( REGISTER_MANUALSW2, &data);
	data &= ~(0x3);

	switch(sel)
	{
		case 1:  // ID connected to video
			data |= 0x1;
			break;
		case 2:  // ID connected to bypass port
			data |= 0x2;
			break;
		case 0:  // Open all switch
		default:
			break;
	}
	fsa9480_write( REGISTER_MANUALSW2, data);

	fsa9480_read( REGISTER_MANUALSW2, &data);
	printk("[FSA9480] %s: MANUALSW2 (0x%x)\n", __func__, data);
}
/**********************************************************************
*    Name         : fsa9480_MakeRxdLow()
*    Description : Make UART port to OPEN state.
*                        
*    Parameter   : None
*                       @ 
*                       @ 
*    Return        : None
*
***********************************************************************/
void fsa9480_MakeRxdLow(void)
{
	unsigned char hidden_reg;

	DEBUG_FSA9480("[FSA9480]%s\n ", __func__);

	fsa9480_write(fsa9480_i2c_client, HIDDEN_REGISTER_MANUAL_OVERRDES1, 0x0a); 
	mdelay(20);
	fsa9480_read(fsa9480_i2c_client, HIDDEN_REGISTER_MANUAL_OVERRDES1, &hidden_reg);
	fsa9480_SetManualSW(0x00, 0x00);
}
Exemple #10
0
void FSA9480_Enable_CP_USB(u8 enable)
{
	struct i2c_client *client = fsa9480_i2c_client;
	byte reg_value=0;
	byte reg_address=0x0D;

	if(enable)
	{
		printk("[FSA9480_Enable_CP_USB] Enable CP USB\n");
		mdelay(10);
		Get_MAX8998_PM_ADDR(reg_address, &reg_value, 1); // read 0x0D register
		check_reg = reg_value;
		reg_value = ((0x2<<5)|reg_value);
		check_reg = reg_value;
		Set_MAX8998_PM_ADDR(reg_address,&reg_value,1);
		check_reg = reg_value;
			
		mdelay(10);
#if defined(CONFIG_GALAXY_I897)
                fsa9480_write(client, REGISTER_MANUALSW1, 0x90);  // D+/- switching by Audio_L/R
#else
		fsa9480_write(client, REGISTER_MANUALSW1, 0x48);  // D+/- switching by Audio_L/R in HW04
#endif

		mdelay(10);
		fsa9480_write(client, REGISTER_CONTROL, 0x1A);	

	}
	else
	{
		printk("[FSA9480_Enable_AP_USB] Enable AP USB\n");
		Get_MAX8998_PM_ADDR(reg_address, &reg_value, 1); // read 0x0D register
	
		if(askonstatus||mtp_mode_on)
		ap_usb_power_on(0);
		else
		ap_usb_power_on(1);
		mdelay(10);
		fsa9480_write(client, REGISTER_CONTROL, 0x1E);
	}
}
Exemple #11
0
void fsa9480_chip_init(void)
{
    struct i2c_client *client = fsa9480_i2c_client;

    fsa9480_write(client, HIDDEN_REGISTER_MANUAL_OVERRDES1, 0x01); //RESET

    mdelay(10);
    fsa9480_write(client, REGISTER_CONTROL, 0x1E);

    mdelay(10);

    fsa9480_write(client, REGISTER_INTERRUPTMASK1, 0xFC);

    mdelay(10);

    fsa9480_read(client, REGISTER_DEVICETYPE1, &fsa9480_device1);

    mdelay(10);

    fsa9480_read(client, REGISTER_DEVICETYPE2, &fsa9480_device2);
}
Exemple #12
0
void FSA9480_ChangePathToAudio(u8 enable)
{
	u8 manualsw1;

	if(enable)
	{
		mdelay(10);
		fsa9480_write( REGISTER_MANUALSW1, 0x48);			

		mdelay(10);
		fsa9480_write( REGISTER_CONTROL, 0x1A);

		fsa9480_read( REGISTER_MANUALSW1, &manualsw1);
		printk("Fsa9480 ManualSW1 = 0x%x\n",manualsw1);
	}
	else
	{
		mdelay(10);
		fsa9480_write( REGISTER_CONTROL, 0x1E);	
	}
}
Exemple #13
0
void FSA9480_Enable_CP_USB(u8 enable)
{
	byte reg_value=0;
	byte reg_address=0x0D;

	if(enable)
	{
		printk("[FSA9480_Enable_CP_USB] Enable CP USB\n");
		mdelay(10);
		Get_MAX8998_PM_ADDR(reg_address, &reg_value, 1); // read 0x0D register
		check_reg = reg_value;
		reg_value = ((0x2<<5)|reg_value);
		check_reg = reg_value;
		Set_MAX8998_PM_ADDR(reg_address,&reg_value,1);
		check_reg = reg_value;
			
		mdelay(10);
		fsa9480_write( REGISTER_MANUALSW1, 0x90);	

		mdelay(10);
		fsa9480_write( REGISTER_CONTROL, 0x1A);	

	}
	else
	{
		printk("[FSA9480_Enable_AP_USB] Enable AP USB\n");
		Get_MAX8998_PM_ADDR(reg_address, &reg_value, 1); // read 0x0D register

		if(askonstatus||mtp_mode_on)
			ap_usb_power_on(0);
		else
			ap_usb_power_on(1);
		mdelay(10);
		fsa9480_write( REGISTER_CONTROL, 0x1E);	
	}

}
Exemple #14
0
static int fsa9480_codec_probe(struct i2c_client *client, const struct i2c_device_id *id)
{
	struct fsa9480_state *state;
	struct device *dev = &client->dev;
	u8 pData;

	DEBUG_FSA9480("[FSA9480] %s\n", __func__);

	s3c_gpio_cfgpin(GPIO_USB_SW_SCL, S3C_GPIO_OUTPUT);
	s3c_gpio_setpull(GPIO_USB_SW_SCL, S3C_GPIO_PULL_NONE);

	s3c_gpio_cfgpin(GPIO_USB_SW_SDA, S3C_GPIO_OUTPUT);
	s3c_gpio_setpull(GPIO_USB_SW_SDA, S3C_GPIO_PULL_NONE);

	 s3c_gpio_cfgpin(GPIO_UART_SEL, S3C_GPIO_OUTPUT );
	 s3c_gpio_setpull(GPIO_UART_SEL, S3C_GPIO_PULL_NONE);

	user_switch_init();

	 init_waitqueue_head(&usb_detect_waitq); 
	 INIT_WORK(&fsa9480_work, FSA9480_ReadIntRegister);
	 fsa9480_workqueue = create_singlethread_workqueue("fsa9480_workqueue");

	 state = kzalloc(sizeof(struct fsa9480_state), GFP_KERNEL);
	 if(!state) {
		 dev_err(dev, "%s: failed to create fsa9480_state\n", __func__);
		 return -ENOMEM;
	 }

	state->client = client;
	fsa9480_i2c_client = client;

	i2c_set_clientdata(client, state);
	if(!fsa9480_i2c_client)
	{
		dev_err(dev, "%s: failed to create fsa9480_i2c_client\n", __func__);
		return -ENODEV;
	}

	 /*clear interrupt mask register*/
	fsa9480_read( REGISTER_CONTROL, &pData);
	fsa9480_write( REGISTER_CONTROL, pData & ~INT_MASK);

	 fsa9480_interrupt_init();

	 fsa9480_chip_init();

	 return 0;
}
Exemple #15
0
static int fsa9480_modify(struct i2c_client *client, u8 reg, u8 data, u8 mask)
{
    u8 original_value, modified_value;

    fsa9480_read(client, reg, &original_value);

    mdelay(10);

    modified_value = ((original_value&~mask) | data);

    fsa9480_write(client, reg, modified_value);

    mdelay(10);

    return 0;
}
static int fsa9480_modify(struct i2c_client *client, u8 reg, u8 data, u8 mask)
{
   u8 original_value, modified_value;

   fsa9480_read(client, reg, &original_value);

   mdelay(10);
   
   DEBUG_FSA9480("[FSA9480] %s Original value is 0x%02x\n ",__func__, original_value);
   
   modified_value = ((original_value&~mask) | data);
   
   DEBUG_FSA9480("[FSA9480] %s modified value is 0x%02x\n ",__func__, modified_value);
   
   fsa9480_write(client, reg, modified_value);

   mdelay(10);

   return 0;
}
static int fsa9480_resume(struct i2c_client *client)
{
#ifdef FEATURE_FTM_SLEEP
	if(ftm_sleep)
	{
#ifdef CONFIG_ARCH_OMAP34XX
		if(wakeup_timer_seconds)
#endif
		{
#ifdef CONFIG_ARCH_OMAP34XX
			wakeup_timer_seconds = 0;
#endif

			/*set Auto Swithing mode */
			fsa9480_write(fsa9480_i2c_client, REGISTER_CONTROL, 0x1E);
		}
	}
#endif

	return 0;
}
Exemple #18
0
static int fsa9480_codec_probe(struct i2c_client *client, const struct i2c_device_id *id)
{
    struct fsa9480_state *state;
    struct device *dev = &client->dev;
    u8 pData;

    DEBUG_FSA9480("[FSA9480] %s\n", __func__);

    s3c_gpio_cfgpin(GPIO_USB_SCL_28V, S3C_GPIO_OUTPUT);
    s3c_gpio_setpull(GPIO_USB_SCL_28V, S3C_GPIO_PULL_NONE);

    s3c_gpio_cfgpin(GPIO_USB_SDA_28V, S3C_GPIO_OUTPUT);
    s3c_gpio_setpull(GPIO_USB_SDA_28V, S3C_GPIO_PULL_NONE);

    s3c_gpio_cfgpin(GPIO_UART_SEL, S3C_GPIO_OUTPUT );
    s3c_gpio_setpull(GPIO_UART_SEL, S3C_GPIO_PULL_NONE);

    if (device_create_file(switch_dev, &dev_attr_uart_sel) < 0)
        pr_err("Failed to create device file(%s)!\n", dev_attr_uart_sel.attr.name);

    if (device_create_file(switch_dev, &dev_attr_usb_sel) < 0)
        DEBUG_FSA9480("[FSA9480]Failed to create device file(%s)!\n", dev_attr_usb_sel.attr.name);

    if (device_create_file(switch_dev, &dev_attr_usb_state) < 0)
        DEBUG_FSA9480("[FSA9480]Failed to create device file(%s)!\n", dev_attr_usb_state.attr.name);

#if 1
    if (device_create_file(switch_dev, &dev_attr_DMport) < 0)
        pr_err("Failed to create device file(%s)!\n", dev_attr_DMport.attr.name);

    if (device_create_file(switch_dev, &dev_attr_DMlog) < 0)
        pr_err("Failed to create device file(%s)!\n", dev_attr_DMlog.attr.name);
#endif

    if (device_create_file(switch_dev, &dev_attr_UsbMenuSel) < 0)
        pr_err("Failed to create device file(%s)!\n", dev_attr_UsbMenuSel.attr.name);

    if (device_create_file(switch_dev, &dev_attr_AskOnMenuSel) < 0)
        pr_err("Failed to create device file(%s)!\n", dev_attr_AskOnMenuSel.attr.name);

    if (device_create_file(switch_dev, &dev_attr_Mtp) < 0)
        pr_err("Failed to create device file(%s)!\n", dev_attr_Mtp.attr.name);

    if (device_create_file(switch_dev, &dev_attr_SwitchingInitValue) < 0)
        pr_err("Failed to create device file(%s)!\n", dev_attr_SwitchingInitValue.attr.name);

    if (device_create_file(switch_dev, &dev_attr_FactoryResetValue) < 0)
        pr_err("Failed to create device file(%s)!\n", dev_attr_FactoryResetValue.attr.name);

    if (device_create_file(switch_dev, &dev_attr_AskOnStatus) < 0)
        pr_err("Failed to create device file(%s)!\n", dev_attr_AskOnStatus.attr.name);

    if (device_create_file(switch_dev, &dev_attr_MtpInitStatusSel) < 0)
        pr_err("Failed to create device file(%s)!\n", dev_attr_MtpInitStatusSel.attr.name);

    if (device_create_file(switch_dev, &dev_attr_AskInitStatusSel) < 0)
        pr_err("Failed to create device file(%s)!\n", dev_attr_AskInitStatusSel.attr.name);

    if (device_create_file(switch_dev, &dev_attr_tethering) < 0)
        pr_err("Failed to create device file(%s)!\n", dev_attr_tethering.attr.name);

    if (device_create_file(switch_dev, &dev_attr_dock) < 0)
        pr_err("Failed to create device file(%s)!\n", dev_attr_dock.attr.name);


    init_waitqueue_head(&usb_detect_waitq);
    INIT_WORK(&fsa9480_work, FSA9480_ReadIntRegister);
    fsa9480_workqueue = create_singlethread_workqueue("fsa9480_workqueue");

    state = kzalloc(sizeof(struct fsa9480_state), GFP_KERNEL);
    if(!state) {
        dev_err(dev, "%s: failed to create fsa9480_state\n", __func__);
        return -ENOMEM;
    }

    indicator_dev.name = DRIVER_NAME;
    indicator_dev.print_name = print_switch_name;
    indicator_dev.print_state = print_switch_state;
    switch_dev_register(&indicator_dev);

    state->client = client;
    fsa9480_i2c_client = client;

    i2c_set_clientdata(client, state);
    if(!fsa9480_i2c_client)
    {
        dev_err(dev, "%s: failed to create fsa9480_i2c_client\n", __func__);
        return -ENODEV;
    }

    /*clear interrupt mask register*/
    fsa9480_read(fsa9480_i2c_client, REGISTER_CONTROL, &pData);
    fsa9480_write(fsa9480_i2c_client, REGISTER_CONTROL, pData & ~INT_MASK);

    fsa9480_interrupt_init();

    fsa9480_chip_init();

    INIT_DELAYED_WORK(&micorusb_init_work, connectivity_switching_init);
    schedule_delayed_work(&micorusb_init_work, msecs_to_jiffies(200));

    return 0;
}
void microusb_init(void)
{
#define I2C_READ_RETRY_MAX 2
	int ret = 0;
	int read_retry;
	u8 device1;
	u8 device2;
	u8 interrupt1;
	u8 interrupt2;
	u8 attach = FSA9480_INT1_ATTACH;

	for(read_retry = 0; read_retry < I2C_READ_RETRY_MAX; read_retry++) {
		device1 = 0;
		if(fsa9480_read(fsa9480_i2c_client, REGISTER_DEVICETYPE1, &device1) == 0) {
			break;
		}
	}

	for(read_retry = 0; read_retry < I2C_READ_RETRY_MAX; read_retry++) {
		device2 = 0;
		if(fsa9480_read(fsa9480_i2c_client, REGISTER_DEVICETYPE2, &device2) == 0) {
			break;
		}
	}

	if(microusb_usbpath > 0) // if CP USB
	{
		fsa9480_write(fsa9480_i2c_client, REGISTER_CONTROL, 0x1A);
		mdelay(10);

		fsa9480_write(fsa9480_i2c_client, REGISTER_MANUALSW1, 0x90);
		mdelay(10);

		fsa9480_write(fsa9480_i2c_client, REGISTER_MANUALSW2, 0x10);
		mdelay(10);
	}
	else
	{
		if(device1 && (device1 != FSA9480_DEV_TY1_DED_CHG)) {
			attach = FSA9480_INT1_ATTACH;
		}

		if(device1 == 0 && device2 == 0) {
			device1 = FSA9480_DEV_TY1_USB;
			attach = FSA9480_INT1_DETACH;
		}

		fsa9480_device1 = device1;
		fsa9480_device2 = device2;

		fsa9480_process_device(fsa9480_device1, fsa9480_device2, attach);

		fsa9480_init();
	}

	// clear interrupt
	fsa9480_read(fsa9480_i2c_client, REGISTER_INTERRUPT1, &interrupt1);
	msleep(5);

	fsa9480_read(fsa9480_i2c_client, REGISTER_INTERRUPT2, &interrupt2);
	msleep(5);

	fsa9480_interrupt_init(fsa9480_i2c_client->irq, fsa9480_i2c_device_id);
}
static void fsa9480_read_int_register(struct work_struct *work)
{
	u8 interrupt1 , interrupt2, device1, device2, temp;

	DEBUG_FSA9480("fsa9480_read_int_register function!!!!\n");

	fsa9480_read(fsa9480_i2c_client, REGISTER_INTERRUPT1, &interrupt1);

	mdelay(10);

	fsa9480_read(fsa9480_i2c_client, REGISTER_INTERRUPT2, &interrupt2);

	mdelay(10);

	fsa9480_read(fsa9480_i2c_client, REGISTER_DEVICETYPE1, &device1);

	mdelay(10);

	fsa9480_read(fsa9480_i2c_client, REGISTER_DEVICETYPE2, &device2);

	if(interrupt1 & FSA9480_INT1_ATTACH)
	{
		fsa9480_device1 = device1;
		fsa9480_device2 = device2;

		if(fsa9480_device1 & FSA9480_DEV_TY1_CAR_KIT)
		{
			mdelay(10);
			fsa9480_write(fsa9480_i2c_client, REGISTER_CARKITSTATUS, 0x02);

			mdelay(10);
			fsa9480_read(fsa9480_i2c_client, REGISTER_CARKITINT1, &temp);
		}
	}

	mdelay(10);

	if(microusb_usbpath > 0) // if CP USB
	{
		fsa9480_write(fsa9480_i2c_client, REGISTER_CONTROL, 0x1A);
		mdelay(10);

		fsa9480_write(fsa9480_i2c_client, REGISTER_MANUALSW1, 0x90);
		mdelay(10);

		fsa9480_write(fsa9480_i2c_client, REGISTER_MANUALSW2, 0x10);
		mdelay(10);
	}
	else
	{
		fsa9480_write(fsa9480_i2c_client, REGISTER_CONTROL, 0x1E);	 

		wake_up_interruptible(&usb_detect_waitq);

		fsa9480_process_device(fsa9480_device1, fsa9480_device2, interrupt1);
	}

	fsa9480_write(fsa9480_i2c_client, REGISTER_INTERRUPTMASK1, 0xFC);

	if(interrupt1 & FSA9480_INT1_DETACH)
	{
		fsa9480_device1 = 0;
		fsa9480_device2 = 0;
	}

	enable_irq(fsa9480_i2c_client->irq);

	wake_lock_timeout(&fsa9480_wake_lock, 3*HZ);
}
Exemple #21
0
void FSA9480_ReadIntRegister(struct work_struct *work)
{
    struct i2c_client *client = fsa9480_i2c_client;
    u8 interrupt1 ,interrupt2 ,device1, device2, temp;

    DEBUG_FSA9480("[FSA9480] %s\n", __func__);

    fsa9480_read(client, REGISTER_INTERRUPT1, &interrupt1);
    msleep(5);

    fsa9480_read(client, REGISTER_INTERRUPT2, &interrupt2);
    msleep(5);

    fsa9480_read(client, REGISTER_DEVICETYPE1, &device1);
    msleep(5);

    fsa9480_read(client, REGISTER_DEVICETYPE2, &device2);

    usb_state = (device2 << 8) | (device1 << 0);

    if(interrupt1 & FSA9480_INT1_ATTACH)
    {
        fsa9480_device1 = device1;
        fsa9480_device2 = device2;

        if(fsa9480_device1 != FSA9480_DEV_TY1_DED_CHG) {
            //DEBUG_FSA9480("FSA9480_enable LDO8\n");
            s3c_usb_cable(1);
        }

        if(fsa9480_device1&FSA9480_DEV_TY1_CAR_KIT)
        {
            msleep(5);
            fsa9480_write(client, REGISTER_CARKITSTATUS, 0x02);

            msleep(5);
            fsa9480_read(client, REGISTER_CARKITINT1, &temp);
        }
    }

    msleep(5);

    fsa9480_write(client, REGISTER_CONTROL, 0x1E);
    fsa9480_write(client, REGISTER_INTERRUPTMASK1, 0xFC);
#if defined(CONFIG_ARIES_NTT) // Modify NTTS1
    //syyoon 20100724	 fix for SC - Ad_10_2nd - 0006. When USB is removed, sometimes attatch value gets 0x00
    if((fsa9480_device1 == FSA9480_DEV_TY1_USB) && (!interrupt1)) {
        printk("[FSA9480] dev1=usb, attach change is from 0 to 2\n");
        interrupt1 = FSA9480_INT1_DETACH;
    }
#endif
    FSA9480_ProcessDevice(fsa9480_device1, fsa9480_device2, interrupt1);

    if(interrupt1 & FSA9480_INT1_DETACH)
    {
        if(fsa9480_device1 != FSA9480_DEV_TY1_DED_CHG) {
            //DEBUG_FSA9480("FSA9480_disable LDO8\n");
            s3c_usb_cable(0);
        }

        fsa9480_device1 = 0;
        fsa9480_device2 = 0;
    }

    enable_irq(IRQ_FSA9480_INTB);
}