usb host: lock cpu when usb otg connector is connected 08/100608/2
authortaeyoung <ty317.kim@samsung.com>
Mon, 28 Nov 2016 13:47:25 +0000 (22:47 +0900)
committerTaeyoung Kim <ty317.kim@samsung.com>
Wed, 30 Nov 2016 05:51:15 +0000 (21:51 -0800)
usb otg connector can be notified by the extcon event.
If usb otg connector is connected, CPU needs to be locked

Change-Id: Ic5569bf97f5716d1a99d84e720ed8936a0875458
Signed-off-by: taeyoung <ty317.kim@samsung.com>
src/extcon/extcon.h
src/usbhost/usb-host.c

index df42bbc..5a53454 100755 (executable)
 #define __EXTCON_H__
 
 #include "core/common.h"
+#include <hw/external_connection.h>
 
 /**
  * Extcon cable name is shared with kernel extcon class.
  * So do not change below strings.
  */
-#define EXTCON_CABLE_USB              "USB"
-#define EXTCON_CABLE_USB_HOST         "USB-Host"
-#define EXTCON_CABLE_TA               "TA"
-#define EXTCON_CABLE_HDMI             "HDMI"
-#define EXTCON_CABLE_DOCK             "Dock"
-#define EXTCON_CABLE_MIC_IN           "Microphone"
-#define EXTCON_CABLE_HEADPHONE_OUT    "Headphone"
+#define EXTCON_CABLE_USB              EXTERNAL_CONNECTION_USB
+#define EXTCON_CABLE_USB_HOST         EXTERNAL_CONNECTION_USB_HOST
+#define EXTCON_CABLE_TA               EXTERNAL_CONNECTION_TA
+#define EXTCON_CABLE_HDMI             EXTERNAL_CONNECTION_HDMI
+#define EXTCON_CABLE_DOCK             EXTERNAL_CONNECTION_DOCK
+#define EXTCON_CABLE_MIC_IN           EXTERNAL_CONNECTION_MIC
+#define EXTCON_CABLE_HEADPHONE_OUT    EXTERNAL_CONNECTION_HEADPHONE
 
 struct extcon_ops {
        const char *name;
index 02b03b5..c44fa5f 100644 (file)
@@ -31,6 +31,7 @@
 #include "core/list.h"
 #include "core/device-idler.h"
 #include "apps/apps.h"
+#include "extcon/extcon.h"
 
 #define USB_INTERFACE_CLASS     "bInterfaceClass"
 #define USB_INTERFACE_SUBCLASS  "bInterfaceSubClass"
@@ -1323,3 +1324,22 @@ static const struct device_ops usbhost_device_ops = {
 };
 
 DEVICE_OPS_REGISTER(&usbhost_device_ops)
+
+static int extcon_usbhost_state_changed(int status)
+{
+       if (status == 0) {
+               _I("USB host connector disconnected");
+               pm_unlock_internal(INTERNAL_LOCK_USB, LCD_OFF, STAY_CUR_STATE);
+       } else {
+               _I("USB host connector connected");
+               pm_lock_internal(INTERNAL_LOCK_USB, LCD_OFF, STAY_CUR_STATE, 0);
+       }
+       return 0;
+}
+
+struct extcon_ops extcon_usbhost_ops = {
+       .name   = EXTCON_CABLE_USB_HOST,
+       .update = extcon_usbhost_state_changed,
+};
+
+EXTCON_OPS_REGISTER(extcon_usbhost_ops)