xref: /openbmc/qemu/hw/usb/hcd-xhci-nec.c (revision a27bd6c779badb8d76e4430d810ef710a1b98f4e)
10bbb2f3dSGerd Hoffmann /*
20bbb2f3dSGerd Hoffmann  * USB xHCI controller emulation
30bbb2f3dSGerd Hoffmann  *
40bbb2f3dSGerd Hoffmann  * Copyright (c) 2011 Securiforest
50bbb2f3dSGerd Hoffmann  * Date: 2011-05-11 ;  Author: Hector Martin <hector@marcansoft.com>
60bbb2f3dSGerd Hoffmann  * Based on usb-ohci.c, emulates Renesas NEC USB 3.0
70bbb2f3dSGerd Hoffmann  *
80bbb2f3dSGerd Hoffmann  * This library is free software; you can redistribute it and/or
90bbb2f3dSGerd Hoffmann  * modify it under the terms of the GNU Lesser General Public
100bbb2f3dSGerd Hoffmann  * License as published by the Free Software Foundation; either
110bbb2f3dSGerd Hoffmann  * version 2 of the License, or (at your option) any later version.
120bbb2f3dSGerd Hoffmann  *
130bbb2f3dSGerd Hoffmann  * This library is distributed in the hope that it will be useful,
140bbb2f3dSGerd Hoffmann  * but WITHOUT ANY WARRANTY; without even the implied warranty of
150bbb2f3dSGerd Hoffmann  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
160bbb2f3dSGerd Hoffmann  * Lesser General Public License for more details.
170bbb2f3dSGerd Hoffmann  *
180bbb2f3dSGerd Hoffmann  * You should have received a copy of the GNU Lesser General Public
190bbb2f3dSGerd Hoffmann  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
200bbb2f3dSGerd Hoffmann  */
210bbb2f3dSGerd Hoffmann 
220bbb2f3dSGerd Hoffmann #include "qemu/osdep.h"
230bbb2f3dSGerd Hoffmann #include "hw/usb.h"
240b8fa32fSMarkus Armbruster #include "qemu/module.h"
250bbb2f3dSGerd Hoffmann #include "hw/pci/pci.h"
26*a27bd6c7SMarkus Armbruster #include "hw/qdev-properties.h"
270bbb2f3dSGerd Hoffmann 
280bbb2f3dSGerd Hoffmann #include "hcd-xhci.h"
290bbb2f3dSGerd Hoffmann 
300bbb2f3dSGerd Hoffmann static Property nec_xhci_properties[] = {
310bbb2f3dSGerd Hoffmann     DEFINE_PROP_ON_OFF_AUTO("msi", XHCIState, msi, ON_OFF_AUTO_AUTO),
320bbb2f3dSGerd Hoffmann     DEFINE_PROP_ON_OFF_AUTO("msix", XHCIState, msix, ON_OFF_AUTO_AUTO),
330bbb2f3dSGerd Hoffmann     DEFINE_PROP_BIT("superspeed-ports-first",
340bbb2f3dSGerd Hoffmann                     XHCIState, flags, XHCI_FLAG_SS_FIRST, true),
350bbb2f3dSGerd Hoffmann     DEFINE_PROP_BIT("force-pcie-endcap", XHCIState, flags,
360bbb2f3dSGerd Hoffmann                     XHCI_FLAG_FORCE_PCIE_ENDCAP, false),
370bbb2f3dSGerd Hoffmann     DEFINE_PROP_UINT32("intrs", XHCIState, numintrs, MAXINTRS),
380bbb2f3dSGerd Hoffmann     DEFINE_PROP_UINT32("slots", XHCIState, numslots, MAXSLOTS),
390bbb2f3dSGerd Hoffmann     DEFINE_PROP_END_OF_LIST(),
400bbb2f3dSGerd Hoffmann };
410bbb2f3dSGerd Hoffmann 
420bbb2f3dSGerd Hoffmann static void nec_xhci_class_init(ObjectClass *klass, void *data)
430bbb2f3dSGerd Hoffmann {
440bbb2f3dSGerd Hoffmann     PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
450bbb2f3dSGerd Hoffmann     DeviceClass *dc = DEVICE_CLASS(klass);
460bbb2f3dSGerd Hoffmann 
470bbb2f3dSGerd Hoffmann     dc->props       = nec_xhci_properties;
480bbb2f3dSGerd Hoffmann     k->vendor_id    = PCI_VENDOR_ID_NEC;
490bbb2f3dSGerd Hoffmann     k->device_id    = PCI_DEVICE_ID_NEC_UPD720200;
500bbb2f3dSGerd Hoffmann     k->revision     = 0x03;
510bbb2f3dSGerd Hoffmann }
520bbb2f3dSGerd Hoffmann 
530bbb2f3dSGerd Hoffmann static const TypeInfo nec_xhci_info = {
540bbb2f3dSGerd Hoffmann     .name          = TYPE_NEC_XHCI,
550bbb2f3dSGerd Hoffmann     .parent        = TYPE_XHCI,
560bbb2f3dSGerd Hoffmann     .class_init    = nec_xhci_class_init,
570bbb2f3dSGerd Hoffmann };
580bbb2f3dSGerd Hoffmann 
590bbb2f3dSGerd Hoffmann static void nec_xhci_register_types(void)
600bbb2f3dSGerd Hoffmann {
610bbb2f3dSGerd Hoffmann     type_register_static(&nec_xhci_info);
620bbb2f3dSGerd Hoffmann }
630bbb2f3dSGerd Hoffmann 
640bbb2f3dSGerd Hoffmann type_init(nec_xhci_register_types)
65