From 12fdf943794f933a1fb78b2dca662fe653d08ac6 Mon Sep 17 00:00:00 2001 From: Kisang Lee Date: Wed, 27 Jun 2018 14:29:24 +0900 Subject: [PATCH] [COMMON] usb: notify: add TA checking condition Change-Id: Id7b640d0a81c7383b83ee200ebfc51037858f7c8 Signed-off-by: Kisang Lee --- drivers/usb/notify/usb_notifier.c | 14 ++++++++++++++ drivers/usb/notify/usb_notify.c | 18 +++++++++++++----- include/linux/usb_notify.h | 1 + 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/drivers/usb/notify/usb_notifier.c b/drivers/usb/notify/usb_notifier.c index 850efade67ea..9d4fd45cbe0f 100644 --- a/drivers/usb/notify/usb_notifier.c +++ b/drivers/usb/notify/usb_notifier.c @@ -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, diff --git a/drivers/usb/notify/usb_notify.c b/drivers/usb/notify/usb_notify.c index ab051d581d1d..973718c924b0 100644 --- a/drivers/usb/notify/usb_notify.c +++ b/drivers/usb/notify/usb_notify.c @@ -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: diff --git a/include/linux/usb_notify.h b/include/linux/usb_notify.h index 274dc5dbf0b0..d354cbec2450 100644 --- a/include/linux/usb_notify.h +++ b/include/linux/usb_notify.h @@ -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); -- 2.20.1