Add PowerPC power-management state check callback.
[qemu] / hw / usb-ohci.c
index a4f8aa6..2d5af7d 100644 (file)
@@ -59,8 +59,7 @@ enum ohci_type {
 };
 
 typedef struct {
-    void *pic;
-    int irq;
+    qemu_irq irq;
     enum ohci_type type;
     target_phys_addr_t mem_base;
     int mem;
@@ -121,6 +120,8 @@ struct ohci_hcca {
     uint32_t done;
 };
 
+static void ohci_bus_stop(OHCIState *ohci);
+
 /* Bitfields for the first word of an Endpoint Desciptor.  */
 #define OHCI_ED_FA_SHIFT  0
 #define OHCI_ED_FA_MASK   (0x7f<<OHCI_ED_FA_SHIFT)
@@ -282,10 +283,7 @@ static inline void ohci_intr_update(OHCIState *ohci)
         (ohci->intr_status & ohci->intr))
         level = 1;
 
-    if (ohci->type == OHCI_TYPE_PCI)
-      pci_set_irq((PCIDevice *)ohci->pic, ohci->irq, level);
-    else
-      pic_set_irq_new(ohci->pic, ohci->irq, level);
+    qemu_set_irq(ohci->irq, level);
 }
 
 /* Set an interrupt */
@@ -348,11 +346,13 @@ static void ohci_attach(USBPort *port1, USBDevice *dev)
 }
 
 /* Reset the controller */
-static void ohci_reset(OHCIState *ohci)
+static void ohci_reset(void *opaque)
 {
+    OHCIState *ohci = opaque;
     OHCIPort *port;
     int i;
 
+    ohci_bus_stop(ohci);
     ohci->ctl = 0;
     ohci->old_ctl = 0;
     ohci->status = 0;
@@ -837,6 +837,7 @@ static void ohci_bus_stop(OHCIState *ohci)
 {
     if (ohci->eof_timer)
         qemu_del_timer(ohci->eof_timer);
+    ohci->eof_timer = NULL;
 }
 
 /* Sets a flag in a port status register but only set it if the port is
@@ -922,6 +923,7 @@ static void ohci_set_ctl(OHCIState *ohci, uint32_t val)
         dprintf("usb-ohci: %s: USB Resume\n", ohci->name);
         break;
     case OHCI_USB_RESET:
+        ohci_reset(ohci);
         dprintf("usb-ohci: %s: USB Reset\n", ohci->name);
         break;
     }
@@ -1263,7 +1265,7 @@ static CPUWriteMemoryFunc *ohci_writefn[3]={
 };
 
 static void usb_ohci_init(OHCIState *ohci, int num_ports, int devfn,
-            void *pic, int irq, enum ohci_type type, const char *name)
+            qemu_irq irq, enum ohci_type type, const char *name)
 {
     int i;
 
@@ -1286,7 +1288,6 @@ static void usb_ohci_init(OHCIState *ohci, int num_ports, int devfn,
     ohci->mem = cpu_register_io_memory(0, ohci_readfn, ohci_writefn, ohci);
     ohci->name = name;
 
-    ohci->pic = pic;
     ohci->irq = irq;
     ohci->type = type;
 
@@ -1296,6 +1297,7 @@ static void usb_ohci_init(OHCIState *ohci, int num_ports, int devfn,
     }
 
     ohci->async_td = 0;
+    qemu_register_reset(ohci_reset, ohci);
     ohci_reset(ohci);
 }
 
@@ -1334,21 +1336,21 @@ void usb_ohci_init_pci(struct PCIBus *bus, int num_ports, int devfn)
     ohci->pci_dev.config[0x0b] = 0xc;
     ohci->pci_dev.config[0x3d] = 0x01; /* interrupt pin 1 */
 
-    usb_ohci_init(&ohci->state, num_ports, devfn, &ohci->pci_dev,
-                  0, OHCI_TYPE_PCI, ohci->pci_dev.name);
+    usb_ohci_init(&ohci->state, num_ports, devfn, ohci->pci_dev.irq[0],
+                  OHCI_TYPE_PCI, ohci->pci_dev.name);
 
     pci_register_io_region((struct PCIDevice *)ohci, 0, 256,
                            PCI_ADDRESS_SPACE_MEM, ohci_mapfunc);
 }
 
 void usb_ohci_init_pxa(target_phys_addr_t base, int num_ports, int devfn,
-            void *pic, int irq)
+                       qemu_irq irq)
 {
     OHCIState *ohci = (OHCIState *)qemu_mallocz(sizeof(OHCIState));
 
-    usb_ohci_init(ohci, num_ports, devfn, pic, irq,
+    usb_ohci_init(ohci, num_ports, devfn, irq,
                   OHCI_TYPE_PXA, "OHCI USB");
     ohci->mem_base = base;
 
-    cpu_register_physical_memory(ohci->mem_base, 0xfff, ohci->mem);
+    cpu_register_physical_memory(ohci->mem_base, 0x1000, ohci->mem);
 }