Commit 467a78c8 authored by Peter Chen's avatar Peter Chen Committed by Felipe Balbi

usb: chipidea: udc: apply new usb_udc_vbus_handler interface

It can move all pullup/pulldown operation control to udc-core
through usb_gadget_connect/usb_gadget_disconnect according to
vbus status.
Signed-off-by: default avatarPeter Chen <peter.chen@freescale.com>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
parent 628ef0d2
...@@ -86,10 +86,8 @@ static int hw_device_state(struct ci_hdrc *ci, u32 dma) ...@@ -86,10 +86,8 @@ static int hw_device_state(struct ci_hdrc *ci, u32 dma)
/* interrupt, error, port change, reset, sleep/suspend */ /* interrupt, error, port change, reset, sleep/suspend */
hw_write(ci, OP_USBINTR, ~0, hw_write(ci, OP_USBINTR, ~0,
USBi_UI|USBi_UEI|USBi_PCI|USBi_URI|USBi_SLI); USBi_UI|USBi_UEI|USBi_PCI|USBi_URI|USBi_SLI);
hw_write(ci, OP_USBCMD, USBCMD_RS, USBCMD_RS);
} else { } else {
hw_write(ci, OP_USBINTR, ~0, 0); hw_write(ci, OP_USBINTR, ~0, 0);
hw_write(ci, OP_USBCMD, USBCMD_RS, 0);
} }
return 0; return 0;
} }
...@@ -1474,7 +1472,9 @@ static int ci_udc_vbus_session(struct usb_gadget *_gadget, int is_active) ...@@ -1474,7 +1472,9 @@ static int ci_udc_vbus_session(struct usb_gadget *_gadget, int is_active)
hw_device_reset(ci); hw_device_reset(ci);
hw_device_state(ci, ci->ep0out->qh.dma); hw_device_state(ci, ci->ep0out->qh.dma);
usb_gadget_set_state(_gadget, USB_STATE_POWERED); usb_gadget_set_state(_gadget, USB_STATE_POWERED);
usb_udc_vbus_handler(_gadget, true);
} else { } else {
usb_udc_vbus_handler(_gadget, false);
if (ci->driver) if (ci->driver)
ci->driver->disconnect(&ci->gadget); ci->driver->disconnect(&ci->gadget);
hw_device_state(ci, 0); hw_device_state(ci, 0);
...@@ -1540,13 +1540,12 @@ static int ci_udc_pullup(struct usb_gadget *_gadget, int is_on) ...@@ -1540,13 +1540,12 @@ static int ci_udc_pullup(struct usb_gadget *_gadget, int is_on)
{ {
struct ci_hdrc *ci = container_of(_gadget, struct ci_hdrc, gadget); struct ci_hdrc *ci = container_of(_gadget, struct ci_hdrc, gadget);
if (!ci->vbus_active) pm_runtime_get_sync(&ci->gadget.dev);
return -EOPNOTSUPP;
if (is_on) if (is_on)
hw_write(ci, OP_USBCMD, USBCMD_RS, USBCMD_RS); hw_write(ci, OP_USBCMD, USBCMD_RS, USBCMD_RS);
else else
hw_write(ci, OP_USBCMD, USBCMD_RS, 0); hw_write(ci, OP_USBCMD, USBCMD_RS, 0);
pm_runtime_put_sync(&ci->gadget.dev);
return 0; return 0;
} }
...@@ -1676,6 +1675,7 @@ static int ci_udc_start(struct usb_gadget *gadget, ...@@ -1676,6 +1675,7 @@ static int ci_udc_start(struct usb_gadget *gadget,
spin_lock_irqsave(&ci->lock, flags); spin_lock_irqsave(&ci->lock, flags);
hw_device_reset(ci); hw_device_reset(ci);
} else { } else {
usb_udc_vbus_handler(&ci->gadget, false);
pm_runtime_put_sync(&ci->gadget.dev); pm_runtime_put_sync(&ci->gadget.dev);
return retval; return retval;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment