|
5 | 5 | */ |
6 | 6 |
|
7 | 7 | #include "sdkconfig.h" |
| 8 | +#include "soc/soc_caps.h" |
8 | 9 | #include "phy_init_data.h" |
| 10 | +#include "esp_private/phy.h" |
| 11 | +#include "esp_check.h" |
9 | 12 |
|
10 | 13 |
|
11 | 14 | const char __attribute__((section(".rodata"))) phy_init_magic_pre[] = PHY_INIT_MAGIC; |
@@ -273,3 +276,69 @@ const esp_phy_init_data_t phy_init_data= { { |
273 | 276 | } }; |
274 | 277 |
|
275 | 278 | const char __attribute__((section(".rodata"))) phy_init_magic_post[] = PHY_INIT_MAGIC; |
| 279 | + |
| 280 | +#if SOC_PM_MODEM_RETENTION_BY_REGDMA && CONFIG_MAC_BB_PD |
| 281 | + |
| 282 | +#include "esp_private/sleep_retention.h" |
| 283 | + |
| 284 | +static const char* TAG = "phy_sleep"; |
| 285 | + |
| 286 | +static esp_err_t sleep_retention_wifi_bb_init(void *arg) |
| 287 | +{ |
| 288 | + #define N_REGS_WIFI_AGC() (126) |
| 289 | + #define N_REGS_WIFI_TX() (20) |
| 290 | + #define N_REGS_WIFI_NRX() (141) |
| 291 | + #define N_REGS_WIFI_BB() (63) |
| 292 | + #define N_REGS_WIFI_BRX() (39) |
| 293 | + #define N_REGS_WIFI_FE_COEX() (19) |
| 294 | + #define N_REGS_WIFI_FE_DATA() (31) |
| 295 | + #define N_REGS_WIFI_FE_CTRL() (55) |
| 296 | + |
| 297 | + const static sleep_retention_entries_config_t bb_regs_retention[] = { |
| 298 | + [0] = { .config = REGDMA_LINK_CONTINUOUS_INIT(0x0b00, 0x600a7000, 0x600a7000, N_REGS_WIFI_AGC(), 0, 0), .owner = BIT(0) | BIT(1) }, /* AGC */ |
| 299 | + [1] = { .config = REGDMA_LINK_CONTINUOUS_INIT(0x0b01, 0x600a7400, 0x600a7400, N_REGS_WIFI_TX(), 0, 0), .owner = BIT(0) | BIT(1) }, /* TX */ |
| 300 | + [2] = { .config = REGDMA_LINK_CONTINUOUS_INIT(0x0b02, 0x600a7800, 0x600a7800, N_REGS_WIFI_NRX(), 0, 0), .owner = BIT(0) | BIT(1) }, /* NRX */ |
| 301 | + [3] = { .config = REGDMA_LINK_CONTINUOUS_INIT(0x0b03, 0x600a7c00, 0x600a7c00, N_REGS_WIFI_BB(), 0, 0), .owner = BIT(0) | BIT(1) }, /* BB */ |
| 302 | + [4] = { .config = REGDMA_LINK_CONTINUOUS_INIT(0x0b05, 0x600a0000, 0x600a0000, N_REGS_WIFI_FE_COEX(), 0, 0), .owner = BIT(0) | BIT(1) }, /* FE COEX */ |
| 303 | + [5] = { .config = REGDMA_LINK_CONTINUOUS_INIT(0x0b06, 0x600a8000, 0x600a8000, N_REGS_WIFI_BRX(), 0, 0), .owner = BIT(0) | BIT(1) }, /* BRX */ |
| 304 | + [6] = { .config = REGDMA_LINK_CONTINUOUS_INIT(0x0b07, 0x600a0400, 0x600a0400, N_REGS_WIFI_FE_DATA(), 0, 0), .owner = BIT(0) | BIT(1) }, /* FE DATA */ |
| 305 | + [7] = { .config = REGDMA_LINK_CONTINUOUS_INIT(0x0b08, 0x600a0800, 0x600a0800, N_REGS_WIFI_FE_CTRL(), 0, 0), .owner = BIT(0) | BIT(1) }, /* FE CTRL */ |
| 306 | + [8] = { .config = REGDMA_LINK_CONTINUOUS_INIT(0x0b09, 0x600a0c00, 0x600a0c00, 20, 0, 0), .owner = BIT(0) | BIT(1) } /* FE WIFI DATA */ |
| 307 | + }; |
| 308 | + esp_err_t err = sleep_retention_entries_create(bb_regs_retention, ARRAY_SIZE(bb_regs_retention), 3, SLEEP_RETENTION_MODULE_WIFI_BB); |
| 309 | + ESP_RETURN_ON_ERROR(err, TAG, "failed to allocate memory for modem (%s) retention", "WiFi BB"); |
| 310 | + ESP_LOGD(TAG, "WiFi BB sleep retention initialization"); |
| 311 | + return ESP_OK; |
| 312 | +} |
| 313 | + |
| 314 | +void esp_phy_sleep_data_init(void) |
| 315 | +{ |
| 316 | + sleep_retention_module_init_param_t init_param = { |
| 317 | + .cbs = { .create = { .handle = sleep_retention_wifi_bb_init, .arg = NULL } }, |
| 318 | + .depends = RETENTION_MODULE_BITMAP_INIT(CLOCK_MODEM) |
| 319 | + }; |
| 320 | + esp_err_t err = sleep_retention_module_init(SLEEP_RETENTION_MODULE_WIFI_BB, &init_param); |
| 321 | + if (err != ESP_OK) { |
| 322 | + ESP_LOGW(TAG, "WiFi BB sleep retention init failed"); |
| 323 | + return; |
| 324 | + } |
| 325 | + err = sleep_retention_module_allocate(SLEEP_RETENTION_MODULE_WIFI_BB); |
| 326 | + if (err != ESP_OK) { |
| 327 | + ESP_LOGW(TAG, "failed to allocate sleep retention linked list for wifi bb retention"); |
| 328 | + } |
| 329 | +} |
| 330 | + |
| 331 | +void esp_phy_sleep_data_deinit(void) |
| 332 | +{ |
| 333 | + esp_err_t err = sleep_retention_module_free(SLEEP_RETENTION_MODULE_WIFI_BB); |
| 334 | + if (err != ESP_OK) { |
| 335 | + ESP_LOGW(TAG, "failed to free sleep retention linked list for wifi bb retention"); |
| 336 | + return; |
| 337 | + } |
| 338 | + err = sleep_retention_module_deinit(SLEEP_RETENTION_MODULE_WIFI_BB); |
| 339 | + if (err != ESP_OK) { |
| 340 | + ESP_LOGW(TAG, "WiFi BB sleep retention deinit failed"); |
| 341 | + } |
| 342 | +} |
| 343 | + |
| 344 | +#endif /* SOC_PM_MODEM_RETENTION_BY_REGDMA && CONFIG_MAC_BB_PD */ |
0 commit comments