usb: xhci: Fix USB xHCI support on Intel platform
Subsystems (10)
v3 cover usb: xhci: Fix USB xHCI support on Intel platform
Currently U-Boot xHCI driver does not work on Intel BayTrail SoC based boards that have USB 3.0 ports. Trying to do a 'usb start' simply hangs the board. This series fixes a bunch of xHCI driver issues to make it work on Intel's platform.
Issues identified in the U-Boot xHCI driver are really spec violations, but apparently other xHCI IPs found on ARM SoCs (mainly Synopsis IP?) are quite tolerant with these spec violations, or IOW those IPs don't respect the xHCI spec. While it comes to Intel platform, it just breaks.
Note xHCI interrupt transfer is still not supported in this series, as it has been there since the original commit of xHCI support for years.
Tested on Intel MinnowMax board with the following USB devices:
- Dell USB 1.1 keyboard
- Dell USB 1.1 mouse
- Netac USB 2.0 flash disk
- JetFlash USB 3.0 flash disk
- GenesysLogic 4-port USB 3.0 hub, with an integrated Realtek USB ethernet chipset connected to one of its downstream port
Testing were performed on both ports (2.0 port and 3.0 port), and both ports are connected to xHCI (configure MinnowMax to enable xHCI).
Testing results:
- DELL USB 1.1 keyboard and mouse can be enumerated on both ports
- USB 2.0 and 3.0 flash disks work fine (enumerated, read/write) on both ports
- GenesysLogic USB 3.0 hub can be enumerated on 2.0 port as a 2.0 hub, and the integrated Realtek USB ethernet chipset enumerated as well. USB 2.0 and 3.0 flash disks connected via the hub can be enumerated, but DELL USB 1.1 keyboard and mouse cannot.
- GenesysLogic USB 3.0 hub can be enumerated on 3.0 port as a 3.0 hub, but the integrated Realtek USB ethernet chipset cannot be enumerated. None of devices connected via the hub can be enumerated. U-Boot xHCI driver just throws BUG_ON() on the event TRB handling.
This indicates that USB 3.0 hub support in U-Boot is seriously broken. So far this series tries to fix some of the issues identified, but the USB 3.0 hub is still not working. This will be left as future work.
The USB 3.0 hub work includes: port status translation, USB 3.0 newly added "Set Hub Depth" request support, xHCI codes update to fill in hub description fields in the input slot context when issuing commands to xHC, etc.
This series is available at u-boot-x86/xhci-working for testing.
Changes in v3:
- Rebase on u-boot/master
Changes in v2:
- Change to use uint and also 'normal' variable name packet_size.
- Update description to use "PCI-based"
- Remove CONFIG_USB_XHCI_PCI from config_whitelist.txt
- Drop two x86 patches that were already applied to u-boot-x86
Bin Meng (18):
usb: xhci: Remove incorrect comments for struct xhci_container_ctx
usb: xhci: Correct command TRB 4th dword initialization
usb: xhci: Initialize scratchpad buffer array and scratchpad buffers
usb: xhci: Add input slot context in xhci_set_configuration()
usb: hub: Update handling connect status/change in usb_scan_port()
usb: hub: Send correct wValue to get hub descriptor of a USB 3.0 hub
usb: hub: Revise wLength for 'get port status' request
usb: hub: Change USB hub descriptor to match USB 3.0 hubs
usb: hub: Add 3.0 hub port status mask of 2.0 hub
usb: xhci: Change MAX_HC_PORTS to 255
usb: xhci: Get rid of CONFIG_SYS_USB_XHCI_MAX_ROOT_PORTS
configs: Remove CONFIG_SYS_USB_XHCI_MAX_ROOT_PORTS in all boards
usb: ehci: Get rid of CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS
configs: Remove CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS in all boards
usb: cmd: Print actual packet size for super speed devices
usb: xhci: Convert CONFIG_USB_XHCI_PCI to Kconfig
x86: minnowmax: Add a environment variable for USB power-on delay
x86: minnowmax: Enable USB xHCI support
arch/arm/include/asm/ehci-omap.h | 4 -- arch/x86/dts/minnowmax.dts | 3 ++ cmd/usb.c | 7 ++- common/usb_hub.c | 41 +++++++++++------ configs/minnowmax_defconfig | 1 + drivers/usb/emul/sandbox_hub.c | 7 ++- drivers/usb/host/Kconfig | 6 +++ drivers/usb/host/ehci-hcd.c | 14 +++--- drivers/usb/host/ehci.h | 7 ++- drivers/usb/host/xhci-mem.c | 87 ++++++++++++++++++++++++++++++++++++ drivers/usb/host/xhci-ring.c | 11 ++++- drivers/usb/host/xhci.c | 17 ++++--- drivers/usb/host/xhci.h | 23 +++++----- include/configs/MPC8572DS.h | 1 - include/configs/am43xx_evm.h | 1 - include/configs/am57xx_evm.h | 1 - include/configs/cl-som-am57x.h | 1 - include/configs/cm_t43.h | 1 - include/configs/cm_t54.h | 1 - include/configs/corvus.h | 3 -- include/configs/dra7xx_evm.h | 1 - include/configs/ds414.h | 1 - include/configs/duovero.h | 2 - include/configs/exynos5-common.h | 3 -- include/configs/ls1012afrdm.h | 1 - include/configs/ls1012aqds.h | 1 - include/configs/ls1012ardb.h | 1 - include/configs/ls1021aiot.h | 1 - include/configs/ls1021aqds.h | 1 - include/configs/ls1021atwr.h | 1 - include/configs/ls1043aqds.h | 1 - include/configs/ls1043ardb.h | 1 - include/configs/ls1046aqds.h | 1 - include/configs/ls1046ardb.h | 1 - include/configs/ls2080aqds.h | 1 - include/configs/ls2080ardb.h | 1 - include/configs/ma5d4evk.h | 1 - include/configs/mcx.h | 1 - include/configs/minnowmax.h | 3 +- include/configs/mvebu_armada-37xx.h | 9 +--- include/configs/mvebu_armada-8k.h | 9 +--- include/configs/mx35pdk.h | 1 - include/configs/odroid.h | 1 - include/configs/omap3_beagle.h | 1 - include/configs/omap3_overo.h | 1 - include/configs/omap4_panda.h | 2 - include/configs/omap5_uevm.h | 1 - include/configs/picosam9g45.h | 3 -- include/configs/rk3328_common.h | 2 - include/configs/rk3399_common.h | 3 -- include/configs/sama5d2_ptc.h | 4 -- include/configs/snapper9g45.h | 3 -- include/configs/sunxi-common.h | 1 - include/configs/tam3517-common.h | 1 - include/configs/tao3530.h | 1 - include/configs/tegra114-common.h | 1 - include/configs/tegra124-common.h | 1 - include/configs/tegra20-common.h | 1 - include/configs/tegra210-common.h | 1 - include/configs/tegra30-common.h | 1 - include/configs/ti_armv7_keystone2.h | 1 - include/configs/uniphier.h | 3 -- include/configs/vinco.h | 6 --- include/configs/x86-common.h | 1 - include/configs/xilinx_zynqmp.h | 2 - include/usb.h | 18 ++++++-- include/usb_defs.h | 8 +++- scripts/config_whitelist.txt | 3 -- 68 files changed, 205 insertions(+), 146 deletions(-)
Signature · 1 line
2.9.2
PATCH v3 1/18 usb: xhci: Remove incorrect comments for struct xhci_container_ctx
There is no member called 'dma' in struct xhci_container_ctx. Remove the comments that mentions it.
---
Changes in v3: None
Changes in v2: None
drivers/usb/host/xhci.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/usb/host/xhci.h +1 -2
@@ -482,10 +482,9 @@ struct xhci_protocol_caps {* @type: Type of context. Used to calculated offsets to contained contexts. * @size: Size of the context data * @bytes: The raw context data given to HW -* @dma: dma address of the bytes * * Represents either a Device or Input context. Holds a pointer to the raw -* memory used for the context (bytes) and dma address of it (dma). +* memory used for the context (bytes). */ struct xhci_container_ctx {unsigned type;
Signature · 1 line
2.9.2
PATCH v3 2/18 usb: xhci: Correct command TRB 4th dword initialization
In reply to Bin MengIn xhci_queue_command(), when the command is not 'reset endpoint', 'stop endpoint' or 'set TR dequeue pointer', endpoint ID should not be encoded in the TRB.
---
Changes in v3: None
Changes in v2: None
drivers/usb/host/xhci-ring.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/usb/host/xhci-ring.c +9 -2
@@ -280,8 +280,15 @@ void xhci_queue_command(struct xhci_ctrl *ctrl, u8 *ptr, u32 slot_id, fields[0 ] =lower_32_bits (val_64); fields[1 ] =upper_32_bits (val_64); fields[2 ] =0 ; - fields[3 ] =TRB_TYPE (cmd) |EP_ID_FOR_TRB (ep_index) | -SLOT_ID_FOR_TRB (slot_id) | ctrl->cmd_ring->cycle_state; + fields[3 ] =TRB_TYPE (cmd) |SLOT_ID_FOR_TRB (slot_id) | + ctrl->cmd_ring->cycle_state; + +/* +* Only 'reset endpoint', 'stop endpoint' and 'set TR dequeue pointer' +* commands need endpoint id encoded. +*/ +if (cmd >=TRB_RESET_EP && cmd <=TRB_SET_DEQ ) + fields[3 ] |=EP_ID_FOR_TRB (ep_index);queue_trb (ctrl, ctrl->cmd_ring, false, fields);
Signature · 1 line
2.9.2
PATCH v3 3/18 usb: xhci: Initialize scratchpad buffer array and scratchpad buffers
In reply to Bin MengThe scratchpad buffer array is used to define the locations of statically allocated memory pages that are available for the private use of the xHC. The xHCI spec explicitly mentions that system software shall allocate the scratchpad buffers before placing the xHC in to Run mode (Run/Stop (R/S) = ‘1’), however U-Boot is missing this part.
This causes xHC on Intel platform does not respond the very first 'enable slot' command that is given to xHC and the 'enable slot' command completion event TRB is never generated and xHC seems to hang forever.
---
Changes in v3: None
Changes in v2: None
drivers/usb/host/xhci-mem.c | 87 +++++++++++++++++++++++++++++++++++++++++++++ drivers/usb/host/xhci.h | 10 ++++-- 2 files changed, 95 insertions(+), 2 deletions(-)
drivers/usb/host/xhci-mem.c +87 -0
@@ -96,6 +96,25 @@ static void xhci_ring_free(struct xhci_ring *ring) }/** +* Free the scratchpad buffer array and scratchpad buffers +* +* @ctrl host controller data structure +* @return none +*/ +static void xhci_scratchpad_free (struct xhci_ctrl *ctrl) +{ +if (!ctrl->scratchpad) +return ; + + ctrl->dcbaa->dev_context_ptrs[0 ] =0 ; + +free ((void *)(uintptr_t )ctrl->scratchpad->sp_array[0 ]); +free (ctrl->scratchpad->sp_array); +free (ctrl->scratchpad); + ctrl->scratchpad =NULL ; +} + +/** * frees the "xhci_container_ctx" pointer passed * * @param ptr pointer to "xhci_container_ctx" to be freed
@@ -155,6 +174,7 @@ void xhci_cleanup(struct xhci_ctrl *ctrl) {xhci_ring_free (ctrl->event_ring);xhci_ring_free (ctrl->cmd_ring); +xhci_scratchpad_free (ctrl);xhci_free_virt_devices (ctrl);free (ctrl->erst.entries);free (ctrl->dcbaa);
@@ -320,6 +340,70 @@ struct xhci_ring *xhci_ring_alloc(unsigned int num_segs, bool link_trbs) }/** +* Set up the scratchpad buffer array and scratchpad buffers +* +* @ctrl host controller data structure +* @return -ENOMEM if buffer allocation fails, 0 on success +*/ +static int xhci_scratchpad_alloc (struct xhci_ctrl *ctrl) +{ +struct xhci_hccr *hccr = ctrl->hccr; +struct xhci_hcor *hcor = ctrl->hcor; +struct xhci_scratchpad *scratchpad; +int num_sp; +uint32_t page_size; +void *buf; +int i; + + num_sp =HCS_MAX_SCRATCHPAD (xhci_readl (&hccr->cr_hcsparams2)); +if (!num_sp) +return 0 ; + + scratchpad =malloc (sizeof (*scratchpad)); +if (!scratchpad) + goto fail_sp; + ctrl->scratchpad = scratchpad; + + scratchpad->sp_array =xhci_malloc (num_sp *sizeof (u64)); +if (!scratchpad->sp_array) + goto fail_sp2; + ctrl->dcbaa->dev_context_ptrs[0 ] = +cpu_to_le64 ((uintptr_t )scratchpad->sp_array); + + page_size =xhci_readl (&hcor->or_pagesize) &0xffff ; +for (i =0 ; i <16 ; i++) { +if ((0x1 & page_size) !=0 ) +break ; + page_size = page_size >>1 ; + } +BUG_ON (i ==16 ); + + page_size =1 << (i +12 ); + buf =memalign (page_size, num_sp * page_size); +if (!buf) + goto fail_sp3; +memset (buf,'\0' , num_sp * page_size); +xhci_flush_cache ((uintptr_t )buf, num_sp * page_size); + +for (i =0 ; i < num_sp; i++) { +uintptr_t ptr = (uintptr_t )buf + i * page_size; + scratchpad->sp_array[i] =cpu_to_le64 (ptr); + } + +return 0 ; + +fail_sp3: +free (scratchpad->sp_array); + +fail_sp2: +free (scratchpad); + ctrl->scratchpad =NULL ; + +fail_sp: +return -ENOMEM ; +} + +/** * Allocates the Container context * * @param ctrl Host controller data structure
@@ -499,6 +583,9 @@ int xhci_mem_init(struct xhci_ctrl *ctrl, struct xhci_hccr *hccr,xhci_writeq (&ctrl->ir_set->erst_base, val_64); +/* set up the scratchpad buffer array and scratchpad buffers */ +xhci_scratchpad_alloc (ctrl); +/* initializing the virtual devices to NULL */ for (i =0 ; i <MAX_HC_SLOTS ; ++i) ctrl->devs[i] =NULL ;
drivers/usb/host/xhci.h +8 -2
@@ -111,9 +111,10 @@ struct xhci_hccr {#define HCS_IST (p) (((p) >> 0) & 0xf)/* bits 4:7, max number of Event Ring segments */ #define HCS_ERST_MAX (p) (((p) >> 4) & 0xf) +/* bits 21:25 Hi 5 bits of Scratchpad buffers SW must allocate for the HW */ /* bit 26 Scratchpad restore - for save/restore HW state - not used yet */ -/* bits 27:31 number of Scratchpad buffers SW must allocate for the HW */ -#define HCS_MAX_SCRATCHPAD (p) (((p) >> 27) & 0x1f) +/* bits 27:31 Lo 5 bits of Scratchpad buffers SW must allocate for the HW */ +#define HCS_MAX_SCRATCHPAD (p) ((((p) >> 16) & 0x3e0) | (((p) >> 27) & 0x1f))/* HCSPARAMS3 - hcs_params3 - bitmasks */ /* bits 0:7, Max U1 to U0 latency for the roothub ports */
@@ -1037,6 +1038,10 @@ struct xhci_erst {unsigned int erst_size; }; +struct xhci_scratchpad { +u64 *sp_array; +}; +/* * Each segment table entry is 4*32bits long. 1K seems like an ok size: * (1K bytes * 8bytes/bit) / (4*32 bits) = 64 segment entries in the table,
@@ -1224,6 +1229,7 @@ struct xhci_ctrl {struct xhci_intr_reg *ir_set;struct xhci_erst erst;struct xhci_erst_entry entry[ERST_NUM_SEGS ]; +struct xhci_scratchpad *scratchpad;struct xhci_virt_device *devs[MAX_HC_SLOTS ];int rootdev; };
Signature · 1 line
2.9.2
PATCH v3 4/18 usb: xhci: Add input slot context in xhci_set_configuration()
In reply to Bin MengA valid input slot context for a 'configure endpoint' command requires the 'Context Entries' field to be initialized to the index of the last valid endpoint context that is defined by the target configuration. We set up the 'Context Entries' field, but we forget to include the input slot context in the input control context 'Add Context flags' bitmap. So xHC will simply ignore input slot context and continue using its own which contains old information of the device.
---
Changes in v3: None
Changes in v2: None
drivers/usb/host/xhci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/host/xhci.c +2 -2
@@ -332,8 +332,8 @@ static int xhci_set_configuration(struct usb_device *udev) ifdesc = &udev->config.if_desc[0 ]; ctrl_ctx =xhci_get_input_control_ctx (in_ctx); -/* Zero the input context control */ - ctrl_ctx->add_flags =0 ; +/* Initialize the input context control */ + ctrl_ctx->add_flags =cpu_to_le32 (SLOT_FLAG ); ctrl_ctx->drop_flags =0 ;/* EP_FLAG gives values 1 & 4 for EP1OUT and EP2IN */
Signature · 1 line
2.9.2
PATCH v3 5/18 usb: hub: Update handling connect status/change in usb_scan_port()
In reply to Bin MengIt was observed that on Intel MinnowMax board, when xHCI is enabled in the BayTrail SoC, with a USB 3.0 device connected to the bottom USB 3.0 port (mapped to xHCI root port #7), its PORTSC register is always 0x201203 (CCS = 1, CSC = 0). The root cause of such behavior is unknown yet. Connect status change bit is set on the same port with a USB 2.0 device (mapped to xHCI port #1, which is a different port on the root hub).
With current logic in usb_scan_port(), the enumeration process will abort if it does not detect a connect status change on a hub port. However since a device connection status is correctly reported, the enumeration process can still continue.
With this change, USB device connected to the bottom blue port on MinnowMax board can be enumerated under either SS or HS mode.
---
Changes in v3: None
Changes in v2: None
common/usb_hub.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
common/usb_hub.c +9 -6
@@ -405,8 +405,15 @@ static int usb_scan_port(struct usb_device_scan *usb_scan) portchange =le16_to_cpu (portsts->wPortChange);debug ("Port %d Status %X Change %X\n" , i +1 , portstatus, portchange); -/* No connection change happened, wait a bit more. */ -if (!(portchange &USB_PORT_STAT_C_CONNECTION )) { +/* +* No connection change happened, wait a bit more. +* +* For some situation, the hub reports no connection change but a +* device is connected to the port (eg: CCS bit is set but CSC is not +* in the PORTSC register of a root hub), ignore such case. +*/ +if (!(portchange &USB_PORT_STAT_C_CONNECTION ) && + !(portstatus &USB_PORT_STAT_CONNECTION )) {if (get_timer (0 ) >= hub->connect_timeout) {debug ("devnum=%d port=%d: timeout\n" , dev->devnum, i +1 );
@@ -418,10 +425,6 @@ static int usb_scan_port(struct usb_device_scan *usb_scan)return 0 ; } -/* Test if the connection came up, and if not exit */ -if (!(portstatus &USB_PORT_STAT_CONNECTION )) -return 0 ; -/* A new USB device is ready at this point */ debug ("devnum=%d port=%d: USB dev found\n" , dev->devnum, i +1 );
Signature · 1 line
2.9.2
PATCH v3 6/18 usb: hub: Send correct wValue to get hub descriptor of a USB 3.0 hub
In reply to Bin MengTesting a USB 3.0 hub by connecting it to the xHCI port on Intel MinnowMax, when issuing 'get hub descriptor' to the hub, xHCI reports a transfer event TRB with a completion code 6 which means 'Stall Error'.
In fact super speed USB hub descriptor type is 0x2a, not 0x29. Sending correct SETUP packet to the hub makes it not stall anymore.
---
Changes in v3: None
Changes in v2: None
common/usb_hub.c | 12 +++++++++++- drivers/usb/host/xhci.c | 1 + include/usb_defs.h | 1 + 3 files changed, 13 insertions(+), 1 deletion(-)
common/usb_hub.c +11 -1
@@ -65,11 +65,21 @@ __weak void usb_hub_reset_devices(int port)return ; } +static inline bool usb_hub_is_superspeed (struct usb_device *hdev) +{ +return hdev->descriptor.bDeviceProtocol ==3 ; +} +static int usb_get_hub_descriptor (struct usb_device *dev,void *data,int size) { +unsigned short dtype =USB_DT_HUB ; + +if (usb_hub_is_superspeed (dev)) + dtype =USB_DT_SS_HUB ; +return usb_control_msg (dev,usb_rcvctrlpipe (dev,0 ),USB_REQ_GET_DESCRIPTOR ,USB_DIR_IN |USB_RT_HUB , -USB_DT_HUB <<8 ,0 , data, size,USB_CNTL_TIMEOUT ); + dtype <<8 ,0 , data, size,USB_CNTL_TIMEOUT ); }static int usb_clear_port_feature (struct usb_device *dev,int port,int feature)
drivers/usb/host/xhci.c +1 -0
@@ -727,6 +727,7 @@ static int xhci_submit_root(struct usb_device *udev, unsigned long pipe,case USB_REQ_GET_DESCRIPTOR | ((USB_DIR_IN |USB_RT_HUB ) <<8 ):switch (le16_to_cpu (req->value) >>8 ) {case USB_DT_HUB : +case USB_DT_SS_HUB :debug ("USB_DT_HUB config\n" ); srcptr = &descriptor.hub; srclen =0x8 ;
include/usb_defs.h +1 -0
@@ -93,6 +93,7 @@#define USB_DT_REPORT (USB_TYPE_CLASS | 0x02)#define USB_DT_PHYSICAL (USB_TYPE_CLASS | 0x03)#define USB_DT_HUB (USB_TYPE_CLASS | 0x09) +#define USB_DT_SS_HUB (USB_TYPE_CLASS | 0x0a)/* Descriptor sizes per descriptor type */ #define USB_DT_DEVICE_SIZE 18
Signature · 1 line
2.9.2
PATCH v3 7/18 usb: hub: Revise wLength for 'get port status' request
In reply to Bin MengFor accuracy, we should use 'sizeof(struct usb_port_status)' as the wLength for 'get port status' request, although it happens to be equal to 'sizeof(struct usb_hub_status)'.
---
Changes in v3: None
Changes in v2: None
common/usb_hub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
common/usb_hub.c +1 -1
@@ -107,7 +107,7 @@ int usb_get_port_status(struct usb_device *dev, int port, void *data) {return usb_control_msg (dev,usb_rcvctrlpipe (dev,0 ),USB_REQ_GET_STATUS ,USB_DIR_IN |USB_RT_PORT ,0 , port, - data,sizeof (struct usb_hub_status ),USB_CNTL_TIMEOUT ); + data,sizeof (struct usb_port_status ),USB_CNTL_TIMEOUT ); }
Signature · 1 line
2.9.2
PATCH v3 8/18 usb: hub: Change USB hub descriptor to match USB 3.0 hubs
In reply to Bin MengUSB 3.0 hubs have a slightly different hub descriptor than USB 2.0 hubs, with a fixed (rather than variable length) size. Change the host controller drivers that access those last two fields (DeviceRemovable and PortPowerCtrlMask) to use the union.
---
Changes in v3: None
Changes in v2: None
common/usb_hub.c | 12 +++++++----- drivers/usb/emul/sandbox_hub.c | 7 ++++++- drivers/usb/host/ehci-hcd.c | 4 ++-- drivers/usb/host/xhci.c | 4 ++-- include/usb.h | 18 ++++++++++++++---- 5 files changed, 31 insertions(+), 14 deletions(-)
common/usb_hub.c +7 -5
@@ -583,17 +583,19 @@ static int usb_hub_configure(struct usb_device *dev) &descriptor->wHubCharacteristics)), &hub->desc.wHubCharacteristics);/* set the bitmap */ - bitmap = (unsigned char *)&hub->desc.DeviceRemovable[0 ]; + bitmap = (unsigned char *)&hub->desc.u.hs.DeviceRemovable[0 ];/* devices not removable by default */ memset (bitmap,0xff , (USB_MAXCHILDREN +1 +7 )/8 ); - bitmap = (unsigned char *)&hub->desc.PortPowerCtrlMask[0 ]; + bitmap = (unsigned char *)&hub->desc.u.hs.PortPowerCtrlMask[0 ];memset (bitmap,0xff , (USB_MAXCHILDREN +1 +7 )/8 );/* PowerMask = 1B */ for (i =0 ; i < ((hub->desc.bNbrPorts +1 +7 )/8 ); i++) - hub->desc.DeviceRemovable[i] = descriptor->DeviceRemovable[i]; + hub->desc.u.hs.DeviceRemovable[i] = + descriptor->u.hs.DeviceRemovable[i];for (i =0 ; i < ((hub->desc.bNbrPorts +1 +7 )/8 ); i++) - hub->desc.PortPowerCtrlMask[i] = descriptor->PortPowerCtrlMask[i]; + hub->desc.u.hs.PortPowerCtrlMask[i] = + descriptor->u.hs.PortPowerCtrlMask[i]; dev->maxchild = descriptor->bNbrPorts;debug ("%d ports detected\n" , dev->maxchild);
@@ -637,7 +639,7 @@ static int usb_hub_configure(struct usb_device *dev)for (i =0 ; i < dev->maxchild; i++)debug ("port %d is%s removable\n" , i +1 , - hub->desc.DeviceRemovable[(i +1 ) /8 ] & \ + hub->desc.u.hs.DeviceRemovable[(i +1 ) /8 ] & \ (1 << ((i +1 ) %8 )) ?" not" :"" );if (sizeof (struct usb_hub_status ) >USB_BUFSIZ ) {
drivers/usb/emul/sandbox_hub.c +6 -1
@@ -96,7 +96,12 @@ static struct usb_hub_descriptor hub_desc = { 1 << 7), .bPwrOn2PwrGood = 2, .bHubContrCurrent = 5, - .DeviceRemovable = {0, 0xff}, /* all ports removeable */ + { + { +/* all ports removeable */ + .DeviceRemovable = {0, 0xff} + } + }#if SANDBOX_NUM_PORTS >8 #error "This code sets up an incorrect mask"#endif
drivers/usb/host/ehci-hcd.c +2 -2
@@ -52,8 +52,8 @@ static struct descriptor {0 ,/* wHubCharacteristics */ 10 ,/* bPwrOn2PwrGood */ 0 ,/* bHubCntrCurrent */ - {}, /* Device removable */ - {} /* at most 7 ports! XXX */ + { /* Device removable */ + } /* at most 7 ports! XXX */ }, { 0x12, /* bLength */
drivers/usb/host/xhci.c +2 -2
@@ -50,8 +50,8 @@ static struct descriptor {cpu_to_le16 (0x8 ),/* wHubCharacteristics */ 10 ,/* bPwrOn2PwrGood */ 0 ,/* bHubCntrCurrent */ - {}, /* Device removable */ - {} /* at most 7 ports! XXX */ + { /* Device removable */ + } /* at most 7 ports! XXX */ }, { 0x12, /* bLength */
include/usb.h +14 -4
@@ -546,10 +546,20 @@ struct usb_hub_descriptor {unsigned short wHubCharacteristics;unsigned char bPwrOn2PwrGood;unsigned char bHubContrCurrent; -unsigned char DeviceRemovable[(USB_MAXCHILDREN +1 +7 )/8 ]; -unsigned char PortPowerCtrlMask[(USB_MAXCHILDREN +1 +7 )/8 ]; -/* DeviceRemovable and PortPwrCtrlMask want to be variable-length -bitmaps that hold max 255 entries. (bit0 is ignored) */ +/* 2.0 and 3.0 hubs differ here */ +union { +struct { +/* add 1 bit for hub status change; round to bytes */ +__u8 DeviceRemovable[(USB_MAXCHILDREN +1 +7 ) /8 ]; +__u8 PortPowerCtrlMask[(USB_MAXCHILDREN +1 +7 ) /8 ]; + } __attribute__ ((packed)) hs; + +struct { +__u8 bHubHdrDecLat; +__le16 wHubDelay; +__le16 DeviceRemovable; + } __attribute__ ((packed)) ss; + } u; } __attribute__ ((packed));
Signature · 1 line
2.9.2
PATCH v3 9/18 usb: hub: Add 3.0 hub port status mask of 2.0 hub
In reply to Bin MengUSB 3.0 hub port status has different bit position regarding to port power, port speed, etc. But others are the same as 2.0 hubs.
---
Changes in v3: None
Changes in v2: None
include/usb_defs.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
include/usb_defs.h +6 -1
@@ -262,12 +262,17 @@/* * Changes to wPortStatus bit field in USB 3.0 -* See USB 3.0 spec Table 10-11 +* See USB 3.0 spec Table 10-10 */ #define USB_SS_PORT_STAT_LINK_STATE 0x01e0#define USB_SS_PORT_STAT_POWER 0x0200#define USB_SS_PORT_STAT_SPEED 0x1c00#define USB_SS_PORT_STAT_SPEED_5GBPS 0x0000 +/* Bits that are the same from USB 2.0 */ +#define USB_SS_PORT_STAT_MASK (USB_PORT_STAT_CONNECTION | \ + USB_PORT_STAT_ENABLE | \ + USB_PORT_STAT_OVERCURRENT | \ + USB_PORT_STAT_RESET)/* wPortChange bits */ #define USB_PORT_STAT_C_CONNECTION 0x0001
Signature · 1 line
2.9.2
PATCH v3 10/18 usb: xhci: Change MAX_HC_PORTS to 255
In reply to Bin MengHCSPARAMS1:MaxPorts field specifies the maximum port number value, and its valid values are in the range of 1 to 255.
---
Changes in v3: None
Changes in v2: None
drivers/usb/host/xhci.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/usb/host/xhci.h +3 -3
@@ -30,7 +30,7 @@/* Max number of USB devices for any host controller - limit in section 6.1 */ #define MAX_HC_SLOTS 256/* Section 5.3.3 - MaxPorts */ -#define MAX_HC_PORTS 127 +#define MAX_HC_PORTS 255/* Up to 16 ms to halt an HC */ #define XHCI_MAX_HALT_USEC (16*1000)
@@ -102,8 +102,8 @@ struct xhci_hccr {#define HCS_MAX_INTRS (p) (((p) >> 8) & 0x7ff)/* bits 24:31, Max Ports - max value is 0x7F = 127 ports */ #define HCS_MAX_PORTS_SHIFT 24 -#define HCS_MAX_PORTS_MASK (0x7f << HCS_MAX_PORTS_SHIFT) -#define HCS_MAX_PORTS (p) (((p) >> 24) & 0x7f) +#define HCS_MAX_PORTS_MASK (0xff << HCS_MAX_PORTS_SHIFT) +#define HCS_MAX_PORTS (p) (((p) >> 24) & 0xff)/* HCSPARAMS2 - hcs_params2 - bitmasks */ /* bits 0:3, frames or uframes that SW needs to queue transactions
Signature · 1 line
2.9.2
PATCH v3 11/18 usb: xhci: Get rid of CONFIG_SYS_USB_XHCI_MAX_ROOT_PORTS
In reply to Bin MengxHC reports supported maximum number of ports in the HCSPARAMS1 register, so it's unnecessary to use a hardcoded config option CONFIG_SYS_USB_XHCI_MAX_ROOT_PORTS.
---
Changes in v3: None
Changes in v2: None
drivers/usb/host/xhci.c | 8 +++++--- drivers/usb/host/xhci.h | 4 +--- 2 files changed, 6 insertions(+), 6 deletions(-)
drivers/usb/host/xhci.c +5 -3
@@ -668,12 +668,14 @@ static int xhci_submit_root(struct usb_device *udev, unsigned long pipe,uint32_t reg;volatile uint32_t *status_reg;struct xhci_ctrl *ctrl =xhci_get_ctrl (udev); +struct xhci_hccr *hccr = ctrl->hccr;struct xhci_hcor *hcor = ctrl->hcor; +int max_ports =HCS_MAX_PORTS (xhci_readl (&hccr->cr_hcsparams1));if ((req->requesttype &USB_RT_PORT ) && -le16_to_cpu (req->index) >CONFIG_SYS_USB_XHCI_MAX_ROOT_PORTS ) { -printf ("The request port(%d) is not configured\n" , -le16_to_cpu (req->index) -1 ); +le16_to_cpu (req->index) > max_ports) { +printf ("The request port(%d) exceeds maximum port number\n" , +le16_to_cpu (req->index) -1 );return -EINVAL ; }
drivers/usb/host/xhci.h +1 -3
@@ -172,9 +172,7 @@ struct xhci_hcor {volatile uint64_t or_dcbaap;volatile uint32_t or_config;volatile uint32_t reserved_2[241 ]; -struct xhci_hcor_port_regs portregs[CONFIG_SYS_USB_XHCI_MAX_ROOT_PORTS ]; - -uint32_t reserved_4[CONFIG_SYS_USB_XHCI_MAX_ROOT_PORTS *254 ]; +struct xhci_hcor_port_regs portregs[MAX_HC_PORTS ]; };/* USBCMD - USB command - command bitmasks */
Signature · 1 line
2.9.2
PATCH v3 12/18 configs: Remove CONFIG_SYS_USB_XHCI_MAX_ROOT_PORTS in all boards
In reply to Bin MengNow that xHCD does not use CONFIG_SYS_USB_XHCI_MAX_ROOT_PORTS, remove it in all boards' config files.
---
Changes in v3: None
Changes in v2: None
include/configs/am43xx_evm.h | 1 - include/configs/am57xx_evm.h | 1 - include/configs/cl-som-am57x.h | 1 - include/configs/cm_t43.h | 1 - include/configs/dra7xx_evm.h | 1 - include/configs/ds414.h | 1 - include/configs/exynos5-common.h | 1 - include/configs/ls1012afrdm.h | 1 - include/configs/ls1012aqds.h | 1 - include/configs/ls1012ardb.h | 1 - include/configs/ls1021aiot.h | 1 - include/configs/ls1021aqds.h | 1 - include/configs/ls1021atwr.h | 1 - include/configs/ls1043aqds.h | 1 - include/configs/ls1043ardb.h | 1 - include/configs/ls1046aqds.h | 1 - include/configs/ls1046ardb.h | 1 - include/configs/ls2080aqds.h | 1 - include/configs/ls2080ardb.h | 1 - include/configs/mvebu_armada-37xx.h | 4 +--- include/configs/mvebu_armada-8k.h | 4 +--- include/configs/rk3328_common.h | 2 -- include/configs/rk3399_common.h | 3 --- include/configs/ti_armv7_keystone2.h | 1 - include/configs/uniphier.h | 3 --- include/configs/xilinx_zynqmp.h | 2 -- scripts/config_whitelist.txt | 1 - 27 files changed, 2 insertions(+), 37 deletions(-)
include/configs/am43xx_evm.h +0 -1
@@ -83,7 +83,6 @@#if defined(CONFIG_SPL_USB_HOST_SUPPORT ) || !defined(CONFIG_SPL_BUILD )#define CONFIG_SYS_USB_FAT_BOOT_PARTITION 1#define CONFIG_USB_XHCI_OMAP -#define CONFIG_SYS_USB_XHCI_MAX_ROOT_PORTS 2#define CONFIG_OMAP_USB_PHY #define CONFIG_AM437X_USB2PHY2_HOST
include/configs/am57xx_evm.h +0 -1
@@ -93,7 +93,6 @@/* USB xHCI HOST */ #define CONFIG_USB_XHCI_OMAP -#define CONFIG_SYS_USB_XHCI_MAX_ROOT_PORTS 2#define CONFIG_OMAP_USB_PHY #define CONFIG_OMAP_USB3PHY1_HOST
include/configs/cl-som-am57x.h +0 -1
@@ -84,7 +84,6 @@/* USB xHCI HOST */ #define CONFIG_USB_XHCI_OMAP -#define CONFIG_SYS_USB_XHCI_MAX_ROOT_PORTS 2#define CONFIG_OMAP_USB_PHY #define CONFIG_OMAP_USB3PHY1_HOST
include/configs/cm_t43.h +0 -1
@@ -60,7 +60,6 @@/* USB support */ #define CONFIG_USB_XHCI_OMAP -#define CONFIG_SYS_USB_XHCI_MAX_ROOT_PORTS 2#define CONFIG_OMAP_USB_PHY #define CONFIG_AM437X_USB2PHY2_HOST
include/configs/dra7xx_evm.h +0 -1
@@ -156,7 +156,6 @@/* USB xHCI HOST */ #define CONFIG_USB_XHCI_OMAP -#define CONFIG_SYS_USB_XHCI_MAX_ROOT_PORTS 2#define CONFIG_OMAP_USB_PHY #define CONFIG_OMAP_USB2PHY2_HOST
include/configs/ds414.h +0 -1
@@ -69,7 +69,6 @@#if 0 #undef CONFIG_DM_USB#define CONFIG_USB_XHCI_PCI -#define CONFIG_SYS_USB_XHCI_MAX_ROOT_PORTS 2#endif #if !defined(CONFIG_USB_XHCI_HCD )
include/configs/exynos5-common.h +0 -1
@@ -135,7 +135,6 @@/* USB */ #define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS 3 -#define CONFIG_SYS_USB_XHCI_MAX_ROOT_PORTS 2#define CONFIG_USB_HOST_ETHER #define CONFIG_USB_ETHER_ASIX
include/configs/ls1012afrdm.h +0 -1
@@ -39,7 +39,6 @@#ifdef CONFIG_HAS_FSL_XHCI_USB #define CONFIG_USB_XHCI_FSL #define CONFIG_USB_MAX_CONTROLLER_COUNT 1 -#define CONFIG_SYS_USB_XHCI_MAX_ROOT_PORTS 2#endif #define CONFIG_CMD_MEMINFO
include/configs/ls1012aqds.h +0 -1
@@ -124,7 +124,6 @@#ifdef CONFIG_HAS_FSL_XHCI_USB #define CONFIG_USB_XHCI_FSL #define CONFIG_USB_MAX_CONTROLLER_COUNT 1 -#define CONFIG_SYS_USB_XHCI_MAX_ROOT_PORTS 2#endif /* MMC */
include/configs/ls1012ardb.h +0 -1
@@ -27,7 +27,6 @@#ifdef CONFIG_HAS_FSL_XHCI_USB #define CONFIG_USB_XHCI_FSL #define CONFIG_USB_MAX_CONTROLLER_COUNT 1 -#define CONFIG_SYS_USB_XHCI_MAX_ROOT_PORTS 2#endif /*
include/configs/ls1021aiot.h +0 -1
@@ -26,7 +26,6 @@#define CONFIG_USB_XHCI_FSL #define CONFIG_USB_XHCI_DWC3 #define CONFIG_USB_MAX_CONTROLLER_COUNT 1 -#define CONFIG_SYS_USB_XHCI_MAX_ROOT_PORTS 2#endif #if defined(CONFIG_HAS_FSL_DR_USB ) || defined(CONFIG_HAS_FSL_XHCI_USB )
include/configs/ls1021aqds.h +0 -1
@@ -413,7 +413,6 @@ unsigned long get_board_ddr_clk(void);#ifdef CONFIG_HAS_FSL_XHCI_USB #define CONFIG_USB_XHCI_FSL #define CONFIG_USB_MAX_CONTROLLER_COUNT 1 -#define CONFIG_SYS_USB_XHCI_MAX_ROOT_PORTS 2#endif /*
include/configs/ls1021atwr.h +0 -1
@@ -50,7 +50,6 @@#ifdef CONFIG_HAS_FSL_XHCI_USB #define CONFIG_USB_XHCI_FSL #define CONFIG_USB_MAX_CONTROLLER_COUNT 1 -#define CONFIG_SYS_USB_XHCI_MAX_ROOT_PORTS 2#endif #define CONFIG_SYS_CLK_FREQ 100000000
include/configs/ls1043aqds.h +0 -1
@@ -378,7 +378,6 @@ unsigned long get_board_ddr_clk(void);#ifdef CONFIG_HAS_FSL_XHCI_USB #define CONFIG_USB_XHCI_FSL #define CONFIG_USB_MAX_CONTROLLER_COUNT 3 -#define CONFIG_SYS_USB_XHCI_MAX_ROOT_PORTS 2#endif /*
include/configs/ls1043ardb.h +0 -1
@@ -291,7 +291,6 @@#ifdef CONFIG_HAS_FSL_XHCI_USB #define CONFIG_USB_XHCI_FSL #define CONFIG_USB_MAX_CONTROLLER_COUNT 3 -#define CONFIG_SYS_USB_XHCI_MAX_ROOT_PORTS 2#endif #endif
include/configs/ls1046aqds.h +0 -1
@@ -144,7 +144,6 @@ unsigned long get_board_ddr_clk(void);#define CONFIG_USB_XHCI_FSL #define CONFIG_USB_XHCI_DWC3 #define CONFIG_USB_MAX_CONTROLLER_COUNT 3 -#define CONFIG_SYS_USB_XHCI_MAX_ROOT_PORTS 2#define CONFIG_CMD_USB #define CONFIG_USB_STORAGE #endif
include/configs/ls1046ardb.h +0 -1
@@ -222,7 +222,6 @@#define CONFIG_USB_XHCI_FSL #define CONFIG_USB_XHCI_DWC3 #define CONFIG_USB_MAX_CONTROLLER_COUNT 3 -#define CONFIG_SYS_USB_XHCI_MAX_ROOT_PORTS 2#define CONFIG_CMD_USB #define CONFIG_USB_STORAGE #endif
include/configs/ls2080aqds.h +0 -1
@@ -450,7 +450,6 @@ unsigned long get_board_ddr_clk(void);#define CONFIG_HAS_FSL_XHCI_USB #define CONFIG_USB_XHCI_FSL #define CONFIG_USB_MAX_CONTROLLER_COUNT 2 -#define CONFIG_SYS_USB_XHCI_MAX_ROOT_PORTS 2#include <asm/fsl_secure_boot.h>
include/configs/ls2080ardb.h +0 -1
@@ -349,7 +349,6 @@ unsigned long get_board_sys_clk(void);#define CONFIG_HAS_FSL_XHCI_USB #define CONFIG_USB_XHCI_FSL #define CONFIG_USB_MAX_CONTROLLER_COUNT 2 -#define CONFIG_SYS_USB_XHCI_MAX_ROOT_PORTS 2#undef CONFIG_CMDLINE_EDITING#include <config_distro_defaults.h>
include/configs/mvebu_armada-37xx.h +1 -3
@@ -98,10 +98,8 @@#define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS 3/* USB 3.0 */ -#define CONFIG_SYS_USB_XHCI_MAX_ROOT_PORTS 3 -#define CONFIG_USB_MAX_CONTROLLER_COUNT (CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS + \ - CONFIG_SYS_USB_XHCI_MAX_ROOT_PORTS) + 3)/* USB ethernet */ #define CONFIG_USB_HOST_ETHER
include/configs/mvebu_armada-8k.h +1 -3
@@ -104,10 +104,8 @@#define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS 3/* USB 3.0 */ -#define CONFIG_SYS_USB_XHCI_MAX_ROOT_PORTS 3 -#define CONFIG_USB_MAX_CONTROLLER_COUNT (CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS + \ - CONFIG_SYS_USB_XHCI_MAX_ROOT_PORTS) + 3)/* USB ethernet */ #define CONFIG_USB_HOST_ETHER
include/configs/rk3328_common.h +0 -2
@@ -63,6 +63,4 @@#define CONFIG_USB_OHCI_NEW #define CONFIG_SYS_USB_OHCI_MAX_ROOT_PORTS 1 -/* xhci host */ -#define CONFIG_SYS_USB_XHCI_MAX_ROOT_PORTS 2#endif
include/configs/rk3399_common.h +0 -3
@@ -82,7 +82,4 @@#define CONFIG_USB_ETHER_SMSC95XX #define CONFIG_USB_ETHER_RTL8152 -/* rockchip xhci host driver */ -#define CONFIG_SYS_USB_XHCI_MAX_ROOT_PORTS 2 -#endif
include/configs/ti_armv7_keystone2.h +0 -1
@@ -195,7 +195,6 @@/* USB Configuration */ #define CONFIG_USB_XHCI_KEYSTONE -#define CONFIG_SYS_USB_XHCI_MAX_ROOT_PORTS 2#define CONFIG_USB_SS_BASE KS2_USB_SS_BASE#define CONFIG_USB_HOST_XHCI_BASE KS2_USB_HOST_XHCI_BASE#define CONFIG_DEV_USB_PHY_BASE KS2_DEV_USB_PHY_BASE
include/configs/uniphier.h +0 -3
@@ -114,9 +114,6 @@#define CONFIG_SYS_NAND_USE_FLASH_BBT #define CONFIG_SYS_NAND_BAD_BLOCK_POS 0 -/* USB */ -#define CONFIG_SYS_USB_XHCI_MAX_ROOT_PORTS 4 -/* SD/MMC */ #define CONFIG_SUPPORT_EMMC_BOOT
include/configs/xilinx_zynqmp.h +0 -2
@@ -91,8 +91,6 @@#define CONFIG_SYS_LOAD_ADDR 0x8000000#if defined(CONFIG_ZYNQMP_USB ) -#define CONFIG_SYS_USB_XHCI_MAX_ROOT_PORTS 2 -#define CONFIG_SYS_DFU_DATA_BUF_SIZE 0x1800000#define DFU_DEFAULT_POLL_TIMEOUT 300#define CONFIG_USB_CABLE_CHECK
scripts/config_whitelist.txt +0 -1
@@ -4891,7 +4891,6 @@ CONFIG_SYS_USB_OHCI_CPU_INIT CONFIG_SYS_USB_OHCI_MAX_ROOT_PORTS CONFIG_SYS_USB_OHCI_REGS_BASE CONFIG_SYS_USB_OHCI_SLOT_NAME -CONFIG_SYS_USB_XHCI_MAX_ROOT_PORTS CONFIG_SYS_USER_SWITCHES_BASE CONFIG_SYS_USE_BOOT_NORFLASH CONFIG_SYS_USE_DATAFLASH
Signature · 1 line
2.9.2
PATCH v3 13/18 usb: ehci: Get rid of CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS
In reply to Bin MengEHC reports supported maximum number of ports in the HCSPARAMS register, so it's unnecessary to use a hardcoded config option CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS.
---
Changes in v3: None
Changes in v2: None
drivers/usb/host/ehci-hcd.c | 10 +++++++--- drivers/usb/host/ehci.h | 7 +++---- 2 files changed, 10 insertions(+), 7 deletions(-)
drivers/usb/host/ehci-hcd.c +7 -3
@@ -148,9 +148,12 @@ static void ehci_powerup_fixup(struct ehci_ctrl *ctrl, uint32_t *status_reg,static uint32_t *ehci_get_portsc_register (struct ehci_ctrl *ctrl,int port) { -if (port <0 || port >=CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS ) { +int max_ports =HCS_N_PORTS (ehci_readl (&ctrl->hccr->cr_hcsparams)); + +if (port <0 || port >= max_ports) {/* Printing the message would cause a scan failure! */ -debug ("The request port(%u) is not configured\n" , port); +debug ("The request port(%u) exceeds maximum port number\n" , + port);return NULL ; }
@@ -205,6 +208,7 @@ static int ehci_shutdown(struct ehci_ctrl *ctrl) {int i, ret =0 ;uint32_t cmd, reg; +int max_ports =HCS_N_PORTS (ehci_readl (&ctrl->hccr->cr_hcsparams));if (!ctrl || !ctrl->hcor)return -EINVAL ;
@@ -219,7 +223,7 @@ static int ehci_shutdown(struct ehci_ctrl *ctrl) 100 * 1000);if (!ret) { -for (i =0 ; i <CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS ; i++) { +for (i =0 ; i < max_ports; i++) { reg =ehci_readl (&ctrl->hcor->or_portsc[i]); reg |=EHCI_PS_SUSP ;ehci_writel (&ctrl->hcor->or_portsc[i], reg);
drivers/usb/host/ehci.h +3 -4
@@ -11,9 +11,8 @@#include <usb.h> -#if !defined(CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS ) -#define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS 2 -#endif +/* Section 2.2.3 - N_PORTS */ +#define MAX_HC_PORTS 15/* * Register Space.
@@ -62,7 +61,7 @@ struct ehci_hcor {uint32_t _reserved_1_[6 ];uint32_t or_configflag;#define FLAG_CF (1 << 0)/* true: we'll support "high speed" */ -uint32_t or_portsc[CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS ]; +uint32_t or_portsc[MAX_HC_PORTS ];#define PORTSC_PSPD (x) (((x) >> 26) & 0x3)#define PORTSC_PSPD_FS 0x0#define PORTSC_PSPD_LS 0x1
Signature · 1 line
2.9.2
PATCH v3 14/18 configs: Remove CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS in all boards
In reply to Bin MengNow that EHCD does not use CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS, remove it in all boards' config files.
---
Changes in v3: None
Changes in v2: None
arch/arm/include/asm/ehci-omap.h | 4 ---- include/configs/MPC8572DS.h | 1 - include/configs/cm_t54.h | 1 - include/configs/corvus.h | 3 --- include/configs/duovero.h | 2 -- include/configs/exynos5-common.h | 2 -- include/configs/ma5d4evk.h | 1 - include/configs/mcx.h | 1 - include/configs/mvebu_armada-37xx.h | 7 +------ include/configs/mvebu_armada-8k.h | 7 +------ include/configs/mx35pdk.h | 1 - include/configs/odroid.h | 1 - include/configs/omap3_beagle.h | 1 - include/configs/omap3_overo.h | 1 - include/configs/omap4_panda.h | 2 -- include/configs/omap5_uevm.h | 1 - include/configs/picosam9g45.h | 3 --- include/configs/sama5d2_ptc.h | 4 ---- include/configs/snapper9g45.h | 3 --- include/configs/sunxi-common.h | 1 - include/configs/tam3517-common.h | 1 - include/configs/tao3530.h | 1 - include/configs/tegra114-common.h | 1 - include/configs/tegra124-common.h | 1 - include/configs/tegra20-common.h | 1 - include/configs/tegra210-common.h | 1 - include/configs/tegra30-common.h | 1 - include/configs/vinco.h | 6 ------ include/configs/x86-common.h | 1 - scripts/config_whitelist.txt | 1 - 30 files changed, 2 insertions(+), 60 deletions(-)
arch/arm/include/asm/ehci-omap.h +0 -4
@@ -19,11 +19,7 @@ enum usbhs_omap_port_mode { OMAP_EHCI_PORT_MODE_HSIC, }; -#ifdef CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS -#define OMAP_HS_USB_PORTS CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS -#else #define OMAP_HS_USB_PORTS 3 -#endif #define is_ehci_phy_mode (x) ((x) == OMAP_EHCI_PORT_MODE_PHY)#define is_ehci_tll_mode (x) ((x) == OMAP_EHCI_PORT_MODE_TLL)
include/configs/MPC8572DS.h +0 -1
@@ -562,7 +562,6 @@#define CONFIG_USB_EHCI_PCI #define CONFIG_EHCI_HCD_INIT_AFTER_RESET #define CONFIG_PCI_EHCI_DEVICE 0 -#define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS 2#endif #undef CONFIG_WATCHDOG/* watchdog disabled */
include/configs/cm_t54.h +0 -1
@@ -58,7 +58,6 @@#define CONFIG_SYS_SCSI_MAX_DEVICE (CONFIG_SYS_SCSI_MAX_SCSI_ID * \ CONFIG_SYS_SCSI_MAX_LUN)/* USB UHH support options */ -#define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS 3#define CONFIG_EHCI_HCD_INIT_AFTER_RESET #define CONFIG_OMAP_EHCI_PHY2_RESET_GPIO 76/* HSIC2 HUB #RESET */
include/configs/corvus.h +0 -3
@@ -94,9 +94,6 @@#define CONFIG_NET_RETRY_COUNT 20#define CONFIG_AT91_WANTS_COMMON_PHY -/* USB */ -#define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS 2 -/* USB DFU support */ #define CONFIG_CMD_MTDPARTS #define CONFIG_MTD_DEVICE
include/configs/duovero.h +0 -2
@@ -25,8 +25,6 @@#define CONFIG_SYS_DEFAULT_LPDDR2_TIMINGS /* USB UHH support options */ -#define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS 3 -#define CONFIG_OMAP_EHCI_PHY1_RESET_GPIO 1#define CONFIG_OMAP_EHCI_PHY2_RESET_GPIO 62
include/configs/exynos5-common.h +0 -2
@@ -134,8 +134,6 @@/* Enable Time Command */ /* USB */ -#define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS 3 -#define CONFIG_USB_HOST_ETHER #define CONFIG_USB_ETHER_ASIX #define CONFIG_USB_ETHER_SMSC95XX
include/configs/ma5d4evk.h +0 -1
@@ -97,7 +97,6 @@* USB */ #ifdef CONFIG_CMD_USB -#define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS 3/* USB device */ #define CONFIG_USB_ETHER
include/configs/mcx.h +0 -1
@@ -74,7 +74,6 @@/* EHCI */ #define CONFIG_OMAP_EHCI_PHY1_RESET_GPIO 57 -#define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS 3#define CONFIG_USB_HOST_ETHER #define CONFIG_USB_ETHER_ASIX #define CONFIG_USB_ETHER_MCS7830
include/configs/mvebu_armada-37xx.h +1 -6
@@ -94,12 +94,7 @@#define CONFIG_NET_RETRY_COUNT 50#define CONFIG_PHY_MARVELL -/* USB 2.0 */ -#define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS 3 - -/* USB 3.0 */ -#define CONFIG_USB_MAX_CONTROLLER_COUNT (CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS + \ - 3) +#define CONFIG_USB_MAX_CONTROLLER_COUNT (3 + 3)/* USB ethernet */ #define CONFIG_USB_HOST_ETHER
include/configs/mvebu_armada-8k.h +1 -6
@@ -100,12 +100,7 @@#define CONFIG_ARP_TIMEOUT 200#define CONFIG_NET_RETRY_COUNT 50 -/* USB 2.0 */ -#define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS 3 - -/* USB 3.0 */ -#define CONFIG_USB_MAX_CONTROLLER_COUNT (CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS + \ - 3) +#define CONFIG_USB_MAX_CONTROLLER_COUNT (3 + 3)/* USB ethernet */ #define CONFIG_USB_HOST_ETHER
include/configs/mx35pdk.h +0 -1
@@ -199,7 +199,6 @@#define CONFIG_SYS_NAND_LARGEPAGE /* EHCI driver */ -#define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS 1#define CONFIG_EHCI_IS_TDI #define CONFIG_EHCI_HCD_INIT_AFTER_RESET #define CONFIG_USB_EHCI_MXC
include/configs/odroid.h +0 -1
@@ -185,7 +185,6 @@/* USB */ #define CONFIG_USB_EHCI_EXYNOS -#define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS 3#define CONFIG_USB_HOST_ETHER #define CONFIG_USB_ETHER_SMSC95XX
include/configs/omap3_beagle.h +0 -1
@@ -58,7 +58,6 @@#define CONFIG_OMAP_EHCI_PHY1_RESET_GPIO 147 -#define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS 3#define CONFIG_USB_HOST_ETHER #define CONFIG_USB_ETHER_ASIX #define CONFIG_USB_ETHER_MCS7830
include/configs/omap3_overo.h +0 -1
@@ -41,7 +41,6 @@/* USB EHCI */ #define CONFIG_OMAP_EHCI_PHY1_RESET_GPIO 183 -#define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS 3/* commands to include */
include/configs/omap4_panda.h +0 -2
@@ -17,8 +17,6 @@*/ /* USB UHH support options */ -#define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS 3 -#define CONFIG_OMAP_EHCI_PHY1_RESET_GPIO 1#define CONFIG_OMAP_EHCI_PHY2_RESET_GPIO 62
include/configs/omap5_uevm.h +0 -1
@@ -52,7 +52,6 @@#define CONFIG_SYS_I2C_TCA642X_ADDR 0x22/* USB UHH support options */ -#define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS 3#define CONFIG_EHCI_HCD_INIT_AFTER_RESET #define CONFIG_OMAP_EHCI_PHY2_RESET_GPIO 80
include/configs/picosam9g45.h +0 -3
@@ -97,9 +97,6 @@#define CONFIG_RESET_PHY_R #define CONFIG_AT91_WANTS_COMMON_PHY -/* USB */ -#define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS 2 -#define CONFIG_SYS_LOAD_ADDR 0x22000000/* load address */ #define CONFIG_SYS_MEMTEST_START CONFIG_SYS_SDRAM_BASE
include/configs/sama5d2_ptc.h +0 -4
@@ -65,10 +65,6 @@/* USB */ #define CONFIG_CMD_USB -#ifdef CONFIG_CMD_USB -#define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS 3 -#endif -/* USB device */ #define CONFIG_USB_GADGET #define CONFIG_USB_GADGET_DUALSPEED
include/configs/snapper9g45.h +0 -3
@@ -60,9 +60,6 @@#define CONFIG_TFTP_PORT #define CONFIG_TFTP_TSIZE -/* USB */ -#define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS 2 -/* MMC */ #define CONFIG_GENERIC_ATMEL_MCI
include/configs/sunxi-common.h +0 -1
@@ -311,7 +311,6 @@ extern int soft_i2c_gpio_scl;#define CONFIG_USB_OHCI_NEW #define CONFIG_USB_OHCI_SUNXI #define CONFIG_SYS_USB_OHCI_MAX_ROOT_PORTS 1 -#define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS 1#endif #ifdef CONFIG_USB_MUSB_SUNXI
include/configs/tam3517-common.h +0 -1
@@ -67,7 +67,6 @@ 115200}/* EHCI */ #define CONFIG_OMAP_EHCI_PHY1_RESET_GPIO 25 -#define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS 3/* commands to include */ #define CONFIG_CMD_NAND /* NAND support */
include/configs/tao3530.h +0 -1
@@ -230,7 +230,6 @@/* USB EHCI */ #define CONFIG_OMAP_EHCI_PHY1_RESET_GPIO 162 -#define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS 3#define CONFIG_USB_HOST_ETHER #define CONFIG_USB_ETHER_SMSC95XX
include/configs/tegra114-common.h +0 -1
@@ -63,6 +63,5 @@/* For USB EHCI controller */ #define CONFIG_EHCI_IS_TDI #define CONFIG_USB_EHCI_TXFIFO_THRESH 0x10 -#define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS 1#endif /* _TEGRA114_COMMON_H_ */
include/configs/tegra124-common.h +0 -1
@@ -65,7 +65,6 @@/* For USB EHCI controller */ #define CONFIG_EHCI_IS_TDI #define CONFIG_USB_EHCI_TXFIFO_THRESH 0x10 -#define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS 1/* GPU needs setup */ #define CONFIG_TEGRA_GPU
include/configs/tegra20-common.h +0 -1
@@ -82,7 +82,6 @@*/ #define CONFIG_USB_EHCI_TXFIFO_THRESH 10#define CONFIG_EHCI_IS_TDI -#define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS 1#define CONFIG_SYS_NAND_SELF_INIT #define CONFIG_SYS_NAND_ONFI_DETECTION
include/configs/tegra210-common.h +0 -1
@@ -68,7 +68,6 @@/* For USB EHCI controller */ #define CONFIG_EHCI_IS_TDI #define CONFIG_USB_EHCI_TXFIFO_THRESH 0x10 -#define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS 1/* GPU needs setup */ #define CONFIG_TEGRA_GPU
include/configs/tegra30-common.h +0 -1
@@ -64,6 +64,5 @@/* For USB EHCI controller */ #define CONFIG_EHCI_IS_TDI #define CONFIG_USB_EHCI_TXFIFO_THRESH 0x10 -#define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS 1#endif /* _TEGRA30_COMMON_H_ */
include/configs/vinco.h +0 -6
@@ -63,12 +63,6 @@#endif -/* USB */ - -#ifdef CONFIG_CMD_USB -#define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS 3 -#endif -/* USB device */ #define CONFIG_USB_ETHER #define CONFIG_USB_ETH_RNDIS
include/configs/x86-common.h +0 -1
@@ -131,7 +131,6 @@* USB configuration */ #define CONFIG_USB_EHCI_PCI -#define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS 12#define CONFIG_SYS_USB_EVENT_POLL #define CONFIG_USB_HOST_ETHER
scripts/config_whitelist.txt +0 -1
@@ -4882,7 +4882,6 @@ CONFIG_SYS_UNSPEC_STRID CONFIG_SYS_USBCTRL CONFIG_SYS_USBD_BASE CONFIG_SYS_USB_EHCI_CPU_INIT -CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS CONFIG_SYS_USB_EHCI_REGS_BASE CONFIG_SYS_USB_FAT_BOOT_PARTITION CONFIG_SYS_USB_HOST
Signature · 1 line
2.9.2
PATCH v3 14/18 configs: Remove CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS in all boards
Quoted 35 lines · Bin Meng
Now that EHCD does not use
CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS, remove it in all boards' config files.Signed-off-by Bin Meng <[email protected]>Reviewed-by Simon Glass <[email protected]>Reviewed-by Stefan Roese <[email protected]>Tested-by Stefan Roese <[email protected]>---
Changes in v3: None
Changes in v2: Nonearch/arm/include/asm/ehci-omap.h | 4 ---- include/configs/MPC8572DS.h | 1 - include/configs/cm_t54.h | 1 - include/configs/corvus.h | 3 --- include/configs/duovero.h | 2 -- include/configs/exynos5-common.h | 2 -- include/configs/ma5d4evk.h | 1 - include/configs/mcx.h | 1 - include/configs/mvebu_armada-37xx.h | 7 +------ include/configs/mvebu_armada-8k.h | 7 +------ include/configs/mx35pdk.h | 1 - include/configs/odroid.h | 1 - include/configs/omap3_beagle.h | 1 - include/configs/omap3_overo.h | 1 - include/configs/omap4_panda.h | 2 -- include/configs/omap5_uevm.h | 1 - include/configs/picosam9g45.h | 3 --- include/configs/sama5d2_ptc.h | 4 ---- include/configs/snapper9g45.h | 3 --- include/configs/sunxi-common.h | 1 - include/configs/tam3517-common.h | 1 - include/configs/tao3530.h | 1 - include/configs/tegra114-common.h | 1 -
Quoted 9 lines
include/configs/tegra124-common.h | 1 - include/configs/tegra20-common.h | 1 - include/configs/tegra210-common.h | 1 - include/configs/tegra30-common.h | 1 - include/configs/vinco.h | 6 ------ include/configs/x86-common.h | 1 - scripts/config_whitelist.txt | 1 - 30 files changed, 2 insertions(+), 60 deletions(-)
Ah, this misses poplar board which was brought in before v2017.07 release.
Regards,
Bin
PATCH v3 15/18 usb: cmd: Print actual packet size for super speed devices
In reply to Bin MengUSB 3.0 defines bMaxPacketSize0 field in the device descriptor as the exponent of 2, so let's print the calculated actual size.
---
Changes in v3: None
Changes in v2:
- Change to use uint and also 'normal' variable name packet_size.
cmd/usb.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
cmd/usb.c +5 -2
@@ -150,6 +150,8 @@ static void usb_display_string(struct usb_device *dev, int index)static void usb_display_desc (struct usb_device *dev) { +uint packet_size = dev->descriptor.bMaxPacketSize0; +if (dev->descriptor.bDescriptorType ==USB_DT_DEVICE ) { printf("%d: %s, USB Revision %x.%x\n", dev->devnum, usb_get_class_desc(dev->config.if_desc[0].desc.bInterfaceClass),
@@ -171,9 +173,10 @@ static void usb_display_desc(struct usb_device *dev)usb_get_class_desc ( dev->config.if_desc[0].desc.bInterfaceClass)); } +if (dev->descriptor.bcdUSB >=cpu_to_le16 (0x0300 )) + packet_size =1 << packet_size;printf (" - PacketSize: %d Configurations: %d\n" , - dev->descriptor.bMaxPacketSize0, - dev->descriptor.bNumConfigurations); + packet_size, dev->descriptor.bNumConfigurations); printf(" - Vendor: 0x%04x Product 0x%04x Version %d.%d\n", dev->descriptor.idVendor, dev->descriptor.idProduct, (dev->descriptor.bcdDevice>>8) & 0xff,
Signature · 1 line
2.9.2
PATCH v3 16/18 usb: xhci: Convert CONFIG_USB_XHCI_PCI to Kconfig
In reply to Bin MengAdd CONFIG_USB_XHCI_PCI as a Kconfig option.
---
Changes in v3: None
Changes in v2:
- Update description to use "PCI-based"
- Remove CONFIG_USB_XHCI_PCI from config_whitelist.txt
drivers/usb/host/Kconfig | 6 ++++++ scripts/config_whitelist.txt | 1 - 2 files changed, 6 insertions(+), 1 deletion(-)
drivers/usb/host/Kconfig +6 -0
@@ -31,6 +31,12 @@ config USB_XHCI_MVEBU SoCs, which includes Armada8K, Armada3700 and other Armada family SoCs. +config USB_XHCI_PCI + bool "Support for PCI-based xHCI USB controller" + default y if X86 + help + Enables support for the PCI-based xHCI controller. + config USB_XHCI_ROCKCHIP bool "Support for Rockchip on-chip xHCI USB controller" depends on ARCH_ROCKCHIP
scripts/config_whitelist.txt +0 -1
@@ -5208,7 +5208,6 @@ CONFIG_USB_XHCI_EXYNOS CONFIG_USB_XHCI_FSL CONFIG_USB_XHCI_KEYSTONE CONFIG_USB_XHCI_OMAP -CONFIG_USB_XHCI_PCI CONFIG_USER_LOWLEVEL_INIT CONFIG_USE_FDT CONFIG_USE_INTERRUPT
Signature · 1 line
2.9.2
PATCH v3 17/18 x86: minnowmax: Add a environment variable for USB power-on delay
In reply to Bin MengOccasionally it was observed that on Intel MinnowMax board, with a USB 2.0 device connected to the bottom port, when doing 'usb start' on the xHCI controller:
scanning bus 0 for devices... cannot reset port 3!?
But neither of the two USB ports is routed to xHCI root port 3. Adding some debug information shows that xHCI port 3 PORTSC register mysteriously reports both CCS = 1 and CSC = 1.
This is not seen every time. After increasing the timeout to wait for power to become stable, the issue is gone. So this indicates current default USB power-on delay (20ms) might be at a critical region where power is stable/unstable. U-Boot provides a mechanism to have a environment variable to override the default one. Add one for MinnowMax.
---
Changes in v3: None
Changes in v2: None
include/configs/minnowmax.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
include/configs/minnowmax.h +2 -1
@@ -20,7 +20,8 @@#define CONFIG_STD_DEVICES_SETTINGS "stdin=usbkbd,serial\0" \ "stdout=vidconsole,serial\0" \ - "stderr=vidconsole,serial\0" + "stderr=vidconsole,serial\0" \ + "usb_pgood_delay=40\0"#define CONFIG_SCSI_DEV_LIST \ {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_VALLEYVIEW_SATA}, \
Signature · 1 line
2.9.2
PATCH v3 18/18 x86: minnowmax: Enable USB xHCI support
In reply to Bin MengBayTrail SoC supports both EHCI and xHCI controllers. However only one host controller (either EHCI or xHCI) can be used. To enable HSIC and SS ports, xHCI must be used. This turns on xHCI support on Intel MinnowMax board.
---
Changes in v3:
- Rebase on u-boot/master
Changes in v2:
- Drop two x86 patches that were already applied to u-boot-x86
arch/x86/dts/minnowmax.dts | 3 +++ configs/minnowmax_defconfig | 1 + 2 files changed, 4 insertions(+)
arch/x86/dts/minnowmax.dts +3 -0
@@ -272,6 +272,9 @@ fsp,enable-spi; fsp,enable-sata; fsp,sata-mode = <SATA_MODE_AHCI>; +#ifdef CONFIG_USB_XHCI_HCD + fsp,enable-xhci; +#endif fsp,lpe-mode = <LPE_MODE_PCI>; fsp,lpss-sio-mode = <LPSS_SIO_MODE_PCI>; fsp,enable-dma0;
configs/minnowmax_defconfig +1 -0
@@ -68,6 +68,7 @@ CONFIG_ICH_SPI=y CONFIG_TIMER=y CONFIG_USB=y CONFIG_DM_USB=y +CONFIG_USB_XHCI_HCD=y CONFIG_USB_STORAGE=y CONFIG_USB_KEYBOARD=y CONFIG_DM_VIDEO=y
Signature · 1 line
2.9.2