static int detach_usb(struct tsu6721_muic_data *muic_data) { struct muic_platform_data *pdata = muic_data->pdata; /* struct sec_switch_data *switch_data = muic_data->switch_data; */ int ret = 0; pr_info("%s:%s attached_dev type(%d)\n", MUIC_DEV_NAME, __func__, muic_data->attached_dev); ret = detach_charger(muic_data); if (ret) return ret; ret = com_to_open(muic_data); if (ret) return ret; muic_data->attached_dev = ATTACHED_DEV_NONE_MUIC; if (pdata->usb_path == MUIC_PATH_USB_CP) return ret; /* if ((pdata->usb_path == MUIC_PATH_USB_AP) && (switch_data->usb_cb) && (muic_data->is_usb_ready)) switch_data->usb_cb(USB_CABLE_DETACHED); */ return ret; }
static int max14577_muic_logically_detach(struct max14577_muic_data *muic_data, muic_attached_dev_t new_dev) { bool force_path_open = true; int ret = 0; switch (muic_data->attached_dev) { case ATTACHED_DEV_USB_MUIC: case ATTACHED_DEV_CDP_MUIC: case ATTACHED_DEV_TA_MUIC: case ATTACHED_DEV_JIG_USB_ON_MUIC: #if defined(CONFIG_SEC_FACTORY_MODE) case ATTACHED_DEV_JIG_UART_ON_MUIC: #endif /* CONFIG_SEC_FACTORY_MODE */ #if defined(CONFIG_MUIC_SUPPORT_FACTORY_BUTTON) case ATTACHED_DEV_FACTORY_BUTTON: #endif /* CONFIG_MUIC_SUPPORT_FACTORY_BUTTON */ #if defined(CONFIG_MUIC_SUPPORT_POGO_TA) case ATTACHED_DEV_POGO_TA_MUIC: #endif /* CONFIG_MUIC_SUPPORT_POGO_TA */ #if defined(CONFIG_MUIC_SUPPORT_POGO_USB) case ATTACHED_DEV_POGO_USB_MUIC: #endif /* CONFIG_MUIC_SUPPORT_POGO_USB */ break; case ATTACHED_DEV_JIG_UART_OFF_MUIC: if (new_dev == ATTACHED_DEV_JIG_UART_OFF_VB_MUIC) force_path_open = false; break; case ATTACHED_DEV_JIG_UART_OFF_VB_MUIC: if (new_dev == ATTACHED_DEV_JIG_UART_OFF_MUIC) force_path_open = false; break; case ATTACHED_DEV_UNKNOWN_MUIC: if (new_dev == ATTACHED_DEV_JIG_UART_OFF_MUIC) force_path_open = false; break; case ATTACHED_DEV_NONE_MUIC: goto out; default: pr_warn("%s:%s try to attach without logically detach\n", MUIC_DEV_NAME, __func__); goto out; } pr_info("%s:%s attached(%d)!=new(%d), assume detach\n", MUIC_DEV_NAME, __func__, muic_data->attached_dev, new_dev); max14577_muic_force_detach(muic_data); if (force_path_open) ret = com_to_open(muic_data); out: return ret; }
static int max14577_muic_handle_detach(struct max14577_muic_data *muic_data) { int ret = 0; /* Enable Factory Accessory Detection State Machine */ max14577_muic_enable_accdet(muic_data); max14577_muic_force_detach(muic_data); ret = com_to_open(muic_data); return ret; }
static void tsu6721_muic_handle_detach(struct tsu6721_muic_data *muic_data) { int ret; bool noti = true; ret = com_to_open(muic_data); switch (muic_data->attached_dev) { case ATTACHED_DEV_JIG_USB_OFF_MUIC: case ATTACHED_DEV_JIG_USB_ON_MUIC: case ATTACHED_DEV_USB_MUIC: case ATTACHED_DEV_CDP_MUIC: ret = detach_usb(muic_data); break; case ATTACHED_DEV_OTG_MUIC: ret = detach_usb(muic_data); break; case ATTACHED_DEV_TA_MUIC: ret = com_to_iset(muic_data, false); ret = detach_charger(muic_data); break; case ATTACHED_DEV_JIG_UART_OFF_VB_MUIC: case ATTACHED_DEV_JIG_UART_OFF_MUIC: ret = detach_jig_uart_boot_off(muic_data); break; case ATTACHED_DEV_NONE_MUIC: pr_info("%s:%s duplicated(NONE)\n", MUIC_DEV_NAME, __func__); break; case ATTACHED_DEV_UNKNOWN_MUIC: case ATTACHED_DEV_UNKNOWN_VB_MUIC: pr_info("%s:%s UNKNOWN\n", MUIC_DEV_NAME, __func__); ret = detach_charger(muic_data); muic_data->attached_dev = ATTACHED_DEV_NONE_MUIC; break; default: pr_info("%s:%s invalid attached_dev type(%d)\n", MUIC_DEV_NAME, __func__, muic_data->attached_dev); muic_data->attached_dev = ATTACHED_DEV_NONE_MUIC; break; } if (ret) pr_warn("%s:%s something wrong with detaching %d (ERR=%d)\n", MUIC_DEV_NAME, __func__, muic_data->attached_dev, ret); #if defined(CONFIG_MUIC_NOTIFIER) if (noti) muic_notifier_detach_attached_dev(muic_data->attached_dev); #endif /* CONFIG_MUIC_NOTIFIER */ }
static ssize_t max14577_muic_store_manual_sw(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct max14577_muic_data *muic_data = dev_get_drvdata(dev); if (!strncasecmp(buf, "OPEN", 4)) com_to_open(muic_data); else if (!strncasecmp(buf, "USB", 3)) com_to_usb(muic_data); else if (!strncasecmp(buf, "AUDIO", 5)) com_to_audio(muic_data); else if (!strncasecmp(buf, "UART", 4)) com_to_uart(muic_data); else pr_warn("%s:%s invalid value\n", MUIC_DEV_NAME, __func__); return count; }
static void tsu6721_muic_shutdown(struct i2c_client *i2c) { struct tsu6721_muic_data *muic_data = i2c_get_clientdata(i2c); int ret; pr_info("%s:%s\n", MUIC_DEV_NAME, __func__); if (!muic_data->i2c) { pr_err("%s:%s no muic i2c client\n", MUIC_DEV_NAME, __func__); return; } pr_info("%s:%s open D+,D-,V_bus line\n", MUIC_DEV_NAME, __func__); ret = com_to_open(muic_data); if (ret < 0) pr_err("%s:%s fail to open mansw1 reg\n", MUIC_DEV_NAME, __func__); pr_info("%s:%s muic auto detection enable\n", MUIC_DEV_NAME, __func__); ret = set_manual_sw(muic_data, true); if (ret < 0) { pr_err("%s:%s fail to update reg\n", MUIC_DEV_NAME, __func__); return; } }