Skip to content

Commit

Permalink
core: arm: Fold UART headers and source
Browse files Browse the repository at this point in the history
UART headers are no longer shared. No reason to keep code inside
headers.

Signed-off-by: Ralf Ramsauer <ralf.ramsauer@oth-regensburg.de>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
  • Loading branch information
rralf authored and jan-kiszka committed Nov 29, 2016
1 parent c7c60d9 commit d989b18
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 123 deletions.
48 changes: 0 additions & 48 deletions hypervisor/arch/arm-common/include/asm/uart-8250.h

This file was deleted.

73 changes: 0 additions & 73 deletions hypervisor/arch/arm-common/include/asm/uart-pl011.h

This file was deleted.

37 changes: 36 additions & 1 deletion hypervisor/arch/arm-common/uart-8250.c
Expand Up @@ -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)
{
Expand Down
57 changes: 56 additions & 1 deletion hypervisor/arch/arm-common/uart-pl011.c
Expand Up @@ -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)
{
Expand Down

0 comments on commit d989b18

Please sign in to comment.