2 * SiFive UART interface
4 * Copyright (c) 2016 Stefan O'Rear
5 * Copyright (c) 2017 SiFive, Inc.
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms and conditions of the GNU General Public License,
9 * version 2 or later, as published by the Free Software Foundation.
11 * This program is distributed in the hope it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 * You should have received a copy of the GNU General Public License along with
17 * this program. If not, see <http://www.gnu.org/licenses/>.
20 #ifndef HW_SIFIVE_UART_H
21 #define HW_SIFIVE_UART_H
23 #include "chardev/char-fe.h"
24 #include "hw/sysbus.h"
25 #include "qom/object.h"
28 SIFIVE_UART_TXFIFO
= 0,
29 SIFIVE_UART_RXFIFO
= 4,
30 SIFIVE_UART_TXCTRL
= 8,
31 SIFIVE_UART_TXMARK
= 10,
32 SIFIVE_UART_RXCTRL
= 12,
33 SIFIVE_UART_RXMARK
= 14,
41 SIFIVE_UART_IE_TXWM
= 1, /* Transmit watermark interrupt enable */
42 SIFIVE_UART_IE_RXWM
= 2 /* Receive watermark interrupt enable */
46 SIFIVE_UART_IP_TXWM
= 1, /* Transmit watermark interrupt pending */
47 SIFIVE_UART_IP_RXWM
= 2 /* Receive watermark interrupt pending */
50 #define SIFIVE_UART_GET_TXCNT(txctrl) ((txctrl >> 16) & 0x7)
51 #define SIFIVE_UART_GET_RXCNT(rxctrl) ((rxctrl >> 16) & 0x7)
53 #define TYPE_SIFIVE_UART "riscv.sifive.uart"
55 typedef struct SiFiveUARTState SiFiveUARTState
;
56 DECLARE_INSTANCE_CHECKER(SiFiveUARTState
, SIFIVE_UART
,
59 struct SiFiveUARTState
{
61 SysBusDevice parent_obj
;
68 unsigned int rx_fifo_len
;
76 SiFiveUARTState
*sifive_uart_create(MemoryRegion
*address_space
, hwaddr base
,
77 Chardev
*chr
, qemu_irq irq
);