1 /* 2 * This program is free software; you can redistribute it and/or modify it 3 * under the terms and conditions of the GNU General Public License, 4 * version 2 or later, as published by the Free Software Foundation. 5 * 6 * This program is distributed in the hope it will be useful, but WITHOUT 7 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 8 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 9 * more details. 10 * 11 * You should have received a copy of the GNU General Public License along with 12 * this program. If not, see <http://www.gnu.org/licenses/>. 13 */ 14 15 #ifndef XILINX_UARTLITE_H 16 #define XILINX_UARTLITE_H 17 18 #include "hw/qdev-properties.h" 19 #include "hw/sysbus.h" 20 #include "qapi/error.h" 21 #include "qom/object.h" 22 23 #define TYPE_XILINX_UARTLITE "xlnx.xps-uartlite" 24 OBJECT_DECLARE_SIMPLE_TYPE(XilinxUARTLite, XILINX_UARTLITE) 25 26 static inline DeviceState *xilinx_uartlite_create(hwaddr addr, 27 qemu_irq irq, 28 Chardev *chr) 29 { 30 DeviceState *dev; 31 SysBusDevice *s; 32 33 dev = qdev_new(TYPE_XILINX_UARTLITE); 34 s = SYS_BUS_DEVICE(dev); 35 qdev_prop_set_chr(dev, "chardev", chr); 36 sysbus_realize_and_unref(s, &error_fatal); 37 sysbus_mmio_map(s, 0, addr); 38 sysbus_connect_irq(s, 0, irq); 39 40 return dev; 41 } 42 43 #endif 44