xref: /openbmc/qemu/hw/usb/vt82c686-uhci-pci.c (revision e0091133)
1 #include "qemu/osdep.h"
2 #include "hw/irq.h"
3 #include "hw/isa/vt82c686.h"
4 #include "hcd-uhci.h"
5 
6 static void uhci_isa_set_irq(void *opaque, int irq_num, int level)
7 {
8     UHCIState *s = opaque;
9     uint8_t irq = pci_get_byte(s->dev.config + PCI_INTERRUPT_LINE);
10     if (irq > 0 && irq < 15) {
11         via_isa_set_irq(pci_get_function_0(&s->dev), irq, level);
12     }
13 }
14 
15 static void usb_uhci_vt82c686b_realize(PCIDevice *dev, Error **errp)
16 {
17     UHCIState *s = UHCI(dev);
18     uint8_t *pci_conf = s->dev.config;
19 
20     /* USB misc control 1/2 */
21     pci_set_long(pci_conf + 0x40, 0x00001000);
22     /* PM capability */
23     pci_set_long(pci_conf + 0x80, 0x00020001);
24     /* USB legacy support  */
25     pci_set_long(pci_conf + 0xc0, 0x00002000);
26 
27     usb_uhci_common_realize(dev, errp);
28     object_unref(s->irq);
29     s->irq = qemu_allocate_irq(uhci_isa_set_irq, s, 0);
30 }
31 
32 static UHCIInfo uhci_info[] = {
33     {
34         .name      = TYPE_VT82C686B_USB_UHCI,
35         .vendor_id = PCI_VENDOR_ID_VIA,
36         .device_id = PCI_DEVICE_ID_VIA_UHCI,
37         .revision  = 0x01,
38         .irq_pin   = 3,
39         .realize   = usb_uhci_vt82c686b_realize,
40         .unplug    = true,
41         /* Reason: only works as USB function of VT82xx superio chips */
42         .notuser   = true,
43     }
44 };
45 
46 static const TypeInfo vt82c686b_usb_uhci_type_info = {
47     .parent         = TYPE_UHCI,
48     .name           = TYPE_VT82C686B_USB_UHCI,
49     .class_init     = uhci_data_class_init,
50     .class_data     = uhci_info,
51 };
52 
53 static void vt82c686b_usb_uhci_register_types(void)
54 {
55     type_register_static(&vt82c686b_usb_uhci_type_info);
56 }
57 
58 type_init(vt82c686b_usb_uhci_register_types)
59