| From d3690dac4e91a369c27937ac93dcf9a503ad2ada Mon Sep 17 00:00:00 2001 |
| From: Mathias Nyman <mathias.nyman@linux.intel.com> |
| Date: Thu, 23 May 2013 17:14:29 +0300 |
| Subject: usb: xhci: define port register names and use them instead of magic |
| numbers |
| |
| Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> |
| Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com> |
| (cherry picked from commit b6e76371c888f5cb677f190a28444ac8875359ad) |
| Signed-off-by: Benson Leung <bleung@chromium.org> |
| |
| |
| Reviewed-on: https://chromium-review.googlesource.com/169211 |
| Reviewed-by: Julius Werner <jwerner@chromium.org> |
| Commit-Queue: Benson Leung <bleung@chromium.org> |
| Tested-by: Benson Leung <bleung@chromium.org> |
| Signed-off-by: Darren Hart <dvhart@linux.intel.com> |
| --- |
| drivers/usb/host/xhci-hub.c | 16 +++++++--------- |
| drivers/usb/host/xhci.c | 4 ++-- |
| drivers/usb/host/xhci.h | 5 +++++ |
| 3 files changed, 14 insertions(+), 11 deletions(-) |
| |
| --- a/drivers/usb/host/xhci-hub.c |
| +++ b/drivers/usb/host/xhci-hub.c |
| @@ -928,18 +928,18 @@ int xhci_hub_control(struct usb_hcd *hcd |
| case USB_PORT_FEAT_U1_TIMEOUT: |
| if (hcd->speed != HCD_USB3) |
| goto error; |
| - temp = xhci_readl(xhci, port_array[wIndex] + 1); |
| + temp = xhci_readl(xhci, port_array[wIndex] + PORTPMSC); |
| temp &= ~PORT_U1_TIMEOUT_MASK; |
| temp |= PORT_U1_TIMEOUT(timeout); |
| - xhci_writel(xhci, temp, port_array[wIndex] + 1); |
| + xhci_writel(xhci, temp, port_array[wIndex] + PORTPMSC); |
| break; |
| case USB_PORT_FEAT_U2_TIMEOUT: |
| if (hcd->speed != HCD_USB3) |
| goto error; |
| - temp = xhci_readl(xhci, port_array[wIndex] + 1); |
| + temp = xhci_readl(xhci, port_array[wIndex] + PORTPMSC); |
| temp &= ~PORT_U2_TIMEOUT_MASK; |
| temp |= PORT_U2_TIMEOUT(timeout); |
| - xhci_writel(xhci, temp, port_array[wIndex] + 1); |
| + xhci_writel(xhci, temp, port_array[wIndex] + PORTPMSC); |
| break; |
| default: |
| goto error; |
| @@ -1159,10 +1159,8 @@ int xhci_bus_suspend(struct usb_hcd *hcd |
| __le32 __iomem *addr; |
| u32 tmp; |
| |
| - /* Add one to the port status register address to get |
| - * the port power control register address. |
| - */ |
| - addr = port_array[port_index] + 1; |
| + /* Get the port power control register address. */ |
| + addr = port_array[port_index] + PORTPMSC; |
| tmp = xhci_readl(xhci, addr); |
| tmp |= PORT_RWE; |
| xhci_writel(xhci, tmp, addr); |
| @@ -1254,7 +1252,7 @@ int xhci_bus_resume(struct usb_hcd *hcd) |
| /* Add one to the port status register address to get |
| * the port power control register address. |
| */ |
| - addr = port_array[port_index] + 1; |
| + addr = port_array[port_index] + PORTPMSC; |
| tmp = xhci_readl(xhci, addr); |
| tmp &= ~PORT_RWE; |
| xhci_writel(xhci, tmp, addr); |
| --- a/drivers/usb/host/xhci.c |
| +++ b/drivers/usb/host/xhci.c |
| @@ -3943,7 +3943,7 @@ static int xhci_usb2_software_lpm_test(s |
| * Check device's USB 2.0 extension descriptor to determine whether |
| * HIRD or BESL shoule be used. See USB2.0 LPM errata. |
| */ |
| - pm_addr = port_array[port_num] + 1; |
| + pm_addr = port_array[port_num] + PORTPMSC; |
| hird = xhci_calculate_hird_besl(xhci, udev); |
| temp = PORT_L1DS(udev->slot_id) | PORT_HIRD(hird); |
| xhci_writel(xhci, temp, pm_addr); |
| @@ -4041,7 +4041,7 @@ int xhci_set_usb2_hardware_lpm(struct us |
| |
| port_array = xhci->usb2_ports; |
| port_num = udev->portnum - 1; |
| - pm_addr = port_array[port_num] + 1; |
| + pm_addr = port_array[port_num] + PORTPMSC; |
| temp = xhci_readl(xhci, pm_addr); |
| |
| xhci_dbg(xhci, "%s port %d USB2 hardware LPM\n", |
| --- a/drivers/usb/host/xhci.h |
| +++ b/drivers/usb/host/xhci.h |
| @@ -134,6 +134,11 @@ struct xhci_cap_regs { |
| /* Number of registers per port */ |
| #define NUM_PORT_REGS 4 |
| |
| +#define PORTSC 0 |
| +#define PORTPMSC 1 |
| +#define PORTLI 2 |
| +#define PORTHLPMC 3 |
| + |
| /** |
| * struct xhci_op_regs - xHCI Host Controller Operational Registers. |
| * @command: USBCMD - xHC command register |