Hi Romain,

On 2026-07-02T08:11:07, Romain Gantois <[email protected]> wrote:
> usb: gadget: Add Renesas RZ/N1 USBF controller support
>
> Add support for the Renesas USBF controller. This is an USB2.0 UDC
> controller available in the RZ/N1 SoC.
>
> This driver was originally written by Hervé Codina for the Linux kernel.
> Suspend/resume features have been removed in this U-Boot port.
>
> Linux revision this was ported from:
>
> 74851fbb6d64 usb: gadget: renesas_usbf: Handle devm_pm_runtime_...
>
> Signed-off-by: Herve Codina <[email protected]>
> Co-developed-by: Romain Gantois (Schneider Electric) 
> <[email protected]>
> Signed-off-by: Romain Gantois (Schneider Electric) 
> <[email protected]>
> Tested-by: Ralph Siemsen <[email protected]>
>
> MAINTAINERS                       |    5 +
>  drivers/usb/gadget/Kconfig        |    9 +
>  drivers/usb/gadget/Makefile       |    1 +
>  drivers/usb/gadget/renesas_usbf.c | 3036 
> +++++++++++++++++++++++++++++++++++++
>  4 files changed, 3051 insertions(+)

> This driver was originally written by Hervé Codina for the Linux kernel.
> Suspend/resume features have been removed in this U-Boot port.

Please also mention the two other removals noted in the cover letter -
handling of endpoints > 2 and dynamic detection of endpoint DMA
capability. Otherwise users will be surprised when a gadget needing
more than two endpoints fails to bind.

> +     for (i = 0; i < ARRAY_SIZE(udc->ep); i++) {
> +             ep = &udc->ep[i];
> +
> +             if (!(usbf_reg_readl(udc, USBF_REG_USBSSCONF) &
> +                   USBF_SYS_EP_AVAILABLE(i))) {
> +                     continue;
> +             }
> +
> +             INIT_LIST_HEAD(&ep->queue);

If the availability check fails, INIT_LIST_HEAD() is never called and
ep->disabled stays 0. usbf_reset() and usbf_detach() then iterate over
all slots and only skip disabled == 1, so they will call
usbf_ep_nuke() on an ep whose queue list is uninitialised. On RZ/N1
all three endpoints are always present so this is latent, but please
set ep->disabled = 1 before the continue (or at least init the
list_head).

> diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
> @@ -159,6 +159,15 @@ config CI_UDC
> +config USB_GADGET_RENESAS_USBF
> +     bool 'Renesas USB Function controller'
> +     depends on RZN1
> +     depends on DM_USB_GADGET
> +     select USB_GADGET_DUALSPEED
> +     help
> +        Renesas USB Function controller is a USB peripheral controller
> +        available on RZ/N1 Renesas SoCs.

Two Kconfig nits: prompts use double quotes throughout the file. Also,
the help text is indented one space more than the tab + two spaces
convention used by the neighbouring entries - compare with CI_UDC just
above.

> diff --git a/drivers/usb/gadget/renesas_usbf.c 
> b/drivers/usb/gadget/renesas_usbf.c
> @@ -0,0 +1,3036 @@
> +static int usbf_remove(struct udevice *dev)
> +{
> +     struct usbf_udc *udc = dev_get_priv(dev);
> +
> +     usb_del_gadget_udc(&udc->gadget);
> +
> +     return 0;
> +}

Just to check - if the device is removed while the pull-up is still
asserted, D+ stays driven and interrupts remain enabled at the EPC
level. Would it be worth calling usbf_detach() here so remove() always
leaves the hardware quiescent? What do you think?

Regards,
Simon

Reply via email to