usb: gadget: cdns3: Convert interrupt handling to usb_gadget_generic_ops

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.

Keep the dm_usb_gadget_handle_interrupts() in this driver for non-DM
case for now, until this driver gets fully converted to DM USB gadget.

Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Tested-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> # vim3
Link: https://lore.kernel.org/r/20240614005309.34433-3-marek.vasut+renesas@mailbox.org
Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
diff --git a/drivers/usb/cdns3/core.c b/drivers/usb/cdns3/core.c
index b4e9316..cbe06a9 100644
--- a/drivers/usb/cdns3/core.c
+++ b/drivers/usb/cdns3/core.c
@@ -20,6 +20,7 @@
 #include <linux/bug.h>
 #include <linux/kernel.h>
 #include <linux/io.h>
+#include <linux/usb/gadget.h>
 #include <usb.h>
 #include <usb/xhci.h>
 
@@ -462,15 +463,38 @@
 	return cdns3_remove(cdns);
 }
 
+static int cdns3_gadget_handle_interrupts(struct udevice *dev)
+{
+	struct cdns3 *cdns = dev_get_priv(dev);
+
+	cdns3_gadget_uboot_handle_interrupt(cdns);
+
+	return 0;
+}
+
+static const struct usb_gadget_generic_ops cdns3_gadget_ops = {
+	.handle_interrupts	= cdns3_gadget_handle_interrupts,
+};
+
 U_BOOT_DRIVER(cdns_usb3_peripheral) = {
 	.name	= "cdns-usb3-peripheral",
 	.id	= UCLASS_USB_GADGET_GENERIC,
 	.of_match = cdns3_ids,
+	.ops	= &cdns3_gadget_ops,
 	.probe = cdns3_gadget_probe,
 	.remove = cdns3_gadget_remove,
 	.priv_auto	= sizeof(struct cdns3_gadget_priv),
 	.flags = DM_FLAG_ALLOC_PRIV_DMA,
 };
+#else
+int dm_usb_gadget_handle_interrupts(struct udevice *dev)
+{
+	struct cdns3 *cdns = dev_get_priv(dev);
+
+	cdns3_gadget_uboot_handle_interrupt(cdns);
+
+	return 0;
+}
 #endif
 
 #if defined(CONFIG_SPL_USB_HOST) || \