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 95424588f814..0f5c2cf54870 100644 --- a/configs/bananapi.c +++ b/configs/bananapi.c @@ -32,6 +32,7 @@ struct { .debug_console = { .address = 0x01c28000, .size = 0x1000, + /* .divider = 0x0d, */ .flags = JAILHOUSE_DBG_TYPE_UART_ARM | JAILHOUSE_DBG_FLAG_MMIO | JAILHOUSE_DBG_FLAG_REG_WIDTH_32, diff --git a/configs/f2a88xm-hd3.c b/configs/f2a88xm-hd3.c index ba1e2f0d8b85..d9e631edf6ac 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 | JAILHOUSE_DBG_FLAG_REG_WIDTH_8, diff --git a/configs/h87i.c b/configs/h87i.c index 1cbdc33113dc..7422667d62ed 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 | JAILHOUSE_DBG_FLAG_REG_WIDTH_8, diff --git a/configs/imb-a180.c b/configs/imb-a180.c index f944fe35a6d8..7981b8613996 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 | JAILHOUSE_DBG_FLAG_REG_WIDTH_8, diff --git a/configs/jetson-tk1.c b/configs/jetson-tk1.c index cc24ad0cc05b..572d827fc145 100644 --- a/configs/jetson-tk1.c +++ b/configs/jetson-tk1.c @@ -35,6 +35,7 @@ struct { .debug_console = { .address = 0x70006000, .size = 0x1000, + /* .divider = 0xdd, */ .flags = JAILHOUSE_DBG_TYPE_UART_ARM | JAILHOUSE_DBG_FLAG_MMIO | JAILHOUSE_DBG_FLAG_REG_WIDTH_32, diff --git a/configs/qemu-vm.c b/configs/qemu-vm.c index 532aa3d07720..8c91420c4a3a 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 | JAILHOUSE_DBG_FLAG_REG_WIDTH_8, diff --git a/hypervisor/arch/arm-common/uart-8250.c b/hypervisor/arch/arm-common/uart-8250.c index b040b8daf9f9..613f2cabc7a8 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 d5d3a6386c30..6faae13d3f06 100644 --- a/hypervisor/arch/x86/uart.c +++ b/hypervisor/arch/x86/uart.c @@ -64,6 +64,7 @@ static u8 (*uart_reg_in)(unsigned int) = uart_pio_in; void uart_init(void) { + u32 divider = system_config->debug_console.divider; u64 flags = system_config->debug_console.flags; if (DBG_IS_MMIO(flags)) { @@ -81,12 +82,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 6e2cb3fff86d..3ff54c34285d 100644 --- a/hypervisor/include/jailhouse/cell-config.h +++ b/hypervisor/include/jailhouse/cell-config.h @@ -187,6 +187,8 @@ struct jailhouse_debug_console { __u64 address; __u32 size; __u32 flags; + __u32 divider; + __u32 __reserved; } __attribute__((packed)); #define JAILHOUSE_SYSTEM_SIGNATURE "JAILSYST" -- 2.10.2 -- 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.
