[PATCH 02/11] usb: gadget: cdns3: Convert interrupt handling to usb_gadget_generic_ops
Marek Vasut
marek.vasut+renesas at mailbox.org
Fri Jun 14 02:51:17 CEST 2024
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 at mailbox.org>
---
Cc: Alexander Sverdlin <alexander.sverdlin at siemens.com>
Cc: Felipe Balbi <felipe.balbi at linux.intel.com>
Cc: Lukasz Majewski <lukma at denx.de>
Cc: Mattijs Korpershoek <mkorpershoek at baylibre.com>
Cc: Nishanth Menon <nm at ti.com>
Cc: Simon Glass <sjg at chromium.org>
Cc: Thinh Nguyen <Thinh.Nguyen at synopsys.com>
Cc: Tom Rini <trini at konsulko.com>
Cc: u-boot at lists.denx.de
---
drivers/usb/cdns3/core.c | 24 ++++++++++++++++++++++++
drivers/usb/cdns3/gadget-export.h | 2 ++
drivers/usb/cdns3/gadget.c | 11 +----------
3 files changed, 27 insertions(+), 10 deletions(-)
diff --git a/drivers/usb/cdns3/core.c b/drivers/usb/cdns3/core.c
index b4e931646b8..cbe06a9e7b6 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 @@ static int cdns3_gadget_remove(struct udevice *dev)
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) || \
diff --git a/drivers/usb/cdns3/gadget-export.h b/drivers/usb/cdns3/gadget-export.h
index 577469eee96..b3fd7c53039 100644
--- a/drivers/usb/cdns3/gadget-export.h
+++ b/drivers/usb/cdns3/gadget-export.h
@@ -25,4 +25,6 @@ static inline void cdns3_gadget_exit(struct cdns3 *cdns) { }
#endif
+void cdns3_gadget_uboot_handle_interrupt(struct cdns3 *cdns);
+
#endif /* __LINUX_CDNS3_GADGET_EXPORT */
diff --git a/drivers/usb/cdns3/gadget.c b/drivers/usb/cdns3/gadget.c
index d11175dc5b6..32b2c412068 100644
--- a/drivers/usb/cdns3/gadget.c
+++ b/drivers/usb/cdns3/gadget.c
@@ -2755,19 +2755,10 @@ int cdns3_gadget_init(struct cdns3 *cdns)
*
* Handles ep0 and gadget interrupt
*/
-static void cdns3_gadget_uboot_handle_interrupt(struct cdns3 *cdns)
+void cdns3_gadget_uboot_handle_interrupt(struct cdns3 *cdns)
{
int ret = cdns3_device_irq_handler(0, cdns);
if (ret == IRQ_WAKE_THREAD)
cdns3_device_thread_irq_handler(0, cdns);
}
-
-int dm_usb_gadget_handle_interrupts(struct udevice *dev)
-{
- struct cdns3 *cdns = dev_get_priv(dev);
-
- cdns3_gadget_uboot_handle_interrupt(cdns);
-
- return 0;
-}
--
2.43.0
More information about the U-Boot
mailing list