Gerd Hoffmann (3): usb: add boot prio support for mmio host adapters usb/xhci: split xhci setup into generic and pci parts usb/xhci: add support for mmio host adapters (via acpi).
src/hw/usb.h | 1 + src/boot.c | 10 ++++++- src/hw/usb-xhci.c | 71 ++++++++++++++++++++++++++++++++++++++--------- 3 files changed, 68 insertions(+), 14 deletions(-)
Add mmio field to usb controller struct, add support for mmio-mapped usb host adapters to boot order handling.
Signed-off-by: Gerd Hoffmann kraxel@redhat.com --- src/hw/usb.h | 1 + src/boot.c | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/src/hw/usb.h b/src/hw/usb.h index 2cfb5721775a..887f2064cf3a 100644 --- a/src/hw/usb.h +++ b/src/hw/usb.h @@ -35,6 +35,7 @@ struct usb_s { struct usb_pipe *freelist; struct mutex_s resetlock; struct pci_device *pci; + void *mmio; u8 type; u8 maxaddr; }; diff --git a/src/boot.c b/src/boot.c index a715e37356e2..bd78fb907c5a 100644 --- a/src/boot.c +++ b/src/boot.c @@ -425,7 +425,15 @@ int bootprio_find_usb(struct usbdevice_s *usbdev, int lun) return -1; // Find usb - for example: /pci@i0cf8/usb@1,2/storage@1/channel@0/disk@0,0 char desc[256], *p; - p = build_pci_path(desc, sizeof(desc), "usb", usbdev->hub->cntl->pci); + + if (usbdev->hub->cntl->pci) + p = build_pci_path(desc, sizeof(desc), "usb", usbdev->hub->cntl->pci); + else if (usbdev->hub->cntl->mmio) + p = desc + snprintf(desc, sizeof(desc), "/*@%016x" + , (u32)usbdev->hub->cntl->mmio); + else + return -1; + p = build_usb_path(p, desc+sizeof(desc)-p, usbdev->hub); snprintf(p, desc+sizeof(desc)-p, "/storage@%x/*@0/*@0,%x" , usb_portmap(usbdev), lun);
On Wed, Sep 30, 2020 at 01:14:31PM +0200, Gerd Hoffmann wrote:
Add mmio field to usb controller struct, add support for mmio-mapped usb host adapters to boot order handling.
Signed-off-by: Gerd Hoffmann kraxel@redhat.com
src/hw/usb.h | 1 + src/boot.c | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/src/hw/usb.h b/src/hw/usb.h index 2cfb5721775a..887f2064cf3a 100644 --- a/src/hw/usb.h +++ b/src/hw/usb.h @@ -35,6 +35,7 @@ struct usb_s { struct usb_pipe *freelist; struct mutex_s resetlock; struct pci_device *pci;
- void *mmio; u8 type; u8 maxaddr;
}; diff --git a/src/boot.c b/src/boot.c index a715e37356e2..bd78fb907c5a 100644 --- a/src/boot.c +++ b/src/boot.c @@ -425,7 +425,15 @@ int bootprio_find_usb(struct usbdevice_s *usbdev, int lun) return -1; // Find usb - for example: /pci@i0cf8/usb@1,2/storage@1/channel@0/disk@0,0
What does an example usb descriptor look like with mmio?
char desc[256], *p;
- p = build_pci_path(desc, sizeof(desc), "usb", usbdev->hub->cntl->pci);
- if (usbdev->hub->cntl->pci)
p = build_pci_path(desc, sizeof(desc), "usb", usbdev->hub->cntl->pci);
- else if (usbdev->hub->cntl->mmio)
p = desc + snprintf(desc, sizeof(desc), "/*@%016x"
, (u32)usbdev->hub->cntl->mmio);
- else
return -1;
- p = build_usb_path(p, desc+sizeof(desc)-p, usbdev->hub); snprintf(p, desc+sizeof(desc)-p, "/storage@%x/*@0/*@0,%x" , usb_portmap(usbdev), lun);
-- 2.27.0 _______________________________________________ SeaBIOS mailing list -- seabios@seabios.org To unsubscribe send an email to seabios-leave@seabios.org
On Wed, Sep 30, 2020 at 11:26:06AM -0400, Kevin O'Connor wrote:
On Wed, Sep 30, 2020 at 01:14:31PM +0200, Gerd Hoffmann wrote:
Add mmio field to usb controller struct, add support for mmio-mapped usb host adapters to boot order handling.
Signed-off-by: Gerd Hoffmann kraxel@redhat.com
src/hw/usb.h | 1 + src/boot.c | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/src/hw/usb.h b/src/hw/usb.h index 2cfb5721775a..887f2064cf3a 100644 --- a/src/hw/usb.h +++ b/src/hw/usb.h @@ -35,6 +35,7 @@ struct usb_s { struct usb_pipe *freelist; struct mutex_s resetlock; struct pci_device *pci;
- void *mmio; u8 type; u8 maxaddr;
}; diff --git a/src/boot.c b/src/boot.c index a715e37356e2..bd78fb907c5a 100644 --- a/src/boot.c +++ b/src/boot.c @@ -425,7 +425,15 @@ int bootprio_find_usb(struct usbdevice_s *usbdev, int lun) return -1; // Find usb - for example: /pci@i0cf8/usb@1,2/storage@1/channel@0/disk@0,0
What does an example usb descriptor look like with mmio?
/sysbus-xhci@00000000fe900000/storage@1/channel@0/disk@0,0
I'll update the comment for v2.
take care, Gerd
Split the pci-specific code into a separate xhci_controller_setup_pci() function, turn xhci_controller_setup() to a generic xhci setup function which only needs the mmio address if the control registers.
Signed-off-by: Gerd Hoffmann kraxel@redhat.com --- src/hw/usb-xhci.c | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-)
diff --git a/src/hw/usb-xhci.c b/src/hw/usb-xhci.c index 21d091f29606..f27867e4f184 100644 --- a/src/hw/usb-xhci.c +++ b/src/hw/usb-xhci.c @@ -534,17 +534,13 @@ fail: free(xhci); }
-static void -xhci_controller_setup(struct pci_device *pci) +static struct usb_xhci_s* +xhci_controller_setup(void *baseaddr) { - void *baseaddr = pci_enable_membar(pci, PCI_BASE_ADDRESS_0); - if (!baseaddr) - return; - struct usb_xhci_s *xhci = malloc_high(sizeof(*xhci)); if (!xhci) { warn_noalloc(); - return; + return NULL; } memset(xhci, 0, sizeof(*xhci)); xhci->caps = baseaddr; @@ -559,13 +555,11 @@ xhci_controller_setup(struct pci_device *pci) xhci->slots = hcs1 & 0xff; xhci->xcap = ((hcc >> 16) & 0xffff) << 2; xhci->context64 = (hcc & 0x04) ? 1 : 0; - - xhci->usb.pci = pci; xhci->usb.type = USB_TYPE_XHCI;
- dprintf(1, "XHCI init on dev %pP: regs @ %p, %d ports, %d slots" + dprintf(1, "XHCI init: regs @ %p, %d ports, %d slots" ", %d byte contexts\n" - , pci, xhci->caps, xhci->ports, xhci->slots + , xhci->caps, xhci->ports, xhci->slots , xhci->context64 ? 64 : 32);
if (xhci->xcap) { @@ -616,11 +610,30 @@ xhci_controller_setup(struct pci_device *pci) dprintf(1, "XHCI driver does not support page size code %d\n" , pagesize<<12); free(xhci); - return; + return NULL; }
+ return xhci; +} + +static void +xhci_controller_setup_pci(struct pci_device *pci) +{ + struct usb_xhci_s *xhci; + void *baseaddr; + + baseaddr = pci_enable_membar(pci, PCI_BASE_ADDRESS_0); + if (!baseaddr) + return; + + dprintf(1, "PCI: XHCI at %pP (mmio %p)\n", pci, baseaddr); pci_enable_busmaster(pci);
+ xhci = xhci_controller_setup(baseaddr); + if (!xhci) + return; + + xhci->usb.pci = pci; run_thread(configure_xhci, xhci); }
@@ -629,10 +642,11 @@ xhci_setup(void) { if (! CONFIG_USB_XHCI) return; + struct pci_device *pci; foreachpci(pci) { if (pci_classprog(pci) == PCI_CLASS_SERIAL_USB_XHCI) - xhci_controller_setup(pci); + xhci_controller_setup_pci(pci); } }
Add xhci_controller_setup_acpi() function to initialize usb host adapters declared in the DSDT table. Search the acpi devices list for xhci controllers.
Signed-off-by: Gerd Hoffmann kraxel@redhat.com --- src/hw/usb-xhci.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)
diff --git a/src/hw/usb-xhci.c b/src/hw/usb-xhci.c index f27867e4f184..c35f2211983d 100644 --- a/src/hw/usb-xhci.c +++ b/src/hw/usb-xhci.c @@ -637,6 +637,29 @@ xhci_controller_setup_pci(struct pci_device *pci) run_thread(configure_xhci, xhci); }
+static void +xhci_controller_setup_acpi(struct acpi_device *dev) +{ + struct usb_xhci_s *xhci; + u64 mem, unused; + void *baseaddr; + + if (acpi_dsdt_find_mem(dev, &mem, &unused) < 0) + return; + if (mem >= 0x100000000ll) + return; + + baseaddr = (void*)(u32)mem; + dprintf(1, "ACPI: XHCI at mmio %p\n", baseaddr); + + xhci = xhci_controller_setup(baseaddr); + if (!xhci) + return; + + xhci->usb.mmio = baseaddr; + run_thread(configure_xhci, xhci); +} + void xhci_setup(void) { @@ -648,6 +671,14 @@ xhci_setup(void) if (pci_classprog(pci) == PCI_CLASS_SERIAL_USB_XHCI) xhci_controller_setup_pci(pci); } + + u16 xhci_eisaid = 0x0d10; + struct acpi_device *dev; + for (dev = acpi_dsdt_find_eisaid(NULL, xhci_eisaid); + dev != NULL; + dev = acpi_dsdt_find_eisaid(dev, xhci_eisaid)) { + xhci_controller_setup_acpi(dev); + } }
On Wed, Sep 30, 2020 at 01:14:30PM +0200, Gerd Hoffmann wrote:
Gerd Hoffmann (3):
usb: add boot prio support for mmio host adapters
usb/xhci: split xhci setup into generic and pci parts
usb/xhci: add support for mmio host adapters (via acpi).
Thanks. The series looks okay to me.
-Kevin
On Wed, Sep 30, 2020 at 11:28:03AM -0400, Kevin O'Connor wrote:
On Wed, Sep 30, 2020 at 01:14:30PM +0200, Gerd Hoffmann wrote:
Gerd Hoffmann (3):
usb: add boot prio support for mmio host adapters
usb/xhci: split xhci setup into generic and pci parts
usb/xhci: add support for mmio host adapters (via acpi).
Thanks. The series looks okay to me.
Committed & pushed.
take care, Gerd