u-boot-dfu-20240711

Usb gadget:
- A welcome cleanup: epautoconf workaround is dropped to use
  .match_ep() instead
- Introduce handle_interrupts() op for USB_GADGET_GENERIC, which
  allows a per-driver interrupt handling

Fastboot:
- Fix mssing include when building with TCP only
This commit is contained in:
Tom Rini
2024-07-11 16:12:39 -06:00
20 changed files with 223 additions and 406 deletions

View File

@@ -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) || \

View File

@@ -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 */

View File

@@ -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;
}

View File

@@ -194,16 +194,6 @@ 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)
{
struct dwc3_generic_priv *priv = dev_get_priv(dev);
struct dwc3 *dwc3 = &priv->dwc3;
dwc3_gadget_uboot_handle_interrupt(dwc3);
return 0;
}
static int dwc3_generic_peripheral_probe(struct udevice *dev)
{
struct dwc3_generic_priv *priv = dev_get_priv(dev);
@@ -218,10 +208,25 @@ static int dwc3_generic_peripheral_remove(struct udevice *dev)
return dwc3_generic_remove(dev, priv);
}
static int dwc3_gadget_handle_interrupts(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;
}
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),

View File

@@ -99,15 +99,6 @@ 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)
{
struct dwc3_layerscape_priv *priv = dev_get_priv(dev);
dwc3_gadget_uboot_handle_interrupt(&priv->dwc3);
return 0;
}
static int dwc3_layerscape_peripheral_probe(struct udevice *dev)
{
struct dwc3_layerscape_priv *priv = dev_get_priv(dev);
@@ -122,10 +113,24 @@ static int dwc3_layerscape_peripheral_remove(struct udevice *dev)
return dwc3_layerscape_remove(dev, priv);
}
static int dwc3_layerscape_gadget_handle_interrupts(struct udevice *dev)
{
struct dwc3_layerscape_priv *priv = dev_get_priv(dev);
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),

View File

@@ -1606,6 +1606,38 @@ static int dwc3_gadget_stop(struct usb_gadget *g)
return 0;
}
static struct usb_ep *dwc3_find_ep(struct usb_gadget *gadget, const char *name)
{
struct usb_ep *ep;
list_for_each_entry(ep, &gadget->ep_list, ep_list)
if (!strcmp(ep->name, name))
return ep;
return NULL;
}
static struct
usb_ep *dwc3_gadget_match_ep(struct usb_gadget *gadget,
struct usb_endpoint_descriptor *desc,
struct usb_ss_ep_comp_descriptor *comp_desc)
{
/*
* First try standard, common configuration: ep1in-bulk,
* ep2out-bulk, ep3in-int to match other udc drivers to avoid
* confusion in already deployed software (endpoint numbers
* hardcoded in userspace software/drivers)
*/
if (usb_endpoint_is_bulk_in(desc))
return dwc3_find_ep(gadget, "ep1in");
if (usb_endpoint_is_bulk_out(desc))
return dwc3_find_ep(gadget, "ep2out");
if (usb_endpoint_is_int_in(desc))
return dwc3_find_ep(gadget, "ep3in");
return NULL;
}
static const struct usb_gadget_ops dwc3_gadget_ops = {
.get_frame = dwc3_gadget_get_frame,
.wakeup = dwc3_gadget_wakeup,
@@ -1613,6 +1645,7 @@ static const struct usb_gadget_ops dwc3_gadget_ops = {
.pullup = dwc3_gadget_pullup,
.udc_start = dwc3_gadget_start,
.udc_stop = dwc3_gadget_stop,
.match_ep = dwc3_gadget_match_ep,
};
/* -------------------------------------------------------------------------- */

View File

@@ -941,11 +941,6 @@ int dwc2_udc_handle_interrupt(void)
return 0;
}
int dm_usb_gadget_handle_interrupts(struct udevice *dev)
{
return dwc2_udc_handle_interrupt();
}
#if CONFIG_IS_ENABLED(DM_USB_GADGET)
struct dwc2_priv_data {
struct clk_bulk clks;
@@ -1173,6 +1168,15 @@ static int dwc2_udc_otg_remove(struct udevice *dev)
return dm_scan_fdt_dev(dev);
}
static int dwc2_gadget_handle_interrupts(struct udevice *dev)
{
return dwc2_udc_handle_interrupt();
}
static const struct usb_gadget_generic_ops dwc2_gadget_ops = {
.handle_interrupts = dwc2_gadget_handle_interrupts,
};
static const struct udevice_id dwc2_udc_otg_ids[] = {
{ .compatible = "snps,dwc2" },
{ .compatible = "brcm,bcm2835-usb" },
@@ -1185,6 +1189,7 @@ U_BOOT_DRIVER(dwc2_udc_otg) = {
.name = "dwc2-udc-otg",
.id = UCLASS_USB_GADGET_GENERIC,
.of_match = dwc2_udc_otg_ids,
.ops = &dwc2_gadget_ops,
.of_to_plat = dwc2_udc_otg_of_to_plat,
.probe = dwc2_udc_otg_probe,
.remove = dwc2_udc_otg_remove,
@@ -1200,4 +1205,9 @@ int dwc2_udc_B_session_valid(struct udevice *dev)
return readl(&usbotg_reg->gotgctl) & B_SESSION_VALID;
}
#else
int dm_usb_gadget_handle_interrupts(struct udevice *dev)
{
return dwc2_udc_handle_interrupt();
}
#endif /* CONFIG_IS_ENABLED(DM_USB_GADGET) */

View File

@@ -12,7 +12,6 @@
#include <linux/errno.h>
#include <linux/usb/gadget.h>
#include <asm/unaligned.h>
#include "gadget_chips.h"
#define isdigit(c) ('0' <= (c) && (c) <= '9')
@@ -167,18 +166,6 @@ static int ep_matches(
return 1;
}
static struct usb_ep *
find_ep(struct usb_gadget *gadget, const char *name)
{
struct usb_ep *ep;
list_for_each_entry(ep, &gadget->ep_list, ep_list) {
if (0 == strcmp(ep->name, name))
return ep;
}
return NULL;
}
/**
* usb_ep_autoconfig - choose an endpoint matching the descriptor
* @gadget: The device to which the endpoint must belong.
@@ -214,75 +201,13 @@ struct usb_ep *usb_ep_autoconfig(
struct usb_endpoint_descriptor *desc
)
{
struct usb_ep *ep = NULL;
u8 type;
struct usb_ep *ep;
type = desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK;
/* First, apply chip-specific "best usage" knowledge.
* This might make a good usb_gadget_ops hook ...
*/
if (gadget_is_net2280(gadget) && type == USB_ENDPOINT_XFER_INT) {
/* ep-e, ep-f are PIO with only 64 byte fifos */
ep = find_ep(gadget, "ep-e");
if (ep && ep_matches(gadget, ep, desc))
return ep;
ep = find_ep(gadget, "ep-f");
if (ep && ep_matches(gadget, ep, desc))
return ep;
} else if (gadget_is_goku(gadget)) {
if (USB_ENDPOINT_XFER_INT == type) {
/* single buffering is enough */
ep = find_ep(gadget, "ep3-bulk");
if (ep && ep_matches(gadget, ep, desc))
return ep;
} else if (USB_ENDPOINT_XFER_BULK == type
&& (USB_DIR_IN & desc->bEndpointAddress)) {
/* DMA may be available */
ep = find_ep(gadget, "ep2-bulk");
if (ep && ep_matches(gadget, ep, desc))
return ep;
}
} else if (gadget_is_sh(gadget) && USB_ENDPOINT_XFER_INT == type) {
/* single buffering is enough; maybe 8 byte fifo is too */
ep = find_ep(gadget, "ep3in-bulk");
if (ep && ep_matches(gadget, ep, desc))
return ep;
} else if (gadget_is_mq11xx(gadget) && USB_ENDPOINT_XFER_INT == type) {
ep = find_ep(gadget, "ep1-bulk");
if (ep && ep_matches(gadget, ep, desc))
return ep;
#ifndef CONFIG_SPL_BUILD
} else if (gadget_is_dwc3(gadget)) {
const char *name = NULL;
/*
* First try standard, common configuration: ep1in-bulk,
* ep2out-bulk, ep3in-int to match other udc drivers to avoid
* confusion in already deployed software (endpoint numbers
* hardcoded in userspace software/drivers)
*/
if ((desc->bEndpointAddress & USB_DIR_IN) &&
type == USB_ENDPOINT_XFER_BULK)
name = "ep1in";
else if ((desc->bEndpointAddress & USB_DIR_IN) == 0 &&
type == USB_ENDPOINT_XFER_BULK)
name = "ep2out";
else if ((desc->bEndpointAddress & USB_DIR_IN) &&
type == USB_ENDPOINT_XFER_INT)
name = "ep3in";
if (name)
ep = find_ep(gadget, name);
if (ep && ep_matches(gadget, ep, desc))
return ep;
#endif
}
if (gadget->ops->match_ep)
if (gadget->ops->match_ep) {
ep = gadget->ops->match_ep(gadget, desc, NULL);
if (ep && ep_matches(gadget, ep, desc))
return ep;
}
/* Second, look at endpoints until an unclaimed one looks usable */
list_for_each_entry(ep, &gadget->ep_list, ep_list) {

View File

@@ -22,8 +22,8 @@
#include <malloc.h>
#include <memalign.h>
#include <linux/ctype.h>
#include <version.h>
#include "gadget_chips.h"
#include "rndis.h"
#include <dm.h>
@@ -1989,28 +1989,15 @@ static int eth_bind(struct usb_gadget *gadget)
* standard protocol is _strongly_ preferred for interop purposes.
* (By everyone except Microsoft.)
*/
if (gadget_is_musbhdrc(gadget)) {
if (IS_ENABLED(CONFIG_USB_MUSB_GADGET) &&
!strcmp("musb-hdrc", gadget->name)) {
/* reduce tx dma overhead by avoiding special cases */
zlp = 0;
} else if (gadget_is_sh(gadget)) {
/* sh doesn't support multiple interfaces or configs */
cdc = 0;
rndis = 0;
}
gcnum = usb_gadget_controller_number(gadget);
if (gcnum >= 0)
device_desc.bcdDevice = cpu_to_le16(0x0300 + gcnum);
else {
/*
* can't assume CDC works. don't want to default to
* anything less functional on CDC-capable hardware,
* so we fail in this case.
*/
pr_err("controller '%s' not recognized",
gadget->name);
return -ENODEV;
}
gcnum = (U_BOOT_VERSION_NUM << 4) | U_BOOT_VERSION_NUM_PATCH;
device_desc.bcdDevice = cpu_to_le16(gcnum);
/*
* If there's an RNDIS configuration, that's what Windows wants to

View File

@@ -17,10 +17,10 @@
#include <usb_mass_storage.h>
#include <dfu.h>
#include <thor.h>
#include <version.h>
#include <env_callback.h>
#include "gadget_chips.h"
#include "composite.c"
/*
@@ -199,18 +199,6 @@ void g_dnl_clear_detach(void)
g_dnl_detach_request = false;
}
static int g_dnl_get_bcd_device_number(struct usb_composite_dev *cdev)
{
struct usb_gadget *gadget = cdev->gadget;
int gcnum;
gcnum = usb_gadget_controller_number(gadget);
if (gcnum > 0)
gcnum += 0x200;
return g_dnl_get_board_bcd_device_number(gcnum);
}
/**
* Update internal serial number variable when the "serial#" env var changes.
*
@@ -261,7 +249,8 @@ static int g_dnl_bind(struct usb_composite_dev *cdev)
if (ret)
goto error;
gcnum = g_dnl_get_bcd_device_number(cdev);
gcnum = g_dnl_get_board_bcd_device_number((U_BOOT_VERSION_NUM << 4) |
U_BOOT_VERSION_NUM_PATCH);
if (gcnum >= 0)
device_desc.bcdDevice = cpu_to_le16(gcnum);
else {

View File

@@ -1,210 +0,0 @@
/*
* USB device controllers have lots of quirks. Use these macros in
* gadget drivers or other code that needs to deal with them, and which
* autoconfigures instead of using early binding to the hardware.
*
* This SHOULD eventually work like the ARM mach_is_*() stuff, driven by
* some config file that gets updated as new hardware is supported.
* (And avoiding all runtime comparisons in typical one-choice configs!)
*
* NOTE: some of these controller drivers may not be available yet.
* Some are available on 2.4 kernels; several are available, but not
* yet pushed in the 2.6 mainline tree.
*
* Ported to U-Boot by: Thomas Smits <ts.smits@gmail.com> and
* Remy Bohmer <linux@bohmer.net>
*/
#ifdef CONFIG_USB_GADGET_NET2280
#define gadget_is_net2280(g) (!strcmp("net2280", (g)->name))
#else
#define gadget_is_net2280(g) 0
#endif
#ifdef CONFIG_USB_GADGET_AMD5536UDC
#define gadget_is_amd5536udc(g) (!strcmp("amd5536udc", (g)->name))
#else
#define gadget_is_amd5536udc(g) 0
#endif
#ifdef CONFIG_USB_GADGET_DUMMY_HCD
#define gadget_is_dummy(g) (!strcmp("dummy_udc", (g)->name))
#else
#define gadget_is_dummy(g) 0
#endif
#ifdef CONFIG_USB_GADGET_GOKU
#define gadget_is_goku(g) (!strcmp("goku_udc", (g)->name))
#else
#define gadget_is_goku(g) 0
#endif
/* SH3 UDC -- not yet ported 2.4 --> 2.6 */
#ifdef CONFIG_USB_GADGET_SUPERH
#define gadget_is_sh(g) (!strcmp("sh_udc", (g)->name))
#else
#define gadget_is_sh(g) 0
#endif
/* handhelds.org tree (?) */
#ifdef CONFIG_USB_GADGET_MQ11XX
#define gadget_is_mq11xx(g) (!strcmp("mq11xx_udc", (g)->name))
#else
#define gadget_is_mq11xx(g) 0
#endif
#ifdef CONFIG_USB_GADGET_OMAP
#define gadget_is_omap(g) (!strcmp("omap_udc", (g)->name))
#else
#define gadget_is_omap(g) 0
#endif
/* not yet ported 2.4 --> 2.6 */
#ifdef CONFIG_USB_GADGET_N9604
#define gadget_is_n9604(g) (!strcmp("n9604_udc", (g)->name))
#else
#define gadget_is_n9604(g) 0
#endif
#ifdef CONFIG_USB_GADGET_ATMEL_USBA
#define gadget_is_atmel_usba(g) (!strcmp("atmel_usba_udc", (g)->name))
#else
#define gadget_is_atmel_usba(g) 0
#endif
#ifdef CONFIG_USB_GADGET_AT91
#define gadget_is_at91(g) (!strcmp("at91_udc", (g)->name))
#else
#define gadget_is_at91(g) 0
#endif
/* status unclear */
#ifdef CONFIG_USB_GADGET_IMX
#define gadget_is_imx(g) (!strcmp("imx_udc", (g)->name))
#else
#define gadget_is_imx(g) 0
#endif
#ifdef CONFIG_USB_GADGET_FSL_USB2
#define gadget_is_fsl_usb2(g) (!strcmp("fsl-usb2-udc", (g)->name))
#else
#define gadget_is_fsl_usb2(g) 0
#endif
/* Mentor high speed function controller */
/* from Montavista kernel (?) */
#ifdef CONFIG_USB_GADGET_MUSBHSFC
#define gadget_is_musbhsfc(g) (!strcmp("musbhsfc_udc", (g)->name))
#else
#define gadget_is_musbhsfc(g) 0
#endif
/* Mentor high speed "dual role" controller, in peripheral role */
#ifdef CONFIG_USB_MUSB_GADGET
#define gadget_is_musbhdrc(g) (!strcmp("musb-hdrc", (g)->name))
#else
#define gadget_is_musbhdrc(g) 0
#endif
#ifdef CONFIG_USB_GADGET_M66592
#define gadget_is_m66592(g) (!strcmp("m66592_udc", (g)->name))
#else
#define gadget_is_m66592(g) 0
#endif
#ifdef CONFIG_CI_UDC
#define gadget_is_ci(g) (!strcmp("ci_udc", (g)->name))
#else
#define gadget_is_ci(g) 0
#endif
#ifdef CONFIG_USB_DWC3_GADGET
#define gadget_is_dwc3(g) (!strcmp("dwc3-gadget", (g)->name))
#else
#define gadget_is_dwc3(g) 0
#endif
#ifdef CONFIG_USB_CDNS3_GADGET
#define gadget_is_cdns3(g) (!strcmp("cdns3-gadget", (g)->name))
#else
#define gadget_is_cdns3(g) 0
#endif
#ifdef CONFIG_USB_GADGET_MAX3420
#define gadget_is_max3420(g) (!strcmp("max3420-udc", (g)->name))
#else
#define gadget_is_max3420(g) 0
#endif
#ifdef CONFIG_USB_MTU3_GADGET
#define gadget_is_mtu3(g) (!strcmp("mtu3-gadget", (g)->name))
#else
#define gadget_is_mtu3(g) 0
#endif
#ifdef CONFIG_USB_GADGET_DWC2_OTG
#define gadget_is_dwc2(g) (!strcmp("dwc2-udc", (g)->name))
#else
#define gadget_is_dwc2(g) 0
#endif
/**
* usb_gadget_controller_number - support bcdDevice id convention
* @gadget: the controller being driven
*
* Return a 2-digit BCD value associated with the peripheral controller,
* suitable for use as part of a bcdDevice value, or a negative error code.
*
* NOTE: this convention is purely optional, and has no meaning in terms of
* any USB specification. If you want to use a different convention in your
* gadget driver firmware -- maybe a more formal revision ID -- feel free.
*
* Hosts see these bcdDevice numbers, and are allowed (but not encouraged!)
* to change their behavior accordingly. For example it might help avoiding
* some chip bug.
*/
static inline int usb_gadget_controller_number(struct usb_gadget *gadget)
{
if (gadget_is_net2280(gadget))
return 0x01;
else if (gadget_is_dummy(gadget))
return 0x02;
else if (gadget_is_sh(gadget))
return 0x04;
else if (gadget_is_goku(gadget))
return 0x06;
else if (gadget_is_mq11xx(gadget))
return 0x07;
else if (gadget_is_omap(gadget))
return 0x08;
else if (gadget_is_n9604(gadget))
return 0x09;
else if (gadget_is_at91(gadget))
return 0x12;
else if (gadget_is_imx(gadget))
return 0x13;
else if (gadget_is_musbhsfc(gadget))
return 0x14;
else if (gadget_is_musbhdrc(gadget))
return 0x15;
else if (gadget_is_atmel_usba(gadget))
return 0x17;
else if (gadget_is_fsl_usb2(gadget))
return 0x18;
else if (gadget_is_amd5536udc(gadget))
return 0x19;
else if (gadget_is_m66592(gadget))
return 0x20;
else if (gadget_is_ci(gadget))
return 0x21;
else if (gadget_is_dwc3(gadget))
return 0x23;
else if (gadget_is_cdns3(gadget))
return 0x24;
else if (gadget_is_max3420(gadget))
return 0x25;
else if (gadget_is_mtu3(gadget))
return 0x26;
else if (gadget_is_dwc2(gadget))
return 0x27;
return -ENOENT;
}

View File

@@ -808,13 +808,6 @@ static void max3420_setup_spi(struct max3420_udc *udc)
spi_wr8(udc, MAX3420_REG_PINCTL, bFDUPSPI);
}
int dm_usb_gadget_handle_interrupts(struct udevice *dev)
{
struct max3420_udc *udc = dev_get_priv(dev);
return max3420_irq(udc);
}
static int max3420_udc_probe(struct udevice *dev)
{
struct max3420_udc *udc = dev_get_priv(dev);
@@ -859,6 +852,17 @@ static int max3420_udc_remove(struct udevice *dev)
return 0;
}
static int max3420_gadget_handle_interrupts(struct udevice *dev)
{
struct max3420_udc *udc = dev_get_priv(dev);
return max3420_irq(udc);
}
static const struct usb_gadget_generic_ops max3420_gadget_ops = {
.handle_interrupts = max3420_gadget_handle_interrupts,
};
static const struct udevice_id max3420_ids[] = {
{ .compatible = "maxim,max3421-udc" },
{ }
@@ -868,6 +872,7 @@ U_BOOT_DRIVER(max3420_generic_udc) = {
.name = "max3420-udc",
.id = UCLASS_USB_GADGET_GENERIC,
.of_match = max3420_ids,
.ops = &max3420_gadget_ops,
.probe = max3420_udc_probe,
.remove = max3420_udc_remove,
.priv_auto = sizeof(struct max3420_udc),

View File

@@ -12,6 +12,25 @@
#include <linux/usb/gadget.h>
#if CONFIG_IS_ENABLED(DM_USB_GADGET)
static inline const struct usb_gadget_generic_ops *
usb_gadget_generic_dev_ops(struct udevice *dev)
{
return (const struct usb_gadget_generic_ops *)dev->driver->ops;
}
int dm_usb_gadget_handle_interrupts(struct udevice *dev)
{
const struct usb_gadget_generic_ops *ops;
ops = usb_gadget_generic_dev_ops(dev);
if (!ops)
return -EFAULT;
if (!ops->handle_interrupts)
return -ENOSYS;
return ops->handle_interrupts(dev);
}
int udc_device_get_by_index(int index, struct udevice **udev)
{
struct udevice *dev = NULL;
@@ -54,6 +73,11 @@ int udc_device_put(struct udevice *udev)
{
return board_usb_cleanup(legacy_index, USB_INIT_DEVICE);
}
__weak int dm_usb_gadget_handle_interrupts(struct udevice *dev)
{
return 0;
}
#endif
#if CONFIG_IS_ENABLED(DM)

View File

@@ -123,12 +123,7 @@ static int sandbox_submit_int(struct udevice *bus, struct usb_device *udev,
return ret;
}
#if CONFIG_IS_ENABLED(DM_USB_GADGET)
int dm_usb_gadget_handle_interrupts(struct udevice *dev)
{
return 0;
}
#else
#if !CONFIG_IS_ENABLED(DM_USB_GADGET)
int usb_gadget_register_driver(struct usb_gadget_driver *driver)
{
struct sandbox_udc *dev = this_controller;

View File

@@ -223,15 +223,6 @@ static const struct udevice_id ssusb_of_match[] = {
};
#if CONFIG_IS_ENABLED(DM_USB_GADGET)
int dm_usb_gadget_handle_interrupts(struct udevice *dev)
{
struct mtu3 *mtu = dev_get_priv(dev);
mtu3_irq(0, mtu);
return 0;
}
static int mtu3_gadget_probe(struct udevice *dev)
{
struct ssusb_mtk *ssusb = dev_to_ssusb(dev->parent);
@@ -250,10 +241,24 @@ static int mtu3_gadget_remove(struct udevice *dev)
return 0;
}
static int mtu3_gadget_handle_interrupts(struct udevice *dev)
{
struct mtu3 *mtu = dev_get_priv(dev);
mtu3_irq(0, mtu);
return 0;
}
static const struct usb_gadget_generic_ops mtu3_gadget_ops = {
.handle_interrupts = mtu3_gadget_handle_interrupts,
};
U_BOOT_DRIVER(mtu3_peripheral) = {
.name = "mtu3-peripheral",
.id = UCLASS_USB_GADGET_GENERIC,
.of_match = ssusb_of_match,
.ops = &mtu3_gadget_ops,
.probe = mtu3_gadget_probe,
.remove = mtu3_gadget_remove,
.priv_auto = sizeof(struct mtu3),

View File

@@ -46,16 +46,6 @@ static inline void omap2430_low_level_init(struct musb *musb)
musb_writel(musb->mregs, OTG_FORCESTDBY, l);
}
#ifdef CONFIG_DM_USB_GADGET
int dm_usb_gadget_handle_interrupts(struct udevice *dev)
{
struct musb_host_data *host = dev_get_priv(dev);
host->host->isr(0, host->host);
return 0;
}
#endif
static int omap2430_musb_init(struct musb *musb)
{
u32 l;
@@ -273,6 +263,21 @@ static int omap2430_musb_remove(struct udevice *dev)
return 0;
}
#ifndef CONFIG_USB_MUSB_HOST
static int omap2340_gadget_handle_interrupts(struct udevice *dev)
{
struct musb_host_data *host = dev_get_priv(dev);
host->host->isr(0, host->host);
return 0;
}
static const struct usb_gadget_generic_ops omap2340_gadget_ops = {
.handle_interrupts = omap2340_gadget_handle_interrupts,
};
#endif
static const struct udevice_id omap2430_musb_ids[] = {
{ .compatible = "ti,omap3-musb" },
{ .compatible = "ti,omap4-musb" },
@@ -285,6 +290,7 @@ U_BOOT_DRIVER(omap2430_musb) = {
.id = UCLASS_USB,
#else
.id = UCLASS_USB_GADGET_GENERIC,
.ops = &omap2340_gadget_ops,
#endif
.of_match = omap2430_musb_ids,
.of_to_plat = omap2430_musb_of_to_plat,

View File

@@ -233,15 +233,6 @@ static int ti_musb_peripheral_of_to_plat(struct udevice *dev)
}
#endif
int dm_usb_gadget_handle_interrupts(struct udevice *dev)
{
struct ti_musb_peripheral *priv = dev_get_priv(dev);
priv->periph->isr(0, priv->periph);
return 0;
}
static int ti_musb_peripheral_probe(struct udevice *dev)
{
struct ti_musb_peripheral *priv = dev_get_priv(dev);
@@ -269,12 +260,26 @@ static int ti_musb_peripheral_remove(struct udevice *dev)
return 0;
}
static int ti_musb_gadget_handle_interrupts(struct udevice *dev)
{
struct ti_musb_peripheral *priv = dev_get_priv(dev);
priv->periph->isr(0, priv->periph);
return 0;
}
static const struct usb_gadget_generic_ops ti_musb_gadget_ops = {
.handle_interrupts = ti_musb_gadget_handle_interrupts,
};
U_BOOT_DRIVER(ti_musb_peripheral) = {
.name = "ti-musb-peripheral",
.id = UCLASS_USB_GADGET_GENERIC,
#if CONFIG_IS_ENABLED(OF_CONTROL)
.of_to_plat = ti_musb_peripheral_of_to_plat,
#endif
.ops = &ti_musb_gadget_ops,
.probe = ti_musb_peripheral_probe,
.remove = ti_musb_peripheral_remove,
.ops = &musb_usb_ops,

View File

@@ -91,14 +91,6 @@ static const struct musb_platform_ops ux500_musb_ops = {
.disable = ux500_musb_disable,
};
int dm_usb_gadget_handle_interrupts(struct udevice *dev)
{
struct ux500_glue *glue = dev_get_priv(dev);
glue->mdata.host->isr(0, glue->mdata.host);
return 0;
}
static int ux500_musb_probe(struct udevice *dev)
{
#ifdef CONFIG_USB_MUSB_HOST
@@ -155,6 +147,19 @@ static int ux500_musb_remove(struct udevice *dev)
return 0;
}
static int ux500_gadget_handle_interrupts(struct udevice *dev)
{
struct ux500_glue *glue = dev_get_priv(dev);
glue->mdata.host->isr(0, glue->mdata.host);
return 0;
}
static const struct usb_gadget_generic_ops ux500_gadget_ops = {
.handle_interrupts = ux500_gadget_handle_interrupts,
};
static const struct udevice_id ux500_musb_ids[] = {
{ .compatible = "stericsson,db8500-musb" },
{ }
@@ -168,6 +173,7 @@ U_BOOT_DRIVER(ux500_musb) = {
.id = UCLASS_USB_GADGET_GENERIC,
#endif
.of_match = ux500_musb_ids,
.ops = &ux500_gadget_ops,
.probe = ux500_musb_probe,
.remove = ux500_musb_remove,
#ifdef CONFIG_USB_MUSB_HOST

View File

@@ -12,6 +12,8 @@
#ifndef _FASTBOOT_H_
#define _FASTBOOT_H_
#include <linux/types.h>
#define FASTBOOT_VERSION "0.4"
/*

View File

@@ -970,6 +970,14 @@ extern void usb_ep_autoconfig_reset(struct usb_gadget *);
extern int dm_usb_gadget_handle_interrupts(struct udevice *);
/**
* struct usb_gadget_generic_ops - The functions that a gadget driver must implement.
* @handle_interrupts: Handle UDC interrupts.
*/
struct usb_gadget_generic_ops {
int (*handle_interrupts)(struct udevice *udevice);
};
/**
* udc_device_get_by_index() - Get UDC udevice by index
* @index: UDC device index