feat(ieee802154): register power_down/power_up callback for esp32c6

This commit is contained in:
xiaqilin
2023-11-01 12:01:01 +08:00
committed by cjin
parent e98e291601
commit 5a77f87986
7 changed files with 37 additions and 6 deletions

View File

@@ -30,6 +30,7 @@
#include "esp_pm.h" #include "esp_pm.h"
#include "esp_private/esp_clk.h" #include "esp_private/esp_clk.h"
#include "esp_private/sleep_retention.h" #include "esp_private/sleep_retention.h"
#include "esp_private/sleep_modem.h"
static bool s_rf_closed = false; static bool s_rf_closed = false;
#if SOC_PM_RETENTION_HAS_CLOCK_BUG #if SOC_PM_RETENTION_HAS_CLOCK_BUG
#define IEEE802154_LINK_OWNER ENTRY(3) #define IEEE802154_LINK_OWNER ENTRY(3)
@@ -613,6 +614,12 @@ void ieee802154_enable(void)
void ieee802154_disable(void) void ieee802154_disable(void)
{ {
modem_clock_module_disable(ieee802154_periph.module); modem_clock_module_disable(ieee802154_periph.module);
#if CONFIG_FREERTOS_USE_TICKLESS_IDLE
#if SOC_PM_RETENTION_HAS_CLOCK_BUG && CONFIG_MAC_BB_PD
esp_pm_unregister_mac_bb_module_prepare_callback(mac_bb_power_down_prepare,
mac_bb_power_up_prepare);
#endif // SOC_PM_RETENTION_HAS_CLOCK_BUG && CONFIG_MAC_BB_PD
#endif // CONFIG_FREERTOS_USE_TICKLESS_IDLE
ieee802154_set_state(IEEE802154_STATE_DISABLE); ieee802154_set_state(IEEE802154_STATE_DISABLE);
} }
@@ -788,6 +795,12 @@ static esp_err_t ieee802154_sleep_init(void)
err = sleep_retention_entries_create(ieee802154_mac_regs_retention, ARRAY_SIZE(ieee802154_mac_regs_retention), REGDMA_LINK_PRI_7, SLEEP_RETENTION_MODULE_802154_MAC); err = sleep_retention_entries_create(ieee802154_mac_regs_retention, ARRAY_SIZE(ieee802154_mac_regs_retention), REGDMA_LINK_PRI_7, SLEEP_RETENTION_MODULE_802154_MAC);
ESP_RETURN_ON_ERROR(err, IEEE802154_TAG, "failed to allocate memory for ieee802154 mac retention"); ESP_RETURN_ON_ERROR(err, IEEE802154_TAG, "failed to allocate memory for ieee802154 mac retention");
ESP_LOGI(IEEE802154_TAG, "ieee802154 mac sleep retention initialization"); ESP_LOGI(IEEE802154_TAG, "ieee802154 mac sleep retention initialization");
#if SOC_PM_RETENTION_HAS_CLOCK_BUG && CONFIG_MAC_BB_PD
esp_pm_register_mac_bb_module_prepare_callback(mac_bb_power_down_prepare,
mac_bb_power_up_prepare);
#endif // SOC_PM_RETENTION_HAS_CLOCK_BUG && CONFIG_MAC_BB_PD
#endif #endif
return err; return err;
} }

View File

@@ -45,8 +45,15 @@ examples/openthread/ot_rcp:
reason: only test on esp32c6 reason: only test on esp32c6
<<: *openthread_dependencies <<: *openthread_dependencies
# To add support for the ESP32-C6 in TZ-302 examples/openthread/ot_sleepy_device/deep_sleep:
examples/openthread/ot_sleepy_device:
enable: enable:
- if: IDF_TARGET in ["esp32h2"] - if: IDF_TARGET in ["esp32h2"]
disable_test:
- if: IDF_TARGET == "esp32h2"
temporary: true
reason: Unsupport
examples/openthread/ot_sleepy_device/light_sleep:
enable:
- if: IDF_TARGET in ["esp32h2", "esp32c6"]
<<: [*openthread_dependencies, *openthread_sleep_dependencies] <<: [*openthread_dependencies, *openthread_sleep_dependencies]

View File

@@ -1,6 +1,5 @@
| Supported Targets | ESP32-H2 | | Supported Targets | ESP32-C6 | ESP32-H2 |
| ----------------- | -------- | | ----------------- | -------- | -------- |
# OpenThread Sleepy Device Example # OpenThread Sleepy Device Example
The example demonstrates the Thread Sleepy End Device (SED), the device will enter [Light Sleep mode](https://docs.espressif.com/projects/esp-idf/en/latest/esp32h2/api-reference/system/sleep_modes.html#sleep-modes) during idle state. The example demonstrates the Thread Sleepy End Device (SED), the device will enter [Light Sleep mode](https://docs.espressif.com/projects/esp-idf/en/latest/esp32h2/api-reference/system/sleep_modes.html#sleep-modes) during idle state.

View File

@@ -3,4 +3,4 @@ CONFIG_IDF_TARGET_ESP32C6=y
CONFIG_OPENTHREAD_NETWORK_CHANNEL=12 CONFIG_OPENTHREAD_NETWORK_CHANNEL=12
CONFIG_OPENTHREAD_NETWORK_MASTERKEY="aabbccddeeff00112233445566778899" CONFIG_OPENTHREAD_NETWORK_MASTERKEY="aabbccddeeff00112233445566778899"
CONFIG_ESP_SLEEP_DEBUG=y CONFIG_ESP_SLEEP_DEBUG=y
CONFIG_LOG_DEFAULT_LEVEL_DEBUG=y CONFIG_LOG_MAXIMUM_LEVEL_DEBUG=y

View File

@@ -0,0 +1,7 @@
CONFIG_IDF_TARGET="esp32c6"
#
# Sleep Config
#
CONFIG_ESP_PHY_MAC_BB_PD=y
# end of Sleep Config

View File

@@ -0,0 +1 @@
CONFIG_IDF_TARGET="esp32h2"

View File

@@ -558,6 +558,10 @@ def test_TCP_NAT64(Init_interface:bool, dut: Tuple[IdfDut, IdfDut, IdfDut]) -> N
@pytest.mark.openthread_sleep @pytest.mark.openthread_sleep
@pytest.mark.parametrize( @pytest.mark.parametrize(
'config, count, app_path, target', [ 'config, count, app_path, target', [
('cli_h2|sleepy_c6', 2,
f'{os.path.join(os.path.dirname(__file__), "ot_cli")}'
f'|{os.path.join(os.path.dirname(__file__), "ot_sleepy_device")}',
'esp32h2|esp32c6'),
('cli_c6|sleepy_h2', 2, ('cli_c6|sleepy_h2', 2,
f'{os.path.join(os.path.dirname(__file__), "ot_cli")}' f'{os.path.join(os.path.dirname(__file__), "ot_cli")}'
f'|{os.path.join(os.path.dirname(__file__), "ot_sleepy_device")}', f'|{os.path.join(os.path.dirname(__file__), "ot_sleepy_device")}',