]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
usb: gadget: atmel: Add attach/detach support
authorZixun LI <admin@hifiphile.com>
Thu, 25 Jul 2024 15:32:00 +0000 (17:32 +0200)
committerMattijs Korpershoek <mkorpershoek@baylibre.com>
Tue, 6 Aug 2024 12:58:14 +0000 (14:58 +0200)
Add controller attach/detach support by using
usb_gadget_ops.pullup() function.

Signed-off-by: Zixun LI <admin@hifiphile.com>
Reviewed-by: Marek Vasut <marex@denx.de>
Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Link: https://lore.kernel.org/r/20240725153204.358925-7-admin@hifiphile.com
Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
drivers/usb/gadget/atmel_usba_udc.c

index ea9ad7585eb4de6058371a68dee2dfcaa5e89788..a7b96449f8ef2ddf5a31a87a113a93a39f01e6ee 100644 (file)
@@ -506,10 +506,28 @@ usba_udc_set_selfpowered(struct usb_gadget *gadget, int is_selfpowered)
        return 0;
 }
 
+static int usba_udc_pullup(struct usb_gadget *gadget, int is_on)
+{
+       struct usba_udc *udc = to_usba_udc(gadget);
+       u32 ctrl;
+
+       ctrl = usba_readl(udc, CTRL);
+
+       if (is_on)
+               ctrl &= ~USBA_DETACH;
+       else
+               ctrl |= USBA_DETACH;
+
+       usba_writel(udc, CTRL, ctrl);
+
+       return 0;
+}
+
 static const struct usb_gadget_ops usba_udc_ops = {
        .get_frame              = usba_udc_get_frame,
        .wakeup                 = usba_udc_wakeup,
        .set_selfpowered        = usba_udc_set_selfpowered,
+       .pullup                 = usba_udc_pullup,
 };
 
 static struct usb_endpoint_descriptor usba_ep0_desc = {