102d74341Scmchao /*
202d74341Scmchao * TI OMAP processors UART emulation.
302d74341Scmchao *
402d74341Scmchao * Copyright (C) 2006-2008 Andrzej Zaborowski <balrog@zabor.org>
502d74341Scmchao * Copyright (C) 2007-2009 Nokia Corporation
602d74341Scmchao *
702d74341Scmchao * This program is free software; you can redistribute it and/or
802d74341Scmchao * modify it under the terms of the GNU General Public License as
902d74341Scmchao * published by the Free Software Foundation; either version 2 or
1002d74341Scmchao * (at your option) version 3 of the License.
1102d74341Scmchao *
1202d74341Scmchao * This program is distributed in the hope that it will be useful,
1302d74341Scmchao * but WITHOUT ANY WARRANTY; without even the implied warranty of
1402d74341Scmchao * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1502d74341Scmchao * GNU General Public License for more details.
1602d74341Scmchao *
1702d74341Scmchao * You should have received a copy of the GNU General Public License along
1802d74341Scmchao * with this program; if not, see <http://www.gnu.org/licenses/>.
1902d74341Scmchao */
2017b7f2dbSPeter Maydell #include "qemu/osdep.h"
218228e353SMarc-André Lureau #include "chardev/char.h"
220d09e41aSPaolo Bonzini #include "hw/arm/omap.h"
237e6b5497SBernhard Beschow #include "hw/char/serial-mm.h"
24*dfc56946SRichard Henderson #include "system/address-spaces.h"
2502d74341Scmchao
2602d74341Scmchao /* UARTs */
2702d74341Scmchao struct omap_uart_s {
28aee39503SAvi Kivity MemoryRegion iomem;
29a8170e5eSAvi Kivity hwaddr base;
30490a9d9bSMarc-André Lureau SerialMM *serial; /* TODO */
3102d74341Scmchao omap_clk fclk;
3202d74341Scmchao qemu_irq irq;
3302d74341Scmchao
3402d74341Scmchao uint8_t eblr;
3502d74341Scmchao uint8_t syscontrol;
3602d74341Scmchao uint8_t wkup;
3702d74341Scmchao uint8_t cfps;
3802d74341Scmchao uint8_t clksel;
3902d74341Scmchao };
4002d74341Scmchao
omap_uart_reset(struct omap_uart_s * s)4102d74341Scmchao void omap_uart_reset(struct omap_uart_s *s)
4202d74341Scmchao {
4302d74341Scmchao s->eblr = 0x00;
4402d74341Scmchao s->syscontrol = 0;
4502d74341Scmchao s->wkup = 0x3f;
4602d74341Scmchao s->cfps = 0x69;
4702d74341Scmchao s->clksel = 0;
4802d74341Scmchao }
4902d74341Scmchao
omap_uart_init(hwaddr base,qemu_irq irq,omap_clk fclk,omap_clk iclk,qemu_irq txdma,qemu_irq rxdma,const char * label,Chardev * chr)50a8170e5eSAvi Kivity struct omap_uart_s *omap_uart_init(hwaddr base,
5102d74341Scmchao qemu_irq irq, omap_clk fclk, omap_clk iclk,
526a8aabd3SStefan Weil qemu_irq txdma, qemu_irq rxdma,
530ec7b3e7SMarc-André Lureau const char *label, Chardev *chr)
5402d74341Scmchao {
55b45c03f5SMarkus Armbruster struct omap_uart_s *s = g_new0(struct omap_uart_s, 1);
5602d74341Scmchao
5702d74341Scmchao s->base = base;
5802d74341Scmchao s->fclk = fclk;
5902d74341Scmchao s->irq = irq;
6039186d8aSRichard Henderson s->serial = serial_mm_init(get_system_memory(), base, 2, irq,
6139186d8aSRichard Henderson omap_clk_getrate(fclk) / 16,
624ad6f6cbSPaolo Bonzini chr ?: qemu_chr_new(label, "null", NULL),
63fb50cfe4SRichard Henderson DEVICE_NATIVE_ENDIAN);
6402d74341Scmchao return s;
6502d74341Scmchao }
66