From: Kisang Lee Date: Mon, 25 Jun 2018 07:15:25 +0000 (+0900) Subject: [COMMON] usb: notify: check TA to disable USB device X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=9caa3db37e3606d097354b63aaf42f82e39509a1;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git [COMMON] usb: notify: check TA to disable USB device Change-Id: I03e5764d5de99de6de1e7f368feebc3a9092e0e3 Signed-off-by: Kisang Lee --- diff --git a/drivers/usb/notify/usb_notifier.c b/drivers/usb/notify/usb_notifier.c index c54c4408daf1..850efade67ea 100644 --- a/drivers/usb/notify/usb_notifier.c +++ b/drivers/usb/notify/usb_notifier.c @@ -414,6 +414,16 @@ static int muic_usb_handle_notification(struct notifier_block *nb, __func__, action, attached_dev); switch (attached_dev) { +#if defined(CONFIG_IFCONN_NOTIFIER) + case ATTACHED_DEV_TA_MUIC: + if (action == IFCONN_NOTIFY_ID_DETACH) + send_otg_notify(o_notify, NOTIFY_EVENT_CHARGER, 0); + else if (action == IFCONN_NOTIFY_ID_ATTACH) + send_otg_notify(o_notify, NOTIFY_EVENT_CHARGER, 1); + else + pr_err("%s - ACTION Error!\n", __func__); + break; +#endif case ATTACHED_DEV_USB_MUIC: case ATTACHED_DEV_CDP_MUIC: case ATTACHED_DEV_UNOFFICIAL_ID_USB_MUIC: @@ -853,6 +863,9 @@ static struct otg_notify dwc_lsi_notify = { .vbus_drive = otg_accessory_power, .set_host = exynos_set_host, .set_peripheral = exynos_set_peripheral, +#if defined(CONFIG_IFCONN_NOTIFIER) + .charger_detect = 0, +#endif .vbus_detect_gpio = -1, .is_wakelock = 0, .booting_delay_sec = 10, diff --git a/drivers/usb/notify/usb_notify.c b/drivers/usb/notify/usb_notify.c index 018aa2d98746..ab051d581d1d 100644 --- a/drivers/usb/notify/usb_notify.c +++ b/drivers/usb/notify/usb_notify.c @@ -682,8 +682,14 @@ static void otg_notify_state(struct otg_notify *n, if (n->pre_peri_delay_us) usleep_range(n->pre_peri_delay_us * 1000, n->pre_peri_delay_us * 1000); +#if defined(CONFIG_IFCONN_NOTIFIER) + pr_info("Charger status in usb detect = %d\n", n->charger_detect); + if (n->set_peripheral && n->charger_detect == 0) + n->set_peripheral(true); +#else if (n->set_peripheral) n->set_peripheral(true); +#endif } else { u_notify->ndev.mode = NOTIFY_NONE_MODE; if (n->set_peripheral) @@ -797,6 +803,13 @@ static void otg_notify_state(struct otg_notify *n, case NOTIFY_EVENT_CHARGER: if (n->set_charger) n->set_charger(enable); +#if defined(CONFIG_IFCONN_NOTIFIER) + pr_info("%s charger detect = %d\n", __func__, enable); + if (enable) + n->charger_detect = 1; + else + n->charger_detect = 0; +#endif break; case NOTIFY_EVENT_MMDOCK: enable_ovc(u_notify, enable); diff --git a/include/linux/usb_notify.h b/include/linux/usb_notify.h index 443beffb895a..274dc5dbf0b0 100644 --- a/include/linux/usb_notify.h +++ b/include/linux/usb_notify.h @@ -127,6 +127,9 @@ struct otg_notify { int pre_peri_delay_us; int sec_whitelist_enable; int speed; +#if defined(CONFIG_IFCONN_NOTIFIER) + int charger_detect; +#endif const char *muic_name; int (*pre_gpio)(int gpio, int use); int (*post_gpio)(int gpio, int use);