otg休眠问题

问题:手机作为otg host时,怎样进入待机休眠?

移远EC20模块的功能说明:
在这里插入图片描述

这里说的是如果主机不支持remote wakeup就需要RI信号来唤醒主机;如果主机支持的话就可以通过usb唤醒。

高通文档:
《80-NF283-1_C_Linux_USB_Implementation_Guide》介绍:
section: 7.1.2 Host mode state transition
As shown in Figure 7-1, the USB enters LPM when:
n The USB A-Cable is removed, with or without a B-Device connected.
n USB bus suspend – USB Host mode provides the Autosuspend feature via CONFIG_USB_SUSPEND, defined by default. The host controller driver monitors each device connected on the bus and, if any device is idle for a period more than a predefined timeout, it selectively suspends the device. However, if any one of the drivers corresponding to an interface in the USB device does not support Autosuspend, the device cannot be suspended. The mass storage driver does not support Autosuspend.Hence, if a mass storage device is connected, it is not suspended. The HUB driver supports Autosuspend. More information is available at Documentation/usb/power-management.txt.

高通case回复Answer:
Linux Android USB host driver stack(UHCI&EHCI&XHCI) have support for suspend/power collapse, but most device class drivers do not enabled auto suspend. We need to enable autosuspend for those devices,can call usb_enable_autosuspend() function in the driver device probe routine.An example for HID device is as below:

drivers/hid/usbhid/hid-core.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
index ff052c8…399d964 100644
— a/drivers/hid/usbhid/hid-core.c
+++ b/drivers/hid/usbhid/hid-core.c
@@ -1338,6 +1338,9 @@ static int usbhid_probe(struct usb_interface *intf, const struct usb_device_id *
goto err_free;
}

+/* enable suspend/resume support for HID devices. */
+usb_enable_autosuspend(dev);

return 0;
err_free:
kfree(usbhid);
@@ -1349,11 +1352,13 @@ err:
static void usbhid_disconnect(struct usb_interface *intf)
{
struct hid_device *hid = usb_get_intfdata(intf);
+struct usb_device *dev = interface_to_usbdev(intf);
struct usbhid_device *usbhid;

if (WARN_ON(!hid))
return;

+usb_disable_autosuspend(dev);
usbhid = hid->driver_data;
hid_destroy_device(hid);
kfree(usbhid);

扫描二维码关注公众号,回复: 12395586 查看本文章

We also need to pay attention that if remotewakeup is not supported, autosuspend doesn’t happen, see function autosuspend_check:

if (w && !device_can_wakeup(&udev->dev)) {
dev_dbg(&udev->dev, “remote wakeup needed for autosuspend\n”);
return -EOPNOTSUPP;
}

on 8994/8992, host bus suspend is not supported due to some HW issue.

static int dwc3_otg_start_host(struct usb_otg otg, int on)
{

/
*
*WORKAROUND: currently host mode suspend isn’t working well.
*Disable xHCI’s runtime PM for now.
*/
pm_runtime_disable(&dwc->xhci->dev);

按照上面的修改后,otg侧连上鼠标是可以进入休眠了;点击鼠标是可以正常唤醒手机的。

猜你喜欢

转载自blog.csdn.net/cornerstone1/article/details/112633350
OTG
今日推荐