You need to sign in or sign up before continuing.
提交 4f4555cf 编写于 作者: L Li Jun 提交者: Peter Chen

usb: chipidea: udc: update gadget state after bus resume

Gadget state is set to be suspended when bus suspened, but not updated
after resume, this patch saves the gadget state before suspend and
restores it after resume.
Signed-off-by: NLi Jun <jun.li@nxp.com>
Signed-off-by: NPeter Chen <peter.chen@nxp.com>
上级 4495c08e
...@@ -177,6 +177,7 @@ struct hw_bank { ...@@ -177,6 +177,7 @@ struct hw_bank {
* @td_pool: allocation pool for transfer descriptors * @td_pool: allocation pool for transfer descriptors
* @gadget: device side representation for peripheral controller * @gadget: device side representation for peripheral controller
* @driver: gadget driver * @driver: gadget driver
* @resume_state: save the state of gadget suspend from
* @hw_ep_max: total number of endpoints supported by hardware * @hw_ep_max: total number of endpoints supported by hardware
* @ci_hw_ep: array of endpoints * @ci_hw_ep: array of endpoints
* @ep0_dir: ep0 direction * @ep0_dir: ep0 direction
...@@ -227,6 +228,7 @@ struct ci_hdrc { ...@@ -227,6 +228,7 @@ struct ci_hdrc {
struct usb_gadget gadget; struct usb_gadget gadget;
struct usb_gadget_driver *driver; struct usb_gadget_driver *driver;
enum usb_device_state resume_state;
unsigned hw_ep_max; unsigned hw_ep_max;
struct ci_hw_ep ci_hw_ep[ENDPT_MAX]; struct ci_hw_ep ci_hw_ep[ENDPT_MAX];
u32 ep0_dir; u32 ep0_dir;
......
...@@ -1845,27 +1845,32 @@ static irqreturn_t udc_irq(struct ci_hdrc *ci) ...@@ -1845,27 +1845,32 @@ static irqreturn_t udc_irq(struct ci_hdrc *ci)
if (USBi_PCI & intr) { if (USBi_PCI & intr) {
ci->gadget.speed = hw_port_is_high_speed(ci) ? ci->gadget.speed = hw_port_is_high_speed(ci) ?
USB_SPEED_HIGH : USB_SPEED_FULL; USB_SPEED_HIGH : USB_SPEED_FULL;
if (ci->suspended && ci->driver->resume) { if (ci->suspended) {
spin_unlock(&ci->lock); if (ci->driver->resume) {
ci->driver->resume(&ci->gadget); spin_unlock(&ci->lock);
spin_lock(&ci->lock); ci->driver->resume(&ci->gadget);
spin_lock(&ci->lock);
}
ci->suspended = 0; ci->suspended = 0;
usb_gadget_set_state(&ci->gadget,
ci->resume_state);
} }
} }
if (USBi_UI & intr) if (USBi_UI & intr)
isr_tr_complete_handler(ci); isr_tr_complete_handler(ci);
if (USBi_SLI & intr) { if ((USBi_SLI & intr) && !(ci->suspended)) {
ci->suspended = 1;
ci->resume_state = ci->gadget.state;
if (ci->gadget.speed != USB_SPEED_UNKNOWN && if (ci->gadget.speed != USB_SPEED_UNKNOWN &&
ci->driver->suspend) { ci->driver->suspend) {
ci->suspended = 1;
spin_unlock(&ci->lock); spin_unlock(&ci->lock);
ci->driver->suspend(&ci->gadget); ci->driver->suspend(&ci->gadget);
usb_gadget_set_state(&ci->gadget,
USB_STATE_SUSPENDED);
spin_lock(&ci->lock); spin_lock(&ci->lock);
} }
usb_gadget_set_state(&ci->gadget,
USB_STATE_SUSPENDED);
} }
retval = IRQ_HANDLED; retval = IRQ_HANDLED;
} else { } else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册