[COMMON] usb: notify: check TA to disable USB device
authorKisang Lee <kisang80.lee@samsung.com>
Mon, 25 Jun 2018 07:15:25 +0000 (16:15 +0900)
committerTaekki Kim <taekki.kim@samsung.com>
Mon, 25 Jun 2018 13:40:39 +0000 (22:40 +0900)
Change-Id: I03e5764d5de99de6de1e7f368feebc3a9092e0e3
Signed-off-by: Kisang Lee <kisang80.lee@samsung.com>
drivers/usb/notify/usb_notifier.c
drivers/usb/notify/usb_notify.c
include/linux/usb_notify.h

index c54c4408daf1906364ea8c1871ca4d1a405d68cc..850efade67ea470ffe8eb28cd8de698b9703749d 100644 (file)
@@ -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,
index 018aa2d987469d0644b0c4a664cf6cbdc981fc63..ab051d581d1d6832bc29694f22d2c57ba438d2a3 100644 (file)
@@ -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);
index 443beffb895a4c30fc61cfb2013000e6ce50a809..274dc5dbf0b0b295c614767542869cadeee6b727 100644 (file)
@@ -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);