diff mbox

[03/15] ohci: Allow sysbus version to be used as a companion

Message ID 25eb9dc6c387f03754114e4a0584516847f1da7d.1503249785.git.balaton@eik.bme.hu
State New
Headers show

Commit Message

BALATON Zoltan Aug. 20, 2017, 5:23 p.m. UTC
Some PPC SoCs have an EHCI with OHCI companion USB controller. To
emulate this allow the sysbus version of OHCI to be used as a companion.

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
---
 hw/usb/hcd-ohci.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

Comments

David Gibson Aug. 21, 2017, 4:10 a.m. UTC | #1
On Sun, Aug 20, 2017 at 07:23:05PM +0200, BALATON Zoltan wrote:
1;4803;0c> Some PPC SoCs have an EHCI with OHCI companion USB controller. To
> emulate this allow the sysbus version of OHCI to be used as a companion.
> 
> Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>

Gerd,  if you're happy with this, I can queue it for 2.11.  Let me
know what you'd prefer.

> ---
>  hw/usb/hcd-ohci.c | 15 ++++++++++++---
>  1 file changed, 12 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c
> index 267982e..17beedd 100644
> --- a/hw/usb/hcd-ohci.c
> +++ b/hw/usb/hcd-ohci.c
> @@ -1999,7 +1999,9 @@ typedef struct {
>      /*< public >*/
>  
>      OHCIState ohci;
> +    char *masterbus;
>      uint32_t num_ports;
> +    uint32_t firstport;
>      dma_addr_t dma_offset;
>  } OHCISysBusState;
>  
> @@ -2007,10 +2009,15 @@ static void ohci_realize_pxa(DeviceState *dev, Error **errp)
>  {
>      OHCISysBusState *s = SYSBUS_OHCI(dev);
>      SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
> +    Error *err = NULL;
>  
> -    /* Cannot fail as we pass NULL for masterbus */
> -    usb_ohci_init(&s->ohci, dev, s->num_ports, s->dma_offset, NULL, 0,
> -                  &address_space_memory, &error_abort);
> +    usb_ohci_init(&s->ohci, dev, s->num_ports, s->dma_offset,
> +                  s->masterbus, s->firstport,
> +                  &address_space_memory, &err);
> +    if (err) {
> +        error_propagate(errp, err);
> +        return;
> +    }
>      sysbus_init_irq(sbd, &s->ohci.irq);
>      sysbus_init_mmio(sbd, &s->ohci.mem);
>  }
> @@ -2142,7 +2149,9 @@ static const TypeInfo ohci_pci_info = {
>  };
>  
>  static Property ohci_sysbus_properties[] = {
> +    DEFINE_PROP_STRING("masterbus", OHCISysBusState, masterbus),
>      DEFINE_PROP_UINT32("num-ports", OHCISysBusState, num_ports, 3),
> +    DEFINE_PROP_UINT32("firstport", OHCISysBusState, firstport, 0),
>      DEFINE_PROP_DMAADDR("dma-offset", OHCISysBusState, dma_offset, 0),
>      DEFINE_PROP_END_OF_LIST(),
>  };
Gerd Hoffmann Aug. 23, 2017, 1:58 p.m. UTC | #2
On Mon, 2017-08-21 at 14:10 +1000, David Gibson wrote:
> On Sun, Aug 20, 2017 at 07:23:05PM +0200, BALATON Zoltan wrote:
> 1;4803;0c> Some PPC SoCs have an EHCI with OHCI companion USB
> controller. To
> > emulate this allow the sysbus version of OHCI to be used as a
> > companion.
> > 
> > Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
> 
> Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
> 
> Gerd,  if you're happy with this, I can queue it for 2.11.  Let me
> know what you'd prefer.

Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>

cheers,
  Gerd
diff mbox

Patch

diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c
index 267982e..17beedd 100644
--- a/hw/usb/hcd-ohci.c
+++ b/hw/usb/hcd-ohci.c
@@ -1999,7 +1999,9 @@  typedef struct {
     /*< public >*/
 
     OHCIState ohci;
+    char *masterbus;
     uint32_t num_ports;
+    uint32_t firstport;
     dma_addr_t dma_offset;
 } OHCISysBusState;
 
@@ -2007,10 +2009,15 @@  static void ohci_realize_pxa(DeviceState *dev, Error **errp)
 {
     OHCISysBusState *s = SYSBUS_OHCI(dev);
     SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
+    Error *err = NULL;
 
-    /* Cannot fail as we pass NULL for masterbus */
-    usb_ohci_init(&s->ohci, dev, s->num_ports, s->dma_offset, NULL, 0,
-                  &address_space_memory, &error_abort);
+    usb_ohci_init(&s->ohci, dev, s->num_ports, s->dma_offset,
+                  s->masterbus, s->firstport,
+                  &address_space_memory, &err);
+    if (err) {
+        error_propagate(errp, err);
+        return;
+    }
     sysbus_init_irq(sbd, &s->ohci.irq);
     sysbus_init_mmio(sbd, &s->ohci.mem);
 }
@@ -2142,7 +2149,9 @@  static const TypeInfo ohci_pci_info = {
 };
 
 static Property ohci_sysbus_properties[] = {
+    DEFINE_PROP_STRING("masterbus", OHCISysBusState, masterbus),
     DEFINE_PROP_UINT32("num-ports", OHCISysBusState, num_ports, 3),
+    DEFINE_PROP_UINT32("firstport", OHCISysBusState, firstport, 0),
     DEFINE_PROP_DMAADDR("dma-offset", OHCISysBusState, dma_offset, 0),
     DEFINE_PROP_END_OF_LIST(),
 };