usb:langwell_udc: fix pullup issue
authorjzhuan5 <jin.can.zhuang@intel.com>
Sun, 15 Apr 2012 17:09:37 +0000 (13:09 -0400)
committerbuildbot <buildbot@intel.com>
Fri, 27 Apr 2012 11:29:53 +0000 (04:29 -0700)
commit25d19f4c28d9380b4156070b8a4e7eb8fabacbfa
tree36726819f9e5bc787d5bbb5e29dff7293ec4c333
parent08adb2e63485a1031287ee8756259cd5f0c49d98
usb:langwell_udc: fix pullup issue

BZ: 32720

Pullup shouldn't be connected/disconnected if dev->stopped is set which indicates interrupt
is not enabled and the controller maybe in a low power state.

Pullup should be connected if and only if the condition
dev->driver && dev->softconnected && dev->vbus_active && !dev->stopped is true.
dev->driver && dev->softconnected indicates the gadget want to connect pullup and
dev->vbus_active && !dev->stopped indicates uB is plugged in, in which state
vbus is active and controller is powered in device mode.
One related issue is in intel_mid_start_peripheral, pullup can be connected even
dev->softconnected is 0.

Solution:
1. add langwell_udc_pullup() to manage pullup connection/disconnection.
2. Check dev->stopped in langwell_udc_pullup(). If it's set, do nothing.
3. Check condition "dev->driver && dev->softconnected && dev->vbus_active && !dev->stopped"
in langwell_udc_pullup() before connecting pullup.
4. Every time when dev->driver/dev->softconnected/dev->vbus_active/dev->stopped changes,
langwell_udc_pullup should be called to connect pullup whenever is possible or disconnect
if necessary.

Signed-off-by: jzhuan5 <jin.can.zhuang@intel.com>
Change-Id: Idf4ba0a6ab200c66484146c0047073dbb98896bd
Reviewed-on: http://android.intel.com:8080/43514
Reviewed-by: Zhuang, Jin Can <jin.can.zhuang@intel.com>
Reviewed-by: Meng, Zhe <zhe.meng@intel.com>
Tested-by: Meng, Zhe <zhe.meng@intel.com>
Reviewed-by: Tang, Richard <richard.tang@intel.com>
Reviewed-by: buildbot <buildbot@intel.com>
Tested-by: buildbot <buildbot@intel.com>
drivers/usb/gadget/langwell_udc.c