mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 03:00:34 +03:00
feat(driver_spi): spi master support sleep retention(recovery)
This commit is contained in:
@@ -488,177 +488,7 @@ typedef volatile struct spi_dev_s {
|
||||
uint32_t dma_outlink_dscr_bf1; /*The content of current out descriptor data buffer pointer.*/
|
||||
uint32_t dma_rx_status; /*spi dma read data from memory status.*/
|
||||
uint32_t dma_tx_status; /*spi dma write data to memory status.*/
|
||||
uint32_t reserved_150;
|
||||
uint32_t reserved_154;
|
||||
uint32_t reserved_158;
|
||||
uint32_t reserved_15c;
|
||||
uint32_t reserved_160;
|
||||
uint32_t reserved_164;
|
||||
uint32_t reserved_168;
|
||||
uint32_t reserved_16c;
|
||||
uint32_t reserved_170;
|
||||
uint32_t reserved_174;
|
||||
uint32_t reserved_178;
|
||||
uint32_t reserved_17c;
|
||||
uint32_t reserved_180;
|
||||
uint32_t reserved_184;
|
||||
uint32_t reserved_188;
|
||||
uint32_t reserved_18c;
|
||||
uint32_t reserved_190;
|
||||
uint32_t reserved_194;
|
||||
uint32_t reserved_198;
|
||||
uint32_t reserved_19c;
|
||||
uint32_t reserved_1a0;
|
||||
uint32_t reserved_1a4;
|
||||
uint32_t reserved_1a8;
|
||||
uint32_t reserved_1ac;
|
||||
uint32_t reserved_1b0;
|
||||
uint32_t reserved_1b4;
|
||||
uint32_t reserved_1b8;
|
||||
uint32_t reserved_1bc;
|
||||
uint32_t reserved_1c0;
|
||||
uint32_t reserved_1c4;
|
||||
uint32_t reserved_1c8;
|
||||
uint32_t reserved_1cc;
|
||||
uint32_t reserved_1d0;
|
||||
uint32_t reserved_1d4;
|
||||
uint32_t reserved_1d8;
|
||||
uint32_t reserved_1dc;
|
||||
uint32_t reserved_1e0;
|
||||
uint32_t reserved_1e4;
|
||||
uint32_t reserved_1e8;
|
||||
uint32_t reserved_1ec;
|
||||
uint32_t reserved_1f0;
|
||||
uint32_t reserved_1f4;
|
||||
uint32_t reserved_1f8;
|
||||
uint32_t reserved_1fc;
|
||||
uint32_t reserved_200;
|
||||
uint32_t reserved_204;
|
||||
uint32_t reserved_208;
|
||||
uint32_t reserved_20c;
|
||||
uint32_t reserved_210;
|
||||
uint32_t reserved_214;
|
||||
uint32_t reserved_218;
|
||||
uint32_t reserved_21c;
|
||||
uint32_t reserved_220;
|
||||
uint32_t reserved_224;
|
||||
uint32_t reserved_228;
|
||||
uint32_t reserved_22c;
|
||||
uint32_t reserved_230;
|
||||
uint32_t reserved_234;
|
||||
uint32_t reserved_238;
|
||||
uint32_t reserved_23c;
|
||||
uint32_t reserved_240;
|
||||
uint32_t reserved_244;
|
||||
uint32_t reserved_248;
|
||||
uint32_t reserved_24c;
|
||||
uint32_t reserved_250;
|
||||
uint32_t reserved_254;
|
||||
uint32_t reserved_258;
|
||||
uint32_t reserved_25c;
|
||||
uint32_t reserved_260;
|
||||
uint32_t reserved_264;
|
||||
uint32_t reserved_268;
|
||||
uint32_t reserved_26c;
|
||||
uint32_t reserved_270;
|
||||
uint32_t reserved_274;
|
||||
uint32_t reserved_278;
|
||||
uint32_t reserved_27c;
|
||||
uint32_t reserved_280;
|
||||
uint32_t reserved_284;
|
||||
uint32_t reserved_288;
|
||||
uint32_t reserved_28c;
|
||||
uint32_t reserved_290;
|
||||
uint32_t reserved_294;
|
||||
uint32_t reserved_298;
|
||||
uint32_t reserved_29c;
|
||||
uint32_t reserved_2a0;
|
||||
uint32_t reserved_2a4;
|
||||
uint32_t reserved_2a8;
|
||||
uint32_t reserved_2ac;
|
||||
uint32_t reserved_2b0;
|
||||
uint32_t reserved_2b4;
|
||||
uint32_t reserved_2b8;
|
||||
uint32_t reserved_2bc;
|
||||
uint32_t reserved_2c0;
|
||||
uint32_t reserved_2c4;
|
||||
uint32_t reserved_2c8;
|
||||
uint32_t reserved_2cc;
|
||||
uint32_t reserved_2d0;
|
||||
uint32_t reserved_2d4;
|
||||
uint32_t reserved_2d8;
|
||||
uint32_t reserved_2dc;
|
||||
uint32_t reserved_2e0;
|
||||
uint32_t reserved_2e4;
|
||||
uint32_t reserved_2e8;
|
||||
uint32_t reserved_2ec;
|
||||
uint32_t reserved_2f0;
|
||||
uint32_t reserved_2f4;
|
||||
uint32_t reserved_2f8;
|
||||
uint32_t reserved_2fc;
|
||||
uint32_t reserved_300;
|
||||
uint32_t reserved_304;
|
||||
uint32_t reserved_308;
|
||||
uint32_t reserved_30c;
|
||||
uint32_t reserved_310;
|
||||
uint32_t reserved_314;
|
||||
uint32_t reserved_318;
|
||||
uint32_t reserved_31c;
|
||||
uint32_t reserved_320;
|
||||
uint32_t reserved_324;
|
||||
uint32_t reserved_328;
|
||||
uint32_t reserved_32c;
|
||||
uint32_t reserved_330;
|
||||
uint32_t reserved_334;
|
||||
uint32_t reserved_338;
|
||||
uint32_t reserved_33c;
|
||||
uint32_t reserved_340;
|
||||
uint32_t reserved_344;
|
||||
uint32_t reserved_348;
|
||||
uint32_t reserved_34c;
|
||||
uint32_t reserved_350;
|
||||
uint32_t reserved_354;
|
||||
uint32_t reserved_358;
|
||||
uint32_t reserved_35c;
|
||||
uint32_t reserved_360;
|
||||
uint32_t reserved_364;
|
||||
uint32_t reserved_368;
|
||||
uint32_t reserved_36c;
|
||||
uint32_t reserved_370;
|
||||
uint32_t reserved_374;
|
||||
uint32_t reserved_378;
|
||||
uint32_t reserved_37c;
|
||||
uint32_t reserved_380;
|
||||
uint32_t reserved_384;
|
||||
uint32_t reserved_388;
|
||||
uint32_t reserved_38c;
|
||||
uint32_t reserved_390;
|
||||
uint32_t reserved_394;
|
||||
uint32_t reserved_398;
|
||||
uint32_t reserved_39c;
|
||||
uint32_t reserved_3a0;
|
||||
uint32_t reserved_3a4;
|
||||
uint32_t reserved_3a8;
|
||||
uint32_t reserved_3ac;
|
||||
uint32_t reserved_3b0;
|
||||
uint32_t reserved_3b4;
|
||||
uint32_t reserved_3b8;
|
||||
uint32_t reserved_3bc;
|
||||
uint32_t reserved_3c0;
|
||||
uint32_t reserved_3c4;
|
||||
uint32_t reserved_3c8;
|
||||
uint32_t reserved_3cc;
|
||||
uint32_t reserved_3d0;
|
||||
uint32_t reserved_3d4;
|
||||
uint32_t reserved_3d8;
|
||||
uint32_t reserved_3dc;
|
||||
uint32_t reserved_3e0;
|
||||
uint32_t reserved_3e4;
|
||||
uint32_t reserved_3e8;
|
||||
uint32_t reserved_3ec;
|
||||
uint32_t reserved_3f0;
|
||||
uint32_t reserved_3f4;
|
||||
uint32_t reserved_3f8;
|
||||
uint32_t reserved_150[171];
|
||||
union {
|
||||
struct {
|
||||
uint32_t date: 28; /*SPI register version.*/
|
||||
@@ -667,6 +497,7 @@ typedef volatile struct spi_dev_s {
|
||||
uint32_t val;
|
||||
} date;
|
||||
} spi_dev_t;
|
||||
|
||||
extern spi_dev_t SPI0; /* SPI0 IS FOR INTERNAL USE*/
|
||||
extern spi_dev_t SPI1;
|
||||
extern spi_dev_t SPI2;
|
||||
|
||||
@@ -991,6 +991,10 @@ config SOC_SPI_SUPPORT_SLAVE_HD_VER2
|
||||
bool
|
||||
default y
|
||||
|
||||
config SOC_SPI_SUPPORT_SLEEP_RETENTION
|
||||
bool
|
||||
default y
|
||||
|
||||
config SOC_SPI_SUPPORT_CLK_XTAL
|
||||
bool
|
||||
default y
|
||||
|
||||
@@ -36,6 +36,7 @@ typedef enum periph_retention_module {
|
||||
SLEEP_RETENTION_MODULE_RMT0 = 13,
|
||||
SLEEP_RETENTION_MODULE_UART0 = 14,
|
||||
SLEEP_RETENTION_MODULE_UART1 = 15,
|
||||
SLEEP_RETENTION_MODULE_GPSPI2 = 16,
|
||||
|
||||
/* Modem module, which includes WiFi, BLE and 802.15.4 */
|
||||
SLEEP_RETENTION_MODULE_WIFI_MAC = 26,
|
||||
@@ -62,6 +63,7 @@ typedef enum periph_retention_module {
|
||||
: ((m) == SLEEP_RETENTION_MODULE_RMT0) ? true \
|
||||
: ((m) == SLEEP_RETENTION_MODULE_UART0) ? true \
|
||||
: ((m) == SLEEP_RETENTION_MODULE_UART1) ? true \
|
||||
: ((m) == SLEEP_RETENTION_MODULE_GPSPI2) ? true \
|
||||
: false)
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -395,6 +395,7 @@
|
||||
#define SOC_SPI_SUPPORT_CD_SIG 1
|
||||
#define SOC_SPI_SUPPORT_CONTINUOUS_TRANS 1
|
||||
#define SOC_SPI_SUPPORT_SLAVE_HD_VER2 1
|
||||
#define SOC_SPI_SUPPORT_SLEEP_RETENTION 1
|
||||
#define SOC_SPI_SUPPORT_CLK_XTAL 1
|
||||
#define SOC_SPI_SUPPORT_CLK_PLL_F80M 1
|
||||
#define SOC_SPI_SUPPORT_CLK_RC_FAST 1
|
||||
|
||||
@@ -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 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 = FSPICLK_OUT_IDX,
|
||||
.spiclk_in = FSPICLK_IN_IDX,
|
||||
@@ -62,3 +39,47 @@ const spi_signal_conn_t spi_periph_signal[SOC_SPI_PERIPH_NUM] = {
|
||||
.func = SPI2_FUNC_NUM,
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* 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) | ENTRY(2) }, \
|
||||
/* 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) | ENTRY(2) }, \
|
||||
}
|
||||
|
||||
static const regdma_entries_config_t spi2_regs_retention[] = SPI_REG_RETENTION_ENTRIES(2); // '2' for GPSPI2
|
||||
|
||||
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),
|
||||
},
|
||||
};
|
||||
|
||||
@@ -991,6 +991,10 @@ config SOC_SPI_SUPPORT_SLAVE_HD_VER2
|
||||
bool
|
||||
default y
|
||||
|
||||
config SOC_SPI_SUPPORT_SLEEP_RETENTION
|
||||
bool
|
||||
default y
|
||||
|
||||
config SOC_SPI_SUPPORT_CLK_XTAL
|
||||
bool
|
||||
default y
|
||||
|
||||
@@ -37,6 +37,7 @@ typedef enum periph_retention_module {
|
||||
SLEEP_RETENTION_MODULE_RMT0 = 14,
|
||||
SLEEP_RETENTION_MODULE_UART0 = 15,
|
||||
SLEEP_RETENTION_MODULE_UART1 = 16,
|
||||
SLEEP_RETENTION_MODULE_GPSPI2 = 17,
|
||||
|
||||
/* Modem module, which includes BLE and 802.15.4 */
|
||||
SLEEP_RETENTION_MODULE_BLE_MAC = 28,
|
||||
@@ -62,6 +63,7 @@ typedef enum periph_retention_module {
|
||||
: ((m) == SLEEP_RETENTION_MODULE_RMT0) ? true \
|
||||
: ((m) == SLEEP_RETENTION_MODULE_UART0) ? true \
|
||||
: ((m) == SLEEP_RETENTION_MODULE_UART1) ? true \
|
||||
: ((m) == SLEEP_RETENTION_MODULE_GPSPI2) ? true \
|
||||
: false)
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -409,6 +409,7 @@
|
||||
#define SOC_SPI_SUPPORT_CD_SIG 1
|
||||
#define SOC_SPI_SUPPORT_CONTINUOUS_TRANS 1
|
||||
#define SOC_SPI_SUPPORT_SLAVE_HD_VER2 1
|
||||
#define SOC_SPI_SUPPORT_SLEEP_RETENTION 1
|
||||
#define SOC_SPI_SUPPORT_CLK_XTAL 1
|
||||
#define SOC_SPI_SUPPORT_CLK_PLL_F48M 1
|
||||
#define SOC_SPI_SUPPORT_CLK_RC_FAST 1
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -14,7 +14,7 @@ extern "C" {
|
||||
/** SPI_CMD_REG register
|
||||
* Command control register
|
||||
*/
|
||||
#define SPI_CMD_REG (DR_REG_SPI_BASE + 0x0)
|
||||
#define SPI_CMD_REG(i) (REG_SPI_BASE(i) + 0x0)
|
||||
/** SPI_CONF_BITLEN : R/W; bitpos: [17:0]; default: 0;
|
||||
* Define the APB cycles of SPI_CONF state. Can be configured in CONF state.
|
||||
*/
|
||||
@@ -43,7 +43,7 @@ extern "C" {
|
||||
/** SPI_ADDR_REG register
|
||||
* Address value register
|
||||
*/
|
||||
#define SPI_ADDR_REG (DR_REG_SPI_BASE + 0x4)
|
||||
#define SPI_ADDR_REG(i) (REG_SPI_BASE(i) + 0x4)
|
||||
/** SPI_USR_ADDR_VALUE : R/W; bitpos: [31:0]; default: 0;
|
||||
* Address to slave. Can be configured in CONF state.
|
||||
*/
|
||||
@@ -55,7 +55,7 @@ extern "C" {
|
||||
/** SPI_CTRL_REG register
|
||||
* SPI control register
|
||||
*/
|
||||
#define SPI_CTRL_REG (DR_REG_SPI_BASE + 0x8)
|
||||
#define SPI_CTRL_REG(i) (REG_SPI_BASE(i) + 0x8)
|
||||
/** SPI_DUMMY_OUT : R/W; bitpos: [3]; default: 0;
|
||||
* 0: In the dummy phase, the FSPI bus signals are not output. 1: In the dummy phase,
|
||||
* the FSPI bus signals are output. Can be configured in CONF state.
|
||||
@@ -188,7 +188,7 @@ extern "C" {
|
||||
/** SPI_CLOCK_REG register
|
||||
* SPI clock control register
|
||||
*/
|
||||
#define SPI_CLOCK_REG (DR_REG_SPI_BASE + 0xc)
|
||||
#define SPI_CLOCK_REG(i) (REG_SPI_BASE(i) + 0xc)
|
||||
/** SPI_CLKCNT_L : R/W; bitpos: [5:0]; default: 3;
|
||||
* In the master mode it must be equal to spi_clkcnt_N. In the slave mode it must be
|
||||
* 0. Can be configured in CONF state.
|
||||
@@ -221,7 +221,7 @@ extern "C" {
|
||||
#define SPI_CLKDIV_PRE_V 0x0000000FU
|
||||
#define SPI_CLKDIV_PRE_S 18
|
||||
/** SPI_CLK_EQU_SYSCLK : R/W; bitpos: [31]; default: 1;
|
||||
* In the master mode 1: spi_clk is eqaul to system 0: spi_clk is divided from system
|
||||
* In the master mode 1: spi_clk is equal to system 0: spi_clk is divided from system
|
||||
* clock. Can be configured in CONF state.
|
||||
*/
|
||||
#define SPI_CLK_EQU_SYSCLK (BIT(31))
|
||||
@@ -232,7 +232,7 @@ extern "C" {
|
||||
/** SPI_USER_REG register
|
||||
* SPI USER control register
|
||||
*/
|
||||
#define SPI_USER_REG (DR_REG_SPI_BASE + 0x10)
|
||||
#define SPI_USER_REG(i) (REG_SPI_BASE(i) + 0x10)
|
||||
/** SPI_DOUTDIN : R/W; bitpos: [0]; default: 0;
|
||||
* Set the bit to enable full duplex communication. 1: enable 0: disable. Can be
|
||||
* configured in CONF state.
|
||||
@@ -403,7 +403,7 @@ extern "C" {
|
||||
/** SPI_USER1_REG register
|
||||
* SPI USER control register 1
|
||||
*/
|
||||
#define SPI_USER1_REG (DR_REG_SPI_BASE + 0x14)
|
||||
#define SPI_USER1_REG(i) (REG_SPI_BASE(i) + 0x14)
|
||||
/** SPI_USR_DUMMY_CYCLELEN : R/W; bitpos: [7:0]; default: 7;
|
||||
* The length in spi_clk cycles of dummy phase. The register value shall be
|
||||
* (cycle_num-1). Can be configured in CONF state.
|
||||
@@ -449,7 +449,7 @@ extern "C" {
|
||||
/** SPI_USER2_REG register
|
||||
* SPI USER control register 2
|
||||
*/
|
||||
#define SPI_USER2_REG (DR_REG_SPI_BASE + 0x18)
|
||||
#define SPI_USER2_REG(i) (REG_SPI_BASE(i) + 0x18)
|
||||
/** SPI_USR_COMMAND_VALUE : R/W; bitpos: [15:0]; default: 0;
|
||||
* The value of command. Can be configured in CONF state.
|
||||
*/
|
||||
@@ -478,7 +478,7 @@ extern "C" {
|
||||
/** SPI_MS_DLEN_REG register
|
||||
* SPI data bit length control register
|
||||
*/
|
||||
#define SPI_MS_DLEN_REG (DR_REG_SPI_BASE + 0x1c)
|
||||
#define SPI_MS_DLEN_REG(i) (REG_SPI_BASE(i) + 0x1c)
|
||||
/** SPI_MS_DATA_BITLEN : R/W; bitpos: [17:0]; default: 0;
|
||||
* The value of these bits is the configured SPI transmission data bit length in
|
||||
* master mode DMA controlled transfer or CPU controlled transfer. The value is also
|
||||
@@ -493,7 +493,7 @@ extern "C" {
|
||||
/** SPI_MISC_REG register
|
||||
* SPI misc register
|
||||
*/
|
||||
#define SPI_MISC_REG (DR_REG_SPI_BASE + 0x20)
|
||||
#define SPI_MISC_REG(i) (REG_SPI_BASE(i) + 0x20)
|
||||
/** SPI_CS0_DIS : R/W; bitpos: [0]; default: 0;
|
||||
* SPI CS$n pin enable, 1: disable CS$n, 0: spi_cs$n signal is from/to CS$n pin. Can
|
||||
* be configured in CONF state.
|
||||
@@ -634,7 +634,7 @@ extern "C" {
|
||||
/** SPI_DIN_MODE_REG register
|
||||
* SPI input delay mode configuration
|
||||
*/
|
||||
#define SPI_DIN_MODE_REG (DR_REG_SPI_BASE + 0x24)
|
||||
#define SPI_DIN_MODE_REG(i) (REG_SPI_BASE(i) + 0x24)
|
||||
/** SPI_DIN0_MODE : R/W; bitpos: [1:0]; default: 0;
|
||||
* the input signals are delayed by SPI module clock cycles, 0: input without delayed,
|
||||
* 1: input with the posedge of clk_apb,2 input with the negedge of clk_apb, 3: input
|
||||
@@ -725,7 +725,7 @@ extern "C" {
|
||||
/** SPI_DIN_NUM_REG register
|
||||
* SPI input delay number configuration
|
||||
*/
|
||||
#define SPI_DIN_NUM_REG (DR_REG_SPI_BASE + 0x28)
|
||||
#define SPI_DIN_NUM_REG(i) (REG_SPI_BASE(i) + 0x28)
|
||||
/** SPI_DIN0_NUM : R/W; bitpos: [1:0]; default: 0;
|
||||
* the input signals are delayed by SPI module clock cycles, 0: delayed by 1 cycle, 1:
|
||||
* delayed by 2 cycles,... Can be configured in CONF state.
|
||||
@@ -794,7 +794,7 @@ extern "C" {
|
||||
/** SPI_DOUT_MODE_REG register
|
||||
* SPI output delay mode configuration
|
||||
*/
|
||||
#define SPI_DOUT_MODE_REG (DR_REG_SPI_BASE + 0x2c)
|
||||
#define SPI_DOUT_MODE_REG(i) (REG_SPI_BASE(i) + 0x2c)
|
||||
/** SPI_DOUT0_MODE : R/W; bitpos: [0]; default: 0;
|
||||
* The output signal $n is delayed by the SPI module clock, 0: output without delayed,
|
||||
* 1: output delay for a SPI module clock cycle at its negative edge. Can be
|
||||
@@ -880,7 +880,7 @@ extern "C" {
|
||||
/** SPI_DMA_CONF_REG register
|
||||
* SPI DMA control register
|
||||
*/
|
||||
#define SPI_DMA_CONF_REG (DR_REG_SPI_BASE + 0x30)
|
||||
#define SPI_DMA_CONF_REG(i) (REG_SPI_BASE(i) + 0x30)
|
||||
/** SPI_DMA_OUTFIFO_EMPTY : RO; bitpos: [0]; default: 1;
|
||||
* Records the status of DMA TX FIFO. 1: DMA TX FIFO is not ready for sending data. 0:
|
||||
* DMA TX FIFO is ready for sending data.
|
||||
@@ -972,7 +972,7 @@ extern "C" {
|
||||
/** SPI_DMA_INT_ENA_REG register
|
||||
* SPI interrupt enable register
|
||||
*/
|
||||
#define SPI_DMA_INT_ENA_REG (DR_REG_SPI_BASE + 0x34)
|
||||
#define SPI_DMA_INT_ENA_REG(i) (REG_SPI_BASE(i) + 0x34)
|
||||
/** SPI_DMA_INFIFO_FULL_ERR_INT_ENA : R/W; bitpos: [0]; default: 0;
|
||||
* The enable bit for SPI_DMA_INFIFO_FULL_ERR_INT interrupt.
|
||||
*/
|
||||
@@ -1124,7 +1124,7 @@ extern "C" {
|
||||
/** SPI_DMA_INT_CLR_REG register
|
||||
* SPI interrupt clear register
|
||||
*/
|
||||
#define SPI_DMA_INT_CLR_REG (DR_REG_SPI_BASE + 0x38)
|
||||
#define SPI_DMA_INT_CLR_REG(i) (REG_SPI_BASE(i) + 0x38)
|
||||
/** SPI_DMA_INFIFO_FULL_ERR_INT_CLR : WT; bitpos: [0]; default: 0;
|
||||
* The clear bit for SPI_DMA_INFIFO_FULL_ERR_INT interrupt.
|
||||
*/
|
||||
@@ -1276,7 +1276,7 @@ extern "C" {
|
||||
/** SPI_DMA_INT_RAW_REG register
|
||||
* SPI interrupt raw register
|
||||
*/
|
||||
#define SPI_DMA_INT_RAW_REG (DR_REG_SPI_BASE + 0x3c)
|
||||
#define SPI_DMA_INT_RAW_REG(i) (REG_SPI_BASE(i) + 0x3c)
|
||||
/** SPI_DMA_INFIFO_FULL_ERR_INT_RAW : R/WTC/SS; bitpos: [0]; default: 0;
|
||||
* 1: The current data rate of DMA Rx is smaller than that of SPI, which will lose the
|
||||
* receive data. 0: Others.
|
||||
@@ -1450,7 +1450,7 @@ extern "C" {
|
||||
/** SPI_DMA_INT_ST_REG register
|
||||
* SPI interrupt status register
|
||||
*/
|
||||
#define SPI_DMA_INT_ST_REG (DR_REG_SPI_BASE + 0x40)
|
||||
#define SPI_DMA_INT_ST_REG(i) (REG_SPI_BASE(i) + 0x40)
|
||||
/** SPI_DMA_INFIFO_FULL_ERR_INT_ST : RO; bitpos: [0]; default: 0;
|
||||
* The status bit for SPI_DMA_INFIFO_FULL_ERR_INT interrupt.
|
||||
*/
|
||||
@@ -1602,7 +1602,7 @@ extern "C" {
|
||||
/** SPI_DMA_INT_SET_REG register
|
||||
* SPI interrupt software set register
|
||||
*/
|
||||
#define SPI_DMA_INT_SET_REG (DR_REG_SPI_BASE + 0x44)
|
||||
#define SPI_DMA_INT_SET_REG(i) (REG_SPI_BASE(i) + 0x44)
|
||||
/** SPI_DMA_INFIFO_FULL_ERR_INT_SET : WT; bitpos: [0]; default: 0;
|
||||
* The software set bit for SPI_DMA_INFIFO_FULL_ERR_INT interrupt.
|
||||
*/
|
||||
@@ -1754,7 +1754,7 @@ extern "C" {
|
||||
/** SPI_W0_REG register
|
||||
* SPI CPU-controlled buffer0
|
||||
*/
|
||||
#define SPI_W0_REG (DR_REG_SPI_BASE + 0x98)
|
||||
#define SPI_W0_REG(i) (REG_SPI_BASE(i) + 0x98)
|
||||
/** SPI_BUF0 : R/W/SS; bitpos: [31:0]; default: 0;
|
||||
* data buffer
|
||||
*/
|
||||
@@ -1766,7 +1766,7 @@ extern "C" {
|
||||
/** SPI_W1_REG register
|
||||
* SPI CPU-controlled buffer1
|
||||
*/
|
||||
#define SPI_W1_REG (DR_REG_SPI_BASE + 0x9c)
|
||||
#define SPI_W1_REG(i) (REG_SPI_BASE(i) + 0x9c)
|
||||
/** SPI_BUF1 : R/W/SS; bitpos: [31:0]; default: 0;
|
||||
* data buffer
|
||||
*/
|
||||
@@ -1778,7 +1778,7 @@ extern "C" {
|
||||
/** SPI_W2_REG register
|
||||
* SPI CPU-controlled buffer2
|
||||
*/
|
||||
#define SPI_W2_REG (DR_REG_SPI_BASE + 0xa0)
|
||||
#define SPI_W2_REG(i) (REG_SPI_BASE(i) + 0xa0)
|
||||
/** SPI_BUF2 : R/W/SS; bitpos: [31:0]; default: 0;
|
||||
* data buffer
|
||||
*/
|
||||
@@ -1790,7 +1790,7 @@ extern "C" {
|
||||
/** SPI_W3_REG register
|
||||
* SPI CPU-controlled buffer3
|
||||
*/
|
||||
#define SPI_W3_REG (DR_REG_SPI_BASE + 0xa4)
|
||||
#define SPI_W3_REG(i) (REG_SPI_BASE(i) + 0xa4)
|
||||
/** SPI_BUF3 : R/W/SS; bitpos: [31:0]; default: 0;
|
||||
* data buffer
|
||||
*/
|
||||
@@ -1802,7 +1802,7 @@ extern "C" {
|
||||
/** SPI_W4_REG register
|
||||
* SPI CPU-controlled buffer4
|
||||
*/
|
||||
#define SPI_W4_REG (DR_REG_SPI_BASE + 0xa8)
|
||||
#define SPI_W4_REG(i) (REG_SPI_BASE(i) + 0xa8)
|
||||
/** SPI_BUF4 : R/W/SS; bitpos: [31:0]; default: 0;
|
||||
* data buffer
|
||||
*/
|
||||
@@ -1814,7 +1814,7 @@ extern "C" {
|
||||
/** SPI_W5_REG register
|
||||
* SPI CPU-controlled buffer5
|
||||
*/
|
||||
#define SPI_W5_REG (DR_REG_SPI_BASE + 0xac)
|
||||
#define SPI_W5_REG(i) (REG_SPI_BASE(i) + 0xac)
|
||||
/** SPI_BUF5 : R/W/SS; bitpos: [31:0]; default: 0;
|
||||
* data buffer
|
||||
*/
|
||||
@@ -1826,7 +1826,7 @@ extern "C" {
|
||||
/** SPI_W6_REG register
|
||||
* SPI CPU-controlled buffer6
|
||||
*/
|
||||
#define SPI_W6_REG (DR_REG_SPI_BASE + 0xb0)
|
||||
#define SPI_W6_REG(i) (REG_SPI_BASE(i) + 0xb0)
|
||||
/** SPI_BUF6 : R/W/SS; bitpos: [31:0]; default: 0;
|
||||
* data buffer
|
||||
*/
|
||||
@@ -1838,7 +1838,7 @@ extern "C" {
|
||||
/** SPI_W7_REG register
|
||||
* SPI CPU-controlled buffer7
|
||||
*/
|
||||
#define SPI_W7_REG (DR_REG_SPI_BASE + 0xb4)
|
||||
#define SPI_W7_REG(i) (REG_SPI_BASE(i) + 0xb4)
|
||||
/** SPI_BUF7 : R/W/SS; bitpos: [31:0]; default: 0;
|
||||
* data buffer
|
||||
*/
|
||||
@@ -1850,7 +1850,7 @@ extern "C" {
|
||||
/** SPI_W8_REG register
|
||||
* SPI CPU-controlled buffer8
|
||||
*/
|
||||
#define SPI_W8_REG (DR_REG_SPI_BASE + 0xb8)
|
||||
#define SPI_W8_REG(i) (REG_SPI_BASE(i) + 0xb8)
|
||||
/** SPI_BUF8 : R/W/SS; bitpos: [31:0]; default: 0;
|
||||
* data buffer
|
||||
*/
|
||||
@@ -1862,7 +1862,7 @@ extern "C" {
|
||||
/** SPI_W9_REG register
|
||||
* SPI CPU-controlled buffer9
|
||||
*/
|
||||
#define SPI_W9_REG (DR_REG_SPI_BASE + 0xbc)
|
||||
#define SPI_W9_REG(i) (REG_SPI_BASE(i) + 0xbc)
|
||||
/** SPI_BUF9 : R/W/SS; bitpos: [31:0]; default: 0;
|
||||
* data buffer
|
||||
*/
|
||||
@@ -1874,7 +1874,7 @@ extern "C" {
|
||||
/** SPI_W10_REG register
|
||||
* SPI CPU-controlled buffer10
|
||||
*/
|
||||
#define SPI_W10_REG (DR_REG_SPI_BASE + 0xc0)
|
||||
#define SPI_W10_REG(i) (REG_SPI_BASE(i) + 0xc0)
|
||||
/** SPI_BUF10 : R/W/SS; bitpos: [31:0]; default: 0;
|
||||
* data buffer
|
||||
*/
|
||||
@@ -1886,7 +1886,7 @@ extern "C" {
|
||||
/** SPI_W11_REG register
|
||||
* SPI CPU-controlled buffer11
|
||||
*/
|
||||
#define SPI_W11_REG (DR_REG_SPI_BASE + 0xc4)
|
||||
#define SPI_W11_REG(i) (REG_SPI_BASE(i) + 0xc4)
|
||||
/** SPI_BUF11 : R/W/SS; bitpos: [31:0]; default: 0;
|
||||
* data buffer
|
||||
*/
|
||||
@@ -1898,7 +1898,7 @@ extern "C" {
|
||||
/** SPI_W12_REG register
|
||||
* SPI CPU-controlled buffer12
|
||||
*/
|
||||
#define SPI_W12_REG (DR_REG_SPI_BASE + 0xc8)
|
||||
#define SPI_W12_REG(i) (REG_SPI_BASE(i) + 0xc8)
|
||||
/** SPI_BUF12 : R/W/SS; bitpos: [31:0]; default: 0;
|
||||
* data buffer
|
||||
*/
|
||||
@@ -1910,7 +1910,7 @@ extern "C" {
|
||||
/** SPI_W13_REG register
|
||||
* SPI CPU-controlled buffer13
|
||||
*/
|
||||
#define SPI_W13_REG (DR_REG_SPI_BASE + 0xcc)
|
||||
#define SPI_W13_REG(i) (REG_SPI_BASE(i) + 0xcc)
|
||||
/** SPI_BUF13 : R/W/SS; bitpos: [31:0]; default: 0;
|
||||
* data buffer
|
||||
*/
|
||||
@@ -1922,7 +1922,7 @@ extern "C" {
|
||||
/** SPI_W14_REG register
|
||||
* SPI CPU-controlled buffer14
|
||||
*/
|
||||
#define SPI_W14_REG (DR_REG_SPI_BASE + 0xd0)
|
||||
#define SPI_W14_REG(i) (REG_SPI_BASE(i) + 0xd0)
|
||||
/** SPI_BUF14 : R/W/SS; bitpos: [31:0]; default: 0;
|
||||
* data buffer
|
||||
*/
|
||||
@@ -1934,7 +1934,7 @@ extern "C" {
|
||||
/** SPI_W15_REG register
|
||||
* SPI CPU-controlled buffer15
|
||||
*/
|
||||
#define SPI_W15_REG (DR_REG_SPI_BASE + 0xd4)
|
||||
#define SPI_W15_REG(i) (REG_SPI_BASE(i) + 0xd4)
|
||||
/** SPI_BUF15 : R/W/SS; bitpos: [31:0]; default: 0;
|
||||
* data buffer
|
||||
*/
|
||||
@@ -1946,11 +1946,11 @@ extern "C" {
|
||||
/** SPI_SLAVE_REG register
|
||||
* SPI slave control register
|
||||
*/
|
||||
#define SPI_SLAVE_REG (DR_REG_SPI_BASE + 0xe0)
|
||||
#define SPI_SLAVE_REG(i) (REG_SPI_BASE(i) + 0xe0)
|
||||
/** SPI_CLK_MODE : R/W; bitpos: [1:0]; default: 0;
|
||||
* SPI clock mode bits. 0: SPI clock is off when CS inactive 1: SPI clock is delayed
|
||||
* one cycle after CS inactive 2: SPI clock is delayed two cycles after CS inactive 3:
|
||||
* SPI clock is alwasy on. Can be configured in CONF state.
|
||||
* SPI clock is always on. Can be configured in CONF state.
|
||||
*/
|
||||
#define SPI_CLK_MODE 0x00000003U
|
||||
#define SPI_CLK_MODE_M (SPI_CLK_MODE_V << SPI_CLK_MODE_S)
|
||||
@@ -2047,7 +2047,7 @@ extern "C" {
|
||||
/** SPI_SLAVE1_REG register
|
||||
* SPI slave control register 1
|
||||
*/
|
||||
#define SPI_SLAVE1_REG (DR_REG_SPI_BASE + 0xe4)
|
||||
#define SPI_SLAVE1_REG(i) (REG_SPI_BASE(i) + 0xe4)
|
||||
/** SPI_SLV_DATA_BITLEN : R/W/SS; bitpos: [17:0]; default: 0;
|
||||
* The transferred data bit length in SPI slave FD and HD mode.
|
||||
*/
|
||||
@@ -2073,7 +2073,7 @@ extern "C" {
|
||||
/** SPI_CLK_GATE_REG register
|
||||
* SPI module clock and register clock control
|
||||
*/
|
||||
#define SPI_CLK_GATE_REG (DR_REG_SPI_BASE + 0xe8)
|
||||
#define SPI_CLK_GATE_REG(i) (REG_SPI_BASE(i) + 0xe8)
|
||||
/** SPI_CLK_EN : R/W; bitpos: [0]; default: 0;
|
||||
* Set this bit to enable clk gate
|
||||
*/
|
||||
@@ -2100,7 +2100,7 @@ extern "C" {
|
||||
/** SPI_DATE_REG register
|
||||
* Version control
|
||||
*/
|
||||
#define SPI_DATE_REG (DR_REG_SPI_BASE + 0xf0)
|
||||
#define SPI_DATE_REG(i) (REG_SPI_BASE(i) + 0xf0)
|
||||
/** SPI_DATE : R/W; bitpos: [27:0]; default: 35656448;
|
||||
* SPI register version.
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2020-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 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 = FSPICLK_OUT_IDX,
|
||||
.spiclk_in = FSPICLK_IN_IDX,
|
||||
@@ -62,3 +39,46 @@ const spi_signal_conn_t spi_periph_signal[SOC_SPI_PERIPH_NUM] = {
|
||||
.func = SPI2_FUNC_NUM,
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 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) | ENTRY(2) }, \
|
||||
/* 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) | ENTRY(2) }, \
|
||||
}
|
||||
|
||||
static const regdma_entries_config_t spi2_regs_retention[] = SPI_REG_RETENTION_ENTRIES(2); // '2' for GPSPI2
|
||||
|
||||
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),
|
||||
},
|
||||
};
|
||||
|
||||
@@ -52,6 +52,7 @@ extern "C" {
|
||||
#define REGDMA_TG1_WDT_LINK(_pri) ((0x1B << 8) | _pri)
|
||||
#define REGDMA_TG0_TIMER_LINK(_pri) ((0x1C << 8) | _pri)
|
||||
#define REGDMA_TG1_TIMER_LINK(_pri) ((0x1D << 8) | _pri)
|
||||
#define REGDMA_GPSPI_LINK(_pri) ((0x1E << 8) | _pri)
|
||||
#define REGDMA_MODEM_FE_LINK(_pri) ((0xFF << 8) | _pri)
|
||||
|
||||
#define REGDMA_LINK_PRI_SYS_CLK REGDMA_LINK_PRI_0
|
||||
@@ -69,6 +70,7 @@ extern "C" {
|
||||
#define REGDMA_LINK_PRI_GPTIMER REGDMA_LINK_PRI_GENERAL_PERIPH
|
||||
#define REGDMA_LINK_PRI_I2C REGDMA_LINK_PRI_GENERAL_PERIPH
|
||||
#define REGDMA_LINK_PRI_UART REGDMA_LINK_PRI_GENERAL_PERIPH
|
||||
#define REGDMA_LINK_PRI_GPSPI REGDMA_LINK_PRI_GENERAL_PERIPH
|
||||
|
||||
typedef enum {
|
||||
REGDMA_LINK_PRI_0 = 0,
|
||||
|
||||
@@ -10,12 +10,17 @@
|
||||
#include "sdkconfig.h"
|
||||
#include "soc/soc.h"
|
||||
#include "soc/periph_defs.h"
|
||||
#include "soc/soc_caps.h"
|
||||
#include "soc/spi_pins.h"
|
||||
#if SOC_PAU_SUPPORTED
|
||||
#include "soc/regdma.h"
|
||||
#include "soc/retention_periph_defs.h"
|
||||
#endif
|
||||
|
||||
//include soc related (generated) definitions
|
||||
#include "soc/soc_caps.h"
|
||||
#include "soc/interrupts.h"
|
||||
#include "soc/spi_reg.h"
|
||||
#include "soc/spi_struct.h"
|
||||
#include "soc/spi_pins.h"
|
||||
#include "soc/gpio_sig_map.h"
|
||||
#if SOC_MEMSPI_IS_INDEPENDENT
|
||||
#include "soc/spi_mem_struct.h"
|
||||
@@ -72,12 +77,22 @@ typedef struct {
|
||||
const uint8_t irq; //irq source for interrupt mux
|
||||
const uint8_t irq_dma; //dma irq source for interrupt mux
|
||||
const periph_module_t module; //peripheral module, for enabling clock etc
|
||||
const int func; //function number for IOMUX
|
||||
spi_dev_t *hw; //Pointer to the hardware registers
|
||||
const int func; //function number for IOMUX
|
||||
spi_dev_t *hw; //Pointer to the hardware registers
|
||||
} spi_signal_conn_t;
|
||||
|
||||
extern const spi_signal_conn_t spi_periph_signal[SOC_SPI_PERIPH_NUM];
|
||||
|
||||
#if SOC_PAU_SUPPORTED
|
||||
typedef struct {
|
||||
const periph_retention_module_t module_id;
|
||||
const regdma_entries_config_t *entry_array;
|
||||
uint32_t array_size;
|
||||
} spi_reg_retention_info_t;
|
||||
|
||||
extern const spi_reg_retention_info_t spi_reg_retention_info[SOC_SPI_PERIPH_NUM - 1]; // -1 to except mspi
|
||||
#endif // SOC_PAU_SUPPORTED
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user