mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 11:10:54 +03:00
feat(uart): support uart module sleep retention on c6/h2
This commit is contained in:
@@ -18,7 +18,6 @@
|
||||
#include "esp_private/sleep_retention.h"
|
||||
#include "esp_regdma.h"
|
||||
|
||||
#include "soc/uart_reg.h"
|
||||
#include "soc/systimer_reg.h"
|
||||
#include "soc/timer_group_reg.h"
|
||||
#include "soc/spi_mem_reg.h"
|
||||
@@ -84,22 +83,21 @@ static __attribute__((unused)) esp_err_t sleep_sys_periph_tee_apm_retention_init
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static __attribute__((unused)) esp_err_t sleep_sys_periph_uart0_retention_init(void *arg)
|
||||
#if CONFIG_ESP_CONSOLE_UART
|
||||
#include "sleep_uart_retention_context.inc"
|
||||
|
||||
const uart_reg_retention_info_t uart_regs_retention[SOC_UART_HP_NUM] = UART_REGS_RETENTION_INFO;
|
||||
|
||||
static __attribute__((unused)) esp_err_t sleep_sys_periph_stdout_console_uart_retention_init(void *arg)
|
||||
{
|
||||
#define N_REGS_UART() (((UART_ID_REG(0) - UART_INT_RAW_REG(0)) / 4) + 1)
|
||||
|
||||
const static sleep_retention_entries_config_t uart_regs_retention[] = {
|
||||
[0] = { .config = REGDMA_LINK_CONTINUOUS_INIT(REGDMA_UART_LINK(0x00), UART_INT_RAW_REG(0), UART_INT_RAW_REG(0), N_REGS_UART(), 0, 0), .owner = ENTRY(0) | ENTRY(2) }, /* uart */
|
||||
/* Note: uart register should set update reg to make the configuration take effect */
|
||||
[1] = { .config = REGDMA_LINK_WRITE_INIT (REGDMA_UART_LINK(0x01), UART_REG_UPDATE_REG(0), UART_REG_UPDATE, UART_REG_UPDATE_M, 1, 0), .owner = ENTRY(0) | ENTRY(2) },
|
||||
[2] = { .config = REGDMA_LINK_WAIT_INIT (REGDMA_UART_LINK(0x02), UART_REG_UPDATE_REG(0), 0x0, UART_REG_UPDATE_M, 1, 0), .owner = ENTRY(0) | ENTRY(2) }
|
||||
};
|
||||
|
||||
esp_err_t err = sleep_retention_entries_create(uart_regs_retention, ARRAY_SIZE(uart_regs_retention), REGDMA_LINK_PRI_5, SLEEP_RETENTION_MODULE_SYS_PERIPH);
|
||||
esp_err_t err = sleep_retention_entries_create(uart_regs_retention[CONFIG_ESP_CONSOLE_UART_NUM].regdma_entry_array,
|
||||
uart_regs_retention[CONFIG_ESP_CONSOLE_UART_NUM].array_size,
|
||||
REGDMA_LINK_PRI_5, SLEEP_RETENTION_MODULE_SYS_PERIPH);
|
||||
ESP_RETURN_ON_ERROR(err, TAG, "failed to allocate memory for digital peripherals (%s) retention", "UART");
|
||||
ESP_LOGD(TAG, "UART sleep retention initialization");
|
||||
ESP_LOGD(TAG, "stdout console UART sleep retention initialization");
|
||||
return ESP_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
static __attribute__((unused)) esp_err_t sleep_sys_periph_tg0_retention_init(void *arg)
|
||||
{
|
||||
@@ -229,8 +227,10 @@ static __attribute__((unused)) esp_err_t sleep_sys_periph_retention_init(void *a
|
||||
if(err) goto error;
|
||||
err = sleep_sys_periph_tee_apm_retention_init(arg);
|
||||
if(err) goto error;
|
||||
err = sleep_sys_periph_uart0_retention_init(arg);
|
||||
#if CONFIG_ESP_CONSOLE_UART
|
||||
err = sleep_sys_periph_stdout_console_uart_retention_init(arg);
|
||||
if(err) goto error;
|
||||
#endif
|
||||
err = sleep_sys_periph_tg0_retention_init(arg);
|
||||
if(err) goto error;
|
||||
err = sleep_sys_periph_iomux_retention_init(arg);
|
||||
@@ -248,9 +248,7 @@ bool peripheral_domain_pd_allowed(void)
|
||||
#if CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP
|
||||
const uint32_t inited_modules = sleep_retention_get_inited_modules();
|
||||
const uint32_t created_modules = sleep_retention_get_created_modules();
|
||||
const uint32_t mask = (const uint32_t) (BIT(SLEEP_RETENTION_MODULE_SYS_PERIPH));
|
||||
|
||||
return ((inited_modules & mask) == (created_modules & mask));
|
||||
return (((inited_modules ^ created_modules) & TOP_DOMAIN_PERIPHERALS_BM) == 0);
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user