コード例 #1
0
static int tsu6721_detach_dev(struct tsu6721_usbsw *usbsw)
{
	struct tsu6721_platform_data *pdata = usbsw->pdata;

	/* USB */
	if (usbsw->dev1 & DEV_USB ||
			usbsw->dev2 & DEV_T2_USB_MASK) {
		pr_info("[MUIC] USB Disonnected\n");
		pdata->callback(CABLE_TYPE_USB, TSU6721_DETACHED);
		local_usbsw->last_state.detach = USB_CALL;
	/* CDP */
	} else if (usbsw->dev1 & DEV_USB_CHG) {
		pr_info("[MUIC] CDP Disconnected\n");
		pdata->callback(CABLE_TYPE_CDP, TSU6721_DETACHED);
		local_usbsw->last_state.detach = CDP_CALL;
	/* UART */
	} else if (usbsw->dev1 & DEV_T1_UART_MASK ||
			usbsw->dev2 & DEV_T2_UART_MASK) {
		pr_info("[MUIC] UART Disonnected\n");
#ifndef CONFIG_MACH_LT02
		pdata->callback(CABLE_TYPE_UARTOFF, TSU6721_DETACHED);
#endif
		local_usbsw->last_state.detach = UART_CALL;
		uart_connecting = 0;
	/* CHARGER */
	} else if ((usbsw->dev1 & DEV_T1_CHARGER_MASK) ||
			(usbsw->dev3 & DEV_T3_CHARGER_MASK)) {
		pr_info("[MUIC] Charger Disonnected\n");
		pdata->callback(CABLE_TYPE_AC, TSU6721_DETACHED);
		local_usbsw->last_state.detach = CHARGER_CALL;
#if defined(CONFIG_USB_HOST_NOTIFY)
	/* for SAMSUNG OTG */
	} else if (usbsw->dev1 & DEV_USB_OTG) {
		pr_info("[MUIC] OTG Disonnected\n");
		tsu6721_set_otg(usbsw, TSU6721_DETACHED);
		pdata->callback(CABLE_TYPE_OTG, TSU6721_DETACHED);
		local_usbsw->last_state.detach = OTG_CALL;
#endif
	/* JIG */
	} else if (usbsw->dev2 & DEV_T2_JIG_MASK) {
		pr_info("[MUIC] JIG Disonnected\n");
		pdata->callback(CABLE_TYPE_JIG, TSU6721_DETACHED);
		local_usbsw->last_state.detach = JIG_CALL;
	/* Desk Dock */
	} else if ((usbsw->dev2 & DEV_AV) ||
	(usbsw->dev3 & DEV_AV_VBUS)) {
		pr_info("[MUIC] Deskdock Disonnected\n");
		local_usbsw->dock_attached = TSU6721_DETACHED;
		tsu6721_dock_control(usbsw, CABLE_TYPE_DESK_DOCK,
			TSU6721_DETACHED, SW_ALL_OPEN);
		local_usbsw->last_state.detach = DESKDOCK_CALL;
#if defined(CONFIG_MHL_D3_SUPPORT)
	/* MHL */
	} else if (usbsw->dev3 & DEV_MHL) {
		pr_info("[MUIC] MHL Disonnected\n");
		mhl_onoff_ex(false);
		local_usbsw->last_state.detach = MHL_CALL;
		detached_status = 1;
#endif
	/* Car Dock */
	} else if (usbsw->dev2 & DEV_JIG_UART_ON) {
		pr_info("[MUIC] Cardock Disonnected\n");
		local_usbsw->dock_attached = TSU6721_DETACHED;
		tsu6721_dock_control(usbsw, CABLE_TYPE_CARDOCK,
			TSU6721_DETACHED, SW_ALL_OPEN);
		local_usbsw->last_state.detach = CARDOCK_CALL;
	/* Smart Dock */
	} else if (usbsw->dev2 == DEV_SMARTDOCK) {
		pr_info("[MUIC] Smartdock Disonnected\n");
		tsu6721_dock_control(usbsw, CABLE_TYPE_SMART_DOCK,
			TSU6721_DETACHED, SW_ALL_OPEN);
		local_usbsw->last_state.detach = SMARTDOCK_CALL;
#if defined(CONFIG_VIDEO_MHL_V2)
		mhl_onoff_ex(false);
#endif
#if defined(CONFIG_USB_HOST_NOTIFY)
	/* Audio Dock */
	} else if (usbsw->dev2 == DEV_AUDIO_DOCK) {
		pr_info("[MUIC] Audiodock Disonnected\n");
		tsu6721_dock_control(usbsw, CABLE_TYPE_AUDIO_DOCK,
			TSU6721_DETACHED, SW_ALL_OPEN);
		local_usbsw->last_state.detach = AUDIODOCK_CALL;
#endif
	/*LG cable support*/
	} else if (usbsw->dev2 == DEV_LG_CABLE) {
		pr_info("[MUIC] LG Data Cable Disconnected \n");
		pdata->callback(CABLE_TYPE_USB, TSU6721_DETACHED);
	/* Incompatible */
	} else if (usbsw->dev3 & DEV_VBUS_DEBOUNCE) {
		pr_info("[MUIC] Incompatible Charger Disonnected\n");
		pdata->callback(CABLE_TYPE_INCOMPATIBLE,
				TSU6721_DETACHED);
		local_usbsw->last_state.detach = INCOMPATIBLE_CALL;
	}
	usbsw->dev1 = 0;
	usbsw->dev2 = 0;
	usbsw->dev3 = 0;
	usbsw->adc = 0;

	return 0;

}
コード例 #2
0
static int tsu6721_attach_dev(struct tsu6721_usbsw *usbsw)
{
	int adc;
	int val1, val2, val3;
	struct tsu6721_platform_data *pdata = usbsw->pdata;
	struct i2c_client *client = usbsw->client;
#if defined(CONFIG_VIDEO_MHL_V2)
	/*u8 mhl_ret = 0;*/
#endif
#if defined(CONFIG_TOUCHSCREEN_MMS144)
	int tsp_noti_ignore = 0;
#endif
	val1 = i2c_smbus_read_byte_data(client, REG_DEVICE_TYPE1);
	if (val1 < 0) {
		dev_err(&client->dev, "%s: err %d\n", __func__, val1);
		return val1;
	}

	val2 = i2c_smbus_read_byte_data(client, REG_DEVICE_TYPE2);
	if (val2 < 0) {
		dev_err(&client->dev, "%s: err %d\n", __func__, val2);
		return val2;
	}
	jig_state =  (val2 & DEV_T2_JIG_ALL_MASK) ? 1 : 0;

	val3 = i2c_smbus_read_byte_data(client, REG_DEVICE_TYPE3);
	if (val3 < 0) {
		dev_err(&client->dev, "%s: err %d\n", __func__, val3);
		return val3;
	}
	adc = i2c_smbus_read_byte_data(client, REG_ADC);

	if (adc == ADC_SMART_DOCK) {
		val2 = DEV_SMARTDOCK;
		val1 = 0;
	}
#if defined(CONFIG_USB_HOST_NOTIFY)
	if (adc == 0x11 || adc == ADC_AUDIO_DOCK) {
		val2 = DEV_AUDIO_DOCK;
		val1 = 0;
	}
#endif
	if (adc == ADC_LG_CABLE) {
		val2 = DEV_LG_CABLE;
		val1 = 0;
	}
	dev_err(&client->dev,
			"dev1: 0x%x, dev2: 0x%x, dev3: 0x%x, ADC: 0x%x Jig:%s\n",
			val1, val2, val3, adc,
			(check_jig_state() ? "ON" : "OFF"));

	/* USB */
	if (val1 & DEV_USB || val2 & DEV_T2_USB_MASK) {
		pr_info("[MUIC] USB Connected\n");
		pdata->callback(CABLE_TYPE_USB, TSU6721_ATTACHED);
	/* USB_CDP */
	} else if (val1 & DEV_USB_CHG) {
		pr_info("[MUIC] CDP Connected\n");
		pdata->callback(CABLE_TYPE_CDP, TSU6721_ATTACHED);
	/* UART FACTORY JIG CASE*/
	} else if (val1 & DEV_T1_UART_MASK || val2 & DEV_T2_UART_MASK) {
		uart_connecting = 1;
		pr_info("[MUIC] UART Connected\n");
		if((adc == ADC_JIG_UART_OFF) && (val3 & DEV_VBUS_DEBOUNCE))
			pdata->callback(CABLE_TYPE_JIG_UART_OFF_VB, TSU6721_ATTACHED);
		else
			pdata->callback(CABLE_TYPE_UARTOFF, TSU6721_ATTACHED);
#if (!defined(CONFIG_MACH_CT01) && !defined(CONFIG_MACH_CT01_CHN_CU))
		flash_control(true);
#endif
	/* CHARGER */
	} else if ((val1 & DEV_T1_CHARGER_MASK) ||
			(val3 & DEV_T3_CHARGER_MASK)) {
		pr_info("[MUIC] Charger Connected\n");
		pdata->callback(CABLE_TYPE_AC, TSU6721_ATTACHED);
#if defined(CONFIG_USB_HOST_NOTIFY)
	/* for SAMSUNG OTG */
	} else if (val1 & DEV_USB_OTG) {
		pr_info("[MUIC] OTG Connected\n");
		tsu6721_set_otg(usbsw, TSU6721_ATTACHED);
		pdata->callback(CABLE_TYPE_OTG, TSU6721_ATTACHED);
#endif
	/* JIG */
	} else if (val2 & DEV_T2_JIG_MASK) {
		pr_info("[MUIC] JIG Connected\n");
		pdata->callback(CABLE_TYPE_JIG, TSU6721_ATTACHED);
#if (!defined(CONFIG_MACH_CT01) && !defined(CONFIG_MACH_CT01_CHN_CU))
		flash_control(true);
#endif
	/* Desk Dock */
	} else if ((val2 & DEV_AV) || (val3 & DEV_AV_VBUS)) {
		pr_info("[MUIC] Deskdock Connected\n");
		local_usbsw->dock_attached = TSU6721_ATTACHED;
		if(val3 & DEV_VBUS_DEBOUNCE)
			tsu6721_dock_control(usbsw, CABLE_TYPE_DESK_DOCK,
				TSU6721_ATTACHED, SW_AUDIO);
		else
			tsu6721_dock_control(usbsw, CABLE_TYPE_DESK_DOCK_NO_VB,
				TSU6721_ATTACHED, SW_AUDIO);
#if defined(CONFIG_VIDEO_MHL_V2)
	/* MHL */
	} else if (val3 & DEV_MHL) {
		pr_info("[MUIC] MHL Connected\n");
		tsu6721_disable_interrupt();
		if (!poweroff_charging)
			/*mhl_ret = mhl_onoff_ex(1); support from sii8240*/
		else
			pr_info("LPM mode, skip MHL sequence\n");
		tsu6721_enable_interrupt();
#endif
	/* Car Dock */
	} else if (val2 & DEV_JIG_UART_ON) {
コード例 #3
0
static int tsu6721_attach_dev(struct tsu6721_usbsw *usbsw)
{
	int adc;
	int val1, val2, val3;
	struct tsu6721_platform_data *pdata = usbsw->pdata;
	struct i2c_client *client = usbsw->client;
#if defined(CONFIG_VIDEO_MHL_V2)
	u8 mhl_ret = 0;
#endif
	val1 = i2c_smbus_read_byte_data(client, REG_DEVICE_TYPE1);
	if (val1 < 0) {
		dev_err(&client->dev, "%s: err %d\n", __func__, val1);
		return val1;
	}

	val2 = i2c_smbus_read_byte_data(client, REG_DEVICE_TYPE2);
	if (val2 < 0) {
		dev_err(&client->dev, "%s: err %d\n", __func__, val2);
		return val2;
	}
	jig_state =  (val2 & DEV_T2_JIG_ALL_MASK) ? 1 : 0;

	val3 = i2c_smbus_read_byte_data(client, REG_DEVICE_TYPE3);
	if (val3 < 0) {
		dev_err(&client->dev, "%s: err %d\n", __func__, val3);
		return val3;
	}
	adc = i2c_smbus_read_byte_data(client, REG_ADC);

	if (adc == ADC_SMART_DOCK) {
		val2 = DEV_SMARTDOCK;
		val1 = 0;
	}
#if defined(CONFIG_USB_HOST_NOTIFY)
	if (adc == 0x11 || adc == ADC_AUDIO_DOCK) {
		val2 = DEV_AUDIO_DOCK;
		val1 = 0;
	}
#endif
	if (adc == ADC_LG_CABLE) {
		val2 = DEV_LG_CABLE;
		val1 = 0;
	}
	if ((val1 & DEV_USB || val1 & DEV_USB_CHG ||
			val1 & DEV_T1_CHARGER_MASK) &&
			!(val3 & DEV_VBUS_DEBOUNCE)) {
		pr_info("%s Attach USB or Charger but not include VBUS",
				__func__);
		return 0;
	}

	dev_err(&client->dev,
			"dev1: 0x%x, dev2: 0x%x, dev3: 0x%x, ADC: 0x%x Jig:%s\n",
			val1, val2, val3, adc,
			(check_jig_state() ? "ON" : "OFF"));

	if ((val1+val2+val3 != 0)) {
		pr_info("%s Save state\n", __func__);
		local_usbsw->last_state.dev1 = val1;
		local_usbsw->last_state.dev2 = val2;
		local_usbsw->last_state.dev3 = val3;
	}

	/* USB */
	if (val1 & DEV_USB || val2 & DEV_T2_USB_MASK) {
		pr_info("[MUIC] USB Connected\n");
		pdata->callback(CABLE_TYPE_USB, TSU6721_ATTACHED);
		local_usbsw->last_state.attach = USB_CALL;
	/* USB_CDP */
	} else if (val1 & DEV_USB_CHG) {
		pr_info("[MUIC] CDP Connected\n");
		pdata->callback(CABLE_TYPE_CDP, TSU6721_ATTACHED);
		local_usbsw->last_state.attach = CDP_CALL;
	/* UART */
	} else if (val1 & DEV_T1_UART_MASK || val2 & DEV_T2_UART_MASK) {
		uart_connecting = 1;
		pr_info("[MUIC] UART Connected\n");
#ifndef CONFIG_MACH_LT02
		pdata->callback(CABLE_TYPE_UARTOFF, TSU6721_ATTACHED);
#endif
		local_usbsw->last_state.detach = UART_CALL;
	/* CHARGER */
	} else if ((val1 & DEV_T1_CHARGER_MASK) ||
			(val3 & DEV_T3_CHARGER_MASK)) {
		pr_info("[MUIC] Charger Connected\n");
		pdata->callback(CABLE_TYPE_AC, TSU6721_ATTACHED);
		local_usbsw->last_state.attach = CHARGER_CALL;
#if defined(CONFIG_USB_HOST_NOTIFY)
	/* for SAMSUNG OTG */
	} else if (val1 & DEV_USB_OTG) {
		pr_info("[MUIC] OTG Connected\n");
		tsu6721_set_otg(usbsw, TSU6721_ATTACHED);
		pdata->callback(CABLE_TYPE_OTG, TSU6721_ATTACHED);
		local_usbsw->last_state.attach = OTG_CALL;
#endif
	/* JIG */
	} else if (val2 & DEV_T2_JIG_MASK) {
		pr_info("[MUIC] JIG Connected\n");
		pdata->callback(CABLE_TYPE_JIG, TSU6721_ATTACHED);
		local_usbsw->last_state.attach = JIG_CALL;
	/* Desk Dock */
	} else if ((val2 & DEV_AV) || (val3 & DEV_AV_VBUS)) {
		pr_info("[MUIC] Deskdock Connected\n");
		local_usbsw->dock_attached = TSU6721_ATTACHED;
		tsu6721_dock_control(usbsw, CABLE_TYPE_DESK_DOCK,
			TSU6721_ATTACHED, SW_AUDIO);
		local_usbsw->last_state.attach = DESKDOCK_CALL;

#if defined(CONFIG_VIDEO_MHL_V2)
	/* MHL */
	} else if (val3 & DEV_MHL) {
		pr_info("[MUIC] MHL Connected\n");
		tsu6721_disable_interrupt();
		if (!poweroff_charging) {
			mhl_ret = mhl_onoff_ex(1);
			local_usbsw->last_state.attach = MHL_CALL;
		} else
			pr_info("LPM mode, skip MHL sequence\n");
		tsu6721_enable_interrupt();
#endif
	/* Car Dock */
	} else if (val2 & DEV_JIG_UART_ON) {
		pr_info("[MUIC] Cardock Connected\n");
		local_usbsw->dock_attached = TSU6721_ATTACHED;
		tsu6721_dock_control(usbsw, CABLE_TYPE_CARDOCK,
			TSU6721_ATTACHED, SW_AUDIO);
		local_usbsw->last_state.attach = CARDOCK_CALL;
	/* SmartDock */
	} else if (val2 & DEV_SMARTDOCK) {
		pr_info("[MUIC] Smartdock Connected\n");
		tsu6721_dock_control(usbsw, CABLE_TYPE_SMART_DOCK,
			TSU6721_ATTACHED, SW_DHOST);
		local_usbsw->last_state.attach = SMARTDOCK_CALL;
#if defined(CONFIG_VIDEO_MHL_V2)
		mhl_onoff_ex(1);
#endif
#if defined(CONFIG_USB_HOST_NOTIFY)
	/* Audio Dock */
	} else if (val2 & DEV_AUDIO_DOCK) {
		pr_info("[MUIC] Audiodock Connected\n");
		tsu6721_dock_control(usbsw, CABLE_TYPE_AUDIO_DOCK,
			TSU6721_ATTACHED, SW_DHOST);
		local_usbsw->last_state.attach = AUDIODOCK_CALL;
#endif
	/*LG cable support*/
	} else if (val2 & DEV_LG_CABLE) {
		pr_info("[MUIC] LG Data Cable connected \n");
		pdata->callback(CABLE_TYPE_USB, TSU6721_ATTACHED);
	/* Incompatible */
	} else if (val3 & DEV_VBUS_DEBOUNCE) {
		pr_info("[MUIC] Incompatible Charger Connected\n");
		pdata->callback(CABLE_TYPE_INCOMPATIBLE,
				TSU6721_ATTACHED);
		local_usbsw->last_state.attach = INCOMPATIBLE_CALL;
	}
	usbsw->dev1 = val1;
	usbsw->dev2 = val2;
	usbsw->dev3 = val3;
	usbsw->adc = adc;

	return adc;
}