diff options
Diffstat (limited to 'drivers/usb/gadget')
31 files changed, 63 insertions, 416 deletions
diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c index e573a03477b..86b2cbf3f6a 100644 --- a/drivers/usb/gadget/at91_udc.c +++ b/drivers/usb/gadget/at91_udc.c @@ -13,7 +13,6 @@ #undef VERBOSE_DEBUG #undef PACKET_TRACE -#include <common.h> #include <dm/devres.h> #include <linux/bug.h> #include <linux/err.h> diff --git a/drivers/usb/gadget/atmel_usba_udc.c b/drivers/usb/gadget/atmel_usba_udc.c index 4c420747b0b..f99553df8d4 100644 --- a/drivers/usb/gadget/atmel_usba_udc.c +++ b/drivers/usb/gadget/atmel_usba_udc.c @@ -7,7 +7,6 @@ * Bo Shen <voice.shen@atmel.com> */ -#include <common.h> #include <linux/bitops.h> #include <linux/errno.h> #include <asm/gpio.h> diff --git a/drivers/usb/gadget/bcm_udc_otg_phy.c b/drivers/usb/gadget/bcm_udc_otg_phy.c index c89cd57c253..9875191091c 100644 --- a/drivers/usb/gadget/bcm_udc_otg_phy.c +++ b/drivers/usb/gadget/bcm_udc_otg_phy.c @@ -4,7 +4,6 @@ */ #include <config.h> -#include <common.h> #include <asm/io.h> #include <asm/arch/sysmap.h> #include <asm/kona-common/clk.h> diff --git a/drivers/usb/gadget/ci_udc.c b/drivers/usb/gadget/ci_udc.c index 750d4714879..bbe03cfff1f 100644 --- a/drivers/usb/gadget/ci_udc.c +++ b/drivers/usb/gadget/ci_udc.c @@ -7,7 +7,6 @@ * Murray.Jensen@cmst.csiro.au, 27-Jan-01. */ -#include <common.h> #include <command.h> #include <config.h> #include <cpu_func.h> diff --git a/drivers/usb/gadget/config.c b/drivers/usb/gadget/config.c index e96782644f3..e41b1d964ea 100644 --- a/drivers/usb/gadget/config.c +++ b/drivers/usb/gadget/config.c @@ -8,7 +8,6 @@ * Remy Bohmer <linux@bohmer.net> */ -#include <common.h> #include <asm/unaligned.h> #include <linux/errno.h> #include <linux/list.h> @@ -17,7 +16,6 @@ #include <linux/usb/ch9.h> #include <linux/usb/gadget.h> - /** * usb_descriptor_fillbuf - fill buffer with descriptors * @buf: Buffer to be filled @@ -52,7 +50,6 @@ usb_descriptor_fillbuf(void *buf, unsigned buflen, return dest - (u8 *)buf; } - /** * usb_gadget_config_buf - builts a complete configuration descriptor * @config: Header for the descriptor, including characteristics such diff --git a/drivers/usb/gadget/core.c b/drivers/usb/gadget/core.c index 888f0cfea66..bcb1ad3082c 100644 --- a/drivers/usb/gadget/core.c +++ b/drivers/usb/gadget/core.c @@ -22,7 +22,6 @@ #define MAX_INTERFACES 2 - int maxstrings = 20; /* Global variables ************************************************************************** */ @@ -65,10 +64,8 @@ __maybe_unused static char *usbd_device_status[] = { #define USBD_DEVICE_STATUS(x) (((unsigned int)x <= USBD_CLOSING) ? usbd_device_status[x] : "UNKNOWN") - /* Descriptor support functions ************************************************************** */ - /** * usbd_get_string - find and return a string descriptor * @index: string index to return @@ -83,10 +80,8 @@ struct usb_string_descriptor *usbd_get_string (__u8 index) return usb_strings[index]; } - /* Access to device descriptor functions ***************************************************** */ - /* * * usbd_device_configuration_instance - find a configuration instance for this device * @device: @@ -103,7 +98,6 @@ static struct usb_configuration_instance *usbd_device_configuration_instance (st return device->configuration_instance_array + configuration; } - /* * * usbd_device_interface_instance * @device: @@ -149,7 +143,6 @@ struct usb_alternate_instance *usbd_device_alternate_instance (struct usb_device return interface_instance->alternates_instance_array + alternate; } - /* * * usbd_device_device_descriptor * @device: which device @@ -182,7 +175,6 @@ struct usb_configuration_descriptor *usbd_device_configuration_descriptor (struc return (configuration_instance->configuration_descriptor); } - /** * usbd_device_interface_descriptor * @device: which device @@ -231,7 +223,6 @@ struct usb_endpoint_descriptor *usbd_device_endpoint_descriptor_index (struct us return *(alternate_instance->endpoints_descriptor_array + index); } - /** * usbd_device_endpoint_transfersize * @device: which device @@ -255,7 +246,6 @@ int usbd_device_endpoint_transfersize (struct usb_device_instance *device, int p return *(alternate_instance->endpoint_transfersize_array + index); } - /** * usbd_device_endpoint_descriptor * @device: which device @@ -292,7 +282,6 @@ int usbd_endpoint_halted (struct usb_device_instance *device, int endpoint) return (device->status == USB_STATUS_HALT); } - /** * usbd_rcv_complete - complete a receive * @endpoint: @@ -460,7 +449,6 @@ struct urb *first_urb_detached (urb_link * hd) return urb; } - /* * Append an urb_link (or a whole list of * urb_links) to the tail of another list diff --git a/drivers/usb/gadget/dwc2_udc_otg.c b/drivers/usb/gadget/dwc2_udc_otg.c index 27082f5152c..7e9dd6f4268 100644 --- a/drivers/usb/gadget/dwc2_udc_otg.c +++ b/drivers/usb/gadget/dwc2_udc_otg.c @@ -17,7 +17,6 @@ * Lukasz Majewski <l.majewski@samsumg.com> */ #undef DEBUG -#include <common.h> #include <clk.h> #include <dm.h> #include <generic-phy.h> @@ -942,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; @@ -1174,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" }, @@ -1186,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, @@ -1201,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) */ diff --git a/drivers/usb/gadget/dwc2_udc_otg_phy.c b/drivers/usb/gadget/dwc2_udc_otg_phy.c index 7f8e9564b9e..c7eea7b3442 100644 --- a/drivers/usb/gadget/dwc2_udc_otg_phy.c +++ b/drivers/usb/gadget/dwc2_udc_otg_phy.c @@ -17,7 +17,6 @@ * Lukasz Majewski <l.majewski@samsumg.com> */ -#include <common.h> #include <linux/delay.h> #include <linux/errno.h> #include <linux/list.h> diff --git a/drivers/usb/gadget/dwc2_udc_otg_regs.h b/drivers/usb/gadget/dwc2_udc_otg_regs.h index 9ca6f423757..01056fab1c2 100644 --- a/drivers/usb/gadget/dwc2_udc_otg_regs.h +++ b/drivers/usb/gadget/dwc2_udc_otg_regs.h @@ -204,7 +204,6 @@ struct dwc2_usbotg_reg { #define DIEPCTL0_NEXT_EP_BIT (11) - /* DWC2_UDC_OTG_DIEPMSK/DOEPMSK device IN/OUT endpoint common interrupt mask register */ /* DWC2_UDC_OTG_DIEPINTn/DOEPINTn device IN/OUT endpoint interrupt register */ diff --git a/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c b/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c index 1c34b753511..c0408bae076 100644 --- a/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c +++ b/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c @@ -17,7 +17,6 @@ * Lukasz Majewski <l.majewski@samsumg.com> */ -#include <common.h> #include <cpu_func.h> #include <log.h> #include <linux/bug.h> @@ -93,7 +92,6 @@ static inline void dwc2_ep0_complete_out(void) } - static int setdma_rx(struct dwc2_ep *ep, struct dwc2_request *req) { u32 *buf, ctrl; @@ -973,7 +971,6 @@ static void dwc2_udc_set_nak(struct dwc2_ep *ep) return; } - static void dwc2_udc_ep_set_stall(struct dwc2_ep *ep) { u8 ep_num; @@ -1441,7 +1438,6 @@ static void dwc2_ep0_setup(struct dwc2_udc *dev) } } - if (likely(dev->driver)) { /* device-2-host (IN) or no data setup command, * process immediately */ @@ -1463,7 +1459,6 @@ static void dwc2_ep0_setup(struct dwc2_udc *dev) " bRequest = %d\n", i, usb_ctrl->bRequest); - } else if (dev->req_pending) { dev->req_pending = 0; debug_cond(DEBUG_SETUP != 0, diff --git a/drivers/usb/gadget/ep0.c b/drivers/usb/gadget/ep0.c index c256cc31fbd..8c7fc17c2ea 100644 --- a/drivers/usb/gadget/ep0.c +++ b/drivers/usb/gadget/ep0.c @@ -36,7 +36,6 @@ * XXX */ -#include <common.h> #include <serial.h> #include <usbdevice.h> @@ -94,7 +93,6 @@ __maybe_unused static char *usbd_device_requests[] = { /* EP0 Configuration Set ********************************************************************* */ - /** * ep0_get_status - fill in URB data with appropriate status * @device: @@ -377,7 +375,6 @@ static int ep0_get_descriptor (struct usb_device_instance *device, return -1; } - dbg_ep0 (1, "urb: buffer: %p buffer_length: %2d actual_length: %2d tx_packetSize: %2d", urb->buffer, urb->buffer_length, urb->actual_length, device->bus->endpoint_array[0].tx_packetSize); @@ -422,7 +419,6 @@ int ep0_recv_setup (struct urb *urb) dbg_ep0 (3, "urb: %p device: %p", urb, urb->device); - /*dbg_ep0(2, "- - - - - - - - - -"); */ dbg_ep0 (2, @@ -534,7 +530,6 @@ int ep0_recv_setup (struct urb *urb) /* handle the requests that do not return data */ else { - /*dbg_ep0(3, "Host-to-Device"); */ switch (request->bRequest) { diff --git a/drivers/usb/gadget/ep0.h b/drivers/usb/gadget/ep0.h index 976825ab93e..a16d36be938 100644 --- a/drivers/usb/gadget/ep0.h +++ b/drivers/usb/gadget/ep0.h @@ -18,8 +18,6 @@ #ifndef __USBDCORE_EP0_H__ #define __USBDCORE_EP0_H__ - int ep0_recv_setup (struct urb *urb); - #endif diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c index bb0d2971d06..495460473e9 100644 --- a/drivers/usb/gadget/epautoconf.c +++ b/drivers/usb/gadget/epautoconf.c @@ -8,12 +8,10 @@ * Remy Bohmer <linux@bohmer.net> */ -#include <common.h> #include <linux/usb/ch9.h> #include <linux/errno.h> #include <linux/usb/gadget.h> #include <asm/unaligned.h> -#include "gadget_chips.h" #define isdigit(c) ('0' <= (c) && (c) <= '9') @@ -26,7 +24,6 @@ static unsigned epnum; static unsigned in_epnum; #endif - /* * This should work with endpoints from controller drivers sharing the * same endpoint naming convention. By example: @@ -168,18 +165,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. @@ -215,76 +200,14 @@ struct usb_ep *usb_ep_autoconfig( struct usb_endpoint_descriptor *desc ) { - struct usb_ep *ep = NULL; - u8 type; - - type = desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK; + struct usb_ep *ep; - /* 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 (gadget->ops->match_ep) { + ep = gadget->ops->match_ep(gadget, desc, NULL); if (ep && ep_matches(gadget, ep, desc)) return ep; -#endif } - if (gadget->ops->match_ep) - ep = gadget->ops->match_ep(gadget, desc, NULL); - /* Second, look at endpoints until an unclaimed one looks usable */ list_for_each_entry(ep, &gadget->ep_list, ep_list) { if (ep_matches(gadget, ep, desc)) diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c index 36618f0bdf3..7973927e8a7 100644 --- a/drivers/usb/gadget/ether.c +++ b/drivers/usb/gadget/ether.c @@ -7,7 +7,6 @@ * Copyright (C) 2008 Nokia Corporation */ -#include <common.h> #include <console.h> #include <env.h> #include <log.h> @@ -23,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> @@ -36,7 +35,6 @@ extern struct platform_data brd; - unsigned packet_received, packet_sent; /* @@ -274,7 +272,6 @@ static char dev_addr[18]; static char host_addr[18]; - /*-------------------------------------------------------------------------*/ /* @@ -807,7 +804,6 @@ static const struct usb_descriptor_header *hs_rndis_function[] = { }; #endif - /* maxpacket and other transfer characteristics vary by speed. */ static inline struct usb_endpoint_descriptor * ep_desc(struct usb_gadget *g, struct usb_endpoint_descriptor *hs, @@ -1990,28 +1986,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 @@ -2151,7 +2134,6 @@ autoconf_fail: #endif } - /* network device setup */ dev->net = l_priv->netdev; diff --git a/drivers/usb/gadget/f_acm.c b/drivers/usb/gadget/f_acm.c index ba216128ab2..f18c6a0a761 100644 --- a/drivers/usb/gadget/f_acm.c +++ b/drivers/usb/gadget/f_acm.c @@ -10,7 +10,6 @@ */ #include <circbuf.h> -#include <common.h> #include <console.h> #include <errno.h> #include <g_dnl.h> diff --git a/drivers/usb/gadget/f_dfu.c b/drivers/usb/gadget/f_dfu.c index 44877df4ec6..ca8b36e077b 100644 --- a/drivers/usb/gadget/f_dfu.c +++ b/drivers/usb/gadget/f_dfu.c @@ -16,7 +16,6 @@ #include <env.h> #include <errno.h> -#include <common.h> #include <log.h> #include <malloc.h> diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index 09e740cc962..8df0e3f331d 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -11,7 +11,6 @@ */ #include <command.h> #include <config.h> -#include <common.h> #include <env.h> #include <errno.h> #include <fastboot.h> diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c index ef90c7ec7fb..ffe1ae6eb73 100644 --- a/drivers/usb/gadget/f_mass_storage.c +++ b/drivers/usb/gadget/f_mass_storage.c @@ -244,7 +244,6 @@ #include <hexdump.h> #include <log.h> #include <malloc.h> -#include <common.h> #include <console.h> #include <g_dnl.h> #include <dm/devres.h> @@ -388,7 +387,6 @@ struct fsg_dev { struct usb_ep *bulk_out; }; - static inline int __fsg_is_set(struct fsg_common *common, const char *func, unsigned line) { @@ -405,13 +403,11 @@ static inline int __fsg_is_set(struct fsg_common *common, #define fsg_is_set(common) likely(__fsg_is_set(common, __func__, __LINE__)) - static inline struct fsg_dev *fsg_from_func(struct usb_function *f) { return container_of(f, struct fsg_dev, function); } - typedef void (*fsg_routine_t)(struct fsg_dev *); static int exception_in_progress(struct fsg_common *common) @@ -1119,7 +1115,6 @@ static int do_inquiry(struct fsg_common *common, struct fsg_buffhd *bh) return 36; } - static int do_request_sense(struct fsg_common *common, struct fsg_buffhd *bh) { struct fsg_lun *curlun = &common->luns[common->lun]; @@ -1211,7 +1206,6 @@ static int do_read_header(struct fsg_common *common, struct fsg_buffhd *bh) return 8; } - static int do_read_toc(struct fsg_common *common, struct fsg_buffhd *bh) { struct fsg_lun *curlun = &common->luns[common->lun]; @@ -1320,7 +1314,6 @@ static int do_mode_sense(struct fsg_common *common, struct fsg_buffhd *bh) return len; } - static int do_start_stop(struct fsg_common *common) { struct fsg_lun *curlun = &common->luns[common->lun]; @@ -1359,7 +1352,6 @@ static int do_prevent_allow(struct fsg_common *common) return 0; } - static int do_read_format_capacities(struct fsg_common *common, struct fsg_buffhd *bh) { @@ -1377,7 +1369,6 @@ static int do_read_format_capacities(struct fsg_common *common, return 12; } - static int do_mode_select(struct fsg_common *common, struct fsg_buffhd *bh) { struct fsg_lun *curlun = &common->luns[common->lun]; @@ -1388,7 +1379,6 @@ static int do_mode_select(struct fsg_common *common, struct fsg_buffhd *bh) return -EINVAL; } - /*-------------------------------------------------------------------------*/ static int halt_bulk_in_endpoint(struct fsg_dev *fsg) @@ -1513,7 +1503,6 @@ static int throw_away_data(struct fsg_common *common) return 0; } - static int finish_reply(struct fsg_common *common) { struct fsg_buffhd *bh = common->next_buffhd_to_fill; @@ -1609,7 +1598,6 @@ static int finish_reply(struct fsg_common *common) return rc; } - static int send_status(struct fsg_common *common) { struct fsg_lun *curlun = &common->luns[common->lun]; @@ -1665,7 +1653,6 @@ static int send_status(struct fsg_common *common) return 0; } - /*-------------------------------------------------------------------------*/ /* Check whether the command is properly formed and whether its data size @@ -1793,7 +1780,6 @@ static int check_command_size_in_blocks(struct fsg_common *common, mask, needs_medium, name); } - static int do_scsi_command(struct fsg_common *common) { struct fsg_buffhd *bh; @@ -2128,7 +2114,6 @@ static int received_cbw(struct fsg_dev *fsg, struct fsg_buffhd *bh) return 0; } - static int get_next_command(struct fsg_common *common) { struct fsg_buffhd *bh; @@ -2167,7 +2152,6 @@ static int get_next_command(struct fsg_common *common) return rc; } - /*-------------------------------------------------------------------------*/ static int enable_endpoint(struct fsg_common *common, struct usb_ep *ep, @@ -2280,10 +2264,8 @@ reset: return rc; } - /****************************** ALT CONFIGS ******************************/ - static int fsg_set_alt(struct usb_function *f, unsigned intf, unsigned alt) { struct fsg_dev *fsg = fsg_from_func(f); @@ -2604,7 +2586,6 @@ static void fsg_common_release(struct kref *ref) kfree(common); } - /*-------------------------------------------------------------------------*/ /** @@ -2723,7 +2704,6 @@ autoconf_fail: return -ENOTSUPP; } - /****************************** ADD FUNCTION ******************************/ static struct usb_gadget_strings *fsg_strings_array[] = { diff --git a/drivers/usb/gadget/f_rockusb.c b/drivers/usb/gadget/f_rockusb.c index 98a7ffa2a75..d679cdae97c 100644 --- a/drivers/usb/gadget/f_rockusb.c +++ b/drivers/usb/gadget/f_rockusb.c @@ -6,7 +6,6 @@ */ #include <command.h> #include <config.h> -#include <common.h> #include <env.h> #include <errno.h> #include <log.h> diff --git a/drivers/usb/gadget/f_sdp.c b/drivers/usb/gadget/f_sdp.c index ca2760c00d0..514c097591b 100644 --- a/drivers/usb/gadget/f_sdp.c +++ b/drivers/usb/gadget/f_sdp.c @@ -17,7 +17,6 @@ */ #include <errno.h> -#include <common.h> #include <console.h> #include <env.h> #include <log.h> @@ -589,7 +588,6 @@ static struct usb_request *alloc_ep_req(struct usb_ep *ep, unsigned length) return req; } - static struct usb_request *sdp_start_ep(struct usb_ep *ep, bool in) { struct usb_request *req; diff --git a/drivers/usb/gadget/f_thor.c b/drivers/usb/gadget/f_thor.c index 0e7529dcdbb..54372118348 100644 --- a/drivers/usb/gadget/f_thor.c +++ b/drivers/usb/gadget/f_thor.c @@ -15,7 +15,6 @@ */ #include <command.h> -#include <common.h> #include <console.h> #include <dm.h> #include <errno.h> diff --git a/drivers/usb/gadget/g_dnl.c b/drivers/usb/gadget/g_dnl.c index afb7b74f305..631969b3405 100644 --- a/drivers/usb/gadget/g_dnl.c +++ b/drivers/usb/gadget/g_dnl.c @@ -6,7 +6,6 @@ * Lukasz Majewski <l.majewski@samsung.com> */ -#include <common.h> #include <log.h> #include <malloc.h> @@ -18,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" /* @@ -200,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. * @@ -262,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 { diff --git a/drivers/usb/gadget/gadget_chips.h b/drivers/usb/gadget/gadget_chips.h deleted file mode 100644 index 98156c312d2..00000000000 --- a/drivers/usb/gadget/gadget_chips.h +++ /dev/null @@ -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; -} diff --git a/drivers/usb/gadget/max3420_udc.c b/drivers/usb/gadget/max3420_udc.c index fa655c98dcc..557a1f0644e 100644 --- a/drivers/usb/gadget/max3420_udc.c +++ b/drivers/usb/gadget/max3420_udc.c @@ -1,6 +1,5 @@ // SPDX-License-Identifier: GPL-2.0+ -#include <common.h> #include <linux/errno.h> #include <linux/delay.h> #include <asm/gpio.h> @@ -809,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); @@ -860,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" }, { } @@ -869,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), diff --git a/drivers/usb/gadget/ndis.h b/drivers/usb/gadget/ndis.h index 753838f7941..371d37ff05a 100644 --- a/drivers/usb/gadget/ndis.h +++ b/drivers/usb/gadget/ndis.h @@ -21,7 +21,6 @@ #ifndef _USBGADGET_NDIS_H #define _USBGADGET_NDIS_H - #define NDIS_STATUS_MULTICAST_FULL 0xC0010009 #define NDIS_STATUS_MULTICAST_EXISTS 0xC001000A #define NDIS_STATUS_MULTICAST_NOT_FOUND 0xC001000B @@ -60,7 +59,6 @@ struct NDIS_PM_PACKET_PATTERN { __le32 PatternFlags; }; - /* Required Object IDs (OIDs) */ #define OID_GEN_SUPPORTED_LIST 0x00010101 #define OID_GEN_HARDWARE_STATUS 0x00010102 diff --git a/drivers/usb/gadget/rndis.c b/drivers/usb/gadget/rndis.c index e7276ccd37a..76801bff9a3 100644 --- a/drivers/usb/gadget/rndis.c +++ b/drivers/usb/gadget/rndis.c @@ -18,7 +18,6 @@ * updates to merge with Linux 2.6, better match RNDIS spec */ -#include <common.h> #include <log.h> #include <net.h> #include <malloc.h> @@ -54,7 +53,6 @@ static const __le32 rndis_driver_version = __constant_cpu_to_le32(1); /* Function Prototypes */ static rndis_resp_t *rndis_add_response(int configNr, u32 length); - /* supported OIDs */ static const u32 oid_supported_list[] = { /* the general stuff */ @@ -139,7 +137,6 @@ static const u32 oid_supported_list[] = { #endif /* RNDIS_PM */ }; - /* NDIS Functions */ static int gen_ndis_query_resp(int configNr, u32 OID, u8 *buf, unsigned buf_len, rndis_resp_t *r) @@ -943,7 +940,6 @@ static int rndis_keepalive_response(int configNr, return 0; } - /* * Device to Host Comunication */ diff --git a/drivers/usb/gadget/rndis.h b/drivers/usb/gadget/rndis.h index 77db55a563f..84b6aeffb08 100644 --- a/drivers/usb/gadget/rndis.h +++ b/drivers/usb/gadget/rndis.h @@ -72,7 +72,6 @@ #define OID_PNP_REMOVE_WAKE_UP_PATTERN 0xFD010104 #define OID_PNP_ENABLE_WAKE_UP 0xFD010106 - typedef struct rndis_init_msg_type { __le32 MessageType; __le32 MessageLength; diff --git a/drivers/usb/gadget/storage_common.c b/drivers/usb/gadget/storage_common.c index 97dc6b6f729..7e4b542f7ce 100644 --- a/drivers/usb/gadget/storage_common.c +++ b/drivers/usb/gadget/storage_common.c @@ -13,7 +13,6 @@ * Ćukasz Majewski <l.majewski@samsung.com> */ - /* * This file requires the following identifiers used in USB strings to * be defined (each of type pointer to char): @@ -46,10 +45,8 @@ * characters rather then a pointer to void. */ - /* #include <asm/unaligned.h> */ - /* * Thanks to NetChip Technologies for donating this product ID. * diff --git a/drivers/usb/gadget/udc/udc-core.c b/drivers/usb/gadget/udc/udc-core.c index ba658d92296..6bb419ae2ab 100644 --- a/drivers/usb/gadget/udc/udc-core.c +++ b/drivers/usb/gadget/udc/udc-core.c @@ -19,7 +19,6 @@ #include <malloc.h> #include <asm/cache.h> #include <linux/dma-mapping.h> -#include <common.h> #include <dm.h> #include <dm/device-internal.h> #include <linux/usb/ch9.h> diff --git a/drivers/usb/gadget/udc/udc-uclass.c b/drivers/usb/gadget/udc/udc-uclass.c index 30ee1cab066..fbe62bbce47 100644 --- a/drivers/usb/gadget/udc/udc-uclass.c +++ b/drivers/usb/gadget/udc/udc-uclass.c @@ -6,13 +6,31 @@ #define LOG_CATEGORY UCLASS_USB_GADGET_GENERIC -#include <common.h> #include <dm.h> #include <dm/device-internal.h> #include <linux/printk.h> #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; @@ -55,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) diff --git a/drivers/usb/gadget/usbstring.c b/drivers/usb/gadget/usbstring.c index e2464ad923f..4617a95bd0a 100644 --- a/drivers/usb/gadget/usbstring.c +++ b/drivers/usb/gadget/usbstring.c @@ -6,7 +6,6 @@ * Remy Bohmer <linux@bohmer.net> */ -#include <common.h> #include <linux/errno.h> #include <linux/usb/ch9.h> #include <linux/usb/gadget.h> |