zephyr/drivers/serial/uart_riscv_qemu.c
Kumar Gala 461b5018d3 serial: introduce SERIAL_SUPPORT_INTERRUPT Kconfig option
As not all drivers support interrupts we don't have a means to know if
we can allow UART_INTERRUPT_DRIVEN to be enabled and thus various
Kconfig options that select UART_INTERRUPT_DRIVEN.  Some drivers have a
interrupts, however not all do.  So introduce a Kconfig option to let us
know what the driver actually supports.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-06-29 07:07:31 -04:00

51 lines
1.1 KiB
C

/*
* Copyright (c) 2016 Jean-Paul Etienne <fractalclone@gmail.com>
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <kernel.h>
#include <arch/cpu.h>
#include <uart.h>
#include <sys_io.h>
#define DEV_CFG(dev) \
((const struct uart_device_config * const) \
(dev)->config->config_info)
static unsigned char uart_riscv_qemu_poll_out(struct device *dev,
unsigned char c)
{
sys_write8(c, DEV_CFG(dev)->regs);
return c;
}
static int uart_riscv_qemu_poll_in(struct device *dev, unsigned char *c)
{
*c = sys_read8(DEV_CFG(dev)->regs);
return 0;
}
static int uart_riscv_qemu_init(struct device *dev)
{
/* Nothing to do */
return 0;
}
static const struct uart_driver_api uart_riscv_qemu_driver_api = {
.poll_in = uart_riscv_qemu_poll_in,
.poll_out = uart_riscv_qemu_poll_out,
.err_check = NULL,
};
static const struct uart_device_config uart_riscv_qemu_dev_cfg_0 = {
.regs = RISCV_QEMU_UART_BASE,
};
DEVICE_AND_API_INIT(uart_riscv_qemu_0, "uart0",
uart_riscv_qemu_init, NULL,
&uart_riscv_qemu_dev_cfg_0,
PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
(void *)&uart_riscv_qemu_driver_api);