Skip to content

Commit 0296c30

Browse files
committed
feat(soc): introduce the soc_caps_full.h for internal use only
1 parent 296bc7d commit 0296c30

File tree

45 files changed

+467
-451
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+467
-451
lines changed

components/soc/README.md

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
1-
## `soc` ##
1+
# The SoC component
22

3-
The `soc` component provides hardware description for targets supported by ESP-IDF.
3+
The `soc` component provides register-level descriptions for targets supported by ESP-IDF.
44

5-
- `xxx_reg.h` - defines registers related to the hardware
6-
- `xxx_struct.h` - hardware description in C `struct`
7-
- `xxx_channel.h` - definitions for hardware with multiple channels
8-
- `xxx_caps.h` - features/capabilities of the hardware
9-
- `xxx_pins.h` - pin definitions
10-
- `xxx_periph.h/*.c` - includes all headers related to a peripheral; declaration and definition of IO mapping for that hardware
5+
| File | Description |
6+
|---------------------|-----------------------------------------------------------------------------------------------|
7+
| `xxx_reg.h`/`xx_struct.h` | Defines registers layout of a specific module. These files are automated, and should not be updated manually. <br/> Please note the register names and layout are subject to change between different chip series. |
8+
| `xxx_pins.h` | Defines the unchangeable GPIOs used by a specific module. <br/> e.g. if a high speed signal is routed through IO MUX, its corresponding GPIO is not selectable. |
9+
| `soc_caps.h` | Describes the differences in capabilities between different chips. <br/> The macros here can also affect cmake build system, Kconfig system, docs system, pytest and CI environment. <br/> **Changes to this file requires extra caution as they are part of the public API.** |
10+
| `xxx_periph.h` | This is the portal for each peripheral module at the SoC layer, <br/> containing all relevant register header files and organizing other key information, such as interrupt sources, hardware signal IDs, etc. |
11+
| `xxx.peripherals.ld` | This is the linker script that defines each module's memory address. |
1112

12-
Specially, the `xxx_reg.h` and `xxx_struct.h` headers that generated by script are under `register/soc` folder. Please DO NOT **add** other manual coded files under this folder.
13+
## The SoC Capabilities
1314

14-
For other soc headers that are used as wrapper, definition, signaling, mapping or manual coded registers, please add them under `include/soc` folder.
15+
There are two documents describing SoC capabilities, `soc_caps.h` and `soc_caps_full.h`. The former is a public header file, and the information in it is coarse-grained. The latter is a header file for internal developers that contains fine-grained module information. To used the soc capability macros, you should use the macro functions offered by `soc/soc_caps_eval.h`.
16+
17+
| Macro function | Description | Example |
18+
|----------------|-------------|---------|
19+
| `SOC_IS` | Checks if the current SoC is a specific one. | `SOC_IS(ESP32)` |
20+
| `SOC_HAS` | Checks if the current SoC has a specific module. | `SOC_HAS(DAC)` |
21+
| `SOC_MODULE_ATTR` | Get the attribute of a specific module. | `SOC_MODULE_ATTR(GPTIMER, TIMERS_TOTAL)` |
22+
| `SOC_MODULE_SUPPORT` | Checks if the current SoC supports a specific feature. | `SOC_MODULE_SUPPORT(GPTIMER, ETM)` |

components/soc/esp32/include/soc/Kconfig.soc_caps.in

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,6 @@ config SOC_XTAL_SUPPORT_40M
191191
bool
192192
default y
193193

194-
config SOC_XTAL_SUPPORT_AUTO_DETECT
195-
bool
196-
default y
197-
198194
config SOC_ADC_RTC_CTRL_SUPPORTED
199195
bool
200196
default y
@@ -249,11 +245,11 @@ config SOC_ADC_DIGI_MONITOR_NUM
249245

250246
config SOC_ADC_SAMPLE_FREQ_THRES_HIGH
251247
int
252-
default 2
248+
default 2000000
253249

254250
config SOC_ADC_SAMPLE_FREQ_THRES_LOW
255251
int
256-
default 20
252+
default 20000
257253

258254
config SOC_ADC_RTC_MIN_BITWIDTH
259255
int
@@ -439,10 +435,6 @@ config SOC_I2S_SUPPORTS_ADC
439435
bool
440436
default y
441437

442-
config SOC_I2S_SUPPORTS_DAC
443-
bool
444-
default y
445-
446438
config SOC_I2S_SUPPORTS_LCD_CAMERA
447439
bool
448440
default y
@@ -691,26 +683,6 @@ config SOC_MEMSPI_SRC_FREQ_20M_SUPPORTED
691683
bool
692684
default y
693685

694-
config SOC_TIMER_GROUPS
695-
int
696-
default 2
697-
698-
config SOC_TIMER_GROUP_TIMERS_PER_GROUP
699-
int
700-
default 2
701-
702-
config SOC_TIMER_GROUP_COUNTER_BIT_WIDTH
703-
int
704-
default 64
705-
706-
config SOC_TIMER_GROUP_TOTAL_TIMERS
707-
int
708-
default 4
709-
710-
config SOC_TIMER_GROUP_SUPPORT_APB
711-
bool
712-
default y
713-
714686
config SOC_LP_TIMER_BIT_WIDTH_LO
715687
int
716688
default 32

components/soc/esp32/include/soc/soc_caps.h

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@
3737

3838
#pragma once
3939

40+
#if __has_include("soc/soc_caps_eval.h")
41+
#include "soc/soc_caps_eval.h"
42+
#endif
43+
4044
#ifdef __has_include
4145
# if __has_include("sdkconfig.h")
4246
# include "sdkconfig.h"
@@ -55,10 +59,11 @@
5559
// Define warning strings here for ECO-ed features to show error when they are used without being
5660
// defined correctly
5761
#define SOC_BROWNOUT_RESET_SUPPORTED "Not determined" // [gen_soc_caps:ignore]
58-
#define SOC_TWAI_BRP_DIV_SUPPORTED "Not determined" // [gen_soc_caps:ignore]
5962
#define SOC_DPORT_WORKAROUND "Not determined" // [gen_soc_caps:ignore]
6063
#endif
6164

65+
#define _SOC_CAPS_TARGET_IS_ESP32 1 // [gen_soc_caps:ignore]
66+
6267
/*-------------------------- COMMON CAPS ---------------------------------------*/
6368
#define SOC_CAPS_ECO_VER_MAX 301
6469

@@ -114,7 +119,6 @@
114119
/*-------------------------- XTAL CAPS ---------------------------------------*/
115120
#define SOC_XTAL_SUPPORT_26M 1
116121
#define SOC_XTAL_SUPPORT_40M 1
117-
#define SOC_XTAL_SUPPORT_AUTO_DETECT 1 // Measure XTAL freq with an internal RC clock
118122

119123
/*-------------------------- ADC CAPS ----------------------------------------*/
120124
/*!< SAR ADC Module*/
@@ -135,8 +139,8 @@
135139
#define SOC_ADC_DIGI_RESULT_BYTES (2)
136140
#define SOC_ADC_DIGI_DATA_BYTES_PER_CONV (4)
137141
#define SOC_ADC_DIGI_MONITOR_NUM (0U) // to reference `IDF_TARGET_SOC_ADC_DIGI_MONITOR_NUM` in document
138-
#define SOC_ADC_SAMPLE_FREQ_THRES_HIGH (2*1000*1000)
139-
#define SOC_ADC_SAMPLE_FREQ_THRES_LOW (20*1000)
142+
#define SOC_ADC_SAMPLE_FREQ_THRES_HIGH (2000000)
143+
#define SOC_ADC_SAMPLE_FREQ_THRES_LOW (20000)
140144

141145
/*!< RTC */
142146
#define SOC_ADC_RTC_MIN_BITWIDTH (9)
@@ -226,7 +230,6 @@
226230
#define SOC_I2S_PDM_MAX_RX_LINES (1U)
227231
#define SOC_I2S_SUPPORTS_ADC_DAC (1)
228232
#define SOC_I2S_SUPPORTS_ADC (1)
229-
#define SOC_I2S_SUPPORTS_DAC (1)
230233
#define SOC_I2S_SUPPORTS_LCD_CAMERA (1)
231234
#define SOC_I2S_MAX_DATA_WIDTH (24)
232235

@@ -322,13 +325,6 @@
322325
// Peripheral supports DIO, DOUT, QIO, or QOUT
323326
#define SOC_SPI_PERIPH_SUPPORT_MULTILINE_MODE(spi_host) ({(void)spi_host; 1;})
324327

325-
/*-------------------------- TIMER GROUP CAPS --------------------------------*/
326-
#define SOC_TIMER_GROUPS (2)
327-
#define SOC_TIMER_GROUP_TIMERS_PER_GROUP (2)
328-
#define SOC_TIMER_GROUP_COUNTER_BIT_WIDTH (64)
329-
#define SOC_TIMER_GROUP_TOTAL_TIMERS (4)
330-
#define SOC_TIMER_GROUP_SUPPORT_APB (1)
331-
332328
/*-------------------------- LP_TIMER CAPS ----------------------------------*/
333329
#define SOC_LP_TIMER_BIT_WIDTH_LO 32 // Bit width of lp_timer low part
334330
#define SOC_LP_TIMER_BIT_WIDTH_HI 16 // Bit width of lp_timer high part
@@ -347,7 +343,6 @@
347343
#define SOC_TWAI_BRP_MIN 2
348344
#if SOC_CAPS_ECO_VER >= 200
349345
# define SOC_TWAI_BRP_MAX 256
350-
# define SOC_TWAI_BRP_DIV_SUPPORTED 1
351346
#else
352347
# define SOC_TWAI_BRP_MAX 128
353348
#endif
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#pragma once
8+
9+
#include "soc/soc_caps.h"
10+
#include "soc/soc_caps_eval.h"
11+
12+
/*--------------------------- Timer Group -------------------------------------------*/
13+
#define _SOC_CAPS_TIMG_INST_NUM 2 // Number of Timer Group instances
14+
15+
/*--------------------------- GPTIMER ---------------------------------------*/
16+
#define _SOC_CAPS_GPTIMER_COUNTER_BIT_WIDTH 64 // Bit width of GPTIMER counter
17+
#define _SOC_CAPS_GPTIMER_TIMERS_PER_TIMG 2 // Number of general purpose timers in each Timer Group
18+
#define _SOC_CAPS_GPTIMER_TIMERS_TOTAL (_SOC_CAPS_TIMG_INST_NUM * _SOC_CAPS_GPTIMER_TIMERS_PER_TIMG)
19+
20+
/*--------------------------- Watch Dog ------------------------------------------*/
21+
#define _SOC_CAPS_WDT_MWDTS_PER_TIMG 1 // Number of main watchdog timers in each Timer Group

components/soc/esp32c2/include/soc/Kconfig.soc_caps.in

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -603,26 +603,6 @@ config SOC_SYSTIMER_ALARM_MISS_COMPENSATE
603603
bool
604604
default y
605605

606-
config SOC_TIMER_GROUPS
607-
int
608-
default 1
609-
610-
config SOC_TIMER_GROUP_TIMERS_PER_GROUP
611-
int
612-
default 1
613-
614-
config SOC_TIMER_GROUP_COUNTER_BIT_WIDTH
615-
int
616-
default 54
617-
618-
config SOC_TIMER_GROUP_SUPPORT_XTAL
619-
bool
620-
default y
621-
622-
config SOC_TIMER_GROUP_TOTAL_TIMERS
623-
int
624-
default 1
625-
626606
config SOC_LP_TIMER_BIT_WIDTH_LO
627607
int
628608
default 32

components/soc/esp32c2/include/soc/soc_caps.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@
1616

1717
#pragma once
1818

19+
#if __has_include("soc/soc_caps_eval.h")
20+
#include "soc/soc_caps_eval.h"
21+
#endif
22+
23+
#define _SOC_CAPS_TARGET_IS_ESP32C2 1 // [gen_soc_caps:ignore]
24+
1925
/*-------------------------- COMMON CAPS ---------------------------------------*/
2026
#define SOC_ADC_SUPPORTED 1
2127
#define SOC_DEDICATED_GPIO_SUPPORTED 1
@@ -268,13 +274,6 @@
268274
#define SOC_SYSTIMER_INT_LEVEL 1 // Systimer peripheral uses level interrupt
269275
#define SOC_SYSTIMER_ALARM_MISS_COMPENSATE 1 // Systimer peripheral can generate interrupt immediately if t(target) > t(current)
270276

271-
/*--------------------------- TIMER GROUP CAPS ---------------------------------------*/
272-
#define SOC_TIMER_GROUPS (1U)
273-
#define SOC_TIMER_GROUP_TIMERS_PER_GROUP (1U)
274-
#define SOC_TIMER_GROUP_COUNTER_BIT_WIDTH (54)
275-
#define SOC_TIMER_GROUP_SUPPORT_XTAL (1)
276-
#define SOC_TIMER_GROUP_TOTAL_TIMERS (1U)
277-
278277
/*-------------------------- LP_TIMER CAPS ----------------------------------*/
279278
#define SOC_LP_TIMER_BIT_WIDTH_LO 32 // Bit width of lp_timer low part
280279
#define SOC_LP_TIMER_BIT_WIDTH_HI 16 // Bit width of lp_timer high part
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#pragma once
8+
9+
#include "soc/soc_caps.h"
10+
#include "soc/soc_caps_eval.h"
11+
12+
/*--------------------------- Timer Group -------------------------------------------*/
13+
#define _SOC_CAPS_TIMG_INST_NUM 1 // Number of Timer Group instances
14+
15+
/*--------------------------- GPTIMER ---------------------------------------*/
16+
#define _SOC_CAPS_GPTIMER_COUNTER_BIT_WIDTH 54 // Bit width of GPTIMER counter
17+
#define _SOC_CAPS_GPTIMER_TIMERS_PER_TIMG 1 // Number of general purpose timers in each Timer Group
18+
#define _SOC_CAPS_GPTIMER_TIMERS_TOTAL (_SOC_CAPS_TIMG_INST_NUM * _SOC_CAPS_GPTIMER_TIMERS_PER_TIMG)
19+
20+
/*--------------------------- Watch Dog ------------------------------------------*/
21+
#define _SOC_CAPS_WDT_MWDTS_PER_TIMG 1 // Number of main watchdog timers in each Timer Group

components/soc/esp32c3/include/soc/Kconfig.soc_caps.in

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -863,30 +863,6 @@ config SOC_SYSTIMER_ALARM_MISS_COMPENSATE
863863
bool
864864
default y
865865

866-
config SOC_TIMER_GROUPS
867-
int
868-
default 2
869-
870-
config SOC_TIMER_GROUP_TIMERS_PER_GROUP
871-
int
872-
default 1
873-
874-
config SOC_TIMER_GROUP_COUNTER_BIT_WIDTH
875-
int
876-
default 54
877-
878-
config SOC_TIMER_GROUP_SUPPORT_XTAL
879-
bool
880-
default y
881-
882-
config SOC_TIMER_GROUP_SUPPORT_APB
883-
bool
884-
default y
885-
886-
config SOC_TIMER_GROUP_TOTAL_TIMERS
887-
int
888-
default 2
889-
890866
config SOC_LP_TIMER_BIT_WIDTH_LO
891867
int
892868
default 32

components/soc/esp32c3/include/soc/soc_caps.h

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@
1616

1717
#pragma once
1818

19+
#if __has_include("soc/soc_caps_eval.h")
20+
#include "soc/soc_caps_eval.h"
21+
#endif
22+
23+
#define _SOC_CAPS_TARGET_IS_ESP32C3 1 // [gen_soc_caps:ignore]
24+
1925
/*-------------------------- COMMON CAPS ---------------------------------------*/
2026
#define SOC_ADC_SUPPORTED 1
2127
#define SOC_DEDICATED_GPIO_SUPPORTED 1
@@ -363,14 +369,6 @@
363369
#define SOC_SYSTIMER_INT_LEVEL 1 // Systimer peripheral uses level interrupt
364370
#define SOC_SYSTIMER_ALARM_MISS_COMPENSATE 1 // Systimer peripheral can generate interrupt immediately if t(target) > t(current)
365371

366-
/*--------------------------- TIMER GROUP CAPS ---------------------------------------*/
367-
#define SOC_TIMER_GROUPS (2)
368-
#define SOC_TIMER_GROUP_TIMERS_PER_GROUP (1U)
369-
#define SOC_TIMER_GROUP_COUNTER_BIT_WIDTH (54)
370-
#define SOC_TIMER_GROUP_SUPPORT_XTAL (1)
371-
#define SOC_TIMER_GROUP_SUPPORT_APB (1)
372-
#define SOC_TIMER_GROUP_TOTAL_TIMERS (2)
373-
374372
/*-------------------------- LP_TIMER CAPS ----------------------------------*/
375373
#define SOC_LP_TIMER_BIT_WIDTH_LO 32 // Bit width of lp_timer low part
376374
#define SOC_LP_TIMER_BIT_WIDTH_HI 16 // Bit width of lp_timer high part
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#pragma once
8+
9+
#include "soc/soc_caps.h"
10+
#include "soc/soc_caps_eval.h"
11+
12+
/*--------------------------- Timer Group -------------------------------------------*/
13+
#define _SOC_CAPS_TIMG_INST_NUM 2 // Number of Timer Group instances
14+
15+
/*--------------------------- GPTIMER ---------------------------------------*/
16+
#define _SOC_CAPS_GPTIMER_COUNTER_BIT_WIDTH 54 // Bit width of GPTIMER counter
17+
#define _SOC_CAPS_GPTIMER_TIMERS_PER_TIMG 1 // Number of general purpose timers in each Timer Group
18+
#define _SOC_CAPS_GPTIMER_TIMERS_TOTAL (_SOC_CAPS_TIMG_INST_NUM * _SOC_CAPS_GPTIMER_TIMERS_PER_TIMG)
19+
20+
/*--------------------------- Watch Dog ------------------------------------------*/
21+
#define _SOC_CAPS_WDT_MWDTS_PER_TIMG 1 // Number of main watchdog timers in each Timer Group

0 commit comments

Comments
 (0)