示例#1
0
文件: pl011.c 项目: OP-TEE/optee_os
void pl011_init(struct pl011_data *pd, paddr_t pbase, uint32_t uart_clk,
		uint32_t baud_rate)
{
	vaddr_t base;

	pd->base.pa = pbase;
	pd->chip.ops = &pl011_ops;

	base = io_pa_or_va(&pd->base);

	/* Clear all errors */
	io_write32(base + UART_RSR_ECR, 0);
	/* Disable everything */
	io_write32(base + UART_CR, 0);

	if (baud_rate) {
		uint32_t divisor = (uart_clk * 4) / baud_rate;

		io_write32(base + UART_IBRD, divisor >> 6);
		io_write32(base + UART_FBRD, divisor & 0x3f);
	}

	/* Configure TX to 8 bits, 1 stop bit, no parity, fifo disabled. */
	io_write32(base + UART_LCR_H, UART_LCRH_WLEN_8);

	/* Enable interrupts for receive and receive timeout */
	io_write32(base + UART_IMSC, UART_IMSC_RXIM | UART_IMSC_RTIM);

	/* Enable UART and RX/TX */
	io_write32(base + UART_CR, UART_CR_UARTEN | UART_CR_TXE | UART_CR_RXE);

	pl011_flush(&pd->chip);
}
示例#2
0
static vaddr_t chip_to_base(struct serial_chip *chip)
{
	struct cdns_uart_data *pd =
		container_of(chip, struct cdns_uart_data, chip);

	return io_pa_or_va(&pd->base);
}
vaddr_t stm32_pwr_base(void)
{
	static struct io_pa_va base = { .pa = PWR_BASE };

	return io_pa_or_va(&base);
}