[COMMON][9610] drivers : fix typec role swap
authorJunhan Bae <junhan84.bae@samsung.com>
Fri, 22 Mar 2019 12:14:31 +0000 (21:14 +0900)
committerlingsen1 <lingsen1@lenovo.com>
Mon, 10 Jun 2019 03:25:11 +0000 (11:25 +0800)
Fix Macbook pro role swap issue
Add data swap and power swap
Mot-CRs-fixed:(CR)

Change-Id: I5a239b7552f4c3bb464f72d5f9f5aaae9f76ef66
Signed-off-by: Junhan Bae <junhan84.bae@samsung.com>
Reviewed-on: https://gerrit.mot.com/1337168
SME-Granted: SME Approvals Granted
SLTApproved: Slta Waiver
Tested-by: Jira Key
Reviewed-by: Xiangpo Zhao <zhaoxp3@motorola.com>
Submit-Approved: Jira Key

drivers/ccic/s2mu106-usbpd.c
drivers/ccic/usbpd_cc.c

index 19869b141bdf214fca0fef98eb1100f8d78ecb82..4cbd941d2809de5c215ef7079d17535ce58a5ca5 100644 (file)
@@ -2200,11 +2200,10 @@ static void s2mu106_usbpd_notify_detach(struct s2mu106_usbpd_data *pdic_data)
                }
                pdic_data->typec_power_role = TYPEC_SINK;
                pdic_data->typec_data_role = TYPEC_DEVICE;
+#endif
                /* USB */
                ifconn_event_work(pdic_data, IFCONN_NOTIFY_USB, IFCONN_NOTIFY_ID_USB,
                                                                                IFCONN_NOTIFY_EVENT_DETACH, NULL);
-
-#endif
        }
 #else
        usbpd_manager_plug_detach(dev, 1);
index 917ece236ea8fc13860da43c1f410e955133b007..f39192d1247c2db37c3de7ae04410bdd07d3bf7e 100644 (file)
@@ -51,7 +51,7 @@ static void ccic_event_notifier(struct work_struct *data)
        CC_NOTI_TYPEDEF ccic_noti;
 
        switch (event_work->dest) {
-       case CCIC_NOTIFY_DEV_USB:
+               case CCIC_NOTIFY_DEV_USB:
                pr_info("usb:%s, dest=%s, id=%s, attach=%s, drp=%s, event_work=%p\n", __func__,
                                CCIC_NOTI_DEST_Print[event_work->dest],
                                CCIC_NOTI_ID_Print[event_work->id],
@@ -227,51 +227,51 @@ extern void ifconn_event_work(void *pd_data, int dest, int id, int event, void *
                }
        }
 #elif defined(CONFIG_TYPEC)
-       if (id == IFCONN_NOTIFY_ID_USB) {
-               if (usbpd_data->typec_try_state_change &&
-                       (event != IFCONN_NOTIFY_EVENT_DETACH)) {
-                       /* Role change try and new mode detected */
-                       pr_info("usb: %s, role_reverse_completion\n", __func__);
-                       complete(&usbpd_data->role_reverse_completion);
-               }
-
-               if (usbpd_data->partner == NULL) {
-                       if (event == IFCONN_NOTIFY_EVENT_USB_ATTACH_UFP) {
-                               pr_info("usb: %s, line : %d\n", __func__, __LINE__);
-                               mode = typec_get_pd_support(usbpd_data);
-                               typec_set_pwr_opmode(usbpd_data->port, mode);
-                               desc.usb_pd = mode == TYPEC_PWR_MODE_PD;
-                               desc.accessory = TYPEC_ACCESSORY_NONE; /* XXX: handle accessories */
-                               desc.identity = NULL;
-                               usbpd_data->typec_data_role = TYPEC_DEVICE;
-                               typec_set_pwr_role(usbpd_data->port, usbpd_data->typec_power_role);
-                               typec_set_data_role(usbpd_data->port, TYPEC_DEVICE);
-                               usbpd_data->partner = typec_register_partner(usbpd_data->port, &desc);
-                       } else if (event == IFCONN_NOTIFY_EVENT_USB_ATTACH_DFP) {
-                               pr_info("usb: %s, line : %d\n", __func__, __LINE__);
-                               mode = typec_get_pd_support(usbpd_data);
-                               typec_set_pwr_opmode(usbpd_data->port, mode);
-                               desc.usb_pd = mode == TYPEC_PWR_MODE_PD;
-                               desc.accessory = TYPEC_ACCESSORY_NONE; /* XXX: handle accessories */
-                               desc.identity = NULL;
-                               usbpd_data->typec_data_role = TYPEC_HOST;
-                               typec_set_pwr_role(usbpd_data->port, usbpd_data->typec_power_role);
-                               typec_set_data_role(usbpd_data->port, TYPEC_HOST);
-                               usbpd_data->partner = typec_register_partner(usbpd_data->port, &desc);
-                       } else
-                               pr_info("usb: %s, line : %d\n", __func__, __LINE__);
-               } else {
-                       if (event == IFCONN_NOTIFY_EVENT_USB_ATTACH_UFP) {
-                               pr_info("usb: %s, line : %d\n", __func__, __LINE__);
-                               usbpd_data->typec_data_role = TYPEC_DEVICE;
-                               typec_set_data_role(usbpd_data->port, TYPEC_DEVICE);
-                       } else if (event == IFCONN_NOTIFY_EVENT_USB_ATTACH_DFP) {
-                               usbpd_data->typec_data_role = TYPEC_HOST;
-                               typec_set_data_role(usbpd_data->port, TYPEC_HOST);
-                       } else
-                               pr_info("usb: %s, line : %d\n", __func__, __LINE__);
-               }
-       }
+           if (id == IFCONN_NOTIFY_ID_USB) {
+                       if (usbpd_data->typec_try_state_change &&
+                           (event != IFCONN_NOTIFY_EVENT_DETACH)) {
+                           /* Role change try and new mode detected */
+                           pr_info("usb: %s, role_reverse_completion\n", __func__);
+                           complete(&usbpd_data->role_reverse_completion);
+                       }
+
+                       if (usbpd_data->partner == NULL) {
+                               if (event == IFCONN_NOTIFY_EVENT_USB_ATTACH_UFP) {
+                                   pr_info("usb: %s, line : %d\n", __func__, __LINE__);
+                                   mode = typec_get_pd_support(usbpd_data);
+                                   typec_set_pwr_opmode(usbpd_data->port, mode);
+                                   desc.usb_pd = mode == TYPEC_PWR_MODE_PD;
+                                   desc.accessory = TYPEC_ACCESSORY_NONE; /* XXX: handle accessories */
+                                   desc.identity = NULL;
+                                   usbpd_data->typec_data_role = TYPEC_DEVICE;
+                                   typec_set_pwr_role(usbpd_data->port, usbpd_data->typec_power_role);
+                                   typec_set_data_role(usbpd_data->port, TYPEC_DEVICE);
+                                   usbpd_data->partner = typec_register_partner(usbpd_data->port, &desc);
+                               } else if (event == IFCONN_NOTIFY_EVENT_USB_ATTACH_DFP) {
+                                   pr_info("usb: %s, line : %d\n", __func__, __LINE__);
+                                   mode = typec_get_pd_support(usbpd_data);
+                                   typec_set_pwr_opmode(usbpd_data->port, mode);
+                                   desc.usb_pd = mode == TYPEC_PWR_MODE_PD;
+                                   desc.accessory = TYPEC_ACCESSORY_NONE; /* XXX: handle accessories */
+                                   desc.identity = NULL;
+                                   usbpd_data->typec_data_role = TYPEC_HOST;
+                                   typec_set_pwr_role(usbpd_data->port, usbpd_data->typec_power_role);
+                                   typec_set_data_role(usbpd_data->port, TYPEC_HOST);
+                                   usbpd_data->partner = typec_register_partner(usbpd_data->port, &desc);
+                               } else
+                                   pr_info("usb: %s, line : %d\n", __func__, __LINE__);
+                       } else {
+                               if (event == IFCONN_NOTIFY_EVENT_USB_ATTACH_UFP) {
+                                   pr_info("usb: %s, line : %d\n", __func__, __LINE__);
+                                   usbpd_data->typec_data_role = TYPEC_DEVICE;
+                                   typec_set_data_role(usbpd_data->port, TYPEC_DEVICE);
+                               } else if (event == IFCONN_NOTIFY_EVENT_USB_ATTACH_DFP) {
+                                   usbpd_data->typec_data_role = TYPEC_HOST;
+                                   typec_set_data_role(usbpd_data->port, TYPEC_HOST);
+                               } else
+                                   pr_info("usb: %s, line : %d\n", __func__, __LINE__);
+                       }
+           }
 #endif
 
        if (queue_work(usbpd_data->ifconn_wq, &event_work->ifconn_work) == 0) {