mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-10 04:43:33 +00:00
feat(driver_spi): spi master support sleep retention(recovery)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -13,29 +13,6 @@
|
||||
const spi_signal_conn_t spi_periph_signal[SOC_SPI_PERIPH_NUM] = {
|
||||
{
|
||||
// MSPI on P4 has dedicated iomux pins
|
||||
.spiclk_out = -1,
|
||||
.spiclk_in = -1,
|
||||
.spid_out = -1,
|
||||
.spiq_out = -1,
|
||||
.spiwp_out = -1,
|
||||
.spihd_out = -1,
|
||||
.spid_in = -1,
|
||||
.spiq_in = -1,
|
||||
.spiwp_in = -1,
|
||||
.spihd_in = -1,
|
||||
.spics_out = {-1},
|
||||
.spics_in = -1,
|
||||
.spiclk_iomux_pin = -1,
|
||||
.spid_iomux_pin = -1,
|
||||
.spiq_iomux_pin = -1,
|
||||
.spiwp_iomux_pin = -1,
|
||||
.spihd_iomux_pin = -1,
|
||||
.spics0_iomux_pin = -1,
|
||||
.irq = -1,
|
||||
.irq_dma = -1,
|
||||
.module = -1,
|
||||
.hw = NULL,
|
||||
.func = -1,
|
||||
}, {
|
||||
.spiclk_out = SPI2_CK_PAD_OUT_IDX,
|
||||
.spiclk_in = SPI2_CK_PAD_IN_IDX,
|
||||
@@ -65,7 +42,6 @@ const spi_signal_conn_t spi_periph_signal[SOC_SPI_PERIPH_NUM] = {
|
||||
.spics0_iomux_pin = SPI2_IOMUX_PIN_NUM_CS,
|
||||
.irq = ETS_SPI2_INTR_SOURCE,
|
||||
.irq_dma = -1,
|
||||
.module = PERIPH_GPSPI2_MODULE,
|
||||
.hw = &GPSPI2,
|
||||
.func = SPI2_FUNC_NUM,
|
||||
}, {
|
||||
@@ -90,8 +66,56 @@ const spi_signal_conn_t spi_periph_signal[SOC_SPI_PERIPH_NUM] = {
|
||||
.spics0_iomux_pin = -1,
|
||||
.irq = ETS_SPI3_INTR_SOURCE,
|
||||
.irq_dma = -1,
|
||||
.module = PERIPH_GPSPI3_MODULE,
|
||||
.hw = &GPSPI3,
|
||||
.func = -1,
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Backup registers in Light sleep: (total cnt 12)
|
||||
*
|
||||
* cmd
|
||||
* addr
|
||||
* ctrl
|
||||
* clock
|
||||
* user
|
||||
* user1
|
||||
* user2
|
||||
* ms_dlen
|
||||
* misc
|
||||
* dma_conf
|
||||
* dma_int_ena
|
||||
* slave
|
||||
*/
|
||||
#define SPI_RETENTION_REGS_CNT 12
|
||||
static const uint32_t spi_regs_map[4] = {0x31ff, 0x1000000, 0x0, 0x0};
|
||||
#define SPI_REG_RETENTION_ENTRIES(num) { \
|
||||
[0] = { .config = REGDMA_LINK_ADDR_MAP_INIT(REGDMA_GPSPI_LINK(0), \
|
||||
REG_SPI_BASE(num), REG_SPI_BASE(num), \
|
||||
SPI_RETENTION_REGS_CNT, 0, 0, \
|
||||
spi_regs_map[0], spi_regs_map[1], \
|
||||
spi_regs_map[2], spi_regs_map[3]), \
|
||||
.owner = ENTRY(0) }, \
|
||||
/* Additional interrupt setting is required by idf SPI drivers after register recovered */ \
|
||||
[1] = { .config = REGDMA_LINK_WRITE_INIT(REGDMA_GPSPI_LINK(1), \
|
||||
SPI_DMA_INT_SET_REG(num), \
|
||||
SPI_TRANS_DONE_INT_SET | SPI_DMA_SEG_TRANS_DONE_INT_SET , \
|
||||
UINT32_MAX, 1, 0), \
|
||||
.owner = ENTRY(0) }, \
|
||||
}
|
||||
|
||||
static const regdma_entries_config_t spi2_regs_retention[] = SPI_REG_RETENTION_ENTRIES(2); // '2' for GPSPI2
|
||||
static const regdma_entries_config_t spi3_regs_retention[] = SPI_REG_RETENTION_ENTRIES(3);
|
||||
|
||||
const spi_reg_retention_info_t spi_reg_retention_info[SOC_SPI_PERIPH_NUM - 1] = { // '-1' to except mspi
|
||||
{
|
||||
.module_id = SLEEP_RETENTION_MODULE_GPSPI2,
|
||||
.entry_array = spi2_regs_retention,
|
||||
.array_size = ARRAY_SIZE(spi2_regs_retention),
|
||||
},
|
||||
{
|
||||
.module_id = SLEEP_RETENTION_MODULE_GPSPI3,
|
||||
.entry_array = spi3_regs_retention,
|
||||
.array_size = ARRAY_SIZE(spi3_regs_retention),
|
||||
},
|
||||
};
|
||||
|
Reference in New Issue
Block a user