From 95327b5b94f373cc01499f92c0826e000c52f5ec Mon Sep 17 00:00:00 2001 From: taeyoung Date: Mon, 28 Nov 2016 22:47:25 +0900 Subject: [PATCH] usb host: lock cpu when usb otg connector is connected 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 --- src/extcon/extcon.h | 15 ++++++++------- src/usbhost/usb-host.c | 20 ++++++++++++++++++++ 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/src/extcon/extcon.h b/src/extcon/extcon.h index df42bbc..5a53454 100755 --- a/src/extcon/extcon.h +++ b/src/extcon/extcon.h @@ -21,18 +21,19 @@ #define __EXTCON_H__ #include "core/common.h" +#include /** * 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; diff --git a/src/usbhost/usb-host.c b/src/usbhost/usb-host.c index 02b03b5..c44fa5f 100644 --- a/src/usbhost/usb-host.c +++ b/src/usbhost/usb-host.c @@ -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) -- 2.7.4