drivers: serial: add support for esp32c3
into esp32_serial unified driver Signed-off-by: Felipe Neves <felipe.neves@espressif.com>
This commit is contained in:
parent
84dc576670
commit
4c069b9894
|
@ -8,7 +8,6 @@ CONFIG_SYS_CLOCK_TICKS_PER_SEC=1000
|
|||
CONFIG_CONSOLE=y
|
||||
CONFIG_SERIAL=y
|
||||
CONFIG_UART_CONSOLE=y
|
||||
CONFIG_UART_ROM_ESP32C3=y
|
||||
CONFIG_XIP=n
|
||||
CONFIG_PINMUX=y
|
||||
CONFIG_PINMUX_ESP32=y
|
||||
|
|
|
@ -9,6 +9,6 @@ config UART_ESP32
|
|||
select SERIAL_HAS_DRIVER
|
||||
select SERIAL_SUPPORT_INTERRUPT
|
||||
select GPIO_ESP32
|
||||
depends on SOC_ESP32 || SOC_ESP32S2
|
||||
depends on SOC_ESP32 || SOC_ESP32S2 || SOC_ESP32C3
|
||||
help
|
||||
Enable the ESP32 UART using ROM routines.
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
# Copyright (c) 2021 Espressif Systems (Shanghai) Co., Ltd.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
DT_COMPAT_ESP32_UART := espressif,esp32-uart
|
||||
DT_COMPAT_ESP32_UART_ROM := espressif,esp32c3-uart
|
||||
|
||||
config UART_ROM_ESP32C3
|
||||
bool "ESP32C3 ROM UART driver"
|
||||
default y
|
||||
default ($(dt_compat_enabled,$(DT_COMPAT_ESP32_UART_ROM))\
|
||||
&& !$(dt_compat_enabled,$(DT_COMPAT_ESP32_UART)))
|
||||
select SERIAL_HAS_DRIVER
|
||||
depends on SOC_ESP32C3
|
||||
help
|
||||
|
|
|
@ -14,25 +14,39 @@
|
|||
#elif defined(CONFIG_SOC_ESP32S2)
|
||||
#include <esp32s2/rom/ets_sys.h>
|
||||
#include <esp32s2/rom/gpio.h>
|
||||
#elif defined(CONFIG_SOC_ESP32C3)
|
||||
#include <esp32c3/rom/ets_sys.h>
|
||||
#include <esp32c3/rom/gpio.h>
|
||||
#endif
|
||||
#include <soc/uart_struct.h>
|
||||
#include <soc/dport_reg.h>
|
||||
#include <soc/dport_access.h>
|
||||
#include "stubs.h"
|
||||
#include <hal/uart_ll.h>
|
||||
|
||||
|
||||
#include <soc/gpio_sig_map.h>
|
||||
#include <soc/uart_reg.h>
|
||||
|
||||
#include <device.h>
|
||||
#include <soc.h>
|
||||
#include <drivers/uart.h>
|
||||
|
||||
#ifndef CONFIG_SOC_ESP32C3
|
||||
#include <drivers/interrupt_controller/intc_esp32.h>
|
||||
#else
|
||||
#include <drivers/interrupt_controller/intc_esp32c3.h>
|
||||
#endif
|
||||
#include <drivers/clock_control.h>
|
||||
#include <errno.h>
|
||||
#include <sys/util.h>
|
||||
#include <esp_attr.h>
|
||||
|
||||
#ifdef CONFIG_SOC_ESP32C3
|
||||
#define ISR_HANDLER isr_handler_t
|
||||
#else
|
||||
#define ISR_HANDLER intr_handler_t
|
||||
#endif
|
||||
|
||||
|
||||
struct uart_esp32_config {
|
||||
|
||||
struct uart_device_config dev_conf;
|
||||
|
@ -179,7 +193,12 @@ static int uart_esp32_configure_pins(const struct device *dev)
|
|||
static int uart_esp32_configure(const struct device *dev,
|
||||
const struct uart_config *cfg)
|
||||
{
|
||||
|
||||
#ifndef CONFIG_SOC_ESP32C3
|
||||
/* this register does not exist for esp32c3 uart controller */
|
||||
DEV_BASE(dev)->conf0.tick_ref_always_on = 1;
|
||||
#endif
|
||||
|
||||
DEV_BASE(dev)->conf1.rxfifo_full_thrhd = UART_RX_FIFO_THRESH;
|
||||
DEV_BASE(dev)->conf1.txfifo_empty_thrhd = UART_TX_FIFO_THRESH;
|
||||
|
||||
|
@ -258,7 +277,11 @@ static int uart_esp32_init(const struct device *dev)
|
|||
|
||||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||
DEV_DATA(dev)->irq_line =
|
||||
esp_intr_alloc(DEV_CFG(dev)->irq_source, 0, uart_esp32_isr, (void *)dev, NULL);
|
||||
esp_intr_alloc(DEV_CFG(dev)->irq_source,
|
||||
0,
|
||||
(ISR_HANDLER)uart_esp32_isr,
|
||||
(void *)dev,
|
||||
NULL);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -100,10 +100,27 @@
|
|||
};
|
||||
|
||||
uart0: uart@60000000 {
|
||||
compatible = "espressif,esp32c3-uart";
|
||||
compatible = "espressif,esp32-uart";
|
||||
reg = <0x60000000 0x400>;
|
||||
label = "UART_0";
|
||||
interrupts = <UART0_INTR_SOURCE>;
|
||||
interrupt-parent = <&intc>;
|
||||
clocks = <&rtc ESP32_UART0_MODULE>;
|
||||
current-speed = <115200>;
|
||||
status = "okay";
|
||||
tx-pin = <21>;
|
||||
rx-pin = <20>;
|
||||
};
|
||||
|
||||
uart1: uart@60010000 {
|
||||
compatible = "espressif,esp32-uart";
|
||||
reg = <0x60010000 0x400>;
|
||||
label = "UART_1";
|
||||
status = "disabled";
|
||||
interrupts = <UART1_INTR_SOURCE>;
|
||||
interrupt-parent = <&intc>;
|
||||
clocks = <&rtc ESP32_UART1_MODULE>;
|
||||
current-speed = <115200>;
|
||||
};
|
||||
|
||||
trng0: trng@3ff700b0 {
|
||||
|
|
|
@ -40,6 +40,9 @@ extern void esp_rom_uart_attach(void);
|
|||
extern void esp_rom_uart_tx_wait_idle(uint8_t uart_no);
|
||||
extern STATUS esp_rom_uart_tx_one_char(uint8_t chr);
|
||||
extern STATUS esp_rom_uart_rx_one_char(uint8_t *chr);
|
||||
extern int esp_rom_gpio_matrix_in(uint32_t gpio, uint32_t signal_index, bool inverted);
|
||||
extern int esp_rom_gpio_matrix_out(uint32_t gpio, uint32_t signal_index,
|
||||
bool out_invrted, bool out_enabled_inverted);
|
||||
extern void esp_rom_ets_set_user_start(uint32_t start);
|
||||
extern void esprv_intc_int_set_threshold(int priority_threshold);
|
||||
uint32_t soc_intr_get_next_source(void);
|
||||
|
|
Loading…
Reference in a new issue