xref: /qemu/hw/char/imx_serial.c (revision 64552b6be4758d3a774f7787b294543ccebd5358)
140b6f911SPeter Chubb /*
240b6f911SPeter Chubb  * IMX31 UARTS
340b6f911SPeter Chubb  *
440b6f911SPeter Chubb  * Copyright (c) 2008 OKL
540b6f911SPeter Chubb  * Originally Written by Hans Jiang
640b6f911SPeter Chubb  * Copyright (c) 2011 NICTA Pty Ltd.
7cd0bda20SJean-Christophe Dubois  * Updated by Jean-Christophe Dubois <jcd@tribudubois.net>
840b6f911SPeter Chubb  *
940b6f911SPeter Chubb  * This work is licensed under the terms of the GNU GPL, version 2 or later.
1040b6f911SPeter Chubb  * See the COPYING file in the top-level directory.
1140b6f911SPeter Chubb  *
1240b6f911SPeter Chubb  * This is a `bare-bones' implementation of the IMX series serial ports.
1340b6f911SPeter Chubb  * TODO:
1440b6f911SPeter Chubb  *  -- implement FIFOs.  The real hardware has 32 word transmit
1540b6f911SPeter Chubb  *                       and receive FIFOs; we currently use a 1-char buffer
1640b6f911SPeter Chubb  *  -- implement DMA
1740b6f911SPeter Chubb  *  -- implement BAUD-rate and modem lines, for when the backend
1840b6f911SPeter Chubb  *     is a real serial device.
1940b6f911SPeter Chubb  */
2040b6f911SPeter Chubb 
218ef94f0bSPeter Maydell #include "qemu/osdep.h"
22cd0bda20SJean-Christophe Dubois #include "hw/char/imx_serial.h"
23*64552b6bSMarkus Armbruster #include "hw/irq.h"
249c17d615SPaolo Bonzini #include "sysemu/sysemu.h"
2503dd024fSPaolo Bonzini #include "qemu/log.h"
260b8fa32fSMarkus Armbruster #include "qemu/module.h"
2740b6f911SPeter Chubb 
288ccce77cSJean-Christophe Dubois #ifndef DEBUG_IMX_UART
298ccce77cSJean-Christophe Dubois #define DEBUG_IMX_UART 0
3040b6f911SPeter Chubb #endif
3140b6f911SPeter Chubb 
328ccce77cSJean-Christophe Dubois #define DPRINTF(fmt, args...) \
338ccce77cSJean-Christophe Dubois     do { \
348ccce77cSJean-Christophe Dubois         if (DEBUG_IMX_UART) { \
358ccce77cSJean-Christophe Dubois             fprintf(stderr, "[%s]%s: " fmt , TYPE_IMX_SERIAL, \
368ccce77cSJean-Christophe Dubois                                              __func__, ##args); \
378ccce77cSJean-Christophe Dubois         } \
388ccce77cSJean-Christophe Dubois     } while (0)
3940b6f911SPeter Chubb 
4040b6f911SPeter Chubb static const VMStateDescription vmstate_imx_serial = {
41fa2650a3SJean-Christophe Dubois     .name = TYPE_IMX_SERIAL,
4246d3fb63SAndrey Smirnov     .version_id = 2,
4346d3fb63SAndrey Smirnov     .minimum_version_id = 2,
4440b6f911SPeter Chubb     .fields = (VMStateField[]) {
4540b6f911SPeter Chubb         VMSTATE_INT32(readbuff, IMXSerialState),
4640b6f911SPeter Chubb         VMSTATE_UINT32(usr1, IMXSerialState),
4740b6f911SPeter Chubb         VMSTATE_UINT32(usr2, IMXSerialState),
4840b6f911SPeter Chubb         VMSTATE_UINT32(ucr1, IMXSerialState),
4940b6f911SPeter Chubb         VMSTATE_UINT32(uts1, IMXSerialState),
5040b6f911SPeter Chubb         VMSTATE_UINT32(onems, IMXSerialState),
5140b6f911SPeter Chubb         VMSTATE_UINT32(ufcr, IMXSerialState),
5240b6f911SPeter Chubb         VMSTATE_UINT32(ubmr, IMXSerialState),
5340b6f911SPeter Chubb         VMSTATE_UINT32(ubrc, IMXSerialState),
5440b6f911SPeter Chubb         VMSTATE_UINT32(ucr3, IMXSerialState),
5546d3fb63SAndrey Smirnov         VMSTATE_UINT32(ucr4, IMXSerialState),
5640b6f911SPeter Chubb         VMSTATE_END_OF_LIST()
5740b6f911SPeter Chubb     },
5840b6f911SPeter Chubb };
5940b6f911SPeter Chubb 
6040b6f911SPeter Chubb static void imx_update(IMXSerialState *s)
6140b6f911SPeter Chubb {
62824e4a12SAndrey Smirnov     uint32_t usr1;
63824e4a12SAndrey Smirnov     uint32_t usr2;
64824e4a12SAndrey Smirnov     uint32_t mask;
6540b6f911SPeter Chubb 
66824e4a12SAndrey Smirnov     /*
67824e4a12SAndrey Smirnov      * Lucky for us TRDY and RRDY has the same offset in both USR1 and
68824e4a12SAndrey Smirnov      * UCR1, so we can get away with something as simple as the
69824e4a12SAndrey Smirnov      * following:
70824e4a12SAndrey Smirnov      */
71824e4a12SAndrey Smirnov     usr1 = s->usr1 & s->ucr1 & (USR1_TRDY | USR1_RRDY);
72824e4a12SAndrey Smirnov     /*
73824e4a12SAndrey Smirnov      * Bits that we want in USR2 are not as conveniently laid out,
74824e4a12SAndrey Smirnov      * unfortunately.
75824e4a12SAndrey Smirnov      */
76824e4a12SAndrey Smirnov     mask = (s->ucr1 & UCR1_TXMPTYEN) ? USR2_TXFE : 0;
7746d3fb63SAndrey Smirnov     /*
7846d3fb63SAndrey Smirnov      * TCEN and TXDC are both bit 3
793c54cf77SHans-Erik Floryd      * RDR and DREN are both bit 0
8046d3fb63SAndrey Smirnov      */
813c54cf77SHans-Erik Floryd     mask |= s->ucr4 & (UCR4_TCEN | UCR4_DREN);
8246d3fb63SAndrey Smirnov 
83824e4a12SAndrey Smirnov     usr2 = s->usr2 & mask;
8440b6f911SPeter Chubb 
85824e4a12SAndrey Smirnov     qemu_set_irq(s->irq, usr1 || usr2);
8640b6f911SPeter Chubb }
8740b6f911SPeter Chubb 
8840b6f911SPeter Chubb static void imx_serial_reset(IMXSerialState *s)
8940b6f911SPeter Chubb {
9040b6f911SPeter Chubb 
9140b6f911SPeter Chubb     s->usr1 = USR1_TRDY | USR1_RXDS;
9240b6f911SPeter Chubb     /*
9340b6f911SPeter Chubb      * Fake attachment of a terminal: assert RTS.
9440b6f911SPeter Chubb      */
9540b6f911SPeter Chubb     s->usr1 |= USR1_RTSS;
9640b6f911SPeter Chubb     s->usr2 = USR2_TXFE | USR2_TXDC | USR2_DCDIN;
9740b6f911SPeter Chubb     s->uts1 = UTS1_RXEMPTY | UTS1_TXEMPTY;
9840b6f911SPeter Chubb     s->ucr1 = 0;
9940b6f911SPeter Chubb     s->ucr2 = UCR2_SRST;
10040b6f911SPeter Chubb     s->ucr3 = 0x700;
10140b6f911SPeter Chubb     s->ubmr = 0;
10240b6f911SPeter Chubb     s->ubrc = 4;
10340b6f911SPeter Chubb     s->readbuff = URXD_ERR;
10440b6f911SPeter Chubb }
10540b6f911SPeter Chubb 
10640b6f911SPeter Chubb static void imx_serial_reset_at_boot(DeviceState *dev)
10740b6f911SPeter Chubb {
1088d8e3481SAndreas Färber     IMXSerialState *s = IMX_SERIAL(dev);
10940b6f911SPeter Chubb 
11040b6f911SPeter Chubb     imx_serial_reset(s);
11140b6f911SPeter Chubb 
11240b6f911SPeter Chubb     /*
11340b6f911SPeter Chubb      * enable the uart on boot, so messages from the linux decompresser
11440b6f911SPeter Chubb      * are visible.  On real hardware this is done by the boot rom
11540b6f911SPeter Chubb      * before anything else is loaded.
11640b6f911SPeter Chubb      */
11740b6f911SPeter Chubb     s->ucr1 = UCR1_UARTEN;
11840b6f911SPeter Chubb     s->ucr2 = UCR2_TXEN;
11940b6f911SPeter Chubb 
12040b6f911SPeter Chubb }
12140b6f911SPeter Chubb 
122a8170e5eSAvi Kivity static uint64_t imx_serial_read(void *opaque, hwaddr offset,
12340b6f911SPeter Chubb                                 unsigned size)
12440b6f911SPeter Chubb {
12540b6f911SPeter Chubb     IMXSerialState *s = (IMXSerialState *)opaque;
12640b6f911SPeter Chubb     uint32_t c;
12740b6f911SPeter Chubb 
1288ccce77cSJean-Christophe Dubois     DPRINTF("read(offset=0x%" HWADDR_PRIx ")\n", offset);
1298ccce77cSJean-Christophe Dubois 
13040b6f911SPeter Chubb     switch (offset >> 2) {
13140b6f911SPeter Chubb     case 0x0: /* URXD */
13240b6f911SPeter Chubb         c = s->readbuff;
13340b6f911SPeter Chubb         if (!(s->uts1 & UTS1_RXEMPTY)) {
13440b6f911SPeter Chubb             /* Character is valid */
13540b6f911SPeter Chubb             c |= URXD_CHARRDY;
13640b6f911SPeter Chubb             s->usr1 &= ~USR1_RRDY;
13740b6f911SPeter Chubb             s->usr2 &= ~USR2_RDR;
13840b6f911SPeter Chubb             s->uts1 |= UTS1_RXEMPTY;
13940b6f911SPeter Chubb             imx_update(s);
1405345fdb4SMarc-André Lureau             qemu_chr_fe_accept_input(&s->chr);
14140b6f911SPeter Chubb         }
14240b6f911SPeter Chubb         return c;
14340b6f911SPeter Chubb 
14440b6f911SPeter Chubb     case 0x20: /* UCR1 */
14540b6f911SPeter Chubb         return s->ucr1;
14640b6f911SPeter Chubb 
14740b6f911SPeter Chubb     case 0x21: /* UCR2 */
14840b6f911SPeter Chubb         return s->ucr2;
14940b6f911SPeter Chubb 
15040b6f911SPeter Chubb     case 0x25: /* USR1 */
15140b6f911SPeter Chubb         return s->usr1;
15240b6f911SPeter Chubb 
15340b6f911SPeter Chubb     case 0x26: /* USR2 */
15440b6f911SPeter Chubb         return s->usr2;
15540b6f911SPeter Chubb 
15640b6f911SPeter Chubb     case 0x2A: /* BRM Modulator */
15740b6f911SPeter Chubb         return s->ubmr;
15840b6f911SPeter Chubb 
15940b6f911SPeter Chubb     case 0x2B: /* Baud Rate Count */
16040b6f911SPeter Chubb         return s->ubrc;
16140b6f911SPeter Chubb 
16240b6f911SPeter Chubb     case 0x2d: /* Test register */
16340b6f911SPeter Chubb         return s->uts1;
16440b6f911SPeter Chubb 
16540b6f911SPeter Chubb     case 0x24: /* UFCR */
16640b6f911SPeter Chubb         return s->ufcr;
16740b6f911SPeter Chubb 
16840b6f911SPeter Chubb     case 0x2c:
16940b6f911SPeter Chubb         return s->onems;
17040b6f911SPeter Chubb 
17140b6f911SPeter Chubb     case 0x22: /* UCR3 */
17240b6f911SPeter Chubb         return s->ucr3;
17340b6f911SPeter Chubb 
17440b6f911SPeter Chubb     case 0x23: /* UCR4 */
17546d3fb63SAndrey Smirnov         return s->ucr4;
17646d3fb63SAndrey Smirnov 
17740b6f911SPeter Chubb     case 0x29: /* BRM Incremental */
17840b6f911SPeter Chubb         return 0x0; /* TODO */
17940b6f911SPeter Chubb 
18040b6f911SPeter Chubb     default:
1818ccce77cSJean-Christophe Dubois         qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: Bad register at offset 0x%"
1828ccce77cSJean-Christophe Dubois                       HWADDR_PRIx "\n", TYPE_IMX_SERIAL, __func__, offset);
18340b6f911SPeter Chubb         return 0;
18440b6f911SPeter Chubb     }
18540b6f911SPeter Chubb }
18640b6f911SPeter Chubb 
187a8170e5eSAvi Kivity static void imx_serial_write(void *opaque, hwaddr offset,
18840b6f911SPeter Chubb                              uint64_t value, unsigned size)
18940b6f911SPeter Chubb {
19040b6f911SPeter Chubb     IMXSerialState *s = (IMXSerialState *)opaque;
1910ec7b3e7SMarc-André Lureau     Chardev *chr = qemu_chr_fe_get_driver(&s->chr);
19240b6f911SPeter Chubb     unsigned char ch;
19340b6f911SPeter Chubb 
1948ccce77cSJean-Christophe Dubois     DPRINTF("write(offset=0x%" HWADDR_PRIx ", value = 0x%x) to %s\n",
1955345fdb4SMarc-André Lureau             offset, (unsigned int)value, chr ? chr->label : "NODEV");
19640b6f911SPeter Chubb 
19740b6f911SPeter Chubb     switch (offset >> 2) {
19840b6f911SPeter Chubb     case 0x10: /* UTXD */
19940b6f911SPeter Chubb         ch = value;
20040b6f911SPeter Chubb         if (s->ucr2 & UCR2_TXEN) {
2016ab3fc32SDaniel P. Berrange             /* XXX this blocks entire thread. Rewrite to use
2026ab3fc32SDaniel P. Berrange              * qemu_chr_fe_write and background I/O callbacks */
2035345fdb4SMarc-André Lureau             qemu_chr_fe_write_all(&s->chr, &ch, 1);
20440b6f911SPeter Chubb             s->usr1 &= ~USR1_TRDY;
20546d3fb63SAndrey Smirnov             s->usr2 &= ~USR2_TXDC;
20640b6f911SPeter Chubb             imx_update(s);
20740b6f911SPeter Chubb             s->usr1 |= USR1_TRDY;
20846d3fb63SAndrey Smirnov             s->usr2 |= USR2_TXDC;
20940b6f911SPeter Chubb             imx_update(s);
21040b6f911SPeter Chubb         }
21140b6f911SPeter Chubb         break;
21240b6f911SPeter Chubb 
21340b6f911SPeter Chubb     case 0x20: /* UCR1 */
21440b6f911SPeter Chubb         s->ucr1 = value & 0xffff;
2158ccce77cSJean-Christophe Dubois 
21640b6f911SPeter Chubb         DPRINTF("write(ucr1=%x)\n", (unsigned int)value);
2178ccce77cSJean-Christophe Dubois 
21840b6f911SPeter Chubb         imx_update(s);
21940b6f911SPeter Chubb         break;
22040b6f911SPeter Chubb 
22140b6f911SPeter Chubb     case 0x21: /* UCR2 */
22240b6f911SPeter Chubb         /*
22340b6f911SPeter Chubb          * Only a few bits in control register 2 are implemented as yet.
22440b6f911SPeter Chubb          * If it's intended to use a real serial device as a back-end, this
22540b6f911SPeter Chubb          * register will have to be implemented more fully.
22640b6f911SPeter Chubb          */
22740b6f911SPeter Chubb         if (!(value & UCR2_SRST)) {
22840b6f911SPeter Chubb             imx_serial_reset(s);
22940b6f911SPeter Chubb             imx_update(s);
23040b6f911SPeter Chubb             value |= UCR2_SRST;
23140b6f911SPeter Chubb         }
23240b6f911SPeter Chubb         if (value & UCR2_RXEN) {
23340b6f911SPeter Chubb             if (!(s->ucr2 & UCR2_RXEN)) {
2345345fdb4SMarc-André Lureau                 qemu_chr_fe_accept_input(&s->chr);
23540b6f911SPeter Chubb             }
23640b6f911SPeter Chubb         }
23740b6f911SPeter Chubb         s->ucr2 = value & 0xffff;
23840b6f911SPeter Chubb         break;
23940b6f911SPeter Chubb 
24040b6f911SPeter Chubb     case 0x25: /* USR1 */
24140b6f911SPeter Chubb         value &= USR1_AWAKE | USR1_AIRINT | USR1_DTRD | USR1_AGTIM |
24240b6f911SPeter Chubb                  USR1_FRAMERR | USR1_ESCF | USR1_RTSD | USR1_PARTYER;
24340b6f911SPeter Chubb         s->usr1 &= ~value;
24440b6f911SPeter Chubb         break;
24540b6f911SPeter Chubb 
24640b6f911SPeter Chubb     case 0x26: /* USR2 */
24740b6f911SPeter Chubb         /*
24840b6f911SPeter Chubb          * Writing 1 to some bits clears them; all other
24940b6f911SPeter Chubb          * values are ignored
25040b6f911SPeter Chubb          */
25140b6f911SPeter Chubb         value &= USR2_ADET | USR2_DTRF | USR2_IDLE | USR2_ACST |
25240b6f911SPeter Chubb                  USR2_RIDELT | USR2_IRINT | USR2_WAKE |
25340b6f911SPeter Chubb                  USR2_DCDDELT | USR2_RTSF | USR2_BRCD | USR2_ORE;
25440b6f911SPeter Chubb         s->usr2 &= ~value;
25540b6f911SPeter Chubb         break;
25640b6f911SPeter Chubb 
25740b6f911SPeter Chubb     /*
25840b6f911SPeter Chubb      * Linux expects to see what it writes to these registers
25940b6f911SPeter Chubb      * We don't currently alter the baud rate
26040b6f911SPeter Chubb      */
26140b6f911SPeter Chubb     case 0x29: /* UBIR */
26240b6f911SPeter Chubb         s->ubrc = value & 0xffff;
26340b6f911SPeter Chubb         break;
26440b6f911SPeter Chubb 
26540b6f911SPeter Chubb     case 0x2a: /* UBMR */
26640b6f911SPeter Chubb         s->ubmr = value & 0xffff;
26740b6f911SPeter Chubb         break;
26840b6f911SPeter Chubb 
26940b6f911SPeter Chubb     case 0x2c: /* One ms reg */
27040b6f911SPeter Chubb         s->onems = value & 0xffff;
27140b6f911SPeter Chubb         break;
27240b6f911SPeter Chubb 
27340b6f911SPeter Chubb     case 0x24: /* FIFO control register */
27440b6f911SPeter Chubb         s->ufcr = value & 0xffff;
27540b6f911SPeter Chubb         break;
27640b6f911SPeter Chubb 
27740b6f911SPeter Chubb     case 0x22: /* UCR3 */
27840b6f911SPeter Chubb         s->ucr3 = value & 0xffff;
27940b6f911SPeter Chubb         break;
28040b6f911SPeter Chubb 
28140b6f911SPeter Chubb     case 0x23: /* UCR4 */
28246d3fb63SAndrey Smirnov         s->ucr4 = value & 0xffff;
28346d3fb63SAndrey Smirnov         imx_update(s);
28446d3fb63SAndrey Smirnov         break;
28546d3fb63SAndrey Smirnov 
28646d3fb63SAndrey Smirnov     case 0x2d: /* UTS1 */
2878ccce77cSJean-Christophe Dubois         qemu_log_mask(LOG_UNIMP, "[%s]%s: Unimplemented reg 0x%"
2888ccce77cSJean-Christophe Dubois                       HWADDR_PRIx "\n", TYPE_IMX_SERIAL, __func__, offset);
28940b6f911SPeter Chubb         /* TODO */
29040b6f911SPeter Chubb         break;
29140b6f911SPeter Chubb 
29240b6f911SPeter Chubb     default:
2938ccce77cSJean-Christophe Dubois         qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: Bad register at offset 0x%"
2948ccce77cSJean-Christophe Dubois                       HWADDR_PRIx "\n", TYPE_IMX_SERIAL, __func__, offset);
29540b6f911SPeter Chubb     }
29640b6f911SPeter Chubb }
29740b6f911SPeter Chubb 
29840b6f911SPeter Chubb static int imx_can_receive(void *opaque)
29940b6f911SPeter Chubb {
30040b6f911SPeter Chubb     IMXSerialState *s = (IMXSerialState *)opaque;
30140b6f911SPeter Chubb     return !(s->usr1 & USR1_RRDY);
30240b6f911SPeter Chubb }
30340b6f911SPeter Chubb 
30440b6f911SPeter Chubb static void imx_put_data(void *opaque, uint32_t value)
30540b6f911SPeter Chubb {
30640b6f911SPeter Chubb     IMXSerialState *s = (IMXSerialState *)opaque;
3078ccce77cSJean-Christophe Dubois 
30840b6f911SPeter Chubb     DPRINTF("received char\n");
3098ccce77cSJean-Christophe Dubois 
31040b6f911SPeter Chubb     s->usr1 |= USR1_RRDY;
31140b6f911SPeter Chubb     s->usr2 |= USR2_RDR;
31240b6f911SPeter Chubb     s->uts1 &= ~UTS1_RXEMPTY;
31340b6f911SPeter Chubb     s->readbuff = value;
314478a573aSTrent Piepho     if (value & URXD_BRK) {
315478a573aSTrent Piepho         s->usr2 |= USR2_BRCD;
316478a573aSTrent Piepho     }
31740b6f911SPeter Chubb     imx_update(s);
31840b6f911SPeter Chubb }
31940b6f911SPeter Chubb 
32040b6f911SPeter Chubb static void imx_receive(void *opaque, const uint8_t *buf, int size)
32140b6f911SPeter Chubb {
32240b6f911SPeter Chubb     imx_put_data(opaque, *buf);
32340b6f911SPeter Chubb }
32440b6f911SPeter Chubb 
32540b6f911SPeter Chubb static void imx_event(void *opaque, int event)
32640b6f911SPeter Chubb {
32740b6f911SPeter Chubb     if (event == CHR_EVENT_BREAK) {
328478a573aSTrent Piepho         imx_put_data(opaque, URXD_BRK | URXD_FRMERR | URXD_ERR);
32940b6f911SPeter Chubb     }
33040b6f911SPeter Chubb }
33140b6f911SPeter Chubb 
33240b6f911SPeter Chubb 
33340b6f911SPeter Chubb static const struct MemoryRegionOps imx_serial_ops = {
33440b6f911SPeter Chubb     .read = imx_serial_read,
33540b6f911SPeter Chubb     .write = imx_serial_write,
33640b6f911SPeter Chubb     .endianness = DEVICE_NATIVE_ENDIAN,
33740b6f911SPeter Chubb };
33840b6f911SPeter Chubb 
339f6c64000SJean-Christophe Dubois static void imx_serial_realize(DeviceState *dev, Error **errp)
34040b6f911SPeter Chubb {
3418d8e3481SAndreas Färber     IMXSerialState *s = IMX_SERIAL(dev);
34240b6f911SPeter Chubb 
343fa394ed6SMarc-André Lureau     DPRINTF("char dev for uart: %p\n", qemu_chr_fe_get_driver(&s->chr));
344fa394ed6SMarc-André Lureau 
3455345fdb4SMarc-André Lureau     qemu_chr_fe_set_handlers(&s->chr, imx_can_receive, imx_receive,
34681517ba3SAnton Nefedov                              imx_event, NULL, s, NULL, true);
347f6c64000SJean-Christophe Dubois }
34840b6f911SPeter Chubb 
349f6c64000SJean-Christophe Dubois static void imx_serial_init(Object *obj)
350f6c64000SJean-Christophe Dubois {
351f6c64000SJean-Christophe Dubois     SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
352f6c64000SJean-Christophe Dubois     IMXSerialState *s = IMX_SERIAL(obj);
353f6c64000SJean-Christophe Dubois 
354f6c64000SJean-Christophe Dubois     memory_region_init_io(&s->iomem, obj, &imx_serial_ops, s,
355f6c64000SJean-Christophe Dubois                           TYPE_IMX_SERIAL, 0x1000);
356f6c64000SJean-Christophe Dubois     sysbus_init_mmio(sbd, &s->iomem);
357f6c64000SJean-Christophe Dubois     sysbus_init_irq(sbd, &s->irq);
35840b6f911SPeter Chubb }
35940b6f911SPeter Chubb 
360f6c64000SJean-Christophe Dubois static Property imx_serial_properties[] = {
36140b6f911SPeter Chubb     DEFINE_PROP_CHR("chardev", IMXSerialState, chr),
36240b6f911SPeter Chubb     DEFINE_PROP_END_OF_LIST(),
36340b6f911SPeter Chubb };
36440b6f911SPeter Chubb 
36540b6f911SPeter Chubb static void imx_serial_class_init(ObjectClass *klass, void *data)
36640b6f911SPeter Chubb {
36740b6f911SPeter Chubb     DeviceClass *dc = DEVICE_CLASS(klass);
36840b6f911SPeter Chubb 
369f6c64000SJean-Christophe Dubois     dc->realize = imx_serial_realize;
37040b6f911SPeter Chubb     dc->vmsd = &vmstate_imx_serial;
37140b6f911SPeter Chubb     dc->reset = imx_serial_reset_at_boot;
372125ee0edSMarcel Apfelbaum     set_bit(DEVICE_CATEGORY_INPUT, dc->categories);
37340b6f911SPeter Chubb     dc->desc = "i.MX series UART";
374f6c64000SJean-Christophe Dubois     dc->props = imx_serial_properties;
37540b6f911SPeter Chubb }
37640b6f911SPeter Chubb 
3778c43a6f0SAndreas Färber static const TypeInfo imx_serial_info = {
3788d8e3481SAndreas Färber     .name           = TYPE_IMX_SERIAL,
37940b6f911SPeter Chubb     .parent         = TYPE_SYS_BUS_DEVICE,
38040b6f911SPeter Chubb     .instance_size  = sizeof(IMXSerialState),
381f6c64000SJean-Christophe Dubois     .instance_init  = imx_serial_init,
38240b6f911SPeter Chubb     .class_init     = imx_serial_class_init,
38340b6f911SPeter Chubb };
38440b6f911SPeter Chubb 
38540b6f911SPeter Chubb static void imx_serial_register_types(void)
38640b6f911SPeter Chubb {
38740b6f911SPeter Chubb     type_register_static(&imx_serial_info);
38840b6f911SPeter Chubb }
38940b6f911SPeter Chubb 
39040b6f911SPeter Chubb type_init(imx_serial_register_types)
391