UART headers are no longer shared. No reason to keep code inside headers. Signed-off-by: Ralf Ramsauer <[email protected]> --- hypervisor/arch/arm-common/include/asm/uart-8250.h | 48 -------------- .../arch/arm-common/include/asm/uart-pl011.h | 73 ---------------------- hypervisor/arch/arm-common/uart-8250.c | 37 ++++++++++- hypervisor/arch/arm-common/uart-pl011.c | 57 ++++++++++++++++- 4 files changed, 92 insertions(+), 123 deletions(-) delete mode 100644 hypervisor/arch/arm-common/include/asm/uart-8250.h delete mode 100644 hypervisor/arch/arm-common/include/asm/uart-pl011.h
diff --git a/hypervisor/arch/arm-common/include/asm/uart-8250.h b/hypervisor/arch/arm-common/include/asm/uart-8250.h deleted file mode 100644 index 6930f58c47..0000000000 --- a/hypervisor/arch/arm-common/include/asm/uart-8250.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Jailhouse, a Linux-based partitioning hypervisor - * - * Copyright (c) Siemens AG, 2014 - * - * Authors: - * Jan Kiszka <[email protected]> - * - * This work is licensed under the terms of the GNU GPL, version 2. See - * the COPYING file in the top-level directory. - */ - -#include <jailhouse/mmio.h> -#include <jailhouse/processor.h> -#include <asm/uart.h> - -#define UART_TX 0x0 -#define UART_DLL 0x0 -#define UART_DLM 0x4 -#define UART_LCR 0xc -#define UART_LCR_8N1 0x03 -#define UART_LCR_DLAB 0x80 -#define UART_LSR 0x14 -#define UART_LSR_THRE 0x20 - -static void uart_init(struct uart_chip *chip) -{ - if (chip->clock_reg) - mmio_write32(chip->clock_reg, - mmio_read32(chip->clock_reg) | - (1 << chip->gate_nr)); - - mmio_write32(chip->virt_base + UART_LCR, UART_LCR_DLAB); - mmio_write32(chip->virt_base + UART_DLL, 0x0d); - mmio_write32(chip->virt_base + UART_DLM, 0); - mmio_write32(chip->virt_base + UART_LCR, UART_LCR_8N1); -} - -static void uart_wait(struct uart_chip *chip) -{ - while (!(mmio_read32(chip->virt_base + UART_LSR) & UART_LSR_THRE)) - cpu_relax(); -} - -static void uart_write(struct uart_chip *chip, char c) -{ - mmio_write32(chip->virt_base + UART_TX, c); -} diff --git a/hypervisor/arch/arm-common/include/asm/uart-pl011.h b/hypervisor/arch/arm-common/include/asm/uart-pl011.h deleted file mode 100644 index 06d1f3a027..0000000000 --- a/hypervisor/arch/arm-common/include/asm/uart-pl011.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Jailhouse, a Linux-based partitioning hypervisor - * - * Copyright (c) ARM Limited, 2014 - * - * Authors: - * Jean-Philippe Brucker <[email protected]> - * - * This work is licensed under the terms of the GNU GPL, version 2. See - * the COPYING file in the top-level directory. - */ - -#ifndef _JAILHOUSE_ASM_DEBUG_PL011_H -#define _JAILHOUSE_ASM_DEBUG_PL011_H - -#include <jailhouse/mmio.h> -#include <asm/processor.h> -#include <asm/uart.h> - -#define UART_CLK 24000000 - -#define UARTDR 0x00 -#define UARTFR 0x18 -#define UARTIBRD 0x24 -#define UARTLCR_H 0x2c -#define UARTCR 0x30 - -#define UARTFR_TXFF (1 << 5) -#define UARTFR_BUSY (1 << 3) - -#define UARTCR_Out2 (1 << 13) -#define UARTCR_Out1 (1 << 12) -#define UARTCR_RXE (1 << 9) -#define UARTCR_TXE (1 << 8) -#define UARTCR_EN (1 << 0) - -#define UARTLCR_H_WLEN (3 << 5) - -static void uart_init(struct uart_chip *chip) -{ -#ifdef CONFIG_MACH_VEXPRESS - /* 115200 8N1 */ - /* FIXME: Can be improved with an implementation of __aeabi_uidiv */ - u32 bauddiv = UART_CLK / (16 * 115200); - void *base = chip->virt_base; - - mmio_write16(base + UARTCR, 0); - while (mmio_read8(base + UARTFR) & UARTFR_BUSY) - cpu_relax(); - - mmio_write8(base + UARTLCR_H, UARTLCR_H_WLEN); - mmio_write16(base + UARTIBRD, bauddiv); - mmio_write16(base + UARTCR, (UARTCR_EN | UARTCR_TXE | UARTCR_RXE | - UARTCR_Out1 | UARTCR_Out2)); -#endif -} - -static void uart_wait(struct uart_chip *chip) -{ - u32 flags; - - do { - flags = mmio_read32(chip->virt_base + UARTFR); - cpu_relax(); - } while (flags & (UARTFR_TXFF | UARTFR_BUSY)); /* FIFO full or busy */ -} - -static void uart_write(struct uart_chip *chip, char c) -{ - mmio_write32(chip->virt_base + UARTDR, c); -} - -#endif /* !_JAILHOUSE_ASM_DEBUG_PL011_H */ diff --git a/hypervisor/arch/arm-common/uart-8250.c b/hypervisor/arch/arm-common/uart-8250.c index ef5bc9ecdb..b040b8daf9 100644 --- a/hypervisor/arch/arm-common/uart-8250.c +++ b/hypervisor/arch/arm-common/uart-8250.c @@ -12,7 +12,42 @@ * the COPYING file in the top-level directory. */ -#include <asm/uart-8250.h> +#include <jailhouse/mmio.h> +#include <jailhouse/processor.h> +#include <asm/uart.h> + +#define UART_TX 0x0 +#define UART_DLL 0x0 +#define UART_DLM 0x4 +#define UART_LCR 0xc +#define UART_LCR_8N1 0x03 +#define UART_LCR_DLAB 0x80 +#define UART_LSR 0x14 +#define UART_LSR_THRE 0x20 + +static void uart_init(struct uart_chip *chip) +{ + if (chip->clock_reg) + mmio_write32(chip->clock_reg, + mmio_read32(chip->clock_reg) | + (1 << chip->gate_nr)); + + mmio_write32(chip->virt_base + UART_LCR, UART_LCR_DLAB); + mmio_write32(chip->virt_base + UART_DLL, 0x0d); + mmio_write32(chip->virt_base + UART_DLM, 0); + mmio_write32(chip->virt_base + UART_LCR, UART_LCR_8N1); +} + +static void uart_wait(struct uart_chip *chip) +{ + while (!(mmio_read32(chip->virt_base + UART_LSR) & UART_LSR_THRE)) + cpu_relax(); +} + +static void uart_write(struct uart_chip *chip, char c) +{ + mmio_write32(chip->virt_base + UART_TX, c); +} void uart_chip_init(struct uart_chip *chip) { diff --git a/hypervisor/arch/arm-common/uart-pl011.c b/hypervisor/arch/arm-common/uart-pl011.c index 6824ff79f6..2716ea4da8 100644 --- a/hypervisor/arch/arm-common/uart-pl011.c +++ b/hypervisor/arch/arm-common/uart-pl011.c @@ -10,7 +10,62 @@ * the COPYING file in the top-level directory. */ -#include <asm/uart-pl011.h> +#include <jailhouse/mmio.h> +#include <asm/processor.h> +#include <asm/uart.h> + +#define UART_CLK 24000000 + +#define UARTDR 0x00 +#define UARTFR 0x18 +#define UARTIBRD 0x24 +#define UARTLCR_H 0x2c +#define UARTCR 0x30 + +#define UARTFR_TXFF (1 << 5) +#define UARTFR_BUSY (1 << 3) + +#define UARTCR_Out2 (1 << 13) +#define UARTCR_Out1 (1 << 12) +#define UARTCR_RXE (1 << 9) +#define UARTCR_TXE (1 << 8) +#define UARTCR_EN (1 << 0) + +#define UARTLCR_H_WLEN (3 << 5) + +static void uart_init(struct uart_chip *chip) +{ +#ifdef CONFIG_MACH_VEXPRESS + /* 115200 8N1 */ + /* FIXME: Can be improved with an implementation of __aeabi_uidiv */ + u32 bauddiv = UART_CLK / (16 * 115200); + void *base = chip->virt_base; + + mmio_write16(base + UARTCR, 0); + while (mmio_read8(base + UARTFR) & UARTFR_BUSY) + cpu_relax(); + + mmio_write8(base + UARTLCR_H, UARTLCR_H_WLEN); + mmio_write16(base + UARTIBRD, bauddiv); + mmio_write16(base + UARTCR, (UARTCR_EN | UARTCR_TXE | UARTCR_RXE | + UARTCR_Out1 | UARTCR_Out2)); +#endif +} + +static void uart_wait(struct uart_chip *chip) +{ + u32 flags; + + do { + flags = mmio_read32(chip->virt_base + UARTFR); + cpu_relax(); + } while (flags & (UARTFR_TXFF | UARTFR_BUSY)); /* FIFO full or busy */ +} + +static void uart_write(struct uart_chip *chip, char c) +{ + mmio_write32(chip->virt_base + UARTDR, c); +} void uart_chip_init(struct uart_chip *chip) { -- 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.
