12f062c72Sths /* 22f062c72Sths * QEMU SCI/SCIF serial port emulation 32f062c72Sths * 42f062c72Sths * Copyright (c) 2007 Magnus Damm 52f062c72Sths * 62f062c72Sths * Based on serial.c - QEMU 16450 UART emulation 72f062c72Sths * Copyright (c) 2003-2004 Fabrice Bellard 82f062c72Sths * 92f062c72Sths * Permission is hereby granted, free of charge, to any person obtaining a copy 102f062c72Sths * of this software and associated documentation files (the "Software"), to deal 112f062c72Sths * in the Software without restriction, including without limitation the rights 122f062c72Sths * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 132f062c72Sths * copies of the Software, and to permit persons to whom the Software is 142f062c72Sths * furnished to do so, subject to the following conditions: 152f062c72Sths * 162f062c72Sths * The above copyright notice and this permission notice shall be included in 172f062c72Sths * all copies or substantial portions of the Software. 182f062c72Sths * 192f062c72Sths * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 202f062c72Sths * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 212f062c72Sths * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 222f062c72Sths * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 232f062c72Sths * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 242f062c72Sths * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 252f062c72Sths * THE SOFTWARE. 262f062c72Sths */ 2764552b6bSMarkus Armbruster 280430891cSPeter Maydell #include "qemu/osdep.h" 2964552b6bSMarkus Armbruster #include "hw/irq.h" 300d09e41aSPaolo Bonzini #include "hw/sh4/sh.h" 314d43a603SMarc-André Lureau #include "chardev/char-fe.h" 3232a6ebecSMarc-André Lureau #include "qapi/error.h" 3371bb4ce1SGeert Uytterhoeven #include "qemu/timer.h" 34*ad52cfc1SBALATON Zoltan #include "trace.h" 352f062c72Sths 362f062c72Sths #define SH_SERIAL_FLAG_TEND (1 << 0) 372f062c72Sths #define SH_SERIAL_FLAG_TDE (1 << 1) 382f062c72Sths #define SH_SERIAL_FLAG_RDF (1 << 2) 392f062c72Sths #define SH_SERIAL_FLAG_BRK (1 << 3) 402f062c72Sths #define SH_SERIAL_FLAG_DR (1 << 4) 412f062c72Sths 4263242a00Saurel32 #define SH_RX_FIFO_LENGTH (16) 4363242a00Saurel32 442f062c72Sths typedef struct { 459a9d0b81SBenoît Canet MemoryRegion iomem; 469a9d0b81SBenoît Canet MemoryRegion iomem_p4; 479a9d0b81SBenoît Canet MemoryRegion iomem_a7; 482f062c72Sths uint8_t smr; 492f062c72Sths uint8_t brr; 502f062c72Sths uint8_t scr; 512f062c72Sths uint8_t dr; /* ftdr / tdr */ 522f062c72Sths uint8_t sr; /* fsr / ssr */ 532f062c72Sths uint16_t fcr; 542f062c72Sths uint8_t sptr; 552f062c72Sths 5663242a00Saurel32 uint8_t rx_fifo[SH_RX_FIFO_LENGTH]; /* frdr / rdr */ 572f062c72Sths uint8_t rx_cnt; 5863242a00Saurel32 uint8_t rx_tail; 5963242a00Saurel32 uint8_t rx_head; 602f062c72Sths 612f062c72Sths int freq; 622f062c72Sths int feat; 632f062c72Sths int flags; 6463242a00Saurel32 int rtrg; 652f062c72Sths 6632a6ebecSMarc-André Lureau CharBackend chr; 6771bb4ce1SGeert Uytterhoeven QEMUTimer *fifo_timeout_timer; 6871bb4ce1SGeert Uytterhoeven uint64_t etu; /* Elementary Time Unit (ns) */ 69bf5b7423Saurel32 704e7ed2d1Saurel32 qemu_irq eri; 714e7ed2d1Saurel32 qemu_irq rxi; 724e7ed2d1Saurel32 qemu_irq txi; 734e7ed2d1Saurel32 qemu_irq tei; 744e7ed2d1Saurel32 qemu_irq bri; 752f062c72Sths } sh_serial_state; 762f062c72Sths 7763242a00Saurel32 static void sh_serial_clear_fifo(sh_serial_state *s) 7863242a00Saurel32 { 7963242a00Saurel32 memset(s->rx_fifo, 0, SH_RX_FIFO_LENGTH); 8063242a00Saurel32 s->rx_cnt = 0; 8163242a00Saurel32 s->rx_head = 0; 8263242a00Saurel32 s->rx_tail = 0; 8363242a00Saurel32 } 8463242a00Saurel32 85a8170e5eSAvi Kivity static void sh_serial_write(void *opaque, hwaddr offs, 869a9d0b81SBenoît Canet uint64_t val, unsigned size) 872f062c72Sths { 882f062c72Sths sh_serial_state *s = opaque; 892f062c72Sths unsigned char ch; 902f062c72Sths 91*ad52cfc1SBALATON Zoltan trace_sh_serial_write(size, offs, val); 922f062c72Sths switch (offs) { 932f062c72Sths case 0x00: /* SMR */ 942f062c72Sths s->smr = val & ((s->feat & SH_SERIAL_FEAT_SCIF) ? 0x7b : 0xff); 952f062c72Sths return; 962f062c72Sths case 0x04: /* BRR */ 972f062c72Sths s->brr = val; 982f062c72Sths return; 992f062c72Sths case 0x08: /* SCR */ 10063242a00Saurel32 /* TODO : For SH7751, SCIF mask should be 0xfb. */ 101bf5b7423Saurel32 s->scr = val & ((s->feat & SH_SERIAL_FEAT_SCIF) ? 0xfa : 0xff); 102ac3c9e74SBALATON Zoltan if (!(val & (1 << 5))) { 1032f062c72Sths s->flags |= SH_SERIAL_FLAG_TEND; 104ac3c9e74SBALATON Zoltan } 105bf5b7423Saurel32 if ((s->feat & SH_SERIAL_FEAT_SCIF) && s->txi) { 1064e7ed2d1Saurel32 qemu_set_irq(s->txi, val & (1 << 7)); 107bf5b7423Saurel32 } 1084e7ed2d1Saurel32 if (!(val & (1 << 6))) { 1094e7ed2d1Saurel32 qemu_set_irq(s->rxi, 0); 11063242a00Saurel32 } 1112f062c72Sths return; 1122f062c72Sths case 0x0c: /* FTDR / TDR */ 11330650701SAnton Nefedov if (qemu_chr_fe_backend_connected(&s->chr)) { 1142f062c72Sths ch = val; 11522138965SBALATON Zoltan /* 11622138965SBALATON Zoltan * XXX this blocks entire thread. Rewrite to use 11722138965SBALATON Zoltan * qemu_chr_fe_write and background I/O callbacks 11822138965SBALATON Zoltan */ 1195345fdb4SMarc-André Lureau qemu_chr_fe_write_all(&s->chr, &ch, 1); 1202f062c72Sths } 1212f062c72Sths s->dr = val; 1222f062c72Sths s->flags &= ~SH_SERIAL_FLAG_TDE; 1232f062c72Sths return; 1242f062c72Sths #if 0 1252f062c72Sths case 0x14: /* FRDR / RDR */ 1262f062c72Sths ret = 0; 1272f062c72Sths break; 1282f062c72Sths #endif 1292f062c72Sths } 1302f062c72Sths if (s->feat & SH_SERIAL_FEAT_SCIF) { 1312f062c72Sths switch (offs) { 1322f062c72Sths case 0x10: /* FSR */ 133ac3c9e74SBALATON Zoltan if (!(val & (1 << 6))) { 1342f062c72Sths s->flags &= ~SH_SERIAL_FLAG_TEND; 135ac3c9e74SBALATON Zoltan } 136ac3c9e74SBALATON Zoltan if (!(val & (1 << 5))) { 1372f062c72Sths s->flags &= ~SH_SERIAL_FLAG_TDE; 138ac3c9e74SBALATON Zoltan } 139ac3c9e74SBALATON Zoltan if (!(val & (1 << 4))) { 1402f062c72Sths s->flags &= ~SH_SERIAL_FLAG_BRK; 141ac3c9e74SBALATON Zoltan } 142ac3c9e74SBALATON Zoltan if (!(val & (1 << 1))) { 1432f062c72Sths s->flags &= ~SH_SERIAL_FLAG_RDF; 144ac3c9e74SBALATON Zoltan } 145ac3c9e74SBALATON Zoltan if (!(val & (1 << 0))) { 1462f062c72Sths s->flags &= ~SH_SERIAL_FLAG_DR; 147ac3c9e74SBALATON Zoltan } 14863242a00Saurel32 14963242a00Saurel32 if (!(val & (1 << 1)) || !(val & (1 << 0))) { 1504e7ed2d1Saurel32 if (s->rxi) { 1514e7ed2d1Saurel32 qemu_set_irq(s->rxi, 0); 15263242a00Saurel32 } 15363242a00Saurel32 } 1542f062c72Sths return; 1552f062c72Sths case 0x18: /* FCR */ 1562f062c72Sths s->fcr = val; 15763242a00Saurel32 switch ((val >> 6) & 3) { 15863242a00Saurel32 case 0: 15963242a00Saurel32 s->rtrg = 1; 16063242a00Saurel32 break; 16163242a00Saurel32 case 1: 16263242a00Saurel32 s->rtrg = 4; 16363242a00Saurel32 break; 16463242a00Saurel32 case 2: 16563242a00Saurel32 s->rtrg = 8; 16663242a00Saurel32 break; 16763242a00Saurel32 case 3: 16863242a00Saurel32 s->rtrg = 14; 16963242a00Saurel32 break; 17063242a00Saurel32 } 17163242a00Saurel32 if (val & (1 << 1)) { 17263242a00Saurel32 sh_serial_clear_fifo(s); 17363242a00Saurel32 s->sr &= ~(1 << 1); 17463242a00Saurel32 } 17563242a00Saurel32 1762f062c72Sths return; 1772f062c72Sths case 0x20: /* SPTR */ 17863242a00Saurel32 s->sptr = val & 0xf3; 1792f062c72Sths return; 1802f062c72Sths case 0x24: /* LSR */ 1812f062c72Sths return; 1822f062c72Sths } 183f94bff13SBALATON Zoltan } else { 1842f062c72Sths switch (offs) { 185d1f193b0Saurel32 #if 0 1862f062c72Sths case 0x0c: 1872f062c72Sths ret = s->dr; 1882f062c72Sths break; 1892f062c72Sths case 0x10: 1902f062c72Sths ret = 0; 1912f062c72Sths break; 1922f062c72Sths #endif 193d1f193b0Saurel32 case 0x1c: 194d1f193b0Saurel32 s->sptr = val & 0x8f; 195d1f193b0Saurel32 return; 196d1f193b0Saurel32 } 1972f062c72Sths } 1982f062c72Sths 199c1950a4eSPeter Maydell fprintf(stderr, "sh_serial: unsupported write to 0x%02" 200a8170e5eSAvi Kivity HWADDR_PRIx "\n", offs); 20143dc2a64SBlue Swirl abort(); 2022f062c72Sths } 2032f062c72Sths 204a8170e5eSAvi Kivity static uint64_t sh_serial_read(void *opaque, hwaddr offs, 2059a9d0b81SBenoît Canet unsigned size) 2062f062c72Sths { 2072f062c72Sths sh_serial_state *s = opaque; 2082f062c72Sths uint32_t ret = ~0; 2092f062c72Sths 2102f062c72Sths #if 0 2112f062c72Sths switch (offs) { 2122f062c72Sths case 0x00: 2132f062c72Sths ret = s->smr; 2142f062c72Sths break; 2152f062c72Sths case 0x04: 2162f062c72Sths ret = s->brr; 2172f062c72Sths break; 2182f062c72Sths case 0x08: 2192f062c72Sths ret = s->scr; 2202f062c72Sths break; 2212f062c72Sths case 0x14: 2222f062c72Sths ret = 0; 2232f062c72Sths break; 2242f062c72Sths } 2252f062c72Sths #endif 2262f062c72Sths if (s->feat & SH_SERIAL_FEAT_SCIF) { 2272f062c72Sths switch (offs) { 228bf5b7423Saurel32 case 0x00: /* SMR */ 229bf5b7423Saurel32 ret = s->smr; 230bf5b7423Saurel32 break; 231bf5b7423Saurel32 case 0x08: /* SCR */ 232bf5b7423Saurel32 ret = s->scr; 233bf5b7423Saurel32 break; 2342f062c72Sths case 0x10: /* FSR */ 2352f062c72Sths ret = 0; 236ac3c9e74SBALATON Zoltan if (s->flags & SH_SERIAL_FLAG_TEND) { 2372f062c72Sths ret |= (1 << 6); 238ac3c9e74SBALATON Zoltan } 239ac3c9e74SBALATON Zoltan if (s->flags & SH_SERIAL_FLAG_TDE) { 2402f062c72Sths ret |= (1 << 5); 241ac3c9e74SBALATON Zoltan } 242ac3c9e74SBALATON Zoltan if (s->flags & SH_SERIAL_FLAG_BRK) { 2432f062c72Sths ret |= (1 << 4); 244ac3c9e74SBALATON Zoltan } 245ac3c9e74SBALATON Zoltan if (s->flags & SH_SERIAL_FLAG_RDF) { 2462f062c72Sths ret |= (1 << 1); 247ac3c9e74SBALATON Zoltan } 248ac3c9e74SBALATON Zoltan if (s->flags & SH_SERIAL_FLAG_DR) { 2492f062c72Sths ret |= (1 << 0); 250ac3c9e74SBALATON Zoltan } 2512f062c72Sths 252ac3c9e74SBALATON Zoltan if (s->scr & (1 << 5)) { 2532f062c72Sths s->flags |= SH_SERIAL_FLAG_TDE | SH_SERIAL_FLAG_TEND; 254ac3c9e74SBALATON Zoltan } 2552f062c72Sths 2562f062c72Sths break; 25763242a00Saurel32 case 0x14: 25863242a00Saurel32 if (s->rx_cnt > 0) { 25963242a00Saurel32 ret = s->rx_fifo[s->rx_tail++]; 26063242a00Saurel32 s->rx_cnt--; 261ac3c9e74SBALATON Zoltan if (s->rx_tail == SH_RX_FIFO_LENGTH) { 26263242a00Saurel32 s->rx_tail = 0; 263ac3c9e74SBALATON Zoltan } 264ac3c9e74SBALATON Zoltan if (s->rx_cnt < s->rtrg) { 26563242a00Saurel32 s->flags &= ~SH_SERIAL_FLAG_RDF; 26663242a00Saurel32 } 267ac3c9e74SBALATON Zoltan } 26863242a00Saurel32 break; 2692f062c72Sths case 0x18: 2702f062c72Sths ret = s->fcr; 2712f062c72Sths break; 2722f062c72Sths case 0x1c: 2732f062c72Sths ret = s->rx_cnt; 2742f062c72Sths break; 2752f062c72Sths case 0x20: 2762f062c72Sths ret = s->sptr; 2772f062c72Sths break; 2782f062c72Sths case 0x24: 2792f062c72Sths ret = 0; 2802f062c72Sths break; 2812f062c72Sths } 282f94bff13SBALATON Zoltan } else { 2832f062c72Sths switch (offs) { 284d1f193b0Saurel32 #if 0 2852f062c72Sths case 0x0c: 2862f062c72Sths ret = s->dr; 2872f062c72Sths break; 2882f062c72Sths case 0x10: 2892f062c72Sths ret = 0; 2902f062c72Sths break; 29163242a00Saurel32 case 0x14: 29263242a00Saurel32 ret = s->rx_fifo[0]; 29363242a00Saurel32 break; 294d1f193b0Saurel32 #endif 2952f062c72Sths case 0x1c: 2962f062c72Sths ret = s->sptr; 2972f062c72Sths break; 2982f062c72Sths } 2992f062c72Sths } 300*ad52cfc1SBALATON Zoltan trace_sh_serial_read(size, offs, ret); 3012f062c72Sths 3022f062c72Sths if (ret & ~((1 << 16) - 1)) { 303c1950a4eSPeter Maydell fprintf(stderr, "sh_serial: unsupported read from 0x%02" 304a8170e5eSAvi Kivity HWADDR_PRIx "\n", offs); 30543dc2a64SBlue Swirl abort(); 3062f062c72Sths } 3072f062c72Sths 3082f062c72Sths return ret; 3092f062c72Sths } 3102f062c72Sths 3112f062c72Sths static int sh_serial_can_receive(sh_serial_state *s) 3122f062c72Sths { 31363242a00Saurel32 return s->scr & (1 << 4); 3142f062c72Sths } 3152f062c72Sths 3162f062c72Sths static void sh_serial_receive_break(sh_serial_state *s) 3172f062c72Sths { 318ac3c9e74SBALATON Zoltan if (s->feat & SH_SERIAL_FEAT_SCIF) { 31963242a00Saurel32 s->sr |= (1 << 4); 3202f062c72Sths } 321ac3c9e74SBALATON Zoltan } 3222f062c72Sths 3232f062c72Sths static int sh_serial_can_receive1(void *opaque) 3242f062c72Sths { 3252f062c72Sths sh_serial_state *s = opaque; 3262f062c72Sths return sh_serial_can_receive(s); 3272f062c72Sths } 3282f062c72Sths 32971bb4ce1SGeert Uytterhoeven static void sh_serial_timeout_int(void *opaque) 33071bb4ce1SGeert Uytterhoeven { 33171bb4ce1SGeert Uytterhoeven sh_serial_state *s = opaque; 33271bb4ce1SGeert Uytterhoeven 33371bb4ce1SGeert Uytterhoeven s->flags |= SH_SERIAL_FLAG_RDF; 33471bb4ce1SGeert Uytterhoeven if (s->scr & (1 << 6) && s->rxi) { 33571bb4ce1SGeert Uytterhoeven qemu_set_irq(s->rxi, 1); 33671bb4ce1SGeert Uytterhoeven } 33771bb4ce1SGeert Uytterhoeven } 33871bb4ce1SGeert Uytterhoeven 3392f062c72Sths static void sh_serial_receive1(void *opaque, const uint8_t *buf, int size) 3402f062c72Sths { 3412f062c72Sths sh_serial_state *s = opaque; 342b7d2b020SAurelien Jarno 343b7d2b020SAurelien Jarno if (s->feat & SH_SERIAL_FEAT_SCIF) { 344b7d2b020SAurelien Jarno int i; 345b7d2b020SAurelien Jarno for (i = 0; i < size; i++) { 346b7d2b020SAurelien Jarno if (s->rx_cnt < SH_RX_FIFO_LENGTH) { 347b7d2b020SAurelien Jarno s->rx_fifo[s->rx_head++] = buf[i]; 348b7d2b020SAurelien Jarno if (s->rx_head == SH_RX_FIFO_LENGTH) { 349b7d2b020SAurelien Jarno s->rx_head = 0; 350b7d2b020SAurelien Jarno } 351b7d2b020SAurelien Jarno s->rx_cnt++; 352b7d2b020SAurelien Jarno if (s->rx_cnt >= s->rtrg) { 353b7d2b020SAurelien Jarno s->flags |= SH_SERIAL_FLAG_RDF; 354b7d2b020SAurelien Jarno if (s->scr & (1 << 6) && s->rxi) { 35571bb4ce1SGeert Uytterhoeven timer_del(s->fifo_timeout_timer); 356b7d2b020SAurelien Jarno qemu_set_irq(s->rxi, 1); 357b7d2b020SAurelien Jarno } 35871bb4ce1SGeert Uytterhoeven } else { 35971bb4ce1SGeert Uytterhoeven timer_mod(s->fifo_timeout_timer, 36071bb4ce1SGeert Uytterhoeven qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + 15 * s->etu); 361b7d2b020SAurelien Jarno } 362b7d2b020SAurelien Jarno } 363b7d2b020SAurelien Jarno } 364b7d2b020SAurelien Jarno } else { 365b7d2b020SAurelien Jarno s->rx_fifo[0] = buf[0]; 366b7d2b020SAurelien Jarno } 3672f062c72Sths } 3682f062c72Sths 369083b266fSPhilippe Mathieu-Daudé static void sh_serial_event(void *opaque, QEMUChrEvent event) 3702f062c72Sths { 3712f062c72Sths sh_serial_state *s = opaque; 372ac3c9e74SBALATON Zoltan if (event == CHR_EVENT_BREAK) { 3732f062c72Sths sh_serial_receive_break(s); 3742f062c72Sths } 375ac3c9e74SBALATON Zoltan } 3762f062c72Sths 3779a9d0b81SBenoît Canet static const MemoryRegionOps sh_serial_ops = { 3789a9d0b81SBenoît Canet .read = sh_serial_read, 3799a9d0b81SBenoît Canet .write = sh_serial_write, 3809a9d0b81SBenoît Canet .endianness = DEVICE_NATIVE_ENDIAN, 3812f062c72Sths }; 3822f062c72Sths 3839a9d0b81SBenoît Canet void sh_serial_init(MemoryRegion *sysmem, 384a8170e5eSAvi Kivity hwaddr base, int feat, 3850ec7b3e7SMarc-André Lureau uint32_t freq, Chardev *chr, 3864e7ed2d1Saurel32 qemu_irq eri_source, 3874e7ed2d1Saurel32 qemu_irq rxi_source, 3884e7ed2d1Saurel32 qemu_irq txi_source, 3894e7ed2d1Saurel32 qemu_irq tei_source, 3904e7ed2d1Saurel32 qemu_irq bri_source) 3912f062c72Sths { 3922f062c72Sths sh_serial_state *s; 3932f062c72Sths 3947267c094SAnthony Liguori s = g_malloc0(sizeof(sh_serial_state)); 3952f062c72Sths 3962f062c72Sths s->feat = feat; 3972f062c72Sths s->flags = SH_SERIAL_FLAG_TEND | SH_SERIAL_FLAG_TDE; 39863242a00Saurel32 s->rtrg = 1; 3992f062c72Sths 4002f062c72Sths s->smr = 0; 4012f062c72Sths s->brr = 0xff; 402b7d35e65Sbalrog s->scr = 1 << 5; /* pretend that TX is enabled so early printk works */ 4032f062c72Sths s->sptr = 0; 4042f062c72Sths 4052f062c72Sths if (feat & SH_SERIAL_FEAT_SCIF) { 4062f062c72Sths s->fcr = 0; 407f94bff13SBALATON Zoltan } else { 4082f062c72Sths s->dr = 0xff; 4092f062c72Sths } 4102f062c72Sths 41163242a00Saurel32 sh_serial_clear_fifo(s); 4122f062c72Sths 4132c9b15caSPaolo Bonzini memory_region_init_io(&s->iomem, NULL, &sh_serial_ops, s, 4149a9d0b81SBenoît Canet "serial", 0x100000000ULL); 4159a9d0b81SBenoît Canet 4162c9b15caSPaolo Bonzini memory_region_init_alias(&s->iomem_p4, NULL, "serial-p4", &s->iomem, 4179a9d0b81SBenoît Canet 0, 0x28); 4189a9d0b81SBenoît Canet memory_region_add_subregion(sysmem, P4ADDR(base), &s->iomem_p4); 4199a9d0b81SBenoît Canet 4202c9b15caSPaolo Bonzini memory_region_init_alias(&s->iomem_a7, NULL, "serial-a7", &s->iomem, 4219a9d0b81SBenoît Canet 0, 0x28); 4229a9d0b81SBenoît Canet memory_region_add_subregion(sysmem, A7ADDR(base), &s->iomem_a7); 4232f062c72Sths 424456d6069SHans de Goede if (chr) { 42532a6ebecSMarc-André Lureau qemu_chr_fe_init(&s->chr, chr, &error_abort); 4265345fdb4SMarc-André Lureau qemu_chr_fe_set_handlers(&s->chr, sh_serial_can_receive1, 4275345fdb4SMarc-André Lureau sh_serial_receive1, 42881517ba3SAnton Nefedov sh_serial_event, NULL, s, NULL, true); 429456d6069SHans de Goede } 430bf5b7423Saurel32 43171bb4ce1SGeert Uytterhoeven s->fifo_timeout_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, 43271bb4ce1SGeert Uytterhoeven sh_serial_timeout_int, s); 43371bb4ce1SGeert Uytterhoeven s->etu = NANOSECONDS_PER_SECOND / 9600; 434bf5b7423Saurel32 s->eri = eri_source; 435bf5b7423Saurel32 s->rxi = rxi_source; 436bf5b7423Saurel32 s->txi = txi_source; 437bf5b7423Saurel32 s->tei = tei_source; 438bf5b7423Saurel32 s->bri = bri_source; 4392f062c72Sths } 440