Add an additional divider variable to the uart structure that allows to dynamically set the uart baudrate.
If the divider is zero, the hypervisor will skip UART initialisation and assume that the UART was already initialised by Linux. For most scenarios, this is the default case and the reason why .divider values are comments inside system configurations that represent common default values, if initialisation is required. Those default values are: - arm: Banana Pi (0x0d, 8250) - arm: Jetson TK1 (0xdd, tegra, yet unused) - x86: PIO (0x1, means 115200 (?)) - x86: OXPCIE (0x22, currently not used) Additionally, the introduction of the divider gives us the chance to get rid of CONFIG_SERIAL_OXPCIE952 in hypervisor code. Signed-off-by: Ralf Ramsauer <[email protected]> --- configs/bananapi.c | 1 + configs/f2a88xm-hd3.c | 1 + configs/h87i.c | 1 + configs/imb-a180.c | 1 + configs/jetson-tk1.c | 1 + configs/qemu-vm.c | 1 + hypervisor/arch/arm-common/uart-8250.c | 6 +++++- hypervisor/arch/x86/uart.c | 10 +++++----- hypervisor/include/jailhouse/cell-config.h | 2 ++ 9 files changed, 18 insertions(+), 6 deletions(-) diff --git a/configs/bananapi.c b/configs/bananapi.c index d0bb0ce575..b79f639e29 100644 --- a/configs/bananapi.c +++ b/configs/bananapi.c @@ -33,6 +33,7 @@ struct { .debug_console = { .address = 0x01c28000, .size = 0x1000, + /* .divider = 0x0d, */ .flags = JAILHOUSE_DBG_TYPE_UART_ARM | JAILHOUSE_DBG_FLAG_MMIO, }, diff --git a/configs/f2a88xm-hd3.c b/configs/f2a88xm-hd3.c index 55e4d9c828..daca0b2ee8 100644 --- a/configs/f2a88xm-hd3.c +++ b/configs/f2a88xm-hd3.c @@ -39,6 +39,7 @@ struct { }, .debug_console = { .address = 0x3f8, + /* .divider = 0x1, */ .flags = JAILHOUSE_DBG_TYPE_UART_X86 | JAILHOUSE_DBG_FLAG_PIO, }, diff --git a/configs/h87i.c b/configs/h87i.c index fbfa55ac43..9c06fb2fd2 100644 --- a/configs/h87i.c +++ b/configs/h87i.c @@ -34,6 +34,7 @@ struct { }, .debug_console = { .address = 0xe010, + /* .divider = 0x1, */ .flags = JAILHOUSE_DBG_TYPE_UART_X86 | JAILHOUSE_DBG_FLAG_PIO, }, diff --git a/configs/imb-a180.c b/configs/imb-a180.c index e740c416cf..3cfdc2012e 100644 --- a/configs/imb-a180.c +++ b/configs/imb-a180.c @@ -38,6 +38,7 @@ struct { }, .debug_console = { .address = 0x3f8, + /* .divider = 0x1, */ .flags = JAILHOUSE_DBG_TYPE_UART_X86 | JAILHOUSE_DBG_FLAG_PIO, }, diff --git a/configs/jetson-tk1.c b/configs/jetson-tk1.c index 7b461bc922..1ee780bd7b 100644 --- a/configs/jetson-tk1.c +++ b/configs/jetson-tk1.c @@ -36,6 +36,7 @@ struct { .debug_console = { .address = 0x70006000, .size = 0x1000, + /* .divider = 0xdd, */ .flags = JAILHOUSE_DBG_TYPE_UART_ARM | JAILHOUSE_DBG_FLAG_MMIO, }, diff --git a/configs/qemu-vm.c b/configs/qemu-vm.c index 0d7ab58166..db905a78ce 100644 --- a/configs/qemu-vm.c +++ b/configs/qemu-vm.c @@ -48,6 +48,7 @@ struct { }, .debug_console = { .address = 0x3f8, + /* .divider = 0x1, */ .flags = JAILHOUSE_DBG_TYPE_UART_X86 | JAILHOUSE_DBG_FLAG_PIO, }, diff --git a/hypervisor/arch/arm-common/uart-8250.c b/hypervisor/arch/arm-common/uart-8250.c index b040b8daf9..613f2cabc7 100644 --- a/hypervisor/arch/arm-common/uart-8250.c +++ b/hypervisor/arch/arm-common/uart-8250.c @@ -32,8 +32,12 @@ static void uart_init(struct uart_chip *chip) mmio_read32(chip->clock_reg) | (1 << chip->gate_nr)); + /* only initialise if divider is not zero */ + if (!chip->debug_console->divider) + return; + mmio_write32(chip->virt_base + UART_LCR, UART_LCR_DLAB); - mmio_write32(chip->virt_base + UART_DLL, 0x0d); + mmio_write32(chip->virt_base + UART_DLL, chip->debug_console->divider); mmio_write32(chip->virt_base + UART_DLM, 0); mmio_write32(chip->virt_base + UART_LCR, UART_LCR_8N1); } diff --git a/hypervisor/arch/x86/uart.c b/hypervisor/arch/x86/uart.c index 41e74e83f2..4d6ce186d5 100644 --- a/hypervisor/arch/x86/uart.c +++ b/hypervisor/arch/x86/uart.c @@ -55,6 +55,7 @@ static u8 (*uart_reg_in)(unsigned int) = uart_pio_in; void uart_init(void) { u32 flags = system_config->debug_console.flags; + u32 divider = system_config->debug_console.divider; if (DBG_IS_MMIO(flags)) { uart_reg_out = uart_mmio32_out; @@ -64,12 +65,11 @@ void uart_init(void) uart_base = system_config->debug_console.address; } + if (!divider) + return; + uart_reg_out(UART_LCR, UART_LCR_DLAB); -#ifdef CONFIG_SERIAL_OXPCIE952 - outb(0x22, uart_base + UART_DLL); -#else - uart_reg_out(UART_DLL, 1); -#endif + uart_reg_out(UART_DLL, divider); uart_reg_out(UART_DLM, 0); uart_reg_out(UART_LCR, UART_LCR_8N1); } diff --git a/hypervisor/include/jailhouse/cell-config.h b/hypervisor/include/jailhouse/cell-config.h index 0c5c8c033f..8cfbc1787a 100644 --- a/hypervisor/include/jailhouse/cell-config.h +++ b/hypervisor/include/jailhouse/cell-config.h @@ -185,6 +185,8 @@ struct jailhouse_debug_console { __u64 address; __u32 size; __u32 flags; + __u32 divider; + __u32 __reserved; } __attribute__((packed)); #define JAILHOUSE_SYSTEM_SIGNATURE "JAILSYST" -- 2.11.0.rc2 -- You received this message because you are subscribed to the Google Groups "Jailhouse" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
