]> git.ipfire.org Git - people/ms/u-boot.git/commitdiff
usb: xhci: Get rid of CONFIG_SYS_USB_XHCI_MAX_ROOT_PORTS
authorBin Meng <bmeng.cn@gmail.com>
Wed, 19 Jul 2017 13:50:03 +0000 (21:50 +0800)
committerMarek Vasut <marex@denx.de>
Fri, 28 Jul 2017 21:34:22 +0000 (23:34 +0200)
xHC 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.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Stefan Roese <sr@denx.de>
Tested-by: Stefan Roese <sr@denx.de>
drivers/usb/host/xhci.c
drivers/usb/host/xhci.h

index d5a1b3402fec0082809f097fc9bcad495c06cb55..62ab62b31b9195ca84aa5175c3e94e32f4a42497 100644 (file)
@@ -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;
        }
 
index 3cf08e4207baf27f8efd2ee9c565938955bac469..b9602baa747a13798b538c193b3dbb354d8efe1a 100644 (file)
@@ -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 */