usb-uhci: convert to PCIDEviceInfo to initialize ids
use PCIDeviceInfo to initialize ids. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
		
							parent
							
								
									113f89df42
								
							
						
					
					
						commit
						dc638fadb5
					
				@ -1115,14 +1115,13 @@ static USBPortOps uhci_port_ops = {
 | 
				
			|||||||
    .wakeup = uhci_wakeup,
 | 
					    .wakeup = uhci_wakeup,
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int usb_uhci_common_initfn(UHCIState *s)
 | 
					static int usb_uhci_common_initfn(PCIDevice *dev)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					    UHCIState *s = DO_UPCAST(UHCIState, dev, dev);
 | 
				
			||||||
    uint8_t *pci_conf = s->dev.config;
 | 
					    uint8_t *pci_conf = s->dev.config;
 | 
				
			||||||
    int i;
 | 
					    int i;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pci_conf[PCI_REVISION_ID] = 0x01; // revision number
 | 
					 | 
				
			||||||
    pci_conf[PCI_CLASS_PROG] = 0x00;
 | 
					    pci_conf[PCI_CLASS_PROG] = 0x00;
 | 
				
			||||||
    pci_config_set_class(pci_conf, PCI_CLASS_SERIAL_USB);
 | 
					 | 
				
			||||||
    /* TODO: reset value should be 0. */
 | 
					    /* TODO: reset value should be 0. */
 | 
				
			||||||
    pci_conf[PCI_INTERRUPT_PIN] = 4; // interrupt pin 3
 | 
					    pci_conf[PCI_INTERRUPT_PIN] = 4; // interrupt pin 3
 | 
				
			||||||
    pci_conf[0x60] = 0x10; // release number
 | 
					    pci_conf[0x60] = 0x10; // release number
 | 
				
			||||||
@ -1148,34 +1147,11 @@ static int usb_uhci_common_initfn(UHCIState *s)
 | 
				
			|||||||
    return 0;
 | 
					    return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int usb_uhci_piix3_initfn(PCIDevice *dev)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    UHCIState *s = DO_UPCAST(UHCIState, dev, dev);
 | 
					 | 
				
			||||||
    uint8_t *pci_conf = s->dev.config;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_INTEL);
 | 
					 | 
				
			||||||
    pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_INTEL_82371SB_2);
 | 
					 | 
				
			||||||
    return usb_uhci_common_initfn(s);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static int usb_uhci_piix4_initfn(PCIDevice *dev)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    UHCIState *s = DO_UPCAST(UHCIState, dev, dev);
 | 
					 | 
				
			||||||
    uint8_t *pci_conf = s->dev.config;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_INTEL);
 | 
					 | 
				
			||||||
    pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_INTEL_82371AB_2);
 | 
					 | 
				
			||||||
    return usb_uhci_common_initfn(s);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static int usb_uhci_vt82c686b_initfn(PCIDevice *dev)
 | 
					static int usb_uhci_vt82c686b_initfn(PCIDevice *dev)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    UHCIState *s = DO_UPCAST(UHCIState, dev, dev);
 | 
					    UHCIState *s = DO_UPCAST(UHCIState, dev, dev);
 | 
				
			||||||
    uint8_t *pci_conf = s->dev.config;
 | 
					    uint8_t *pci_conf = s->dev.config;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_VIA);
 | 
					 | 
				
			||||||
    pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_VIA_UHCI);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /* USB misc control 1/2 */
 | 
					    /* USB misc control 1/2 */
 | 
				
			||||||
    pci_set_long(pci_conf + 0x40,0x00001000);
 | 
					    pci_set_long(pci_conf + 0x40,0x00001000);
 | 
				
			||||||
    /* PM capability */
 | 
					    /* PM capability */
 | 
				
			||||||
@ -1183,7 +1159,7 @@ static int usb_uhci_vt82c686b_initfn(PCIDevice *dev)
 | 
				
			|||||||
    /* USB legacy support  */
 | 
					    /* USB legacy support  */
 | 
				
			||||||
    pci_set_long(pci_conf + 0xc0,0x00002000);
 | 
					    pci_set_long(pci_conf + 0xc0,0x00002000);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return usb_uhci_common_initfn(s);
 | 
					    return usb_uhci_common_initfn(dev);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static PCIDeviceInfo uhci_info[] = {
 | 
					static PCIDeviceInfo uhci_info[] = {
 | 
				
			||||||
@ -1191,17 +1167,29 @@ static PCIDeviceInfo uhci_info[] = {
 | 
				
			|||||||
        .qdev.name    = "piix3-usb-uhci",
 | 
					        .qdev.name    = "piix3-usb-uhci",
 | 
				
			||||||
        .qdev.size    = sizeof(UHCIState),
 | 
					        .qdev.size    = sizeof(UHCIState),
 | 
				
			||||||
        .qdev.vmsd    = &vmstate_uhci,
 | 
					        .qdev.vmsd    = &vmstate_uhci,
 | 
				
			||||||
        .init         = usb_uhci_piix3_initfn,
 | 
					        .init         = usb_uhci_common_initfn,
 | 
				
			||||||
 | 
					        .vendor_id    = PCI_VENDOR_ID_INTEL,
 | 
				
			||||||
 | 
					        .device_id    = PCI_DEVICE_ID_INTEL_82371SB_2,
 | 
				
			||||||
 | 
					        .revision     = 0x01,
 | 
				
			||||||
 | 
					        .class_id     = PCI_CLASS_SERIAL_USB,
 | 
				
			||||||
    },{
 | 
					    },{
 | 
				
			||||||
        .qdev.name    = "piix4-usb-uhci",
 | 
					        .qdev.name    = "piix4-usb-uhci",
 | 
				
			||||||
        .qdev.size    = sizeof(UHCIState),
 | 
					        .qdev.size    = sizeof(UHCIState),
 | 
				
			||||||
        .qdev.vmsd    = &vmstate_uhci,
 | 
					        .qdev.vmsd    = &vmstate_uhci,
 | 
				
			||||||
        .init         = usb_uhci_piix4_initfn,
 | 
					        .init         = usb_uhci_common_initfn,
 | 
				
			||||||
 | 
					        .vendor_id    = PCI_VENDOR_ID_INTEL,
 | 
				
			||||||
 | 
					        .device_id    = PCI_DEVICE_ID_INTEL_82371AB_2,
 | 
				
			||||||
 | 
					        .revision     = 0x01,
 | 
				
			||||||
 | 
					        .class_id     = PCI_CLASS_SERIAL_USB,
 | 
				
			||||||
    },{
 | 
					    },{
 | 
				
			||||||
        .qdev.name    = "vt82c686b-usb-uhci",
 | 
					        .qdev.name    = "vt82c686b-usb-uhci",
 | 
				
			||||||
        .qdev.size    = sizeof(UHCIState),
 | 
					        .qdev.size    = sizeof(UHCIState),
 | 
				
			||||||
        .qdev.vmsd    = &vmstate_uhci,
 | 
					        .qdev.vmsd    = &vmstate_uhci,
 | 
				
			||||||
        .init         = usb_uhci_vt82c686b_initfn,
 | 
					        .init         = usb_uhci_vt82c686b_initfn,
 | 
				
			||||||
 | 
					        .vendor_id    = PCI_VENDOR_ID_VIA,
 | 
				
			||||||
 | 
					        .device_id    = PCI_DEVICE_ID_VIA_UHCI,
 | 
				
			||||||
 | 
					        .revision     = 0x01,
 | 
				
			||||||
 | 
					        .class_id     = PCI_CLASS_SERIAL_USB,
 | 
				
			||||||
    },{
 | 
					    },{
 | 
				
			||||||
        /* end of list */
 | 
					        /* end of list */
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user