mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-10 04:43:33 +00:00
feat(clk): Add basic clock support for esp32c5 mp
- Support SOC ROOT clock source switch - Support CPU frequency change - Support RTC SLOW clock source switch - Support RTC SLOW clock + RC FAST calibration - Remove FPGA build
This commit is contained in:
@@ -131,6 +131,10 @@ config SOC_SECURE_BOOT_SUPPORTED
|
||||
bool
|
||||
default y
|
||||
|
||||
config SOC_PMU_SUPPORTED
|
||||
bool
|
||||
default y
|
||||
|
||||
config SOC_LP_TIMER_SUPPORTED
|
||||
bool
|
||||
default y
|
||||
@@ -139,6 +143,10 @@ config SOC_LP_PERIPHERALS_SUPPORTED
|
||||
bool
|
||||
default y
|
||||
|
||||
config SOC_CLK_TREE_SUPPORTED
|
||||
bool
|
||||
default y
|
||||
|
||||
config SOC_SPI_FLASH_SUPPORTED
|
||||
bool
|
||||
default y
|
||||
@@ -847,6 +855,14 @@ config SOC_UART_BITRATE_MAX
|
||||
int
|
||||
default 5000000
|
||||
|
||||
config SOC_UART_SUPPORT_PLL_F80M_CLK
|
||||
bool
|
||||
default y
|
||||
|
||||
config SOC_UART_SUPPORT_RTC_CLK
|
||||
bool
|
||||
default y
|
||||
|
||||
config SOC_UART_SUPPORT_XTAL_CLK
|
||||
bool
|
||||
default y
|
||||
@@ -895,6 +911,10 @@ config SOC_PM_SUPPORT_RTC_PERIPH_PD
|
||||
bool
|
||||
default y
|
||||
|
||||
config SOC_CLK_RC_FAST_SUPPORT_CALIBRATION
|
||||
bool
|
||||
default y
|
||||
|
||||
config SOC_MODEM_CLOCK_IS_INDEPENDENT
|
||||
bool
|
||||
default y
|
||||
@@ -911,6 +931,10 @@ config SOC_CLK_RC32K_SUPPORTED
|
||||
bool
|
||||
default y
|
||||
|
||||
config SOC_CLK_LP_FAST_SUPPORT_XTAL
|
||||
bool
|
||||
default y
|
||||
|
||||
config SOC_RCC_IS_INDEPENDENT
|
||||
bool
|
||||
default y
|
||||
|
@@ -19,7 +19,7 @@ extern "C" {
|
||||
*
|
||||
* The exact frequency of RC_FAST_CLK can be computed in runtime through calibration.
|
||||
*
|
||||
* 2) External 40/48MHz Crystal Clock: XTAL
|
||||
* 2) External 48MHz Crystal Clock: XTAL
|
||||
*
|
||||
* 3) Internal 136kHz RC Oscillator: RC_SLOW (may also referred as SOSC in TRM or reg. description)
|
||||
*
|
||||
@@ -45,7 +45,6 @@ extern "C" {
|
||||
* OSC_SLOW_CLK can also be calibrated to get its exact frequency.
|
||||
*/
|
||||
|
||||
// TODO: [ESP32C5] IDF-8642 (inherit from C6)
|
||||
/* With the default value of FOSC_DFREQ = 100, RC_FAST clock frequency is 17.5 MHz +/- 7% */
|
||||
#define SOC_CLK_RC_FAST_FREQ_APPROX 17500000 /*!< Approximate RC_FAST_CLK frequency in Hz */
|
||||
#define SOC_CLK_RC_SLOW_FREQ_APPROX 136000 /*!< Approximate RC_SLOW_CLK frequency in Hz */
|
||||
@@ -60,10 +59,10 @@ extern "C" {
|
||||
/**
|
||||
* @brief Root clock
|
||||
*/
|
||||
typedef enum { // TODO: [ESP32C5] IDF-8642 (inherit from C6)
|
||||
typedef enum {
|
||||
SOC_ROOT_CLK_INT_RC_FAST, /*!< Internal 17.5MHz RC oscillator */
|
||||
SOC_ROOT_CLK_INT_RC_SLOW, /*!< Internal 136kHz RC oscillator */
|
||||
SOC_ROOT_CLK_EXT_XTAL, /*!< External 40MHz crystal */
|
||||
SOC_ROOT_CLK_EXT_XTAL, /*!< External 48MHz crystal */
|
||||
SOC_ROOT_CLK_EXT_XTAL32K, /*!< External 32kHz crystal */
|
||||
SOC_ROOT_CLK_INT_RC32K, /*!< Internal 32kHz RC oscillator */
|
||||
SOC_ROOT_CLK_EXT_OSC_SLOW, /*!< External slow clock signal at pin0 */
|
||||
@@ -73,12 +72,11 @@ typedef enum { // TODO: [ESP32C5] IDF-8642 (inherit from C6)
|
||||
* @brief CPU_CLK mux inputs, which are the supported clock sources for the CPU_CLK
|
||||
* @note Enum values are matched with the register field values on purpose
|
||||
*/
|
||||
typedef enum { // TODO: [ESP32C5] IDF-8642 (inherit from C6)
|
||||
typedef enum {
|
||||
SOC_CPU_CLK_SRC_XTAL = 0, /*!< Select XTAL_CLK as CPU_CLK source */
|
||||
SOC_CPU_CLK_SRC_RC_FAST = 1, /*!< Select RC_FAST_CLK as CPU_CLK source */
|
||||
SOC_CPU_CLK_SRC_PLL_F160M = 2, /*!< Select PLL_F160M_CLK as CPU_CLK source (PLL_F160M_CLK is derived from SPLL (480MHz), which is the output of the main crystal oscillator frequency multiplier) */
|
||||
SOC_CPU_CLK_SRC_PLL_F240M = 3, /*!< Select PLL_F240M_CLK as CPU_CLK source (PLL_F240M_CLK is derived from SPLL (480MHz), which is the output of the main crystal oscillator frequency multiplier) */
|
||||
SOC_CPU_CLK_SRC_PLL = SOC_CPU_CLK_SRC_PLL_F240M, // TODO: [IDF-8642] remove this alias
|
||||
SOC_CPU_CLK_SRC_INVALID, /*!< Invalid CPU_CLK source */
|
||||
} soc_cpu_clk_src_t;
|
||||
|
||||
@@ -86,7 +84,7 @@ typedef enum { // TODO: [ESP32C5] IDF-8642 (inherit from C6)
|
||||
* @brief RTC_SLOW_CLK mux inputs, which are the supported clock sources for the RTC_SLOW_CLK
|
||||
* @note Enum values are matched with the register field values on purpose
|
||||
*/
|
||||
typedef enum { // TODO: [ESP32C5] IDF-8642 (inherit from C6)
|
||||
typedef enum {
|
||||
SOC_RTC_SLOW_CLK_SRC_RC_SLOW = 0, /*!< Select RC_SLOW_CLK as RTC_SLOW_CLK source */
|
||||
SOC_RTC_SLOW_CLK_SRC_XTAL32K = 1, /*!< Select XTAL32K_CLK as RTC_SLOW_CLK source */
|
||||
SOC_RTC_SLOW_CLK_SRC_RC32K = 2, /*!< Select RC32K_CLK as RTC_SLOW_CLK source */
|
||||
@@ -98,7 +96,7 @@ typedef enum { // TODO: [ESP32C5] IDF-8642 (inherit from C6)
|
||||
* @brief RTC_FAST_CLK mux inputs, which are the supported clock sources for the RTC_FAST_CLK
|
||||
* @note Enum values are matched with the register field values on purpose
|
||||
*/
|
||||
typedef enum { // TODO: [ESP32C5] IDF-8642 (inherit from C6)
|
||||
typedef enum {
|
||||
SOC_RTC_FAST_CLK_SRC_RC_FAST = 0, /*!< Select RC_FAST_CLK as RTC_FAST_CLK source */
|
||||
SOC_RTC_FAST_CLK_SRC_XTAL_D2 = 1, /*!< Select XTAL_D2_CLK as RTC_FAST_CLK source */
|
||||
SOC_RTC_FAST_CLK_SRC_XTAL_DIV = SOC_RTC_FAST_CLK_SRC_XTAL_D2, /*!< Alias name for `SOC_RTC_FAST_CLK_SRC_XTAL_D2` */
|
||||
@@ -125,7 +123,7 @@ typedef enum {
|
||||
*
|
||||
* @note enum starts from 1, to save 0 for special purpose
|
||||
*/
|
||||
typedef enum { // TODO: [ESP32C5] IDF-8642 (inherit from C6)
|
||||
typedef enum {
|
||||
// For CPU domain
|
||||
SOC_MOD_CLK_CPU = 1, /*!< CPU_CLK can be sourced from XTAL, PLL, or RC_FAST by configuring soc_cpu_clk_src_t */
|
||||
// For RTC domain
|
||||
@@ -138,9 +136,9 @@ typedef enum { // TODO: [ESP32C5] IDF-8642 (inherit from C6)
|
||||
SOC_MOD_CLK_SPLL, /*!< SPLL is from the main XTAL oscillator frequency multipliers, it has a "fixed" frequency of 480MHz */
|
||||
SOC_MOD_CLK_XTAL32K, /*!< XTAL32K_CLK comes from the external 32kHz crystal, passing a clock gating to the peripherals */
|
||||
SOC_MOD_CLK_RC_FAST, /*!< RC_FAST_CLK comes from the internal 20MHz rc oscillator, passing a clock gating to the peripherals */
|
||||
SOC_MOD_CLK_XTAL, /*!< XTAL_CLK comes from the external 40MHz crystal */
|
||||
SOC_MOD_CLK_XTAL, /*!< XTAL_CLK comes from the external 48MHz crystal */
|
||||
// For LP peripherals
|
||||
SOC_MOD_CLK_XTAL_D2, /*!< XTAL_D2_CLK comes from the external 40MHz crystal, passing a div of 2 to the LP peripherals */
|
||||
SOC_MOD_CLK_XTAL_D2, /*!< XTAL_D2_CLK comes from the external 48MHz crystal, passing a div of 2 to the LP peripherals */
|
||||
|
||||
SOC_MOD_CLK_INVALID, /*!< Indication of the end of the available module clock sources */
|
||||
} soc_module_clk_t;
|
||||
@@ -548,7 +546,7 @@ typedef enum { // TODO: [ESP32C5] IDF-8649
|
||||
} soc_periph_mspi_clk_src_t;
|
||||
|
||||
//////////////////////////////////////////////CLOCK OUTPUT///////////////////////////////////////////////////////////
|
||||
typedef enum { // TODO: [ESP32C5] IDF-8642 (inherit from C6)
|
||||
typedef enum { // TODO
|
||||
CLKOUT_SIG_PLL = 1, /*!< PLL_CLK is the output of crystal oscillator frequency multiplier */
|
||||
CLKOUT_SIG_XTAL = 5, /*!< Main crystal oscillator clock */
|
||||
CLKOUT_SIG_PLL_F80M = 13, /*!< From PLL, usually be 80MHz */
|
||||
|
@@ -1902,21 +1902,6 @@ extern "C" {
|
||||
* SYSCLK configuration register
|
||||
*/
|
||||
#define PCR_SYSCLK_CONF_REG (DR_REG_PCR_BASE + 0x110)
|
||||
/** PCR_LS_DIV_NUM : HRO; bitpos: [7:0]; default: 0;
|
||||
* clk_hproot is div1 of low-speed clock-source if clck-source is a low-speed
|
||||
* clock-source such as XTAL/FOSC.
|
||||
*/
|
||||
#define PCR_LS_DIV_NUM 0x000000FFU
|
||||
#define PCR_LS_DIV_NUM_M (PCR_LS_DIV_NUM_V << PCR_LS_DIV_NUM_S)
|
||||
#define PCR_LS_DIV_NUM_V 0x000000FFU
|
||||
#define PCR_LS_DIV_NUM_S 0
|
||||
/** PCR_HS_DIV_NUM : HRO; bitpos: [15:8]; default: 2;
|
||||
* clk_hproot is div3 of SPLL if the clock-source is high-speed clock SPLL.
|
||||
*/
|
||||
#define PCR_HS_DIV_NUM 0x000000FFU
|
||||
#define PCR_HS_DIV_NUM_M (PCR_HS_DIV_NUM_V << PCR_HS_DIV_NUM_S)
|
||||
#define PCR_HS_DIV_NUM_V 0x000000FFU
|
||||
#define PCR_HS_DIV_NUM_S 8
|
||||
/** PCR_SOC_CLK_SEL : R/W; bitpos: [17:16]; default: 0;
|
||||
* Configures to select the clock source of HP_ROOT_CLK.\\
|
||||
* 0 (default): XTAL_CLK\\
|
||||
|
@@ -1642,15 +1642,7 @@ typedef union {
|
||||
*/
|
||||
typedef union {
|
||||
struct {
|
||||
/** ls_div_num : HRO; bitpos: [7:0]; default: 0;
|
||||
* clk_hproot is div1 of low-speed clock-source if clck-source is a low-speed
|
||||
* clock-source such as XTAL/FOSC.
|
||||
*/
|
||||
uint32_t ls_div_num:8;
|
||||
/** hs_div_num : HRO; bitpos: [15:8]; default: 2;
|
||||
* clk_hproot is div3 of SPLL if the clock-source is high-speed clock SPLL.
|
||||
*/
|
||||
uint32_t hs_div_num:8;
|
||||
uint32_t reserved_0:16;
|
||||
/** soc_clk_sel : R/W; bitpos: [17:16]; default: 0;
|
||||
* Configures to select the clock source of HP_ROOT_CLK.\\
|
||||
* 0 (default): XTAL_CLK\\
|
||||
@@ -1706,7 +1698,7 @@ typedef union {
|
||||
typedef union {
|
||||
struct {
|
||||
/** cpu_div_num : R/W; bitpos: [7:0]; default: 0;
|
||||
* Set this field to generate clk_cpu driven by clk_hproot. The clk_cpu is
|
||||
* Set this field to generate clk_cpu derived by clk_hproot. The clk_cpu is
|
||||
* div1(default)/div2/div4 of clk_hproot. This field is only available for low-speed
|
||||
* clock-source such as XTAL/FOSC, and should be used together with PCR_AHB_DIV_NUM.
|
||||
*/
|
||||
@@ -1722,7 +1714,7 @@ typedef union {
|
||||
typedef union {
|
||||
struct {
|
||||
/** ahb_div_num : R/W; bitpos: [7:0]; default: 0;
|
||||
* Set this field to generate clk_ahb driven by clk_hproot. The clk_ahb is
|
||||
* Set this field to generate clk_ahb derived by clk_hproot. The clk_ahb is
|
||||
* div1(default)/div2/div4/div8 of clk_hproot. This field is only available for
|
||||
* low-speed clock-source such as XTAL/FOSC, and should be used together with
|
||||
* PCR_CPU_DIV_NUM.
|
||||
@@ -1749,7 +1741,7 @@ typedef union {
|
||||
*/
|
||||
uint32_t apb_decrease_div_num:8;
|
||||
/** apb_div_num : R/W; bitpos: [15:8]; default: 0;
|
||||
* Set as one within (0,1,3) to generate clk_apb driven by clk_ahb. The clk_apb is
|
||||
* Set as one within (0,1,3) to generate clk_apb derived by clk_ahb. The clk_apb is
|
||||
* div1(default)/div2/div4 of clk_ahb.
|
||||
*/
|
||||
uint32_t apb_div_num:8;
|
||||
@@ -1764,47 +1756,47 @@ typedef union {
|
||||
typedef union {
|
||||
struct {
|
||||
/** pll_240m_clk_en : R/W; bitpos: [0]; default: 1;
|
||||
* This field is used to open 240 MHz clock (div2 of SPLL) driven from SPLL. 0: close,
|
||||
* This field is used to open 240 MHz clock (div2 of SPLL) derived from SPLL. 0: close,
|
||||
* 1: open(default). Only available when high-speed clock-source SPLL is active.
|
||||
*/
|
||||
uint32_t pll_240m_clk_en:1;
|
||||
/** pll_160m_clk_en : R/W; bitpos: [1]; default: 1;
|
||||
* This field is used to open 160 MHz clock (div3 of SPLL) driven from SPLL. 0: close,
|
||||
* This field is used to open 160 MHz clock (div3 of SPLL) derived from SPLL. 0: close,
|
||||
* 1: open(default). Only available when high-speed clock-source SPLL is active.
|
||||
*/
|
||||
uint32_t pll_160m_clk_en:1;
|
||||
/** pll_120m_clk_en : R/W; bitpos: [2]; default: 1;
|
||||
* This field is used to open 120 MHz clock (div4 of SPLL) driven from SPLL. 0: close,
|
||||
* This field is used to open 120 MHz clock (div4 of SPLL) derived from SPLL. 0: close,
|
||||
* 1: open(default). Only available when high-speed clock-source SPLL is active.
|
||||
*/
|
||||
uint32_t pll_120m_clk_en:1;
|
||||
/** pll_80m_clk_en : R/W; bitpos: [3]; default: 1;
|
||||
* This field is used to open 80 MHz clock (div6 of SPLL) driven from SPLL. 0: close,
|
||||
* This field is used to open 80 MHz clock (div6 of SPLL) derived from SPLL. 0: close,
|
||||
* 1: open(default). Only available when high-speed clock-source SPLL is active.
|
||||
*/
|
||||
uint32_t pll_80m_clk_en:1;
|
||||
/** pll_60m_clk_en : R/W; bitpos: [4]; default: 1;
|
||||
* This field is used to open 60 MHz clock (div8 of SPLL) driven from SPLL. 0: close,
|
||||
* This field is used to open 60 MHz clock (div8 of SPLL) derived from SPLL. 0: close,
|
||||
* 1: open(default). Only available when high-speed clock-source SPLL is active.
|
||||
*/
|
||||
uint32_t pll_60m_clk_en:1;
|
||||
/** pll_48m_clk_en : R/W; bitpos: [5]; default: 1;
|
||||
* This field is used to open 48 MHz clock (div10 of SPLL) driven from SPLL. 0: close,
|
||||
* This field is used to open 48 MHz clock (div10 of SPLL) derived from SPLL. 0: close,
|
||||
* 1: open(default). Only available when high-speed clock-source SPLL is active.
|
||||
*/
|
||||
uint32_t pll_48m_clk_en:1;
|
||||
/** pll_40m_clk_en : R/W; bitpos: [6]; default: 1;
|
||||
* This field is used to open 40 MHz clock (div12 of SPLL) driven from SPLL. 0: close,
|
||||
* This field is used to open 40 MHz clock (div12 of SPLL) derived from SPLL. 0: close,
|
||||
* 1: open(default). Only available when high-speed clock-source SPLL is active.
|
||||
*/
|
||||
uint32_t pll_40m_clk_en:1;
|
||||
/** pll_20m_clk_en : R/W; bitpos: [7]; default: 1;
|
||||
* This field is used to open 20 MHz clock (div24 of SPLL) driven from SPLL. 0: close,
|
||||
* This field is used to open 20 MHz clock (div24 of SPLL) derived from SPLL. 0: close,
|
||||
* 1: open(default). Only available when high-speed clock-source SPLL is active.
|
||||
*/
|
||||
uint32_t pll_20m_clk_en:1;
|
||||
/** pll_12m_clk_en : R/W; bitpos: [8]; default: 1;
|
||||
* This field is used to open 12 MHz clock (div40 of SPLL) driven from SPLL. 0: close,
|
||||
* This field is used to open 12 MHz clock (div40 of SPLL) derived from SPLL. 0: close,
|
||||
* 1: open(default). Only available when high-speed clock-source SPLL is active.
|
||||
*/
|
||||
uint32_t pll_12m_clk_en:1;
|
||||
|
@@ -58,14 +58,14 @@
|
||||
#define SOC_SECURE_BOOT_SUPPORTED 1
|
||||
// #define SOC_BOD_SUPPORTED 1 // TODO: [ESP32C5] IDF-8647
|
||||
// #define SOC_APM_SUPPORTED 1 // TODO: [ESP32C5] IDF-8614, IDF-8615
|
||||
// #define SOC_PMU_SUPPORTED 1 // TODO: [ESP32C5] IDF-8667
|
||||
#define SOC_PMU_SUPPORTED 1 // TODO: [ESP32C5] IDF-8667
|
||||
// #define SOC_PAU_SUPPORTED 1 // TODO: [ESP32C5] IDF-8638
|
||||
#define SOC_LP_TIMER_SUPPORTED 1
|
||||
// #define SOC_LP_AON_SUPPORTED 1 // TODO: [ESP32C5] IDF-8638
|
||||
#define SOC_LP_PERIPHERALS_SUPPORTED 1
|
||||
// #define SOC_LP_I2C_SUPPORTED 1 // TODO: [ESP32C5] IDF-8634
|
||||
// #define SOC_ULP_LP_UART_SUPPORTED 1 // TODO: [ESP32C5] IDF-8633
|
||||
// #define SOC_CLK_TREE_SUPPORTED 1 // TODO: [ESP32C5] IDF-8642
|
||||
#define SOC_CLK_TREE_SUPPORTED 1
|
||||
// #define SOC_ASSIST_DEBUG_SUPPORTED 1 // TODO: [ESP32C5] IDF-8663
|
||||
// #define SOC_WDT_SUPPORTED 1 // TODO: [ESP32C5] IDF-8650
|
||||
#define SOC_SPI_FLASH_SUPPORTED 1 // TODO: [ESP32C5] IDF-8715
|
||||
@@ -493,8 +493,8 @@
|
||||
#define SOC_UART_FIFO_LEN (128) /*!< The UART hardware FIFO length */
|
||||
#define SOC_LP_UART_FIFO_LEN (16) /*!< The LP UART hardware FIFO length */
|
||||
#define SOC_UART_BITRATE_MAX (5000000) /*!< Max bit rate supported by UART */
|
||||
// #define SOC_UART_SUPPORT_PLL_F80M_CLK (1) /*!< Support PLL_F80M as the clock source */
|
||||
// #define SOC_UART_SUPPORT_RTC_CLK (1) /*!< Support RTC clock as the clock source */ // TODO: [ESP32C5] IDF-8642
|
||||
#define SOC_UART_SUPPORT_PLL_F80M_CLK (1) /*!< Support PLL_F80M as the clock source */
|
||||
#define SOC_UART_SUPPORT_RTC_CLK (1) /*!< Support RTC clock as the clock source */
|
||||
#define SOC_UART_SUPPORT_XTAL_CLK (1) /*!< Support XTAL clock as the clock source */
|
||||
#define SOC_UART_SUPPORT_WAKEUP_INT (1) /*!< Support UART wakeup interrupt */
|
||||
#define SOC_UART_HAS_LP_UART (1) /*!< Support LP UART */
|
||||
@@ -545,12 +545,13 @@
|
||||
// #define SOC_PM_PAU_LINK_NUM (4)
|
||||
|
||||
/*-------------------------- CLOCK SUBSYSTEM CAPS ----------------------------------------*/
|
||||
// #define SOC_CLK_RC_FAST_SUPPORT_CALIBRATION (1) // TODO: IDF-8642
|
||||
#define SOC_CLK_RC_FAST_SUPPORT_CALIBRATION (1)
|
||||
#define SOC_MODEM_CLOCK_IS_INDEPENDENT (1)
|
||||
|
||||
#define SOC_CLK_XTAL32K_SUPPORTED (1) /*!< Support to connect an external low frequency crystal */
|
||||
#define SOC_CLK_OSC_SLOW_SUPPORTED (1) /*!< Support to connect an external oscillator, not a crystal */
|
||||
#define SOC_CLK_RC32K_SUPPORTED (1) /*!< Support an internal 32kHz RC oscillator */
|
||||
#define SOC_CLK_LP_FAST_SUPPORT_XTAL (1) /*!< Support XTAL clock as the LP_FAST clock source */
|
||||
|
||||
#define SOC_RCC_IS_INDEPENDENT 1 /*!< Reset and Clock Control is independent, thanks to the PCR registers */
|
||||
|
||||
|
Reference in New Issue
Block a user