usb-tablet: Don't claim wakeup capability for USB-2 version
[qemu/ar7.git] / hw / serial-isa.c
bloba630a7d506a7e6e05b10e2f18c12f9eb046029c4
1 /*
2 * QEMU 16550A UART emulation
4 * Copyright (c) 2003-2004 Fabrice Bellard
5 * Copyright (c) 2008 Citrix Systems, Inc.
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 * THE SOFTWARE.
26 #include "hw/serial.h"
27 #include "hw/isa.h"
29 typedef struct ISASerialState {
30 ISADevice dev;
31 uint32_t index;
32 uint32_t iobase;
33 uint32_t isairq;
34 SerialState state;
35 } ISASerialState;
37 static const int isa_serial_io[MAX_SERIAL_PORTS] = {
38 0x3f8, 0x2f8, 0x3e8, 0x2e8
40 static const int isa_serial_irq[MAX_SERIAL_PORTS] = {
41 4, 3, 4, 3
44 static int serial_isa_initfn(ISADevice *dev)
46 static int index;
47 ISASerialState *isa = DO_UPCAST(ISASerialState, dev, dev);
48 SerialState *s = &isa->state;
50 if (isa->index == -1) {
51 isa->index = index;
53 if (isa->index >= MAX_SERIAL_PORTS) {
54 return -1;
56 if (isa->iobase == -1) {
57 isa->iobase = isa_serial_io[isa->index];
59 if (isa->isairq == -1) {
60 isa->isairq = isa_serial_irq[isa->index];
62 index++;
64 s->baudbase = 115200;
65 isa_init_irq(dev, &s->irq, isa->isairq);
66 serial_init_core(s);
67 qdev_set_legacy_instance_id(&dev->qdev, isa->iobase, 3);
69 memory_region_init_io(&s->io, &serial_io_ops, s, "serial", 8);
70 isa_register_ioport(dev, &s->io, isa->iobase);
71 return 0;
74 static const VMStateDescription vmstate_isa_serial = {
75 .name = "serial",
76 .version_id = 3,
77 .minimum_version_id = 2,
78 .fields = (VMStateField[]) {
79 VMSTATE_STRUCT(state, ISASerialState, 0, vmstate_serial, SerialState),
80 VMSTATE_END_OF_LIST()
84 static Property serial_isa_properties[] = {
85 DEFINE_PROP_UINT32("index", ISASerialState, index, -1),
86 DEFINE_PROP_HEX32("iobase", ISASerialState, iobase, -1),
87 DEFINE_PROP_UINT32("irq", ISASerialState, isairq, -1),
88 DEFINE_PROP_CHR("chardev", ISASerialState, state.chr),
89 DEFINE_PROP_UINT32("wakeup", ISASerialState, state.wakeup, 0),
90 DEFINE_PROP_END_OF_LIST(),
93 static void serial_isa_class_initfn(ObjectClass *klass, void *data)
95 DeviceClass *dc = DEVICE_CLASS(klass);
96 ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
97 ic->init = serial_isa_initfn;
98 dc->vmsd = &vmstate_isa_serial;
99 dc->props = serial_isa_properties;
102 static const TypeInfo serial_isa_info = {
103 .name = "isa-serial",
104 .parent = TYPE_ISA_DEVICE,
105 .instance_size = sizeof(ISASerialState),
106 .class_init = serial_isa_class_initfn,
109 static void serial_register_types(void)
111 type_register_static(&serial_isa_info);
114 type_init(serial_register_types)
116 bool serial_isa_init(ISABus *bus, int index, CharDriverState *chr)
118 ISADevice *dev;
120 dev = isa_try_create(bus, "isa-serial");
121 if (!dev) {
122 return false;
124 qdev_prop_set_uint32(&dev->qdev, "index", index);
125 qdev_prop_set_chr(&dev->qdev, "chardev", chr);
126 if (qdev_init(&dev->qdev) < 0) {
127 return false;
129 return true;