~ubuntu-branches/ubuntu/trusty/qemu/trusty

« back to all changes in this revision

Viewing changes to hw/usb/hcd-ohci.c

  • Committer: Package Import Robot
  • Author(s): Serge Hallyn
  • Date: 2013-10-22 22:47:07 UTC
  • mfrom: (1.8.3) (10.1.42 sid)
  • Revision ID: package-import@ubuntu.com-20131022224707-1lya34fw3k3f24tv
Tags: 1.6.0+dfsg-2ubuntu1
* Merge 1.6.0~rc0+dfsg-2exp from debian experimental.  Remaining changes:
  - debian/control
    * update maintainer
    * remove libiscsi, usb-redir, vde, vnc-jpeg, and libssh2-1-dev
      from build-deps
    * enable rbd
    * add qemu-system and qemu-common B/R to qemu-keymaps
    * add D:udev, R:qemu, R:qemu-common and B:qemu-common to
      qemu-system-common
    * qemu-system-arm, qemu-system-ppc, qemu-system-sparc:
      - add qemu-kvm to Provides
      - add qemu-common, qemu-kvm, kvm to B/R
      - remove openbios-sparc from qemu-system-sparc D
      - drop openbios-ppc and openhackware Depends to Suggests (for now)
    * qemu-system-x86:
      - add qemu-common to Breaks/Replaces.
      - add cpu-checker to Recommends.
    * qemu-user: add B/R:qemu-kvm
    * qemu-kvm:
      - add armhf armel powerpc sparc to Architecture
      - C/R/P: qemu-kvm-spice
    * add qemu-common package
    * drop qemu-slof which is not packaged in ubuntu
  - add qemu-system-common.links for tap ifup/down scripts and OVMF link.
  - qemu-system-x86.links:
    * remove pxe rom links which are in kvm-ipxe
    * add symlink for kvm.1 manpage
  - debian/rules
    * add kvm-spice symlink to qemu-kvm
    * call dh_installmodules for qemu-system-x86
    * update dh_installinit to install upstart script
    * run dh_installman (Closes: #709241) (cherrypicked from 1.5.0+dfsg-2)
  - Add qemu-utils.links for kvm-* symlinks.
  - Add qemu-system-x86.qemu-kvm.upstart and .default
  - Add qemu-system-x86.modprobe to set nesting=1
  - Add qemu-system-common.preinst to add kvm group
  - qemu-system-common.postinst: remove bad group acl if there, then have
    udev relabel /dev/kvm.
  - New linaro patches from qemu-linaro rebasing branch
  - Dropped patches:
    * xen-simplify-xen_enabled.patch
    * sparc-linux-user-fix-missing-symbols-in-.rel-.rela.plt-sections.patch
    * main_loop-do-not-set-nonblocking-if-xen_enabled.patch
    * xen_machine_pv-do-not-create-a-dummy-CPU-in-machine-.patch
    * virtio-rng-fix-crash
  - Kept patches:
    * expose_vms_qemu64cpu.patch - updated
    * linaro arm patches from qemu-linaro rebasing branch
  - New patches:
    * fix-pci-add: change CONFIG variable in ifdef to make sure that
      pci_add is defined.
* Add linaro patches
* Add experimental mach-virt patches for arm virtualization.
* qemu-system-common.install: add debian/tmp/usr/lib to install the
  qemu-bridge-helper

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 *  o Allocate bandwidth in frames properly
23
23
 *  o Disable timers when nothing needs to be done, or remove timer usage
24
24
 *    all together.
25
 
 *  o Handle unrecoverable errors properly
26
25
 *  o BIOS work to boot from USB storage
27
26
*/
28
27
 
62
61
    USBBus bus;
63
62
    qemu_irq irq;
64
63
    MemoryRegion mem;
65
 
    DMAContext *dma;
 
64
    AddressSpace *as;
66
65
    int num_ports;
67
66
    const char *name;
68
67
 
308
307
 
309
308
#define OHCI_HRESET_FSBIR       (1 << 0)
310
309
 
 
310
static void ohci_die(OHCIState *ohci);
 
311
 
311
312
/* Update IRQ levels */
312
313
static inline void ohci_intr_update(OHCIState *ohci)
313
314
{
508
509
    addr += ohci->localmem_base;
509
510
 
510
511
    for (i = 0; i < num; i++, buf++, addr += sizeof(*buf)) {
511
 
        dma_memory_read(ohci->dma, addr, buf, sizeof(*buf));
 
512
        if (dma_memory_read(ohci->as, addr, buf, sizeof(*buf))) {
 
513
            return -1;
 
514
        }
512
515
        *buf = le32_to_cpu(*buf);
513
516
    }
514
517
 
515
 
    return 1;
 
518
    return 0;
516
519
}
517
520
 
518
521
/* Put an array of dwords in to main memory */
525
528
 
526
529
    for (i = 0; i < num; i++, buf++, addr += sizeof(*buf)) {
527
530
        uint32_t tmp = cpu_to_le32(*buf);
528
 
        dma_memory_write(ohci->dma, addr, &tmp, sizeof(tmp));
 
531
        if (dma_memory_write(ohci->as, addr, &tmp, sizeof(tmp))) {
 
532
            return -1;
 
533
        }
529
534
    }
530
535
 
531
 
    return 1;
 
536
    return 0;
532
537
}
533
538
 
534
539
/* Get an array of words from main memory */
540
545
    addr += ohci->localmem_base;
541
546
 
542
547
    for (i = 0; i < num; i++, buf++, addr += sizeof(*buf)) {
543
 
        dma_memory_read(ohci->dma, addr, buf, sizeof(*buf));
 
548
        if (dma_memory_read(ohci->as, addr, buf, sizeof(*buf))) {
 
549
            return -1;
 
550
        }
544
551
        *buf = le16_to_cpu(*buf);
545
552
    }
546
553
 
547
 
    return 1;
 
554
    return 0;
548
555
}
549
556
 
550
557
/* Put an array of words in to main memory */
557
564
 
558
565
    for (i = 0; i < num; i++, buf++, addr += sizeof(*buf)) {
559
566
        uint16_t tmp = cpu_to_le16(*buf);
560
 
        dma_memory_write(ohci->dma, addr, &tmp, sizeof(tmp));
 
567
        if (dma_memory_write(ohci->as, addr, &tmp, sizeof(tmp))) {
 
568
            return -1;
 
569
        }
561
570
    }
562
571
 
563
 
    return 1;
 
572
    return 0;
564
573
}
565
574
 
566
575
static inline int ohci_read_ed(OHCIState *ohci,
578
587
static inline int ohci_read_iso_td(OHCIState *ohci,
579
588
                                   dma_addr_t addr, struct ohci_iso_td *td)
580
589
{
581
 
    return (get_dwords(ohci, addr, (uint32_t *)td, 4) &&
582
 
            get_words(ohci, addr + 16, td->offset, 8));
 
590
    return get_dwords(ohci, addr, (uint32_t *)td, 4) ||
 
591
           get_words(ohci, addr + 16, td->offset, 8);
583
592
}
584
593
 
585
594
static inline int ohci_read_hcca(OHCIState *ohci,
586
595
                                 dma_addr_t addr, struct ohci_hcca *hcca)
587
596
{
588
 
    dma_memory_read(ohci->dma, addr + ohci->localmem_base, hcca, sizeof(*hcca));
589
 
    return 1;
 
597
    return dma_memory_read(ohci->as, addr + ohci->localmem_base,
 
598
                           hcca, sizeof(*hcca));
590
599
}
591
600
 
592
601
static inline int ohci_put_ed(OHCIState *ohci,
610
619
static inline int ohci_put_iso_td(OHCIState *ohci,
611
620
                                  dma_addr_t addr, struct ohci_iso_td *td)
612
621
{
613
 
    return (put_dwords(ohci, addr, (uint32_t *)td, 4) &&
614
 
            put_words(ohci, addr + 16, td->offset, 8));
 
622
    return put_dwords(ohci, addr, (uint32_t *)td, 4 ||
 
623
           put_words(ohci, addr + 16, td->offset, 8));
615
624
}
616
625
 
617
626
static inline int ohci_put_hcca(OHCIState *ohci,
618
627
                                dma_addr_t addr, struct ohci_hcca *hcca)
619
628
{
620
 
    dma_memory_write(ohci->dma,
621
 
                     addr + ohci->localmem_base + HCCA_WRITEBACK_OFFSET,
622
 
                     (char *)hcca + HCCA_WRITEBACK_OFFSET,
623
 
                     HCCA_WRITEBACK_SIZE);
624
 
    return 1;
 
629
    return dma_memory_write(ohci->as,
 
630
                            addr + ohci->localmem_base + HCCA_WRITEBACK_OFFSET,
 
631
                            (char *)hcca + HCCA_WRITEBACK_OFFSET,
 
632
                            HCCA_WRITEBACK_SIZE);
625
633
}
626
634
 
627
635
/* Read/Write the contents of a TD from/to main memory.  */
628
 
static void ohci_copy_td(OHCIState *ohci, struct ohci_td *td,
629
 
                         uint8_t *buf, int len, DMADirection dir)
 
636
static int ohci_copy_td(OHCIState *ohci, struct ohci_td *td,
 
637
                        uint8_t *buf, int len, DMADirection dir)
630
638
{
631
639
    dma_addr_t ptr, n;
632
640
 
634
642
    n = 0x1000 - (ptr & 0xfff);
635
643
    if (n > len)
636
644
        n = len;
637
 
    dma_memory_rw(ohci->dma, ptr + ohci->localmem_base, buf, n, dir);
638
 
    if (n == len)
639
 
        return;
 
645
 
 
646
    if (dma_memory_rw(ohci->as, ptr + ohci->localmem_base, buf, n, dir)) {
 
647
        return -1;
 
648
    }
 
649
    if (n == len) {
 
650
        return 0;
 
651
    }
640
652
    ptr = td->be & ~0xfffu;
641
653
    buf += n;
642
 
    dma_memory_rw(ohci->dma, ptr + ohci->localmem_base, buf, len - n, dir);
 
654
    if (dma_memory_rw(ohci->as, ptr + ohci->localmem_base, buf,
 
655
                      len - n, dir)) {
 
656
        return -1;
 
657
    }
 
658
    return 0;
643
659
}
644
660
 
645
661
/* Read/Write the contents of an ISO TD from/to main memory.  */
646
 
static void ohci_copy_iso_td(OHCIState *ohci,
647
 
                             uint32_t start_addr, uint32_t end_addr,
648
 
                             uint8_t *buf, int len, DMADirection dir)
 
662
static int ohci_copy_iso_td(OHCIState *ohci,
 
663
                            uint32_t start_addr, uint32_t end_addr,
 
664
                            uint8_t *buf, int len, DMADirection dir)
649
665
{
650
666
    dma_addr_t ptr, n;
651
667
 
653
669
    n = 0x1000 - (ptr & 0xfff);
654
670
    if (n > len)
655
671
        n = len;
656
 
    dma_memory_rw(ohci->dma, ptr + ohci->localmem_base, buf, n, dir);
657
 
    if (n == len)
658
 
        return;
 
672
 
 
673
    if (dma_memory_rw(ohci->as, ptr + ohci->localmem_base, buf, n, dir)) {
 
674
        return -1;
 
675
    }
 
676
    if (n == len) {
 
677
        return 0;
 
678
    }
659
679
    ptr = end_addr & ~0xfffu;
660
680
    buf += n;
661
 
    dma_memory_rw(ohci->dma, ptr + ohci->localmem_base, buf, len - n, dir);
 
681
    if (dma_memory_rw(ohci->as, ptr + ohci->localmem_base, buf,
 
682
                      len - n, dir)) {
 
683
        return -1;
 
684
    }
 
685
    return 0;
662
686
}
663
687
 
664
688
static void ohci_process_lists(OHCIState *ohci, int completion);
698
722
 
699
723
    addr = ed->head & OHCI_DPTR_MASK;
700
724
 
701
 
    if (!ohci_read_iso_td(ohci, addr, &iso_td)) {
 
725
    if (ohci_read_iso_td(ohci, addr, &iso_td)) {
702
726
        printf("usb-ohci: ISO_TD read error at %x\n", addr);
 
727
        ohci_die(ohci);
703
728
        return 0;
704
729
    }
705
730
 
740
765
        i = OHCI_BM(iso_td.flags, TD_DI);
741
766
        if (i < ohci->done_count)
742
767
            ohci->done_count = i;
743
 
        ohci_put_iso_td(ohci, addr, &iso_td);
 
768
        if (ohci_put_iso_td(ohci, addr, &iso_td)) {
 
769
            ohci_die(ohci);
 
770
            return 1;
 
771
        }
744
772
        return 0;
745
773
    }
746
774
 
821
849
    }
822
850
 
823
851
    if (len && dir != OHCI_TD_DIR_IN) {
824
 
        ohci_copy_iso_td(ohci, start_addr, end_addr, ohci->usb_buf, len,
825
 
                         DMA_DIRECTION_TO_DEVICE);
 
852
        if (ohci_copy_iso_td(ohci, start_addr, end_addr, ohci->usb_buf, len,
 
853
                             DMA_DIRECTION_TO_DEVICE)) {
 
854
            ohci_die(ohci);
 
855
            return 1;
 
856
        }
826
857
    }
827
858
 
828
859
    if (!completion) {
852
883
    /* Writeback */
853
884
    if (dir == OHCI_TD_DIR_IN && ret >= 0 && ret <= len) {
854
885
        /* IN transfer succeeded */
855
 
        ohci_copy_iso_td(ohci, start_addr, end_addr, ohci->usb_buf, ret,
856
 
                         DMA_DIRECTION_FROM_DEVICE);
 
886
        if (ohci_copy_iso_td(ohci, start_addr, end_addr, ohci->usb_buf, ret,
 
887
                             DMA_DIRECTION_FROM_DEVICE)) {
 
888
            ohci_die(ohci);
 
889
            return 1;
 
890
        }
857
891
        OHCI_SET_BM(iso_td.offset[relative_frame_number], TD_PSW_CC,
858
892
                    OHCI_CC_NOERROR);
859
893
        OHCI_SET_BM(iso_td.offset[relative_frame_number], TD_PSW_SIZE, ret);
910
944
        if (i < ohci->done_count)
911
945
            ohci->done_count = i;
912
946
    }
913
 
    ohci_put_iso_td(ohci, addr, &iso_td);
 
947
    if (ohci_put_iso_td(ohci, addr, &iso_td)) {
 
948
        ohci_die(ohci);
 
949
    }
914
950
    return 1;
915
951
}
916
952
 
943
979
#endif
944
980
        return 1;
945
981
    }
946
 
    if (!ohci_read_td(ohci, addr, &td)) {
 
982
    if (ohci_read_td(ohci, addr, &td)) {
947
983
        fprintf(stderr, "usb-ohci: TD read error at %x\n", addr);
 
984
        ohci_die(ohci);
948
985
        return 0;
949
986
    }
950
987
 
997
1034
                pktlen = len;
998
1035
            }
999
1036
            if (!completion) {
1000
 
                ohci_copy_td(ohci, &td, ohci->usb_buf, pktlen,
1001
 
                             DMA_DIRECTION_TO_DEVICE);
 
1037
                if (ohci_copy_td(ohci, &td, ohci->usb_buf, pktlen,
 
1038
                                 DMA_DIRECTION_TO_DEVICE)) {
 
1039
                    ohci_die(ohci);
 
1040
                }
1002
1041
            }
1003
1042
        }
1004
1043
    }
1055
1094
 
1056
1095
    if (ret >= 0) {
1057
1096
        if (dir == OHCI_TD_DIR_IN) {
1058
 
            ohci_copy_td(ohci, &td, ohci->usb_buf, ret,
1059
 
                         DMA_DIRECTION_FROM_DEVICE);
 
1097
            if (ohci_copy_td(ohci, &td, ohci->usb_buf, ret,
 
1098
                             DMA_DIRECTION_FROM_DEVICE)) {
 
1099
                ohci_die(ohci);
 
1100
            }
1060
1101
#ifdef DEBUG_PACKET
1061
1102
            DPRINTF("  data:");
1062
1103
            for (i = 0; i < ret; i++)
1133
1174
    if (i < ohci->done_count)
1134
1175
        ohci->done_count = i;
1135
1176
exit_no_retire:
1136
 
    ohci_put_td(ohci, addr, &td);
 
1177
    if (ohci_put_td(ohci, addr, &td)) {
 
1178
        ohci_die(ohci);
 
1179
        return 1;
 
1180
    }
1137
1181
    return OHCI_BM(td.flags, TD_CC) != OHCI_CC_NOERROR;
1138
1182
}
1139
1183
 
1151
1195
        return 0;
1152
1196
 
1153
1197
    for (cur = head; cur; cur = next_ed) {
1154
 
        if (!ohci_read_ed(ohci, cur, &ed)) {
 
1198
        if (ohci_read_ed(ohci, cur, &ed)) {
1155
1199
            fprintf(stderr, "usb-ohci: ED read error at %x\n", cur);
 
1200
            ohci_die(ohci);
1156
1201
            return 0;
1157
1202
        }
1158
1203
 
1194
1239
            }
1195
1240
        }
1196
1241
 
1197
 
        ohci_put_ed(ohci, cur, &ed);
 
1242
        if (ohci_put_ed(ohci, cur, &ed)) {
 
1243
            ohci_die(ohci);
 
1244
            return 0;
 
1245
        }
1198
1246
    }
1199
1247
 
1200
1248
    return active;
1236
1284
    OHCIState *ohci = opaque;
1237
1285
    struct ohci_hcca hcca;
1238
1286
 
1239
 
    ohci_read_hcca(ohci, ohci->hcca, &hcca);
 
1287
    if (ohci_read_hcca(ohci, ohci->hcca, &hcca)) {
 
1288
        fprintf(stderr, "usb-ohci: HCCA read error at %x\n", ohci->hcca);
 
1289
        ohci_die(ohci);
 
1290
        return;
 
1291
    }
1240
1292
 
1241
1293
    /* Process all the lists at the end of the frame */
1242
1294
    if (ohci->ctl & OHCI_CTL_PLE) {
1257
1309
    ohci->old_ctl = ohci->ctl;
1258
1310
    ohci_process_lists(ohci, 0);
1259
1311
 
 
1312
    /* Stop if UnrecoverableError happened or ohci_sof will crash */
 
1313
    if (ohci->intr_status & OHCI_INTR_UE) {
 
1314
        return;
 
1315
    }
 
1316
 
1260
1317
    /* Frame boundary, so do EOF stuf here */
1261
1318
    ohci->frt = ohci->fit;
1262
1319
 
1282
1339
    ohci_sof(ohci);
1283
1340
 
1284
1341
    /* Writeback HCCA */
1285
 
    ohci_put_hcca(ohci, ohci->hcca, &hcca);
 
1342
    if (ohci_put_hcca(ohci, ohci->hcca, &hcca)) {
 
1343
        ohci_die(ohci);
 
1344
    }
1286
1345
}
1287
1346
 
1288
1347
/* Start sending SOF tokens across the USB bus, lists are processed in
1296
1355
 
1297
1356
    if (ohci->eof_timer == NULL) {
1298
1357
        fprintf(stderr, "usb-ohci: %s: qemu_new_timer_ns failed\n", ohci->name);
1299
 
        /* TODO: Signal unrecoverable error */
 
1358
        ohci_die(ohci);
1300
1359
        return 0;
1301
1360
    }
1302
1361
 
1788
1847
static int usb_ohci_init(OHCIState *ohci, DeviceState *dev,
1789
1848
                         int num_ports, dma_addr_t localmem_base,
1790
1849
                         char *masterbus, uint32_t firstport,
1791
 
                         DMAContext *dma)
 
1850
                         AddressSpace *as)
1792
1851
{
1793
1852
    int i;
1794
1853
 
1795
 
    ohci->dma = dma;
 
1854
    ohci->as = as;
1796
1855
 
1797
1856
    if (usb_frame_time == 0) {
1798
1857
#ifdef OHCI_TIME_WARP
1830
1889
        }
1831
1890
    }
1832
1891
 
1833
 
    memory_region_init_io(&ohci->mem, &ohci_mem_ops, ohci, "ohci", 256);
 
1892
    memory_region_init_io(&ohci->mem, OBJECT(dev), &ohci_mem_ops,
 
1893
                          ohci, "ohci", 256);
1834
1894
    ohci->localmem_base = localmem_base;
1835
1895
 
1836
1896
    ohci->name = object_get_typename(OBJECT(dev));
1842
1902
    return 0;
1843
1903
}
1844
1904
 
 
1905
#define TYPE_PCI_OHCI "pci-ohci"
 
1906
#define PCI_OHCI(obj) OBJECT_CHECK(OHCIPCIState, (obj), TYPE_PCI_OHCI)
 
1907
 
1845
1908
typedef struct {
1846
 
    PCIDevice pci_dev;
 
1909
    /*< private >*/
 
1910
    PCIDevice parent_obj;
 
1911
    /*< public >*/
 
1912
 
1847
1913
    OHCIState state;
1848
1914
    char *masterbus;
1849
1915
    uint32_t num_ports;
1850
1916
    uint32_t firstport;
1851
1917
} OHCIPCIState;
1852
1918
 
1853
 
static int usb_ohci_initfn_pci(struct PCIDevice *dev)
1854
 
{
1855
 
    OHCIPCIState *ohci = DO_UPCAST(OHCIPCIState, pci_dev, dev);
1856
 
 
1857
 
    ohci->pci_dev.config[PCI_CLASS_PROG] = 0x10; /* OHCI */
1858
 
    ohci->pci_dev.config[PCI_INTERRUPT_PIN] = 0x01; /* interrupt pin A */
1859
 
 
1860
 
    if (usb_ohci_init(&ohci->state, &dev->qdev, ohci->num_ports, 0,
 
1919
/** A typical O/EHCI will stop operating, set itself into error state
 
1920
 * (which can be queried by MMIO) and will set PERR in its config
 
1921
 * space to signal that it got an error
 
1922
 */
 
1923
static void ohci_die(OHCIState *ohci)
 
1924
{
 
1925
    OHCIPCIState *dev = container_of(ohci, OHCIPCIState, state);
 
1926
 
 
1927
    fprintf(stderr, "%s: DMA error\n", __func__);
 
1928
 
 
1929
    ohci_set_interrupt(ohci, OHCI_INTR_UE);
 
1930
    ohci_bus_stop(ohci);
 
1931
    pci_set_word(dev->parent_obj.config + PCI_STATUS,
 
1932
                 PCI_STATUS_DETECTED_PARITY);
 
1933
}
 
1934
 
 
1935
static int usb_ohci_initfn_pci(PCIDevice *dev)
 
1936
{
 
1937
    OHCIPCIState *ohci = PCI_OHCI(dev);
 
1938
 
 
1939
    dev->config[PCI_CLASS_PROG] = 0x10; /* OHCI */
 
1940
    dev->config[PCI_INTERRUPT_PIN] = 0x01; /* interrupt pin A */
 
1941
 
 
1942
    if (usb_ohci_init(&ohci->state, DEVICE(dev), ohci->num_ports, 0,
1861
1943
                      ohci->masterbus, ohci->firstport,
1862
 
                      pci_dma_context(dev)) != 0) {
 
1944
                      pci_get_address_space(dev)) != 0) {
1863
1945
        return -1;
1864
1946
    }
1865
 
    ohci->state.irq = ohci->pci_dev.irq[0];
 
1947
    ohci->state.irq = dev->irq[0];
1866
1948
 
1867
 
    /* TODO: avoid cast below by using dev */
1868
 
    pci_register_bar(&ohci->pci_dev, 0, 0, &ohci->state.mem);
 
1949
    pci_register_bar(dev, 0, 0, &ohci->state.mem);
1869
1950
    return 0;
1870
1951
}
1871
1952
 
 
1953
#define TYPE_SYSBUS_OHCI "sysbus-ohci"
 
1954
#define SYSBUS_OHCI(obj) OBJECT_CHECK(OHCISysBusState, (obj), TYPE_SYSBUS_OHCI)
 
1955
 
1872
1956
typedef struct {
1873
 
    SysBusDevice busdev;
 
1957
    /*< private >*/
 
1958
    SysBusDevice parent_obj;
 
1959
    /*< public >*/
 
1960
 
1874
1961
    OHCIState ohci;
1875
1962
    uint32_t num_ports;
1876
1963
    dma_addr_t dma_offset;
1877
1964
} OHCISysBusState;
1878
1965
 
1879
 
static int ohci_init_pxa(SysBusDevice *dev)
 
1966
static void ohci_realize_pxa(DeviceState *dev, Error **errp)
1880
1967
{
1881
 
    OHCISysBusState *s = FROM_SYSBUS(OHCISysBusState, dev);
 
1968
    OHCISysBusState *s = SYSBUS_OHCI(dev);
 
1969
    SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
1882
1970
 
1883
1971
    /* Cannot fail as we pass NULL for masterbus */
1884
 
    usb_ohci_init(&s->ohci, &dev->qdev, s->num_ports, s->dma_offset, NULL, 0,
1885
 
                  &dma_context_memory);
1886
 
    sysbus_init_irq(dev, &s->ohci.irq);
1887
 
    sysbus_init_mmio(dev, &s->ohci.mem);
1888
 
 
1889
 
    return 0;
 
1972
    usb_ohci_init(&s->ohci, dev, s->num_ports, s->dma_offset, NULL, 0,
 
1973
                  &address_space_memory);
 
1974
    sysbus_init_irq(sbd, &s->ohci.irq);
 
1975
    sysbus_init_mmio(sbd, &s->ohci.mem);
1890
1976
}
1891
1977
 
1892
1978
static Property ohci_pci_properties[] = {
1906
1992
    k->device_id = PCI_DEVICE_ID_APPLE_IPID_USB;
1907
1993
    k->class_id = PCI_CLASS_SERIAL_USB;
1908
1994
    k->no_hotplug = 1;
 
1995
    set_bit(DEVICE_CATEGORY_USB, dc->categories);
1909
1996
    dc->desc = "Apple USB Controller";
1910
1997
    dc->props = ohci_pci_properties;
1911
1998
}
1912
1999
 
1913
2000
static const TypeInfo ohci_pci_info = {
1914
 
    .name          = "pci-ohci",
 
2001
    .name          = TYPE_PCI_OHCI,
1915
2002
    .parent        = TYPE_PCI_DEVICE,
1916
2003
    .instance_size = sizeof(OHCIPCIState),
1917
2004
    .class_init    = ohci_pci_class_init,
1926
2013
static void ohci_sysbus_class_init(ObjectClass *klass, void *data)
1927
2014
{
1928
2015
    DeviceClass *dc = DEVICE_CLASS(klass);
1929
 
    SysBusDeviceClass *sbc = SYS_BUS_DEVICE_CLASS(klass);
1930
2016
 
1931
 
    sbc->init = ohci_init_pxa;
 
2017
    dc->realize = ohci_realize_pxa;
 
2018
    set_bit(DEVICE_CATEGORY_USB, dc->categories);
1932
2019
    dc->desc = "OHCI USB Controller";
1933
2020
    dc->props = ohci_sysbus_properties;
1934
2021
}
1935
2022
 
1936
2023
static const TypeInfo ohci_sysbus_info = {
1937
 
    .name          = "sysbus-ohci",
 
2024
    .name          = TYPE_SYSBUS_OHCI,
1938
2025
    .parent        = TYPE_SYS_BUS_DEVICE,
1939
2026
    .instance_size = sizeof(OHCISysBusState),
1940
2027
    .class_init    = ohci_sysbus_class_init,