From 3e70dafa0b386b4b3ca146d62e75a920ee024ad3 Mon Sep 17 00:00:00 2001 From: Lou Tianhao Date: Thu, 20 Jun 2024 17:20:29 +0800 Subject: [PATCH] change(soc): update pmu register context structure and driver for esp32c5 --- .../esp_hw_support/port/esp32c5/pmu_param.c | 97 ++++++++++--------- .../port/esp32c5/private_include/pmu_param.h | 7 +- .../soc/esp32c5/include/soc/pmu_struct.h | 39 ++++---- 3 files changed, 75 insertions(+), 68 deletions(-) diff --git a/components/esp_hw_support/port/esp32c5/pmu_param.c b/components/esp_hw_support/port/esp32c5/pmu_param.c index cdcc639ad5..ec443e16fe 100644 --- a/components/esp_hw_support/port/esp32c5/pmu_param.c +++ b/components/esp_hw_support/port/esp32c5/pmu_param.c @@ -195,66 +195,69 @@ const pmu_hp_system_digital_param_t * pmu_hp_system_digital_param_default(pmu_hp } #define PMU_HP_ACTIVE_ANALOG_CONFIG_DEFAULT() { \ - .bias = { \ - .xpd_bias = 1, \ - .dbg_atten = 0x0, \ - .pd_cur = 0, \ - .bias_sleep = 0 \ + .bias = { \ + .xpd_bias = 1, \ + .dbg_atten = 0x0, \ + .pd_cur = 0, \ + .bias_sleep = 0 \ }, \ - .regulator0 = { \ - .lp_dbias_vol = 0xd, \ - .hp_dbias_vol = 0x1c,\ - .dbias_sel = 1, \ - .dbias_init = 1, \ - .slp_mem_xpd = 0, \ - .slp_logic_xpd = 0, \ - .xpd = 1, \ - .slp_mem_dbias = 0, \ - .slp_logic_dbias = 0, \ - .dbias = HP_CALI_DBIAS_DEFAULT \ + .regulator0 = { \ + .slp_connect_en = 0, \ + .lp_dbias_vol = 0xd, \ + .hp_dbias_vol = 0x1c, \ + .dbias_sel = 1, \ + .dbias_init = 1, \ + .slp_mem_xpd = 0, \ + .slp_logic_xpd = 0, \ + .xpd = 1, \ + .slp_mem_dbias = 0, \ + .slp_logic_dbias = 0, \ + .dbias = HP_CALI_DBIAS_DEFAULT \ }, \ - .regulator1 = { \ - .drv_b = 0x0 \ + .regulator1 = { \ + .drv_b = 0x0 \ } \ } #define PMU_HP_MODEM_ANALOG_CONFIG_DEFAULT() { \ - .bias = { \ - .xpd_bias = 0, \ - .dbg_atten = 0x0, \ - .pd_cur = 0, \ - .bias_sleep = 0 \ + .bias = { \ + .xpd_bias = 0, \ + .dbg_atten = 0x0, \ + .pd_cur = 0, \ + .bias_sleep = 0 \ }, \ - .regulator0 = { \ - .slp_mem_xpd = 0, \ - .slp_logic_xpd = 0, \ - .xpd = 1, \ - .slp_mem_dbias = 0, \ - .slp_logic_dbias = 0, \ - .dbias = HP_CALI_DBIAS_DEFAULT \ + .regulator0 = { \ + .slp_connect_en = 0, \ + .slp_mem_xpd = 0, \ + .slp_logic_xpd = 0, \ + .xpd = 1, \ + .slp_mem_dbias = 0, \ + .slp_logic_dbias = 0, \ + .dbias = HP_CALI_DBIAS_DEFAULT \ }, \ - .regulator1 = { \ - .drv_b = 0x0 \ + .regulator1 = { \ + .drv_b = 0x0 \ } \ } #define PMU_HP_SLEEP_ANALOG_CONFIG_DEFAULT() { \ - .bias = { \ - .xpd_bias = 0, \ - .dbg_atten = 0x0, \ - .pd_cur = 0, \ - .bias_sleep = 0 \ + .bias = { \ + .xpd_bias = 0, \ + .dbg_atten = 0x0, \ + .pd_cur = 0, \ + .bias_sleep = 0 \ }, \ - .regulator0 = { \ - .slp_mem_xpd = 0, \ - .slp_logic_xpd = 0, \ - .xpd = 1, \ - .slp_mem_dbias = 0, \ - .slp_logic_dbias = 0, \ - .dbias = 1 \ + .regulator0 = { \ + .slp_connect_en = 0, \ + .slp_mem_xpd = 0, \ + .slp_logic_xpd = 0, \ + .xpd = 1, \ + .slp_mem_dbias = 0, \ + .slp_logic_dbias = 0, \ + .dbias = 1 \ }, \ - .regulator1 = { \ - .drv_b = 0x0 \ + .regulator1 = { \ + .drv_b = 0x0 \ } \ } @@ -269,7 +272,7 @@ const pmu_hp_system_analog_param_t * pmu_hp_system_analog_param_default(pmu_hp_m return &hp_analog[mode]; } -#define PMU_HP_RETENTION_REGDMA_CONFIG(dir, entry) ((((dir)<<2) | (entry & 0x3)) & 0x7) +#define PMU_HP_RETENTION_REGDMA_CONFIG(dir, entry) ((((dir)<<4) | (entry & 0xf)) & 0x1f) #define PMU_HP_ACTIVE_RETENTION_CONFIG_DEFAULT() { \ .retention = { \ diff --git a/components/esp_hw_support/port/esp32c5/private_include/pmu_param.h b/components/esp_hw_support/port/esp32c5/private_include/pmu_param.h index 7153ef4846..a330e4ab91 100644 --- a/components/esp_hw_support/port/esp32c5/private_include/pmu_param.h +++ b/components/esp_hw_support/port/esp32c5/private_include/pmu_param.h @@ -169,7 +169,12 @@ typedef struct { uint32_t bias_sleep: 1; }; struct { - uint32_t reserved1 : 16; + uint32_t reserved1 : 3; /* Only HP_ACTIVE modem under hp system is valid */ + uint32_t dbias_init : 1; /* Only HP_ACTIVE modem under hp system is valid */ + uint32_t lp_dbias_vol : 5; /* Only HP_ACTIVE modem under hp system is valid */ + uint32_t hp_dbias_vol : 5; /* Only HP_ACTIVE modem under hp system is valid */ + uint32_t dbias_sel : 1; /* Only HP_ACTIVE modem under hp system is valid */ + uint32_t slp_connect_en : 1; uint32_t slp_mem_xpd : 1; uint32_t slp_logic_xpd : 1; uint32_t xpd : 1; diff --git a/components/soc/esp32c5/include/soc/pmu_struct.h b/components/soc/esp32c5/include/soc/pmu_struct.h index ef9f62e81b..67f6269fc3 100644 --- a/components/soc/esp32c5/include/soc/pmu_struct.h +++ b/components/soc/esp32c5/include/soc/pmu_struct.h @@ -87,10 +87,9 @@ typedef union { uint32_t reserved2 : 1; uint32_t hp_sleep2active_backup_clk_sel : 2; uint32_t hp_modem2active_backup_clk_sel : 2; - uint32_t reserved3 : 2; - uint32_t hp_sleep2active_backup_mode : 3; - uint32_t hp_modem2active_backup_mode : 3; - uint32_t reserved4 : 3; + uint32_t hp_sleep2active_backup_mode : 5; + uint32_t hp_modem2active_backup_mode : 5; + uint32_t reserved4 : 1; uint32_t hp_sleep2active_backup_en : 1; uint32_t hp_modem2active_backup_en : 1; uint32_t reserved5 : 1; @@ -104,8 +103,8 @@ typedef union { uint32_t reserved8 : 2; uint32_t hp_sleep2modem_backup_clk_sel : 2; uint32_t reserved9 : 4; - uint32_t hp_sleep2modem_backup_mode : 3; - uint32_t reserved10 : 6; + uint32_t hp_sleep2modem_backup_mode : 5; + uint32_t reserved10 : 4; uint32_t hp_sleep2modem_backup_en : 1; uint32_t reserved11 : 2; }; @@ -120,10 +119,8 @@ typedef union { uint32_t reserved14 : 2; uint32_t hp_modem2sleep_backup_clk_sel : 2; uint32_t hp_active2sleep_backup_clk_sel : 2; - uint32_t reserved15 : 3; - uint32_t hp_modem2sleep_backup_mode : 3; - uint32_t hp_active2sleep_backup_mode : 3; - uint32_t reserved16 : 1; + uint32_t hp_modem2sleep_backup_mode : 5; + uint32_t hp_active2sleep_backup_mode : 5; uint32_t hp_modem2sleep_backup_en : 1; uint32_t hp_active2sleep_backup_en : 1; }; @@ -144,11 +141,12 @@ typedef union { typedef union { struct { - uint32_t reserved0 : 4; /* Only HP_ACTIVE modem under hp system is valid */ + uint32_t reserved0 : 3; /* Only HP_ACTIVE modem under hp system is valid */ + uint32_t dbias_init : 1; /* Only HP_ACTIVE modem under hp system is valid */ uint32_t lp_dbias_vol : 5; /* Only HP_ACTIVE modem under hp system is valid */ uint32_t hp_dbias_vol : 5; /* Only HP_ACTIVE modem under hp system is valid */ uint32_t dbias_sel : 1; /* Only HP_ACTIVE modem under hp system is valid */ - uint32_t dbias_init : 1; /* Only HP_ACTIVE modem under hp system is valid */ + uint32_t slp_connect_en : 1; uint32_t slp_mem_xpd : 1; uint32_t slp_logic_xpd : 1; uint32_t xpd : 1; @@ -378,10 +376,10 @@ typedef union { typedef union { struct { - uint32_t reserved0 : 9; - uint32_t powerdown_timer: 7; - uint32_t powerup_timer : 7; - uint32_t wait_timer : 9; + uint32_t lp_iso_wait_timer : 8; + uint32_t lp_rst_wait_timer : 8; + uint32_t hp_iso_wait_timer : 8; + uint32_t hp_rst_wait_timer : 8; }; uint32_t val; } pmu_power_wait_timer2_reg_t; @@ -565,7 +563,10 @@ typedef union { typedef union { struct { - uint32_t reserved0 : 26; + uint32_t reserved0 : 23; + uint32_t xpd_ckgen5g : 1; + uint32_t xpd_tc5g_i2c : 1; + uint32_t xpd_rx5g_i2c : 1; uint32_t perif_i2c_rstb: 1; uint32_t xpd_perif_i2c : 1; uint32_t xpd_txrf_i2c : 1; @@ -754,9 +755,7 @@ typedef struct pmu_dev_t{ extern pmu_dev_t PMU; #ifndef __cplusplus - -//_Static_assert(offsetof(pmu_dev_t, reserved) == (PMU_VDD_SPI_STATUS_REG - DR_REG_PMU_BASE) + 4, "Invalid size of pmu_dev_t structure"); TODO IDF-8643 - +_Static_assert(sizeof(pmu_dev_t) == 0x1ac, "Invalid size of pmu_dev_t structure"); #endif #ifdef __cplusplus