[PATCH v2 3/4] usb: gadget: atmel: Add attach/detach support

Zixun LI admin at hifiphile.com
Mon Jul 22 22:23:29 CEST 2024


Add controller attach/detach support by using
usb_gadget_ops.pullup() method.

Signed-off-by: Zixun LI <zli at ogga.fr>
---
 drivers/usb/gadget/atmel_usba_udc.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/drivers/usb/gadget/atmel_usba_udc.c b/drivers/usb/gadget/atmel_usba_udc.c
index 3e3c5cb403..46f7ae9a0c 100644
--- a/drivers/usb/gadget/atmel_usba_udc.c
+++ b/drivers/usb/gadget/atmel_usba_udc.c
@@ -1176,6 +1176,23 @@ static int usba_udc_disable(struct usba_udc *udc)
 	return 0;
 }
 
+static int usba_udc_pullup(struct usb_gadget *g, int is_on)
+{
+	struct usba_udc *udc = controller;
+	u32 ctrl;
+
+	ctrl = usba_readl(udc, CTRL);
+
+	if (is_on)
+		ctrl &= ~USBA_DETACH;
+	else
+		ctrl |= USBA_DETACH;
+
+	usba_writel(udc, CTRL, ctrl);
+
+	return 0;
+}
+
 int dm_usb_gadget_handle_interrupts(struct udevice *dev)
 {
 	struct usba_udc *udc = controller;
@@ -1233,6 +1250,7 @@ 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 usba_udc udc_controller = {
-- 
2.45.2



More information about the U-Boot mailing list