drivers: esp32: Add minimal UART driver based on ROM routines
This is a minimal driver enabling console output during the port bringup. While the driver works, only one of the three UART devices are supported, and there isn't any way to change any parameters or use interrupts. This will most likely be superceded by a proper driver after the port has matured. Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
This commit is contained in:
parent
c13174935b
commit
37ea77173c
7 changed files with 82 additions and 1 deletions
|
@ -24,6 +24,9 @@
|
|||
|
||||
PROVIDE ( __stack = 0x3ffe3f20 );
|
||||
|
||||
PROVIDE ( uart_tx_one_char = 0x40009200 );
|
||||
PROVIDE ( uart_rx_one_char = 0x400092d0 );
|
||||
|
||||
MEMORY
|
||||
{
|
||||
iram0_0_seg(RX): org = 0x40080000, len = 0x20000
|
||||
|
|
|
@ -6,4 +6,3 @@
|
|||
config BOARD_ESP32
|
||||
bool "ESP32 Development Board"
|
||||
depends on XTENSA
|
||||
|
||||
|
|
|
@ -8,3 +8,10 @@ CONFIG_SOC_ESP32=y
|
|||
CONFIG_MAIN_STACK_SIZE=2048
|
||||
|
||||
CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=160000000
|
||||
|
||||
CONFIG_CONSOLE=y
|
||||
CONFIG_SERIAL_HAS_DRIVER=y
|
||||
CONFIG_SERIAL=y
|
||||
CONFIG_UART_CONSOLE_ON_DEV_NAME="ROMUART"
|
||||
CONFIG_UART_CONSOLE=y
|
||||
CONFIG_UART_ESP32=y
|
||||
|
|
|
@ -89,4 +89,6 @@ source "drivers/serial/Kconfig.riscv_qemu"
|
|||
|
||||
source "drivers/serial/Kconfig.fe310"
|
||||
|
||||
source "drivers/serial/Kconfig.esp32"
|
||||
|
||||
endif
|
||||
|
|
7
drivers/serial/Kconfig.esp32
Normal file
7
drivers/serial/Kconfig.esp32
Normal file
|
@ -0,0 +1,7 @@
|
|||
menuconfig UART_ESP32
|
||||
bool "ESP32 UART driver"
|
||||
default n
|
||||
select SERIAL_HAS_DRIVER
|
||||
help
|
||||
Enable the ESP32 UART using ROM routines.
|
||||
|
|
@ -18,3 +18,4 @@ obj-$(CONFIG_UART_CC32XX) += uart_cc32xx.o
|
|||
obj-$(CONFIG_UART_CMSDK_APB) += uart_cmsdk_apb.o
|
||||
obj-$(CONFIG_UART_RISCV_QEMU) += uart_riscv_qemu.o
|
||||
obj-$(CONFIG_UART_FE310) += uart_fe310.o
|
||||
obj-$(CONFIG_UART_ESP32) += uart_esp32.o
|
||||
|
|
62
drivers/serial/uart_esp32.c
Normal file
62
drivers/serial/uart_esp32.c
Normal file
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* Copyright (c) 2017 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <uart.h>
|
||||
#include <rom/uart.h>
|
||||
#include <rom/ets_sys.h>
|
||||
#include <errno.h>
|
||||
|
||||
static unsigned char esp32_uart_tx(struct device *dev,
|
||||
unsigned char c)
|
||||
{
|
||||
ARG_UNUSED(dev);
|
||||
|
||||
uart_tx_one_char(c);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int esp32_uart_rx(struct device *dev, unsigned char *p_char)
|
||||
{
|
||||
ARG_UNUSED(dev);
|
||||
|
||||
switch (uart_rx_one_char(p_char)) {
|
||||
case OK:
|
||||
return 0;
|
||||
case PENDING:
|
||||
return -EINPROGRESS;
|
||||
case BUSY:
|
||||
return -EBUSY;
|
||||
case CANCEL:
|
||||
return -ECANCELED;
|
||||
default:
|
||||
return -EIO;
|
||||
}
|
||||
}
|
||||
|
||||
static int esp32_uart_init(struct device *dev)
|
||||
{
|
||||
ARG_UNUSED(dev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static const struct uart_driver_api esp32_uart_api = {
|
||||
.poll_in = &esp32_uart_rx,
|
||||
.poll_out = &esp32_uart_tx,
|
||||
.err_check = NULL,
|
||||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||
|
||||
#error "Interrupt-driven ESP32 UART not implemented yet"
|
||||
|
||||
#endif
|
||||
};
|
||||
|
||||
DEVICE_AND_API_INIT(esp32_uart, "ROMUART",
|
||||
esp32_uart_init, NULL, NULL,
|
||||
PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
|
||||
&esp32_uart_api);
|
Loading…
Add table
Add a link
Reference in a new issue