diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-05-20 21:26:12 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-05-20 21:26:12 -0700 |
commit | 7a9b149212f3716c598afe973b6261fd58453b7a (patch) | |
tree | 477716d84c71da124448b72278e98da28aadbd3d /include/linux | |
parent | 3d62e3fdce8ef265a3706c52ae1ca6ab84e30f0e (diff) | |
parent | e26bcf37234c67624f62d9fc95f922b8dbda1363 (diff) | |
download | linux-3.10-7a9b149212f3716c598afe973b6261fd58453b7a.tar.gz linux-3.10-7a9b149212f3716c598afe973b6261fd58453b7a.tar.bz2 linux-3.10-7a9b149212f3716c598afe973b6261fd58453b7a.zip |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb-2.6: (229 commits)
USB: remove unused usb_buffer_alloc and usb_buffer_free macros
usb: musb: update gfp/slab.h includes
USB: ftdi_sio: fix legacy SIO-device header
USB: kl5usb105: reimplement using generic framework
USB: kl5usb105: minor clean ups
USB: kl5usb105: fix memory leak
USB: io_ti: use kfifo to implement write buffering
USB: io_ti: remove unsused private counter
USB: ti_usb: use kfifo to implement write buffering
USB: ir-usb: fix incorrect write-buffer length
USB: aircable: fix incorrect write-buffer length
USB: safe_serial: straighten out read processing
USB: safe_serial: reimplement read using generic framework
USB: safe_serial: reimplement write using generic framework
usb-storage: always print quirks
USB: usb-storage: trivial debug improvements
USB: oti6858: use port write fifo
USB: oti6858: use kfifo to implement write buffering
USB: cypress_m8: use kfifo to implement write buffering
USB: cypress_m8: remove unused drain define
...
Fix up conflicts (due to usb_buffer_alloc/free renaming) in
drivers/input/tablet/acecad.c
drivers/input/tablet/kbtab.c
drivers/input/tablet/wacom_sys.c
drivers/media/video/gspca/gspca.c
sound/usb/usbaudio.c
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/usb.h | 137 | ||||
-rw-r--r-- | include/linux/usb/Kbuild | 1 | ||||
-rw-r--r-- | include/linux/usb/atmel_usba_udc.h | 2 | ||||
-rw-r--r-- | include/linux/usb/audio.h | 6 | ||||
-rw-r--r-- | include/linux/usb/cdc.h | 94 | ||||
-rw-r--r-- | include/linux/usb/ch11.h | 167 | ||||
-rw-r--r-- | include/linux/usb/ch9.h | 16 | ||||
-rw-r--r-- | include/linux/usb/composite.h | 1 | ||||
-rw-r--r-- | include/linux/usb/ehci_def.h | 6 | ||||
-rw-r--r-- | include/linux/usb/functionfs.h | 199 | ||||
-rw-r--r-- | include/linux/usb/g_hid.h | 32 | ||||
-rw-r--r-- | include/linux/usb/gadget.h | 6 | ||||
-rw-r--r-- | include/linux/usb/gadgetfs.h | 2 | ||||
-rw-r--r-- | include/linux/usb/hcd.h | 625 | ||||
-rw-r--r-- | include/linux/usb/langwell_udc.h | 2 | ||||
-rw-r--r-- | include/linux/usb/musb.h | 40 | ||||
-rw-r--r-- | include/linux/usb/ncm.h | 114 | ||||
-rw-r--r-- | include/linux/usb/net2280.h | 6 | ||||
-rw-r--r-- | include/linux/usb/quirks.h | 4 | ||||
-rw-r--r-- | include/linux/usb/rndis_host.h | 66 | ||||
-rw-r--r-- | include/linux/usb/serial.h | 36 | ||||
-rw-r--r-- | include/linux/usb/ulpi.h | 140 | ||||
-rw-r--r-- | include/linux/usb/usbnet.h | 40 | ||||
-rw-r--r-- | include/linux/usb/wusb-wa.h | 2 | ||||
-rw-r--r-- | include/linux/wait.h | 149 |
25 files changed, 1741 insertions, 152 deletions
diff --git a/include/linux/usb.h b/include/linux/usb.h index 739f1fd1cc1..d5922a87799 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -45,27 +45,14 @@ struct wusb_dev; struct ep_device; -/* For SS devices */ -/** - * struct usb_host_ss_ep_comp - Valid for SuperSpeed devices only - * @desc: endpoint companion descriptor, wMaxPacketSize in native byteorder - * @extra: descriptors following this endpoint companion descriptor - * @extralen: how many bytes of "extra" are valid - */ -struct usb_host_ss_ep_comp { - struct usb_ss_ep_comp_descriptor desc; - unsigned char *extra; /* Extra descriptors */ - int extralen; -}; - /** * struct usb_host_endpoint - host-side endpoint descriptor and queue * @desc: descriptor for this endpoint, wMaxPacketSize in native byteorder + * @ss_ep_comp: SuperSpeed companion descriptor for this endpoint * @urb_list: urbs queued to this endpoint; maintained by usbcore * @hcpriv: for use by HCD; typically holds hardware dma queue head (QH) * with one or more transfer descriptors (TDs) per urb * @ep_dev: ep_device for sysfs info - * @ss_ep_comp: companion descriptor information for this endpoint * @extra: descriptors following this endpoint in the configuration * @extralen: how many bytes of "extra" are valid * @enabled: URBs may be submitted to this endpoint @@ -74,11 +61,11 @@ struct usb_host_ss_ep_comp { * descriptor within an active interface in a given USB configuration. */ struct usb_host_endpoint { - struct usb_endpoint_descriptor desc; + struct usb_endpoint_descriptor desc; + struct usb_ss_ep_comp_descriptor ss_ep_comp; struct list_head urb_list; void *hcpriv; - struct ep_device *ep_dev; /* For sysfs info */ - struct usb_host_ss_ep_comp *ss_ep_comp; /* For SS devices */ + struct ep_device *ep_dev; /* For sysfs info */ unsigned char *extra; /* Extra descriptors */ int extralen; @@ -109,8 +96,8 @@ enum usb_interface_condition { /** * struct usb_interface - what usb device drivers talk to * @altsetting: array of interface structures, one for each alternate - * setting that may be selected. Each one includes a set of - * endpoint configurations. They will be in no particular order. + * setting that may be selected. Each one includes a set of + * endpoint configurations. They will be in no particular order. * @cur_altsetting: the current altsetting. * @num_altsetting: number of altsettings defined. * @intf_assoc: interface association descriptor @@ -197,8 +184,6 @@ struct usb_interface { struct work_struct reset_ws; /* for resets in atomic context */ }; #define to_usb_interface(d) container_of(d, struct usb_interface, dev) -#define interface_to_usbdev(intf) \ - container_of(intf->dev.parent, struct usb_device, dev) static inline void *usb_get_intfdata(struct usb_interface *intf) { @@ -215,7 +200,7 @@ void usb_put_intf(struct usb_interface *intf); /* this maximum is arbitrary */ #define USB_MAXINTERFACES 32 -#define USB_MAXIADS USB_MAXINTERFACES/2 +#define USB_MAXIADS (USB_MAXINTERFACES/2) /** * struct usb_interface_cache - long-term representation of a device interface @@ -425,7 +410,6 @@ struct usb_tt; * @connect_time: time device was first connected * @do_remote_wakeup: remote wakeup should be enabled * @reset_resume: needs reset instead of resume - * @autosuspend_disabled: autosuspend disabled by the user * @wusb_dev: if this is a Wireless USB device, link to the WUSB * specific data for the device. * @slot_id: Slot ID assigned by xHCI @@ -436,7 +420,7 @@ struct usb_tt; */ struct usb_device { int devnum; - char devpath [16]; + char devpath[16]; u32 route; enum usb_device_state state; enum usb_device_speed speed; @@ -469,7 +453,7 @@ struct usb_device { unsigned persist_enabled:1; unsigned have_langid:1; unsigned authorized:1; - unsigned authenticated:1; + unsigned authenticated:1; unsigned wusb:1; int string_langid; @@ -501,13 +485,17 @@ struct usb_device { unsigned do_remote_wakeup:1; unsigned reset_resume:1; - unsigned autosuspend_disabled:1; #endif struct wusb_dev *wusb_dev; int slot_id; }; #define to_usb_device(d) container_of(d, struct usb_device, dev) +static inline struct usb_device *interface_to_usbdev(struct usb_interface *intf) +{ + return to_usb_device(intf->dev.parent); +} + extern struct usb_device *usb_get_dev(struct usb_device *dev); extern void usb_put_dev(struct usb_device *dev); @@ -522,12 +510,11 @@ extern int usb_lock_device_for_reset(struct usb_device *udev, extern int usb_reset_device(struct usb_device *dev); extern void usb_queue_reset_device(struct usb_interface *dev); -extern struct usb_device *usb_find_device(u16 vendor_id, u16 product_id); /* USB autosuspend and autoresume */ #ifdef CONFIG_USB_SUSPEND -extern int usb_enable_autosuspend(struct usb_device *udev); -extern int usb_disable_autosuspend(struct usb_device *udev); +extern void usb_enable_autosuspend(struct usb_device *udev); +extern void usb_disable_autosuspend(struct usb_device *udev); extern int usb_autopm_get_interface(struct usb_interface *intf); extern void usb_autopm_put_interface(struct usb_interface *intf); @@ -572,6 +559,16 @@ static inline void usb_mark_last_busy(struct usb_device *udev) /* for drivers using iso endpoints */ extern int usb_get_current_frame_number(struct usb_device *usb_dev); +/* Sets up a group of bulk endpoints to support multiple stream IDs. */ +extern int usb_alloc_streams(struct usb_interface *interface, + struct usb_host_endpoint **eps, unsigned int num_eps, + unsigned int num_streams, gfp_t mem_flags); + +/* Reverts a group of bulk endpoints back to not using stream IDs. */ +extern void usb_free_streams(struct usb_interface *interface, + struct usb_host_endpoint **eps, unsigned int num_eps, + gfp_t mem_flags); + /* used these for multi-interface device registration */ extern int usb_driver_claim_interface(struct usb_driver *driver, struct usb_interface *iface, void *priv); @@ -667,7 +664,7 @@ static inline int usb_make_path(struct usb_device *dev, char *buf, size_t size) * This macro is used to create a struct usb_device_id that matches a * specific device. */ -#define USB_DEVICE(vend,prod) \ +#define USB_DEVICE(vend, prod) \ .match_flags = USB_DEVICE_ID_MATCH_DEVICE, \ .idVendor = (vend), \ .idProduct = (prod) @@ -958,17 +955,25 @@ extern int usb_disabled(void); #define URB_ISO_ASAP 0x0002 /* iso-only, urb->start_frame * ignored */ #define URB_NO_TRANSFER_DMA_MAP 0x0004 /* urb->transfer_dma valid on submit */ -#define URB_NO_SETUP_DMA_MAP 0x0008 /* urb->setup_dma valid on submit */ #define URB_NO_FSBR 0x0020 /* UHCI-specific */ #define URB_ZERO_PACKET 0x0040 /* Finish bulk OUT with short packet */ #define URB_NO_INTERRUPT 0x0080 /* HINT: no non-error interrupt * needed */ #define URB_FREE_BUFFER 0x0100 /* Free transfer buffer with the URB */ +/* The following flags are used internally by usbcore and HCDs */ #define URB_DIR_IN 0x0200 /* Transfer from device to host */ #define URB_DIR_OUT 0 #define URB_DIR_MASK URB_DIR_IN +#define URB_DMA_MAP_SINGLE 0x00010000 /* Non-scatter-gather mapping */ +#define URB_DMA_MAP_PAGE 0x00020000 /* HCD-unsupported S-G */ +#define URB_DMA_MAP_SG 0x00040000 /* HCD-supported S-G */ +#define URB_MAP_LOCAL 0x00080000 /* HCD-local-memory mapping */ +#define URB_SETUP_MAP_SINGLE 0x00100000 /* Setup packet DMA mapped */ +#define URB_SETUP_MAP_LOCAL 0x00200000 /* HCD-local setup packet */ +#define URB_DMA_SG_COMBINED 0x00400000 /* S-G entries were combined */ + struct usb_iso_packet_descriptor { unsigned int offset; unsigned int length; /* expected length */ @@ -1045,12 +1050,8 @@ typedef void (*usb_complete_t)(struct urb *); * @setup_packet: Only used for control transfers, this points to eight bytes * of setup data. Control transfers always start by sending this data * to the device. Then transfer_buffer is read or written, if needed. - * @setup_dma: For control transfers with URB_NO_SETUP_DMA_MAP set, the - * device driver has provided this DMA address for the setup packet. - * The host controller driver should use this in preference to - * setup_packet, but the HCD may chose to ignore the address if it must - * copy the setup packet into internal structures. Therefore, setup_packet - * must always point to a valid buffer. + * @setup_dma: DMA pointer for the setup packet. The caller must not use + * this field; setup_packet must point to a valid buffer. * @start_frame: Returns the initial frame for isochronous transfers. * @number_of_packets: Lists the number of ISO transfer buffers. * @interval: Specifies the polling interval for interrupt or isochronous @@ -1082,13 +1083,14 @@ typedef void (*usb_complete_t)(struct urb *); * bounce buffer or talking to an IOMMU), * although they're cheap on commodity x86 and ppc hardware. * - * Alternatively, drivers may pass the URB_NO_xxx_DMA_MAP transfer flags, - * which tell the host controller driver that no such mapping is needed since + * Alternatively, drivers may pass the URB_NO_TRANSFER_DMA_MAP transfer flag, + * which tells the host controller driver that no such mapping is needed for + * the transfer_buffer since * the device driver is DMA-aware. For example, a device driver might * allocate a DMA buffer with usb_alloc_coherent() or call usb_buffer_map(). - * When these transfer flags are provided, host controller drivers will - * attempt to use the dma addresses found in the transfer_dma and/or - * setup_dma fields rather than determining a dma address themselves. + * When this transfer flag is provided, host controller drivers will + * attempt to use the dma address found in the transfer_dma + * field rather than determining a dma address themselves. * * Note that transfer_buffer must still be set if the controller * does not support DMA (as indicated by bus.uses_dma) and when talking @@ -1111,11 +1113,9 @@ typedef void (*usb_complete_t)(struct urb *); * should always terminate with a short packet, even if it means adding an * extra zero length packet. * - * Control URBs must provide a setup_packet. The setup_packet and - * transfer_buffer may each be mapped for DMA or not, independently of - * the other. The transfer_flags bits URB_NO_TRANSFER_DMA_MAP and - * URB_NO_SETUP_DMA_MAP indicate which buffers have already been mapped. - * URB_NO_SETUP_DMA_MAP is ignored for non-control URBs. + * Control URBs must provide a valid pointer in the setup_packet field. + * Unlike the transfer_buffer, the setup_packet may not be mapped for DMA + * beforehand. * * Interrupt URBs must provide an interval, saying how often (in milliseconds * or, for highspeed devices, 125 microsecond units) @@ -1186,14 +1186,15 @@ struct urb { * current owner */ struct list_head anchor_list; /* the URB may be anchored */ struct usb_anchor *anchor; - struct usb_device *dev; /* (in) pointer to associated device */ + struct usb_device *dev; /* (in) pointer to associated device */ struct usb_host_endpoint *ep; /* (internal) pointer to endpoint */ unsigned int pipe; /* (in) pipe information */ + unsigned int stream_id; /* (in) stream ID */ int status; /* (return) non-ISO status */ unsigned int transfer_flags; /* (in) URB_SHORT_NOT_OK | ...*/ void *transfer_buffer; /* (in) associated data buffer */ dma_addr_t transfer_dma; /* (in) dma addr for transfer_buffer */ - struct usb_sg_request *sg; /* (in) scatter gather buffer list */ + struct scatterlist *sg; /* (in) scatter gather buffer list */ int num_sgs; /* (in) number of entries in the sg list */ u32 transfer_buffer_length; /* (in) data buffer length */ u32 actual_length; /* (return) actual transfer length */ @@ -1371,18 +1372,6 @@ void *usb_alloc_coherent(struct usb_device *dev, size_t size, void usb_free_coherent(struct usb_device *dev, size_t size, void *addr, dma_addr_t dma); -/* Compatible macros while we switch over */ -static inline void *usb_buffer_alloc(struct usb_device *dev, size_t size, - gfp_t mem_flags, dma_addr_t *dma) -{ - return usb_alloc_coherent(dev, size, mem_flags, dma); -} -static inline void usb_buffer_free(struct usb_device *dev, size_t size, - void *addr, dma_addr_t dma) -{ - return usb_free_coherent(dev, size, addr, dma); -} - #if 0 struct urb *usb_buffer_map(struct urb *urb); void usb_buffer_dmasync(struct urb *urb); @@ -1467,8 +1456,6 @@ struct usb_sg_request { struct usb_device *dev; int pipe; - struct scatterlist *sg; - int nents; int entries; struct urb **urbs; @@ -1536,23 +1523,31 @@ static inline unsigned int __create_pipe(struct usb_device *dev, } /* Create various pipes... */ -#define usb_sndctrlpipe(dev,endpoint) \ +#define usb_sndctrlpipe(dev, endpoint) \ ((PIPE_CONTROL << 30) | __create_pipe(dev, endpoint)) -#define usb_rcvctrlpipe(dev,endpoint) \ +#define usb_rcvctrlpipe(dev, endpoint) \ ((PIPE_CONTROL << 30) | __create_pipe(dev, endpoint) | USB_DIR_IN) -#define usb_sndisocpipe(dev,endpoint) \ +#define usb_sndisocpipe(dev, endpoint) \ ((PIPE_ISOCHRONOUS << 30) | __create_pipe(dev, endpoint)) -#define usb_rcvisocpipe(dev,endpoint) \ +#define usb_rcvisocpipe(dev, endpoint) \ ((PIPE_ISOCHRONOUS << 30) | __create_pipe(dev, endpoint) | USB_DIR_IN) -#define usb_sndbulkpipe(dev,endpoint) \ +#define usb_sndbulkpipe(dev, endpoint) \ ((PIPE_BULK << 30) | __create_pipe(dev, endpoint)) -#define usb_rcvbulkpipe(dev,endpoint) \ +#define usb_rcvbulkpipe(dev, endpoint) \ ((PIPE_BULK << 30) | __create_pipe(dev, endpoint) | USB_DIR_IN) -#define usb_sndintpipe(dev,endpoint) \ +#define usb_sndintpipe(dev, endpoint) \ ((PIPE_INTERRUPT << 30) | __create_pipe(dev, endpoint)) -#define usb_rcvintpipe(dev,endpoint) \ +#define usb_rcvintpipe(dev, endpoint) \ ((PIPE_INTERRUPT << 30) | __create_pipe(dev, endpoint) | USB_DIR_IN) +static inline struct usb_host_endpoint * +usb_pipe_endpoint(struct usb_device *dev, unsigned int pipe) +{ + struct usb_host_endpoint **eps; + eps = usb_pipein(pipe) ? dev->ep_in : dev->ep_out; + return eps[usb_pipeendpoint(pipe)]; +} + /*-------------------------------------------------------------------------*/ static inline __u16 diff --git a/include/linux/usb/Kbuild b/include/linux/usb/Kbuild index 29fd73b0bff..51410e0200c 100644 --- a/include/linux/usb/Kbuild +++ b/include/linux/usb/Kbuild @@ -1,6 +1,7 @@ header-y += audio.h header-y += cdc.h header-y += ch9.h +header-y += ch11.h header-y += gadgetfs.h header-y += midi.h header-y += g_printer.h diff --git a/include/linux/usb/atmel_usba_udc.h b/include/linux/usb/atmel_usba_udc.h index baf41c8616e..ba99af275a3 100644 --- a/include/linux/usb/atmel_usba_udc.h +++ b/include/linux/usb/atmel_usba_udc.h @@ -15,7 +15,7 @@ struct usba_ep_data { struct usba_platform_data { int vbus_pin; - int vbus_pin_inverted; + int vbus_pin_inverted; int num_ep; struct usba_ep_data ep[0]; }; diff --git a/include/linux/usb/audio.h b/include/linux/usb/audio.h index c0ef18dc2da..5d646c38875 100644 --- a/include/linux/usb/audio.h +++ b/include/linux/usb/audio.h @@ -101,7 +101,7 @@ struct uac_ac_header_descriptor_v1 { #define UAC_DT_AC_HEADER_SIZE(n) (8 + (n)) /* As above, but more useful for defining your own descriptors: */ -#define DECLARE_UAC_AC_HEADER_DESCRIPTOR(n) \ +#define DECLARE_UAC_AC_HEADER_DESCRIPTOR(n) \ struct uac_ac_header_descriptor_v1_##n { \ __u8 bLength; \ __u8 bDescriptorType; \ @@ -169,7 +169,7 @@ struct uac_output_terminal_descriptor_v1 { #define UAC_DT_FEATURE_UNIT_SIZE(ch) (7 + ((ch) + 1) * 2) /* As above, but more useful for defining your own descriptors: */ -#define DECLARE_UAC_FEATURE_UNIT_DESCRIPTOR(ch) \ +#define DECLARE_UAC_FEATURE_UNIT_DESCRIPTOR(ch) \ struct uac_feature_unit_descriptor_##ch { \ __u8 bLength; \ __u8 bDescriptorType; \ @@ -378,7 +378,7 @@ struct uac_format_type_i_discrete_descriptor { __u8 tSamFreq[][3]; } __attribute__ ((packed)); -#define DECLARE_UAC_FORMAT_TYPE_I_DISCRETE_DESC(n) \ +#define DECLARE_UAC_FORMAT_TYPE_I_DISCRETE_DESC(n) \ struct uac_format_type_i_discrete_descriptor_##n { \ __u8 bLength; \ __u8 bDescriptorType; \ diff --git a/include/linux/usb/cdc.h b/include/linux/usb/cdc.h index c24124a42ce..c117a68d04a 100644 --- a/include/linux/usb/cdc.h +++ b/include/linux/usb/cdc.h @@ -18,6 +18,7 @@ #define USB_CDC_SUBCLASS_MDLM 0x0a #define USB_CDC_SUBCLASS_OBEX 0x0b #define USB_CDC_SUBCLASS_EEM 0x0c +#define USB_CDC_SUBCLASS_NCM 0x0d #define USB_CDC_PROTO_NONE 0 @@ -49,6 +50,7 @@ #define USB_CDC_MDLM_DETAIL_TYPE 0x13 /* mdlm_detail_desc */ #define USB_CDC_DMM_TYPE 0x14 #define USB_CDC_OBEX_TYPE 0x15 +#define USB_CDC_NCM_TYPE 0x1a /* "Header Functional Descriptor" from CDC spec 5.2.3.1 */ struct usb_cdc_header_desc { @@ -174,6 +176,15 @@ struct usb_cdc_obex_desc { __le16 bcdVersion; } __attribute__ ((packed)); +/* "NCM Control Model Functional Descriptor" */ +struct usb_cdc_ncm_desc { + __u8 bLength; + __u8 bDescriptorType; + __u8 bDescriptorSubType; + + __le16 bcdNcmVersion; + __u8 bmNetworkCapabilities; +} __attribute__ ((packed)); /*-------------------------------------------------------------------------*/ /* @@ -197,6 +208,17 @@ struct usb_cdc_obex_desc { #define USB_CDC_GET_ETHERNET_PM_PATTERN_FILTER 0x42 #define USB_CDC_SET_ETHERNET_PACKET_FILTER 0x43 #define USB_CDC_GET_ETHERNET_STATISTIC 0x44 +#define USB_CDC_GET_NTB_PARAMETERS 0x80 +#define USB_CDC_GET_NET_ADDRESS 0x81 +#define USB_CDC_SET_NET_ADDRESS 0x82 +#define USB_CDC_GET_NTB_FORMAT 0x83 +#define USB_CDC_SET_NTB_FORMAT 0x84 +#define USB_CDC_GET_NTB_INPUT_SIZE 0x85 +#define USB_CDC_SET_NTB_INPUT_SIZE 0x86 +#define USB_CDC_GET_MAX_DATAGRAM_SIZE 0x87 +#define USB_CDC_SET_MAX_DATAGRAM_SIZE 0x88 +#define USB_CDC_GET_CRC_MODE 0x89 +#define USB_CDC_SET_CRC_MODE 0x8a /* Line Coding Structure from CDC spec 6.2.13 */ struct usb_cdc_line_coding { @@ -247,4 +269,76 @@ struct usb_cdc_notification { __le16 wLength; } __attribute__ ((packed)); +/*-------------------------------------------------------------------------*/ + +/* + * Class Specific structures and constants + * + * CDC NCM parameter structure, CDC NCM subclass 6.2.1 + * + */ + +struct usb_cdc_ncm_ntb_parameter { + __le16 wLength; + __le16 bmNtbFormatSupported; + __le32 dwNtbInMaxSize; + __le16 wNdpInDivisor; + __le16 wNdpInPayloadRemainder; + __le16 wNdpInAlignment; + __le16 wPadding1; + __le32 dwNtbOutMaxSize; + __le16 wNdpOutDivisor; + __le16 wNdpOutPayloadRemainder; + __le16 wNdpOutAlignment; + __le16 wPadding2; +} __attribute__ ((packed)); + +/* + * CDC NCM transfer headers, CDC NCM subclass 3.2 + */ + +#define NCM_NTH16_SIGN 0x484D434E /* NCMH */ +#define NCM_NTH32_SIGN 0x686D636E /* ncmh */ + +struct usb_cdc_ncm_nth16 { + __le32 dwSignature; + __le16 wHeaderLength; + __le16 wSequence; + __le16 wBlockLength; + __le16 wFpIndex; +} __attribute__ ((packed)); + +struct usb_cdc_ncm_nth32 { + __le32 dwSignature; + __le16 wHeaderLength; + __le16 wSequence; + __le32 dwBlockLength; + __le32 dwFpIndex; +} __attribute__ ((packed)); + +/* + * CDC NCM datagram pointers, CDC NCM subclass 3.3 + */ + +#define NCM_NDP16_CRC_SIGN 0x314D434E /* NCM1 */ +#define NCM_NDP16_NOCRC_SIGN 0x304D434E /* NCM0 */ +#define NCM_NDP32_CRC_SIGN 0x316D636E /* ncm1 */ +#define NCM_NDP32_NOCRC_SIGN 0x306D636E /* ncm0 */ + +struct usb_cdc_ncm_ndp16 { + __le32 dwSignature; + __le16 wLength; + __le16 wNextFpIndex; + __u8 data[0]; +} __attribute__ ((packed)); + +struct usb_cdc_ncm_ndp32 { + __le32 dwSignature; + __le16 wLength; + __le16 wReserved6; + __le32 dwNextFpIndex; + __le32 dwReserved12; + __u8 data[0]; +} __attribute__ ((packed)); + #endif /* __LINUX_USB_CDC_H */ diff --git a/include/linux/usb/ch11.h b/include/linux/usb/ch11.h new file mode 100644 index 00000000000..119194c85d1 --- /dev/null +++ b/include/linux/usb/ch11.h @@ -0,0 +1,167 @@ +/* + * This file holds Hub protocol constants and data structures that are + * defined in chapter 11 (Hub Specification) of the USB 2.0 specification. + * + * It is used/shared between the USB core, the HCDs and couple of other USB + * drivers. + */ + +#ifndef __LINUX_CH11_H +#define __LINUX_CH11_H + +#include <linux/types.h> /* __u8 etc */ + +/* + * Hub request types + */ + +#define USB_RT_HUB (USB_TYPE_CLASS | USB_RECIP_DEVICE) +#define USB_RT_PORT (USB_TYPE_CLASS | USB_RECIP_OTHER) + +/* + * Hub class requests + * See USB 2.0 spec Table 11-16 + */ +#define HUB_CLEAR_TT_BUFFER 8 +#define HUB_RESET_TT 9 +#define HUB_GET_TT_STATE 10 +#define HUB_STOP_TT 11 + +/* + * Hub Class feature numbers + * See USB 2.0 spec Table 11-17 + */ +#define C_HUB_LOCAL_POWER 0 +#define C_HUB_OVER_CURRENT 1 + +/* + * Port feature numbers + * See USB 2.0 spec Table 11-17 + */ +#define USB_PORT_FEAT_CONNECTION 0 +#define USB_PORT_FEAT_ENABLE 1 +#define USB_PORT_FEAT_SUSPEND 2 /* L2 suspend */ +#define USB_PORT_FEAT_OVER_CURRENT 3 +#define USB_PORT_FEAT_RESET 4 +#define USB_PORT_FEAT_L1 5 /* L1 suspend */ +#define USB_PORT_FEAT_POWER 8 +#define USB_PORT_FEAT_LOWSPEED 9 /* Should never be used */ +#define USB_PORT_FEAT_C_CONNECTION 16 +#define USB_PORT_FEAT_C_ENABLE 17 +#define USB_PORT_FEAT_C_SUSPEND 18 +#define USB_PORT_FEAT_C_OVER_CURRENT 19 +#define USB_PORT_FEAT_C_RESET 20 +#define USB_PORT_FEAT_TEST 21 +#define USB_PORT_FEAT_INDICATOR 22 +#define USB_PORT_FEAT_C_PORT_L1 23 + +/* + * Hub Status and Hub Change results + * See USB 2.0 spec Table 11-19 and Table 11-20 + */ +struct usb_port_status { + __le16 wPortStatus; + __le16 wPortChange; +} __attribute__ ((packed)); + +/* + * wPortStatus bit field + * See USB 2.0 spec Table 11-21 + */ +#define USB_PORT_STAT_CONNECTION 0x0001 +#define USB_PORT_STAT_ENABLE 0x0002 +#define USB_PORT_STAT_SUSPEND 0x0004 +#define USB_PORT_STAT_OVERCURRENT 0x0008 +#define USB_PORT_STAT_RESET 0x0010 +#define USB_PORT_STAT_L1 0x0020 +/* bits 6 to 7 are reserved */ +#define USB_PORT_STAT_POWER 0x0100 +#define USB_PORT_STAT_LOW_SPEED 0x0200 +#define USB_PORT_STAT_HIGH_SPEED 0x0400 +#define USB_PORT_STAT_TEST 0x0800 +#define USB_PORT_STAT_INDICATOR 0x1000 +/* bits 13 to 15 are reserved */ +#define USB_PORT_STAT_SUPER_SPEED 0x8000 /* Linux-internal */ + +/* + * wPortChange bit field + * See USB 2.0 spec Table 11-22 + * Bits 0 to 4 shown, bits 5 to 15 are reserved + */ +#define USB_PORT_STAT_C_CONNECTION 0x0001 +#define USB_PORT_STAT_C_ENABLE 0x0002 +#define USB_PORT_STAT_C_SUSPEND 0x0004 +#define USB_PORT_STAT_C_OVERCURRENT 0x0008 +#define USB_PORT_STAT_C_RESET 0x0010 +#define USB_PORT_STAT_C_L1 0x0020 + +/* + * wHubCharacteristics (masks) + * See USB 2.0 spec Table 11-13, offset 3 + */ +#define HUB_CHAR_LPSM 0x0003 /* D1 .. D0 */ +#define HUB_CHAR_COMPOUND 0x0004 /* D2 */ +#define HUB_CHAR_OCPM 0x0018 /* D4 .. D3 */ +#define HUB_CHAR_TTTT 0x0060 /* D6 .. D5 */ +#define HUB_CHAR_PORTIND 0x0080 /* D7 */ + +struct usb_hub_status { + __le16 wHubStatus; + __le16 wHubChange; +} __attribute__ ((packed)); + +/* + * Hub Status & Hub Change bit masks + * See USB 2.0 spec Table 11-19 and Table 11-20 + * Bits 0 and 1 for wHubStatus and wHubChange + * Bits 2 to 15 are reserved for both + */ +#define HUB_STATUS_LOCAL_POWER 0x0001 +#define HUB_STATUS_OVERCURRENT 0x0002 +#define HUB_CHANGE_LOCAL_POWER 0x0001 +#define HUB_CHANGE_OVERCURRENT 0x0002 + + +/* + * Hub descriptor + * See USB 2.0 spec Table 11-13 + */ + +#define USB_DT_HUB (USB_TYPE_CLASS | 0x09) +#define USB_DT_HUB_NONVAR_SIZE 7 + +struct usb_hub_descriptor { + __u8 bDescLength; + __u8 bDescriptorType; + __u8 bNbrPorts; + __le16 wHubCharacteristics; + __u8 bPwrOn2PwrGood; + __u8 bHubContrCurrent; + /* add 1 bit for hub status change; round to bytes */ + __u8 DeviceRemovable[(USB_MAXCHILDREN + 1 + 7) / 8]; + __u8 PortPwrCtrlMask[(USB_MAXCHILDREN + 1 + 7) / 8]; +} __attribute__ ((packed)); + + +/* port indicator status selectors, tables 11-7 and 11-25 */ +#define HUB_LED_AUTO 0 +#define HUB_LED_AMBER 1 +#define HUB_LED_GREEN 2 +#define HUB_LED_OFF 3 + +enum hub_led_mode { + INDICATOR_AUTO = 0, + INDICATOR_CYCLE, + /* software blinks for attention: software, hardware, reserved */ + INDICATOR_GREEN_BLINK, INDICATOR_GREEN_BLINK_OFF, + INDICATOR_AMBER_BLINK, INDICATOR_AMBER_BLINK_OFF, + INDICATOR_ALT_BLINK, INDICATOR_ALT_BLINK_OFF +} __attribute__ ((packed)); + +/* Transaction Translator Think Times, in bits */ +#define HUB_TTTT_8_BITS 0x00 +#define HUB_TTTT_16_BITS 0x20 +#define HUB_TTTT_24_BITS 0x40 +#define HUB_TTTT_32_BITS 0x60 + +#endif /* __LINUX_CH11_H */ diff --git a/include/linux/usb/ch9.h b/include/linux/usb/ch9.h index e58369ff816..da2ed77d3e8 100644 --- a/include/linux/usb/ch9.h +++ b/include/linux/usb/ch9.h @@ -191,6 +191,8 @@ struct usb_ctrlrequest { #define USB_DT_WIRE_ADAPTER 0x21 #define USB_DT_RPIPE 0x22 #define USB_DT_CS_RADIO_CONTROL 0x23 +/* From the T10 UAS specification */ +#define USB_DT_PIPE_USAGE 0x24 /* From the USB 3.0 spec */ #define USB_DT_SS_ENDPOINT_COMP 0x30 @@ -475,7 +477,7 @@ static inline int usb_endpoint_xfer_isoc( static inline int usb_endpoint_is_bulk_in( const struct usb_endpoint_descriptor *epd) { - return (usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_in(epd)); + return usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_in(epd); } /** @@ -488,7 +490,7 @@ static inline int usb_endpoint_is_bulk_in( static inline int usb_endpoint_is_bulk_out( const struct usb_endpoint_descriptor *epd) { - return (usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_out(epd)); + return usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_out(epd); } /** @@ -501,7 +503,7 @@ static inline int usb_endpoint_is_bulk_out( static inline int usb_endpoint_is_int_in( const struct usb_endpoint_descriptor *epd) { - return (usb_endpoint_xfer_int(epd) && usb_endpoint_dir_in(epd)); + return usb_endpoint_xfer_int(epd) && usb_endpoint_dir_in(epd); } /** @@ -514,7 +516,7 @@ static inline int usb_endpoint_is_int_in( static inline int usb_endpoint_is_int_out( const struct usb_endpoint_descriptor *epd) { - return (usb_endpoint_xfer_int(epd) && usb_endpoint_dir_out(epd)); + return usb_endpoint_xfer_int(epd) && usb_endpoint_dir_out(epd); } /** @@ -527,7 +529,7 @@ static inline int usb_endpoint_is_int_out( static inline int usb_endpoint_is_isoc_in( const struct usb_endpoint_descriptor *epd) { - return (usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_in(epd)); + return usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_in(epd); } /** @@ -540,7 +542,7 @@ static inline int usb_endpoint_is_isoc_in( static inline int usb_endpoint_is_isoc_out( const struct usb_endpoint_descriptor *epd) { - return (usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_out(epd)); + return usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_out(epd); } /*-------------------------------------------------------------------------*/ @@ -556,6 +558,8 @@ struct usb_ss_ep_comp_descriptor { } __attribute__ ((packed)); #define USB_DT_SS_EP_COMP_SIZE 6 +/* Bits 4:0 of bmAttributes if this is a bulk endpoint */ +#define USB_SS_MAX_STREAMS(p) (1 << (p & 0x1f)) /*-------------------------------------------------------------------------*/ diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h index 738ea1a691c..139353efad3 100644 --- a/include/linux/usb/composite.h +++ b/include/linux/usb/composite.h @@ -326,6 +326,7 @@ struct usb_composite_dev { /* private: */ /* internals */ + unsigned int suspended:1; struct usb_device_descriptor desc; struct list_head configs; struct usb_composite_driver *driver; diff --git a/include/linux/usb/ehci_def.h b/include/linux/usb/ehci_def.h index af4b86f3aca..80287af2a73 100644 --- a/include/linux/usb/ehci_def.h +++ b/include/linux/usb/ehci_def.h @@ -45,7 +45,7 @@ struct ehci_caps { #define HCC_CANPARK(p) ((p)&(1 << 2)) /* true: can park on async qh */ #define HCC_PGM_FRAMELISTLEN(p) ((p)&(1 << 1)) /* true: periodic_size changes*/ #define HCC_64BIT_ADDR(p) ((p)&(1)) /* true: can use 64-bit addr */ - u8 portroute [8]; /* nibbles for routing - offset 0xC */ + u8 portroute[8]; /* nibbles for routing - offset 0xC */ } __attribute__ ((packed)); @@ -92,14 +92,14 @@ struct ehci_regs { /* ASYNCLISTADDR: offset 0x18 */ u32 async_next; /* address of next async queue head */ - u32 reserved [9]; + u32 reserved[9]; /* CONFIGFLAG: offset 0x40 */ u32 configured_flag; #define FLAG_CF (1<<0) /* true: we'll support "high speed" */ /* PORTSC: offset 0x44 */ - u32 port_status [0]; /* up to N_PORTS */ + u32 port_status[0]; /* up to N_PORTS */ /* 31:23 reserved */ #define PORT_WKOC_E (1<<22) /* wake on overcurrent (enable) */ #define PORT_WKDISC_E (1<<21) /* wake on disconnect (enable) */ diff --git a/include/linux/usb/functionfs.h b/include/linux/usb/functionfs.h new file mode 100644 index 00000000000..a34a2a043b2 --- /dev/null +++ b/include/linux/usb/functionfs.h @@ -0,0 +1,199 @@ +#ifndef __LINUX_FUNCTIONFS_H__ +#define __LINUX_FUNCTIONFS_H__ 1 + + +#include <linux/types.h> +#include <linux/ioctl.h> + +#include <linux/usb/ch9.h> + + +enum { + FUNCTIONFS_DESCRIPTORS_MAGIC = 1, + FUNCTIONFS_STRINGS_MAGIC = 2 +}; + + +#ifndef __KERNEL__ + +/* Descriptor of an non-audio endpoint */ +struct usb_endpoint_descriptor_no_audio { + __u8 bLength; + __u8 bDescriptorType; + + __u8 bEndpointAddress; + __u8 bmAttributes; + __le16 wMaxPacketSize; + __u8 bInterval; +} __attribute__((packed)); + + +/* + * All numbers must be in little endian order. + */ + +struct usb_functionfs_descs_head { + __le32 magic; + __le32 length; + __le32 fs_count; + __le32 hs_count; +} __attribute__((packed)); + +/* + * Descriptors format: + * + * | off | name | type | description | + * |-----+-----------+--------------+--------------------------------------| + * | 0 | magic | LE32 | FUNCTIONFS_{FS,HS}_DESCRIPTORS_MAGIC | + * | 4 | lenght | LE32 | length of the whole data chunk | + * | 8 | fs_count | LE32 | number of full-speed descriptors | + * | 12 | hs_count | LE32 | number of high-speed descriptors | + * | 16 | fs_descrs | Descriptor[] | list of full-speed descriptors | + * | | hs_descrs | Descriptor[] | list of high-speed descriptors | + * + * descs are just valid USB descriptors and have the following format: + * + * | off | name | type | description | + * |-----+-----------------+------+--------------------------| + * | 0 | bLength | U8 | length of the descriptor | + * | 1 | bDescriptorType | U8 | descriptor type | + * | 2 | payload | | descriptor's payload | + */ + +struct usb_functionfs_strings_head { + __le32 magic; + __le32 length; + __le32 str_count; + __le32 lang_count; +} __attribute__((packed)); + +/* + * Strings format: + * + * | off | name | type | description | + * |-----+------------+-----------------------+----------------------------| + * | 0 | magic | LE32 | FUNCTIONFS_STRINGS_MAGIC | + * | 4 | length | LE32 | length of the data chunk | + * | 8 | str_count | LE32 | number of strings | + * | 12 | lang_count | LE32 | number of languages | + * | 16 | stringtab | StringTab[lang_count] | table of strings per lang | + * + * For each language there is one stringtab entry (ie. there are lang_count + * stringtab entires). Each StringTab has following format: + * + * | off | name | type | description | + * |-----+---------+-------------------+------------------------------------| + * | 0 | lang | LE16 | language code | + * | 2 | strings | String[str_count] | array of strings in given language | + * + * For each string ther is one strings entry (ie. there are str_count + * string entries). Each String is a NUL terminated string encoded in + * UTF-8. + */ + +#endif + + +/* + * Events are delivered on the ep0 file descriptor, when the user mode driver + * reads from this file descriptor after writing the descriptors. Don't + * stop polling this descriptor. + */ + +enum usb_functionfs_event_type { + FUNCTIONFS_BIND, + FUNCTIONFS_UNBIND, + + FUNCTIONFS_ENABLE, + FUNCTIONFS_DISABLE, + + FUNCTIONFS_SETUP, + + FUNCTIONFS_SUSPEND, + FUNCTIONFS_RESUME +}; + +/* NOTE: this structure must stay the same size and layout on + * both 32-bit and 64-bit kernels. + */ +struct usb_functionfs_event { + union { + /* SETUP: packet; DATA phase i/o precedes next event + *(setup.bmRequestType & USB_DIR_IN) flags direction */ + struct usb_ctrlrequest setup; + } __attribute__((packed)) u; + + /* enum usb_functionfs_event_type */ + __u8 type; + __u8 _pad[3]; +} __attribute__((packed)); + + +/* Endpoint ioctls */ +/* The same as in gadgetfs */ + +/* IN transfers may be reported to the gadget driver as complete + * when the fifo is loaded, before the host reads the data; + * OUT transfers may be reported to the host's "client" driver as + * complete when they're sitting in the FIFO unread. + * THIS returns how many bytes are "unclaimed" in the endpoint fifo + * (needed for precise fault handling, when the hardware allows it) + */ +#define FUNCTIONFS_FIFO_STATUS _IO('g', 1) + +/* discards any unclaimed data in the fifo. */ +#define FUNCTIONFS_FIFO_FLUSH _IO('g', 2) + +/* resets endpoint halt+toggle; used to implement set_interface. + * some hardware (like pxa2xx) can't support this. + */ +#define FUNCTIONFS_CLEAR_HALT _IO('g', 3) + +/* Specific for functionfs */ + +/* + * Returns reverse mapping of an interface. Called on EP0. If there + * is no such interface returns -EDOM. If function is not active + * returns -ENODEV. + */ +#define FUNCTIONFS_INTERFACE_REVMAP _IO('g', 128) + +/* + * Returns real bEndpointAddress of an endpoint. If function is not + * active returns -ENODEV. + */ +#define FUNCTIONFS_ENDPOINT_REVMAP _IO('g', 129) + + +#ifdef __KERNEL__ + +struct ffs_data; +struct usb_composite_dev; +struct usb_configuration; + + +static int functionfs_init(void) __attribute__((warn_unused_result)); +static void functionfs_cleanup(void); + +static int functionfs_bind(struct ffs_data *ffs, struct usb_composite_dev *cdev) + __attribute__((warn_unused_result, nonnull)); +static void functionfs_unbind(struct ffs_data *ffs) + __attribute__((nonnull)); + +static int functionfs_add(struct usb_composite_dev *cdev, + struct usb_configuration *c, + struct ffs_data *ffs) + __attribute__((warn_unused_result, nonnull)); + + +static int functionfs_ready_callback(struct ffs_data *ffs) + __attribute__((warn_unused_result, nonnull)); +static void functionfs_closed_callback(struct ffs_data *ffs) + __attribute__((nonnull)); +static int functionfs_check_dev_callback(const char *dev_name) + __attribute__((warn_unused_result, nonnull)); + + +#endif + +#endif diff --git a/include/linux/usb/g_hid.h b/include/linux/usb/g_hid.h new file mode 100644 index 00000000000..50f5745df28 --- /dev/null +++ b/include/linux/usb/g_hid.h @@ -0,0 +1,32 @@ +/* + * g_hid.h -- Header file for USB HID gadget driver + * + * Copyright (C) 2010 Fabien Chouteau <fabien.chouteau@barco.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __LINUX_USB_G_HID_H +#define __LINUX_USB_G_HID_H + +struct hidg_func_descriptor { + unsigned char subclass; + unsigned char protocol; + unsigned short report_length; + unsigned short report_desc_length; + unsigned char report_desc[]; +}; + +#endif /* __LINUX_USB_G_HID_H */ diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h index f4b7ca516cd..d3ef42d7d2f 100644 --- a/include/linux/usb/gadget.h +++ b/include/linux/usb/gadget.h @@ -494,9 +494,13 @@ static inline void set_gadget_data(struct usb_gadget *gadget, void *data) { dev_set_drvdata(&gadget->dev, data); } static inline void *get_gadget_data(struct usb_gadget *gadget) { return dev_get_drvdata(&gadget->dev); } +static inline struct usb_gadget *dev_to_usb_gadget(struct device *dev) +{ + return container_of(dev, struct usb_gadget, dev); +} /* iterates the non-control endpoints; 'tmp' is a struct usb_ep pointer */ -#define gadget_for_each_ep(tmp,gadget) \ +#define gadget_for_each_ep(tmp, gadget) \ list_for_each_entry(tmp, &(gadget)->ep_list, ep_list) diff --git a/include/linux/usb/gadgetfs.h b/include/linux/usb/gadgetfs.h index 612102e4d75..0bb12e0d4f8 100644 --- a/include/linux/usb/gadgetfs.h +++ b/include/linux/usb/gadgetfs.h @@ -19,7 +19,7 @@ #define __LINUX_USB_GADGETFS_H #include <linux/types.h> -#include <asm/ioctl.h> +#include <linux/ioctl.h> #include <linux/usb/ch9.h> diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h new file mode 100644 index 00000000000..2e3a4ea1a3d --- /dev/null +++ b/include/linux/usb/hcd.h @@ -0,0 +1,625 @@ +/* + * Copyright (c) 2001-2002 by David Brownell + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifndef __USB_CORE_HCD_H +#define __USB_CORE_HCD_H + +#ifdef __KERNEL__ + +#include <linux/rwsem.h> + +#define MAX_TOPO_LEVEL 6 + +/* This file contains declarations of usbcore internals that are mostly + * used or exposed by Host Controller Drivers. + */ + +/* + * USB Packet IDs (PIDs) + */ +#define USB_PID_EXT 0xf0 /* USB 2.0 LPM ECN */ +#define USB_PID_OUT 0xe1 +#define USB_PID_ACK 0xd2 +#define USB_PID_DATA0 0xc3 +#define USB_PID_PING 0xb4 /* USB 2.0 */ +#define USB_PID_SOF 0xa5 +#define USB_PID_NYET 0x96 /* USB 2.0 */ +#define USB_PID_DATA2 0x87 /* USB 2.0 */ +#define USB_PID_SPLIT 0x78 /* USB 2.0 */ +#define USB_PID_IN 0x69 +#define USB_PID_NAK 0x5a +#define USB_PID_DATA1 0x4b +#define USB_PID_PREAMBLE 0x3c /* Token mode */ +#define USB_PID_ERR 0x3c /* USB 2.0: handshake mode */ +#define USB_PID_SETUP 0x2d +#define USB_PID_STALL 0x1e +#define USB_PID_MDATA 0x0f /* USB 2.0 */ + +/*-------------------------------------------------------------------------*/ + +/* + * USB Host Controller Driver (usb_hcd) framework + * + * Since "struct usb_bus" is so thin, you can't share much code in it. + * This framework is a layer over that, and should be more sharable. + * + * @authorized_default: Specifies if new devices are authorized to + * connect by default or they require explicit + * user space authorization; this bit is settable + * through /sys/class/usb_host/X/authorized_default. + * For the rest is RO, so we don't lock to r/w it. + */ + +/*-------------------------------------------------------------------------*/ + +struct usb_hcd { + + /* + * housekeeping + */ + struct usb_bus self; /* hcd is-a bus */ + struct kref kref; /* reference counter */ + + const char *product_desc; /* product/vendor string */ + char irq_descr[24]; /* driver + bus # */ + + struct timer_list rh_timer; /* drives root-hub polling */ + struct urb *status_urb; /* the current status urb */ +#ifdef CONFIG_USB_SUSPEND + struct work_struct wakeup_work; /* for remote wakeup */ +#endif + + /* + * hardware info/state + */ + const struct hc_driver *driver; /* hw-specific hooks */ + + /* Flags that need to be manipulated atomically */ + unsigned long flags; +#define HCD_FLAG_HW_ACCESSIBLE 0x00000001 +#define HCD_FLAG_SAW_IRQ 0x00000002 + + unsigned rh_registered:1;/* is root hub registered? */ + + /* The next flag is a stopgap, to be removed when all the HCDs + * support the new root-hub polling mechanism. */ + unsigned uses_new_polling:1; + unsigned poll_rh:1; /* poll for rh status? */ + unsigned poll_pending:1; /* status has changed? */ + unsigned wireless:1; /* Wireless USB HCD */ + unsigned authorized_default:1; + unsigned has_tt:1; /* Integrated TT in root hub */ + + int irq; /* irq allocated */ + void __iomem *regs; /* device memory/io */ + u64 rsrc_start; /* memory/io resource start */ + u64 rsrc_len; /* memory/io resource length */ + unsigned power_budget; /* in mA, 0 = no limit */ + + /* bandwidth_mutex should be taken before adding or removing + * any new bus bandwidth constraints: + * 1. Before adding a configuration for a new device. + * 2. Before removing the configuration to put the device into + * the addressed state. + * 3. Before selecting a different configuration. + * 4. Before selecting an alternate interface setting. + * + * bandwidth_mutex should be dropped after a successful control message + * to the device, or resetting the bandwidth after a failed attempt. + */ + struct mutex bandwidth_mutex; + + +#define HCD_BUFFER_POOLS 4 + struct dma_pool *pool[HCD_BUFFER_POOLS]; + + int state; +# define __ACTIVE 0x01 +# define __SUSPEND 0x04 +# define __TRANSIENT 0x80 + +# define HC_STATE_HALT 0 +# define HC_STATE_RUNNING (__ACTIVE) +# define HC_STATE_QUIESCING (__SUSPEND|__TRANSIENT|__ACTIVE) +# define HC_STATE_RESUMING (__SUSPEND|__TRANSIENT) +# define HC_STATE_SUSPENDED (__SUSPEND) + +#define HC_IS_RUNNING(state) ((state) & __ACTIVE) +#define HC_IS_SUSPENDED(state) ((state) & __SUSPEND) + + /* more shared queuing code would be good; it should support + * smarter scheduling, handle transaction translators, etc; + * input size of periodic table to an interrupt scheduler. + * (ohci 32, uhci 1024, ehci 256/512/1024). + */ + + /* The HC driver's private data is stored at the end of + * this structure. + */ + unsigned long hcd_priv[0] + __attribute__ ((aligned(sizeof(unsigned long)))); +}; + +/* 2.4 does this a bit differently ... */ +static inline struct usb_bus *hcd_to_bus(struct usb_hcd *hcd) +{ + return &hcd->self; +} + +static inline struct usb_hcd *bus_to_hcd(struct usb_bus *bus) +{ + return container_of(bus, struct usb_hcd, self); +} + +struct hcd_timeout { /* timeouts we allocate */ + struct list_head timeout_list; + struct timer_list timer; +}; + +/*-------------------------------------------------------------------------*/ + + +struct hc_driver { + const char *description; /* "ehci-hcd" etc */ + const char *product_desc; /* product/vendor string */ + size_t hcd_priv_size; /* size of private data */ + + /* irq handler */ + irqreturn_t (*irq) (struct usb_hcd *hcd); + + int flags; +#define HCD_MEMORY 0x0001 /* HC regs use memory (else I/O) */ +#define HCD_LOCAL_MEM 0x0002 /* HC needs local memory */ +#define HCD_USB11 0x0010 /* USB 1.1 */ +#define HCD_USB2 0x0020 /* USB 2.0 */ +#define HCD_USB3 0x0040 /* USB 3.0 */ +#define HCD_MASK 0x0070 + + /* called to init HCD and root hub */ + int (*reset) (struct usb_hcd *hcd); + int (*start) (struct usb_hcd *hcd); + + /* NOTE: these suspend/resume calls relate to the HC as + * a whole, not just the root hub; they're for PCI bus glue. + */ + /* called after suspending the hub, before entering D3 etc */ + int (*pci_suspend)(struct usb_hcd *hcd); + + /* called after entering D0 (etc), before resuming the hub */ + int (*pci_resume)(struct usb_hcd *hcd, bool hibernated); + + /* cleanly make HCD stop writing memory and doing I/O */ + void (*stop) (struct usb_hcd *hcd); + + /* shutdown HCD */ + void (*shutdown) (struct usb_hcd *hcd); + + /* return current frame number */ + int (*get_frame_number) (struct usb_hcd *hcd); + + /* manage i/o requests, device state */ + int (*urb_enqueue)(struct usb_hcd *hcd, + struct urb *urb, gfp_t mem_flags); + int (*urb_dequeue)(struct usb_hcd *hcd, + struct urb *urb, int status); + + /* hw synch, freeing endpoint resources that urb_dequeue can't */ + void (*endpoint_disable)(struct usb_hcd *hcd, + struct usb_host_endpoint *ep); + + /* (optional) reset any endpoint state such as sequence number + and current window */ + void (*endpoint_reset)(struct usb_hcd *hcd, + struct usb_host_endpoint *ep); + + /* root hub support */ + int (*hub_status_data) (struct usb_hcd *hcd, char *buf); + int (*hub_control) (struct usb_hcd *hcd, + u16 typeReq, u16 wValue, u16 wIndex, + char *buf, u16 wLength); + int (*bus_suspend)(struct usb_hcd *); + int (*bus_resume)(struct usb_hcd *); + int (*start_port_reset)(struct usb_hcd *, unsigned port_num); + + /* force handover of high-speed port to full-speed companion */ + void (*relinquish_port)(struct usb_hcd *, int); + /* has a port been handed over to a companion? */ + int (*port_handed_over)(struct usb_hcd *, int); + + /* CLEAR_TT_BUFFER completion callback */ + void (*clear_tt_buffer_complete)(struct usb_hcd *, + struct usb_host_endpoint *); + + /* xHCI specific functions */ + /* Called by usb_alloc_dev to alloc HC device structures */ + int (*alloc_dev)(struct usb_hcd *, struct usb_device *); + /* Called by usb_disconnect to free HC device structures */ + void (*free_dev)(struct usb_hcd *, struct usb_device *); + /* Change a group of bulk endpoints to support multiple stream IDs */ + int (*alloc_streams)(struct usb_hcd *hcd, struct usb_device *udev, + struct usb_host_endpoint **eps, unsigned int num_eps, + unsigned int num_streams, gfp_t mem_flags); + /* Reverts a group of bulk endpoints back to not using stream IDs. + * Can fail if we run out of memory. + */ + int (*free_streams)(struct usb_hcd *hcd, struct usb_device *udev, + struct usb_host_endpoint **eps, unsigned int num_eps, + gfp_t mem_flags); + + /* Bandwidth computation functions */ + /* Note that add_endpoint() can only be called once per endpoint before + * check_bandwidth() or reset_bandwidth() must be called. + * drop_endpoint() can only be called once per endpoint also. + * A call to xhci_drop_endpoint() followed by a call to + * xhci_add_endpoint() will add the endpoint to the schedule with + * possibly new parameters denoted by a different endpoint descriptor + * in usb_host_endpoint. A call to xhci_add_endpoint() followed by a + * call to xhci_drop_endpoint() is not allowed. + */ + /* Allocate endpoint resources and add them to a new schedule */ + int (*add_endpoint)(struct usb_hcd *, struct usb_device *, + struct usb_host_endpoint *); + /* Drop an endpoint from a new schedule */ + int (*drop_endpoint)(struct usb_hcd *, struct usb_device *, + struct usb_host_endpoint *); + /* Check that a new hardware configuration, set using + * endpoint_enable and endpoint_disable, does not exceed bus + * bandwidth. This must be called before any set configuration + * or set interface requests are sent to the device. + */ + int (*check_bandwidth)(struct usb_hcd *, struct usb_device *); + /* Reset the device schedule to the last known good schedule, + * which was set from a previous successful call to + * check_bandwidth(). This reverts any add_endpoint() and + * drop_endpoint() calls since that last successful call. + * Used for when a check_bandwidth() call fails due to resource + * or bandwidth constraints. + */ + void (*reset_bandwidth)(struct usb_hcd *, struct usb_device *); + /* Returns the hardware-chosen device address */ + int (*address_device)(struct usb_hcd *, struct usb_device *udev); + /* Notifies the HCD after a hub descriptor is fetched. + * Will block. + */ + int (*update_hub_device)(struct usb_hcd *, struct usb_device *hdev, + struct usb_tt *tt, gfp_t mem_flags); + int (*reset_device)(struct usb_hcd *, struct usb_device *); +}; + +extern int usb_hcd_link_urb_to_ep(struct usb_hcd *hcd, struct urb *urb); +extern int usb_hcd_check_unlink_urb(struct usb_hcd *hcd, struct urb *urb, + int status); +extern void usb_hcd_unlink_urb_from_ep(struct usb_hcd *hcd, struct urb *urb); + +extern int usb_hcd_submit_urb(struct urb *urb, gfp_t mem_flags); +extern int usb_hcd_unlink_urb(struct urb *urb, int status); +extern void usb_hcd_giveback_urb(struct usb_hcd *hcd, struct urb *urb, + int status); +extern void usb_hcd_flush_endpoint(struct usb_device *udev, + struct usb_host_endpoint *ep); +extern void usb_hcd_disable_endpoint(struct usb_device *udev, + struct usb_host_endpoint *ep); +extern void usb_hcd_reset_endpoint(struct usb_device *udev, + struct usb_host_endpoint *ep); +extern void usb_hcd_synchronize_unlinks(struct usb_device *udev); +extern int usb_hcd_alloc_bandwidth(struct usb_device *udev, + struct usb_host_config *new_config, + struct usb_host_interface *old_alt, + struct usb_host_interface *new_alt); +extern int usb_hcd_get_frame_number(struct usb_device *udev); + +extern struct usb_hcd *usb_create_hcd(const struct hc_driver *driver, + struct device *dev, const char *bus_name); +extern struct usb_hcd *usb_get_hcd(struct usb_hcd *hcd); +extern void usb_put_hcd(struct usb_hcd *hcd); +extern int usb_add_hcd(struct usb_hcd *hcd, + unsigned int irqnum, unsigned long irqflags); +extern void usb_remove_hcd(struct usb_hcd *hcd); + +struct platform_device; +extern void usb_hcd_platform_shutdown(struct platform_device *dev); + +#ifdef CONFIG_PCI +struct pci_dev; +struct pci_device_id; +extern int usb_hcd_pci_probe(struct pci_dev *dev, + const struct pci_device_id *id); +extern void usb_hcd_pci_remove(struct pci_dev *dev); +extern void usb_hcd_pci_shutdown(struct pci_dev *dev); + +#ifdef CONFIG_PM_SLEEP +extern const struct dev_pm_ops usb_hcd_pci_pm_ops; +#endif +#endif /* CONFIG_PCI */ + +/* pci-ish (pdev null is ok) buffer alloc/mapping support */ +int hcd_buffer_create(struct usb_hcd *hcd); +void hcd_buffer_destroy(struct usb_hcd *hcd); + +void *hcd_buffer_alloc(struct usb_bus *bus, size_t size, + gfp_t mem_flags, dma_addr_t *dma); +void hcd_buffer_free(struct usb_bus *bus, size_t size, + void *addr, dma_addr_t dma); + +/* generic bus glue, needed for host controllers that don't use PCI */ +extern irqreturn_t usb_hcd_irq(int irq, void *__hcd); + +extern void usb_hc_died(struct usb_hcd *hcd); +extern void usb_hcd_poll_rh_status(struct usb_hcd *hcd); + +/* The D0/D1 toggle bits ... USE WITH CAUTION (they're almost hcd-internal) */ +#define usb_gettoggle(dev, ep, out) (((dev)->toggle[out] >> (ep)) & 1) +#define usb_dotoggle(dev, ep, out) ((dev)->toggle[out] ^= (1 << (ep))) +#define usb_settoggle(dev, ep, out, bit) \ + ((dev)->toggle[out] = ((dev)->toggle[out] & ~(1 << (ep))) | \ + ((bit) << (ep))) + +/* -------------------------------------------------------------------------- */ + +/* Enumeration is only for the hub driver, or HCD virtual root hubs */ +extern struct usb_device *usb_alloc_dev(struct usb_device *parent, + struct usb_bus *, unsigned port); +extern int usb_new_device(struct usb_device *dev); +extern void usb_disconnect(struct usb_device **); + +extern int usb_get_configuration(struct usb_device *dev); +extern void usb_destroy_configuration(struct usb_device *dev); + +/*-------------------------------------------------------------------------*/ + +/* + * HCD Root Hub support + */ + +#include <linux/usb/ch11.h> + +/* + * As of USB 2.0, full/low speed devices are segregated into trees. + * One type grows from USB 1.1 host controllers (OHCI, UHCI etc). + * The other type grows from high speed hubs when they connect to + * full/low speed devices using "Transaction Translators" (TTs). + * + * TTs should only be known to the hub driver, and high speed bus + * drivers (only EHCI for now). They affect periodic scheduling and + * sometimes control/bulk error recovery. + */ + +struct usb_device; + +struct usb_tt { + struct usb_device *hub; /* upstream highspeed hub */ + int multi; /* true means one TT per port */ + unsigned think_time; /* think time in ns */ + + /* for control/bulk error recovery (CLEAR_TT_BUFFER) */ + spinlock_t lock; + struct list_head clear_list; /* of usb_tt_clear */ + struct work_struct clear_work; +}; + +struct usb_tt_clear { + struct list_head clear_list; + unsigned tt; + u16 devinfo; + struct usb_hcd *hcd; + struct usb_host_endpoint *ep; +}; + +extern int usb_hub_clear_tt_buffer(struct urb *urb); +extern void usb_ep0_reinit(struct usb_device *); + +/* (shifted) direction/type/recipient from the USB 2.0 spec, table 9.2 */ +#define DeviceRequest \ + ((USB_DIR_IN|USB_TYPE_STANDARD|USB_RECIP_DEVICE)<<8) +#define DeviceOutRequest \ + ((USB_DIR_OUT|USB_TYPE_STANDARD|USB_RECIP_DEVICE)<<8) + +#define InterfaceRequest \ + ((USB_DIR_IN|USB_TYPE_STANDARD|USB_RECIP_INTERFACE)<<8) + +#define EndpointRequest \ + ((USB_DIR_IN|USB_TYPE_STANDARD|USB_RECIP_INTERFACE)<<8) +#define EndpointOutRequest \ + ((USB_DIR_OUT|USB_TYPE_STANDARD|USB_RECIP_INTERFACE)<<8) + +/* class requests from the USB 2.0 hub spec, table 11-15 */ +/* GetBusState and SetHubDescriptor are optional, omitted */ +#define ClearHubFeature (0x2000 | USB_REQ_CLEAR_FEATURE) +#define ClearPortFeature (0x2300 | USB_REQ_CLEAR_FEATURE) +#define GetHubDescriptor (0xa000 | USB_REQ_GET_DESCRIPTOR) +#define GetHubStatus (0xa000 | USB_REQ_GET_STATUS) +#define GetPortStatus (0xa300 | USB_REQ_GET_STATUS) +#define SetHubFeature (0x2000 | USB_REQ_SET_FEATURE) +#define SetPortFeature (0x2300 | USB_REQ_SET_FEATURE) + + +/*-------------------------------------------------------------------------*/ + +/* + * Generic bandwidth allocation constants/support + */ +#define FRAME_TIME_USECS 1000L +#define BitTime(bytecount) (7 * 8 * bytecount / 6) /* with integer truncation */ + /* Trying not to use worst-case bit-stuffing + * of (7/6 * 8 * bytecount) = 9.33 * bytecount */ + /* bytecount = data payload byte count */ + +#define NS_TO_US(ns) ((ns + 500L) / 1000L) + /* convert & round nanoseconds to microseconds */ + + +/* + * Full/low speed bandwidth allocation constants/support. + */ +#define BW_HOST_DELAY 1000L /* nanoseconds */ +#define BW_HUB_LS_SETUP 333L /* nanoseconds */ + /* 4 full-speed bit times (est.) */ + +#define FRAME_TIME_BITS 12000L /* frame = 1 millisecond */ +#define FRAME_TIME_MAX_BITS_ALLOC (90L * FRAME_TIME_BITS / 100L) +#define FRAME_TIME_MAX_USECS_ALLOC (90L * FRAME_TIME_USECS / 100L) + +/* + * Ceiling [nano/micro]seconds (typical) for that many bytes at high speed + * ISO is a bit less, no ACK ... from USB 2.0 spec, 5.11.3 (and needed + * to preallocate bandwidth) + */ +#define USB2_HOST_DELAY 5 /* nsec, guess */ +#define HS_NSECS(bytes) (((55 * 8 * 2083) \ + + (2083UL * (3 + BitTime(bytes))))/1000 \ + + USB2_HOST_DELAY) +#define HS_NSECS_ISO(bytes) (((38 * 8 * 2083) \ + + (2083UL * (3 + BitTime(bytes))))/1000 \ + + USB2_HOST_DELAY) +#define HS_USECS(bytes) NS_TO_US(HS_NSECS(bytes)) +#define HS_USECS_ISO(bytes) NS_TO_US(HS_NSECS_ISO(bytes)) + +extern long usb_calc_bus_time(int speed, int is_input, + int isoc, int bytecount); + +/*-------------------------------------------------------------------------*/ + +extern void usb_set_device_state(struct usb_device *udev, + enum usb_device_state new_state); + +/*-------------------------------------------------------------------------*/ + +/* exported only within usbcore */ + +extern struct list_head usb_bus_list; +extern struct mutex usb_bus_list_lock; +extern wait_queue_head_t usb_kill_urb_queue; + +extern int usb_find_interface_driver(struct usb_device *dev, + struct usb_interface *interface); + +#define usb_endpoint_out(ep_dir) (!((ep_dir) & USB_DIR_IN)) + +#ifdef CONFIG_PM +extern void usb_root_hub_lost_power(struct usb_device *rhdev); +extern int hcd_bus_suspend(struct usb_device *rhdev, pm_message_t msg); +extern int hcd_bus_resume(struct usb_device *rhdev, pm_message_t msg); +#endif /* CONFIG_PM */ + +#ifdef CONFIG_USB_SUSPEND +extern void usb_hcd_resume_root_hub(struct usb_hcd *hcd); +#else +static inline void usb_hcd_resume_root_hub(struct usb_hcd *hcd) +{ + return; +} +#endif /* CONFIG_USB_SUSPEND */ + + +/* + * USB device fs stuff + */ + +#ifdef CONFIG_USB_DEVICEFS + +/* + * these are expected to be called from the USB core/hub thread + * with the kernel lock held + */ +extern void usbfs_update_special(void); +extern int usbfs_init(void); +extern void usbfs_cleanup(void); + +#else /* CONFIG_USB_DEVICEFS */ + +static inline void usbfs_update_special(void) {} +static inline int usbfs_init(void) { return 0; } +static inline void usbfs_cleanup(void) { } + +#endif /* CONFIG_USB_DEVICEFS */ + +/*-------------------------------------------------------------------------*/ + +#if defined(CONFIG_USB_MON) || defined(CONFIG_USB_MON_MODULE) + +struct usb_mon_operations { + void (*urb_submit)(struct usb_bus *bus, struct urb *urb); + void (*urb_submit_error)(struct usb_bus *bus, struct urb *urb, int err); + void (*urb_complete)(struct usb_bus *bus, struct urb *urb, int status); + /* void (*urb_unlink)(struct usb_bus *bus, struct urb *urb); */ +}; + +extern struct usb_mon_operations *mon_ops; + +static inline void usbmon_urb_submit(struct usb_bus *bus, struct urb *urb) +{ + if (bus->monitored) + (*mon_ops->urb_submit)(bus, urb); +} + +static inline void usbmon_urb_submit_error(struct usb_bus *bus, struct urb *urb, + int error) +{ + if (bus->monitored) + (*mon_ops->urb_submit_error)(bus, urb, error); +} + +static inline void usbmon_urb_complete(struct usb_bus *bus, struct urb *urb, + int status) +{ + if (bus->monitored) + (*mon_ops->urb_complete)(bus, urb, status); +} + +int usb_mon_register(struct usb_mon_operations *ops); +void usb_mon_deregister(void); + +#else + +static inline void usbmon_urb_submit(struct usb_bus *bus, struct urb *urb) {} +static inline void usbmon_urb_submit_error(struct usb_bus *bus, struct urb *urb, + int error) {} +static inline void usbmon_urb_complete(struct usb_bus *bus, struct urb *urb, + int status) {} + +#endif /* CONFIG_USB_MON || CONFIG_USB_MON_MODULE */ + +/*-------------------------------------------------------------------------*/ + +/* hub.h ... DeviceRemovable in 2.4.2-ac11, gone in 2.4.10 */ +/* bleech -- resurfaced in 2.4.11 or 2.4.12 */ +#define bitmap DeviceRemovable + + +/*-------------------------------------------------------------------------*/ + +/* random stuff */ + +#define RUN_CONTEXT (in_irq() ? "in_irq" \ + : (in_interrupt() ? "in_interrupt" : "can sleep")) + + +/* This rwsem is for use only by the hub driver and ehci-hcd. + * Nobody else should touch it. + */ +extern struct rw_semaphore ehci_cf_port_reset_rwsem; + +/* Keep track of which host controller drivers are loaded */ +#define USB_UHCI_LOADED 0 +#define USB_OHCI_LOADED 1 +#define USB_EHCI_LOADED 2 +extern unsigned long usb_hcds_loaded; + +#endif /* __KERNEL__ */ + +#endif /* __USB_CORE_HCD_H */ diff --git a/include/linux/usb/langwell_udc.h b/include/linux/usb/langwell_udc.h index c949178a653..2d2d1bbad9d 100644 --- a/include/linux/usb/langwell_udc.h +++ b/include/linux/usb/langwell_udc.h @@ -181,7 +181,7 @@ struct langwell_op_regs { #define PORTS_PIC (BIT(15) | BIT(14)) /* port indicator control */ #define PORTS_PO BIT(13) /* port owner */ #define PORTS_PP BIT(12) /* port power */ -#define PORTS_LS (BIT(11) | BIT(10)) /* line status */ +#define PORTS_LS (BIT(11) | BIT(10)) /* line status */ #define PORTS_SLP BIT(9) /* suspend using L1 */ #define PORTS_PR BIT(8) /* port reset */ #define PORTS_SUSP BIT(7) /* suspend */ diff --git a/include/linux/usb/musb.h b/include/linux/usb/musb.h index 7acef0234c0..ee2dd1d506e 100644 --- a/include/linux/usb/musb.h +++ b/include/linux/usb/musb.h @@ -22,12 +22,47 @@ enum musb_mode { struct clk; +enum musb_fifo_style { + FIFO_RXTX, + FIFO_TX, + FIFO_RX +} __attribute__ ((packed)); + +enum musb_buf_mode { + BUF_SINGLE, + BUF_DOUBLE +} __attribute__ ((packed)); + +struct musb_fifo_cfg { + u8 hw_ep_num; + enum musb_fifo_style style; + enum musb_buf_mode mode; + u16 maxpacket; +}; + +#define MUSB_EP_FIFO(ep, st, m, pkt) \ +{ \ + .hw_ep_num = ep, \ + .style = st, \ + .mode = m, \ + .maxpacket = pkt, \ +} + +#define MUSB_EP_FIFO_SINGLE(ep, st, pkt) \ + MUSB_EP_FIFO(ep, st, BUF_SINGLE, pkt) + +#define MUSB_EP_FIFO_DOUBLE(ep, st, pkt) \ + MUSB_EP_FIFO(ep, st, BUF_DOUBLE, pkt) + struct musb_hdrc_eps_bits { const char name[16]; u8 bits; }; struct musb_hdrc_config { + struct musb_fifo_cfg *fifo_cfg; /* board fifo configuration */ + unsigned fifo_cfg_size; /* size of the fifo configuration */ + /* MUSB configuration-specific details */ unsigned multipoint:1; /* multipoint device */ unsigned dyn_fifo:1 __deprecated; /* supports dynamic fifo sizing */ @@ -51,8 +86,9 @@ struct musb_hdrc_config { struct musb_hdrc_eps_bits *eps_bits __deprecated; #ifdef CONFIG_BLACKFIN - /* A GPIO controlling VRSEL in Blackfin */ - unsigned int gpio_vrsel; + /* A GPIO controlling VRSEL in Blackfin */ + unsigned int gpio_vrsel; + unsigned int gpio_vrsel_active; #endif }; diff --git a/include/linux/usb/ncm.h b/include/linux/usb/ncm.h new file mode 100644 index 00000000000..006d1064c8b --- /dev/null +++ b/include/linux/usb/ncm.h @@ -0,0 +1,114 @@ +/* + * USB CDC NCM auxiliary definitions + */ + +#ifndef __LINUX_USB_NCM_H +#define __LINUX_USB_NCM_H + +#include <linux/types.h> +#include <linux/usb/cdc.h> +#include <asm/unaligned.h> + +#define NCM_NTB_MIN_IN_SIZE 2048 +#define NCM_NTB_MIN_OUT_SIZE 2048 + +#define NCM_CONTROL_TIMEOUT (5 * 1000) + +/* bmNetworkCapabilities */ + +#define NCM_NCAP_ETH_FILTER (1 << 0) +#define NCM_NCAP_NET_ADDRESS (1 << 1) +#define NCM_NCAP_ENCAP_COMM (1 << 2) +#define NCM_NCAP_MAX_DGRAM (1 << 3) +#define NCM_NCAP_CRC_MODE (1 << 4) + +/* + * Here are options for NCM Datagram Pointer table (NDP) parser. + * There are 2 different formats: NDP16 and NDP32 in the spec (ch. 3), + * in NDP16 offsets and sizes fields are 1 16bit word wide, + * in NDP32 -- 2 16bit words wide. Also signatures are different. + * To make the parser code the same, put the differences in the structure, + * and switch pointers to the structures when the format is changed. + */ + +struct ndp_parser_opts { + u32 nth_sign; + u32 ndp_sign; + unsigned nth_size; + unsigned ndp_size; + unsigned ndplen_align; + /* sizes in u16 units */ + unsigned dgram_item_len; /* index or length */ + unsigned block_length; + unsigned fp_index; + unsigned reserved1; + unsigned reserved2; + unsigned next_fp_index; +}; + +#define INIT_NDP16_OPTS { \ + .nth_sign = NCM_NTH16_SIGN, \ + .ndp_sign = NCM_NDP16_NOCRC_SIGN, \ + .nth_size = sizeof(struct usb_cdc_ncm_nth16), \ + .ndp_size = sizeof(struct usb_cdc_ncm_ndp16), \ + .ndplen_align = 4, \ + .dgram_item_len = 1, \ + .block_length = 1, \ + .fp_index = 1, \ + .reserved1 = 0, \ + .reserved2 = 0, \ + .next_fp_index = 1, \ + } + + +#define INIT_NDP32_OPTS { \ + .nth_sign = NCM_NTH32_SIGN, \ + .ndp_sign = NCM_NDP32_NOCRC_SIGN, \ + .nth_size = sizeof(struct usb_cdc_ncm_nth32), \ + .ndp_size = sizeof(struct usb_cdc_ncm_ndp32), \ + .ndplen_align = 8, \ + .dgram_item_len = 2, \ + .block_length = 2, \ + .fp_index = 2, \ + .reserved1 = 1, \ + .reserved2 = 2, \ + .next_fp_index = 2, \ + } + +static inline void put_ncm(__le16 **p, unsigned size, unsigned val) +{ + switch (size) { + case 1: + put_unaligned_le16((u16)val, *p); + break; + case 2: + put_unaligned_le32((u32)val, *p); + + break; + default: + BUG(); + } + + *p += size; +} + +static inline unsigned get_ncm(__le16 **p, unsigned size) +{ + unsigned tmp; + + switch (size) { + case 1: + tmp = get_unaligned_le16(*p); + break; + case 2: + tmp = get_unaligned_le32(*p); + break; + default: + BUG(); + } + + *p += size; + return tmp; +} + +#endif /* __LINUX_USB_NCM_H */ diff --git a/include/linux/usb/net2280.h b/include/linux/usb/net2280.h index 96ca549a778..148b8fa5b1a 100644 --- a/include/linux/usb/net2280.h +++ b/include/linux/usb/net2280.h @@ -353,7 +353,7 @@ struct net2280_dma_regs { /* [11.7] */ #define DMA_TRANSACTION_DONE_INTERRUPT 24 #define DMA_ABORT 1 #define DMA_START 0 - u32 _unused0 [2]; + u32 _unused0[2]; /* offset 0x0190, 0x01b0, 0x01d0, 0x01f0, */ u32 dmacount; #define VALID_BIT 31 @@ -374,7 +374,7 @@ struct net2280_dep_regs { /* [11.8] */ u32 dep_cfg; /* offset 0x0204, 0x0214, 0x224, 0x234, 0x244 */ u32 dep_rsp; - u32 _unused [2]; + u32 _unused[2]; } __attribute__ ((packed)); /* configurable endpoint registers, BAR0 + 0x0300 ... array of seven structs @@ -437,7 +437,7 @@ struct net2280_ep_regs { /* [11.9] */ /* offset 0x0310, 0x0330, 0x0350, 0x0370, 0x0390, 0x03b0, 0x03d0 */ u32 ep_avail; u32 ep_data; - u32 _unused0 [2]; + u32 _unused0[2]; } __attribute__ ((packed)); #endif /* __LINUX_USB_NET2280_H */ diff --git a/include/linux/usb/quirks.h b/include/linux/usb/quirks.h index 0a555dd131f..16b7f334754 100644 --- a/include/linux/usb/quirks.h +++ b/include/linux/usb/quirks.h @@ -22,4 +22,8 @@ /*device will morph if reset, don't use reset for handling errors */ #define USB_QUIRK_RESET_MORPHS 0x00000010 +/* device has more interface descriptions than the bNumInterfaces count, + and can't handle talking to these interfaces */ +#define USB_QUIRK_HONOR_BNUMINTERFACES 0x00000020 + #endif /* __LINUX_USB_QUIRKS_H */ diff --git a/include/linux/usb/rndis_host.h b/include/linux/usb/rndis_host.h index 1ef1ebc2b04..05ef5286198 100644 --- a/include/linux/usb/rndis_host.h +++ b/include/linux/usb/rndis_host.h @@ -34,10 +34,10 @@ struct rndis_msg_hdr { __le32 msg_type; /* RNDIS_MSG_* */ __le32 msg_len; - // followed by data that varies between messages + /* followed by data that varies between messages */ __le32 request_id; __le32 status; - // ... and more + /* ... and more */ } __attribute__ ((packed)); /* MS-Windows uses this strange size, but RNDIS spec says 1024 minimum */ @@ -92,67 +92,67 @@ struct rndis_msg_hdr { struct rndis_data_hdr { __le32 msg_type; /* RNDIS_MSG_PACKET */ - __le32 msg_len; // rndis_data_hdr + data_len + pad - __le32 data_offset; // 36 -- right after header - __le32 data_len; // ... real packet size + __le32 msg_len; /* rndis_data_hdr + data_len + pad */ + __le32 data_offset; /* 36 -- right after header */ + __le32 data_len; /* ... real packet size */ - __le32 oob_data_offset; // zero - __le32 oob_data_len; // zero - __le32 num_oob; // zero - __le32 packet_data_offset; // zero + __le32 oob_data_offset; /* zero */ + __le32 oob_data_len; /* zero */ + __le32 num_oob; /* zero */ + __le32 packet_data_offset; /* zero */ - __le32 packet_data_len; // zero - __le32 vc_handle; // zero - __le32 reserved; // zero + __le32 packet_data_len; /* zero */ + __le32 vc_handle; /* zero */ + __le32 reserved; /* zero */ } __attribute__ ((packed)); struct rndis_init { /* OUT */ - // header and: + /* header and: */ __le32 msg_type; /* RNDIS_MSG_INIT */ - __le32 msg_len; // 24 + __le32 msg_len; /* 24 */ __le32 request_id; - __le32 major_version; // of rndis (1.0) + __le32 major_version; /* of rndis (1.0) */ __le32 minor_version; __le32 max_transfer_size; } __attribute__ ((packed)); struct rndis_init_c { /* IN */ - // header and: + /* header and: */ __le32 msg_type; /* RNDIS_MSG_INIT_C */ __le32 msg_len; __le32 request_id; __le32 status; - __le32 major_version; // of rndis (1.0) + __le32 major_version; /* of rndis (1.0) */ __le32 minor_version; __le32 device_flags; - __le32 medium; // zero == 802.3 + __le32 medium; /* zero == 802.3 */ __le32 max_packets_per_message; __le32 max_transfer_size; - __le32 packet_alignment; // max 7; (1<<n) bytes - __le32 af_list_offset; // zero - __le32 af_list_size; // zero + __le32 packet_alignment; /* max 7; (1<<n) bytes */ + __le32 af_list_offset; /* zero */ + __le32 af_list_size; /* zero */ } __attribute__ ((packed)); struct rndis_halt { /* OUT (no reply) */ - // header and: + /* header and: */ __le32 msg_type; /* RNDIS_MSG_HALT */ __le32 msg_len; __le32 request_id; } __attribute__ ((packed)); struct rndis_query { /* OUT */ - // header and: + /* header and: */ __le32 msg_type; /* RNDIS_MSG_QUERY */ __le32 msg_len; __le32 request_id; __le32 oid; __le32 len; __le32 offset; -/*?*/ __le32 handle; // zero +/*?*/ __le32 handle; /* zero */ } __attribute__ ((packed)); struct rndis_query_c { /* IN */ - // header and: + /* header and: */ __le32 msg_type; /* RNDIS_MSG_QUERY_C */ __le32 msg_len; __le32 request_id; @@ -162,18 +162,18 @@ struct rndis_query_c { /* IN */ } __attribute__ ((packed)); struct rndis_set { /* OUT */ - // header and: + /* header and: */ __le32 msg_type; /* RNDIS_MSG_SET */ __le32 msg_len; __le32 request_id; __le32 oid; __le32 len; __le32 offset; -/*?*/ __le32 handle; // zero +/*?*/ __le32 handle; /* zero */ } __attribute__ ((packed)); struct rndis_set_c { /* IN */ - // header and: + /* header and: */ __le32 msg_type; /* RNDIS_MSG_SET_C */ __le32 msg_len; __le32 request_id; @@ -181,14 +181,14 @@ struct rndis_set_c { /* IN */ } __attribute__ ((packed)); struct rndis_reset { /* IN */ - // header and: + /* header and: */ __le32 msg_type; /* RNDIS_MSG_RESET */ __le32 msg_len; __le32 reserved; } __attribute__ ((packed)); struct rndis_reset_c { /* OUT */ - // header and: + /* header and: */ __le32 msg_type; /* RNDIS_MSG_RESET_C */ __le32 msg_len; __le32 status; @@ -196,7 +196,7 @@ struct rndis_reset_c { /* OUT */ } __attribute__ ((packed)); struct rndis_indicate { /* IN (unrequested) */ - // header and: + /* header and: */ __le32 msg_type; /* RNDIS_MSG_INDICATE */ __le32 msg_len; __le32 status; @@ -208,14 +208,14 @@ struct rndis_indicate { /* IN (unrequested) */ } __attribute__ ((packed)); struct rndis_keepalive { /* OUT (optionally IN) */ - // header and: + /* header and: */ __le32 msg_type; /* RNDIS_MSG_KEEPALIVE */ __le32 msg_len; __le32 request_id; } __attribute__ ((packed)); struct rndis_keepalive_c { /* IN (optionally OUT) */ - // header and: + /* header and: */ __le32 msg_type; /* RNDIS_MSG_KEEPALIVE_C */ __le32 msg_len; __le32 request_id; diff --git a/include/linux/usb/serial.h b/include/linux/usb/serial.h index 0a458b86193..84a4c44c208 100644 --- a/include/linux/usb/serial.h +++ b/include/linux/usb/serial.h @@ -35,6 +35,9 @@ enum port_dev_state { PORT_UNREGISTERING, }; +/* USB serial flags */ +#define USB_SERIAL_WRITE_BUSY 0 + /** * usb_serial_port: structure for the specific ports of a device. * @serial: pointer back to the struct usb_serial owner of this port. @@ -49,7 +52,7 @@ enum port_dev_state { * @interrupt_out_size: the size of the interrupt_out_buffer, in bytes. * @interrupt_out_urb: pointer to the interrupt out struct urb for this port. * @interrupt_out_endpointAddress: endpoint address for the interrupt out pipe - * for this port. + * for this port. * @bulk_in_buffer: pointer to the bulk in buffer for this port. * @bulk_in_size: the size of the bulk_in_buffer, in bytes. * @read_urb: pointer to the bulk in struct urb for this port. @@ -60,13 +63,17 @@ enum port_dev_state { * @write_urb: pointer to the bulk out struct urb for this port. * @write_fifo: kfifo used to buffer outgoing data * @write_urb_busy: port`s writing status + * @bulk_out_buffers: pointers to the bulk out buffers for this port + * @write_urbs: pointers to the bulk out urbs for this port + * @write_urbs_free: status bitmap the for bulk out urbs + * @tx_bytes: number of bytes currently in host stack queues * @bulk_out_endpointAddress: endpoint address for the bulk out pipe for this * port. + * @flags: usb serial port flags * @write_wait: a wait_queue_head_t used by the port. * @work: work queue entry for the line discipline waking up. * @throttled: nonzero if the read urb is inactive to throttle the device * @throttle_req: nonzero if the tty wants to throttle us - * @console: attached usb serial console * @dev: pointer to the serial device * * This structure is used by the usb-serial core and drivers for the specific @@ -97,16 +104,19 @@ struct usb_serial_port { struct urb *write_urb; struct kfifo write_fifo; int write_urb_busy; + + unsigned char *bulk_out_buffers[2]; + struct urb *write_urbs[2]; + unsigned long write_urbs_free; __u8 bulk_out_endpointAddress; - int tx_bytes_flight; - int urbs_in_flight; + int tx_bytes; + unsigned long flags; wait_queue_head_t write_wait; struct work_struct work; char throttled; char throttle_req; - char console; unsigned long sysrq; /* sysrq timeout */ struct device dev; enum port_dev_state dev_state; @@ -181,6 +191,8 @@ static inline void usb_set_serial_data(struct usb_serial *serial, void *data) * @id_table: pointer to a list of usb_device_id structures that define all * of the devices this structure can support. * @num_ports: the number of different ports this device will have. + * @bulk_in_size: bytes to allocate for bulk-in buffer (0 = end-point size) + * @bulk_out_size: bytes to allocate for bulk-out buffer (0 = end-point size) * @calc_num_ports: pointer to a function to determine how many ports this * device has dynamically. It will be called after the probe() * callback is called, but before attach() @@ -223,7 +235,9 @@ struct usb_serial_driver { struct device_driver driver; struct usb_driver *usb_driver; struct usb_dynids dynids; - int max_in_flight_urbs; + + size_t bulk_in_size; + size_t bulk_out_size; int (*probe)(struct usb_serial *serial, const struct usb_device_id *id); int (*attach)(struct usb_serial *serial); @@ -269,6 +283,11 @@ struct usb_serial_driver { void (*write_int_callback)(struct urb *urb); void (*read_bulk_callback)(struct urb *urb); void (*write_bulk_callback)(struct urb *urb); + /* Called by the generic read bulk callback */ + void (*process_read_urb)(struct urb *urb); + /* Called by the generic write implementation */ + int (*prepare_write_buffer)(struct usb_serial_port *port, + void *dest, size_t size); }; #define to_usb_serial_driver(d) \ container_of(d, struct usb_serial_driver, driver) @@ -318,8 +337,11 @@ extern void usb_serial_generic_disconnect(struct usb_serial *serial); extern void usb_serial_generic_release(struct usb_serial *serial); extern int usb_serial_generic_register(int debug); extern void usb_serial_generic_deregister(void); -extern void usb_serial_generic_resubmit_read_urb(struct usb_serial_port *port, +extern int usb_serial_generic_submit_read_urb(struct usb_serial_port *port, gfp_t mem_flags); +extern void usb_serial_generic_process_read_urb(struct urb *urb); +extern int usb_serial_generic_prepare_write_buffer(struct usb_serial_port *port, + void *dest, size_t size); extern int usb_serial_handle_sysrq_char(struct tty_struct *tty, struct usb_serial_port *port, unsigned int ch); diff --git a/include/linux/usb/ulpi.h b/include/linux/usb/ulpi.h index 20675c6ebc4..2369d07c3c8 100644 --- a/include/linux/usb/ulpi.h +++ b/include/linux/usb/ulpi.h @@ -1,6 +1,146 @@ +/* + * ulpi.h -- ULPI defines and function prorotypes + * + * Copyright (C) 2010 Nokia Corporation + * + * This software is distributed under the terms of the GNU General + * Public License ("GPL") as published by the Free Software Foundation, + * version 2 of that License. + */ + #ifndef __LINUX_USB_ULPI_H #define __LINUX_USB_ULPI_H +/*-------------------------------------------------------------------------*/ + +/* + * Macros for Set and Clear + * See ULPI 1.1 specification to find the registers with Set and Clear offsets + */ +#define ULPI_SET(a) (a + 1) +#define ULPI_CLR(a) (a + 2) + +/*-------------------------------------------------------------------------*/ + +/* + * Register Map + */ +#define ULPI_VENDOR_ID_LOW 0x00 +#define ULPI_VENDOR_ID_HIGH 0x01 +#define ULPI_PRODUCT_ID_LOW 0x02 +#define ULPI_PRODUCT_ID_HIGH 0x03 +#define ULPI_FUNC_CTRL 0x04 +#define ULPI_IFC_CTRL 0x07 +#define ULPI_OTG_CTRL 0x0a +#define ULPI_USB_INT_EN_RISE 0x0d +#define ULPI_USB_INT_EN_FALL 0x10 +#define ULPI_USB_INT_STS 0x13 +#define ULPI_USB_INT_LATCH 0x14 +#define ULPI_DEBUG 0x15 +#define ULPI_SCRATCH 0x16 +/* Optional Carkit Registers */ +#define ULPI_CARCIT_CTRL 0x19 +#define ULPI_CARCIT_INT_DELAY 0x1c +#define ULPI_CARCIT_INT_EN 0x1d +#define ULPI_CARCIT_INT_STS 0x20 +#define ULPI_CARCIT_INT_LATCH 0x21 +#define ULPI_CARCIT_PLS_CTRL 0x22 +/* Other Optional Registers */ +#define ULPI_TX_POS_WIDTH 0x25 +#define ULPI_TX_NEG_WIDTH 0x26 +#define ULPI_POLARITY_RECOVERY 0x27 +/* Access Extended Register Set */ +#define ULPI_ACCESS_EXTENDED 0x2f +/* Vendor Specific */ +#define ULPI_VENDOR_SPECIFIC 0x30 +/* Extended Registers */ +#define ULPI_EXT_VENDOR_SPECIFIC 0x80 + +/*-------------------------------------------------------------------------*/ + +/* Function Control */ +#define ULPI_FUNC_CTRL_XCVRSEL (1 << 0) +#define ULPI_FUNC_CTRL_XCVRSEL_MASK (3 << 0) +#define ULPI_FUNC_CTRL_HIGH_SPEED (0 << 0) +#define ULPI_FUNC_CTRL_FULL_SPEED (1 << 0) +#define ULPI_FUNC_CTRL_LOW_SPEED (2 << 0) +#define ULPI_FUNC_CTRL_FS4LS (3 << 0) +#define ULPI_FUNC_CTRL_TERMSELECT (1 << 2) +#define ULPI_FUNC_CTRL_OPMODE (1 << 3) +#define ULPI_FUNC_CTRL_OPMODE_MASK (3 << 3) +#define ULPI_FUNC_CTRL_OPMODE_NORMAL (0 << 3) +#define ULPI_FUNC_CTRL_OPMODE_NONDRIVING (1 << 3) +#define ULPI_FUNC_CTRL_OPMODE_DISABLE_NRZI (2 << 3) +#define ULPI_FUNC_CTRL_OPMODE_NOSYNC_NOEOP (3 << 3) +#define ULPI_FUNC_CTRL_RESET (1 << 5) +#define ULPI_FUNC_CTRL_SUSPENDM (1 << 6) + +/* Interface Control */ +#define ULPI_IFC_CTRL_6_PIN_SERIAL_MODE (1 << 0) +#define ULPI_IFC_CTRL_3_PIN_SERIAL_MODE (1 << 1) +#define ULPI_IFC_CTRL_CARKITMODE (1 << 2) +#define ULPI_IFC_CTRL_CLOCKSUSPENDM (1 << 3) +#define ULPI_IFC_CTRL_AUTORESUME (1 << 4) +#define ULPI_IFC_CTRL_EXTERNAL_VBUS (1 << 5) +#define ULPI_IFC_CTRL_PASSTHRU (1 << 6) +#define ULPI_IFC_CTRL_PROTECT_IFC_DISABLE (1 << 7) + +/* OTG Control */ +#define ULPI_OTG_CTRL_ID_PULLUP (1 << 0) +#define ULPI_OTG_CTRL_DP_PULLDOWN (1 << 1) +#define ULPI_OTG_CTRL_DM_PULLDOWN (1 << 2) +#define ULPI_OTG_CTRL_DISCHRGVBUS (1 << 3) +#define ULPI_OTG_CTRL_CHRGVBUS (1 << 4) +#define ULPI_OTG_CTRL_DRVVBUS (1 << 5) +#define ULPI_OTG_CTRL_DRVVBUS_EXT (1 << 6) +#define ULPI_OTG_CTRL_EXTVBUSIND (1 << 7) + +/* USB Interrupt Enable Rising, + * USB Interrupt Enable Falling, + * USB Interrupt Status and + * USB Interrupt Latch + */ +#define ULPI_INT_HOST_DISCONNECT (1 << 0) +#define ULPI_INT_VBUS_VALID (1 << 1) +#define ULPI_INT_SESS_VALID (1 << 2) +#define ULPI_INT_SESS_END (1 << 3) +#define ULPI_INT_IDGRD (1 << 4) + +/* Debug */ +#define ULPI_DEBUG_LINESTATE0 (1 << 0) +#define ULPI_DEBUG_LINESTATE1 (1 << 1) + +/* Carkit Control */ +#define ULPI_CARKIT_CTRL_CARKITPWR (1 << 0) +#define ULPI_CARKIT_CTRL_IDGNDDRV (1 << 1) +#define ULPI_CARKIT_CTRL_TXDEN (1 << 2) +#define ULPI_CARKIT_CTRL_RXDEN (1 << 3) +#define ULPI_CARKIT_CTRL_SPKLEFTEN (1 << 4) +#define ULPI_CARKIT_CTRL_SPKRIGHTEN (1 << 5) +#define ULPI_CARKIT_CTRL_MICEN (1 << 6) + +/* Carkit Interrupt Enable */ +#define ULPI_CARKIT_INT_EN_IDFLOAT_RISE (1 << 0) +#define ULPI_CARKIT_INT_EN_IDFLOAT_FALL (1 << 1) +#define ULPI_CARKIT_INT_EN_CARINTDET (1 << 2) +#define ULPI_CARKIT_INT_EN_DP_RISE (1 << 3) +#define ULPI_CARKIT_INT_EN_DP_FALL (1 << 4) + +/* Carkit Interrupt Status and + * Carkit Interrupt Latch + */ +#define ULPI_CARKIT_INT_IDFLOAT (1 << 0) +#define ULPI_CARKIT_INT_CARINTDET (1 << 1) +#define ULPI_CARKIT_INT_DP (1 << 2) + +/* Carkit Pulse Control*/ +#define ULPI_CARKIT_PLS_CTRL_TXPLSEN (1 << 0) +#define ULPI_CARKIT_PLS_CTRL_RXPLSEN (1 << 1) +#define ULPI_CARKIT_PLS_CTRL_SPKRLEFT_BIASEN (1 << 2) +#define ULPI_CARKIT_PLS_CTRL_SPKRRIGHT_BIASEN (1 << 3) + +/*-------------------------------------------------------------------------*/ + struct otg_transceiver *otg_ulpi_create(struct otg_io_access_ops *ops, unsigned int flags); diff --git a/include/linux/usb/usbnet.h b/include/linux/usb/usbnet.h index df1e83dd9a5..7ae27a47381 100644 --- a/include/linux/usb/usbnet.h +++ b/include/linux/usb/usbnet.h @@ -43,7 +43,7 @@ struct usbnet { /* protocol/interface state */ struct net_device *net; int msg_enable; - unsigned long data [5]; + unsigned long data[5]; u32 xid; u32 hard_mtu; /* count any extra framing */ size_t rx_urb_size; /* size for rx urbs */ @@ -148,8 +148,8 @@ struct driver_info { * much everything except custom framing and chip-specific stuff. */ extern int usbnet_probe(struct usb_interface *, const struct usb_device_id *); -extern int usbnet_suspend (struct usb_interface *, pm_message_t ); -extern int usbnet_resume (struct usb_interface *); +extern int usbnet_suspend(struct usb_interface *, pm_message_t); +extern int usbnet_resume(struct usb_interface *); extern void usbnet_disconnect(struct usb_interface *); @@ -165,8 +165,8 @@ struct cdc_state { struct usb_interface *data; }; -extern int usbnet_generic_cdc_bind (struct usbnet *, struct usb_interface *); -extern void usbnet_cdc_unbind (struct usbnet *, struct usb_interface *); +extern int usbnet_generic_cdc_bind(struct usbnet *, struct usb_interface *); +extern void usbnet_cdc_unbind(struct usbnet *, struct usb_interface *); /* CDC and RNDIS support the same host-chosen packet filters for IN transfers */ #define DEFAULT_FILTER (USB_CDC_PACKET_TYPE_BROADCAST \ @@ -189,29 +189,31 @@ struct skb_data { /* skb->cb is one of these */ size_t length; }; -extern int usbnet_open (struct net_device *net); -extern int usbnet_stop (struct net_device *net); -extern netdev_tx_t usbnet_start_xmit (struct sk_buff *skb, - struct net_device *net); -extern void usbnet_tx_timeout (struct net_device *net); -extern int usbnet_change_mtu (struct net_device *net, int new_mtu); +extern int usbnet_open(struct net_device *net); +extern int usbnet_stop(struct net_device *net); +extern netdev_tx_t usbnet_start_xmit(struct sk_buff *skb, + struct net_device *net); +extern void usbnet_tx_timeout(struct net_device *net); +extern int usbnet_change_mtu(struct net_device *net, int new_mtu); extern int usbnet_get_endpoints(struct usbnet *, struct usb_interface *); extern int usbnet_get_ethernet_addr(struct usbnet *, int); -extern void usbnet_defer_kevent (struct usbnet *, int); -extern void usbnet_skb_return (struct usbnet *, struct sk_buff *); +extern void usbnet_defer_kevent(struct usbnet *, int); +extern void usbnet_skb_return(struct usbnet *, struct sk_buff *); extern void usbnet_unlink_rx_urbs(struct usbnet *); extern void usbnet_pause_rx(struct usbnet *); extern void usbnet_resume_rx(struct usbnet *); extern void usbnet_purge_paused_rxq(struct usbnet *); -extern int usbnet_get_settings (struct net_device *net, struct ethtool_cmd *cmd); -extern int usbnet_set_settings (struct net_device *net, struct ethtool_cmd *cmd); -extern u32 usbnet_get_link (struct net_device *net); -extern u32 usbnet_get_msglevel (struct net_device *); -extern void usbnet_set_msglevel (struct net_device *, u32); -extern void usbnet_get_drvinfo (struct net_device *, struct ethtool_drvinfo *); +extern int usbnet_get_settings(struct net_device *net, + struct ethtool_cmd *cmd); +extern int usbnet_set_settings(struct net_device *net, + struct ethtool_cmd *cmd); +extern u32 usbnet_get_link(struct net_device *net); +extern u32 usbnet_get_msglevel(struct net_device *); +extern void usbnet_set_msglevel(struct net_device *, u32); +extern void usbnet_get_drvinfo(struct net_device *, struct ethtool_drvinfo *); extern int usbnet_nway_reset(struct net_device *net); #endif /* __LINUX_USB_USBNET_H */ diff --git a/include/linux/usb/wusb-wa.h b/include/linux/usb/wusb-wa.h index fb7c359bdfb..f9dec37f617 100644 --- a/include/linux/usb/wusb-wa.h +++ b/include/linux/usb/wusb-wa.h @@ -87,7 +87,7 @@ enum rpipe_crs { * FIXME: explain rpipes */ struct usb_rpipe_descriptor { - u8 bLength; + u8 bLength; u8 bDescriptorType; __le16 wRPipeIndex; __le16 wRequests; diff --git a/include/linux/wait.h b/include/linux/wait.h index 76d96d035ea..0836ccc5712 100644 --- a/include/linux/wait.h +++ b/include/linux/wait.h @@ -376,6 +376,155 @@ do { \ __ret; \ }) + +#define __wait_event_interruptible_locked(wq, condition, exclusive, irq) \ +({ \ + int __ret = 0; \ + DEFINE_WAIT(__wait); \ + if (exclusive) \ + __wait.flags |= WQ_FLAG_EXCLUSIVE; \ + do { \ + if (likely(list_empty(&__wait.task_list))) \ + __add_wait_queue_tail(&(wq), &__wait); \ + set_current_state(TASK_INTERRUPTIBLE); \ + if (signal_pending(current)) { \ + __ret = -ERESTARTSYS; \ + break; \ + } \ + if (irq) \ + spin_unlock_irq(&(wq).lock); \ + else \ + spin_unlock(&(wq).lock); \ + schedule(); \ + if (irq) \ + spin_lock_irq(&(wq).lock); \ + else \ + spin_lock(&(wq).lock); \ + } while (!(condition)); \ + __remove_wait_queue(&(wq), &__wait); \ + __set_current_state(TASK_RUNNING); \ + __ret; \ +}) + + +/** + * wait_event_interruptible_locked - sleep until a condition gets true + * @wq: the waitqueue to wait on + * @condition: a C expression for the event to wait for + * + * The process is put to sleep (TASK_INTERRUPTIBLE) until the + * @condition evaluates to true or a signal is received. + * The @condition is checked each time the waitqueue @wq is woken up. + * + * It must be called with wq.lock being held. This spinlock is + * unlocked while sleeping but @condition testing is done while lock + * is held and when this macro exits the lock is held. + * + * The lock is locked/unlocked using spin_lock()/spin_unlock() + * functions which must match the way they are locked/unlocked outside + * of this macro. + * + * wake_up_locked() has to be called after changing any variable that could + * change the result of the wait condition. + * + * The function will return -ERESTARTSYS if it was interrupted by a + * signal and 0 if @condition evaluated to true. + */ +#define wait_event_interruptible_locked(wq, condition) \ + ((condition) \ + ? 0 : __wait_event_interruptible_locked(wq, condition, 0, 0)) + +/** + * wait_event_interruptible_locked_irq - sleep until a condition gets true + * @wq: the waitqueue to wait on + * @condition: a C expression for the event to wait for + * + * The process is put to sleep (TASK_INTERRUPTIBLE) until the + * @condition evaluates to true or a signal is received. + * The @condition is checked each time the waitqueue @wq is woken up. + * + * It must be called with wq.lock being held. This spinlock is + * unlocked while sleeping but @condition testing is done while lock + * is held and when this macro exits the lock is held. + * + * The lock is locked/unlocked using spin_lock_irq()/spin_unlock_irq() + * functions which must match the way they are locked/unlocked outside + * of this macro. + * + * wake_up_locked() has to be called after changing any variable that could + * change the result of the wait condition. + * + * The function will return -ERESTARTSYS if it was interrupted by a + * signal and 0 if @condition evaluated to true. + */ +#define wait_event_interruptible_locked_irq(wq, condition) \ + ((condition) \ + ? 0 : __wait_event_interruptible_locked(wq, condition, 0, 1)) + +/** + * wait_event_interruptible_exclusive_locked - sleep exclusively until a condition gets true + * @wq: the waitqueue to wait on + * @condition: a C expression for the event to wait for + * + * The process is put to sleep (TASK_INTERRUPTIBLE) until the + * @condition evaluates to true or a signal is received. + * The @condition is checked each time the waitqueue @wq is woken up. + * + * It must be called with wq.lock being held. This spinlock is + * unlocked while sleeping but @condition testing is done while lock + * is held and when this macro exits the lock is held. + * + * The lock is locked/unlocked using spin_lock()/spin_unlock() + * functions which must match the way they are locked/unlocked outside + * of this macro. + * + * The process is put on the wait queue with an WQ_FLAG_EXCLUSIVE flag + * set thus when other process waits process on the list if this + * process is awaken further processes are not considered. + * + * wake_up_locked() has to be called after changing any variable that could + * change the result of the wait condition. + * + * The function will return -ERESTARTSYS if it was interrupted by a + * signal and 0 if @condition evaluated to true. + */ +#define wait_event_interruptible_exclusive_locked(wq, condition) \ + ((condition) \ + ? 0 : __wait_event_interruptible_locked(wq, condition, 1, 0)) + +/** + * wait_event_interruptible_exclusive_locked_irq - sleep until a condition gets true + * @wq: the waitqueue to wait on + * @condition: a C expression for the event to wait for + * + * The process is put to sleep (TASK_INTERRUPTIBLE) until the + * @condition evaluates to true or a signal is received. + * The @condition is checked each time the waitqueue @wq is woken up. + * + * It must be called with wq.lock being held. This spinlock is + * unlocked while sleeping but @condition testing is done while lock + * is held and when this macro exits the lock is held. + * + * The lock is locked/unlocked using spin_lock_irq()/spin_unlock_irq() + * functions which must match the way they are locked/unlocked outside + * of this macro. + * + * The process is put on the wait queue with an WQ_FLAG_EXCLUSIVE flag + * set thus when other process waits process on the list if this + * process is awaken further processes are not considered. + * + * wake_up_locked() has to be called after changing any variable that could + * change the result of the wait condition. + * + * The function will return -ERESTARTSYS if it was interrupted by a + * signal and 0 if @condition evaluated to true. + */ +#define wait_event_interruptible_exclusive_locked_irq(wq, condition) \ + ((condition) \ + ? 0 : __wait_event_interruptible_locked(wq, condition, 1, 1)) + + + #define __wait_event_killable(wq, condition, ret) \ do { \ DEFINE_WAIT(__wait); \ |