|
|
5544c1 |
From 670eba790c368e9c37b0c964d94e0ff7f0d0c443 Mon Sep 17 00:00:00 2001
|
|
Hans de Goede |
c8dfc6 |
From: Gerd Hoffmann <kraxel@redhat.com>
|
|
Hans de Goede |
c8dfc6 |
Date: Thu, 30 Aug 2012 17:15:12 +0200
|
|
|
5544c1 |
Subject: [PATCH] xhci: prepare xhci_runtime_{read,write} for multiple
|
|
Hans de Goede |
c8dfc6 |
interrupters
|
|
Hans de Goede |
c8dfc6 |
|
|
Hans de Goede |
c8dfc6 |
Prepare xhci runtime register access function for multiple interrupters.
|
|
Hans de Goede |
c8dfc6 |
|
|
Hans de Goede |
c8dfc6 |
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
|
|
Hans de Goede |
c8dfc6 |
---
|
|
Hans de Goede |
c8dfc6 |
hw/usb/hcd-xhci.c | 100 +++++++++++++++++++++++++++++++-----------------------
|
|
Hans de Goede |
c8dfc6 |
1 file changed, 57 insertions(+), 43 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 8a14ee8..6b3ff16 100644
|
|
Hans de Goede |
c8dfc6 |
--- a/hw/usb/hcd-xhci.c
|
|
Hans de Goede |
c8dfc6 |
+++ b/hw/usb/hcd-xhci.c
|
|
|
5544c1 |
@@ -2586,37 +2586,43 @@ static void xhci_oper_write(XHCIState *xhci, uint32_t reg, uint32_t val)
|
|
Hans de Goede |
c8dfc6 |
|
|
Hans de Goede |
c8dfc6 |
static uint32_t xhci_runtime_read(XHCIState *xhci, uint32_t reg)
|
|
Hans de Goede |
c8dfc6 |
{
|
|
Hans de Goede |
c8dfc6 |
- XHCIInterrupter *intr = &xhci->intr[0];
|
|
Hans de Goede |
c8dfc6 |
- uint32_t ret;
|
|
Hans de Goede |
c8dfc6 |
+ uint32_t ret = 0;
|
|
Hans de Goede |
c8dfc6 |
|
|
Hans de Goede |
c8dfc6 |
- switch (reg) {
|
|
Hans de Goede |
c8dfc6 |
- case 0x00: /* MFINDEX */
|
|
Hans de Goede |
c8dfc6 |
- ret = xhci_mfindex_get(xhci) & 0x3fff;
|
|
Hans de Goede |
c8dfc6 |
- break;
|
|
Hans de Goede |
c8dfc6 |
- case 0x20: /* IMAN */
|
|
Hans de Goede |
c8dfc6 |
- ret = intr->iman;
|
|
Hans de Goede |
c8dfc6 |
- break;
|
|
Hans de Goede |
c8dfc6 |
- case 0x24: /* IMOD */
|
|
Hans de Goede |
c8dfc6 |
- ret = intr->imod;
|
|
Hans de Goede |
c8dfc6 |
- break;
|
|
Hans de Goede |
c8dfc6 |
- case 0x28: /* ERSTSZ */
|
|
Hans de Goede |
c8dfc6 |
- ret = intr->erstsz;
|
|
Hans de Goede |
c8dfc6 |
- break;
|
|
Hans de Goede |
c8dfc6 |
- case 0x30: /* ERSTBA low */
|
|
Hans de Goede |
c8dfc6 |
- ret = intr->erstba_low;
|
|
Hans de Goede |
c8dfc6 |
- break;
|
|
Hans de Goede |
c8dfc6 |
- case 0x34: /* ERSTBA high */
|
|
Hans de Goede |
c8dfc6 |
- ret = intr->erstba_high;
|
|
Hans de Goede |
c8dfc6 |
- break;
|
|
Hans de Goede |
c8dfc6 |
- case 0x38: /* ERDP low */
|
|
Hans de Goede |
c8dfc6 |
- ret = intr->erdp_low;
|
|
Hans de Goede |
c8dfc6 |
- break;
|
|
Hans de Goede |
c8dfc6 |
- case 0x3c: /* ERDP high */
|
|
Hans de Goede |
c8dfc6 |
- ret = intr->erdp_high;
|
|
Hans de Goede |
c8dfc6 |
- break;
|
|
Hans de Goede |
c8dfc6 |
- default:
|
|
Hans de Goede |
c8dfc6 |
- fprintf(stderr, "xhci_runtime_read: reg 0x%x unimplemented\n", reg);
|
|
Hans de Goede |
c8dfc6 |
- ret = 0;
|
|
Hans de Goede |
c8dfc6 |
+ if (reg < 0x20) {
|
|
Hans de Goede |
c8dfc6 |
+ switch (reg) {
|
|
Hans de Goede |
c8dfc6 |
+ case 0x00: /* MFINDEX */
|
|
Hans de Goede |
c8dfc6 |
+ ret = xhci_mfindex_get(xhci) & 0x3fff;
|
|
Hans de Goede |
c8dfc6 |
+ break;
|
|
Hans de Goede |
c8dfc6 |
+ default:
|
|
Hans de Goede |
c8dfc6 |
+ fprintf(stderr, "xhci_runtime_read: reg 0x%x unimplemented\n", reg);
|
|
Hans de Goede |
c8dfc6 |
+ break;
|
|
Hans de Goede |
c8dfc6 |
+ }
|
|
Hans de Goede |
c8dfc6 |
+ } else {
|
|
Hans de Goede |
c8dfc6 |
+ int v = (reg - 0x20) / 0x20;
|
|
Hans de Goede |
c8dfc6 |
+ XHCIInterrupter *intr = &xhci->intr[v];
|
|
Hans de Goede |
c8dfc6 |
+ switch (reg & 0x1f) {
|
|
Hans de Goede |
c8dfc6 |
+ case 0x00: /* IMAN */
|
|
Hans de Goede |
c8dfc6 |
+ ret = intr->iman;
|
|
Hans de Goede |
c8dfc6 |
+ break;
|
|
Hans de Goede |
c8dfc6 |
+ case 0x04: /* IMOD */
|
|
Hans de Goede |
c8dfc6 |
+ ret = intr->imod;
|
|
Hans de Goede |
c8dfc6 |
+ break;
|
|
Hans de Goede |
c8dfc6 |
+ case 0x08: /* ERSTSZ */
|
|
Hans de Goede |
c8dfc6 |
+ ret = intr->erstsz;
|
|
Hans de Goede |
c8dfc6 |
+ break;
|
|
Hans de Goede |
c8dfc6 |
+ case 0x10: /* ERSTBA low */
|
|
Hans de Goede |
c8dfc6 |
+ ret = intr->erstba_low;
|
|
Hans de Goede |
c8dfc6 |
+ break;
|
|
Hans de Goede |
c8dfc6 |
+ case 0x14: /* ERSTBA high */
|
|
Hans de Goede |
c8dfc6 |
+ ret = intr->erstba_high;
|
|
Hans de Goede |
c8dfc6 |
+ break;
|
|
Hans de Goede |
c8dfc6 |
+ case 0x18: /* ERDP low */
|
|
Hans de Goede |
c8dfc6 |
+ ret = intr->erdp_low;
|
|
Hans de Goede |
c8dfc6 |
+ break;
|
|
Hans de Goede |
c8dfc6 |
+ case 0x1c: /* ERDP high */
|
|
Hans de Goede |
c8dfc6 |
+ ret = intr->erdp_high;
|
|
Hans de Goede |
c8dfc6 |
+ break;
|
|
Hans de Goede |
c8dfc6 |
+ }
|
|
Hans de Goede |
c8dfc6 |
}
|
|
Hans de Goede |
c8dfc6 |
|
|
Hans de Goede |
c8dfc6 |
trace_usb_xhci_runtime_read(reg, ret);
|
|
|
5544c1 |
@@ -2625,43 +2631,51 @@ static uint32_t xhci_runtime_read(XHCIState *xhci, uint32_t reg)
|
|
Hans de Goede |
c8dfc6 |
|
|
Hans de Goede |
c8dfc6 |
static void xhci_runtime_write(XHCIState *xhci, uint32_t reg, uint32_t val)
|
|
Hans de Goede |
c8dfc6 |
{
|
|
Hans de Goede |
c8dfc6 |
- XHCIInterrupter *intr = &xhci->intr[0];
|
|
Hans de Goede |
c8dfc6 |
+ int v = (reg - 0x20) / 0x20;
|
|
Hans de Goede |
c8dfc6 |
+ XHCIInterrupter *intr = &xhci->intr[v];
|
|
Hans de Goede |
c8dfc6 |
trace_usb_xhci_runtime_write(reg, val);
|
|
Hans de Goede |
c8dfc6 |
|
|
Hans de Goede |
c8dfc6 |
- switch (reg) {
|
|
Hans de Goede |
c8dfc6 |
- case 0x20: /* IMAN */
|
|
Hans de Goede |
c8dfc6 |
+ if (reg < 0x20) {
|
|
Hans de Goede |
c8dfc6 |
+ fprintf(stderr, "xhci_oper_write: reg 0x%x unimplemented\n", reg);
|
|
Hans de Goede |
c8dfc6 |
+ return;
|
|
Hans de Goede |
c8dfc6 |
+ }
|
|
Hans de Goede |
c8dfc6 |
+
|
|
Hans de Goede |
c8dfc6 |
+ switch (reg & 0x1f) {
|
|
Hans de Goede |
c8dfc6 |
+ case 0x00: /* IMAN */
|
|
Hans de Goede |
c8dfc6 |
if (val & IMAN_IP) {
|
|
Hans de Goede |
c8dfc6 |
intr->iman &= ~IMAN_IP;
|
|
Hans de Goede |
c8dfc6 |
}
|
|
Hans de Goede |
c8dfc6 |
intr->iman &= ~IMAN_IE;
|
|
Hans de Goede |
c8dfc6 |
intr->iman |= val & IMAN_IE;
|
|
Hans de Goede |
c8dfc6 |
- xhci_intx_update(xhci);
|
|
Hans de Goede |
c8dfc6 |
- xhci_msix_update(xhci, 0);
|
|
Hans de Goede |
c8dfc6 |
+ if (v == 0) {
|
|
Hans de Goede |
c8dfc6 |
+ xhci_intx_update(xhci);
|
|
Hans de Goede |
c8dfc6 |
+ }
|
|
Hans de Goede |
c8dfc6 |
+ xhci_msix_update(xhci, v);
|
|
Hans de Goede |
c8dfc6 |
break;
|
|
Hans de Goede |
c8dfc6 |
- case 0x24: /* IMOD */
|
|
Hans de Goede |
c8dfc6 |
+ case 0x04: /* IMOD */
|
|
Hans de Goede |
c8dfc6 |
intr->imod = val;
|
|
Hans de Goede |
c8dfc6 |
break;
|
|
Hans de Goede |
c8dfc6 |
- case 0x28: /* ERSTSZ */
|
|
Hans de Goede |
c8dfc6 |
+ case 0x08: /* ERSTSZ */
|
|
Hans de Goede |
c8dfc6 |
intr->erstsz = val & 0xffff;
|
|
Hans de Goede |
c8dfc6 |
break;
|
|
Hans de Goede |
c8dfc6 |
- case 0x30: /* ERSTBA low */
|
|
Hans de Goede |
c8dfc6 |
+ case 0x10: /* ERSTBA low */
|
|
Hans de Goede |
c8dfc6 |
/* XXX NEC driver bug: it doesn't align this to 64 bytes
|
|
Hans de Goede |
c8dfc6 |
intr->erstba_low = val & 0xffffffc0; */
|
|
Hans de Goede |
c8dfc6 |
intr->erstba_low = val & 0xfffffff0;
|
|
Hans de Goede |
c8dfc6 |
break;
|
|
Hans de Goede |
c8dfc6 |
- case 0x34: /* ERSTBA high */
|
|
Hans de Goede |
c8dfc6 |
+ case 0x14: /* ERSTBA high */
|
|
Hans de Goede |
c8dfc6 |
intr->erstba_high = val;
|
|
Hans de Goede |
c8dfc6 |
- xhci_er_reset(xhci, 0);
|
|
Hans de Goede |
c8dfc6 |
+ xhci_er_reset(xhci, v);
|
|
Hans de Goede |
c8dfc6 |
break;
|
|
Hans de Goede |
c8dfc6 |
- case 0x38: /* ERDP low */
|
|
Hans de Goede |
c8dfc6 |
+ case 0x18: /* ERDP low */
|
|
Hans de Goede |
c8dfc6 |
if (val & ERDP_EHB) {
|
|
Hans de Goede |
c8dfc6 |
intr->erdp_low &= ~ERDP_EHB;
|
|
Hans de Goede |
c8dfc6 |
}
|
|
Hans de Goede |
c8dfc6 |
intr->erdp_low = (val & ~ERDP_EHB) | (intr->erdp_low & ERDP_EHB);
|
|
Hans de Goede |
c8dfc6 |
break;
|
|
Hans de Goede |
c8dfc6 |
- case 0x3c: /* ERDP high */
|
|
Hans de Goede |
c8dfc6 |
+ case 0x1c: /* ERDP high */
|
|
Hans de Goede |
c8dfc6 |
intr->erdp_high = val;
|
|
Hans de Goede |
c8dfc6 |
- xhci_events_update(xhci, 0);
|
|
Hans de Goede |
c8dfc6 |
+ xhci_events_update(xhci, v);
|
|
Hans de Goede |
c8dfc6 |
break;
|
|
Hans de Goede |
c8dfc6 |
default:
|
|
Hans de Goede |
c8dfc6 |
fprintf(stderr, "xhci_oper_write: reg 0x%x unimplemented\n", reg);
|
|
Hans de Goede |
c8dfc6 |
--
|
|
|
5544c1 |
1.7.12.1
|
|
Hans de Goede |
c8dfc6 |
|