Commit cac402dd0832e9c63929eff70d6766cd8623e5fc
Committed by
Felipe Balbi
1 parent
f99987bb26
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
usb: renesas_usbhs: gadget: add support for set_selfpowered
The previous code always set to USB_DEVICE_SELF_POWERED in GET_STATUS. So, this patch adds set_selfpowered(). Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
Showing 1 changed file with 18 additions and 1 deletions Side-by-side Diff
drivers/usb/renesas_usbhs/mod_gadget.c
... | ... | @@ -55,6 +55,7 @@ |
55 | 55 | #define USBHSG_STATUS_STARTED (1 << 0) |
56 | 56 | #define USBHSG_STATUS_REGISTERD (1 << 1) |
57 | 57 | #define USBHSG_STATUS_WEDGE (1 << 2) |
58 | +#define USBHSG_STATUS_SELF_POWERED (1 << 3) | |
58 | 59 | }; |
59 | 60 | |
60 | 61 | struct usbhsg_recip_handle { |
61 | 62 | |
... | ... | @@ -333,8 +334,11 @@ |
333 | 334 | struct usb_ctrlrequest *ctrl) |
334 | 335 | { |
335 | 336 | struct usbhsg_gpriv *gpriv = usbhsg_uep_to_gpriv(uep); |
336 | - unsigned short status = 1 << USB_DEVICE_SELF_POWERED; | |
337 | + unsigned short status = 0; | |
337 | 338 | |
339 | + if (usbhsg_status_has(gpriv, USBHSG_STATUS_SELF_POWERED)) | |
340 | + status = 1 << USB_DEVICE_SELF_POWERED; | |
341 | + | |
338 | 342 | __usbhsg_recip_send_status(gpriv, status); |
339 | 343 | |
340 | 344 | return 0; |
341 | 345 | |
... | ... | @@ -879,8 +883,21 @@ |
879 | 883 | return usbhs_frame_get_num(priv); |
880 | 884 | } |
881 | 885 | |
886 | +static int usbhsg_set_selfpowered(struct usb_gadget *gadget, int is_self) | |
887 | +{ | |
888 | + struct usbhsg_gpriv *gpriv = usbhsg_gadget_to_gpriv(gadget); | |
889 | + | |
890 | + if (is_self) | |
891 | + usbhsg_status_set(gpriv, USBHSG_STATUS_SELF_POWERED); | |
892 | + else | |
893 | + usbhsg_status_clr(gpriv, USBHSG_STATUS_SELF_POWERED); | |
894 | + | |
895 | + return 0; | |
896 | +} | |
897 | + | |
882 | 898 | static struct usb_gadget_ops usbhsg_gadget_ops = { |
883 | 899 | .get_frame = usbhsg_get_frame, |
900 | + .set_selfpowered = usbhsg_set_selfpowered, | |
884 | 901 | .udc_start = usbhsg_gadget_start, |
885 | 902 | .udc_stop = usbhsg_gadget_stop, |
886 | 903 | }; |