static void tsu6721_init_detect(struct work_struct *work)
{
	struct tsu6721_usbsw *usbsw = container_of(work,
			struct tsu6721_usbsw, init_work.work);
	int ret = 0;

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

	mutex_lock(&usbsw->mutex);
	tsu6721_attach_dev(usbsw);
	mutex_unlock(&usbsw->mutex);

	ret = tsu6721_irq_init(usbsw);
	if (ret)
		dev_info(&usbsw->client->dev,
				"failed to enable  irq init %s\n", __func__);

	ret = i2c_smbus_read_byte_data(usbsw->client, REG_INT1);
	dev_info(&usbsw->client->dev, "%s: intr1 : 0x%x\n",
		__func__, ret);
	local_usbsw->last_state.int1 = ret;

	ret = i2c_smbus_read_byte_data(usbsw->client, REG_INT2);
	dev_info(&usbsw->client->dev, "%s: intr2 : 0x%x\n",
		__func__, ret);
	local_usbsw->last_state.int2 = ret;
}
static int tsu6721_resume(struct i2c_client *client)
{
	struct tsu6721_usbsw *usbsw = i2c_get_clientdata(client);

	i2c_smbus_read_byte_data(client, REG_INT1);
	i2c_smbus_read_byte_data(client, REG_INT2);

	/* device detection */
	mutex_lock(&usbsw->mutex);
	tsu6721_attach_dev(usbsw);
	mutex_unlock(&usbsw->mutex);

	return 0;
}
static ssize_t tsu6721_set_apo_factory(struct device *dev,
					  struct device_attribute *attr,
					  const char *buf, size_t count)
{
	struct tsu6721_usbsw *usbsw = dev_get_drvdata(dev);

	pr_info("%s buf:%s\n", __func__, buf);

	/* "FACTORY_START": factory mode */
	if (!strncmp(buf, "FACTORY_START", 13)) {
		usbsw->is_factory_start = true;
		pr_info("%s FACTORY_MODE\n", __func__);
		tsu6721_attach_dev(usbsw);
	} else {
		pr_warn("%s Wrong command\n", __func__);
		return count;
	}

	return count;
}
static irqreturn_t tsu6721_irq_thread(int irq, void *data)
{
	struct tsu6721_usbsw *usbsw = data;
	struct i2c_client *client = usbsw->client;
	int intr1, intr2;
	int val1, val2, val3, adc;
	/* TSU6721 : Read interrupt -> Read Device */
	pr_info("tsu6721_irq_thread is called\n");

	/* device detection */
	mutex_lock(&usbsw->mutex);
	tsu6721_disable_interrupt();
	intr1 = i2c_smbus_read_byte_data(client, REG_INT1);
	intr2 = i2c_smbus_read_byte_data(client, REG_INT2);
	dev_info(&client->dev, "%s: intr : 0x%x intr2 : 0x%x\n",
		__func__, intr1, intr2);

	local_usbsw->last_state.int1 = intr1;
	local_usbsw->last_state.int2 = intr2;

	if ((intr1 + intr2) == DATA_NONE) {
		val1 = i2c_smbus_read_byte_data(client, REG_DEVICE_TYPE1);
		val2 = i2c_smbus_read_byte_data(client, REG_DEVICE_TYPE2);
		val3 = i2c_smbus_read_byte_data(client, REG_DEVICE_TYPE3);
		adc = i2c_smbus_read_byte_data(client, REG_ADC);
		if (((val1 + val2 + val3) == DATA_NONE) && (adc == ADC_OPEN))
			tsu6721_detach_dev(usbsw);
		else
			tsu6721_attach_dev(usbsw);
	}

	/* MUIC OVP Check */
	if (intr1 & INT_OVP_ENABLE)
		usbsw->pdata->oxp_callback(ENABLE);
	else if (intr1 & INT_OXP_DISABLE)
		usbsw->pdata->oxp_callback(DISABLE);
	msleep(20);

	/* interrupt both attach and detach */
	if (intr1 == (INT_ATTACH + INT_DETACH)) {
		val1 = i2c_smbus_read_byte_data(client, REG_DEVICE_TYPE1);
		val3 = i2c_smbus_read_byte_data(client, REG_DEVICE_TYPE3);
		adc = i2c_smbus_read_byte_data(client, REG_ADC);
		if ((adc == ADC_OPEN) && (val1 == DATA_NONE) &&
				((val3 == DATA_NONE) ||
				 (val3 == DEV_VBUS_DEBOUNCE)))
			tsu6721_detach_dev(usbsw);
		else
			tsu6721_attach_dev(usbsw);
	/* interrupt attach */
	} else if (intr1 & INT_ATTACH || intr2 &
			(INT_AV_CHANGE | INT_RESERVED_ATTACH))
		tsu6721_attach_dev(usbsw);
	/* interrupt detach */
	else if (intr1 & INT_DETACH)
		tsu6721_detach_dev(usbsw);

	tsu6721_enable_interrupt();
	mutex_unlock(&usbsw->mutex);

	return IRQ_HANDLED;
}