[uboot] create uboot from github:
repo: https://github.com/u-boot/u-boot commit: d80bb749fab53da72c4a0e09b8c2d2aaa3103c91 Change-Id: Ie6434426e1ec15bc08bb1832798e371f3fd5fb29
This commit is contained in:
19
u-boot-2021.10/include/linux/usb/at91_udc.h
Normal file
19
u-boot-2021.10/include/linux/usb/at91_udc.h
Normal file
@ -0,0 +1,19 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0+ */
|
||||
/*
|
||||
* Platform data definitions for Atmel USBA gadget driver
|
||||
* pieces copied from linux:include/linux/platform_data/atmel.h
|
||||
*/
|
||||
#ifndef __LINUX_USB_AT91_UDC_H__
|
||||
#define __LINUX_USB_AT91_UDC_H__
|
||||
|
||||
struct at91_udc_data {
|
||||
int vbus_pin; /* high == host powering us */
|
||||
u8 vbus_active_low; /* vbus polarity */
|
||||
u8 vbus_polled; /* Use polling, not interrupt */
|
||||
int pullup_pin; /* active == D+ pulled up */
|
||||
u8 pullup_active_low; /* true == pullup_pin is active low */
|
||||
unsigned long baseaddr;
|
||||
};
|
||||
|
||||
int at91_udc_probe(struct at91_udc_data *pdata);
|
||||
#endif /* __LINUX_USB_AT91_UDC_H__ */
|
||||
25
u-boot-2021.10/include/linux/usb/atmel_usba_udc.h
Normal file
25
u-boot-2021.10/include/linux/usb/atmel_usba_udc.h
Normal file
@ -0,0 +1,25 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0+ */
|
||||
/*
|
||||
* Platform data definitions for Atmel USBA gadget driver
|
||||
* [Original from Linux kernel: include/linux/usb/atmel_usba_udc.h]
|
||||
*/
|
||||
#ifndef __LINUX_USB_USBA_H__
|
||||
#define __LINUX_USB_USBA_H__
|
||||
|
||||
struct usba_ep_data {
|
||||
char *name;
|
||||
int index;
|
||||
int fifo_size;
|
||||
int nr_banks;
|
||||
int can_dma;
|
||||
int can_isoc;
|
||||
};
|
||||
|
||||
struct usba_platform_data {
|
||||
int num_ep;
|
||||
struct usba_ep_data *ep;
|
||||
};
|
||||
|
||||
extern int usba_udc_probe(struct usba_platform_data *pdata);
|
||||
|
||||
#endif /* __LINUX_USB_USBA_H */
|
||||
224
u-boot-2021.10/include/linux/usb/cdc.h
Normal file
224
u-boot-2021.10/include/linux/usb/cdc.h
Normal file
@ -0,0 +1,224 @@
|
||||
/*
|
||||
* USB Communications Device Class (CDC) definitions
|
||||
*
|
||||
* CDC says how to talk to lots of different types of network adapters,
|
||||
* notably ethernet adapters and various modems. It's used mostly with
|
||||
* firmware based USB peripherals.
|
||||
*
|
||||
* Ported to U-Boot by: Thomas Smits <ts.smits@gmail.com> and
|
||||
* Remy Bohmer <linux@bohmer.net>
|
||||
*/
|
||||
|
||||
#define USB_CDC_SUBCLASS_ACM 0x02
|
||||
#define USB_CDC_SUBCLASS_ETHERNET 0x06
|
||||
#define USB_CDC_SUBCLASS_WHCM 0x08
|
||||
#define USB_CDC_SUBCLASS_DMM 0x09
|
||||
#define USB_CDC_SUBCLASS_MDLM 0x0a
|
||||
#define USB_CDC_SUBCLASS_OBEX 0x0b
|
||||
|
||||
#define USB_CDC_PROTO_NONE 0
|
||||
|
||||
#define USB_CDC_ACM_PROTO_AT_V25TER 1
|
||||
#define USB_CDC_ACM_PROTO_AT_PCCA101 2
|
||||
#define USB_CDC_ACM_PROTO_AT_PCCA101_WAKE 3
|
||||
#define USB_CDC_ACM_PROTO_AT_GSM 4
|
||||
#define USB_CDC_ACM_PROTO_AT_3G 5
|
||||
#define USB_CDC_ACM_PROTO_AT_CDMA 6
|
||||
#define USB_CDC_ACM_PROTO_VENDOR 0xff
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* Class-Specific descriptors ... there are a couple dozen of them
|
||||
*/
|
||||
|
||||
#define USB_CDC_HEADER_TYPE 0x00 /* header_desc */
|
||||
#define USB_CDC_CALL_MANAGEMENT_TYPE 0x01 /* call_mgmt_descriptor */
|
||||
#define USB_CDC_ACM_TYPE 0x02 /* acm_descriptor */
|
||||
#define USB_CDC_UNION_TYPE 0x06 /* union_desc */
|
||||
#define USB_CDC_COUNTRY_TYPE 0x07
|
||||
#define USB_CDC_NETWORK_TERMINAL_TYPE 0x0a /* network_terminal_desc */
|
||||
#define USB_CDC_ETHERNET_TYPE 0x0f /* ether_desc */
|
||||
#define USB_CDC_WHCM_TYPE 0x11
|
||||
#define USB_CDC_MDLM_TYPE 0x12 /* mdlm_desc */
|
||||
#define USB_CDC_MDLM_DETAIL_TYPE 0x13 /* mdlm_detail_desc */
|
||||
#define USB_CDC_DMM_TYPE 0x14
|
||||
#define USB_CDC_OBEX_TYPE 0x15
|
||||
|
||||
/* "Header Functional Descriptor" from CDC spec 5.2.3.1 */
|
||||
struct usb_cdc_header_desc {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
__u8 bDescriptorSubType;
|
||||
|
||||
__le16 bcdCDC;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
/* "Call Management Descriptor" from CDC spec 5.2.3.2 */
|
||||
struct usb_cdc_call_mgmt_descriptor {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
__u8 bDescriptorSubType;
|
||||
|
||||
__u8 bmCapabilities;
|
||||
#define USB_CDC_CALL_MGMT_CAP_CALL_MGMT 0x01
|
||||
#define USB_CDC_CALL_MGMT_CAP_DATA_INTF 0x02
|
||||
|
||||
__u8 bDataInterface;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
/* "Abstract Control Management Descriptor" from CDC spec 5.2.3.3 */
|
||||
struct usb_cdc_acm_descriptor {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
__u8 bDescriptorSubType;
|
||||
|
||||
__u8 bmCapabilities;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
/* capabilities from 5.2.3.3 */
|
||||
|
||||
#define USB_CDC_COMM_FEATURE 0x01
|
||||
#define USB_CDC_CAP_LINE 0x02
|
||||
#define USB_CDC_CAP_BRK 0x04
|
||||
#define USB_CDC_CAP_NOTIFY 0x08
|
||||
|
||||
/* "Union Functional Descriptor" from CDC spec 5.2.3.8 */
|
||||
struct usb_cdc_union_desc {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
__u8 bDescriptorSubType;
|
||||
|
||||
__u8 bMasterInterface0;
|
||||
__u8 bSlaveInterface0;
|
||||
/* ... and there could be other slave interfaces */
|
||||
} __attribute__ ((packed));
|
||||
|
||||
/* "Country Selection Functional Descriptor" from CDC spec 5.2.3.9 */
|
||||
struct usb_cdc_country_functional_desc {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
__u8 bDescriptorSubType;
|
||||
|
||||
__u8 iCountryCodeRelDate;
|
||||
__le16 wCountyCode0;
|
||||
/* ... and there can be a lot of country codes */
|
||||
} __attribute__ ((packed));
|
||||
|
||||
/* "Network Channel Terminal Functional Descriptor" from CDC spec 5.2.3.11 */
|
||||
struct usb_cdc_network_terminal_desc {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
__u8 bDescriptorSubType;
|
||||
|
||||
__u8 bEntityId;
|
||||
__u8 iName;
|
||||
__u8 bChannelIndex;
|
||||
__u8 bPhysicalInterface;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
/* "Ethernet Networking Functional Descriptor" from CDC spec 5.2.3.16 */
|
||||
struct usb_cdc_ether_desc {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
__u8 bDescriptorSubType;
|
||||
|
||||
__u8 iMACAddress;
|
||||
__le32 bmEthernetStatistics;
|
||||
__le16 wMaxSegmentSize;
|
||||
__le16 wNumberMCFilters;
|
||||
__u8 bNumberPowerFilters;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
/* "MDLM Functional Descriptor" from CDC WMC spec 6.7.2.3 */
|
||||
struct usb_cdc_mdlm_desc {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
__u8 bDescriptorSubType;
|
||||
|
||||
__le16 bcdVersion;
|
||||
__u8 bGUID[16];
|
||||
} __attribute__ ((packed));
|
||||
|
||||
/* "MDLM Detail Functional Descriptor" from CDC WMC spec 6.7.2.4 */
|
||||
struct usb_cdc_mdlm_detail_desc {
|
||||
__u8 bLength;
|
||||
__u8 bDescriptorType;
|
||||
__u8 bDescriptorSubType;
|
||||
|
||||
/* type is associated with mdlm_desc.bGUID */
|
||||
__u8 bGuidDescriptorType;
|
||||
__u8 bDetailData[0];
|
||||
} __attribute__ ((packed));
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* Class-Specific Control Requests (6.2)
|
||||
*
|
||||
* section 3.6.2.1 table 4 has the ACM profile, for modems.
|
||||
* section 3.8.2 table 10 has the ethernet profile.
|
||||
*
|
||||
* Microsoft's RNDIS stack for Ethernet is a vendor-specific CDC ACM variant,
|
||||
* heavily dependent on the encapsulated (proprietary) command mechanism.
|
||||
*/
|
||||
|
||||
#define USB_CDC_SEND_ENCAPSULATED_COMMAND 0x00
|
||||
#define USB_CDC_GET_ENCAPSULATED_RESPONSE 0x01
|
||||
#define USB_CDC_REQ_SET_LINE_CODING 0x20
|
||||
#define USB_CDC_REQ_GET_LINE_CODING 0x21
|
||||
#define USB_CDC_REQ_SET_CONTROL_LINE_STATE 0x22
|
||||
#define USB_CDC_REQ_SEND_BREAK 0x23
|
||||
#define USB_CDC_SET_ETHERNET_MULTICAST_FILTERS 0x40
|
||||
#define USB_CDC_SET_ETHERNET_PM_PATTERN_FILTER 0x41
|
||||
#define USB_CDC_GET_ETHERNET_PM_PATTERN_FILTER 0x42
|
||||
#define USB_CDC_SET_ETHERNET_PACKET_FILTER 0x43
|
||||
#define USB_CDC_GET_ETHERNET_STATISTIC 0x44
|
||||
|
||||
/* Line Coding Structure from CDC spec 6.2.13 */
|
||||
struct usb_cdc_line_coding {
|
||||
__le32 dwDTERate;
|
||||
__u8 bCharFormat;
|
||||
#define USB_CDC_1_STOP_BITS 0
|
||||
#define USB_CDC_1_5_STOP_BITS 1
|
||||
#define USB_CDC_2_STOP_BITS 2
|
||||
|
||||
__u8 bParityType;
|
||||
#define USB_CDC_NO_PARITY 0
|
||||
#define USB_CDC_ODD_PARITY 1
|
||||
#define USB_CDC_EVEN_PARITY 2
|
||||
#define USB_CDC_MARK_PARITY 3
|
||||
#define USB_CDC_SPACE_PARITY 4
|
||||
|
||||
__u8 bDataBits;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
/* table 62; bits in multicast filter */
|
||||
#define USB_CDC_PACKET_TYPE_PROMISCUOUS (1 << 0)
|
||||
#define USB_CDC_PACKET_TYPE_ALL_MULTICAST (1 << 1) /* no filter */
|
||||
#define USB_CDC_PACKET_TYPE_DIRECTED (1 << 2)
|
||||
#define USB_CDC_PACKET_TYPE_BROADCAST (1 << 3)
|
||||
#define USB_CDC_PACKET_TYPE_MULTICAST (1 << 4) /* filtered */
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* Class-Specific Notifications (6.3) sent by interrupt transfers
|
||||
*
|
||||
* section 3.8.2 table 11 of the CDC spec lists Ethernet notifications
|
||||
* section 3.6.2.1 table 5 specifies ACM notifications, accepted by RNDIS
|
||||
* RNDIS also defines its own bit-incompatible notifications
|
||||
*/
|
||||
|
||||
#define USB_CDC_NOTIFY_NETWORK_CONNECTION 0x00
|
||||
#define USB_CDC_NOTIFY_RESPONSE_AVAILABLE 0x01
|
||||
#define USB_CDC_NOTIFY_SERIAL_STATE 0x20
|
||||
#define USB_CDC_NOTIFY_SPEED_CHANGE 0x2a
|
||||
|
||||
struct usb_cdc_notification {
|
||||
__u8 bmRequestType;
|
||||
__u8 bNotificationType;
|
||||
__le16 wValue;
|
||||
__le16 wIndex;
|
||||
__le16 wLength;
|
||||
} __attribute__ ((packed));
|
||||
1063
u-boot-2021.10/include/linux/usb/ch9.h
Normal file
1063
u-boot-2021.10/include/linux/usb/ch9.h
Normal file
File diff suppressed because it is too large
Load Diff
417
u-boot-2021.10/include/linux/usb/composite.h
Normal file
417
u-boot-2021.10/include/linux/usb/composite.h
Normal file
@ -0,0 +1,417 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0+ */
|
||||
/*
|
||||
* composite.h -- framework for usb gadgets which are composite devices
|
||||
*
|
||||
* Copyright (C) 2006-2008 David Brownell
|
||||
*/
|
||||
|
||||
#ifndef __LINUX_USB_COMPOSITE_H
|
||||
#define __LINUX_USB_COMPOSITE_H
|
||||
|
||||
/*
|
||||
* This framework is an optional layer on top of the USB Gadget interface,
|
||||
* making it easier to build (a) Composite devices, supporting multiple
|
||||
* functions within any single configuration, and (b) Multi-configuration
|
||||
* devices, also supporting multiple functions but without necessarily
|
||||
* having more than one function per configuration.
|
||||
*
|
||||
* Example: a device with a single configuration supporting both network
|
||||
* link and mass storage functions is a composite device. Those functions
|
||||
* might alternatively be packaged in individual configurations, but in
|
||||
* the composite model the host can use both functions at the same time.
|
||||
*/
|
||||
|
||||
#include <common.h>
|
||||
#include <linux/usb/ch9.h>
|
||||
#include <linux/usb/gadget.h>
|
||||
#include <linux/bitmap.h>
|
||||
|
||||
/*
|
||||
* USB function drivers should return USB_GADGET_DELAYED_STATUS if they
|
||||
* wish to delay the data/status stages of the control transfer till they
|
||||
* are ready. The control transfer will then be kept from completing till
|
||||
* all the function drivers that requested for USB_GADGET_DELAYED_STAUS
|
||||
* invoke usb_composite_setup_continue().
|
||||
*/
|
||||
#define USB_GADGET_DELAYED_STATUS 0x7fff /* Impossibly large value */
|
||||
|
||||
struct usb_configuration;
|
||||
|
||||
/**
|
||||
* struct usb_os_desc_ext_prop - describes one "Extended Property"
|
||||
* @entry: used to keep a list of extended properties
|
||||
* @type: Extended Property type
|
||||
* @name_len: Extended Property unicode name length, including terminating '\0'
|
||||
* @name: Extended Property name
|
||||
* @data_len: Length of Extended Property blob (for unicode store double len)
|
||||
* @data: Extended Property blob
|
||||
*/
|
||||
struct usb_os_desc_ext_prop {
|
||||
struct list_head entry;
|
||||
u8 type;
|
||||
int name_len;
|
||||
char *name;
|
||||
int data_len;
|
||||
char *data;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct usb_os_desc - describes OS descriptors associated with one interface
|
||||
* @ext_compat_id: 16 bytes of "Compatible ID" and "Subcompatible ID"
|
||||
* @ext_prop: Extended Properties list
|
||||
* @ext_prop_len: Total length of Extended Properties blobs
|
||||
* @ext_prop_count: Number of Extended Properties
|
||||
*/
|
||||
struct usb_os_desc {
|
||||
char *ext_compat_id;
|
||||
struct list_head ext_prop;
|
||||
int ext_prop_len;
|
||||
int ext_prop_count;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct usb_os_desc_table - describes OS descriptors associated with one
|
||||
* interface of a usb_function
|
||||
* @if_id: Interface id
|
||||
* @os_desc: "Extended Compatibility ID" and "Extended Properties" of the
|
||||
* interface
|
||||
*
|
||||
* Each interface can have at most one "Extended Compatibility ID" and a
|
||||
* number of "Extended Properties".
|
||||
*/
|
||||
struct usb_os_desc_table {
|
||||
int if_id;
|
||||
struct usb_os_desc *os_desc;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct usb_function - describes one function of a configuration
|
||||
* @name: For diagnostics, identifies the function.
|
||||
* @strings: tables of strings, keyed by identifiers assigned during bind()
|
||||
* and by language IDs provided in control requests
|
||||
* @descriptors: Table of full (or low) speed descriptors, using interface and
|
||||
* string identifiers assigned during @bind(). If this pointer is null,
|
||||
* the function will not be available at full speed (or at low speed).
|
||||
* @hs_descriptors: Table of high speed descriptors, using interface and
|
||||
* string identifiers assigned during @bind(). If this pointer is null,
|
||||
* the function will not be available at high speed.
|
||||
* @config: assigned when @usb_add_function() is called; this is the
|
||||
* configuration with which this function is associated.
|
||||
* @os_desc_table: Table of (interface id, os descriptors) pairs. The function
|
||||
* can expose more than one interface. If an interface is a member of
|
||||
* an IAD, only the first interface of IAD has its entry in the table.
|
||||
* @os_desc_n: Number of entries in os_desc_table
|
||||
* @bind: Before the gadget can register, all of its functions bind() to the
|
||||
* available resources including string and interface identifiers used
|
||||
* in interface or class descriptors; endpoints; I/O buffers; and so on.
|
||||
* @unbind: Reverses @bind; called as a side effect of unregistering the
|
||||
* driver which added this function.
|
||||
* @set_alt: (REQUIRED) Reconfigures altsettings; function drivers may
|
||||
* initialize usb_ep.driver data at this time (when it is used).
|
||||
* Note that setting an interface to its current altsetting resets
|
||||
* interface state, and that all interfaces have a disabled state.
|
||||
* @get_alt: Returns the active altsetting. If this is not provided,
|
||||
* then only altsetting zero is supported.
|
||||
* @disable: (REQUIRED) Indicates the function should be disabled. Reasons
|
||||
* include host resetting or reconfiguring the gadget, and disconnection.
|
||||
* @setup: Used for interface-specific control requests.
|
||||
* @suspend: Notifies functions when the host stops sending USB traffic.
|
||||
* @resume: Notifies functions when the host restarts USB traffic.
|
||||
*
|
||||
* A single USB function uses one or more interfaces, and should in most
|
||||
* cases support operation at both full and high speeds. Each function is
|
||||
* associated by @usb_add_function() with a one configuration; that function
|
||||
* causes @bind() to be called so resources can be allocated as part of
|
||||
* setting up a gadget driver. Those resources include endpoints, which
|
||||
* should be allocated using @usb_ep_autoconfig().
|
||||
*
|
||||
* To support dual speed operation, a function driver provides descriptors
|
||||
* for both high and full speed operation. Except in rare cases that don't
|
||||
* involve bulk endpoints, each speed needs different endpoint descriptors.
|
||||
*
|
||||
* Function drivers choose their own strategies for managing instance data.
|
||||
* The simplest strategy just declares it "static', which means the function
|
||||
* can only be activated once. If the function needs to be exposed in more
|
||||
* than one configuration at a given speed, it needs to support multiple
|
||||
* usb_function structures (one for each configuration).
|
||||
*
|
||||
* A more complex strategy might encapsulate a @usb_function structure inside
|
||||
* a driver-specific instance structure to allows multiple activations. An
|
||||
* example of multiple activations might be a CDC ACM function that supports
|
||||
* two or more distinct instances within the same configuration, providing
|
||||
* several independent logical data links to a USB host.
|
||||
*/
|
||||
struct usb_function {
|
||||
const char *name;
|
||||
struct usb_gadget_strings **strings;
|
||||
struct usb_descriptor_header **descriptors;
|
||||
struct usb_descriptor_header **hs_descriptors;
|
||||
struct usb_descriptor_header **ss_descriptors;
|
||||
|
||||
struct usb_configuration *config;
|
||||
|
||||
struct usb_os_desc_table *os_desc_table;
|
||||
unsigned os_desc_n;
|
||||
|
||||
/* REVISIT: bind() functions can be marked __init, which
|
||||
* makes trouble for section mismatch analysis. See if
|
||||
* we can't restructure things to avoid mismatching.
|
||||
* Related: unbind() may kfree() but bind() won't...
|
||||
*/
|
||||
|
||||
/* configuration management: bind/unbind */
|
||||
int (*bind)(struct usb_configuration *,
|
||||
struct usb_function *);
|
||||
void (*unbind)(struct usb_configuration *,
|
||||
struct usb_function *);
|
||||
|
||||
/* runtime state management */
|
||||
int (*set_alt)(struct usb_function *,
|
||||
unsigned interface, unsigned alt);
|
||||
int (*get_alt)(struct usb_function *,
|
||||
unsigned interface);
|
||||
void (*disable)(struct usb_function *);
|
||||
int (*setup)(struct usb_function *,
|
||||
const struct usb_ctrlrequest *);
|
||||
void (*suspend)(struct usb_function *);
|
||||
void (*resume)(struct usb_function *);
|
||||
|
||||
/* private: */
|
||||
/* internals */
|
||||
struct list_head list;
|
||||
DECLARE_BITMAP(endpoints, 32);
|
||||
};
|
||||
|
||||
int usb_add_function(struct usb_configuration *, struct usb_function *);
|
||||
|
||||
int usb_function_deactivate(struct usb_function *);
|
||||
int usb_function_activate(struct usb_function *);
|
||||
|
||||
int usb_interface_id(struct usb_configuration *, struct usb_function *);
|
||||
|
||||
/**
|
||||
* ep_choose - select descriptor endpoint at current device speed
|
||||
* @g: gadget, connected and running at some speed
|
||||
* @hs: descriptor to use for high speed operation
|
||||
* @fs: descriptor to use for full or low speed operation
|
||||
*/
|
||||
static inline struct usb_endpoint_descriptor *
|
||||
ep_choose(struct usb_gadget *g, struct usb_endpoint_descriptor *hs,
|
||||
struct usb_endpoint_descriptor *fs)
|
||||
{
|
||||
if (gadget_is_dualspeed(g) && g->speed == USB_SPEED_HIGH)
|
||||
return hs;
|
||||
return fs;
|
||||
}
|
||||
|
||||
#define MAX_CONFIG_INTERFACES 16 /* arbitrary; max 255 */
|
||||
|
||||
/**
|
||||
* struct usb_configuration - represents one gadget configuration
|
||||
* @label: For diagnostics, describes the configuration.
|
||||
* @strings: Tables of strings, keyed by identifiers assigned during @bind()
|
||||
* and by language IDs provided in control requests.
|
||||
* @descriptors: Table of descriptors preceding all function descriptors.
|
||||
* Examples include OTG and vendor-specific descriptors.
|
||||
* @bind: Called from @usb_add_config() to allocate resources unique to this
|
||||
* configuration and to call @usb_add_function() for each function used.
|
||||
* @unbind: Reverses @bind; called as a side effect of unregistering the
|
||||
* driver which added this configuration.
|
||||
* @setup: Used to delegate control requests that aren't handled by standard
|
||||
* device infrastructure or directed at a specific interface.
|
||||
* @bConfigurationValue: Copied into configuration descriptor.
|
||||
* @iConfiguration: Copied into configuration descriptor.
|
||||
* @bmAttributes: Copied into configuration descriptor.
|
||||
* @bMaxPower: Copied into configuration descriptor.
|
||||
* @cdev: assigned by @usb_add_config() before calling @bind(); this is
|
||||
* the device associated with this configuration.
|
||||
*
|
||||
* Configurations are building blocks for gadget drivers structured around
|
||||
* function drivers. Simple USB gadgets require only one function and one
|
||||
* configuration, and handle dual-speed hardware by always providing the same
|
||||
* functionality. Slightly more complex gadgets may have more than one
|
||||
* single-function configuration at a given speed; or have configurations
|
||||
* that only work at one speed.
|
||||
*
|
||||
* Composite devices are, by definition, ones with configurations which
|
||||
* include more than one function.
|
||||
*
|
||||
* The lifecycle of a usb_configuration includes allocation, initialization
|
||||
* of the fields described above, and calling @usb_add_config() to set up
|
||||
* internal data and bind it to a specific device. The configuration's
|
||||
* @bind() method is then used to initialize all the functions and then
|
||||
* call @usb_add_function() for them.
|
||||
*
|
||||
* Those functions would normally be independant of each other, but that's
|
||||
* not mandatory. CDC WMC devices are an example where functions often
|
||||
* depend on other functions, with some functions subsidiary to others.
|
||||
* Such interdependency may be managed in any way, so long as all of the
|
||||
* descriptors complete by the time the composite driver returns from
|
||||
* its bind() routine.
|
||||
*/
|
||||
struct usb_configuration {
|
||||
const char *label;
|
||||
struct usb_gadget_strings **strings;
|
||||
const struct usb_descriptor_header **descriptors;
|
||||
|
||||
/* REVISIT: bind() functions can be marked __init, which
|
||||
* makes trouble for section mismatch analysis. See if
|
||||
* we can't restructure things to avoid mismatching...
|
||||
*/
|
||||
|
||||
/* configuration management: bind/unbind */
|
||||
int (*bind)(struct usb_configuration *);
|
||||
void (*unbind)(struct usb_configuration *);
|
||||
int (*setup)(struct usb_configuration *,
|
||||
const struct usb_ctrlrequest *);
|
||||
|
||||
/* fields in the config descriptor */
|
||||
u8 bConfigurationValue;
|
||||
u8 iConfiguration;
|
||||
u8 bmAttributes;
|
||||
u8 bMaxPower;
|
||||
|
||||
struct usb_composite_dev *cdev;
|
||||
|
||||
/* private: */
|
||||
/* internals */
|
||||
struct list_head list;
|
||||
struct list_head functions;
|
||||
u8 next_interface_id;
|
||||
unsigned highspeed:1;
|
||||
unsigned fullspeed:1;
|
||||
unsigned superspeed:1;
|
||||
struct usb_function *interface[MAX_CONFIG_INTERFACES];
|
||||
};
|
||||
|
||||
int usb_add_config(struct usb_composite_dev *,
|
||||
struct usb_configuration *);
|
||||
|
||||
/**
|
||||
* struct usb_composite_driver - groups configurations into a gadget
|
||||
* @name: For diagnostics, identifies the driver.
|
||||
* @dev: Template descriptor for the device, including default device
|
||||
* identifiers.
|
||||
* @strings: tables of strings, keyed by identifiers assigned during bind()
|
||||
* and language IDs provided in control requests
|
||||
* @max_speed: Highest speed the driver supports.
|
||||
* @bind: (REQUIRED) Used to allocate resources that are shared across the
|
||||
* whole device, such as string IDs, and add its configurations using
|
||||
* @usb_add_config(). This may fail by returning a negative errno
|
||||
* value; it should return zero on successful initialization.
|
||||
* @unbind: Reverses @bind(); called as a side effect of unregistering
|
||||
* this driver.
|
||||
* @disconnect: optional driver disconnect method
|
||||
* @suspend: Notifies when the host stops sending USB traffic,
|
||||
* after function notifications
|
||||
* @resume: Notifies configuration when the host restarts USB traffic,
|
||||
* before function notifications
|
||||
*
|
||||
* Devices default to reporting self powered operation. Devices which rely
|
||||
* on bus powered operation should report this in their @bind() method.
|
||||
*
|
||||
* Before returning from @bind, various fields in the template descriptor
|
||||
* may be overridden. These include the idVendor/idProduct/bcdDevice values
|
||||
* normally to bind the appropriate host side driver, and the three strings
|
||||
* (iManufacturer, iProduct, iSerialNumber) normally used to provide user
|
||||
* meaningful device identifiers. (The strings will not be defined unless
|
||||
* they are defined in @dev and @strings.) The correct ep0 maxpacket size
|
||||
* is also reported, as defined by the underlying controller driver.
|
||||
*/
|
||||
struct usb_composite_driver {
|
||||
const char *name;
|
||||
const struct usb_device_descriptor *dev;
|
||||
struct usb_gadget_strings **strings;
|
||||
enum usb_device_speed max_speed;
|
||||
|
||||
/* REVISIT: bind() functions can be marked __init, which
|
||||
* makes trouble for section mismatch analysis. See if
|
||||
* we can't restructure things to avoid mismatching...
|
||||
*/
|
||||
|
||||
int (*bind)(struct usb_composite_dev *);
|
||||
int (*unbind)(struct usb_composite_dev *);
|
||||
|
||||
void (*disconnect)(struct usb_composite_dev *);
|
||||
|
||||
/* global suspend hooks */
|
||||
void (*suspend)(struct usb_composite_dev *);
|
||||
void (*resume)(struct usb_composite_dev *);
|
||||
};
|
||||
|
||||
extern int usb_composite_register(struct usb_composite_driver *);
|
||||
extern void usb_composite_unregister(struct usb_composite_driver *);
|
||||
|
||||
#define OS_STRING_QW_SIGN_LEN 14
|
||||
#define OS_STRING_IDX 0xEE
|
||||
|
||||
/**
|
||||
* struct usb_composite_device - represents one composite usb gadget
|
||||
* @gadget: read-only, abstracts the gadget's usb peripheral controller
|
||||
* @req: used for control responses; buffer is pre-allocated
|
||||
* @bufsiz: size of buffer pre-allocated in @req
|
||||
* @os_desc_req: used for OS descriptors responses; buffer is pre-allocated
|
||||
* @config: the currently active configuration
|
||||
* @qw_sign: qwSignature part of the OS string
|
||||
* @b_vendor_code: bMS_VendorCode part of the OS string
|
||||
* @use_os_string: false by default, interested gadgets set it
|
||||
* @os_desc_config: the configuration to be used with OS descriptors
|
||||
*
|
||||
* One of these devices is allocated and initialized before the
|
||||
* associated device driver's bind() is called.
|
||||
*
|
||||
* OPEN ISSUE: it appears that some WUSB devices will need to be
|
||||
* built by combining a normal (wired) gadget with a wireless one.
|
||||
* This revision of the gadget framework should probably try to make
|
||||
* sure doing that won't hurt too much.
|
||||
*
|
||||
* One notion for how to handle Wireless USB devices involves:
|
||||
* (a) a second gadget here, discovery mechanism TBD, but likely
|
||||
* needing separate "register/unregister WUSB gadget" calls;
|
||||
* (b) updates to usb_gadget to include flags "is it wireless",
|
||||
* "is it wired", plus (presumably in a wrapper structure)
|
||||
* bandgroup and PHY info;
|
||||
* (c) presumably a wireless_ep wrapping a usb_ep, and reporting
|
||||
* wireless-specific parameters like maxburst and maxsequence;
|
||||
* (d) configurations that are specific to wireless links;
|
||||
* (e) function drivers that understand wireless configs and will
|
||||
* support wireless for (additional) function instances;
|
||||
* (f) a function to support association setup (like CBAF), not
|
||||
* necessarily requiring a wireless adapter;
|
||||
* (g) composite device setup that can create one or more wireless
|
||||
* configs, including appropriate association setup support;
|
||||
* (h) more, TBD.
|
||||
*/
|
||||
struct usb_composite_dev {
|
||||
struct usb_gadget *gadget;
|
||||
struct usb_request *req;
|
||||
unsigned bufsiz;
|
||||
|
||||
struct usb_configuration *config;
|
||||
|
||||
/* OS String is a custom (yet popular) extension to the USB standard. */
|
||||
u8 qw_sign[OS_STRING_QW_SIGN_LEN];
|
||||
u8 b_vendor_code;
|
||||
struct usb_configuration *os_desc_config;
|
||||
unsigned int use_os_string:1;
|
||||
|
||||
/* private: */
|
||||
/* internals */
|
||||
unsigned int suspended:1;
|
||||
struct usb_device_descriptor __aligned(CONFIG_SYS_CACHELINE_SIZE) desc;
|
||||
struct list_head configs;
|
||||
struct usb_composite_driver *driver;
|
||||
u8 next_string_id;
|
||||
|
||||
/* the gadget driver won't enable the data pullup
|
||||
* while the deactivation count is nonzero.
|
||||
*/
|
||||
unsigned deactivations;
|
||||
};
|
||||
|
||||
extern int usb_string_id(struct usb_composite_dev *c);
|
||||
extern int usb_string_ids_tab(struct usb_composite_dev *c,
|
||||
struct usb_string *str);
|
||||
extern int usb_string_ids_n(struct usb_composite_dev *c, unsigned n);
|
||||
|
||||
#endif /* __LINUX_USB_COMPOSITE_H */
|
||||
18
u-boot-2021.10/include/linux/usb/dwc3-omap.h
Normal file
18
u-boot-2021.10/include/linux/usb/dwc3-omap.h
Normal file
@ -0,0 +1,18 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0+ */
|
||||
/* include/linux/usb/dwc3-omap.h
|
||||
*
|
||||
* Copyright (c) 2014 Texas Instruments Incorporated - http://www.ti.com
|
||||
*
|
||||
* Designware SuperSpeed Glue
|
||||
*/
|
||||
|
||||
#ifndef __DWC3_OMAP_H_
|
||||
#define __DWC3_OMAP_H_
|
||||
|
||||
enum dwc3_omap_utmi_mode {
|
||||
DWC3_OMAP_UTMI_MODE_UNKNOWN = 0,
|
||||
DWC3_OMAP_UTMI_MODE_HW,
|
||||
DWC3_OMAP_UTMI_MODE_SW,
|
||||
};
|
||||
|
||||
#endif /* __DWC3_OMAP_H_ */
|
||||
223
u-boot-2021.10/include/linux/usb/dwc3.h
Normal file
223
u-boot-2021.10/include/linux/usb/dwc3.h
Normal file
@ -0,0 +1,223 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0+ */
|
||||
/* include/linux/usb/dwc3.h
|
||||
*
|
||||
* Copyright (c) 2012 Samsung Electronics Co. Ltd
|
||||
*
|
||||
* Designware SuperSpeed USB 3.0 DRD Controller global and OTG registers
|
||||
*/
|
||||
|
||||
#ifndef __DWC3_H_
|
||||
#define __DWC3_H_
|
||||
|
||||
/* Global constants */
|
||||
#define DWC3_ENDPOINTS_NUM 32
|
||||
|
||||
#define DWC3_EVENT_BUFFERS_SIZE PAGE_SIZE
|
||||
#define DWC3_EVENT_TYPE_MASK 0xfe
|
||||
|
||||
#define DWC3_EVENT_TYPE_DEV 0
|
||||
#define DWC3_EVENT_TYPE_CARKIT 3
|
||||
#define DWC3_EVENT_TYPE_I2C 4
|
||||
|
||||
#define DWC3_DEVICE_EVENT_DISCONNECT 0
|
||||
#define DWC3_DEVICE_EVENT_RESET 1
|
||||
#define DWC3_DEVICE_EVENT_CONNECT_DONE 2
|
||||
#define DWC3_DEVICE_EVENT_LINK_STATUS_CHANGE 3
|
||||
#define DWC3_DEVICE_EVENT_WAKEUP 4
|
||||
#define DWC3_DEVICE_EVENT_EOPF 6
|
||||
#define DWC3_DEVICE_EVENT_SOF 7
|
||||
#define DWC3_DEVICE_EVENT_ERRATIC_ERROR 9
|
||||
#define DWC3_DEVICE_EVENT_CMD_CMPL 10
|
||||
#define DWC3_DEVICE_EVENT_OVERFLOW 11
|
||||
|
||||
#define DWC3_GEVNTCOUNT_MASK 0xfffc
|
||||
#define DWC3_GSNPSID_MASK 0xffff0000
|
||||
#define DWC3_GSNPSID_SHIFT 16
|
||||
#define DWC3_GSNPSREV_MASK 0xffff
|
||||
|
||||
#define DWC3_REVISION_MASK 0xffff
|
||||
|
||||
#define DWC3_REG_OFFSET 0xC100
|
||||
|
||||
struct g_event_buffer {
|
||||
u32 g_evntadrlo;
|
||||
u32 g_evntadrhi;
|
||||
u32 g_evntsiz;
|
||||
u32 g_evntcount;
|
||||
};
|
||||
|
||||
struct d_physical_endpoint {
|
||||
u32 d_depcmdpar2;
|
||||
u32 d_depcmdpar1;
|
||||
u32 d_depcmdpar0;
|
||||
u32 d_depcmd;
|
||||
};
|
||||
|
||||
struct dwc3 { /* offset: 0xC100 */
|
||||
u32 g_sbuscfg0;
|
||||
u32 g_sbuscfg1;
|
||||
u32 g_txthrcfg;
|
||||
u32 g_rxthrcfg;
|
||||
u32 g_ctl;
|
||||
|
||||
u32 reserved1;
|
||||
|
||||
u32 g_sts;
|
||||
|
||||
u32 reserved2;
|
||||
|
||||
u32 g_snpsid;
|
||||
u32 g_gpio;
|
||||
u32 g_uid;
|
||||
u32 g_uctl;
|
||||
u64 g_buserraddr;
|
||||
u64 g_prtbimap;
|
||||
|
||||
u32 g_hwparams0;
|
||||
u32 g_hwparams1;
|
||||
u32 g_hwparams2;
|
||||
u32 g_hwparams3;
|
||||
u32 g_hwparams4;
|
||||
u32 g_hwparams5;
|
||||
u32 g_hwparams6;
|
||||
u32 g_hwparams7;
|
||||
|
||||
u32 g_dbgfifospace;
|
||||
u32 g_dbgltssm;
|
||||
u32 g_dbglnmcc;
|
||||
u32 g_dbgbmu;
|
||||
u32 g_dbglspmux;
|
||||
u32 g_dbglsp;
|
||||
u32 g_dbgepinfo0;
|
||||
u32 g_dbgepinfo1;
|
||||
|
||||
u64 g_prtbimap_hs;
|
||||
u64 g_prtbimap_fs;
|
||||
|
||||
u32 reserved3[28];
|
||||
|
||||
u32 g_usb2phycfg[16];
|
||||
u32 g_usb2i2cctl[16];
|
||||
u32 g_usb2phyacc[16];
|
||||
u32 g_usb3pipectl[16];
|
||||
|
||||
u32 g_txfifosiz[32];
|
||||
u32 g_rxfifosiz[32];
|
||||
|
||||
struct g_event_buffer g_evnt_buf[32];
|
||||
|
||||
u32 g_hwparams8;
|
||||
|
||||
u32 reserved4[11];
|
||||
|
||||
u32 g_fladj;
|
||||
|
||||
u32 reserved5[51];
|
||||
|
||||
u32 d_cfg;
|
||||
u32 d_ctl;
|
||||
u32 d_evten;
|
||||
u32 d_sts;
|
||||
u32 d_gcmdpar;
|
||||
u32 d_gcmd;
|
||||
|
||||
u32 reserved6[2];
|
||||
|
||||
u32 d_alepena;
|
||||
|
||||
u32 reserved7[55];
|
||||
|
||||
struct d_physical_endpoint d_phy_ep_cmd[32];
|
||||
|
||||
u32 reserved8[128];
|
||||
|
||||
u32 o_cfg;
|
||||
u32 o_ctl;
|
||||
u32 o_evt;
|
||||
u32 o_evten;
|
||||
u32 o_sts;
|
||||
|
||||
u32 reserved9[3];
|
||||
|
||||
u32 adp_cfg;
|
||||
u32 adp_ctl;
|
||||
u32 adp_evt;
|
||||
u32 adp_evten;
|
||||
|
||||
u32 bc_cfg;
|
||||
|
||||
u32 reserved10;
|
||||
|
||||
u32 bc_evt;
|
||||
u32 bc_evten;
|
||||
};
|
||||
|
||||
/* Global Configuration Register */
|
||||
#define DWC3_GCTL_PWRDNSCALE(n) ((n) << 19)
|
||||
#define DWC3_GCTL_U2RSTECN (1 << 16)
|
||||
#define DWC3_GCTL_RAMCLKSEL(x) \
|
||||
(((x) & DWC3_GCTL_CLK_MASK) << 6)
|
||||
#define DWC3_GCTL_CLK_BUS (0)
|
||||
#define DWC3_GCTL_CLK_PIPE (1)
|
||||
#define DWC3_GCTL_CLK_PIPEHALF (2)
|
||||
#define DWC3_GCTL_CLK_MASK (3)
|
||||
#define DWC3_GCTL_PRTCAP(n) (((n) & (3 << 12)) >> 12)
|
||||
#define DWC3_GCTL_PRTCAPDIR(n) ((n) << 12)
|
||||
#define DWC3_GCTL_PRTCAP_HOST 1
|
||||
#define DWC3_GCTL_PRTCAP_DEVICE 2
|
||||
#define DWC3_GCTL_PRTCAP_OTG 3
|
||||
#define DWC3_GCTL_CORESOFTRESET (1 << 11)
|
||||
#define DWC3_GCTL_SCALEDOWN(n) ((n) << 4)
|
||||
#define DWC3_GCTL_SCALEDOWN_MASK DWC3_GCTL_SCALEDOWN(3)
|
||||
#define DWC3_GCTL_DISSCRAMBLE (1 << 3)
|
||||
#define DWC3_GCTL_DSBLCLKGTNG (1 << 0)
|
||||
|
||||
/* Global HWPARAMS1 Register */
|
||||
#define DWC3_GHWPARAMS1_EN_PWROPT(n) (((n) & (3 << 24)) >> 24)
|
||||
#define DWC3_GHWPARAMS1_EN_PWROPT_NO 0
|
||||
#define DWC3_GHWPARAMS1_EN_PWROPT_CLK 1
|
||||
|
||||
/* Global USB2 PHY Configuration Register */
|
||||
#define DWC3_GUSB2PHYCFG_PHYSOFTRST (1 << 31)
|
||||
#define DWC3_GUSB2PHYCFG_U2_FREECLK_EXISTS (1 << 30)
|
||||
#define DWC3_GUSB2PHYCFG_ENBLSLPM (1 << 8)
|
||||
#define DWC3_GUSB2PHYCFG_SUSPHY (1 << 6)
|
||||
#define DWC3_GUSB2PHYCFG_PHYIF (1 << 3)
|
||||
|
||||
/* Global USB2 PHY Configuration Mask */
|
||||
#define DWC3_GUSB2PHYCFG_USBTRDTIM_MASK (0xf << 10)
|
||||
|
||||
/* Global USB2 PHY Configuration Offset */
|
||||
#define DWC3_GUSB2PHYCFG_USBTRDTIM_OFFSET 10
|
||||
|
||||
#define DWC3_GUSB2PHYCFG_USBTRDTIM_16BIT (0x5 << \
|
||||
DWC3_GUSB2PHYCFG_USBTRDTIM_OFFSET)
|
||||
#define DWC3_GUSB2PHYCFG_USBTRDTIM_8BIT (0x9 << \
|
||||
DWC3_GUSB2PHYCFG_USBTRDTIM_OFFSET)
|
||||
|
||||
/* Global USB3 PIPE Control Register */
|
||||
#define DWC3_GUSB3PIPECTL_PHYSOFTRST (1 << 31)
|
||||
#define DWC3_GUSB3PIPECTL_DISRXDETP3 (1 << 28)
|
||||
#define DWC3_GUSB3PIPECTL_SUSPHY (1 << 17)
|
||||
|
||||
/* Global TX Fifo Size Register */
|
||||
#define DWC3_GTXFIFOSIZ_TXFDEF(n) ((n) & 0xffff)
|
||||
#define DWC3_GTXFIFOSIZ_TXFSTADDR(n) ((n) & 0xffff0000)
|
||||
|
||||
/* Device Control Register */
|
||||
#define DWC3_DCTL_RUN_STOP (1 << 31)
|
||||
#define DWC3_DCTL_CSFTRST (1 << 30)
|
||||
#define DWC3_DCTL_LSFTRST (1 << 29)
|
||||
|
||||
/* Global Frame Length Adjustment Register */
|
||||
#define GFLADJ_30MHZ_REG_SEL (1 << 7)
|
||||
#define GFLADJ_30MHZ(n) ((n) & 0x3f)
|
||||
#define GFLADJ_30MHZ_DEFAULT 0x20
|
||||
|
||||
#ifdef CONFIG_USB_XHCI_DWC3
|
||||
void dwc3_set_mode(struct dwc3 *dwc3_reg, u32 mode);
|
||||
void dwc3_core_soft_reset(struct dwc3 *dwc3_reg);
|
||||
int dwc3_core_init(struct dwc3 *dwc3_reg);
|
||||
void dwc3_set_fladj(struct dwc3 *dwc3_reg, u32 val);
|
||||
#endif
|
||||
#endif /* __DWC3_H_ */
|
||||
990
u-boot-2021.10/include/linux/usb/gadget.h
Normal file
990
u-boot-2021.10/include/linux/usb/gadget.h
Normal file
@ -0,0 +1,990 @@
|
||||
/*
|
||||
* <linux/usb/gadget.h>
|
||||
*
|
||||
* We call the USB code inside a Linux-based peripheral device a "gadget"
|
||||
* driver, except for the hardware-specific bus glue. One USB host can
|
||||
* master many USB gadgets, but the gadgets are only slaved to one host.
|
||||
*
|
||||
*
|
||||
* (C) Copyright 2002-2004 by David Brownell
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* This software is licensed under the GNU GPL version 2.
|
||||
*
|
||||
* Ported to U-Boot by: Thomas Smits <ts.smits@gmail.com> and
|
||||
* Remy Bohmer <linux@bohmer.net>
|
||||
*/
|
||||
|
||||
#ifndef __LINUX_USB_GADGET_H
|
||||
#define __LINUX_USB_GADGET_H
|
||||
|
||||
#include <errno.h>
|
||||
#include <usb.h>
|
||||
#include <linux/compat.h>
|
||||
#include <linux/list.h>
|
||||
|
||||
struct usb_ep;
|
||||
|
||||
/**
|
||||
* struct usb_request - describes one i/o request
|
||||
* @buf: Buffer used for data. Always provide this; some controllers
|
||||
* only use PIO, or don't use DMA for some endpoints.
|
||||
* @dma: DMA address corresponding to 'buf'. If you don't set this
|
||||
* field, and the usb controller needs one, it is responsible
|
||||
* for mapping and unmapping the buffer.
|
||||
* @stream_id: The stream id, when USB3.0 bulk streams are being used
|
||||
* @length: Length of that data
|
||||
* @no_interrupt: If true, hints that no completion irq is needed.
|
||||
* Helpful sometimes with deep request queues that are handled
|
||||
* directly by DMA controllers.
|
||||
* @zero: If true, when writing data, makes the last packet be "short"
|
||||
* by adding a zero length packet as needed;
|
||||
* @short_not_ok: When reading data, makes short packets be
|
||||
* treated as errors (queue stops advancing till cleanup).
|
||||
* @complete: Function called when request completes, so this request and
|
||||
* its buffer may be re-used.
|
||||
* Reads terminate with a short packet, or when the buffer fills,
|
||||
* whichever comes first. When writes terminate, some data bytes
|
||||
* will usually still be in flight (often in a hardware fifo).
|
||||
* Errors (for reads or writes) stop the queue from advancing
|
||||
* until the completion function returns, so that any transfers
|
||||
* invalidated by the error may first be dequeued.
|
||||
* @context: For use by the completion callback
|
||||
* @list: For use by the gadget driver.
|
||||
* @status: Reports completion code, zero or a negative errno.
|
||||
* Normally, faults block the transfer queue from advancing until
|
||||
* the completion callback returns.
|
||||
* Code "-ESHUTDOWN" indicates completion caused by device disconnect,
|
||||
* or when the driver disabled the endpoint.
|
||||
* @actual: Reports bytes transferred to/from the buffer. For reads (OUT
|
||||
* transfers) this may be less than the requested length. If the
|
||||
* short_not_ok flag is set, short reads are treated as errors
|
||||
* even when status otherwise indicates successful completion.
|
||||
* Note that for writes (IN transfers) some data bytes may still
|
||||
* reside in a device-side FIFO when the request is reported as
|
||||
* complete.
|
||||
*
|
||||
* These are allocated/freed through the endpoint they're used with. The
|
||||
* hardware's driver can add extra per-request data to the memory it returns,
|
||||
* which often avoids separate memory allocations (potential failures),
|
||||
* later when the request is queued.
|
||||
*
|
||||
* Request flags affect request handling, such as whether a zero length
|
||||
* packet is written (the "zero" flag), whether a short read should be
|
||||
* treated as an error (blocking request queue advance, the "short_not_ok"
|
||||
* flag), or hinting that an interrupt is not required (the "no_interrupt"
|
||||
* flag, for use with deep request queues).
|
||||
*
|
||||
* Bulk endpoints can use any size buffers, and can also be used for interrupt
|
||||
* transfers. interrupt-only endpoints can be much less functional.
|
||||
*
|
||||
* NOTE: this is analagous to 'struct urb' on the host side, except that
|
||||
* it's thinner and promotes more pre-allocation.
|
||||
*/
|
||||
|
||||
struct usb_request {
|
||||
void *buf;
|
||||
unsigned length;
|
||||
dma_addr_t dma;
|
||||
|
||||
unsigned stream_id:16;
|
||||
unsigned no_interrupt:1;
|
||||
unsigned zero:1;
|
||||
unsigned short_not_ok:1;
|
||||
|
||||
void (*complete)(struct usb_ep *ep,
|
||||
struct usb_request *req);
|
||||
void *context;
|
||||
struct list_head list;
|
||||
|
||||
int status;
|
||||
unsigned actual;
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* endpoint-specific parts of the api to the usb controller hardware.
|
||||
* unlike the urb model, (de)multiplexing layers are not required.
|
||||
* (so this api could slash overhead if used on the host side...)
|
||||
*
|
||||
* note that device side usb controllers commonly differ in how many
|
||||
* endpoints they support, as well as their capabilities.
|
||||
*/
|
||||
struct usb_ep_ops {
|
||||
int (*enable) (struct usb_ep *ep,
|
||||
const struct usb_endpoint_descriptor *desc);
|
||||
int (*disable) (struct usb_ep *ep);
|
||||
|
||||
struct usb_request *(*alloc_request) (struct usb_ep *ep,
|
||||
gfp_t gfp_flags);
|
||||
void (*free_request) (struct usb_ep *ep, struct usb_request *req);
|
||||
|
||||
int (*queue) (struct usb_ep *ep, struct usb_request *req,
|
||||
gfp_t gfp_flags);
|
||||
int (*dequeue) (struct usb_ep *ep, struct usb_request *req);
|
||||
|
||||
int (*set_halt) (struct usb_ep *ep, int value);
|
||||
int (*set_wedge)(struct usb_ep *ep);
|
||||
int (*fifo_status) (struct usb_ep *ep);
|
||||
void (*fifo_flush) (struct usb_ep *ep);
|
||||
};
|
||||
|
||||
/**
|
||||
* struct usb_ep_caps - endpoint capabilities description
|
||||
* @type_control:Endpoint supports control type (reserved for ep0).
|
||||
* @type_iso:Endpoint supports isochronous transfers.
|
||||
* @type_bulk:Endpoint supports bulk transfers.
|
||||
* @type_int:Endpoint supports interrupt transfers.
|
||||
* @dir_in:Endpoint supports IN direction.
|
||||
* @dir_out:Endpoint supports OUT direction.
|
||||
*/
|
||||
struct usb_ep_caps {
|
||||
unsigned type_control:1;
|
||||
unsigned type_iso:1;
|
||||
unsigned type_bulk:1;
|
||||
unsigned type_int:1;
|
||||
unsigned dir_in:1;
|
||||
unsigned dir_out:1;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct usb_ep - device side representation of USB endpoint
|
||||
* @name:identifier for the endpoint, such as "ep-a" or "ep9in-bulk"
|
||||
* @ops: Function pointers used to access hardware-specific operations.
|
||||
* @ep_list:the gadget's ep_list holds all of its endpoints
|
||||
* @caps:The structure describing types and directions supported by endoint.
|
||||
* @maxpacket:The maximum packet size used on this endpoint. The initial
|
||||
* value can sometimes be reduced (hardware allowing), according to
|
||||
* the endpoint descriptor used to configure the endpoint.
|
||||
* @maxpacket_limit:The maximum packet size value which can be handled by this
|
||||
* endpoint. It's set once by UDC driver when endpoint is initialized, and
|
||||
* should not be changed. Should not be confused with maxpacket.
|
||||
* @max_streams: The maximum number of streams supported
|
||||
* by this EP (0 - 16, actual number is 2^n)
|
||||
* @maxburst: the maximum number of bursts supported by this EP (for usb3)
|
||||
* @driver_data:for use by the gadget driver. all other fields are
|
||||
* read-only to gadget drivers.
|
||||
* @desc: endpoint descriptor. This pointer is set before the endpoint is
|
||||
* enabled and remains valid until the endpoint is disabled.
|
||||
* @comp_desc: In case of SuperSpeed support, this is the endpoint companion
|
||||
* descriptor that is used to configure the endpoint
|
||||
*
|
||||
* the bus controller driver lists all the general purpose endpoints in
|
||||
* gadget->ep_list. the control endpoint (gadget->ep0) is not in that list,
|
||||
* and is accessed only in response to a driver setup() callback.
|
||||
*/
|
||||
struct usb_ep {
|
||||
void *driver_data;
|
||||
const char *name;
|
||||
const struct usb_ep_ops *ops;
|
||||
struct list_head ep_list;
|
||||
struct usb_ep_caps caps;
|
||||
unsigned maxpacket:16;
|
||||
unsigned maxpacket_limit:16;
|
||||
unsigned max_streams:16;
|
||||
unsigned maxburst:5;
|
||||
const struct usb_endpoint_descriptor *desc;
|
||||
const struct usb_ss_ep_comp_descriptor *comp_desc;
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* usb_ep_set_maxpacket_limit - set maximum packet size limit for endpoint
|
||||
* @ep:the endpoint being configured
|
||||
* @maxpacket_limit:value of maximum packet size limit
|
||||
*
|
||||
* This function shoud be used only in UDC drivers to initialize endpoint
|
||||
* (usually in probe function).
|
||||
*/
|
||||
static inline void usb_ep_set_maxpacket_limit(struct usb_ep *ep,
|
||||
unsigned maxpacket_limit)
|
||||
{
|
||||
ep->maxpacket_limit = maxpacket_limit;
|
||||
ep->maxpacket = maxpacket_limit;
|
||||
}
|
||||
|
||||
/**
|
||||
* usb_ep_enable - configure endpoint, making it usable
|
||||
* @ep:the endpoint being configured. may not be the endpoint named "ep0".
|
||||
* drivers discover endpoints through the ep_list of a usb_gadget.
|
||||
* @desc:descriptor for desired behavior. caller guarantees this pointer
|
||||
* remains valid until the endpoint is disabled; the data byte order
|
||||
* is little-endian (usb-standard).
|
||||
*
|
||||
* when configurations are set, or when interface settings change, the driver
|
||||
* will enable or disable the relevant endpoints. while it is enabled, an
|
||||
* endpoint may be used for i/o until the driver receives a disconnect() from
|
||||
* the host or until the endpoint is disabled.
|
||||
*
|
||||
* the ep0 implementation (which calls this routine) must ensure that the
|
||||
* hardware capabilities of each endpoint match the descriptor provided
|
||||
* for it. for example, an endpoint named "ep2in-bulk" would be usable
|
||||
* for interrupt transfers as well as bulk, but it likely couldn't be used
|
||||
* for iso transfers or for endpoint 14. some endpoints are fully
|
||||
* configurable, with more generic names like "ep-a". (remember that for
|
||||
* USB, "in" means "towards the USB master".)
|
||||
*
|
||||
* returns zero, or a negative error code.
|
||||
*/
|
||||
static inline int usb_ep_enable(struct usb_ep *ep,
|
||||
const struct usb_endpoint_descriptor *desc)
|
||||
{
|
||||
return ep->ops->enable(ep, desc);
|
||||
}
|
||||
|
||||
/**
|
||||
* usb_ep_disable - endpoint is no longer usable
|
||||
* @ep:the endpoint being unconfigured. may not be the endpoint named "ep0".
|
||||
*
|
||||
* no other task may be using this endpoint when this is called.
|
||||
* any pending and uncompleted requests will complete with status
|
||||
* indicating disconnect (-ESHUTDOWN) before this call returns.
|
||||
* gadget drivers must call usb_ep_enable() again before queueing
|
||||
* requests to the endpoint.
|
||||
*
|
||||
* returns zero, or a negative error code.
|
||||
*/
|
||||
static inline int usb_ep_disable(struct usb_ep *ep)
|
||||
{
|
||||
return ep->ops->disable(ep);
|
||||
}
|
||||
|
||||
/**
|
||||
* usb_ep_alloc_request - allocate a request object to use with this endpoint
|
||||
* @ep:the endpoint to be used with with the request
|
||||
* @gfp_flags:GFP_* flags to use
|
||||
*
|
||||
* Request objects must be allocated with this call, since they normally
|
||||
* need controller-specific setup and may even need endpoint-specific
|
||||
* resources such as allocation of DMA descriptors.
|
||||
* Requests may be submitted with usb_ep_queue(), and receive a single
|
||||
* completion callback. Free requests with usb_ep_free_request(), when
|
||||
* they are no longer needed.
|
||||
*
|
||||
* Returns the request, or null if one could not be allocated.
|
||||
*/
|
||||
static inline struct usb_request *usb_ep_alloc_request(struct usb_ep *ep,
|
||||
gfp_t gfp_flags)
|
||||
{
|
||||
return ep->ops->alloc_request(ep, gfp_flags);
|
||||
}
|
||||
|
||||
/**
|
||||
* usb_ep_free_request - frees a request object
|
||||
* @ep:the endpoint associated with the request
|
||||
* @req:the request being freed
|
||||
*
|
||||
* Reverses the effect of usb_ep_alloc_request().
|
||||
* Caller guarantees the request is not queued, and that it will
|
||||
* no longer be requeued (or otherwise used).
|
||||
*/
|
||||
static inline void usb_ep_free_request(struct usb_ep *ep,
|
||||
struct usb_request *req)
|
||||
{
|
||||
ep->ops->free_request(ep, req);
|
||||
}
|
||||
|
||||
/**
|
||||
* usb_ep_queue - queues (submits) an I/O request to an endpoint.
|
||||
* @ep:the endpoint associated with the request
|
||||
* @req:the request being submitted
|
||||
* @gfp_flags: GFP_* flags to use in case the lower level driver couldn't
|
||||
* pre-allocate all necessary memory with the request.
|
||||
*
|
||||
* This tells the device controller to perform the specified request through
|
||||
* that endpoint (reading or writing a buffer). When the request completes,
|
||||
* including being canceled by usb_ep_dequeue(), the request's completion
|
||||
* routine is called to return the request to the driver. Any endpoint
|
||||
* (except control endpoints like ep0) may have more than one transfer
|
||||
* request queued; they complete in FIFO order. Once a gadget driver
|
||||
* submits a request, that request may not be examined or modified until it
|
||||
* is given back to that driver through the completion callback.
|
||||
*
|
||||
* Each request is turned into one or more packets. The controller driver
|
||||
* never merges adjacent requests into the same packet. OUT transfers
|
||||
* will sometimes use data that's already buffered in the hardware.
|
||||
* Drivers can rely on the fact that the first byte of the request's buffer
|
||||
* always corresponds to the first byte of some USB packet, for both
|
||||
* IN and OUT transfers.
|
||||
*
|
||||
* Bulk endpoints can queue any amount of data; the transfer is packetized
|
||||
* automatically. The last packet will be short if the request doesn't fill it
|
||||
* out completely. Zero length packets (ZLPs) should be avoided in portable
|
||||
* protocols since not all usb hardware can successfully handle zero length
|
||||
* packets. (ZLPs may be explicitly written, and may be implicitly written if
|
||||
* the request 'zero' flag is set.) Bulk endpoints may also be used
|
||||
* for interrupt transfers; but the reverse is not true, and some endpoints
|
||||
* won't support every interrupt transfer. (Such as 768 byte packets.)
|
||||
*
|
||||
* Interrupt-only endpoints are less functional than bulk endpoints, for
|
||||
* example by not supporting queueing or not handling buffers that are
|
||||
* larger than the endpoint's maxpacket size. They may also treat data
|
||||
* toggle differently.
|
||||
*
|
||||
* Control endpoints ... after getting a setup() callback, the driver queues
|
||||
* one response (even if it would be zero length). That enables the
|
||||
* status ack, after transfering data as specified in the response. Setup
|
||||
* functions may return negative error codes to generate protocol stalls.
|
||||
* (Note that some USB device controllers disallow protocol stall responses
|
||||
* in some cases.) When control responses are deferred (the response is
|
||||
* written after the setup callback returns), then usb_ep_set_halt() may be
|
||||
* used on ep0 to trigger protocol stalls.
|
||||
*
|
||||
* For periodic endpoints, like interrupt or isochronous ones, the usb host
|
||||
* arranges to poll once per interval, and the gadget driver usually will
|
||||
* have queued some data to transfer at that time.
|
||||
*
|
||||
* Returns zero, or a negative error code. Endpoints that are not enabled
|
||||
* report errors; errors will also be
|
||||
* reported when the usb peripheral is disconnected.
|
||||
*/
|
||||
static inline int usb_ep_queue(struct usb_ep *ep,
|
||||
struct usb_request *req, gfp_t gfp_flags)
|
||||
{
|
||||
return ep->ops->queue(ep, req, gfp_flags);
|
||||
}
|
||||
|
||||
/**
|
||||
* usb_ep_dequeue - dequeues (cancels, unlinks) an I/O request from an endpoint
|
||||
* @ep:the endpoint associated with the request
|
||||
* @req:the request being canceled
|
||||
*
|
||||
* if the request is still active on the endpoint, it is dequeued and its
|
||||
* completion routine is called (with status -ECONNRESET); else a negative
|
||||
* error code is returned.
|
||||
*
|
||||
* note that some hardware can't clear out write fifos (to unlink the request
|
||||
* at the head of the queue) except as part of disconnecting from usb. such
|
||||
* restrictions prevent drivers from supporting configuration changes,
|
||||
* even to configuration zero (a "chapter 9" requirement).
|
||||
*/
|
||||
static inline int usb_ep_dequeue(struct usb_ep *ep, struct usb_request *req)
|
||||
{
|
||||
return ep->ops->dequeue(ep, req);
|
||||
}
|
||||
|
||||
/**
|
||||
* usb_ep_set_halt - sets the endpoint halt feature.
|
||||
* @ep: the non-isochronous endpoint being stalled
|
||||
*
|
||||
* Use this to stall an endpoint, perhaps as an error report.
|
||||
* Except for control endpoints,
|
||||
* the endpoint stays halted (will not stream any data) until the host
|
||||
* clears this feature; drivers may need to empty the endpoint's request
|
||||
* queue first, to make sure no inappropriate transfers happen.
|
||||
*
|
||||
* Note that while an endpoint CLEAR_FEATURE will be invisible to the
|
||||
* gadget driver, a SET_INTERFACE will not be. To reset endpoints for the
|
||||
* current altsetting, see usb_ep_clear_halt(). When switching altsettings,
|
||||
* it's simplest to use usb_ep_enable() or usb_ep_disable() for the endpoints.
|
||||
*
|
||||
* Returns zero, or a negative error code. On success, this call sets
|
||||
* underlying hardware state that blocks data transfers.
|
||||
* Attempts to halt IN endpoints will fail (returning -EAGAIN) if any
|
||||
* transfer requests are still queued, or if the controller hardware
|
||||
* (usually a FIFO) still holds bytes that the host hasn't collected.
|
||||
*/
|
||||
static inline int usb_ep_set_halt(struct usb_ep *ep)
|
||||
{
|
||||
return ep->ops->set_halt(ep, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* usb_ep_clear_halt - clears endpoint halt, and resets toggle
|
||||
* @ep:the bulk or interrupt endpoint being reset
|
||||
*
|
||||
* Use this when responding to the standard usb "set interface" request,
|
||||
* for endpoints that aren't reconfigured, after clearing any other state
|
||||
* in the endpoint's i/o queue.
|
||||
*
|
||||
* Returns zero, or a negative error code. On success, this call clears
|
||||
* the underlying hardware state reflecting endpoint halt and data toggle.
|
||||
* Note that some hardware can't support this request (like pxa2xx_udc),
|
||||
* and accordingly can't correctly implement interface altsettings.
|
||||
*/
|
||||
static inline int usb_ep_clear_halt(struct usb_ep *ep)
|
||||
{
|
||||
return ep->ops->set_halt(ep, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* usb_ep_fifo_status - returns number of bytes in fifo, or error
|
||||
* @ep: the endpoint whose fifo status is being checked.
|
||||
*
|
||||
* FIFO endpoints may have "unclaimed data" in them in certain cases,
|
||||
* such as after aborted transfers. Hosts may not have collected all
|
||||
* the IN data written by the gadget driver (and reported by a request
|
||||
* completion). The gadget driver may not have collected all the data
|
||||
* written OUT to it by the host. Drivers that need precise handling for
|
||||
* fault reporting or recovery may need to use this call.
|
||||
*
|
||||
* This returns the number of such bytes in the fifo, or a negative
|
||||
* errno if the endpoint doesn't use a FIFO or doesn't support such
|
||||
* precise handling.
|
||||
*/
|
||||
static inline int usb_ep_fifo_status(struct usb_ep *ep)
|
||||
{
|
||||
if (ep->ops->fifo_status)
|
||||
return ep->ops->fifo_status(ep);
|
||||
else
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
/**
|
||||
* usb_ep_fifo_flush - flushes contents of a fifo
|
||||
* @ep: the endpoint whose fifo is being flushed.
|
||||
*
|
||||
* This call may be used to flush the "unclaimed data" that may exist in
|
||||
* an endpoint fifo after abnormal transaction terminations. The call
|
||||
* must never be used except when endpoint is not being used for any
|
||||
* protocol translation.
|
||||
*/
|
||||
static inline void usb_ep_fifo_flush(struct usb_ep *ep)
|
||||
{
|
||||
if (ep->ops->fifo_flush)
|
||||
ep->ops->fifo_flush(ep);
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
struct usb_dcd_config_params {
|
||||
__u8 bU1devExitLat; /* U1 Device exit Latency */
|
||||
__le16 bU2DevExitLat; /* U2 Device exit Latency */
|
||||
};
|
||||
|
||||
struct usb_gadget;
|
||||
struct usb_gadget_driver;
|
||||
|
||||
/* the rest of the api to the controller hardware: device operations,
|
||||
* which don't involve endpoints (or i/o).
|
||||
*/
|
||||
struct usb_gadget_ops {
|
||||
int (*get_frame)(struct usb_gadget *);
|
||||
int (*wakeup)(struct usb_gadget *);
|
||||
int (*set_selfpowered) (struct usb_gadget *, int is_selfpowered);
|
||||
int (*vbus_session) (struct usb_gadget *, int is_active);
|
||||
int (*vbus_draw) (struct usb_gadget *, unsigned mA);
|
||||
int (*pullup) (struct usb_gadget *, int is_on);
|
||||
int (*ioctl)(struct usb_gadget *,
|
||||
unsigned code, unsigned long param);
|
||||
void (*get_config_params)(struct usb_dcd_config_params *);
|
||||
int (*udc_start)(struct usb_gadget *,
|
||||
struct usb_gadget_driver *);
|
||||
int (*udc_stop)(struct usb_gadget *);
|
||||
struct usb_ep *(*match_ep)(struct usb_gadget *,
|
||||
struct usb_endpoint_descriptor *,
|
||||
struct usb_ss_ep_comp_descriptor *);
|
||||
int (*ep_conf)(struct usb_gadget *,
|
||||
struct usb_ep *,
|
||||
struct usb_endpoint_descriptor *);
|
||||
void (*udc_set_speed)(struct usb_gadget *gadget,
|
||||
enum usb_device_speed);
|
||||
};
|
||||
|
||||
/**
|
||||
* struct usb_gadget - represents a usb slave device
|
||||
* @ops: Function pointers used to access hardware-specific operations.
|
||||
* @ep0: Endpoint zero, used when reading or writing responses to
|
||||
* driver setup() requests
|
||||
* @ep_list: List of other endpoints supported by the device.
|
||||
* @speed: Speed of current connection to USB host.
|
||||
* @max_speed: Maximal speed the UDC can handle. UDC must support this
|
||||
* and all slower speeds.
|
||||
* @is_dualspeed: true if the controller supports both high and full speed
|
||||
* operation. If it does, the gadget driver must also support both.
|
||||
* @is_otg: true if the USB device port uses a Mini-AB jack, so that the
|
||||
* gadget driver must provide a USB OTG descriptor.
|
||||
* @is_a_peripheral: false unless is_otg, the "A" end of a USB cable
|
||||
* is in the Mini-AB jack, and HNP has been used to switch roles
|
||||
* so that the "A" device currently acts as A-Peripheral, not A-Host.
|
||||
* @a_hnp_support: OTG device feature flag, indicating that the A-Host
|
||||
* supports HNP at this port.
|
||||
* @a_alt_hnp_support: OTG device feature flag, indicating that the A-Host
|
||||
* only supports HNP on a different root port.
|
||||
* @b_hnp_enable: OTG device feature flag, indicating that the A-Host
|
||||
* enabled HNP support.
|
||||
* @name: Identifies the controller hardware type. Used in diagnostics
|
||||
* and sometimes configuration.
|
||||
* @dev: Driver model state for this abstract device.
|
||||
* @quirk_ep_out_aligned_size: epout requires buffer size to be aligned to
|
||||
* MaxPacketSize.
|
||||
*
|
||||
* Gadgets have a mostly-portable "gadget driver" implementing device
|
||||
* functions, handling all usb configurations and interfaces. Gadget
|
||||
* drivers talk to hardware-specific code indirectly, through ops vectors.
|
||||
* That insulates the gadget driver from hardware details, and packages
|
||||
* the hardware endpoints through generic i/o queues. The "usb_gadget"
|
||||
* and "usb_ep" interfaces provide that insulation from the hardware.
|
||||
*
|
||||
* Except for the driver data, all fields in this structure are
|
||||
* read-only to the gadget driver. That driver data is part of the
|
||||
* "driver model" infrastructure in 2.6 (and later) kernels, and for
|
||||
* earlier systems is grouped in a similar structure that's not known
|
||||
* to the rest of the kernel.
|
||||
*
|
||||
* Values of the three OTG device feature flags are updated before the
|
||||
* setup() call corresponding to USB_REQ_SET_CONFIGURATION, and before
|
||||
* driver suspend() calls. They are valid only when is_otg, and when the
|
||||
* device is acting as a B-Peripheral (so is_a_peripheral is false).
|
||||
*/
|
||||
struct usb_gadget {
|
||||
/* readonly to gadget driver */
|
||||
const struct usb_gadget_ops *ops;
|
||||
struct usb_ep *ep0;
|
||||
struct list_head ep_list; /* of usb_ep */
|
||||
enum usb_device_speed speed;
|
||||
enum usb_device_speed max_speed;
|
||||
enum usb_device_state state;
|
||||
unsigned is_dualspeed:1;
|
||||
unsigned is_otg:1;
|
||||
unsigned is_a_peripheral:1;
|
||||
unsigned b_hnp_enable:1;
|
||||
unsigned a_hnp_support:1;
|
||||
unsigned a_alt_hnp_support:1;
|
||||
const char *name;
|
||||
struct device dev;
|
||||
unsigned quirk_ep_out_aligned_size:1;
|
||||
};
|
||||
|
||||
static inline void set_gadget_data(struct usb_gadget *gadget, void *data)
|
||||
{
|
||||
gadget->dev.driver_data = data;
|
||||
}
|
||||
|
||||
static inline void *get_gadget_data(struct usb_gadget *gadget)
|
||||
{
|
||||
return gadget->dev.driver_data;
|
||||
}
|
||||
|
||||
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) \
|
||||
list_for_each_entry(tmp, &(gadget)->ep_list, ep_list)
|
||||
|
||||
|
||||
/**
|
||||
* gadget_is_dualspeed - return true iff the hardware handles high speed
|
||||
* @g: controller that might support both high and full speeds
|
||||
*/
|
||||
static inline int gadget_is_dualspeed(struct usb_gadget *g)
|
||||
{
|
||||
#ifdef CONFIG_USB_GADGET_DUALSPEED
|
||||
/* runtime test would check "g->is_dualspeed" ... that might be
|
||||
* useful to work around hardware bugs, but is mostly pointless
|
||||
*/
|
||||
return 1;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* gadget_is_otg - return true iff the hardware is OTG-ready
|
||||
* @g: controller that might have a Mini-AB connector
|
||||
*
|
||||
* This is a runtime test, since kernels with a USB-OTG stack sometimes
|
||||
* run on boards which only have a Mini-B (or Mini-A) connector.
|
||||
*/
|
||||
static inline int gadget_is_otg(struct usb_gadget *g)
|
||||
{
|
||||
#ifdef CONFIG_USB_OTG
|
||||
return g->is_otg;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* gadget_is_superspeed() - return true if the hardware handles superspeed
|
||||
* @g: controller that might support superspeed
|
||||
*/
|
||||
static inline int gadget_is_superspeed(struct usb_gadget *g)
|
||||
{
|
||||
return g->max_speed >= USB_SPEED_SUPER;
|
||||
}
|
||||
|
||||
/**
|
||||
* usb_gadget_frame_number - returns the current frame number
|
||||
* @gadget: controller that reports the frame number
|
||||
*
|
||||
* Returns the usb frame number, normally eleven bits from a SOF packet,
|
||||
* or negative errno if this device doesn't support this capability.
|
||||
*/
|
||||
static inline int usb_gadget_frame_number(struct usb_gadget *gadget)
|
||||
{
|
||||
return gadget->ops->get_frame(gadget);
|
||||
}
|
||||
|
||||
/**
|
||||
* usb_gadget_wakeup - tries to wake up the host connected to this gadget
|
||||
* @gadget: controller used to wake up the host
|
||||
*
|
||||
* Returns zero on success, else negative error code if the hardware
|
||||
* doesn't support such attempts, or its support has not been enabled
|
||||
* by the usb host. Drivers must return device descriptors that report
|
||||
* their ability to support this, or hosts won't enable it.
|
||||
*
|
||||
* This may also try to use SRP to wake the host and start enumeration,
|
||||
* even if OTG isn't otherwise in use. OTG devices may also start
|
||||
* remote wakeup even when hosts don't explicitly enable it.
|
||||
*/
|
||||
static inline int usb_gadget_wakeup(struct usb_gadget *gadget)
|
||||
{
|
||||
if (!gadget->ops->wakeup)
|
||||
return -EOPNOTSUPP;
|
||||
return gadget->ops->wakeup(gadget);
|
||||
}
|
||||
|
||||
/**
|
||||
* usb_gadget_set_selfpowered - sets the device selfpowered feature.
|
||||
* @gadget:the device being declared as self-powered
|
||||
*
|
||||
* this affects the device status reported by the hardware driver
|
||||
* to reflect that it now has a local power supply.
|
||||
*
|
||||
* returns zero on success, else negative errno.
|
||||
*/
|
||||
static inline int usb_gadget_set_selfpowered(struct usb_gadget *gadget)
|
||||
{
|
||||
if (!gadget->ops->set_selfpowered)
|
||||
return -EOPNOTSUPP;
|
||||
return gadget->ops->set_selfpowered(gadget, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* usb_gadget_clear_selfpowered - clear the device selfpowered feature.
|
||||
* @gadget:the device being declared as bus-powered
|
||||
*
|
||||
* this affects the device status reported by the hardware driver.
|
||||
* some hardware may not support bus-powered operation, in which
|
||||
* case this feature's value can never change.
|
||||
*
|
||||
* returns zero on success, else negative errno.
|
||||
*/
|
||||
static inline int usb_gadget_clear_selfpowered(struct usb_gadget *gadget)
|
||||
{
|
||||
if (!gadget->ops->set_selfpowered)
|
||||
return -EOPNOTSUPP;
|
||||
return gadget->ops->set_selfpowered(gadget, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* usb_gadget_vbus_connect - Notify controller that VBUS is powered
|
||||
* @gadget:The device which now has VBUS power.
|
||||
*
|
||||
* This call is used by a driver for an external transceiver (or GPIO)
|
||||
* that detects a VBUS power session starting. Common responses include
|
||||
* resuming the controller, activating the D+ (or D-) pullup to let the
|
||||
* host detect that a USB device is attached, and starting to draw power
|
||||
* (8mA or possibly more, especially after SET_CONFIGURATION).
|
||||
*
|
||||
* Returns zero on success, else negative errno.
|
||||
*/
|
||||
static inline int usb_gadget_vbus_connect(struct usb_gadget *gadget)
|
||||
{
|
||||
if (!gadget->ops->vbus_session)
|
||||
return -EOPNOTSUPP;
|
||||
return gadget->ops->vbus_session(gadget, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* usb_gadget_vbus_draw - constrain controller's VBUS power usage
|
||||
* @gadget:The device whose VBUS usage is being described
|
||||
* @mA:How much current to draw, in milliAmperes. This should be twice
|
||||
* the value listed in the configuration descriptor bMaxPower field.
|
||||
*
|
||||
* This call is used by gadget drivers during SET_CONFIGURATION calls,
|
||||
* reporting how much power the device may consume. For example, this
|
||||
* could affect how quickly batteries are recharged.
|
||||
*
|
||||
* Returns zero on success, else negative errno.
|
||||
*/
|
||||
static inline int usb_gadget_vbus_draw(struct usb_gadget *gadget, unsigned mA)
|
||||
{
|
||||
if (!gadget->ops->vbus_draw)
|
||||
return -EOPNOTSUPP;
|
||||
return gadget->ops->vbus_draw(gadget, mA);
|
||||
}
|
||||
|
||||
/**
|
||||
* usb_gadget_vbus_disconnect - notify controller about VBUS session end
|
||||
* @gadget:the device whose VBUS supply is being described
|
||||
*
|
||||
* This call is used by a driver for an external transceiver (or GPIO)
|
||||
* that detects a VBUS power session ending. Common responses include
|
||||
* reversing everything done in usb_gadget_vbus_connect().
|
||||
*
|
||||
* Returns zero on success, else negative errno.
|
||||
*/
|
||||
static inline int usb_gadget_vbus_disconnect(struct usb_gadget *gadget)
|
||||
{
|
||||
if (!gadget->ops->vbus_session)
|
||||
return -EOPNOTSUPP;
|
||||
return gadget->ops->vbus_session(gadget, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* usb_gadget_connect - software-controlled connect to USB host
|
||||
* @gadget:the peripheral being connected
|
||||
*
|
||||
* Enables the D+ (or potentially D-) pullup. The host will start
|
||||
* enumerating this gadget when the pullup is active and a VBUS session
|
||||
* is active (the link is powered). This pullup is always enabled unless
|
||||
* usb_gadget_disconnect() has been used to disable it.
|
||||
*
|
||||
* Returns zero on success, else negative errno.
|
||||
*/
|
||||
static inline int usb_gadget_connect(struct usb_gadget *gadget)
|
||||
{
|
||||
if (!gadget->ops->pullup)
|
||||
return -EOPNOTSUPP;
|
||||
return gadget->ops->pullup(gadget, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* usb_gadget_disconnect - software-controlled disconnect from USB host
|
||||
* @gadget:the peripheral being disconnected
|
||||
*
|
||||
* Disables the D+ (or potentially D-) pullup, which the host may see
|
||||
* as a disconnect (when a VBUS session is active). Not all systems
|
||||
* support software pullup controls.
|
||||
*
|
||||
* This routine may be used during the gadget driver bind() call to prevent
|
||||
* the peripheral from ever being visible to the USB host, unless later
|
||||
* usb_gadget_connect() is called. For example, user mode components may
|
||||
* need to be activated before the system can talk to hosts.
|
||||
*
|
||||
* Returns zero on success, else negative errno.
|
||||
*/
|
||||
static inline int usb_gadget_disconnect(struct usb_gadget *gadget)
|
||||
{
|
||||
if (!gadget->ops->pullup)
|
||||
return -EOPNOTSUPP;
|
||||
return gadget->ops->pullup(gadget, 0);
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* struct usb_gadget_driver - driver for usb 'slave' devices
|
||||
* @function: String describing the gadget's function
|
||||
* @speed: Highest speed the driver handles.
|
||||
* @bind: Invoked when the driver is bound to a gadget, usually
|
||||
* after registering the driver.
|
||||
* At that point, ep0 is fully initialized, and ep_list holds
|
||||
* the currently-available endpoints.
|
||||
* Called in a context that permits sleeping.
|
||||
* @setup: Invoked for ep0 control requests that aren't handled by
|
||||
* the hardware level driver. Most calls must be handled by
|
||||
* the gadget driver, including descriptor and configuration
|
||||
* management. The 16 bit members of the setup data are in
|
||||
* USB byte order. Called in_interrupt; this may not sleep. Driver
|
||||
* queues a response to ep0, or returns negative to stall.
|
||||
* @disconnect: Invoked after all transfers have been stopped,
|
||||
* when the host is disconnected. May be called in_interrupt; this
|
||||
* may not sleep. Some devices can't detect disconnect, so this might
|
||||
* not be called except as part of controller shutdown.
|
||||
* @unbind: Invoked when the driver is unbound from a gadget,
|
||||
* usually from rmmod (after a disconnect is reported).
|
||||
* Called in a context that permits sleeping.
|
||||
* @suspend: Invoked on USB suspend. May be called in_interrupt.
|
||||
* @resume: Invoked on USB resume. May be called in_interrupt.
|
||||
* @reset: Invoked on USB bus reset. It is mandatory for all gadget drivers
|
||||
* and should be called in_interrupt.
|
||||
*
|
||||
* Devices are disabled till a gadget driver successfully bind()s, which
|
||||
* means the driver will handle setup() requests needed to enumerate (and
|
||||
* meet "chapter 9" requirements) then do some useful work.
|
||||
*
|
||||
* If gadget->is_otg is true, the gadget driver must provide an OTG
|
||||
* descriptor during enumeration, or else fail the bind() call. In such
|
||||
* cases, no USB traffic may flow until both bind() returns without
|
||||
* having called usb_gadget_disconnect(), and the USB host stack has
|
||||
* initialized.
|
||||
*
|
||||
* Drivers use hardware-specific knowledge to configure the usb hardware.
|
||||
* endpoint addressing is only one of several hardware characteristics that
|
||||
* are in descriptors the ep0 implementation returns from setup() calls.
|
||||
*
|
||||
* Except for ep0 implementation, most driver code shouldn't need change to
|
||||
* run on top of different usb controllers. It'll use endpoints set up by
|
||||
* that ep0 implementation.
|
||||
*
|
||||
* The usb controller driver handles a few standard usb requests. Those
|
||||
* include set_address, and feature flags for devices, interfaces, and
|
||||
* endpoints (the get_status, set_feature, and clear_feature requests).
|
||||
*
|
||||
* Accordingly, the driver's setup() callback must always implement all
|
||||
* get_descriptor requests, returning at least a device descriptor and
|
||||
* a configuration descriptor. Drivers must make sure the endpoint
|
||||
* descriptors match any hardware constraints. Some hardware also constrains
|
||||
* other descriptors. (The pxa250 allows only configurations 1, 2, or 3).
|
||||
*
|
||||
* The driver's setup() callback must also implement set_configuration,
|
||||
* and should also implement set_interface, get_configuration, and
|
||||
* get_interface. Setting a configuration (or interface) is where
|
||||
* endpoints should be activated or (config 0) shut down.
|
||||
*
|
||||
* (Note that only the default control endpoint is supported. Neither
|
||||
* hosts nor devices generally support control traffic except to ep0.)
|
||||
*
|
||||
* Most devices will ignore USB suspend/resume operations, and so will
|
||||
* not provide those callbacks. However, some may need to change modes
|
||||
* when the host is not longer directing those activities. For example,
|
||||
* local controls (buttons, dials, etc) may need to be re-enabled since
|
||||
* the (remote) host can't do that any longer; or an error state might
|
||||
* be cleared, to make the device behave identically whether or not
|
||||
* power is maintained.
|
||||
*/
|
||||
struct usb_gadget_driver {
|
||||
char *function;
|
||||
enum usb_device_speed speed;
|
||||
int (*bind)(struct usb_gadget *);
|
||||
void (*unbind)(struct usb_gadget *);
|
||||
int (*setup)(struct usb_gadget *,
|
||||
const struct usb_ctrlrequest *);
|
||||
void (*disconnect)(struct usb_gadget *);
|
||||
void (*suspend)(struct usb_gadget *);
|
||||
void (*resume)(struct usb_gadget *);
|
||||
void (*reset)(struct usb_gadget *);
|
||||
};
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* driver modules register and unregister, as usual.
|
||||
* these calls must be made in a context that can sleep.
|
||||
*
|
||||
* these will usually be implemented directly by the hardware-dependent
|
||||
* usb bus interface driver, which will only support a single driver.
|
||||
*/
|
||||
|
||||
/**
|
||||
* usb_gadget_register_driver - register a gadget driver
|
||||
* @driver:the driver being registered
|
||||
*
|
||||
* Call this in your gadget driver's module initialization function,
|
||||
* to tell the underlying usb controller driver about your driver.
|
||||
* The driver's bind() function will be called to bind it to a
|
||||
* gadget before this registration call returns. It's expected that
|
||||
* the bind() functions will be in init sections.
|
||||
* This function must be called in a context that can sleep.
|
||||
*/
|
||||
int usb_gadget_register_driver(struct usb_gadget_driver *driver);
|
||||
|
||||
/**
|
||||
* usb_gadget_unregister_driver - unregister a gadget driver
|
||||
* @driver:the driver being unregistered
|
||||
*
|
||||
* Call this in your gadget driver's module cleanup function,
|
||||
* to tell the underlying usb controller that your driver is
|
||||
* going away. If the controller is connected to a USB host,
|
||||
* it will first disconnect(). The driver is also requested
|
||||
* to unbind() and clean up any device state, before this procedure
|
||||
* finally returns. It's expected that the unbind() functions
|
||||
* will in in exit sections, so may not be linked in some kernels.
|
||||
* This function must be called in a context that can sleep.
|
||||
*/
|
||||
int usb_gadget_unregister_driver(struct usb_gadget_driver *driver);
|
||||
|
||||
int usb_add_gadget_udc_release(struct device *parent,
|
||||
struct usb_gadget *gadget, void (*release)(struct device *dev));
|
||||
int usb_add_gadget_udc(struct device *parent, struct usb_gadget *gadget);
|
||||
void usb_del_gadget_udc(struct usb_gadget *gadget);
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* utility to simplify dealing with string descriptors */
|
||||
|
||||
/**
|
||||
* struct usb_gadget_strings - a set of USB strings in a given language
|
||||
* @language:identifies the strings' language (0x0409 for en-us)
|
||||
* @strings:array of strings with their ids
|
||||
*
|
||||
* If you're using usb_gadget_get_string(), use this to wrap all the
|
||||
* strings for a given language.
|
||||
*/
|
||||
struct usb_gadget_strings {
|
||||
u16 language; /* 0x0409 for en-us */
|
||||
struct usb_string *strings;
|
||||
};
|
||||
|
||||
/* put descriptor for string with that id into buf (buflen >= 256) */
|
||||
int usb_gadget_get_string(struct usb_gadget_strings *table, int id, u8 *buf);
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* utility to simplify managing config descriptors */
|
||||
|
||||
/* write vector of descriptors into buffer */
|
||||
int usb_descriptor_fillbuf(void *, unsigned,
|
||||
const struct usb_descriptor_header **);
|
||||
|
||||
/* build config descriptor from single descriptor vector */
|
||||
int usb_gadget_config_buf(const struct usb_config_descriptor *config,
|
||||
void *buf, unsigned buflen, const struct usb_descriptor_header **desc);
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
/* utility to simplify map/unmap of usb_requests to/from DMA */
|
||||
|
||||
extern int usb_gadget_map_request(struct usb_gadget *gadget,
|
||||
struct usb_request *req, int is_in);
|
||||
|
||||
extern void usb_gadget_unmap_request(struct usb_gadget *gadget,
|
||||
struct usb_request *req, int is_in);
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* utility to set gadget state properly */
|
||||
|
||||
extern void usb_gadget_set_state(struct usb_gadget *gadget,
|
||||
enum usb_device_state state);
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* utility to tell udc core that the bus reset occurs */
|
||||
extern void usb_gadget_udc_reset(struct usb_gadget *gadget,
|
||||
struct usb_gadget_driver *driver);
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* utility to give requests back to the gadget layer */
|
||||
|
||||
extern void usb_gadget_giveback_request(struct usb_ep *ep,
|
||||
struct usb_request *req);
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* utility wrapping a simple endpoint selection policy */
|
||||
|
||||
extern struct usb_ep *usb_ep_autoconfig(struct usb_gadget *,
|
||||
struct usb_endpoint_descriptor *);
|
||||
|
||||
extern void usb_ep_autoconfig_reset(struct usb_gadget *);
|
||||
|
||||
extern int usb_gadget_handle_interrupts(int index);
|
||||
|
||||
#if CONFIG_IS_ENABLED(DM_USB_GADGET)
|
||||
int usb_gadget_initialize(int index);
|
||||
int usb_gadget_release(int index);
|
||||
int dm_usb_gadget_handle_interrupts(struct udevice *dev);
|
||||
#else
|
||||
#include <usb.h>
|
||||
static inline int usb_gadget_initialize(int index)
|
||||
{
|
||||
return board_usb_init(index, USB_INIT_DEVICE);
|
||||
}
|
||||
|
||||
static inline int usb_gadget_release(int index)
|
||||
{
|
||||
return board_usb_cleanup(index, USB_INIT_DEVICE);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __LINUX_USB_GADGET_H */
|
||||
156
u-boot-2021.10/include/linux/usb/musb.h
Normal file
156
u-boot-2021.10/include/linux/usb/musb.h
Normal file
@ -0,0 +1,156 @@
|
||||
/*
|
||||
* This is used to for host and peripheral modes of the driver for
|
||||
* Inventra (Multidrop) Highspeed Dual-Role Controllers: (M)HDRC.
|
||||
*
|
||||
* Board initialization should put one of these into dev->platform_data,
|
||||
* probably on some platform_device named "musb-hdrc". It encapsulates
|
||||
* key configuration differences between boards.
|
||||
*/
|
||||
|
||||
#ifndef __LINUX_USB_MUSB_H
|
||||
#define __LINUX_USB_MUSB_H
|
||||
|
||||
#ifndef __deprecated
|
||||
#define __deprecated
|
||||
#endif
|
||||
|
||||
#include <linux/compat.h>
|
||||
|
||||
/* The USB role is defined by the connector used on the board, so long as
|
||||
* standards are being followed. (Developer boards sometimes won't.)
|
||||
*/
|
||||
enum musb_mode {
|
||||
MUSB_UNDEFINED = 0,
|
||||
MUSB_HOST, /* A or Mini-A connector */
|
||||
MUSB_PERIPHERAL, /* B or Mini-B connector */
|
||||
MUSB_OTG /* Mini-AB connector */
|
||||
};
|
||||
|
||||
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 */
|
||||
unsigned soft_con:1 __deprecated; /* soft connect required */
|
||||
unsigned utm_16:1 __deprecated; /* utm data witdh is 16 bits */
|
||||
unsigned big_endian:1; /* true if CPU uses big-endian */
|
||||
unsigned mult_bulk_tx:1; /* Tx ep required for multbulk pkts */
|
||||
unsigned mult_bulk_rx:1; /* Rx ep required for multbulk pkts */
|
||||
unsigned high_iso_tx:1; /* Tx ep required for HB iso */
|
||||
unsigned high_iso_rx:1; /* Rx ep required for HD iso */
|
||||
unsigned dma:1 __deprecated; /* supports DMA */
|
||||
unsigned vendor_req:1 __deprecated; /* vendor registers required */
|
||||
|
||||
u8 num_eps; /* number of endpoints _with_ ep0 */
|
||||
u8 dma_channels __deprecated; /* number of dma channels */
|
||||
u8 dyn_fifo_size; /* dynamic size in bytes */
|
||||
u8 vendor_ctrl __deprecated; /* vendor control reg width */
|
||||
u8 vendor_stat __deprecated; /* vendor status reg witdh */
|
||||
u8 dma_req_chan __deprecated; /* bitmask for required dma channels */
|
||||
u8 ram_bits; /* ram address size */
|
||||
|
||||
struct musb_hdrc_eps_bits *eps_bits __deprecated;
|
||||
};
|
||||
|
||||
struct musb_hdrc_platform_data {
|
||||
/* MUSB_HOST, MUSB_PERIPHERAL, or MUSB_OTG */
|
||||
u8 mode;
|
||||
|
||||
/* for clk_get() */
|
||||
const char *clock;
|
||||
|
||||
/* (HOST or OTG) switch VBUS on/off */
|
||||
int (*set_vbus)(struct device *dev, int is_on);
|
||||
|
||||
/* (HOST or OTG) mA/2 power supplied on (default = 8mA) */
|
||||
u8 power;
|
||||
|
||||
/* (PERIPHERAL) mA/2 max power consumed (default = 100mA) */
|
||||
u8 min_power;
|
||||
|
||||
/* (HOST or OTG) msec/2 after VBUS on till power good */
|
||||
u8 potpgt;
|
||||
|
||||
/* (HOST or OTG) program PHY for external Vbus */
|
||||
unsigned extvbus:1;
|
||||
|
||||
/* Power the device on or off */
|
||||
int (*set_power)(int state);
|
||||
|
||||
/* MUSB configuration-specific details */
|
||||
struct musb_hdrc_config *config;
|
||||
|
||||
/* Architecture specific board data */
|
||||
void *board_data;
|
||||
|
||||
/* Platform specific struct musb_ops pointer */
|
||||
const void *platform_ops;
|
||||
};
|
||||
|
||||
|
||||
/* TUSB 6010 support */
|
||||
|
||||
#define TUSB6010_OSCCLK_60 16667 /* psec/clk @ 60.0 MHz */
|
||||
#define TUSB6010_REFCLK_24 41667 /* psec/clk @ 24.0 MHz XI */
|
||||
#define TUSB6010_REFCLK_19 52083 /* psec/clk @ 19.2 MHz CLKIN */
|
||||
|
||||
#ifdef CONFIG_ARCH_OMAP2PLUS
|
||||
|
||||
extern int __init tusb6010_setup_interface(
|
||||
struct musb_hdrc_platform_data *data,
|
||||
unsigned ps_refclk, unsigned waitpin,
|
||||
unsigned async_cs, unsigned sync_cs,
|
||||
unsigned irq, unsigned dmachan);
|
||||
|
||||
extern int tusb6010_platform_retime(unsigned is_refclk);
|
||||
|
||||
#endif /* OMAP2 */
|
||||
|
||||
/*
|
||||
* U-Boot specfic stuff
|
||||
*/
|
||||
struct musb *musb_register(struct musb_hdrc_platform_data *plat, void *bdata,
|
||||
void *ctl_regs);
|
||||
|
||||
#endif /* __LINUX_USB_MUSB_H */
|
||||
39
u-boot-2021.10/include/linux/usb/otg.h
Normal file
39
u-boot-2021.10/include/linux/usb/otg.h
Normal file
@ -0,0 +1,39 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0+ */
|
||||
/* include/linux/usb/otg.h
|
||||
*
|
||||
* Copyright (c) 2015 Texas Instruments Incorporated - http://www.ti.com
|
||||
*
|
||||
* USB OTG (On The Go) defines
|
||||
*/
|
||||
|
||||
#ifndef __LINUX_USB_OTG_H
|
||||
#define __LINUX_USB_OTG_H
|
||||
|
||||
#include <dm/ofnode.h>
|
||||
|
||||
enum usb_dr_mode {
|
||||
USB_DR_MODE_UNKNOWN,
|
||||
USB_DR_MODE_HOST,
|
||||
USB_DR_MODE_PERIPHERAL,
|
||||
USB_DR_MODE_OTG,
|
||||
};
|
||||
|
||||
/**
|
||||
* usb_get_dr_mode() - Get dual role mode for given device
|
||||
* @node: ofnode of the given device
|
||||
*
|
||||
* The function gets phy interface string from property 'dr_mode',
|
||||
* and returns the correspondig enum usb_dr_mode
|
||||
*/
|
||||
enum usb_dr_mode usb_get_dr_mode(ofnode node);
|
||||
|
||||
/**
|
||||
* usb_get_maximum_speed() - Get maximum speed for given device
|
||||
* @node: ofnode of the given device
|
||||
*
|
||||
* The function gets phy interface string from property 'maximum-speed',
|
||||
* and returns the correspondig enum usb_device_speed
|
||||
*/
|
||||
enum usb_device_speed usb_get_maximum_speed(ofnode node);
|
||||
|
||||
#endif /* __LINUX_USB_OTG_H */
|
||||
40
u-boot-2021.10/include/linux/usb/phy.h
Normal file
40
u-boot-2021.10/include/linux/usb/phy.h
Normal file
@ -0,0 +1,40 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
/*
|
||||
* USB PHY defines
|
||||
*
|
||||
* These APIs may be used between USB controllers. USB device drivers
|
||||
* (for either host or peripheral roles) don't use these calls; they
|
||||
* continue to use just usb_device and usb_gadget.
|
||||
*/
|
||||
|
||||
#ifndef __LINUX_USB_PHY_H
|
||||
#define __LINUX_USB_PHY_H
|
||||
|
||||
#include <dm/ofnode.h>
|
||||
|
||||
enum usb_phy_interface {
|
||||
USBPHY_INTERFACE_MODE_UNKNOWN,
|
||||
USBPHY_INTERFACE_MODE_UTMI,
|
||||
USBPHY_INTERFACE_MODE_UTMIW,
|
||||
USBPHY_INTERFACE_MODE_ULPI,
|
||||
USBPHY_INTERFACE_MODE_SERIAL,
|
||||
USBPHY_INTERFACE_MODE_HSIC,
|
||||
};
|
||||
|
||||
#if CONFIG_IS_ENABLED(DM_USB)
|
||||
/**
|
||||
* usb_get_phy_mode - Get phy mode for given device_node
|
||||
* @np: Pointer to the given device_node
|
||||
*
|
||||
* The function gets phy interface string from property 'phy_type',
|
||||
* and returns the corresponding enum usb_phy_interface
|
||||
*/
|
||||
enum usb_phy_interface usb_get_phy_mode(ofnode node);
|
||||
#else
|
||||
static inline enum usb_phy_interface usb_get_phy_mode(ofnode node)
|
||||
{
|
||||
return USBPHY_INTERFACE_MODE_UNKNOWN;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __LINUX_USB_PHY_H */
|
||||
73
u-boot-2021.10/include/linux/usb/xhci-fsl.h
Normal file
73
u-boot-2021.10/include/linux/usb/xhci-fsl.h
Normal file
@ -0,0 +1,73 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0+ */
|
||||
/*
|
||||
* Copyright 2015 Freescale Semiconductor, Inc.
|
||||
*
|
||||
* FSL USB HOST xHCI Controller
|
||||
*
|
||||
* Author: Ramneek Mehresh<ramneek.mehresh@freescale.com>
|
||||
*/
|
||||
|
||||
#ifndef _ASM_ARCH_XHCI_FSL_H_
|
||||
#define _ASM_ARCH_XHCI_FSL_H_
|
||||
|
||||
/* Default to the FSL XHCI defines */
|
||||
#define USB3_PWRCTL_CLK_CMD_MASK 0x3FE000
|
||||
#define USB3_PWRCTL_CLK_FREQ_MASK 0xFFC
|
||||
#define USB3_PHY_PARTIAL_RX_POWERON BIT(6)
|
||||
#define USB3_PHY_RX_POWERON BIT(14)
|
||||
#define USB3_PHY_TX_POWERON BIT(15)
|
||||
#define USB3_PHY_TX_RX_POWERON (USB3_PHY_RX_POWERON | USB3_PHY_TX_POWERON)
|
||||
#define USB3_PWRCTL_CLK_CMD_SHIFT 14
|
||||
#define USB3_PWRCTL_CLK_FREQ_SHIFT 22
|
||||
#define USB3_ENABLE_BEAT_BURST 0xF
|
||||
#define USB3_ENABLE_BEAT_BURST_MASK 0xFF
|
||||
#define USB3_SET_BEAT_BURST_LIMIT 0xF00
|
||||
|
||||
/* USBOTGSS_WRAPPER definitions */
|
||||
#define USBOTGSS_WRAPRESET BIT(17)
|
||||
#define USBOTGSS_DMADISABLE BIT(16)
|
||||
#define USBOTGSS_STANDBYMODE_NO_STANDBY BIT(4)
|
||||
#define USBOTGSS_STANDBYMODE_SMRT BIT(5)
|
||||
#define USBOTGSS_STANDBYMODE_SMRT_WKUP (0x3 << 4)
|
||||
#define USBOTGSS_IDLEMODE_NOIDLE BIT(2)
|
||||
#define USBOTGSS_IDLEMODE_SMRT BIT(3)
|
||||
#define USBOTGSS_IDLEMODE_SMRT_WKUP (0x3 << 2)
|
||||
|
||||
/* USBOTGSS_IRQENABLE_SET_0 bit */
|
||||
#define USBOTGSS_COREIRQ_EN BIT(1)
|
||||
|
||||
/* USBOTGSS_IRQENABLE_SET_1 bits */
|
||||
#define USBOTGSS_IRQ_SET_1_IDPULLUP_FALL_EN BIT(1)
|
||||
#define USBOTGSS_IRQ_SET_1_DISCHRGVBUS_FALL_EN BIT(3)
|
||||
#define USBOTGSS_IRQ_SET_1_CHRGVBUS_FALL_EN BIT(4)
|
||||
#define USBOTGSS_IRQ_SET_1_DRVVBUS_FALL_EN BIT(5)
|
||||
#define USBOTGSS_IRQ_SET_1_IDPULLUP_RISE_EN BIT(8)
|
||||
#define USBOTGSS_IRQ_SET_1_DISCHRGVBUS_RISE_EN BIT(11)
|
||||
#define USBOTGSS_IRQ_SET_1_CHRGVBUS_RISE_EN BIT(12)
|
||||
#define USBOTGSS_IRQ_SET_1_DRVVBUS_RISE_EN BIT(13)
|
||||
#define USBOTGSS_IRQ_SET_1_OEVT_EN BIT(16)
|
||||
#define USBOTGSS_IRQ_SET_1_DMADISABLECLR_EN BIT(17)
|
||||
|
||||
struct fsl_xhci {
|
||||
struct xhci_hccr *hcd;
|
||||
struct dwc3 *dwc3_reg;
|
||||
};
|
||||
|
||||
#if defined(CONFIG_ARCH_LS1021A) || defined(CONFIG_ARCH_LS1012A)
|
||||
#define CONFIG_SYS_FSL_XHCI_USB1_ADDR CONFIG_SYS_XHCI_USB1_ADDR
|
||||
#define CONFIG_SYS_FSL_XHCI_USB2_ADDR 0
|
||||
#define CONFIG_SYS_FSL_XHCI_USB3_ADDR 0
|
||||
#elif defined(CONFIG_ARCH_LS2080A) || defined(CONFIG_ARCH_LS1088A)
|
||||
#define CONFIG_SYS_FSL_XHCI_USB1_ADDR CONFIG_SYS_XHCI_USB1_ADDR
|
||||
#define CONFIG_SYS_FSL_XHCI_USB2_ADDR CONFIG_SYS_XHCI_USB2_ADDR
|
||||
#define CONFIG_SYS_FSL_XHCI_USB3_ADDR 0
|
||||
#elif defined(CONFIG_ARCH_LS1043A) || defined(CONFIG_ARCH_LS1046A)
|
||||
#define CONFIG_SYS_FSL_XHCI_USB1_ADDR CONFIG_SYS_XHCI_USB1_ADDR
|
||||
#define CONFIG_SYS_FSL_XHCI_USB2_ADDR CONFIG_SYS_XHCI_USB2_ADDR
|
||||
#define CONFIG_SYS_FSL_XHCI_USB3_ADDR CONFIG_SYS_XHCI_USB3_ADDR
|
||||
#endif
|
||||
|
||||
#define FSL_USB_XHCI_ADDR {CONFIG_SYS_FSL_XHCI_USB1_ADDR, \
|
||||
CONFIG_SYS_FSL_XHCI_USB2_ADDR, \
|
||||
CONFIG_SYS_FSL_XHCI_USB3_ADDR}
|
||||
#endif /* _ASM_ARCH_XHCI_FSL_H_ */
|
||||
145
u-boot-2021.10/include/linux/usb/xhci-omap.h
Normal file
145
u-boot-2021.10/include/linux/usb/xhci-omap.h
Normal file
@ -0,0 +1,145 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0+ */
|
||||
/*
|
||||
* (C) Copyright 2013
|
||||
* Texas Instruments Inc, <www.ti.com>
|
||||
*
|
||||
* Author: Dan Murphy <dmurphy@ti.com>
|
||||
*/
|
||||
|
||||
#ifndef _ASM_ARCH_XHCI_OMAP_H_
|
||||
#define _ASM_ARCH_XHCI_OMAP_H_
|
||||
|
||||
#ifdef CONFIG_DRA7XX
|
||||
#if CONFIG_USB_XHCI_DRA7XX_INDEX == 1
|
||||
#define OMAP_XHCI_BASE 0x488d0000
|
||||
#define OMAP_OCP1_SCP_BASE 0x4A081000
|
||||
#define OMAP_OTG_WRAPPER_BASE 0x488c0000
|
||||
#elif CONFIG_USB_XHCI_DRA7XX_INDEX == 0
|
||||
#define OMAP_XHCI_BASE 0x48890000
|
||||
#define OMAP_OCP1_SCP_BASE 0x4A084c00
|
||||
#define OMAP_OTG_WRAPPER_BASE 0x48880000
|
||||
#endif /* CONFIG_USB_XHCI_DRA7XX_INDEX == 1 */
|
||||
#elif defined CONFIG_AM43XX
|
||||
#define OMAP_XHCI_BASE 0x483d0000
|
||||
#define OMAP_OCP1_SCP_BASE 0x483E8000
|
||||
#define OMAP_OTG_WRAPPER_BASE 0x483dc100
|
||||
#else
|
||||
/* Default to the OMAP5 XHCI defines */
|
||||
#define OMAP_XHCI_BASE 0x4a030000
|
||||
#define OMAP_OCP1_SCP_BASE 0x4a084c00
|
||||
#define OMAP_OTG_WRAPPER_BASE 0x4A020000
|
||||
#endif
|
||||
|
||||
/* Phy register MACRO definitions */
|
||||
#define PLL_REGM_MASK 0x001FFE00
|
||||
#define PLL_REGM_SHIFT 0x9
|
||||
#define PLL_REGM_F_MASK 0x0003FFFF
|
||||
#define PLL_REGM_F_SHIFT 0x0
|
||||
#define PLL_REGN_MASK 0x000001FE
|
||||
#define PLL_REGN_SHIFT 0x1
|
||||
#define PLL_SELFREQDCO_MASK 0x0000000E
|
||||
#define PLL_SELFREQDCO_SHIFT 0x1
|
||||
#define PLL_SD_MASK 0x0003FC00
|
||||
#define PLL_SD_SHIFT 0x9
|
||||
#define SET_PLL_GO 0x1
|
||||
#define PLL_TICOPWDN 0x10000
|
||||
#define PLL_LOCK 0x2
|
||||
#define PLL_IDLE 0x1
|
||||
|
||||
#define USB3_PWRCTL_CLK_CMD_MASK 0x3FE000
|
||||
#define USB3_PWRCTL_CLK_FREQ_MASK 0xFFC
|
||||
#define USB3_PHY_PARTIAL_RX_POWERON (1 << 6)
|
||||
#define USB3_PHY_RX_POWERON (1 << 14)
|
||||
#define USB3_PHY_TX_POWERON (1 << 15)
|
||||
#define USB3_PHY_TX_RX_POWERON (USB3_PHY_RX_POWERON | USB3_PHY_TX_POWERON)
|
||||
#define USB3_PWRCTL_CLK_CMD_SHIFT 14
|
||||
#define USB3_PWRCTL_CLK_FREQ_SHIFT 22
|
||||
|
||||
/* USBOTGSS_WRAPPER definitions */
|
||||
#define USBOTGSS_WRAPRESET (1 << 17)
|
||||
#define USBOTGSS_DMADISABLE (1 << 16)
|
||||
#define USBOTGSS_STANDBYMODE_NO_STANDBY (1 << 4)
|
||||
#define USBOTGSS_STANDBYMODE_SMRT (1 << 5)
|
||||
#define USBOTGSS_STANDBYMODE_SMRT_WKUP (0x3 << 4)
|
||||
#define USBOTGSS_IDLEMODE_NOIDLE (1 << 2)
|
||||
#define USBOTGSS_IDLEMODE_SMRT (1 << 3)
|
||||
#define USBOTGSS_IDLEMODE_SMRT_WKUP (0x3 << 2)
|
||||
|
||||
/* USBOTGSS_IRQENABLE_SET_0 bit */
|
||||
#define USBOTGSS_COREIRQ_EN (1 << 0)
|
||||
|
||||
/* USBOTGSS_IRQENABLE_SET_1 bits */
|
||||
#define USBOTGSS_IRQ_SET_1_IDPULLUP_FALL_EN (1 << 0)
|
||||
#define USBOTGSS_IRQ_SET_1_DISCHRGVBUS_FALL_EN (1 << 3)
|
||||
#define USBOTGSS_IRQ_SET_1_CHRGVBUS_FALL_EN (1 << 4)
|
||||
#define USBOTGSS_IRQ_SET_1_DRVVBUS_FALL_EN (1 << 5)
|
||||
#define USBOTGSS_IRQ_SET_1_IDPULLUP_RISE_EN (1 << 8)
|
||||
#define USBOTGSS_IRQ_SET_1_DISCHRGVBUS_RISE_EN (1 << 11)
|
||||
#define USBOTGSS_IRQ_SET_1_CHRGVBUS_RISE_EN (1 << 12)
|
||||
#define USBOTGSS_IRQ_SET_1_DRVVBUS_RISE_EN (1 << 13)
|
||||
#define USBOTGSS_IRQ_SET_1_OEVT_EN (1 << 16)
|
||||
#define USBOTGSS_IRQ_SET_1_DMADISABLECLR_EN (1 << 17)
|
||||
|
||||
/*
|
||||
* USBOTGSS_WRAPPER registers
|
||||
*/
|
||||
struct omap_dwc_wrapper {
|
||||
u32 revision;
|
||||
|
||||
u32 reserve_1[3];
|
||||
|
||||
u32 sysconfig; /* offset of 0x10 */
|
||||
|
||||
u32 reserve_2[3];
|
||||
u16 reserve_3;
|
||||
|
||||
u32 irqstatus_raw_0; /* offset of 0x24 */
|
||||
u32 irqstatus_0;
|
||||
u32 irqenable_set_0;
|
||||
u32 irqenable_clr_0;
|
||||
|
||||
u32 irqstatus_raw_1; /* offset of 0x34 */
|
||||
u32 irqstatus_1;
|
||||
u32 irqenable_set_1;
|
||||
u32 irqenable_clr_1;
|
||||
|
||||
u32 reserve_4[15];
|
||||
|
||||
u32 utmi_otg_ctrl; /* offset of 0x80 */
|
||||
u32 utmi_otg_status;
|
||||
|
||||
u32 reserve_5[30];
|
||||
|
||||
u32 mram_offset; /* offset of 0x100 */
|
||||
u32 fladj;
|
||||
u32 dbg_config;
|
||||
u32 dbg_data;
|
||||
u32 dev_ebc_en;
|
||||
};
|
||||
|
||||
/* XHCI PHY register structure */
|
||||
struct omap_usb3_phy {
|
||||
u32 reserve1;
|
||||
u32 pll_status;
|
||||
u32 pll_go;
|
||||
u32 pll_config_1;
|
||||
u32 pll_config_2;
|
||||
u32 pll_config_3;
|
||||
u32 pll_ssc_config_1;
|
||||
u32 pll_ssc_config_2;
|
||||
u32 pll_config_4;
|
||||
};
|
||||
|
||||
struct omap_xhci {
|
||||
struct omap_dwc_wrapper *otg_wrapper;
|
||||
struct omap_usb3_phy *usb3_phy;
|
||||
struct xhci_hccr *hcd;
|
||||
struct dwc3 *dwc3_reg;
|
||||
};
|
||||
|
||||
/* USB PHY functions */
|
||||
void omap_enable_phy(struct omap_xhci *omap);
|
||||
void omap_reset_usb_phy(struct dwc3 *dwc3_reg);
|
||||
void usb_phy_power(int on);
|
||||
|
||||
#endif /* _ASM_ARCH_XHCI_OMAP_H_ */
|
||||
Reference in New Issue
Block a user