diff options
Diffstat (limited to 'drivers/usb/chipidea/udc.c')
-rw-r--r-- | drivers/usb/chipidea/udc.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c index 4fe18ce3bd5a..ff451048c1ac 100644 --- a/drivers/usb/chipidea/udc.c +++ b/drivers/usb/chipidea/udc.c | |||
@@ -819,8 +819,8 @@ __acquires(hwep->lock) | |||
819 | } | 819 | } |
820 | 820 | ||
821 | if ((setup->bRequestType & USB_RECIP_MASK) == USB_RECIP_DEVICE) { | 821 | if ((setup->bRequestType & USB_RECIP_MASK) == USB_RECIP_DEVICE) { |
822 | /* Assume that device is bus powered for now. */ | 822 | *(u16 *)req->buf = (ci->remote_wakeup << 1) | |
823 | *(u16 *)req->buf = ci->remote_wakeup << 1; | 823 | ci->gadget.is_selfpowered; |
824 | } else if ((setup->bRequestType & USB_RECIP_MASK) \ | 824 | } else if ((setup->bRequestType & USB_RECIP_MASK) \ |
825 | == USB_RECIP_ENDPOINT) { | 825 | == USB_RECIP_ENDPOINT) { |
826 | dir = (le16_to_cpu(setup->wIndex) & USB_ENDPOINT_DIR_MASK) ? | 826 | dir = (le16_to_cpu(setup->wIndex) & USB_ENDPOINT_DIR_MASK) ? |
@@ -1520,6 +1520,19 @@ static int ci_udc_vbus_draw(struct usb_gadget *_gadget, unsigned ma) | |||
1520 | return -ENOTSUPP; | 1520 | return -ENOTSUPP; |
1521 | } | 1521 | } |
1522 | 1522 | ||
1523 | static int ci_udc_selfpowered(struct usb_gadget *_gadget, int is_on) | ||
1524 | { | ||
1525 | struct ci_hdrc *ci = container_of(_gadget, struct ci_hdrc, gadget); | ||
1526 | struct ci_hw_ep *hwep = ci->ep0in; | ||
1527 | unsigned long flags; | ||
1528 | |||
1529 | spin_lock_irqsave(hwep->lock, flags); | ||
1530 | _gadget->is_selfpowered = (is_on != 0); | ||
1531 | spin_unlock_irqrestore(hwep->lock, flags); | ||
1532 | |||
1533 | return 0; | ||
1534 | } | ||
1535 | |||
1523 | /* Change Data+ pullup status | 1536 | /* Change Data+ pullup status |
1524 | * this func is used by usb_gadget_connect/disconnet | 1537 | * this func is used by usb_gadget_connect/disconnet |
1525 | */ | 1538 | */ |
@@ -1549,6 +1562,7 @@ static int ci_udc_stop(struct usb_gadget *gadget); | |||
1549 | static const struct usb_gadget_ops usb_gadget_ops = { | 1562 | static const struct usb_gadget_ops usb_gadget_ops = { |
1550 | .vbus_session = ci_udc_vbus_session, | 1563 | .vbus_session = ci_udc_vbus_session, |
1551 | .wakeup = ci_udc_wakeup, | 1564 | .wakeup = ci_udc_wakeup, |
1565 | .set_selfpowered = ci_udc_selfpowered, | ||
1552 | .pullup = ci_udc_pullup, | 1566 | .pullup = ci_udc_pullup, |
1553 | .vbus_draw = ci_udc_vbus_draw, | 1567 | .vbus_draw = ci_udc_vbus_draw, |
1554 | .udc_start = ci_udc_start, | 1568 | .udc_start = ci_udc_start, |