예제 #1
0
void fsa9480_audiopath_control(int enable)
{
	struct i2c_client *client = local_usbsw->client;
	dev_info(&client->dev, "%s(%d)\n", __func__, enable);
#if defined(CONFIG_USA_MODEL_SGH_I717) || defined (CONFIG_USA_MODEL_SGH_T769)
	if(enable) {
		if(Dockconnected && !get_sec_det_jack_state()) {
			fsa9480_manual_switching(SWITCH_PORT_AUDIO); /* dock audio path On */
			isDockaudioenable = 1;
		}
		else
			dev_info(&client->dev, "%s: does not On dock audio (dock=%d, earjack=%d)\n", __func__, Dockconnected, get_sec_det_jack_state());
	} else {
		if((!Dockconnected || (Dockconnected && get_sec_det_jack_state())) && isDockaudioenable) {
			fsa9480_manual_switching(SWITCH_PORT_USB); /* dock audio path Off */
			isDockaudioenable = 0;
		}
		else
			dev_info(&client->dev, "%s: does not Off dock audio (dock=%d, earjack=%d, dockaudio=%d)\n", __func__, Dockconnected, get_sec_det_jack_state(), isDockaudioenable);
	}
#else
	if(enable) {
		if(isDeskdockconnected && !get_sec_det_jack_state())
			fsa9480_manual_switching(SWITCH_PORT_AUDIO); /* dock audio path On */
		else
			dev_info(&client->dev, "%s: does not On dock audio (dock=%d, earjack=%d)\n", __func__, isDeskdockconnected, get_sec_det_jack_state());
	} else {
		if(!isDeskdockconnected || (isDeskdockconnected && get_sec_det_jack_state()))
			fsa9480_manual_switching(SWITCH_PORT_USB); /* dock audio path Off */
		else
			dev_info(&client->dev, "%s: does not Off dock audio (dock=%d, earjack=%d)\n", __func__, isDeskdockconnected, get_sec_det_jack_state());
	}
#endif
}
예제 #2
0
static bool check_samsung_charger(void)
{
    int adc_1, adc_2, vol_1, vol_2;
    int i = 0;

    adc_1 = adc_2 = vol_1 = vol_2 = 0;

    fsa9480_manual_switching(SWITCH_Audio_Port);

    for ( i=0; i<3; i++)
    {
        //1.Read ADC value
        adc_1 = sec_bat_get_adc_data(ADC_AP_CHECK_1);
        adc_2 = sec_bat_get_adc_data(ADC_AP_CHECK_2);

        //2. Change ADC value to Voltage
        vol_1= adc_1* 3300 / 4095;
        vol_2= adc_2* 3300 / 4095;
        pr_info("%s: vol_1 = %d, vol_2 = %d!!\n", __func__, vol_1, vol_2);

        //3. Check range of the voltage
        if( (vol_1 < 800) || (vol_1 > 1470) || (vol_2 < 800) || (vol_2 > 1470) )
        {
            pr_info("%s: Improper charger is connected!!!\n", __func__);
            fsa9480_manual_switching(AUTO_SWITCH);
            return false;
        }
    }

    pr_info("%s: Samsung charger is connected!!!\n", __func__);
    fsa9480_manual_switching(AUTO_SWITCH);
    return true;

}
예제 #3
0
static void usb_switch_mode(struct sec_switch_struct *secsw, int mode)
{
	if (mode == SWITCH_PDA)	{
		if (secsw->pdata && secsw->pdata->set_vbus_status)
			secsw->pdata->set_vbus_status((u8)USB_VBUS_AP_ON);
		mdelay(10);
		fsa9480_manual_switching(SWITCH_PORT_AUTO);
	} else {
		if (secsw->pdata && secsw->pdata->set_vbus_status)
			secsw->pdata->set_vbus_status((u8)USB_VBUS_CP_ON);
		mdelay(10);
		fsa9480_manual_switching(SWITCH_PORT_VAUDIO);
	}
}
예제 #4
0
static void uart_switch_mode(struct sec_switch_struct *secsw, int mode)
{
	pr_info("%s : mode = %d\n", __func__, mode);
	if (mode == SWITCH_PDA)	{
		gpio_set_value(GPIO_USB_SW_EN1, 1);
		gpio_set_value(GPIO_UART_SEL, 1);
		fsa9480_manual_switching(SWITCH_PORT_AUTO);
	} else if (mode == SWITCH_MODEM) {
		gpio_set_value(GPIO_USB_SW_EN1, 1);
		gpio_set_value(GPIO_UART_SEL1, 0);
		fsa9480_manual_switching(SWITCH_PORT_VAUDIO);
	} else {
		gpio_set_value(GPIO_USB_SW_EN1, 1);
		gpio_set_value(GPIO_UART_SEL, 0);
		fsa9480_manual_switching(SWITCH_PORT_AUTO);
	}
}
예제 #5
0
static void uart_switch_mode(struct sec_switch_struct *secsw, int mode)
{
	if (mode == SWITCH_PDA)	{	
#ifdef CONFIG_TARGET_LOCALE_US_ATT_REV01
		fsa9480_manual_switching(SWITCH_PORT_AUTO);
#else
		gpio_set_value(UART_SEL_SW,0);
#endif
		mdelay(10);		
	} else {	
#ifdef CONFIG_TARGET_LOCALE_US_ATT_REV01
		fsa9480_manual_switching(SWITCH_PORT_VAUDIO);
#else
		gpio_set_value(UART_SEL_SW,1);
#endif
		mdelay(10);		
	}
}
예제 #6
0
static void usb_switch_mode(struct sec_switch_struct *secsw, int mode)
{
	if (mode == SWITCH_PDA)	{
		if (secsw->pdata && secsw->pdata->set_vbus_status)
			secsw->pdata->set_vbus_status((u8)USB_VBUS_AP_ON);
		mdelay(10);
		fsa9480_manual_switching(SWITCH_PORT_AUTO);
	} else {
		if (secsw->pdata && secsw->pdata->set_vbus_status)
			secsw->pdata->set_vbus_status((u8)USB_VBUS_CP_ON);
		mdelay(10);
	#if defined(CONFIG_S5PC110_KEPLER_BOARD)
		fsa9480_manual_switching(SWITCH_PORT_VAUDIO);
	#elif defined(CONFIG_S5PC110_HAWK_BOARD)
		fsa9480_manual_switching(SWITCH_PORT_AUDIO);
	#endif
	}
}
static void usb_switch_mode(struct sec_switch_struct *secsw, int mode
)
{
	if(mode == SWITCH_PDA)
	{
		if(secsw->pdata && secsw->pdata->set_regulator)
			secsw->pdata->set_regulator(AP_VBUS_ON);
		mdelay(10);

		fsa9480_manual_switching(AUTO_SWITCH);
	}
	else  // SWITCH_MODEM
	{
		if(secsw->pdata && secsw->pdata->set_regulator)
			secsw->pdata->set_regulator(CP_VBUS_ON);
		mdelay(10);

		fsa9480_manual_switching(SWITCH_V_Audio_Port);
	}
예제 #8
0
/*********for WIMAX USB MODEM***********/
int fsa9480_set_ctl_register(void)
{
     int ret=0;
     struct i2c_client *client = local_usbsw->client;
     if (adc_fsa == WIMAX_CABLE_50K)
	     fsa9480_manual_switching(SWITCH_PORT_USB);
     else 
	     ret = i2c_smbus_write_byte_data(client, FSA9480_REG_CTRL,0x1E);
     if (ret < 0)
	     dev_err(&client->dev, "%s: err %d\n", __func__, ret);
}
예제 #9
0
static void usb_switch_mode(struct sec_switch_struct *secsw, int mode)
{
// for qc usb driver change ]
	char buf='5';
	// int retval = 0;
// ]

	if (mode == SWITCH_PDA)	{
		if (secsw->pdata && secsw->pdata->set_vbus_status)
			secsw->pdata->set_vbus_status((u8)USB_VBUS_AP_ON);
		mdelay(10);
#ifdef CONFIG_TARGET_LOCALE_US_ATT_REV01
		gpio_set_value(USB_SEL_SW,0);
		gpio_set_value(USB_MDM_EN,0);
#else
		fsa9480_manual_switching(SWITCH_PORT_AUTO); 
		buf='5';	
#endif		
	} else {
		if (secsw->pdata && secsw->pdata->set_vbus_status)
			secsw->pdata->set_vbus_status((u8)USB_VBUS_CP_ON);
		mdelay(10);		
#ifdef CONFIG_TARGET_LOCALE_US_ATT_REV01
		gpio_set_value(USB_SEL_SW,1);
		gpio_set_value(USB_MDM_EN,1);
#else
		fsa9480_manual_switching(SWITCH_PORT_AUTO); 
		//secsw->is_manualset=0;
		buf='4';
#endif
	}
// for qc , samsung usb driver switch [
	if (secsw->is_manualset)
	{
		UsbMenuSel_switch_store(NULL,NULL,&buf,1);	
	}
// ]
}
예제 #10
0
static void usb_switch_mode(struct sec_switch_struct *secsw, int mode)
{
	if (mode == SWITCH_PDA)	{
		if (secsw->pdata && secsw->pdata->set_vbus_status)
			secsw->pdata->set_vbus_status((u8)USB_VBUS_AP_ON);
		mdelay(10);
#ifdef CONFIG_TARGET_LOCALE_US_ATT_REV01
		gpio_set_value(USB_SEL_SW,0);
		gpio_set_value(USB_MDM_EN,0);
#else
		fsa9480_manual_switching(SWITCH_PORT_AUTO);
#endif		
	} else {
		if (secsw->pdata && secsw->pdata->set_vbus_status)
			secsw->pdata->set_vbus_status((u8)USB_VBUS_CP_ON);
		mdelay(10);		
#ifdef CONFIG_TARGET_LOCALE_US_ATT_REV01
		gpio_set_value(USB_SEL_SW,1);
		gpio_set_value(USB_MDM_EN,1);
#else
		fsa9480_manual_switching(SWITCH_PORT_AUTO);
#endif
	}
}
예제 #11
0
static void usb_switch_mode(struct sec_switch_struct *secsw, int mode)
{
	pr_info("%s : mode = %d\n", __func__, mode);
	if (mode == SWITCH_PDA)	{
		if (secsw->pdata && secsw->pdata->set_vbus_status)
			secsw->pdata->set_vbus_status((u8)USB_VBUS_AP_ON);

		gpio_set_value(GPIO_USB_SW_EN1, 1);
		fsa9480_manual_switching(SWITCH_PORT_AUTO);
	} else if (mode == SWITCH_MODEM) {
		if (secsw->pdata && secsw->pdata->set_vbus_status)
			secsw->pdata->set_vbus_status((u8)USB_VBUS_CP_ON);

		gpio_set_value(GPIO_USB_SW_EN1, 1);
		gpio_set_value(GPIO_UART_SEL1, 1);
		fsa9480_manual_switching(SWITCH_PORT_VAUDIO);
	} else {
		if (secsw->pdata && secsw->pdata->set_vbus_status)
			secsw->pdata->set_vbus_status((u8)USB_VBUS_CP_ON);

		gpio_set_value(GPIO_USB_SW_EN1, 0);
		fsa9480_manual_switching(SWITCH_PORT_OPEN);
	}
}
예제 #12
0
void FSA9480_Enable_SPK(u8 enable)
{
	static struct regulator *esafeout2_regulator;
	//struct i2c_client *client = local_usbsw->client;
	//u8 data = 0;
	
	if (!enable) {
		printk("%s: Speaker Disabled\n", __func__);
		return;
	}
	
	esafeout2_regulator = regulator_get(NULL, "esafeout2");		
	if (IS_ERR(esafeout2_regulator)) {
		pr_err(" failed to get regulator esafeout2\n");
		return;
	}
	regulator_enable(esafeout2_regulator);	
	mdelay(10);

	fsa9480_manual_switching(local_usbsw->pdata->spk_switch);
}
예제 #13
0
static void fsa9480_detect_dev(struct fsa9480_usbsw *usbsw)
{
	int device_type, ret;
	unsigned char val1, val2;
	struct fsa9480_platform_data *pdata = usbsw->pdata;
	struct i2c_client *client = usbsw->client;

#ifdef CONFIG_MACH_VICTORY
	adc_fsa  = i2c_smbus_read_word_data(client, FSA9480_REG_ADC);
	if (adc_fsa < 0)
		dev_err(&client->dev, "%s: err %d\n", __func__, adc_fsa);
	if ( adc_fsa == WIMAX_CABLE_50K){
		switch_set_state(&wimax_cable, USB_CABLE_50K);
	} else if (adc_fsa == WIMAX_CABLE_50K_DIS) {
		fsa9480_manual_switching(SWITCH_PORT_AUTO);
		switch_set_state(&wimax_cable, CABLE_DISCONNECT);
	} 
#endif
	device_type = i2c_smbus_read_word_data(client, FSA9480_REG_DEV_T1);
	if (device_type < 0)
		dev_err(&client->dev, "%s: err %d\n", __func__, device_type);

	val1 = device_type & 0xff;
	val2 = device_type >> 8;

	dev_info(&client->dev, "dev1: 0x%x, dev2: 0x%x\n", val1, val2);

	/* Attached */
	if (val1 || val2) {
		/* USB */
#ifdef CONFIG_MACH_VICTORY
		if (val1 & DEV_T1_USB_MASK){
#else		
			if (val1 & DEV_T1_USB_MASK || val2 & DEV_T2_USB_MASK ) {
#endif
			if (pdata->usb_cb)
				pdata->usb_cb(FSA9480_ATTACHED);

			micro_usb_status = 1;
#ifdef _SUPPORT_SAMSUNG_AUTOINSTALLER_
			askon_gadget_disconnect();
			if (!askon_status)
				UsbIndicator(1);
#else
				UsbIndicator(1);
#endif
			if (usbsw->mansw) {
				ret = i2c_smbus_write_byte_data(client,
					FSA9480_REG_MANSW1, usbsw->mansw);
				if (ret < 0)
					dev_err(&client->dev,
						"%s: err %d\n", __func__, ret);
			}
#ifdef CONFIG_MACH_VICTORY
		} else if ( val2 & DEV_T2_USB_MASK ) {
			if (pdata->wimax_cb)
				pdata->wimax_cb(FSA9480_ATTACHED);
				switch_set_state(&wimax_cable, USB_CABLE_255K);
#endif
		/* UART */
		} else if (val1 & DEV_T1_UART_MASK || val2 & DEV_T2_UART_MASK) {
			if(val2 & DEV_T2_UART_MASK)
				MicroJigUARTOffStatus = 1;

			if (pdata->uart_cb)
				pdata->uart_cb(FSA9480_ATTACHED);

			if (usbsw->mansw) {
				ret = i2c_smbus_write_byte_data(client,
					FSA9480_REG_MANSW1, SW_UART);
				if (ret < 0)
					dev_err(&client->dev,
						"%s: err %d\n", __func__, ret);
			}

			if (val2 & DEV_T2_JIG_MASK) {
				if (pdata->jig_cb)
					pdata->jig_cb(FSA9480_ATTACHED);
			}
		/* CHARGER */
		} else if (val1 & DEV_T1_CHARGER_MASK) {
			if (pdata->charger_cb)
				pdata->charger_cb(FSA9480_ATTACHED);
		/* JIG */
		} else if (val2 & DEV_T2_JIG_MASK) {
			if (pdata->jig_cb)
				pdata->jig_cb(FSA9480_ATTACHED);
		/* Desk Dock */
		} else if (val2 & DEV_AV) {
			if (pdata->deskdock_cb)
				pdata->deskdock_cb(FSA9480_ATTACHED);
				dock_status = 1;
			
			ret = i2c_smbus_write_byte_data(client,
					FSA9480_REG_MANSW1, SW_VAUDIO);
			if (ret < 0)
				dev_err(&client->dev,
					"%s: err %d\n", __func__, ret);

			ret = i2c_smbus_read_byte_data(client,
					FSA9480_REG_CTRL);
			if (ret < 0)
				dev_err(&client->dev,
					"%s: err %d\n", __func__, ret);

			ret = i2c_smbus_write_byte_data(client,
					FSA9480_REG_CTRL, ret & ~CON_MANUAL_SW);
			if (ret < 0)
				dev_err(&client->dev,
					"%s: err %d\n", __func__, ret);
		/* Car Dock */
		} else if (val2 & DEV_JIG_UART_ON) {
			if (pdata->cardock_cb)
				pdata->cardock_cb(FSA9480_ATTACHED);
			dock_status = 1;

                        ret = i2c_smbus_write_byte_data(client,
                                        FSA9480_REG_MANSW1, SW_VAUDIO);
                        if (ret < 0)
                                dev_err(&client->dev,
                                        "%s: err %d\n", __func__, ret);

                        ret = i2c_smbus_read_byte_data(client,
                                        FSA9480_REG_CTRL);
                        if (ret < 0)
                                dev_err(&client->dev,
                                        "%s: err %d\n", __func__, ret);

                        ret = i2c_smbus_write_byte_data(client,
                                FSA9480_REG_CTRL, ret & ~CON_MANUAL_SW);
                        if (ret < 0)
                                dev_err(&client->dev,
                                        "%s: err %d\n", __func__, ret);
		}
	/* Detached */
	} else {
		/* USB */
#ifdef CONFIG_MACH_VICTORY
		if (usbsw->dev1 & DEV_T1_USB_MASK){
#else		
		if (usbsw->dev1 & DEV_T1_USB_MASK ||
				usbsw->dev2 & DEV_T2_USB_MASK) {
#endif
			micro_usb_status = 0;
			UsbIndicator(0);
			if (pdata->usb_cb)
				pdata->usb_cb(FSA9480_DETACHED);
#ifdef CONFIG_MACH_VICTORY		
        	/* USB JIG */
		} else if (usbsw->dev2 & DEV_T2_USB_MASK) {
			if (pdata->wimax_cb)
				pdata->wimax_cb(FSA9480_DETACHED);
			switch_set_state(&wimax_cable, CABLE_DISCONNECT);
#endif
		/* UART */
		} else if (usbsw->dev1 & DEV_T1_UART_MASK ||
				usbsw->dev2 & DEV_T2_UART_MASK) {
			if(usbsw->dev2 & DEV_T2_UART_MASK)
				MicroJigUARTOffStatus = 0;

			if (pdata->uart_cb)
				pdata->uart_cb(FSA9480_DETACHED);
			if (usbsw->dev2 & DEV_T2_JIG_MASK) {
				if (pdata->jig_cb)
					pdata->jig_cb(FSA9480_DETACHED);
			}
		/* CHARGER */
		} else if (usbsw->dev1 & DEV_T1_CHARGER_MASK) {
			if (pdata->charger_cb)
				pdata->charger_cb(FSA9480_DETACHED);
		/* JIG */
		} else if (usbsw->dev2 & DEV_T2_JIG_MASK) {
			if (pdata->jig_cb)
				pdata->jig_cb(FSA9480_DETACHED);
		/* Desk Dock */
		} else if (usbsw->dev2 & DEV_AV) {
			if (pdata->deskdock_cb)
				pdata->deskdock_cb(FSA9480_DETACHED);
			dock_status = 0;
			
			ret = i2c_smbus_read_byte_data(client,FSA9480_REG_CTRL);
			if (ret < 0)
				dev_err(&client->dev,
					"%s: err %d\n", __func__, ret);

			ret = i2c_smbus_write_byte_data(client,
					FSA9480_REG_CTRL, ret | CON_MANUAL_SW);
			if (ret < 0)
				dev_err(&client->dev,
					"%s: err %d\n", __func__, ret);
		/* Car Dock */
		} else if (usbsw->dev2 & DEV_JIG_UART_ON) {
			if (pdata->cardock_cb)
				pdata->cardock_cb(FSA9480_DETACHED);
			dock_status = 0;

                        ret = i2c_smbus_read_byte_data(client,
                                        FSA9480_REG_CTRL);
                        if (ret < 0)
                                dev_err(&client->dev,
                                        "%s: err %d\n", __func__, ret);

                        ret = i2c_smbus_write_byte_data(client,
                                        FSA9480_REG_CTRL, ret | CON_MANUAL_SW);
                        if (ret < 0)
                                dev_err(&client->dev,
                                        "%s: err %d\n", __func__, ret);
		}
	}

	usbsw->dev1 = val1;
	usbsw->dev2 = val2;
}

static void fsa9480_reg_init(struct fsa9480_usbsw *usbsw)
{
	struct i2c_client *client = usbsw->client;
	unsigned int ctrl = CON_MASK;
	int ret;
#if defined (CONFIG_MACH_ATLAS) || defined (CONFIG_MACH_FORTE)
	/* mask interrupts (unmask attach/detach only) */
	ret = i2c_smbus_write_word_data(client, FSA9480_REG_INT1_MASK, 0x1ffc);
	if (ret < 0)
		dev_err(&client->dev, "%s: err %d\n", __func__, ret);
#elif CONFIG_MACH_VICTORY
	/* mask interrupts (unmask attach/detach only reserved attach only) */
	ret = i2c_smbus_write_word_data(client, FSA9480_REG_INT1_MASK, 0x1dfc);
	if (ret < 0)
		dev_err(&client->dev, "%s: err %d\n", __func__, ret);
#endif
	/* mask all car kit interrupts */
	ret = i2c_smbus_write_word_data(client, FSA9480_REG_CK_INTMASK1, 0x07ff);
	if (ret < 0)
		dev_err(&client->dev, "%s: err %d\n", __func__, ret);

	/* ADC Detect Time: 500ms */
	ret = i2c_smbus_write_byte_data(client, FSA9480_REG_TIMING1, 0x6);
	if (ret < 0)
		dev_err(&client->dev, "%s: err %d\n", __func__, ret);

	usbsw->mansw = i2c_smbus_read_byte_data(client, FSA9480_REG_MANSW1);
	if (usbsw->mansw < 0)
		dev_err(&client->dev, "%s: err %d\n", __func__, usbsw->mansw);

	if (usbsw->mansw)
		ctrl &= ~CON_MANUAL_SW;	/* Manual Switching Mode */

	ret = i2c_smbus_write_byte_data(client, FSA9480_REG_CTRL, ctrl);
	if (ret < 0)
		dev_err(&client->dev, "%s: err %d\n", __func__, ret);
}

static irqreturn_t fsa9480_irq_thread(int irq, void *data)
{
	struct fsa9480_usbsw *usbsw = data;
	struct i2c_client *client = usbsw->client;
	int intr;
	
	/* read and clear interrupt status bits */
	intr = i2c_smbus_read_word_data(client, FSA9480_REG_INT1);
	if (intr < 0) {
		dev_err(&client->dev, "%s: err %d\n", __func__, intr);
	} else if (intr == 0) {
		/* interrupt was fired, but no status bits were set,
		so device was reset. In this case, the registers were
		reset to defaults so they need to be reinitialised. */
		fsa9480_reg_init(usbsw);
	}

	/* device detection */
	fsa9480_detect_dev(usbsw);
	
	return IRQ_HANDLED;
}

static int fsa9480_irq_init(struct fsa9480_usbsw *usbsw)
{
	struct i2c_client *client = usbsw->client;
	int ret;

	if (client->irq) {
		ret = request_threaded_irq(client->irq, NULL,
			fsa9480_irq_thread, IRQF_TRIGGER_FALLING,
			"fsa9480 micro USB", usbsw);
		if (ret) {
			dev_err(&client->dev, "failed to reqeust IRQ\n");
			return ret;
		}

		ret = enable_irq_wake(client->irq);
		if (ret < 0)
			dev_err(&client->dev,
				"failed to enable wakeup src %d\n", ret);
	}

	return 0;
}

static int __devinit fsa9480_probe(struct i2c_client *client,
			 const struct i2c_device_id *id)
{
	struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent);
	struct fsa9480_usbsw *usbsw;
	int ret = 0;
#ifdef CONFIG_MACH_FORTE 
        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);
#endif

	if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
		return -EIO;

	usbsw = kzalloc(sizeof(struct fsa9480_usbsw), GFP_KERNEL);
	if (!usbsw) {
		dev_err(&client->dev, "failed to allocate driver data\n");
		return -ENOMEM;
	}

	usbsw->client = client;
	usbsw->pdata = client->dev.platform_data;
	if (!usbsw->pdata)
		goto fail1;

	i2c_set_clientdata(client, usbsw);
	
	local_usbsw = usbsw;  // temp

	if (usbsw->pdata->cfg_gpio)
		usbsw->pdata->cfg_gpio();

	fsa9480_reg_init(usbsw);

	ret = fsa9480_irq_init(usbsw);
	if (ret)
		goto fail1;

	ret = sysfs_create_group(&client->dev.kobj, &fsa9480_group);
	if (ret) {
		dev_err(&client->dev,
				"failed to create fsa9480 attribute group\n");
		goto fail2;
	}

	if (usbsw->pdata->reset_cb)
		usbsw->pdata->reset_cb();

        indicator_dev.name = DRIVER_NAME;
#if 1
        indicator_dev.print_name = print_switch_name;
        indicator_dev.print_state = print_switch_state;
#endif
        switch_dev_register(&indicator_dev);

#if defined(CONFIG_MACH_VICTORY)
		ret = switch_dev_register(&wimax_cable);
		wimax_cable.print_state = wimax_cable_type; 
#endif

	/* device detection */
	fsa9480_detect_dev(usbsw);
	
	// set fsa9480 init flag.
	if (usbsw->pdata->set_init_flag)
		usbsw->pdata->set_init_flag();

	return 0;

fail2:
	if (client->irq)
		free_irq(client->irq, usbsw);
fail1:
	i2c_set_clientdata(client, NULL);
	kfree(usbsw);
	return ret;
}

static int __devexit fsa9480_remove(struct i2c_client *client)
{
	struct fsa9480_usbsw *usbsw = i2c_get_clientdata(client);

	if (client->irq) {
		disable_irq_wake(client->irq);
		free_irq(client->irq, usbsw);
	}
	i2c_set_clientdata(client, NULL);

	sysfs_remove_group(&client->dev.kobj, &fsa9480_group);
	kfree(usbsw);
	return 0;
}

#ifdef CONFIG_PM

static int fsa9480_suspend(struct i2c_client *client, pm_message_t mesg)
{
#ifdef CONFIG_MACH_VICTORY 
	disable_irq(client->irq	);
#endif
	return 0;
}

static int fsa9480_resume(struct i2c_client *client)
{
	struct fsa9480_usbsw *usbsw = i2c_get_clientdata(client);

#ifdef CONFIG_MACH_VICTORY
	enable_irq(client->irq);
#endif
	/* device detection */
	fsa9480_detect_dev(usbsw);

	return 0;
}

#else

#define fsa9480_suspend NULL
#define fsa9480_resume NULL

#endif /* CONFIG_PM */

static const struct i2c_device_id fsa9480_id[] = {
	{"fsa9480", 0},
	{}
};
MODULE_DEVICE_TABLE(i2c, fsa9480_id);

static struct i2c_driver fsa9480_i2c_driver = {
	.driver = {
		.name = "fsa9480",
	},
	.probe = fsa9480_probe,
	.remove = __devexit_p(fsa9480_remove),
	.suspend = fsa9480_suspend,
	.resume = fsa9480_resume,
	.id_table = fsa9480_id,
};