aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Vesely <jano.vesely@gmail.com>2013-02-18 16:58:30 +0000
committerPeter Maydell <peter.maydell@linaro.org>2015-05-03 21:27:53 +0100
commit7e87f92b1621cae0ed777af47bf4df3f9e52c2fa (patch)
tree2412c49f71eccf83d1b284ca9e461e78acfe04eb
parent8521bce75bba75899256274c4a65e0db70972098 (diff)
serial, omap_uart: Add support for fifo level regs
Signed-off-by: Jan Vesely <jano.vesely@gmail.com>
-rw-r--r--hw/char/omap_uart.c10
-rw-r--r--hw/char/serial.c12
-rw-r--r--include/hw/char/serial.h3
3 files changed, 25 insertions, 0 deletions
diff --git a/hw/char/omap_uart.c b/hw/char/omap_uart.c
index c2cf46a7d..565596330 100644
--- a/hw/char/omap_uart.c
+++ b/hw/char/omap_uart.c
@@ -177,6 +177,16 @@ static uint64_t omap_uart_read(void *opaque, hwaddr addr,
return s->wkup;
case 0x60: /* CFPS (OMAP2) */
return s->cfps;
+ case 0x64: /* RXFIFO_LVL_REG (OMAP36xx) */
+ if (s->revision >= 0x52) {
+ return serial_rx_fifo_count(s->serial) & 0xff;
+ }
+ break;
+ case 0x68: /* TXFIFO_LVL_REG (OMAP36xx) */
+ if (s->revision >= 0x52) {
+ return serial_tx_fifo_count(s->serial) & 0xff;
+ }
+ break;
}
OMAP_BAD_REG(addr);
diff --git a/hw/char/serial.c b/hw/char/serial.c
index 2bfed51b4..1a2ae41ef 100644
--- a/hw/char/serial.c
+++ b/hw/char/serial.c
@@ -883,6 +883,18 @@ void serial_exit_core(SerialState *s)
qemu_unregister_reset(serial_reset, s);
}
+/* Get number of stored bytes in receive fifo. */
+unsigned serial_rx_fifo_count(SerialState *s)
+{
+ return fifo8_num_used(&s->recv_fifo);
+}
+
+/* Get number of stored bytes in transmit fifo. */
+unsigned serial_tx_fifo_count(SerialState *s)
+{
+ return fifo8_num_used(&s->xmit_fifo);
+}
+
/* Change the main reference oscillator frequency. */
void serial_set_frequency(SerialState *s, uint32_t frequency)
{
diff --git a/include/hw/char/serial.h b/include/hw/char/serial.h
index 8a9bea5aa..e91e7b39c 100644
--- a/include/hw/char/serial.h
+++ b/include/hw/char/serial.h
@@ -85,6 +85,9 @@ void serial_change_char_driver(SerialState *s, CharDriverState *chr);
const MemoryRegionOps *serial_get_memops(enum device_endian end);
qemu_irq *serial_get_irq(SerialState *s);
+unsigned serial_rx_fifo_count(SerialState *s);
+unsigned serial_tx_fifo_count(SerialState *s);
+
/* legacy pre qom */
SerialState *serial_init(int base, qemu_irq irq, int baudbase,
CharDriverState *chr, MemoryRegion *system_io);