/* usb cable call back function */ void max77803_muic_usb_cb(u8 usb_mode) { #ifdef CONFIG_USB_HOST_NOTIFY struct host_notifier_platform_data *host_noti_pdata = host_notifier_device.dev.platform_data; #endif #ifdef CONFIG_TARGET_LOCALE_KOR if (is_usb_locked) { pr_info("%s: usb locked by mdm\n", __func__); return; } #endif if (usb_mode == USB_CABLE_ATTACHED) { #ifdef CONFIG_MFD_MAX77803 g_usbvbus = USB_CABLE_ATTACHED; #endif max77803_set_vbus_state(USB_CABLE_ATTACHED); pr_info("%s - USB_CABLE_ATTACHED\n", __func__); } else if (usb_mode == USB_CABLE_DETACHED) { #ifdef CONFIG_MFD_MAX77803 g_usbvbus = USB_CABLE_DETACHED; #endif max77803_set_vbus_state(USB_CABLE_DETACHED); pr_info("%s - USB_CABLE_DETACHED\n", __func__); } else if (usb_mode == USB_OTGHOST_ATTACHED) { #ifdef CONFIG_USB_HOST_NOTIFY host_noti_pdata->booster(1); host_noti_pdata->ndev.mode = NOTIFY_HOST_MODE; if (host_noti_pdata->usbhostd_start) host_noti_pdata->usbhostd_start(); #endif #if defined(CONFIG_MACH_J_CHN_CTC) /* defense code for otg mis-detecing issue */ msleep(40); #endif max77803_check_id_state(0); pr_info("%s - USB_OTGHOST_ATTACHED\n", __func__); } else if (usb_mode == USB_OTGHOST_DETACHED) { max77803_check_id_state(1); #ifdef CONFIG_USB_HOST_NOTIFY host_noti_pdata->ndev.mode = NOTIFY_NONE_MODE; if (host_noti_pdata->usbhostd_stop) host_noti_pdata->usbhostd_stop(); host_noti_pdata->booster(0); #endif pr_info("%s - USB_OTGHOST_DETACHED\n", __func__); } else if (usb_mode == USB_POWERED_HOST_ATTACHED) { #ifdef CONFIG_USB_HOST_NOTIFY host_noti_pdata->powered_booster(1); start_usbhostd_wakelock(); #endif max77803_check_id_state(0); pr_info("%s - USB_POWERED_HOST_ATTACHED\n", __func__); } else if (usb_mode == USB_POWERED_HOST_DETACHED) { max77803_check_id_state(1); #ifdef CONFIG_USB_HOST_NOTIFY host_noti_pdata->powered_booster(0); stop_usbhostd_wakelock(); #endif pr_info("%s - USB_POWERED_HOST_DETACHED\n", __func__); } }
/* usb cable call back function */ void max77803_muic_usb_cb(u8 usb_mode) { #ifdef CONFIG_USB_HOST_NOTIFY struct host_notifier_platform_data *host_noti_pdata = host_notifier_device.dev.platform_data; int cable_type = max77803_muic_get_charging_type(); #endif if (is_usb_locked) { pr_info("%s: usb locked by mdm\n", __func__); return; } if (usb_mode == USB_CABLE_ATTACHED) { #if defined(CONFIG_MFD_MAX77803) || defined(CONFIG_MFD_MAX77888) g_usbvbus = USB_CABLE_ATTACHED; #endif #ifdef CONFIG_HA_3G if(system_rev >= 6) usb30_redriver_en(1); #elif defined(CONFIG_V1A) || defined(CONFIG_V2A) usb30_redriver_en(1); #endif max77803_set_vbus_state(USB_CABLE_ATTACHED); pr_info("%s - USB_CABLE_ATTACHED\n", __func__); } else if (usb_mode == USB_CABLE_DETACHED) { #if defined(CONFIG_MFD_MAX77803) || defined(CONFIG_MFD_MAX77888) g_usbvbus = USB_CABLE_DETACHED; #endif #ifdef CONFIG_USB_ANDROID_SAMSUNG_COMPOSITE #ifdef CONFIG_HA_3G usb30en = 0; #endif #endif #ifdef CONFIG_HA_3G if(system_rev >= 6) usb30_redriver_en(0); #elif defined(CONFIG_V1A) || defined(CONFIG_V2A) usb30_redriver_en(0); #endif max77803_set_vbus_state(USB_CABLE_DETACHED); pr_info("%s - USB_CABLE_DETACHED\n", __func__); } else if (usb_mode == USB_OTGHOST_ATTACHED) { #ifdef CONFIG_USB_HOST_NOTIFY host_noti_pdata->booster(1); host_noti_pdata->ndev.mode = NOTIFY_HOST_MODE; if (host_noti_pdata->usbhostd_start) host_noti_pdata->usbhostd_start(); /* defense code for otg mis-detecing issue */ msleep(50); #endif max77803_check_id_state(0); pr_info("%s - USB_OTGHOST_ATTACHED\n", __func__); } else if (usb_mode == USB_OTGHOST_DETACHED) { max77803_check_id_state(1); #ifdef CONFIG_USB_HOST_NOTIFY host_noti_pdata->ndev.mode = NOTIFY_NONE_MODE; if (host_noti_pdata->usbhostd_stop) host_noti_pdata->usbhostd_stop(); host_noti_pdata->booster(0); #endif pr_info("%s - USB_OTGHOST_DETACHED\n", __func__); } else if (usb_mode == USB_POWERED_HOST_ATTACHED) { #ifdef CONFIG_USB_HOST_NOTIFY host_noti_pdata->powered_booster(1); if (cable_type == CABLE_TYPE_MMDOCK_MUIC) { enable_ovc(1); host_state_notify(&host_noti_pdata->ndev, NOTIFY_HOST_NONE); } if (cable_type == CABLE_TYPE_LANHUB_MUIC) { host_noti_pdata->ndev.mode = NOTIFY_HOST_MODE; if (host_noti_pdata->usbhostd_start) host_noti_pdata->usbhostd_start(); } else start_usbhostd_wakelock(); #endif max77803_check_id_state(0); pr_info("%s - USB_POWERED_HOST_ATTACHED\n", __func__); } else if (usb_mode == USB_POWERED_HOST_DETACHED) { max77803_check_id_state(1); #ifdef CONFIG_USB_HOST_NOTIFY host_noti_pdata->powered_booster(0); if (cable_type == CABLE_TYPE_MMDOCK_MUIC) { enable_ovc(0); } if (host_noti_pdata->ndev.mode == NOTIFY_HOST_MODE) { host_noti_pdata->ndev.mode = NOTIFY_NONE_MODE; if (host_noti_pdata->usbhostd_stop) host_noti_pdata->usbhostd_stop(); } else stop_usbhostd_wakelock(); #endif pr_info("%s - USB_POWERED_HOST_DETACHED\n", __func__); } }
/* usb cable call back function */ void max77803_muic_usb_cb(u8 usb_mode) { #ifdef CONFIG_USB_HOST_NOTIFY struct host_notifier_platform_data *host_noti_pdata = host_notifier_device.dev.platform_data; #endif #ifdef CONFIG_USB_GADGET_SWITCH struct usb_gadget *gadget = platform_get_drvdata(&s3c_device_usb_hsotg); int g_state; #endif printk(KERN_ERR "%s - %d\n", __func__, __LINE__); if (usb_mode == USB_CABLE_ATTACHED) { #ifdef CONFIG_USB_GADGET_SWITCH g_state = usb_gadget_vbus_connect(gadget); if (g_state < 0) { pr_err("%s:gadget_vbus connect failed(%d)\n", __func__, g_state); return; } #endif #ifdef CONFIG_MFD_MAX77803 g_usbvbus = USB_CABLE_ATTACHED; #endif max77803_set_vbus_state(USB_CABLE_ATTACHED); pr_info("%s - USB_CABLE_ATTACHED\n", __func__); #ifdef CONFIG_SWITCH switch_set_state(&switch_usb, usb_mode); #endif } else if (usb_mode == USB_CABLE_DETACHED) { #ifdef CONFIG_MFD_MAX77803 g_usbvbus = USB_CABLE_DETACHED; #endif max77803_set_vbus_state(USB_CABLE_DETACHED); pr_info("%s - USB_CABLE_DETACHED\n", __func__); #ifdef CONFIG_SWITCH switch_set_state(&switch_usb, usb_mode); #endif #ifdef CONFIG_USB_GADGET_SWITCH g_state = usb_gadget_vbus_disconnect(gadget); if (g_state < 0) { pr_err("%s:gadget_vbus disconnect failed(%d)\n", __func__, g_state); } #endif } else if (usb_mode == USB_OTGHOST_ATTACHED) { #ifdef CONFIG_USB_HOST_NOTIFY host_noti_pdata->booster(1); host_noti_pdata->ndev.mode = NOTIFY_HOST_MODE; if (host_noti_pdata->usbhostd_start) host_noti_pdata->usbhostd_start(); /* defense code for otg mis-detecing issue */ msleep(50); #endif max77803_check_id_state(0); pr_err("%s - USB_OTGHOST_ATTACHED\n", __func__); } else if (usb_mode == USB_OTGHOST_DETACHED) { max77803_check_id_state(1); #ifdef CONFIG_USB_HOST_NOTIFY host_noti_pdata->ndev.mode = NOTIFY_NONE_MODE; if (host_noti_pdata->usbhostd_stop) host_noti_pdata->usbhostd_stop(); host_noti_pdata->booster(0); #endif pr_err("%s - USB_OTGHOST_DETACHED\n", __func__); } else if (usb_mode == USB_POWERED_HOST_ATTACHED) { #ifdef CONFIG_USB_HOST_NOTIFY host_noti_pdata->powered_booster(1); start_usbhostd_wakelock(); #endif max77803_check_id_state(0); pr_info("%s - USB_POWERED_HOST_ATTACHED\n", __func__); } else if (usb_mode == USB_POWERED_HOST_DETACHED) { max77803_check_id_state(1); #ifdef CONFIG_USB_HOST_NOTIFY host_noti_pdata->powered_booster(0); stop_usbhostd_wakelock(); #endif pr_info("%s - USB_POWERED_HOST_DETACHED\n", __func__); } }