static int sii8240_muic_get_charging_type(void) { #if defined(CONFIG_MFD_MAX77803) int muic_cable_type = max77803_muic_get_charging_type(); #elif defined(CONFIG_MFD_MAX77888) int muic_cable_type = max77888_muic_get_charging_type(); #elif defined(CONFIG_MFD_MAX77804K) int muic_cable_type = max77804k_muic_get_charging_type(); #else return 0; #endif #ifdef MFD_MAX778XX_COMMON pr_info("%s: muic cable_type = %d\n", __func__, muic_cable_type); switch (muic_cable_type) { case CABLE_TYPE_SMARTDOCK_MUIC: case CABLE_TYPE_SMARTDOCK_TA_MUIC: case CABLE_TYPE_SMARTDOCK_USB_MUIC: return -1; default: break; } return 1; #endif }
static int sii8240_muic_get_charging_type(void) { #ifdef CONFIG_EXTCON struct sii8240_platform_data *pdata = g_pdata; if(pdata->is_smartdock == true) return -1; else return 1; #else /* CONFIG_EXTCON */ #if defined(CONFIG_MFD_MAX77803) int muic_cable_type = max77803_muic_get_charging_type(); #elif defined(CONFIG_MFD_MAX77888) int muic_cable_type = max77888_muic_get_charging_type(); #elif defined(CONFIG_MFD_MAX77804K) int muic_cable_type = max77804k_muic_get_charging_type(); #else return 0; #endif #ifdef MFD_MAX778XX_COMMON pr_info("%s: muic cable_type = %d\n", __func__, muic_cable_type); switch (muic_cable_type) { case CABLE_TYPE_SMARTDOCK_MUIC: case CABLE_TYPE_SMARTDOCK_TA_MUIC: case CABLE_TYPE_SMARTDOCK_USB_MUIC: return -1; default: break; } return 1; #endif #endif /* CONFIG_EXTCON */ }
static void muic_mhl_cb(bool otg_enable, int plim) { union power_supply_propval value; int i, ret = 0; struct power_supply *psy; int current_cable_type = POWER_SUPPLY_TYPE_MISC; int sub_type = ONLINE_SUB_TYPE_MHL; int power_type = ONLINE_POWER_TYPE_UNKNOWN; int muic_cable_type = max77803_muic_get_charging_type(); pr_info("%s: muic cable_type = %d\n", __func__, muic_cable_type); switch (muic_cable_type) { case CABLE_TYPE_SMARTDOCK_MUIC: case CABLE_TYPE_SMARTDOCK_TA_MUIC: case CABLE_TYPE_SMARTDOCK_USB_MUIC: return; default: break; } pr_info("muic_mhl_cb:otg_enable=%d, plim=%d\n", otg_enable, plim); if (plim == 0x00) { pr_info("TA charger 500mA\n"); power_type = ONLINE_POWER_TYPE_MHL_500; } else if (plim == 0x01) { pr_info("TA charger 900mA\n"); power_type = ONLINE_POWER_TYPE_MHL_900; } else if (plim == 0x02) { pr_info("TA charger 1500mA\n"); power_type = ONLINE_POWER_TYPE_MHL_1500; } else if (plim == 0x03) { pr_info("USB charger\n"); power_type = ONLINE_POWER_TYPE_USB; } else current_cable_type = POWER_SUPPLY_TYPE_BATTERY; if (otg_enable) { psy_do_property("sec-charger", get, POWER_SUPPLY_PROP_ONLINE, value); pr_info("sec-charger : %d\n", value.intval); if (value.intval == POWER_SUPPLY_TYPE_BATTERY || value.intval == POWER_SUPPLY_TYPE_WPC) { if (!lpcharge) { otg_control(true); current_cable_type = POWER_SUPPLY_TYPE_BATTERY; power_type = ONLINE_POWER_TYPE_UNKNOWN; } } } else otg_control(false); for (i = 0; i < 10; i++) { psy = power_supply_get_by_name("battery"); if (psy) break; } if (i == 10) { pr_err("%s: fail to get battery ps\n", __func__); return; } value.intval = current_cable_type<<ONLINE_TYPE_MAIN_SHIFT | sub_type<<ONLINE_TYPE_SUB_SHIFT | power_type<<ONLINE_TYPE_PWR_SHIFT; ret = psy->set_property(psy, POWER_SUPPLY_PROP_ONLINE, &value); if (ret) { pr_err("%s: fail to set power_suppy ONLINE property(%d)\n", __func__, ret); } }
/* 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__); } }