aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/dwc3/ep0.c
diff options
context:
space:
mode:
authorFelipe Balbi <balbi@ti.com>2011-12-19 06:01:52 -0500
committerFelipe Balbi <balbi@ti.com>2013-03-18 05:17:12 -0400
commit14cd592f72ea1ce1a25d7a576a5ed6aa761456bc (patch)
tree7557811ad7c557a2944c23a24da4c387a0881737 /drivers/usb/dwc3/ep0.c
parent49401f4169c0e5a1b38f1a676d6f12eecaf77485 (diff)
usb: dwc3: gadget: implement gadget state tracking
make use of the previously introduced gadget->state field. Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/dwc3/ep0.c')
-rw-r--r--drivers/usb/dwc3/ep0.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c
index 1d139ca05ef1..2a82b7145052 100644
--- a/drivers/usb/dwc3/ep0.c
+++ b/drivers/usb/dwc3/ep0.c
@@ -512,10 +512,13 @@ static int dwc3_ep0_set_address(struct dwc3 *dwc, struct usb_ctrlrequest *ctrl)
512 reg |= DWC3_DCFG_DEVADDR(addr); 512 reg |= DWC3_DCFG_DEVADDR(addr);
513 dwc3_writel(dwc->regs, DWC3_DCFG, reg); 513 dwc3_writel(dwc->regs, DWC3_DCFG, reg);
514 514
515 if (addr) 515 if (addr) {
516 dwc->dev_state = DWC3_ADDRESS_STATE; 516 dwc->dev_state = DWC3_ADDRESS_STATE;
517 else 517 usb_gadget_set_state(&dwc->gadget, USB_STATE_ADDRESS);
518 } else {
518 dwc->dev_state = DWC3_DEFAULT_STATE; 519 dwc->dev_state = DWC3_DEFAULT_STATE;
520 usb_gadget_set_state(&dwc->gadget, USB_STATE_DEFAULT);
521 }
519 522
520 return 0; 523 return 0;
521} 524}
@@ -549,6 +552,9 @@ static int dwc3_ep0_set_config(struct dwc3 *dwc, struct usb_ctrlrequest *ctrl)
549 /* if the cfg matches and the cfg is non zero */ 552 /* if the cfg matches and the cfg is non zero */
550 if (cfg && (!ret || (ret == USB_GADGET_DELAYED_STATUS))) { 553 if (cfg && (!ret || (ret == USB_GADGET_DELAYED_STATUS))) {
551 dwc->dev_state = DWC3_CONFIGURED_STATE; 554 dwc->dev_state = DWC3_CONFIGURED_STATE;
555 usb_gadget_set_state(&dwc->gadget,
556 USB_STATE_CONFIGURED);
557
552 /* 558 /*
553 * Enable transition to U1/U2 state when 559 * Enable transition to U1/U2 state when
554 * nothing is pending from application. 560 * nothing is pending from application.
@@ -564,8 +570,11 @@ static int dwc3_ep0_set_config(struct dwc3 *dwc, struct usb_ctrlrequest *ctrl)
564 570
565 case DWC3_CONFIGURED_STATE: 571 case DWC3_CONFIGURED_STATE:
566 ret = dwc3_ep0_delegate_req(dwc, ctrl); 572 ret = dwc3_ep0_delegate_req(dwc, ctrl);
567 if (!cfg) 573 if (!cfg) {
568 dwc->dev_state = DWC3_ADDRESS_STATE; 574 dwc->dev_state = DWC3_ADDRESS_STATE;
575 usb_gadget_set_state(&dwc->gadget,
576 USB_STATE_ADDRESS);
577 }
569 break; 578 break;
570 default: 579 default:
571 ret = -EINVAL; 580 ret = -EINVAL;