|
|
5544c1 |
From 0b1ccd39faa8d1ea71f2d02dbab5dfd13f54ac98 Mon Sep 17 00:00:00 2001
|
|
Hans de Goede |
c8dfc6 |
From: Gerd Hoffmann <kraxel@redhat.com>
|
|
Hans de Goede |
c8dfc6 |
Date: Tue, 28 Aug 2012 13:38:01 +0200
|
|
|
5544c1 |
Subject: [PATCH] xhci: update port handling
|
|
Hans de Goede |
c8dfc6 |
|
|
Hans de Goede |
c8dfc6 |
This patch changes the way xhci ports are linked to USBPorts. The fixed
|
|
Hans de Goede |
c8dfc6 |
1:1 relationship between xhci ports and USBPorts is gone. Now each
|
|
Hans de Goede |
c8dfc6 |
USBPort represents a physical plug which has usually two xhci ports
|
|
Hans de Goede |
c8dfc6 |
assigned: one usb2 and ond usb3 port. usb devices show up at one or the
|
|
Hans de Goede |
c8dfc6 |
other, depending on whenever they support superspeed or not.
|
|
Hans de Goede |
c8dfc6 |
|
|
Hans de Goede |
c8dfc6 |
This patch also makes the number of usb2 and usb3 ports runtime
|
|
Hans de Goede |
c8dfc6 |
configurable by adding 'p2' and 'p3' properties. It is allowed to
|
|
Hans de Goede |
c8dfc6 |
have different numbers of usb2 and usb3 ports. Specifying p2=4,p3=2
|
|
Hans de Goede |
c8dfc6 |
will give you an xhci adapter which supports all speeds on physical
|
|
Hans de Goede |
c8dfc6 |
ports 1+2 and usb2 only on ports 3+4.
|
|
Hans de Goede |
c8dfc6 |
---
|
|
Hans de Goede |
c8dfc6 |
hw/usb/hcd-xhci.c | 137 ++++++++++++++++++++++++++++++++++++++----------------
|
|
Hans de Goede |
c8dfc6 |
1 file changed, 97 insertions(+), 40 deletions(-)
|
|
Hans de Goede |
c8dfc6 |
|
|
Hans de Goede |
c8dfc6 |
diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
|
|
|
5544c1 |
index d47539d..5813b4a 100644
|
|
Hans de Goede |
c8dfc6 |
--- a/hw/usb/hcd-xhci.c
|
|
Hans de Goede |
c8dfc6 |
+++ b/hw/usb/hcd-xhci.c
|
|
Hans de Goede |
c8dfc6 |
@@ -36,10 +36,10 @@
|
|
Hans de Goede |
c8dfc6 |
#define FIXME() do { fprintf(stderr, "FIXME %s:%d\n", \
|
|
Hans de Goede |
c8dfc6 |
__func__, __LINE__); abort(); } while (0)
|
|
Hans de Goede |
c8dfc6 |
|
|
Hans de Goede |
c8dfc6 |
-#define USB2_PORTS 4
|
|
Hans de Goede |
c8dfc6 |
-#define USB3_PORTS 4
|
|
Hans de Goede |
c8dfc6 |
+#define MAXPORTS_2 8
|
|
Hans de Goede |
c8dfc6 |
+#define MAXPORTS_3 8
|
|
Hans de Goede |
c8dfc6 |
|
|
Hans de Goede |
c8dfc6 |
-#define MAXPORTS (USB2_PORTS+USB3_PORTS)
|
|
Hans de Goede |
c8dfc6 |
+#define MAXPORTS (MAXPORTS_2+MAXPORTS_3)
|
|
Hans de Goede |
c8dfc6 |
#define MAXSLOTS MAXPORTS
|
|
Hans de Goede |
c8dfc6 |
#define MAXINTRS 1 /* MAXPORTS */
|
|
Hans de Goede |
c8dfc6 |
|
|
Hans de Goede |
c8dfc6 |
@@ -300,8 +300,10 @@ typedef struct XHCIRing {
|
|
Hans de Goede |
c8dfc6 |
} XHCIRing;
|
|
Hans de Goede |
c8dfc6 |
|
|
Hans de Goede |
c8dfc6 |
typedef struct XHCIPort {
|
|
Hans de Goede |
c8dfc6 |
- USBPort port;
|
|
Hans de Goede |
c8dfc6 |
uint32_t portsc;
|
|
Hans de Goede |
c8dfc6 |
+ uint32_t portnr;
|
|
Hans de Goede |
c8dfc6 |
+ USBPort *uport;
|
|
Hans de Goede |
c8dfc6 |
+ uint32_t speedmask;
|
|
Hans de Goede |
c8dfc6 |
} XHCIPort;
|
|
Hans de Goede |
c8dfc6 |
|
|
Hans de Goede |
c8dfc6 |
struct XHCIState;
|
|
Hans de Goede |
c8dfc6 |
@@ -379,9 +381,13 @@ struct XHCIState {
|
|
Hans de Goede |
c8dfc6 |
qemu_irq irq;
|
|
Hans de Goede |
c8dfc6 |
MemoryRegion mem;
|
|
Hans de Goede |
c8dfc6 |
const char *name;
|
|
Hans de Goede |
c8dfc6 |
- uint32_t msi;
|
|
Hans de Goede |
c8dfc6 |
unsigned int devaddr;
|
|
Hans de Goede |
c8dfc6 |
|
|
Hans de Goede |
c8dfc6 |
+ /* properties */
|
|
Hans de Goede |
c8dfc6 |
+ uint32_t numports_2;
|
|
Hans de Goede |
c8dfc6 |
+ uint32_t numports_3;
|
|
Hans de Goede |
c8dfc6 |
+ uint32_t msi;
|
|
Hans de Goede |
c8dfc6 |
+
|
|
Hans de Goede |
c8dfc6 |
/* Operational Registers */
|
|
Hans de Goede |
c8dfc6 |
uint32_t usbcmd;
|
|
Hans de Goede |
c8dfc6 |
uint32_t usbsts;
|
|
Hans de Goede |
c8dfc6 |
@@ -392,8 +398,10 @@ struct XHCIState {
|
|
Hans de Goede |
c8dfc6 |
uint32_t dcbaap_high;
|
|
Hans de Goede |
c8dfc6 |
uint32_t config;
|
|
Hans de Goede |
c8dfc6 |
|
|
Hans de Goede |
c8dfc6 |
+ USBPort uports[MAX(MAXPORTS_2, MAXPORTS_3)];
|
|
Hans de Goede |
c8dfc6 |
XHCIPort ports[MAXPORTS];
|
|
Hans de Goede |
c8dfc6 |
XHCISlot slots[MAXSLOTS];
|
|
Hans de Goede |
c8dfc6 |
+ uint32_t numports;
|
|
Hans de Goede |
c8dfc6 |
|
|
Hans de Goede |
c8dfc6 |
/* Runtime Registers */
|
|
Hans de Goede |
c8dfc6 |
uint32_t iman;
|
|
Hans de Goede |
c8dfc6 |
@@ -578,6 +586,28 @@ static inline dma_addr_t xhci_mask64(uint64_t addr)
|
|
Hans de Goede |
c8dfc6 |
}
|
|
Hans de Goede |
c8dfc6 |
}
|
|
Hans de Goede |
c8dfc6 |
|
|
Hans de Goede |
c8dfc6 |
+static XHCIPort *xhci_lookup_port(XHCIState *xhci, struct USBPort *uport)
|
|
Hans de Goede |
c8dfc6 |
+{
|
|
Hans de Goede |
c8dfc6 |
+ int index;
|
|
Hans de Goede |
c8dfc6 |
+
|
|
Hans de Goede |
c8dfc6 |
+ if (!uport->dev) {
|
|
Hans de Goede |
c8dfc6 |
+ return NULL;
|
|
Hans de Goede |
c8dfc6 |
+ }
|
|
Hans de Goede |
c8dfc6 |
+ switch (uport->dev->speed) {
|
|
Hans de Goede |
c8dfc6 |
+ case USB_SPEED_LOW:
|
|
Hans de Goede |
c8dfc6 |
+ case USB_SPEED_FULL:
|
|
Hans de Goede |
c8dfc6 |
+ case USB_SPEED_HIGH:
|
|
Hans de Goede |
c8dfc6 |
+ index = uport->index;
|
|
Hans de Goede |
c8dfc6 |
+ break;
|
|
Hans de Goede |
c8dfc6 |
+ case USB_SPEED_SUPER:
|
|
Hans de Goede |
c8dfc6 |
+ index = uport->index + xhci->numports_2;
|
|
Hans de Goede |
c8dfc6 |
+ break;
|
|
Hans de Goede |
c8dfc6 |
+ default:
|
|
Hans de Goede |
c8dfc6 |
+ return NULL;
|
|
Hans de Goede |
c8dfc6 |
+ }
|
|
Hans de Goede |
c8dfc6 |
+ return &xhci->ports[index];
|
|
Hans de Goede |
c8dfc6 |
+}
|
|
Hans de Goede |
c8dfc6 |
+
|
|
Hans de Goede |
c8dfc6 |
static void xhci_irq_update(XHCIState *xhci)
|
|
Hans de Goede |
c8dfc6 |
{
|
|
Hans de Goede |
c8dfc6 |
int level = 0;
|
|
Hans de Goede |
c8dfc6 |
@@ -1126,7 +1156,7 @@ static TRBCCode xhci_reset_ep(XHCIState *xhci, unsigned int slotid,
|
|
Hans de Goede |
c8dfc6 |
ep |= 0x80;
|
|
Hans de Goede |
c8dfc6 |
}
|
|
Hans de Goede |
c8dfc6 |
|
|
Hans de Goede |
c8dfc6 |
- dev = xhci->ports[xhci->slots[slotid-1].port-1].port.dev;
|
|
Hans de Goede |
c8dfc6 |
+ dev = xhci->ports[xhci->slots[slotid-1].port-1].uport->dev;
|
|
Hans de Goede |
c8dfc6 |
if (!dev) {
|
|
Hans de Goede |
c8dfc6 |
return CC_USB_TRANSACTION_ERROR;
|
|
Hans de Goede |
c8dfc6 |
}
|
|
Hans de Goede |
c8dfc6 |
@@ -1313,7 +1343,7 @@ static USBDevice *xhci_find_device(XHCIPort *port, uint8_t addr)
|
|
Hans de Goede |
c8dfc6 |
if (!(port->portsc & PORTSC_PED)) {
|
|
Hans de Goede |
c8dfc6 |
return NULL;
|
|
Hans de Goede |
c8dfc6 |
}
|
|
Hans de Goede |
c8dfc6 |
- return usb_find_device(&port->port, addr);
|
|
Hans de Goede |
c8dfc6 |
+ return usb_find_device(port->uport, addr);
|
|
Hans de Goede |
c8dfc6 |
}
|
|
Hans de Goede |
c8dfc6 |
|
|
Hans de Goede |
c8dfc6 |
static int xhci_setup_packet(XHCITransfer *xfer)
|
|
|
5544c1 |
@@ -1734,9 +1764,9 @@ static TRBCCode xhci_address_slot(XHCIState *xhci, unsigned int slotid,
|
|
Hans de Goede |
c8dfc6 |
ep0_ctx[0], ep0_ctx[1], ep0_ctx[2], ep0_ctx[3], ep0_ctx[4]);
|
|
Hans de Goede |
c8dfc6 |
|
|
Hans de Goede |
c8dfc6 |
port = (slot_ctx[1]>>16) & 0xFF;
|
|
Hans de Goede |
c8dfc6 |
- dev = xhci->ports[port-1].port.dev;
|
|
Hans de Goede |
c8dfc6 |
+ dev = xhci->ports[port-1].uport->dev;
|
|
Hans de Goede |
c8dfc6 |
|
|
Hans de Goede |
c8dfc6 |
- if (port < 1 || port > MAXPORTS) {
|
|
Hans de Goede |
c8dfc6 |
+ if (port < 1 || port > xhci->numports) {
|
|
Hans de Goede |
c8dfc6 |
fprintf(stderr, "xhci: bad port %d\n", port);
|
|
Hans de Goede |
c8dfc6 |
return CC_TRB_ERROR;
|
|
Hans de Goede |
c8dfc6 |
} else if (!dev) {
|
|
|
5544c1 |
@@ -1985,7 +2015,7 @@ static unsigned int xhci_get_slot(XHCIState *xhci, XHCIEvent *event, XHCITRB *tr
|
|
Hans de Goede |
c8dfc6 |
static TRBCCode xhci_get_port_bandwidth(XHCIState *xhci, uint64_t pctx)
|
|
Hans de Goede |
c8dfc6 |
{
|
|
Hans de Goede |
c8dfc6 |
dma_addr_t ctx;
|
|
Hans de Goede |
c8dfc6 |
- uint8_t bw_ctx[MAXPORTS+1];
|
|
Hans de Goede |
c8dfc6 |
+ uint8_t bw_ctx[xhci->numports+1];
|
|
Hans de Goede |
c8dfc6 |
|
|
Hans de Goede |
c8dfc6 |
DPRINTF("xhci_get_port_bandwidth()\n");
|
|
Hans de Goede |
c8dfc6 |
|
|
|
5544c1 |
@@ -1995,7 +2025,7 @@ static TRBCCode xhci_get_port_bandwidth(XHCIState *xhci, uint64_t pctx)
|
|
Hans de Goede |
c8dfc6 |
|
|
Hans de Goede |
c8dfc6 |
/* TODO: actually implement real values here */
|
|
Hans de Goede |
c8dfc6 |
bw_ctx[0] = 0;
|
|
Hans de Goede |
c8dfc6 |
- memset(&bw_ctx[1], 80, MAXPORTS); /* 80% */
|
|
Hans de Goede |
c8dfc6 |
+ memset(&bw_ctx[1], 80, xhci->numports); /* 80% */
|
|
Hans de Goede |
c8dfc6 |
pci_dma_write(&xhci->pci_dev, ctx, bw_ctx, sizeof(bw_ctx));
|
|
Hans de Goede |
c8dfc6 |
|
|
Hans de Goede |
c8dfc6 |
return CC_SUCCESS;
|
|
|
5544c1 |
@@ -2165,12 +2195,11 @@ static void xhci_process_commands(XHCIState *xhci)
|
|
Hans de Goede |
c8dfc6 |
|
|
Hans de Goede |
c8dfc6 |
static void xhci_update_port(XHCIState *xhci, XHCIPort *port, int is_detach)
|
|
Hans de Goede |
c8dfc6 |
{
|
|
Hans de Goede |
c8dfc6 |
- int nr = port->port.index + 1;
|
|
Hans de Goede |
c8dfc6 |
-
|
|
Hans de Goede |
c8dfc6 |
port->portsc = PORTSC_PP;
|
|
Hans de Goede |
c8dfc6 |
- if (port->port.dev && port->port.dev->attached && !is_detach) {
|
|
Hans de Goede |
c8dfc6 |
+ if (port->uport->dev && port->uport->dev->attached && !is_detach &&
|
|
Hans de Goede |
c8dfc6 |
+ (1 << port->uport->dev->speed) & port->speedmask) {
|
|
Hans de Goede |
c8dfc6 |
port->portsc |= PORTSC_CCS;
|
|
Hans de Goede |
c8dfc6 |
- switch (port->port.dev->speed) {
|
|
Hans de Goede |
c8dfc6 |
+ switch (port->uport->dev->speed) {
|
|
Hans de Goede |
c8dfc6 |
case USB_SPEED_LOW:
|
|
Hans de Goede |
c8dfc6 |
port->portsc |= PORTSC_SPEED_LOW;
|
|
Hans de Goede |
c8dfc6 |
break;
|
|
|
5544c1 |
@@ -2180,14 +2209,18 @@ static void xhci_update_port(XHCIState *xhci, XHCIPort *port, int is_detach)
|
|
Hans de Goede |
c8dfc6 |
case USB_SPEED_HIGH:
|
|
Hans de Goede |
c8dfc6 |
port->portsc |= PORTSC_SPEED_HIGH;
|
|
Hans de Goede |
c8dfc6 |
break;
|
|
Hans de Goede |
c8dfc6 |
+ case USB_SPEED_SUPER:
|
|
Hans de Goede |
c8dfc6 |
+ port->portsc |= PORTSC_SPEED_SUPER;
|
|
Hans de Goede |
c8dfc6 |
+ break;
|
|
Hans de Goede |
c8dfc6 |
}
|
|
Hans de Goede |
c8dfc6 |
}
|
|
Hans de Goede |
c8dfc6 |
|
|
Hans de Goede |
c8dfc6 |
if (xhci_running(xhci)) {
|
|
Hans de Goede |
c8dfc6 |
port->portsc |= PORTSC_CSC;
|
|
Hans de Goede |
c8dfc6 |
- XHCIEvent ev = { ER_PORT_STATUS_CHANGE, CC_SUCCESS, nr << 24};
|
|
Hans de Goede |
c8dfc6 |
+ XHCIEvent ev = { ER_PORT_STATUS_CHANGE, CC_SUCCESS,
|
|
Hans de Goede |
c8dfc6 |
+ port->portnr << 24};
|
|
Hans de Goede |
c8dfc6 |
xhci_event(xhci, &ev;;
|
|
Hans de Goede |
c8dfc6 |
- DPRINTF("xhci: port change event for port %d\n", nr);
|
|
Hans de Goede |
c8dfc6 |
+ DPRINTF("xhci: port change event for port %d\n", port->portnr);
|
|
Hans de Goede |
c8dfc6 |
}
|
|
Hans de Goede |
c8dfc6 |
}
|
|
Hans de Goede |
c8dfc6 |
|
|
|
5544c1 |
@@ -2215,7 +2248,7 @@ static void xhci_reset(DeviceState *dev)
|
|
Hans de Goede |
c8dfc6 |
xhci_disable_slot(xhci, i+1);
|
|
Hans de Goede |
c8dfc6 |
}
|
|
Hans de Goede |
c8dfc6 |
|
|
Hans de Goede |
c8dfc6 |
- for (i = 0; i < MAXPORTS; i++) {
|
|
Hans de Goede |
c8dfc6 |
+ for (i = 0; i < xhci->numports; i++) {
|
|
Hans de Goede |
c8dfc6 |
xhci_update_port(xhci, xhci->ports + i, 0);
|
|
Hans de Goede |
c8dfc6 |
}
|
|
Hans de Goede |
c8dfc6 |
|
|
|
5544c1 |
@@ -2246,7 +2279,8 @@ static uint32_t xhci_cap_read(XHCIState *xhci, uint32_t reg)
|
|
Hans de Goede |
c8dfc6 |
ret = 0x01000000 | LEN_CAP;
|
|
Hans de Goede |
c8dfc6 |
break;
|
|
Hans de Goede |
c8dfc6 |
case 0x04: /* HCSPARAMS 1 */
|
|
Hans de Goede |
c8dfc6 |
- ret = (MAXPORTS<<24) | (MAXINTRS<<8) | MAXSLOTS;
|
|
Hans de Goede |
c8dfc6 |
+ ret = ((xhci->numports_2+xhci->numports_3)<<24)
|
|
Hans de Goede |
c8dfc6 |
+ | (MAXINTRS<<8) | MAXSLOTS;
|
|
Hans de Goede |
c8dfc6 |
break;
|
|
Hans de Goede |
c8dfc6 |
case 0x08: /* HCSPARAMS 2 */
|
|
Hans de Goede |
c8dfc6 |
ret = 0x0000000f;
|
|
|
5544c1 |
@@ -2276,7 +2310,7 @@ static uint32_t xhci_cap_read(XHCIState *xhci, uint32_t reg)
|
|
Hans de Goede |
c8dfc6 |
ret = 0x20425455; /* "USB " */
|
|
Hans de Goede |
c8dfc6 |
break;
|
|
Hans de Goede |
c8dfc6 |
case 0x28: /* Supported Protocol:08 */
|
|
Hans de Goede |
c8dfc6 |
- ret = 0x00000001 | (USB2_PORTS<<8);
|
|
Hans de Goede |
c8dfc6 |
+ ret = 0x00000001 | (xhci->numports_2<<8);
|
|
Hans de Goede |
c8dfc6 |
break;
|
|
Hans de Goede |
c8dfc6 |
case 0x2c: /* Supported Protocol:0c */
|
|
Hans de Goede |
c8dfc6 |
ret = 0x00000000; /* reserved */
|
|
|
5544c1 |
@@ -2288,7 +2322,7 @@ static uint32_t xhci_cap_read(XHCIState *xhci, uint32_t reg)
|
|
Hans de Goede |
c8dfc6 |
ret = 0x20425455; /* "USB " */
|
|
Hans de Goede |
c8dfc6 |
break;
|
|
Hans de Goede |
c8dfc6 |
case 0x38: /* Supported Protocol:08 */
|
|
Hans de Goede |
c8dfc6 |
- ret = 0x00000000 | (USB2_PORTS+1) | (USB3_PORTS<<8);
|
|
Hans de Goede |
c8dfc6 |
+ ret = 0x00000000 | (xhci->numports_2+1) | (xhci->numports_3<<8);
|
|
Hans de Goede |
c8dfc6 |
break;
|
|
Hans de Goede |
c8dfc6 |
case 0x3c: /* Supported Protocol:0c */
|
|
Hans de Goede |
c8dfc6 |
ret = 0x00000000; /* reserved */
|
|
|
5544c1 |
@@ -2307,7 +2341,7 @@ static uint32_t xhci_port_read(XHCIState *xhci, uint32_t reg)
|
|
Hans de Goede |
c8dfc6 |
uint32_t port = reg >> 4;
|
|
Hans de Goede |
c8dfc6 |
uint32_t ret;
|
|
Hans de Goede |
c8dfc6 |
|
|
Hans de Goede |
c8dfc6 |
- if (port >= MAXPORTS) {
|
|
Hans de Goede |
c8dfc6 |
+ if (port >= xhci->numports) {
|
|
Hans de Goede |
c8dfc6 |
fprintf(stderr, "xhci_port_read: port %d out of bounds\n", port);
|
|
Hans de Goede |
c8dfc6 |
ret = 0;
|
|
Hans de Goede |
c8dfc6 |
goto out;
|
|
|
5544c1 |
@@ -2340,7 +2374,7 @@ static void xhci_port_write(XHCIState *xhci, uint32_t reg, uint32_t val)
|
|
Hans de Goede |
c8dfc6 |
|
|
Hans de Goede |
c8dfc6 |
trace_usb_xhci_port_write(port, reg & 0x0f, val);
|
|
Hans de Goede |
c8dfc6 |
|
|
Hans de Goede |
c8dfc6 |
- if (port >= MAXPORTS) {
|
|
Hans de Goede |
c8dfc6 |
+ if (port >= xhci->numports) {
|
|
Hans de Goede |
c8dfc6 |
fprintf(stderr, "xhci_port_read: port %d out of bounds\n", port);
|
|
Hans de Goede |
c8dfc6 |
return;
|
|
Hans de Goede |
c8dfc6 |
}
|
|
|
5544c1 |
@@ -2362,7 +2396,7 @@ static void xhci_port_write(XHCIState *xhci, uint32_t reg, uint32_t val)
|
|
Hans de Goede |
c8dfc6 |
/* write-1-to-start bits */
|
|
Hans de Goede |
c8dfc6 |
if (val & PORTSC_PR) {
|
|
Hans de Goede |
c8dfc6 |
DPRINTF("xhci: port %d reset\n", port);
|
|
Hans de Goede |
c8dfc6 |
- usb_device_reset(xhci->ports[port].port.dev);
|
|
Hans de Goede |
c8dfc6 |
+ usb_device_reset(xhci->ports[port].uport->dev);
|
|
Hans de Goede |
c8dfc6 |
portsc |= PORTSC_PRC | PORTSC_PED;
|
|
Hans de Goede |
c8dfc6 |
}
|
|
Hans de Goede |
c8dfc6 |
xhci->ports[port].portsc = portsc;
|
|
Hans de Goede |
c8dfc6 |
@@ -2659,7 +2693,7 @@ static const MemoryRegionOps xhci_mem_ops = {
|
|
Hans de Goede |
c8dfc6 |
static void xhci_attach(USBPort *usbport)
|
|
Hans de Goede |
c8dfc6 |
{
|
|
Hans de Goede |
c8dfc6 |
XHCIState *xhci = usbport->opaque;
|
|
Hans de Goede |
c8dfc6 |
- XHCIPort *port = &xhci->ports[usbport->index];
|
|
Hans de Goede |
c8dfc6 |
+ XHCIPort *port = xhci_lookup_port(xhci, usbport);
|
|
Hans de Goede |
c8dfc6 |
|
|
Hans de Goede |
c8dfc6 |
xhci_update_port(xhci, port, 0);
|
|
Hans de Goede |
c8dfc6 |
}
|
|
Hans de Goede |
c8dfc6 |
@@ -2667,7 +2701,7 @@ static void xhci_attach(USBPort *usbport)
|
|
Hans de Goede |
c8dfc6 |
static void xhci_detach(USBPort *usbport)
|
|
Hans de Goede |
c8dfc6 |
{
|
|
Hans de Goede |
c8dfc6 |
XHCIState *xhci = usbport->opaque;
|
|
Hans de Goede |
c8dfc6 |
- XHCIPort *port = &xhci->ports[usbport->index];
|
|
Hans de Goede |
c8dfc6 |
+ XHCIPort *port = xhci_lookup_port(xhci, usbport);
|
|
Hans de Goede |
c8dfc6 |
|
|
Hans de Goede |
c8dfc6 |
xhci_update_port(xhci, port, 1);
|
|
Hans de Goede |
c8dfc6 |
}
|
|
Hans de Goede |
c8dfc6 |
@@ -2675,9 +2709,9 @@ static void xhci_detach(USBPort *usbport)
|
|
Hans de Goede |
c8dfc6 |
static void xhci_wakeup(USBPort *usbport)
|
|
Hans de Goede |
c8dfc6 |
{
|
|
Hans de Goede |
c8dfc6 |
XHCIState *xhci = usbport->opaque;
|
|
Hans de Goede |
c8dfc6 |
- XHCIPort *port = &xhci->ports[usbport->index];
|
|
Hans de Goede |
c8dfc6 |
- int nr = port->port.index + 1;
|
|
Hans de Goede |
c8dfc6 |
- XHCIEvent ev = { ER_PORT_STATUS_CHANGE, CC_SUCCESS, nr << 24};
|
|
Hans de Goede |
c8dfc6 |
+ XHCIPort *port = xhci_lookup_port(xhci, usbport);
|
|
Hans de Goede |
c8dfc6 |
+ XHCIEvent ev = { ER_PORT_STATUS_CHANGE, CC_SUCCESS,
|
|
Hans de Goede |
c8dfc6 |
+ port->portnr << 24};
|
|
Hans de Goede |
c8dfc6 |
uint32_t pls;
|
|
Hans de Goede |
c8dfc6 |
|
|
Hans de Goede |
c8dfc6 |
pls = (port->portsc >> PORTSC_PLS_SHIFT) & PORTSC_PLS_MASK;
|
|
Hans de Goede |
c8dfc6 |
@@ -2759,22 +2793,43 @@ static USBBusOps xhci_bus_ops = {
|
|
Hans de Goede |
c8dfc6 |
|
|
Hans de Goede |
c8dfc6 |
static void usb_xhci_init(XHCIState *xhci, DeviceState *dev)
|
|
Hans de Goede |
c8dfc6 |
{
|
|
Hans de Goede |
c8dfc6 |
- int i;
|
|
Hans de Goede |
c8dfc6 |
+ XHCIPort *port;
|
|
Hans de Goede |
c8dfc6 |
+ int i, usbports, speedmask;
|
|
Hans de Goede |
c8dfc6 |
|
|
Hans de Goede |
c8dfc6 |
xhci->usbsts = USBSTS_HCH;
|
|
Hans de Goede |
c8dfc6 |
|
|
Hans de Goede |
c8dfc6 |
+ if (xhci->numports_2 > MAXPORTS_2) {
|
|
Hans de Goede |
c8dfc6 |
+ xhci->numports_2 = MAXPORTS_2;
|
|
Hans de Goede |
c8dfc6 |
+ }
|
|
Hans de Goede |
c8dfc6 |
+ if (xhci->numports_3 > MAXPORTS_3) {
|
|
Hans de Goede |
c8dfc6 |
+ xhci->numports_3 = MAXPORTS_3;
|
|
Hans de Goede |
c8dfc6 |
+ }
|
|
Hans de Goede |
c8dfc6 |
+ usbports = MAX(xhci->numports_2, xhci->numports_3);
|
|
Hans de Goede |
c8dfc6 |
+ xhci->numports = xhci->numports_2 + xhci->numports_3;
|
|
Hans de Goede |
c8dfc6 |
+
|
|
Hans de Goede |
c8dfc6 |
usb_bus_new(&xhci->bus, &xhci_bus_ops, &xhci->pci_dev.qdev);
|
|
Hans de Goede |
c8dfc6 |
|
|
Hans de Goede |
c8dfc6 |
- for (i = 0; i < MAXPORTS; i++) {
|
|
Hans de Goede |
c8dfc6 |
- memset(&xhci->ports[i], 0, sizeof(xhci->ports[i]));
|
|
Hans de Goede |
c8dfc6 |
- usb_register_port(&xhci->bus, &xhci->ports[i].port, xhci, i,
|
|
Hans de Goede |
c8dfc6 |
- &xhci_port_ops,
|
|
Hans de Goede |
c8dfc6 |
- USB_SPEED_MASK_LOW |
|
|
Hans de Goede |
c8dfc6 |
- USB_SPEED_MASK_FULL |
|
|
Hans de Goede |
c8dfc6 |
- USB_SPEED_MASK_HIGH);
|
|
Hans de Goede |
c8dfc6 |
- }
|
|
Hans de Goede |
c8dfc6 |
- for (i = 0; i < MAXSLOTS; i++) {
|
|
Hans de Goede |
c8dfc6 |
- xhci->slots[i].enabled = 0;
|
|
Hans de Goede |
c8dfc6 |
+ for (i = 0; i < usbports; i++) {
|
|
Hans de Goede |
c8dfc6 |
+ speedmask = 0;
|
|
Hans de Goede |
c8dfc6 |
+ if (i < xhci->numports_2) {
|
|
Hans de Goede |
c8dfc6 |
+ port = &xhci->ports[i];
|
|
Hans de Goede |
c8dfc6 |
+ port->portnr = i + 1;
|
|
Hans de Goede |
c8dfc6 |
+ port->uport = &xhci->uports[i];
|
|
Hans de Goede |
c8dfc6 |
+ port->speedmask =
|
|
Hans de Goede |
c8dfc6 |
+ USB_SPEED_MASK_LOW |
|
|
Hans de Goede |
c8dfc6 |
+ USB_SPEED_MASK_FULL |
|
|
Hans de Goede |
c8dfc6 |
+ USB_SPEED_MASK_HIGH;
|
|
Hans de Goede |
c8dfc6 |
+ speedmask |= port->speedmask;
|
|
Hans de Goede |
c8dfc6 |
+ }
|
|
Hans de Goede |
c8dfc6 |
+ if (i < xhci->numports_3) {
|
|
Hans de Goede |
c8dfc6 |
+ port = &xhci->ports[i + xhci->numports_2];
|
|
Hans de Goede |
c8dfc6 |
+ port->portnr = i + 1 + xhci->numports_2;
|
|
Hans de Goede |
c8dfc6 |
+ port->uport = &xhci->uports[i];
|
|
Hans de Goede |
c8dfc6 |
+ port->speedmask = USB_SPEED_MASK_SUPER;
|
|
Hans de Goede |
c8dfc6 |
+ speedmask |= port->speedmask;
|
|
Hans de Goede |
c8dfc6 |
+ }
|
|
Hans de Goede |
c8dfc6 |
+ usb_register_port(&xhci->bus, &xhci->uports[i], xhci, i,
|
|
Hans de Goede |
c8dfc6 |
+ &xhci_port_ops, speedmask);
|
|
Hans de Goede |
c8dfc6 |
}
|
|
Hans de Goede |
c8dfc6 |
}
|
|
Hans de Goede |
c8dfc6 |
|
|
Hans de Goede |
c8dfc6 |
@@ -2830,6 +2885,8 @@ static const VMStateDescription vmstate_xhci = {
|
|
Hans de Goede |
c8dfc6 |
|
|
Hans de Goede |
c8dfc6 |
static Property xhci_properties[] = {
|
|
Hans de Goede |
c8dfc6 |
DEFINE_PROP_UINT32("msi", XHCIState, msi, 0),
|
|
Hans de Goede |
c8dfc6 |
+ DEFINE_PROP_UINT32("p2", XHCIState, numports_2, 4),
|
|
Hans de Goede |
c8dfc6 |
+ DEFINE_PROP_UINT32("p3", XHCIState, numports_3, 4),
|
|
Hans de Goede |
c8dfc6 |
DEFINE_PROP_END_OF_LIST(),
|
|
Hans de Goede |
c8dfc6 |
};
|
|
Hans de Goede |
c8dfc6 |
|
|
Hans de Goede |
c8dfc6 |
--
|
|
|
5544c1 |
1.7.12.1
|
|
Hans de Goede |
c8dfc6 |
|