xref: /openbmc/qemu/tests/qtest/es1370-test.c (revision 50333482)
11e8a1faeSThomas Huth /*
21e8a1faeSThomas Huth  * QTest testcase for ES1370
31e8a1faeSThomas Huth  *
41e8a1faeSThomas Huth  * Copyright (c) 2014 SUSE LINUX Products GmbH
51e8a1faeSThomas Huth  *
61e8a1faeSThomas Huth  * This work is licensed under the terms of the GNU GPL, version 2 or later.
71e8a1faeSThomas Huth  * See the COPYING file in the top-level directory.
81e8a1faeSThomas Huth  */
91e8a1faeSThomas Huth 
101e8a1faeSThomas Huth #include "qemu/osdep.h"
11907b5105SMarc-André Lureau #include "libqtest.h"
121e8a1faeSThomas Huth #include "qemu/module.h"
131e8a1faeSThomas Huth #include "libqos/qgraph.h"
141e8a1faeSThomas Huth #include "libqos/pci.h"
151e8a1faeSThomas Huth 
161e8a1faeSThomas Huth typedef struct QES1370 QES1370;
171e8a1faeSThomas Huth 
181e8a1faeSThomas Huth struct QES1370 {
191e8a1faeSThomas Huth     QOSGraphObject obj;
201e8a1faeSThomas Huth     QPCIDevice dev;
211e8a1faeSThomas Huth };
221e8a1faeSThomas Huth 
es1370_get_driver(void * obj,const char * interface)231e8a1faeSThomas Huth static void *es1370_get_driver(void *obj, const char *interface)
241e8a1faeSThomas Huth {
251e8a1faeSThomas Huth     QES1370 *es1370 = obj;
261e8a1faeSThomas Huth 
271e8a1faeSThomas Huth     if (!g_strcmp0(interface, "pci-device")) {
281e8a1faeSThomas Huth         return &es1370->dev;
291e8a1faeSThomas Huth     }
301e8a1faeSThomas Huth 
31a65c9527SJuan Quintela     fprintf(stderr, "%s not present in es1370\n", interface);
321e8a1faeSThomas Huth     g_assert_not_reached();
331e8a1faeSThomas Huth }
341e8a1faeSThomas Huth 
es1370_create(void * pci_bus,QGuestAllocator * alloc,void * addr)351e8a1faeSThomas Huth static void *es1370_create(void *pci_bus, QGuestAllocator *alloc, void *addr)
361e8a1faeSThomas Huth {
371e8a1faeSThomas Huth     QES1370 *es1370 = g_new0(QES1370, 1);
381e8a1faeSThomas Huth     QPCIBus *bus = pci_bus;
391e8a1faeSThomas Huth 
401e8a1faeSThomas Huth     qpci_device_init(&es1370->dev, bus, addr);
411e8a1faeSThomas Huth     es1370->obj.get_driver = es1370_get_driver;
421e8a1faeSThomas Huth 
431e8a1faeSThomas Huth     return &es1370->obj;
441e8a1faeSThomas Huth }
451e8a1faeSThomas Huth 
es1370_register_nodes(void)461e8a1faeSThomas Huth static void es1370_register_nodes(void)
471e8a1faeSThomas Huth {
481e8a1faeSThomas Huth     QOSGraphEdgeOptions opts = {
49*50333482SMartin Kletzander         .extra_device_opts = "addr=04.0,audiodev=audio0",
50*50333482SMartin Kletzander         .before_cmd_line = "-audiodev driver=none,id=audio0",
511e8a1faeSThomas Huth     };
521e8a1faeSThomas Huth     add_qpci_address(&opts, &(QPCIAddress) { .devfn = QPCI_DEVFN(4, 0) });
531e8a1faeSThomas Huth 
541e8a1faeSThomas Huth     qos_node_create_driver("ES1370", es1370_create);
551e8a1faeSThomas Huth     qos_node_consumes("ES1370", "pci-bus", &opts);
561e8a1faeSThomas Huth     qos_node_produces("ES1370", "pci-device");
571e8a1faeSThomas Huth }
581e8a1faeSThomas Huth 
591e8a1faeSThomas Huth libqos_init(es1370_register_nodes);
60