[COMMON] usb: notify: add TA checking condition
authorKisang Lee <kisang80.lee@samsung.com>
Wed, 27 Jun 2018 05:29:24 +0000 (14:29 +0900)
committerKisang Lee <kisang80.lee@samsung.com>
Wed, 27 Jun 2018 05:29:24 +0000 (14:29 +0900)
Change-Id: Id7b640d0a81c7383b83ee200ebfc51037858f7c8
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 850efade67ea470ffe8eb28cd8de698b9703749d..9d4fd45cbe0ff560281ff0e1dec85dff152a2e44 100644 (file)
@@ -821,6 +821,18 @@ static int exynos_set_peripheral(bool enable)
        return 0;
 }
 
+#if defined(CONFIG_IFCONN_NOTIFIER)
+static int exynos_set_charger(bool enable)
+{
+       if (enable) {
+               pr_info("%s - revert usb notification\n", __func__);
+               check_usb_vbus_state(0);
+       }
+
+       return 0;
+}
+#endif
+
 #if defined(CONFIG_BATTERY_SAMSUNG_V2)
 static int usb_blocked_chg_control(int set)
 {
@@ -864,7 +876,9 @@ static struct otg_notify dwc_lsi_notify = {
        .set_host = exynos_set_host,
        .set_peripheral = exynos_set_peripheral,
 #if defined(CONFIG_IFCONN_NOTIFIER)
+       .set_charger = exynos_set_charger,
        .charger_detect = 0,
+       .usb_noti_done = 0,
 #endif
        .vbus_detect_gpio = -1,
        .is_wakelock = 0,
index ab051d581d1d6832bc29694f22d2c57ba438d2a3..973718c924b0ee411824fad621df26816b1f1d3e 100644 (file)
@@ -684,8 +684,10 @@ static void otg_notify_state(struct otg_notify *n,
                                        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)
+                       if (n->set_peripheral && n->charger_detect == 0) {
                                n->set_peripheral(true);
+                               n->usb_noti_done = 1;
+                       }
 #else
                        if (n->set_peripheral)
                                n->set_peripheral(true);
@@ -801,14 +803,20 @@ static void otg_notify_state(struct otg_notify *n,
                }
                break;
        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)
+               if (enable) {
                        n->charger_detect = 1;
-               else
+                       if (n->usb_noti_done) {
+                               n->set_charger(enable);
+                               n->usb_noti_done = 0;
+                       }
+               } else {
                        n->charger_detect = 0;
+               }
+#else
+               if (n->set_charger)
+                       n->set_charger(enable);
 #endif
                break;
        case NOTIFY_EVENT_MMDOCK:
index 274dc5dbf0b0b295c614767542869cadeee6b727..d354cbec2450037533792661f2d37a3f4a04b5f7 100644 (file)
@@ -129,6 +129,7 @@ struct otg_notify {
        int speed;
 #if defined(CONFIG_IFCONN_NOTIFIER)
        int charger_detect;
+       int usb_noti_done;
 #endif
        const char *muic_name;
        int (*pre_gpio)(int gpio, int use);