usb: dwc_otg_310: pcd: fix force device mode issue
authorWilliam Wu <william.wu@rock-chips.com>
Thu, 1 Jun 2017 03:10:18 +0000 (11:10 +0800)
committerHuang, Tao <huangtao@rock-chips.com>
Fri, 2 Jun 2017 01:37:26 +0000 (09:37 +0800)
commit9b050a98b7eb120fe4c81aacaccf761a6818ba5c
treea7c4ee71d9b71a9d9a9c60a73de00c79f5762c48
parentcb8b72b50b4cb92327890f7cc65e180865d7186e
usb: dwc_otg_310: pcd: fix force device mode issue

When tested usb device through force device mode method,
we found that usb device failed to connect to usb host
in the following case.

1. Use micro usb 2.0 OTG interface.
2. Plug in otg cable, and the id pin was pulled down
   to Ground.
3. User space force usb to enter device mode through
   'echo 2 > /sys/bus/platform/drivers/usb20_otg/force_usb_mode'
4. Use usb 2.0 Standard-A to Standard-A cable assembly,
   plug into otg cable receptor on one side, and connect
   to PC on the other side.
5. PC fail to enumerate our device, because of usb driver
   logical issue.

This is because that the dwc_otg_pcd_check_vbus_work()
only enable usb to start connecting if check the bvalid
and iddig is high. But in the above test case, the iddig
is low, so fail to start connection work. In this patch,
we enable usb to connect if iddig is high or usb is in
force device mode.

In addition, fix some coding style to increase the readability.

Change-Id: I08f1a4e6e7e5fb246b1716a20d4572d8b866f238
Signed-off-by: William Wu <william.wu@rock-chips.com>
drivers/usb/dwc_otg_310/dwc_otg_pcd_linux.c