diff options
author | Tom Rini <trini@konsulko.com> | 2021-01-31 14:24:35 -0500 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2021-01-31 14:24:35 -0500 |
commit | b4804cdd5747d1d932bd338e0ca102ade51b8b6b (patch) | |
tree | dd3aa210c95de630ee7e62a58e7924e73ee0458a /include | |
parent | fad42d3afbeb23e86fae2bb56ba863a2a5a133e1 (diff) | |
parent | 723fd5668ff2c8dd19e808778b5670d0fa6bdc4b (diff) |
Merge https://gitlab.denx.de/u-boot/custodians/u-boot-usb
- Assorted gadget changes including:
- dfu: Fix handling of UBI partitions in MTD backend
- gadget: f_thor: fix wrong file size cast
- Extend cmd: bcb
- Fixes for fastboot and rockchip gadgets
- dfu: Add SCRIPT and SKIP entities
- dfu/thor: Add `dfu_alt_info` reinitialization from flashed script
- u-boot: Reduce size of u-boot as usbd_device_* arrays are not exported
Diffstat (limited to 'include')
-rw-r--r-- | include/bcb.h | 21 | ||||
-rw-r--r-- | include/dfu.h | 4 | ||||
-rw-r--r-- | include/linux/usb/composite.h | 71 | ||||
-rw-r--r-- | include/linux/usb/gadget.h | 9 | ||||
-rw-r--r-- | include/linux/utf.h | 75 | ||||
-rw-r--r-- | include/thor.h | 2 | ||||
-rw-r--r-- | include/usbdevice.h | 15 |
7 files changed, 182 insertions, 15 deletions
diff --git a/include/bcb.h b/include/bcb.h new file mode 100644 index 0000000000..897e83d371 --- /dev/null +++ b/include/bcb.h @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2020 Eugeniu Rosca <rosca.eugeniu@gmail.com> + * + * Android Bootloader Control Block Header + */ + +#ifndef __BCB_H__ +#define __BCB_H__ + +#if CONFIG_IS_ENABLED(CMD_BCB) +int bcb_write_reboot_reason(int devnum, char *partp, const char *reasonp); +#else +#include <linux/errno.h> +static inline int bcb_write_reboot_reason(int devnum, char *partp, const char *reasonp) +{ + return -EOPNOTSUPP; +} +#endif + +#endif /* __BCB_H__ */ diff --git a/include/dfu.h b/include/dfu.h index a767adee41..d18b701728 100644 --- a/include/dfu.h +++ b/include/dfu.h @@ -33,6 +33,8 @@ enum dfu_layout { DFU_FS_EXT3, DFU_FS_EXT4, DFU_RAM_ADDR, + DFU_SKIP, + DFU_SCRIPT, }; enum dfu_op { @@ -496,6 +498,8 @@ static inline int dfu_fill_entity_virt(struct dfu_entity *dfu, char *devstr, } #endif +extern bool dfu_reinit_needed; + #if CONFIG_IS_ENABLED(DFU_WRITE_ALT) /** * dfu_write_by_name() - write data to DFU medium diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h index a49a66f2f8..935e5c0cbb 100644 --- a/include/linux/usb/composite.h +++ b/include/linux/usb/composite.h @@ -38,6 +38,53 @@ 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() @@ -50,6 +97,10 @@ struct usb_configuration; * 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. @@ -95,9 +146,13 @@ struct usb_function { 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. @@ -225,6 +280,7 @@ struct usb_configuration { u8 next_interface_id; unsigned highspeed:1; unsigned fullspeed:1; + unsigned superspeed:1; struct usb_function *interface[MAX_CONFIG_INTERFACES]; }; @@ -238,6 +294,7 @@ int usb_add_config(struct usb_composite_dev *, * 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 @@ -265,6 +322,7 @@ 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 @@ -284,13 +342,20 @@ struct usb_composite_driver { 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. @@ -324,6 +389,12 @@ struct usb_composite_dev { 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; diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h index 06292ddeb6..7e6d329e54 100644 --- a/include/linux/usb/gadget.h +++ b/include/linux/usb/gadget.h @@ -449,6 +449,11 @@ static inline void usb_ep_fifo_flush(struct usb_ep *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; @@ -464,12 +469,16 @@ struct usb_gadget_ops { 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); }; diff --git a/include/linux/utf.h b/include/linux/utf.h new file mode 100644 index 0000000000..e1f7d3bd1d --- /dev/null +++ b/include/linux/utf.h @@ -0,0 +1,75 @@ +#ifndef _LINUX_UTF_H +#define _LINUX_UTF_H + +#include <asm/unaligned.h> + +static inline int utf8_to_utf16le(const char *s, __le16 *cp, unsigned len) +{ + int count = 0; + u8 c; + u16 uchar; + + /* + * this insists on correct encodings, though not minimal ones. + * BUT it currently rejects legit 4-byte UTF-8 code points, + * which need surrogate pairs. (Unicode 3.1 can use them.) + */ + while (len != 0 && (c = (u8) *s++) != 0) { + if ((c & 0x80)) { + /* + * 2-byte sequence: + * 00000yyyyyxxxxxx = 110yyyyy 10xxxxxx + */ + if ((c & 0xe0) == 0xc0) { + uchar = (c & 0x1f) << 6; + + c = (u8) *s++; + if ((c & 0xc0) != 0x80) + goto fail; + c &= 0x3f; + uchar |= c; + + /* + * 3-byte sequence (most CJKV characters): + * zzzzyyyyyyxxxxxx = 1110zzzz 10yyyyyy 10xxxxxx + */ + } else if ((c & 0xf0) == 0xe0) { + uchar = (c & 0x0f) << 12; + + c = (u8) *s++; + if ((c & 0xc0) != 0x80) + goto fail; + c &= 0x3f; + uchar |= c << 6; + + c = (u8) *s++; + if ((c & 0xc0) != 0x80) + goto fail; + c &= 0x3f; + uchar |= c; + + /* no bogus surrogates */ + if (0xd800 <= uchar && uchar <= 0xdfff) + goto fail; + + /* + * 4-byte sequence (surrogate pairs, currently rare): + * 11101110wwwwzzzzyy + 110111yyyyxxxxxx + * = 11110uuu 10uuzzzz 10yyyyyy 10xxxxxx + * (uuuuu = wwww + 1) + * FIXME accept the surrogate code points (only) + */ + } else + goto fail; + } else + uchar = c; + put_unaligned_le16(uchar, cp++); + count++; + len--; + } + return count; +fail: + return -1; +} + +#endif /* _LINUX_UTF_H */ diff --git a/include/thor.h b/include/thor.h index 62501bda17..ee67ab0a27 100644 --- a/include/thor.h +++ b/include/thor.h @@ -12,6 +12,8 @@ #include <linux/usb/composite.h> +#define THOR_DFU_REINIT_NEEDED 0xFFFFFFFE + int thor_handle(void); int thor_init(void); int thor_add(struct usb_configuration *c); diff --git a/include/usbdevice.h b/include/usbdevice.h index f479724e37..611cd6e4ab 100644 --- a/include/usbdevice.h +++ b/include/usbdevice.h @@ -264,8 +264,6 @@ struct usb_bus_instance; #define USB_REQ_SET_INTERFACE 0x0B #define USB_REQ_SYNCH_FRAME 0x0C -#define USBD_DEVICE_REQUESTS(x) (((unsigned int)x <= USB_REQ_SYNCH_FRAME) ? usbd_device_requests[x] : "UNKNOWN") - /* * HID requests */ @@ -332,9 +330,6 @@ struct usb_bus_instance; #define USB_DESCRIPTOR_TYPE_HID 0x21 #define USB_DESCRIPTOR_TYPE_REPORT 0x22 -#define USBD_DEVICE_DESCRIPTORS(x) (((unsigned int)x <= USB_DESCRIPTOR_TYPE_INTERFACE_POWER) ? \ - usbd_device_descriptors[x] : "UNKNOWN") - /* * standard feature selectors */ @@ -388,8 +383,6 @@ typedef enum usb_device_state { STATE_UNKNOWN, /* destroyed */ } usb_device_state_t; -#define USBD_DEVICE_STATE(x) (((unsigned int)x <= STATE_UNKNOWN) ? usbd_device_states[x] : "UNKNOWN") - /* * Device status * @@ -402,8 +395,6 @@ typedef enum usb_device_status { USBD_CLOSING, /* we are currently closing */ } usb_device_status_t; -#define USBD_DEVICE_STATUS(x) (((unsigned int)x <= USBD_CLOSING) ? usbd_device_status[x] : "UNKNOWN") - /* * Device Events * @@ -617,12 +608,6 @@ struct usb_bus_instance { }; -extern char *usbd_device_events[]; -extern char *usbd_device_states[]; -extern char *usbd_device_status[]; -extern char *usbd_device_requests[]; -extern char *usbd_device_descriptors[]; - void urb_link_init (urb_link * ul); void urb_detach (struct urb *urb); urb_link *first_urb_link (urb_link * hd); |