Commit e740b019 authored by Mathias Nyman's avatar Mathias Nyman Committed by Greg Kroah-Hartman

xhci: xhci-hub: use new port structures to get port address instead of port array

Use the new port structures for functions in xhci-hub.c to get
port mmio address of portsc register instead of the port array

xhci_get_port_io_addr() is no longer needeed and is removed.
Plan is to get rid of the mmio port array completely.
Signed-off-by: default avatarMathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent ffd4b4fc
...@@ -189,9 +189,10 @@ static void xhci_usb2_hub_descriptor(struct usb_hcd *hcd, struct xhci_hcd *xhci, ...@@ -189,9 +189,10 @@ static void xhci_usb2_hub_descriptor(struct usb_hcd *hcd, struct xhci_hcd *xhci,
__u8 port_removable[(USB_MAXCHILDREN + 1 + 7) / 8]; __u8 port_removable[(USB_MAXCHILDREN + 1 + 7) / 8];
u32 portsc; u32 portsc;
unsigned int i; unsigned int i;
struct xhci_hub *rhub;
ports = xhci->num_usb2_ports; rhub = &xhci->usb2_rhub;
ports = rhub->num_ports;
xhci_common_hub_descriptor(xhci, desc, ports); xhci_common_hub_descriptor(xhci, desc, ports);
desc->bDescriptorType = USB_DT_HUB; desc->bDescriptorType = USB_DT_HUB;
temp = 1 + (ports / 8); temp = 1 + (ports / 8);
...@@ -202,7 +203,7 @@ static void xhci_usb2_hub_descriptor(struct usb_hcd *hcd, struct xhci_hcd *xhci, ...@@ -202,7 +203,7 @@ static void xhci_usb2_hub_descriptor(struct usb_hcd *hcd, struct xhci_hcd *xhci,
*/ */
memset(port_removable, 0, sizeof(port_removable)); memset(port_removable, 0, sizeof(port_removable));
for (i = 0; i < ports; i++) { for (i = 0; i < ports; i++) {
portsc = readl(xhci->usb2_ports[i]); portsc = readl(rhub->ports[i]->addr);
/* If a device is removable, PORTSC reports a 0, same as in the /* If a device is removable, PORTSC reports a 0, same as in the
* hub descriptor DeviceRemovable bits. * hub descriptor DeviceRemovable bits.
*/ */
...@@ -241,8 +242,10 @@ static void xhci_usb3_hub_descriptor(struct usb_hcd *hcd, struct xhci_hcd *xhci, ...@@ -241,8 +242,10 @@ static void xhci_usb3_hub_descriptor(struct usb_hcd *hcd, struct xhci_hcd *xhci,
u16 port_removable; u16 port_removable;
u32 portsc; u32 portsc;
unsigned int i; unsigned int i;
struct xhci_hub *rhub;
ports = xhci->num_usb3_ports; rhub = &xhci->usb3_rhub;
ports = rhub->num_ports;
xhci_common_hub_descriptor(xhci, desc, ports); xhci_common_hub_descriptor(xhci, desc, ports);
desc->bDescriptorType = USB_DT_SS_HUB; desc->bDescriptorType = USB_DT_SS_HUB;
desc->bDescLength = USB_DT_SS_HUB_SIZE; desc->bDescLength = USB_DT_SS_HUB_SIZE;
...@@ -256,7 +259,7 @@ static void xhci_usb3_hub_descriptor(struct usb_hcd *hcd, struct xhci_hcd *xhci, ...@@ -256,7 +259,7 @@ static void xhci_usb3_hub_descriptor(struct usb_hcd *hcd, struct xhci_hcd *xhci,
port_removable = 0; port_removable = 0;
/* bit 0 is reserved, bit 1 is for port 1, etc. */ /* bit 0 is reserved, bit 1 is for port 1, etc. */
for (i = 0; i < ports; i++) { for (i = 0; i < ports; i++) {
portsc = readl(xhci->usb3_ports[i]); portsc = readl(rhub->ports[i]->addr);
if (portsc & PORT_DEV_REMOVE) if (portsc & PORT_DEV_REMOVE)
port_removable |= 1 << (i + 1); port_removable |= 1 << (i + 1);
} }
...@@ -563,14 +566,6 @@ struct xhci_hub *xhci_get_rhub(struct usb_hcd *hcd) ...@@ -563,14 +566,6 @@ struct xhci_hub *xhci_get_rhub(struct usb_hcd *hcd)
return &xhci->usb2_rhub; return &xhci->usb2_rhub;
} }
static __le32 __iomem *xhci_get_port_io_addr(struct usb_hcd *hcd, int index)
{
__le32 __iomem **port_array;
xhci_get_ports(hcd, &port_array);
return port_array[index];
}
/* /*
* xhci_set_port_power() must be called with xhci->lock held. * xhci_set_port_power() must be called with xhci->lock held.
* It will release and re-aquire the lock while calling ACPI * It will release and re-aquire the lock while calling ACPI
...@@ -579,21 +574,23 @@ static __le32 __iomem *xhci_get_port_io_addr(struct usb_hcd *hcd, int index) ...@@ -579,21 +574,23 @@ static __le32 __iomem *xhci_get_port_io_addr(struct usb_hcd *hcd, int index)
static void xhci_set_port_power(struct xhci_hcd *xhci, struct usb_hcd *hcd, static void xhci_set_port_power(struct xhci_hcd *xhci, struct usb_hcd *hcd,
u16 index, bool on, unsigned long *flags) u16 index, bool on, unsigned long *flags)
{ {
__le32 __iomem *addr; struct xhci_hub *rhub;
struct xhci_port *port;
u32 temp; u32 temp;
addr = xhci_get_port_io_addr(hcd, index); rhub = xhci_get_rhub(hcd);
temp = readl(addr); port = rhub->ports[index];
temp = readl(port->addr);
temp = xhci_port_state_to_neutral(temp); temp = xhci_port_state_to_neutral(temp);
if (on) { if (on) {
/* Power on */ /* Power on */
writel(temp | PORT_POWER, addr); writel(temp | PORT_POWER, port->addr);
temp = readl(addr); temp = readl(port->addr);
xhci_dbg(xhci, "set port power, actual port %d status = 0x%x\n", xhci_dbg(xhci, "set port power, actual port %d status = 0x%x\n",
index, temp); index, temp);
} else { } else {
/* Power off */ /* Power off */
writel(temp & ~PORT_POWER, addr); writel(temp & ~PORT_POWER, port->addr);
} }
spin_unlock_irqrestore(&xhci->lock, *flags); spin_unlock_irqrestore(&xhci->lock, *flags);
...@@ -609,13 +606,13 @@ static void xhci_port_set_test_mode(struct xhci_hcd *xhci, ...@@ -609,13 +606,13 @@ static void xhci_port_set_test_mode(struct xhci_hcd *xhci,
u16 test_mode, u16 wIndex) u16 test_mode, u16 wIndex)
{ {
u32 temp; u32 temp;
__le32 __iomem *addr; struct xhci_port *port;
/* xhci only supports test mode for usb2 ports, i.e. xhci->main_hcd */ /* xhci only supports test mode for usb2 ports */
addr = xhci_get_port_io_addr(xhci->main_hcd, wIndex); port = xhci->usb2_rhub.ports[wIndex];
temp = readl(addr + PORTPMSC); temp = readl(port->addr + PORTPMSC);
temp |= test_mode << PORT_TEST_MODE_SHIFT; temp |= test_mode << PORT_TEST_MODE_SHIFT;
writel(temp, addr + PORTPMSC); writel(temp, port->addr + PORTPMSC);
xhci->test_mode = test_mode; xhci->test_mode = test_mode;
if (test_mode == TEST_FORCE_EN) if (test_mode == TEST_FORCE_EN)
xhci_start(xhci); xhci_start(xhci);
...@@ -642,10 +639,10 @@ static int xhci_enter_test_mode(struct xhci_hcd *xhci, ...@@ -642,10 +639,10 @@ static int xhci_enter_test_mode(struct xhci_hcd *xhci,
/* Put all ports to the Disable state by clear PP */ /* Put all ports to the Disable state by clear PP */
xhci_dbg(xhci, "Disable all port (PP = 0)\n"); xhci_dbg(xhci, "Disable all port (PP = 0)\n");
/* Power off USB3 ports*/ /* Power off USB3 ports*/
for (i = 0; i < xhci->num_usb3_ports; i++) for (i = 0; i < xhci->usb3_rhub.num_ports; i++)
xhci_set_port_power(xhci, xhci->shared_hcd, i, false, flags); xhci_set_port_power(xhci, xhci->shared_hcd, i, false, flags);
/* Power off USB2 ports*/ /* Power off USB2 ports*/
for (i = 0; i < xhci->num_usb2_ports; i++) for (i = 0; i < xhci->usb2_rhub.num_ports; i++)
xhci_set_port_power(xhci, xhci->main_hcd, i, false, flags); xhci_set_port_power(xhci, xhci->main_hcd, i, false, flags);
/* Stop the controller */ /* Stop the controller */
xhci_dbg(xhci, "Stop controller\n"); xhci_dbg(xhci, "Stop controller\n");
...@@ -803,7 +800,7 @@ static void xhci_hub_report_usb3_link_state(struct xhci_hcd *xhci, ...@@ -803,7 +800,7 @@ static void xhci_hub_report_usb3_link_state(struct xhci_hcd *xhci,
static void xhci_del_comp_mod_timer(struct xhci_hcd *xhci, u32 status, static void xhci_del_comp_mod_timer(struct xhci_hcd *xhci, u32 status,
u16 wIndex) u16 wIndex)
{ {
u32 all_ports_seen_u0 = ((1 << xhci->num_usb3_ports)-1); u32 all_ports_seen_u0 = ((1 << xhci->usb3_rhub.num_ports) - 1);
bool port_in_u0 = ((status & PORT_PLS_MASK) == XDEV_U0); bool port_in_u0 = ((status & PORT_PLS_MASK) == XDEV_U0);
if (!(xhci->quirks & XHCI_COMP_MODE_QUIRK)) if (!(xhci->quirks & XHCI_COMP_MODE_QUIRK))
...@@ -858,6 +855,11 @@ static u32 xhci_get_port_status(struct usb_hcd *hcd, ...@@ -858,6 +855,11 @@ static u32 xhci_get_port_status(struct usb_hcd *hcd,
struct xhci_hcd *xhci = hcd_to_xhci(hcd); struct xhci_hcd *xhci = hcd_to_xhci(hcd);
u32 status = 0; u32 status = 0;
int slot_id; int slot_id;
struct xhci_hub *rhub;
struct xhci_port *port;
rhub = xhci_get_rhub(hcd);
port = rhub->ports[wIndex];
/* wPortChange bits */ /* wPortChange bits */
if (raw_port_status & PORT_CSC) if (raw_port_status & PORT_CSC)
...@@ -949,7 +951,7 @@ static u32 xhci_get_port_status(struct usb_hcd *hcd, ...@@ -949,7 +951,7 @@ static u32 xhci_get_port_status(struct usb_hcd *hcd,
} }
xhci_ring_device(xhci, slot_id); xhci_ring_device(xhci, slot_id);
} else { } else {
int port_status = readl(port_array[wIndex]); int port_status = readl(port->addr);
xhci_warn(xhci, "Port resume took longer than %i msec, port status = 0x%x\n", xhci_warn(xhci, "Port resume took longer than %i msec, port status = 0x%x\n",
XHCI_MAX_REXIT_TIMEOUT, XHCI_MAX_REXIT_TIMEOUT,
port_status); port_status);
...@@ -1040,7 +1042,11 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, ...@@ -1040,7 +1042,11 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
u16 wake_mask = 0; u16 wake_mask = 0;
u16 timeout = 0; u16 timeout = 0;
u16 test_mode = 0; u16 test_mode = 0;
struct xhci_hub *rhub;
struct xhci_port **ports;
rhub = xhci_get_rhub(hcd);
ports = rhub->ports;
max_ports = xhci_get_ports(hcd, &port_array); max_ports = xhci_get_ports(hcd, &port_array);
bus_state = &xhci->bus_state[hcd_index(hcd)]; bus_state = &xhci->bus_state[hcd_index(hcd)];
...@@ -1079,7 +1085,7 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, ...@@ -1079,7 +1085,7 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
if (!wIndex || wIndex > max_ports) if (!wIndex || wIndex > max_ports)
goto error; goto error;
wIndex--; wIndex--;
temp = readl(port_array[wIndex]); temp = readl(ports[wIndex]->addr);
if (temp == ~(u32)0) { if (temp == ~(u32)0) {
xhci_hc_died(xhci); xhci_hc_died(xhci);
retval = -ENODEV; retval = -ENODEV;
...@@ -1105,7 +1111,7 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, ...@@ -1105,7 +1111,7 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
retval = -EINVAL; retval = -EINVAL;
break; break;
} }
port_li = readl(port_array[wIndex] + PORTLI); port_li = readl(ports[wIndex]->addr + PORTLI);
status = xhci_get_ext_port_status(temp, port_li); status = xhci_get_ext_port_status(temp, port_li);
put_unaligned_le32(cpu_to_le32(status), &buf[4]); put_unaligned_le32(cpu_to_le32(status), &buf[4]);
} }
...@@ -1123,7 +1129,7 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, ...@@ -1123,7 +1129,7 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
if (!wIndex || wIndex > max_ports) if (!wIndex || wIndex > max_ports)
goto error; goto error;
wIndex--; wIndex--;
temp = readl(port_array[wIndex]); temp = readl(ports[wIndex]->addr);
if (temp == ~(u32)0) { if (temp == ~(u32)0) {
xhci_hc_died(xhci); xhci_hc_died(xhci);
retval = -ENODEV; retval = -ENODEV;
...@@ -1133,7 +1139,7 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, ...@@ -1133,7 +1139,7 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
/* FIXME: What new port features do we need to support? */ /* FIXME: What new port features do we need to support? */
switch (wValue) { switch (wValue) {
case USB_PORT_FEAT_SUSPEND: case USB_PORT_FEAT_SUSPEND:
temp = readl(port_array[wIndex]); temp = readl(ports[wIndex]->addr);
if ((temp & PORT_PLS_MASK) != XDEV_U0) { if ((temp & PORT_PLS_MASK) != XDEV_U0) {
/* Resume the port to U0 first */ /* Resume the port to U0 first */
xhci_set_link_state(xhci, port_array, wIndex, xhci_set_link_state(xhci, port_array, wIndex,
...@@ -1146,7 +1152,7 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, ...@@ -1146,7 +1152,7 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
* a port unless the port reports that it is in the * a port unless the port reports that it is in the
* enabled (PED = ‘1’,PLS < ‘3’) state. * enabled (PED = ‘1’,PLS < ‘3’) state.
*/ */
temp = readl(port_array[wIndex]); temp = readl(ports[wIndex]->addr);
if ((temp & PORT_PE) == 0 || (temp & PORT_RESET) if ((temp & PORT_PE) == 0 || (temp & PORT_RESET)
|| (temp & PORT_PLS_MASK) >= XDEV_U3) { || (temp & PORT_PLS_MASK) >= XDEV_U3) {
xhci_warn(xhci, "USB core suspending device not in U0/U1/U2.\n"); xhci_warn(xhci, "USB core suspending device not in U0/U1/U2.\n");
...@@ -1170,12 +1176,11 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, ...@@ -1170,12 +1176,11 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
msleep(10); /* wait device to enter */ msleep(10); /* wait device to enter */
spin_lock_irqsave(&xhci->lock, flags); spin_lock_irqsave(&xhci->lock, flags);
temp = readl(port_array[wIndex]); temp = readl(ports[wIndex]->addr);
bus_state->suspended_ports |= 1 << wIndex; bus_state->suspended_ports |= 1 << wIndex;
break; break;
case USB_PORT_FEAT_LINK_STATE: case USB_PORT_FEAT_LINK_STATE:
temp = readl(port_array[wIndex]); temp = readl(ports[wIndex]->addr);
/* Disable port */ /* Disable port */
if (link_state == USB_SS_PORT_LS_SS_DISABLED) { if (link_state == USB_SS_PORT_LS_SS_DISABLED) {
xhci_dbg(xhci, "Disable port %d\n", wIndex); xhci_dbg(xhci, "Disable port %d\n", wIndex);
...@@ -1187,8 +1192,8 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, ...@@ -1187,8 +1192,8 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
temp |= PORT_CSC | PORT_PEC | PORT_WRC | temp |= PORT_CSC | PORT_PEC | PORT_WRC |
PORT_OCC | PORT_RC | PORT_PLC | PORT_OCC | PORT_RC | PORT_PLC |
PORT_CEC; PORT_CEC;
writel(temp | PORT_PE, port_array[wIndex]); writel(temp | PORT_PE, ports[wIndex]->addr);
temp = readl(port_array[wIndex]); temp = readl(ports[wIndex]->addr);
break; break;
} }
...@@ -1197,7 +1202,7 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, ...@@ -1197,7 +1202,7 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
xhci_dbg(xhci, "Enable port %d\n", wIndex); xhci_dbg(xhci, "Enable port %d\n", wIndex);
xhci_set_link_state(xhci, port_array, wIndex, xhci_set_link_state(xhci, port_array, wIndex,
link_state); link_state);
temp = readl(port_array[wIndex]); temp = readl(ports[wIndex]->addr);
break; break;
} }
...@@ -1230,7 +1235,7 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, ...@@ -1230,7 +1235,7 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
wIndex); wIndex);
xhci_set_link_state(xhci, port_array, wIndex, xhci_set_link_state(xhci, port_array, wIndex,
link_state); link_state);
temp = readl(port_array[wIndex]); temp = readl(ports[wIndex]->addr);
break; break;
} }
/* Port must be enabled */ /* Port must be enabled */
...@@ -1264,7 +1269,7 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, ...@@ -1264,7 +1269,7 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
msleep(20); /* wait device to enter */ msleep(20); /* wait device to enter */
spin_lock_irqsave(&xhci->lock, flags); spin_lock_irqsave(&xhci->lock, flags);
temp = readl(port_array[wIndex]); temp = readl(ports[wIndex]->addr);
if (link_state == USB_SS_PORT_LS_U3) if (link_state == USB_SS_PORT_LS_U3)
bus_state->suspended_ports |= 1 << wIndex; bus_state->suspended_ports |= 1 << wIndex;
break; break;
...@@ -1279,40 +1284,39 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, ...@@ -1279,40 +1284,39 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
break; break;
case USB_PORT_FEAT_RESET: case USB_PORT_FEAT_RESET:
temp = (temp | PORT_RESET); temp = (temp | PORT_RESET);
writel(temp, port_array[wIndex]); writel(temp, ports[wIndex]->addr);
temp = readl(port_array[wIndex]); temp = readl(ports[wIndex]->addr);
xhci_dbg(xhci, "set port reset, actual port %d status = 0x%x\n", wIndex, temp); xhci_dbg(xhci, "set port reset, actual port %d status = 0x%x\n", wIndex, temp);
break; break;
case USB_PORT_FEAT_REMOTE_WAKE_MASK: case USB_PORT_FEAT_REMOTE_WAKE_MASK:
xhci_set_remote_wake_mask(xhci, port_array, xhci_set_remote_wake_mask(xhci, port_array,
wIndex, wake_mask); wIndex, wake_mask);
temp = readl(port_array[wIndex]); temp = readl(ports[wIndex]->addr);
xhci_dbg(xhci, "set port remote wake mask, " xhci_dbg(xhci, "set port remote wake mask, "
"actual port %d status = 0x%x\n", "actual port %d status = 0x%x\n",
wIndex, temp); wIndex, temp);
break; break;
case USB_PORT_FEAT_BH_PORT_RESET: case USB_PORT_FEAT_BH_PORT_RESET:
temp |= PORT_WR; temp |= PORT_WR;
writel(temp, port_array[wIndex]); writel(temp, ports[wIndex]->addr);
temp = readl(ports[wIndex]->addr);
temp = readl(port_array[wIndex]);
break; break;
case USB_PORT_FEAT_U1_TIMEOUT: case USB_PORT_FEAT_U1_TIMEOUT:
if (hcd->speed < HCD_USB3) if (hcd->speed < HCD_USB3)
goto error; goto error;
temp = readl(port_array[wIndex] + PORTPMSC); temp = readl(ports[wIndex]->addr + PORTPMSC);
temp &= ~PORT_U1_TIMEOUT_MASK; temp &= ~PORT_U1_TIMEOUT_MASK;
temp |= PORT_U1_TIMEOUT(timeout); temp |= PORT_U1_TIMEOUT(timeout);
writel(temp, port_array[wIndex] + PORTPMSC); writel(temp, ports[wIndex]->addr + PORTPMSC);
break; break;
case USB_PORT_FEAT_U2_TIMEOUT: case USB_PORT_FEAT_U2_TIMEOUT:
if (hcd->speed < HCD_USB3) if (hcd->speed < HCD_USB3)
goto error; goto error;
temp = readl(port_array[wIndex] + PORTPMSC); temp = readl(ports[wIndex]->addr + PORTPMSC);
temp &= ~PORT_U2_TIMEOUT_MASK; temp &= ~PORT_U2_TIMEOUT_MASK;
temp |= PORT_U2_TIMEOUT(timeout); temp |= PORT_U2_TIMEOUT(timeout);
writel(temp, port_array[wIndex] + PORTPMSC); writel(temp, ports[wIndex]->addr + PORTPMSC);
break; break;
case USB_PORT_FEAT_TEST: case USB_PORT_FEAT_TEST:
/* 4.19.6 Port Test Modes (USB2 Test Mode) */ /* 4.19.6 Port Test Modes (USB2 Test Mode) */
...@@ -1327,13 +1331,13 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, ...@@ -1327,13 +1331,13 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
goto error; goto error;
} }
/* unblock any posted writes */ /* unblock any posted writes */
temp = readl(port_array[wIndex]); temp = readl(ports[wIndex]->addr);
break; break;
case ClearPortFeature: case ClearPortFeature:
if (!wIndex || wIndex > max_ports) if (!wIndex || wIndex > max_ports)
goto error; goto error;
wIndex--; wIndex--;
temp = readl(port_array[wIndex]); temp = readl(ports[wIndex]->addr);
if (temp == ~(u32)0) { if (temp == ~(u32)0) {
xhci_hc_died(xhci); xhci_hc_died(xhci);
retval = -ENODEV; retval = -ENODEV;
...@@ -1343,7 +1347,7 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, ...@@ -1343,7 +1347,7 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
temp = xhci_port_state_to_neutral(temp); temp = xhci_port_state_to_neutral(temp);
switch (wValue) { switch (wValue) {
case USB_PORT_FEAT_SUSPEND: case USB_PORT_FEAT_SUSPEND:
temp = readl(port_array[wIndex]); temp = readl(ports[wIndex]->addr);
xhci_dbg(xhci, "clear USB_PORT_FEAT_SUSPEND\n"); xhci_dbg(xhci, "clear USB_PORT_FEAT_SUSPEND\n");
xhci_dbg(xhci, "PORTSC %04x\n", temp); xhci_dbg(xhci, "PORTSC %04x\n", temp);
if (temp & PORT_RESET) if (temp & PORT_RESET)
...@@ -1383,11 +1387,11 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, ...@@ -1383,11 +1387,11 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
case USB_PORT_FEAT_C_PORT_LINK_STATE: case USB_PORT_FEAT_C_PORT_LINK_STATE:
case USB_PORT_FEAT_C_PORT_CONFIG_ERROR: case USB_PORT_FEAT_C_PORT_CONFIG_ERROR:
xhci_clear_port_change_bit(xhci, wValue, wIndex, xhci_clear_port_change_bit(xhci, wValue, wIndex,
port_array[wIndex], temp); ports[wIndex]->addr, temp);
break; break;
case USB_PORT_FEAT_ENABLE: case USB_PORT_FEAT_ENABLE:
xhci_disable_port(hcd, xhci, wIndex, xhci_disable_port(hcd, xhci, wIndex,
port_array[wIndex], temp); ports[wIndex]->addr, temp);
break; break;
case USB_PORT_FEAT_POWER: case USB_PORT_FEAT_POWER:
xhci_set_port_power(xhci, hcd, wIndex, false, &flags); xhci_set_port_power(xhci, hcd, wIndex, false, &flags);
...@@ -1427,7 +1431,11 @@ int xhci_hub_status_data(struct usb_hcd *hcd, char *buf) ...@@ -1427,7 +1431,11 @@ int xhci_hub_status_data(struct usb_hcd *hcd, char *buf)
__le32 __iomem **port_array; __le32 __iomem **port_array;
struct xhci_bus_state *bus_state; struct xhci_bus_state *bus_state;
bool reset_change = false; bool reset_change = false;
struct xhci_hub *rhub;
struct xhci_port **ports;
rhub = xhci_get_rhub(hcd);
ports = rhub->ports;
max_ports = xhci_get_ports(hcd, &port_array); max_ports = xhci_get_ports(hcd, &port_array);
bus_state = &xhci->bus_state[hcd_index(hcd)]; bus_state = &xhci->bus_state[hcd_index(hcd)];
...@@ -1446,7 +1454,7 @@ int xhci_hub_status_data(struct usb_hcd *hcd, char *buf) ...@@ -1446,7 +1454,7 @@ int xhci_hub_status_data(struct usb_hcd *hcd, char *buf)
spin_lock_irqsave(&xhci->lock, flags); spin_lock_irqsave(&xhci->lock, flags);
/* For each port, did anything change? If so, set that bit in buf. */ /* For each port, did anything change? If so, set that bit in buf. */
for (i = 0; i < max_ports; i++) { for (i = 0; i < max_ports; i++) {
temp = readl(port_array[i]); temp = readl(ports[i]->addr);
if (temp == ~(u32)0) { if (temp == ~(u32)0) {
xhci_hc_died(xhci); xhci_hc_died(xhci);
retval = -ENODEV; retval = -ENODEV;
...@@ -1481,7 +1489,11 @@ int xhci_bus_suspend(struct usb_hcd *hcd) ...@@ -1481,7 +1489,11 @@ int xhci_bus_suspend(struct usb_hcd *hcd)
__le32 __iomem **port_array; __le32 __iomem **port_array;
struct xhci_bus_state *bus_state; struct xhci_bus_state *bus_state;
unsigned long flags; unsigned long flags;
struct xhci_hub *rhub;
struct xhci_port **ports;
rhub = xhci_get_rhub(hcd);
ports = rhub->ports;
max_ports = xhci_get_ports(hcd, &port_array); max_ports = xhci_get_ports(hcd, &port_array);
bus_state = &xhci->bus_state[hcd_index(hcd)]; bus_state = &xhci->bus_state[hcd_index(hcd)];
...@@ -1503,7 +1515,7 @@ int xhci_bus_suspend(struct usb_hcd *hcd) ...@@ -1503,7 +1515,7 @@ int xhci_bus_suspend(struct usb_hcd *hcd)
u32 t1, t2; u32 t1, t2;
int slot_id; int slot_id;
t1 = readl(port_array[port_index]); t1 = readl(ports[port_index]->addr);
t2 = xhci_port_state_to_neutral(t1); t2 = xhci_port_state_to_neutral(t1);
if ((t1 & PORT_PE) && !(t1 & PORT_PLS_MASK)) { if ((t1 & PORT_PE) && !(t1 & PORT_PLS_MASK)) {
...@@ -1543,7 +1555,7 @@ int xhci_bus_suspend(struct usb_hcd *hcd) ...@@ -1543,7 +1555,7 @@ int xhci_bus_suspend(struct usb_hcd *hcd)
t1 = xhci_port_state_to_neutral(t1); t1 = xhci_port_state_to_neutral(t1);
if (t1 != t2) if (t1 != t2)
writel(t2, port_array[port_index]); writel(t2, ports[port_index]->addr);
} }
hcd->state = HC_STATE_SUSPENDED; hcd->state = HC_STATE_SUSPENDED;
bus_state->next_statechange = jiffies + msecs_to_jiffies(10); bus_state->next_statechange = jiffies + msecs_to_jiffies(10);
...@@ -1591,7 +1603,11 @@ int xhci_bus_resume(struct usb_hcd *hcd) ...@@ -1591,7 +1603,11 @@ int xhci_bus_resume(struct usb_hcd *hcd)
int sret; int sret;
u32 next_state; u32 next_state;
u32 temp, portsc; u32 temp, portsc;
struct xhci_hub *rhub;
struct xhci_port **ports;
rhub = xhci_get_rhub(hcd);
ports = rhub->ports;
max_ports = xhci_get_ports(hcd, &port_array); max_ports = xhci_get_ports(hcd, &port_array);
bus_state = &xhci->bus_state[hcd_index(hcd)]; bus_state = &xhci->bus_state[hcd_index(hcd)];
...@@ -1617,7 +1633,7 @@ int xhci_bus_resume(struct usb_hcd *hcd) ...@@ -1617,7 +1633,7 @@ int xhci_bus_resume(struct usb_hcd *hcd)
port_index = max_ports; port_index = max_ports;
while (port_index--) { while (port_index--) {
portsc = readl(port_array[port_index]); portsc = readl(ports[port_index]->addr);
/* warm reset CAS limited ports stuck in polling/compliance */ /* warm reset CAS limited ports stuck in polling/compliance */
if ((xhci->quirks & XHCI_MISSING_CAS) && if ((xhci->quirks & XHCI_MISSING_CAS) &&
...@@ -1646,7 +1662,7 @@ int xhci_bus_resume(struct usb_hcd *hcd) ...@@ -1646,7 +1662,7 @@ int xhci_bus_resume(struct usb_hcd *hcd)
} }
/* disable wake for all ports, write new link state if needed */ /* disable wake for all ports, write new link state if needed */
portsc &= ~(PORT_RWC_BITS | PORT_CEC | PORT_WAKE_BITS); portsc &= ~(PORT_RWC_BITS | PORT_CEC | PORT_WAKE_BITS);
writel(portsc, port_array[port_index]); writel(portsc, ports[port_index]->addr);
} }
/* USB2 specific resume signaling delay and U0 link state transition */ /* USB2 specific resume signaling delay and U0 link state transition */
...@@ -1668,7 +1684,7 @@ int xhci_bus_resume(struct usb_hcd *hcd) ...@@ -1668,7 +1684,7 @@ int xhci_bus_resume(struct usb_hcd *hcd)
/* poll for U0 link state complete, both USB2 and USB3 */ /* poll for U0 link state complete, both USB2 and USB3 */
for_each_set_bit(port_index, &bus_state->bus_suspended, BITS_PER_LONG) { for_each_set_bit(port_index, &bus_state->bus_suspended, BITS_PER_LONG) {
sret = xhci_handshake(port_array[port_index], PORT_PLC, sret = xhci_handshake(ports[port_index]->addr, PORT_PLC,
PORT_PLC, 10 * 1000); PORT_PLC, 10 * 1000);
if (sret) { if (sret) {
xhci_warn(xhci, "port %d resume PLC timeout\n", xhci_warn(xhci, "port %d resume PLC timeout\n",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment