xtensa/esp32: Reorganize the pins initialization and adds showprogress in __start
This commit is contained in:
parent
afd6b26232
commit
cce42d5f74
@ -362,7 +362,7 @@ static uart_dev_t g_uart2port =
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Functions
|
* Private Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
#ifndef CONFIG_SUPPRESS_UART_CONFIG
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: esp32_reset_rx_fifo
|
* Name: esp32_reset_rx_fifo
|
||||||
*
|
*
|
||||||
@ -388,7 +388,7 @@ static void esp32_reset_rx_fifo(struct esp32_dev_s *priv)
|
|||||||
{
|
{
|
||||||
getreg32(DR_UART_FIFO_REG(priv->config->id));
|
getreg32(DR_UART_FIFO_REG(priv->config->id));
|
||||||
|
|
||||||
rx_status_reg = getreg32(UART_STATUS_REG(priv->config->id));
|
rx_status_reg = getreg32(UART_STATUS_REG(priv->config->id));
|
||||||
fifo_cnt = REG_MASK(rx_status_reg, UART_RXFIFO_CNT);
|
fifo_cnt = REG_MASK(rx_status_reg, UART_RXFIFO_CNT);
|
||||||
mem_rx_status_reg = getreg32(UART_MEM_RX_STATUS_REG(priv->config->id));
|
mem_rx_status_reg = getreg32(UART_MEM_RX_STATUS_REG(priv->config->id));
|
||||||
rd_address = REG_MASK(mem_rx_status_reg, UART_RD_ADDRESS);
|
rd_address = REG_MASK(mem_rx_status_reg, UART_RD_ADDRESS);
|
||||||
@ -412,6 +412,7 @@ static void esp32_reset_tx_fifo(struct esp32_dev_s *priv)
|
|||||||
modifyreg32(UART_CONF0_REG(priv->config->id), 0, UART_TXFIFO_RST_M);
|
modifyreg32(UART_CONF0_REG(priv->config->id), 0, UART_TXFIFO_RST_M);
|
||||||
modifyreg32(UART_CONF0_REG(priv->config->id), UART_TXFIFO_RST_M, 0);
|
modifyreg32(UART_CONF0_REG(priv->config->id), UART_TXFIFO_RST_M, 0);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: esp32_get_rx_fifo_len
|
* Name: esp32_get_rx_fifo_len
|
||||||
@ -594,26 +595,6 @@ static int esp32_setup(struct uart_dev_s *dev)
|
|||||||
regval |= (clkdiv & 15) << UART_CLKDIV_FRAG_S;
|
regval |= (clkdiv & 15) << UART_CLKDIV_FRAG_S;
|
||||||
putreg32(regval, UART_CLKDIV_REG(priv->config->id));
|
putreg32(regval, UART_CLKDIV_REG(priv->config->id));
|
||||||
|
|
||||||
/* Configure UART pins
|
|
||||||
*
|
|
||||||
* Internal signals can be output to multiple GPIO pads.
|
|
||||||
* But only one GPIO pad can connect with input signal
|
|
||||||
*/
|
|
||||||
|
|
||||||
esp32_configgpio(priv->config->txpin, OUTPUT_FUNCTION_3);
|
|
||||||
esp32_gpio_matrix_out(priv->config->txpin, priv->config->txsig, 0, 0);
|
|
||||||
|
|
||||||
esp32_configgpio(priv->config->rxpin, INPUT_FUNCTION_3);
|
|
||||||
esp32_gpio_matrix_in(priv->config->rxpin, priv->config->rxsig, 0);
|
|
||||||
|
|
||||||
#if defined(CONFIG_SERIAL_IFLOWCONTROL) || defined(CONFIG_SERIAL_OFLOWCONTROL)
|
|
||||||
esp32_configgpio(priv->config->rtspin, OUTPUT_FUNCTION_3);
|
|
||||||
esp32_gpio_matrix_out(priv->config->rtspin, priv->config->rtssig, 0, 0);
|
|
||||||
|
|
||||||
esp32_configgpio(priv->config->ctspin, INPUT_FUNCTION_3);
|
|
||||||
esp32_gpio_matrix_in(priv->config->ctspin, priv->config->ctssig, 0);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Enable RX and error interrupts. Clear and pending interrtupt */
|
/* Enable RX and error interrupts. Clear and pending interrtupt */
|
||||||
|
|
||||||
regval = UART_RXFIFO_FULL_INT_ENA | UART_FRM_ERR_INT_ENA |
|
regval = UART_RXFIFO_FULL_INT_ENA | UART_FRM_ERR_INT_ENA |
|
||||||
@ -670,25 +651,6 @@ static void esp32_shutdown(struct uart_dev_s *dev)
|
|||||||
|
|
||||||
esp32_disableallints(priv, NULL);
|
esp32_disableallints(priv, NULL);
|
||||||
|
|
||||||
/* Revert pins to inputs and detach UART signals */
|
|
||||||
|
|
||||||
esp32_configgpio(priv->config->txpin, INPUT);
|
|
||||||
esp32_gpio_matrix_out(priv->config->txsig,
|
|
||||||
MATRIX_DETACH_OUT_SIG, true, false);
|
|
||||||
|
|
||||||
esp32_configgpio(priv->config->rxpin, INPUT);
|
|
||||||
esp32_gpio_matrix_in(priv->config->rxsig, MATRIX_DETACH_IN_LOW_PIN, false);
|
|
||||||
|
|
||||||
#if defined(CONFIG_SERIAL_IFLOWCONTROL) || defined(CONFIG_SERIAL_OFLOWCONTROL)
|
|
||||||
esp32_configgpio(priv->config->rtspin, INPUT);
|
|
||||||
esp32_gpio_matrix_out(priv->config->rtssig,
|
|
||||||
MATRIX_DETACH_OUT_SIG, true, false);
|
|
||||||
|
|
||||||
esp32_configgpio(priv->config->ctspin, INPUT);
|
|
||||||
esp32_gpio_matrix_in(priv->config->ctssig,
|
|
||||||
MATRIX_DETACH_IN_LOW_PIN, false);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Unconfigure and disable the UART */
|
/* Unconfigure and disable the UART */
|
||||||
|
|
||||||
putreg32(0, UART_CONF0_REG(priv->config->id));
|
putreg32(0, UART_CONF0_REG(priv->config->id));
|
||||||
@ -1232,8 +1194,8 @@ static bool esp32_txready(struct uart_dev_s *dev)
|
|||||||
uint32_t txcnt;
|
uint32_t txcnt;
|
||||||
struct esp32_dev_s *priv = (struct esp32_dev_s *)dev->priv;
|
struct esp32_dev_s *priv = (struct esp32_dev_s *)dev->priv;
|
||||||
|
|
||||||
txcnt = (getreg32(UART_STATUS_REG(priv->config->id)) >> UART_TXFIFO_CNT_S) &
|
txcnt = (getreg32(UART_STATUS_REG(priv->config->id)) >> UART_TXFIFO_CNT_S)
|
||||||
UART_TXFIFO_CNT_V;
|
& UART_TXFIFO_CNT_V;
|
||||||
|
|
||||||
if (txcnt < (UART_TX_FIFO_SIZE -1))
|
if (txcnt < (UART_TX_FIFO_SIZE -1))
|
||||||
{
|
{
|
||||||
@ -1261,6 +1223,41 @@ static bool esp32_txempty(struct uart_dev_s *dev)
|
|||||||
& UART_TXFIFO_CNT_M) == 0);
|
& UART_TXFIFO_CNT_M) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef CONFIG_SUPPRESS_UART_CONFIG
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: esp32_config_pins
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Performs the pin configuration.
|
||||||
|
*
|
||||||
|
* Parameters:
|
||||||
|
* priv - Pointer to the serial driver struct.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
static void esp32_config_pins(struct esp32_dev_s *priv)
|
||||||
|
{
|
||||||
|
/* Configure UART pins
|
||||||
|
*
|
||||||
|
* Internal signals can be output to multiple GPIO pads.
|
||||||
|
* But only one GPIO pad can connect with input signal
|
||||||
|
*/
|
||||||
|
|
||||||
|
esp32_configgpio(priv->config->txpin, OUTPUT_FUNCTION_3);
|
||||||
|
esp32_gpio_matrix_out(priv->config->txpin, priv->config->txsig, 0, 0);
|
||||||
|
|
||||||
|
esp32_configgpio(priv->config->rxpin, INPUT_FUNCTION_3);
|
||||||
|
esp32_gpio_matrix_in(priv->config->rxpin, priv->config->rxsig, 0);
|
||||||
|
|
||||||
|
#if defined(CONFIG_SERIAL_IFLOWCONTROL) || defined(CONFIG_SERIAL_OFLOWCONTROL)
|
||||||
|
esp32_configgpio(priv->config->rtspin, OUTPUT_FUNCTION_3);
|
||||||
|
esp32_gpio_matrix_out(priv->config->rtspin, priv->config->rtssig, 0, 0);
|
||||||
|
|
||||||
|
esp32_configgpio(priv->config->ctspin, INPUT_FUNCTION_3);
|
||||||
|
esp32_gpio_matrix_in(priv->config->ctspin, priv->config->ctssig, 0);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -1269,17 +1266,23 @@ static bool esp32_txempty(struct uart_dev_s *dev)
|
|||||||
* Name: esp32_lowsetup
|
* Name: esp32_lowsetup
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Performs the low level UART initialization early in debug so that the
|
* Performs the pin configuration for all UARTs.
|
||||||
* serial console will be available during bootup. This must be called
|
* This functions is intended to be called in the __start function.
|
||||||
* before up_serialinit.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void esp32_lowsetup(void)
|
void esp32_lowsetup(void)
|
||||||
{
|
{
|
||||||
|
esp32_config_pins(TTYS0_DEV.priv);
|
||||||
|
#ifdef TTYS1_DEV
|
||||||
|
esp32_config_pins(TTYS1_DEV.priv);
|
||||||
|
#endif
|
||||||
|
#ifdef TTYS2_DEV
|
||||||
|
esp32_config_pins(TTYS2_DEV.priv);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif /* CONFIG_SUPPRESS_UART_CONFIG */
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: xtensa_early_serial_initialize
|
* Name: xtensa_early_serial_initialize
|
||||||
*
|
*
|
||||||
|
@ -40,6 +40,16 @@
|
|||||||
#include "esp32_start.h"
|
#include "esp32_start.h"
|
||||||
#include "esp32_spiram.h"
|
#include "esp32_spiram.h"
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Pre-processor Definitions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_DEBUG_FEATURES
|
||||||
|
# define showprogress(c) up_puts(c)
|
||||||
|
#else
|
||||||
|
# define showprogress(c)
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Data
|
* Public Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -53,6 +63,10 @@ uint32_t g_idlestack[IDLETHREAD_STACKWORDS]
|
|||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef CONFIG_SUPPRESS_UART_CONFIG
|
||||||
|
extern void esp32_lowsetup(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: __start
|
* Name: __start
|
||||||
*
|
*
|
||||||
@ -136,12 +150,20 @@ void IRAM_ATTR __start(void)
|
|||||||
|
|
||||||
esp32_clockconfig();
|
esp32_clockconfig();
|
||||||
|
|
||||||
|
#ifndef CONFIG_SUPPRESS_UART_CONFIG
|
||||||
|
/* Configure the UART so we can get debug output */
|
||||||
|
|
||||||
|
esp32_lowsetup();
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef USE_EARLYSERIALINIT
|
#ifdef USE_EARLYSERIALINIT
|
||||||
/* Perform early serial initialization */
|
/* Perform early serial initialization */
|
||||||
|
|
||||||
xtensa_early_serial_initialize();
|
xtensa_early_serial_initialize();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
showprogress("A");
|
||||||
|
|
||||||
#if defined(CONFIG_ESP32_SPIRAM_BOOT_INIT)
|
#if defined(CONFIG_ESP32_SPIRAM_BOOT_INIT)
|
||||||
esp_spiram_init_cache();
|
esp_spiram_init_cache();
|
||||||
if (esp_spiram_init() != OK)
|
if (esp_spiram_init() != OK)
|
||||||
@ -166,6 +188,8 @@ void IRAM_ATTR __start(void)
|
|||||||
|
|
||||||
esp32_board_initialize();
|
esp32_board_initialize();
|
||||||
|
|
||||||
|
showprogress("B");
|
||||||
|
|
||||||
/* Bring up NuttX */
|
/* Bring up NuttX */
|
||||||
|
|
||||||
nx_start();
|
nx_start();
|
||||||
|
Loading…
Reference in New Issue
Block a user