diff mbox series

[04/11] usb: gadget: dwc3: Convert interrupt handling to usb_gadget_generic_ops

Message ID 20240614005309.34433-5-marek.vasut+renesas@mailbox.org
State Accepted
Commit 75f94ed82ff0a8c021decaa9a0eda56d48cba716
Delegated to: Mattijs Korpershoek
Headers show
Series usb: gadget: Introduce handle_interrupts ops to USB_GADGET_GENERIC uclass | expand

Commit Message

Marek Vasut June 14, 2024, 12:51 a.m. UTC
Implement .handle_interrupts callback as a replacement for deprecated
dm_usb_gadget_handle_interrupts() function. The new callback allows
for each DM capable USB gadget controller driver to define its own
IRQ handling implementation without colliding with other controller
drivers.

Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
---
Cc: Alexander Sverdlin <alexander.sverdlin@siemens.com>
Cc: Felipe Balbi <felipe.balbi@linux.intel.com>
Cc: Lukasz Majewski <lukma@denx.de>
Cc: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Cc: Nishanth Menon <nm@ti.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Cc: Tom Rini <trini@konsulko.com>
Cc: u-boot@lists.denx.de
---
 drivers/usb/dwc3/dwc3-generic.c    | 23 ++++++++++++++---------
 drivers/usb/dwc3/dwc3-layerscape.c | 21 +++++++++++++--------
 2 files changed, 27 insertions(+), 17 deletions(-)

Comments

Mattijs Korpershoek June 18, 2024, 7:27 a.m. UTC | #1
Hi Marek,

Thank you for the patch.

On ven., juin 14, 2024 at 02:51, Marek Vasut <marek.vasut+renesas@mailbox.org> wrote:

> Implement .handle_interrupts callback as a replacement for deprecated
> dm_usb_gadget_handle_interrupts() function. The new callback allows
> for each DM capable USB gadget controller driver to define its own
> IRQ handling implementation without colliding with other controller
> drivers.
>
> Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>

Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>

> ---
> Cc: Alexander Sverdlin <alexander.sverdlin@siemens.com>
> Cc: Felipe Balbi <felipe.balbi@linux.intel.com>
> Cc: Lukasz Majewski <lukma@denx.de>
> Cc: Mattijs Korpershoek <mkorpershoek@baylibre.com>
> Cc: Nishanth Menon <nm@ti.com>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
> Cc: Tom Rini <trini@konsulko.com>
> Cc: u-boot@lists.denx.de
> ---
>  drivers/usb/dwc3/dwc3-generic.c    | 23 ++++++++++++++---------
>  drivers/usb/dwc3/dwc3-layerscape.c | 21 +++++++++++++--------
>  2 files changed, 27 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c
> index 8db678eb85d..731ede2fead 100644
> --- a/drivers/usb/dwc3/dwc3-generic.c
> +++ b/drivers/usb/dwc3/dwc3-generic.c
> @@ -194,34 +194,39 @@ static int dwc3_generic_of_to_plat(struct udevice *dev)
>  }
>  
>  #if CONFIG_IS_ENABLED(DM_USB_GADGET)
> -int dm_usb_gadget_handle_interrupts(struct udevice *dev)
> +static int dwc3_generic_peripheral_probe(struct udevice *dev)
>  {
>  	struct dwc3_generic_priv *priv = dev_get_priv(dev);
> -	struct dwc3 *dwc3 = &priv->dwc3;
>  
> -	dwc3_gadget_uboot_handle_interrupt(dwc3);
> -
> -	return 0;
> +	return dwc3_generic_probe(dev, priv);
>  }
>  
> -static int dwc3_generic_peripheral_probe(struct udevice *dev)
> +static int dwc3_generic_peripheral_remove(struct udevice *dev)
>  {
>  	struct dwc3_generic_priv *priv = dev_get_priv(dev);
>  
> -	return dwc3_generic_probe(dev, priv);
> +	return dwc3_generic_remove(dev, priv);
>  }
>  
> -static int dwc3_generic_peripheral_remove(struct udevice *dev)
> +static int dwc3_gadget_handle_interrupts(struct udevice *dev)
>  {
>  	struct dwc3_generic_priv *priv = dev_get_priv(dev);
> +	struct dwc3 *dwc3 = &priv->dwc3;
>  
> -	return dwc3_generic_remove(dev, priv);
> +	dwc3_gadget_uboot_handle_interrupt(dwc3);
> +
> +	return 0;
>  }
>  
> +static const struct usb_gadget_generic_ops dwc3_gadget_ops = {
> +	.handle_interrupts	= dwc3_gadget_handle_interrupts,
> +};
> +
>  U_BOOT_DRIVER(dwc3_generic_peripheral) = {
>  	.name	= "dwc3-generic-peripheral",
>  	.id	= UCLASS_USB_GADGET_GENERIC,
>  	.of_to_plat = dwc3_generic_of_to_plat,
> +	.ops	= &dwc3_gadget_ops,
>  	.probe = dwc3_generic_peripheral_probe,
>  	.remove = dwc3_generic_peripheral_remove,
>  	.priv_auto	= sizeof(struct dwc3_generic_priv),
> diff --git a/drivers/usb/dwc3/dwc3-layerscape.c b/drivers/usb/dwc3/dwc3-layerscape.c
> index ff83bf71e89..108b44c67eb 100644
> --- a/drivers/usb/dwc3/dwc3-layerscape.c
> +++ b/drivers/usb/dwc3/dwc3-layerscape.c
> @@ -99,33 +99,38 @@ static int dwc3_layerscape_of_to_plat(struct udevice *dev)
>  }
>  
>  #if CONFIG_IS_ENABLED(DM_USB_GADGET)
> -int dm_usb_gadget_handle_interrupts(struct udevice *dev)
> +static int dwc3_layerscape_peripheral_probe(struct udevice *dev)
>  {
>  	struct dwc3_layerscape_priv *priv = dev_get_priv(dev);
>  
> -	dwc3_gadget_uboot_handle_interrupt(&priv->dwc3);
> -
> -	return 0;
> +	return dwc3_layerscape_probe(dev, priv);
>  }
>  
> -static int dwc3_layerscape_peripheral_probe(struct udevice *dev)
> +static int dwc3_layerscape_peripheral_remove(struct udevice *dev)
>  {
>  	struct dwc3_layerscape_priv *priv = dev_get_priv(dev);
>  
> -	return dwc3_layerscape_probe(dev, priv);
> +	return dwc3_layerscape_remove(dev, priv);
>  }
>  
> -static int dwc3_layerscape_peripheral_remove(struct udevice *dev)
> +static int dwc3_layerscape_gadget_handle_interrupts(struct udevice *dev)
>  {
>  	struct dwc3_layerscape_priv *priv = dev_get_priv(dev);
>  
> -	return dwc3_layerscape_remove(dev, priv);
> +	dwc3_gadget_uboot_handle_interrupt(&priv->dwc3);
> +
> +	return 0;
>  }
>  
> +static const struct usb_gadget_generic_ops dwc3_layerscape_gadget_ops = {
> +	.handle_interrupts	= dwc3_layerscape_gadget_handle_interrupts,
> +};
> +
>  U_BOOT_DRIVER(dwc3_layerscape_peripheral) = {
>  	.name	= "dwc3-layerscape-peripheral",
>  	.id	= UCLASS_USB_GADGET_GENERIC,
>  	.of_to_plat = dwc3_layerscape_of_to_plat,
> +	.ops	= &dwc3_layerscape_gadget_ops,
>  	.probe = dwc3_layerscape_peripheral_probe,
>  	.remove = dwc3_layerscape_peripheral_remove,
>  	.priv_auto	= sizeof(struct dwc3_layerscape_priv),
> -- 
> 2.43.0
diff mbox series

Patch

diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c
index 8db678eb85d..731ede2fead 100644
--- a/drivers/usb/dwc3/dwc3-generic.c
+++ b/drivers/usb/dwc3/dwc3-generic.c
@@ -194,34 +194,39 @@  static int dwc3_generic_of_to_plat(struct udevice *dev)
 }
 
 #if CONFIG_IS_ENABLED(DM_USB_GADGET)
-int dm_usb_gadget_handle_interrupts(struct udevice *dev)
+static int dwc3_generic_peripheral_probe(struct udevice *dev)
 {
 	struct dwc3_generic_priv *priv = dev_get_priv(dev);
-	struct dwc3 *dwc3 = &priv->dwc3;
 
-	dwc3_gadget_uboot_handle_interrupt(dwc3);
-
-	return 0;
+	return dwc3_generic_probe(dev, priv);
 }
 
-static int dwc3_generic_peripheral_probe(struct udevice *dev)
+static int dwc3_generic_peripheral_remove(struct udevice *dev)
 {
 	struct dwc3_generic_priv *priv = dev_get_priv(dev);
 
-	return dwc3_generic_probe(dev, priv);
+	return dwc3_generic_remove(dev, priv);
 }
 
-static int dwc3_generic_peripheral_remove(struct udevice *dev)
+static int dwc3_gadget_handle_interrupts(struct udevice *dev)
 {
 	struct dwc3_generic_priv *priv = dev_get_priv(dev);
+	struct dwc3 *dwc3 = &priv->dwc3;
 
-	return dwc3_generic_remove(dev, priv);
+	dwc3_gadget_uboot_handle_interrupt(dwc3);
+
+	return 0;
 }
 
+static const struct usb_gadget_generic_ops dwc3_gadget_ops = {
+	.handle_interrupts	= dwc3_gadget_handle_interrupts,
+};
+
 U_BOOT_DRIVER(dwc3_generic_peripheral) = {
 	.name	= "dwc3-generic-peripheral",
 	.id	= UCLASS_USB_GADGET_GENERIC,
 	.of_to_plat = dwc3_generic_of_to_plat,
+	.ops	= &dwc3_gadget_ops,
 	.probe = dwc3_generic_peripheral_probe,
 	.remove = dwc3_generic_peripheral_remove,
 	.priv_auto	= sizeof(struct dwc3_generic_priv),
diff --git a/drivers/usb/dwc3/dwc3-layerscape.c b/drivers/usb/dwc3/dwc3-layerscape.c
index ff83bf71e89..108b44c67eb 100644
--- a/drivers/usb/dwc3/dwc3-layerscape.c
+++ b/drivers/usb/dwc3/dwc3-layerscape.c
@@ -99,33 +99,38 @@  static int dwc3_layerscape_of_to_plat(struct udevice *dev)
 }
 
 #if CONFIG_IS_ENABLED(DM_USB_GADGET)
-int dm_usb_gadget_handle_interrupts(struct udevice *dev)
+static int dwc3_layerscape_peripheral_probe(struct udevice *dev)
 {
 	struct dwc3_layerscape_priv *priv = dev_get_priv(dev);
 
-	dwc3_gadget_uboot_handle_interrupt(&priv->dwc3);
-
-	return 0;
+	return dwc3_layerscape_probe(dev, priv);
 }
 
-static int dwc3_layerscape_peripheral_probe(struct udevice *dev)
+static int dwc3_layerscape_peripheral_remove(struct udevice *dev)
 {
 	struct dwc3_layerscape_priv *priv = dev_get_priv(dev);
 
-	return dwc3_layerscape_probe(dev, priv);
+	return dwc3_layerscape_remove(dev, priv);
 }
 
-static int dwc3_layerscape_peripheral_remove(struct udevice *dev)
+static int dwc3_layerscape_gadget_handle_interrupts(struct udevice *dev)
 {
 	struct dwc3_layerscape_priv *priv = dev_get_priv(dev);
 
-	return dwc3_layerscape_remove(dev, priv);
+	dwc3_gadget_uboot_handle_interrupt(&priv->dwc3);
+
+	return 0;
 }
 
+static const struct usb_gadget_generic_ops dwc3_layerscape_gadget_ops = {
+	.handle_interrupts	= dwc3_layerscape_gadget_handle_interrupts,
+};
+
 U_BOOT_DRIVER(dwc3_layerscape_peripheral) = {
 	.name	= "dwc3-layerscape-peripheral",
 	.id	= UCLASS_USB_GADGET_GENERIC,
 	.of_to_plat = dwc3_layerscape_of_to_plat,
+	.ops	= &dwc3_layerscape_gadget_ops,
 	.probe = dwc3_layerscape_peripheral_probe,
 	.remove = dwc3_layerscape_peripheral_remove,
 	.priv_auto	= sizeof(struct dwc3_layerscape_priv),