[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 1/2] hw/char/serial: Add a helper to set the divisor
From: |
Philippe Mathieu-Daudé |
Subject: |
[Qemu-devel] [PATCH 1/2] hw/char/serial: Add a helper to set the divisor register |
Date: |
Tue, 20 Aug 2019 14:34:16 +0200 |
Some chipsets provide 16650 compatible UART with exhanced
features. The BCM2835 provides a register to directly set
the baudrate divisor register without having to use the
LABD bit.
Add a helper to allow models to directly set the divisor.
Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
---
hw/char/serial.c | 6 ++++++
include/hw/char/serial.h | 1 +
2 files changed, 7 insertions(+)
diff --git a/hw/char/serial.c b/hw/char/serial.c
index b4aa250950..12eb93705d 100644
--- a/hw/char/serial.c
+++ b/hw/char/serial.c
@@ -191,6 +191,12 @@ static void serial_update_parameters(SerialState *s)
speed, parity, data_bits, stop_bits);
}
+void serial_set_divider(SerialState *s, uint16_t divider)
+{
+ s->divider = divider;
+ serial_update_parameters(s);
+}
+
static void serial_update_msl(SerialState *s)
{
uint8_t omsr;
diff --git a/include/hw/char/serial.h b/include/hw/char/serial.h
index 8be3d8a4f9..ef211f695d 100644
--- a/include/hw/char/serial.h
+++ b/include/hw/char/serial.h
@@ -83,6 +83,7 @@ extern const MemoryRegionOps serial_io_ops;
void serial_realize_core(SerialState *s, Error **errp);
void serial_exit_core(SerialState *s);
void serial_set_frequency(SerialState *s, uint32_t frequency);
+void serial_set_divider(SerialState *s, uint16_t divider);
/* legacy pre qom */
SerialState *serial_init(int base, qemu_irq irq, int baudbase,
--
2.20.1