[PATCH 2/3] usb: gadget: atmel: Add attach/detach support
Marek Vasut
marex at denx.de
Mon Jul 22 13:42:12 CEST 2024
On 7/22/24 10:47 AM, Zixun LI wrote:
> 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 327e90a786..48d66d9774 100644
> --- a/drivers/usb/gadget/atmel_usba_udc.c
> +++ b/drivers/usb/gadget/atmel_usba_udc.c
> @@ -1176,6 +1176,23 @@ static int usba_disable(struct usba_udc *udc)
> return 0;
> }
>
> +static int usba_gadget_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;
> @@ -1273,6 +1290,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_gadget_pullup,
The function should probably be called usba_udc_pullup() to be
consistent with the names of the other functions.
More information about the U-Boot
mailing list