xref: /qemu/hw/usb/hcd-xhci-nec.c (revision 2e73a17c68f4d80023dc616e596e8c1f3ea8dd75)
1  /*
2   * USB xHCI controller emulation
3   *
4   * Copyright (c) 2011 Securiforest
5   * Date: 2011-05-11 ;  Author: Hector Martin <hector@marcansoft.com>
6   * Based on usb-ohci.c, emulates Renesas NEC USB 3.0
7   *
8   * This library is free software; you can redistribute it and/or
9   * modify it under the terms of the GNU Lesser General Public
10   * License as published by the Free Software Foundation; either
11   * version 2.1 of the License, or (at your option) any later version.
12   *
13   * This library is distributed in the hope that it will be useful,
14   * but WITHOUT ANY WARRANTY; without even the implied warranty of
15   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16   * Lesser General Public License for more details.
17   *
18   * You should have received a copy of the GNU Lesser General Public
19   * License along with this library; if not, see <http://www.gnu.org/licenses/>.
20   */
21  
22  #include "qemu/osdep.h"
23  #include "hw/usb.h"
24  #include "qemu/module.h"
25  #include "hw/pci/pci.h"
26  #include "hw/qdev-properties.h"
27  
28  #include "hcd-xhci-pci.h"
29  
30  OBJECT_DECLARE_SIMPLE_TYPE(XHCINecState, NEC_XHCI)
31  
32  struct XHCINecState {
33      XHCIPciState parent_obj;
34  
35      uint32_t intrs;
36      uint32_t slots;
37  };
38  
39  static const Property nec_xhci_properties[] = {
40      DEFINE_PROP_UINT32("intrs", XHCINecState, intrs, XHCI_MAXINTRS),
41      DEFINE_PROP_UINT32("slots", XHCINecState, slots, XHCI_MAXSLOTS),
42  };
43  
44  static void nec_xhci_instance_init(Object *obj)
45  {
46      XHCIPciState *pci = XHCI_PCI(obj);
47      XHCINecState *nec = NEC_XHCI(obj);
48  
49      pci->xhci.numintrs = nec->intrs;
50      pci->xhci.numslots = nec->slots;
51  }
52  
53  static void nec_xhci_class_init(ObjectClass *klass, void *data)
54  {
55      PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
56      DeviceClass *dc = DEVICE_CLASS(klass);
57  
58      device_class_set_props(dc, nec_xhci_properties);
59      k->vendor_id    = PCI_VENDOR_ID_NEC;
60      k->device_id    = PCI_DEVICE_ID_NEC_UPD720200;
61      k->revision     = 0x03;
62  }
63  
64  static const TypeInfo nec_xhci_info = {
65      .name          = TYPE_NEC_XHCI,
66      .parent        = TYPE_XHCI_PCI,
67      .instance_size = sizeof(XHCINecState),
68      .instance_init = nec_xhci_instance_init,
69      .class_init    = nec_xhci_class_init,
70  };
71  
72  static void nec_xhci_register_types(void)
73  {
74      type_register_static(&nec_xhci_info);
75  }
76  
77  type_init(nec_xhci_register_types)
78