2
0

hcd-xhci-nec.c 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. #include "qemu/osdep.h"
  22. #include "hw/usb.h"
  23. #include "qemu/module.h"
  24. #include "hw/pci/pci.h"
  25. #include "hw/qdev-properties.h"
  26. #include "hcd-xhci-pci.h"
  27. OBJECT_DECLARE_SIMPLE_TYPE(XHCINecState, NEC_XHCI)
  28. struct XHCINecState {
  29. XHCIPciState parent_obj;
  30. uint32_t intrs;
  31. uint32_t slots;
  32. };
  33. static const Property nec_xhci_properties[] = {
  34. DEFINE_PROP_UINT32("intrs", XHCINecState, intrs, XHCI_MAXINTRS),
  35. DEFINE_PROP_UINT32("slots", XHCINecState, slots, XHCI_MAXSLOTS),
  36. };
  37. static void nec_xhci_instance_init(Object *obj)
  38. {
  39. XHCIPciState *pci = XHCI_PCI(obj);
  40. XHCINecState *nec = NEC_XHCI(obj);
  41. pci->xhci.numintrs = nec->intrs;
  42. pci->xhci.numslots = nec->slots;
  43. }
  44. static void nec_xhci_class_init(ObjectClass *klass, void *data)
  45. {
  46. PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
  47. DeviceClass *dc = DEVICE_CLASS(klass);
  48. device_class_set_props(dc, nec_xhci_properties);
  49. k->vendor_id = PCI_VENDOR_ID_NEC;
  50. k->device_id = PCI_DEVICE_ID_NEC_UPD720200;
  51. k->revision = 0x03;
  52. }
  53. static const TypeInfo nec_xhci_info = {
  54. .name = TYPE_NEC_XHCI,
  55. .parent = TYPE_XHCI_PCI,
  56. .instance_size = sizeof(XHCINecState),
  57. .instance_init = nec_xhci_instance_init,
  58. .class_init = nec_xhci_class_init,
  59. };
  60. static void nec_xhci_register_types(void)
  61. {
  62. type_register_static(&nec_xhci_info);
  63. }
  64. type_init(nec_xhci_register_types)