Skip to content

Commit

Permalink
Merge branch 'bugfix/add_protection_for_mac_rst' into 'master'
Browse files Browse the repository at this point in the history
esp_wifi: add protection for mac reset

Closes BT-2903

See merge request espressif/esp-idf!20828
  • Loading branch information
jack0c committed Nov 1, 2022
2 parents ccc7846 + 57c394c commit e5dc958
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 19 deletions.
3 changes: 1 addition & 2 deletions components/esp_wifi/esp32/esp_adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -515,8 +515,7 @@ static void IRAM_ATTR timer_arm_us_wrapper(void *ptimer, uint32_t us, bool repea

static void wifi_reset_mac_wrapper(void)
{
DPORT_SET_PERI_REG_MASK(DPORT_CORE_RST_EN_REG, DPORT_WIFIMAC_RST);
DPORT_CLEAR_PERI_REG_MASK(DPORT_CORE_RST_EN_REG, DPORT_WIFIMAC_RST);
periph_module_reset(PERIPH_WIFI_MODULE);
}

static void wifi_clock_enable_wrapper(void)
Expand Down
6 changes: 1 addition & 5 deletions components/esp_wifi/esp32c2/esp_adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -392,24 +392,20 @@ static void IRAM_ATTR timer_arm_us_wrapper(void *ptimer, uint32_t us, bool repea

static void wifi_reset_mac_wrapper(void)
{
SET_PERI_REG_MASK(SYSCON_WIFI_RST_EN_REG, SYSTEM_MAC_RST);
CLEAR_PERI_REG_MASK(SYSCON_WIFI_RST_EN_REG, SYSTEM_MAC_RST);
periph_module_reset(PERIPH_WIFI_MODULE);
}

static void IRAM_ATTR wifi_rtc_enable_iso_wrapper(void)
{
#if CONFIG_MAC_BB_PD
esp_mac_bb_power_down();
SET_PERI_REG_MASK(SYSCON_WIFI_RST_EN_REG, SYSTEM_MAC_RST);
#endif
}

static void IRAM_ATTR wifi_rtc_disable_iso_wrapper(void)
{
#if CONFIG_MAC_BB_PD
esp_mac_bb_power_up();
SET_PERI_REG_MASK(SYSCON_WIFI_RST_EN_REG, SYSTEM_MAC_RST);
CLEAR_PERI_REG_MASK(SYSCON_WIFI_RST_EN_REG, SYSTEM_MAC_RST);
#endif
}

Expand Down
6 changes: 1 addition & 5 deletions components/esp_wifi/esp32c3/esp_adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -395,24 +395,20 @@ static void IRAM_ATTR timer_arm_us_wrapper(void *ptimer, uint32_t us, bool repea

static void wifi_reset_mac_wrapper(void)
{
SET_PERI_REG_MASK(SYSCON_WIFI_RST_EN_REG, SYSTEM_WIFIMAC_RST);
CLEAR_PERI_REG_MASK(SYSCON_WIFI_RST_EN_REG, SYSTEM_WIFIMAC_RST);
periph_module_reset(PERIPH_WIFI_MODULE);
}

static void IRAM_ATTR wifi_rtc_enable_iso_wrapper(void)
{
#if CONFIG_MAC_BB_PD
esp_mac_bb_power_down();
SET_PERI_REG_MASK(SYSCON_WIFI_RST_EN_REG, SYSTEM_WIFIMAC_RST);
#endif
}

static void IRAM_ATTR wifi_rtc_disable_iso_wrapper(void)
{
#if CONFIG_MAC_BB_PD
esp_mac_bb_power_up();
SET_PERI_REG_MASK(SYSCON_WIFI_RST_EN_REG, SYSTEM_WIFIMAC_RST);
CLEAR_PERI_REG_MASK(SYSCON_WIFI_RST_EN_REG, SYSTEM_WIFIMAC_RST);
#endif
}

Expand Down
3 changes: 1 addition & 2 deletions components/esp_wifi/esp32s2/esp_adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -504,8 +504,7 @@ static void IRAM_ATTR timer_arm_us_wrapper(void *ptimer, uint32_t us, bool repea

static void wifi_reset_mac_wrapper(void)
{
DPORT_SET_PERI_REG_MASK(DPORT_CORE_RST_EN_REG, DPORT_WIFIMAC_RST);
DPORT_CLEAR_PERI_REG_MASK(DPORT_CORE_RST_EN_REG, DPORT_WIFIMAC_RST);
periph_module_reset(PERIPH_WIFI_MODULE);
}

static void wifi_clock_enable_wrapper(void)
Expand Down
6 changes: 1 addition & 5 deletions components/esp_wifi/esp32s3/esp_adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -507,24 +507,20 @@ static void IRAM_ATTR timer_arm_us_wrapper(void *ptimer, uint32_t us, bool repea

static void wifi_reset_mac_wrapper(void)
{
SET_PERI_REG_MASK(SYSCON_WIFI_RST_EN_REG, SYSTEM_WIFIMAC_RST);
CLEAR_PERI_REG_MASK(SYSCON_WIFI_RST_EN_REG, SYSTEM_WIFIMAC_RST);
periph_module_reset(PERIPH_WIFI_MODULE);
}

static void IRAM_ATTR wifi_rtc_enable_iso_wrapper(void)
{
#if CONFIG_MAC_BB_PD
esp_mac_bb_power_down();
SET_PERI_REG_MASK(SYSCON_WIFI_RST_EN_REG, SYSTEM_WIFIMAC_RST);
#endif
}

static void IRAM_ATTR wifi_rtc_disable_iso_wrapper(void)
{
#if CONFIG_MAC_BB_PD
esp_mac_bb_power_up();
SET_PERI_REG_MASK(SYSCON_WIFI_RST_EN_REG, SYSTEM_WIFIMAC_RST);
CLEAR_PERI_REG_MASK(SYSCON_WIFI_RST_EN_REG, SYSTEM_WIFIMAC_RST);
#endif
}

Expand Down
2 changes: 2 additions & 0 deletions components/hal/esp32/include/hal/clk_gate_ll.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ static inline uint32_t periph_ll_get_rst_en_mask(periph_module_t periph, bool en
switch (periph) {
case PERIPH_LEDC_MODULE:
return DPORT_LEDC_RST;
case PERIPH_WIFI_MODULE:
return DPORT_WIFIMAC_RST;
case PERIPH_UART0_MODULE:
return DPORT_UART_RST;
case PERIPH_UART1_MODULE:
Expand Down
2 changes: 2 additions & 0 deletions components/hal/esp32c2/include/hal/clk_gate_ll.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ static inline uint32_t periph_ll_get_rst_en_mask(periph_module_t periph, bool en
return SYSTEM_APB_SARADC_RST;
case PERIPH_LEDC_MODULE:
return SYSTEM_LEDC_RST;
case PERIPH_WIFI_MODULE:
return SYSTEM_MAC_RST;
case PERIPH_UART0_MODULE:
return SYSTEM_UART_RST;
case PERIPH_UART1_MODULE:
Expand Down
2 changes: 2 additions & 0 deletions components/hal/esp32c3/include/hal/clk_gate_ll.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ static inline uint32_t periph_ll_get_rst_en_mask(periph_module_t periph, bool en
return SYSTEM_RMT_RST;
case PERIPH_LEDC_MODULE:
return SYSTEM_LEDC_RST;
case PERIPH_WIFI_MODULE:
return SYSTEM_WIFIMAC_RST;
case PERIPH_BT_MODULE:
return (SYSTEM_BTBB_RST | SYSTEM_BTBB_REG_RST | SYSTEM_RW_BTMAC_RST | SYSTEM_RW_BTLP_RST | SYSTEM_RW_BTMAC_REG_RST | SYSTEM_RW_BTLP_REG_RST);
case PERIPH_UART0_MODULE:
Expand Down
2 changes: 2 additions & 0 deletions components/hal/esp32s2/include/hal/clk_gate_ll.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ static inline uint32_t periph_ll_get_rst_en_mask(periph_module_t periph, bool en
return DPORT_APB_SARADC_RST;
case PERIPH_LEDC_MODULE:
return DPORT_LEDC_RST;
case PERIPH_WIFI_MODULE:
return DPORT_WIFIMAC_RST;
case PERIPH_UART0_MODULE:
return DPORT_UART_RST;
case PERIPH_UART1_MODULE:
Expand Down
2 changes: 2 additions & 0 deletions components/hal/esp32s3/include/hal/clk_gate_ll.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ static inline uint32_t periph_ll_get_rst_en_mask(periph_module_t periph, bool en
return SYSTEM_RMT_RST;
case PERIPH_LEDC_MODULE:
return SYSTEM_LEDC_RST;
case PERIPH_WIFI_MODULE:
return SYSTEM_WIFIMAC_RST;
case PERIPH_BT_MODULE:
return (SYSTEM_BTBB_RST | SYSTEM_BTBB_REG_RST | SYSTEM_RW_BTMAC_RST | SYSTEM_RW_BTLP_RST | SYSTEM_RW_BTMAC_REG_RST | SYSTEM_RW_BTLP_REG_RST);
case PERIPH_UART0_MODULE:
Expand Down

0 comments on commit e5dc958

Please sign in to comment.