mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 03:00:34 +03:00
feat(phy): add check for required clock bits during phy enable
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2022-2026 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -62,6 +62,18 @@ void modem_clock_module_enable(periph_module_t module);
|
||||
*/
|
||||
void modem_clock_module_disable(periph_module_t module);
|
||||
|
||||
/**
|
||||
* @brief Gets the clock bitmask associated with the specified modem module.
|
||||
*
|
||||
* This function returns the complete set of clock-enable bits that correspond
|
||||
* to @p module.
|
||||
*
|
||||
* @param module Target shared peripheral clock module.
|
||||
*
|
||||
* @return Bitmask of clock-enable bits for the given module.
|
||||
*/
|
||||
uint32_t modem_clock_module_bits_get(periph_module_t module);
|
||||
|
||||
/**
|
||||
* @brief Reset the mac of modem module
|
||||
*
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "sdkconfig.h"
|
||||
#include "soc/periph_defs.h"
|
||||
|
||||
@@ -167,6 +168,13 @@ void phy_module_enable(void);
|
||||
*/
|
||||
void phy_module_disable(void);
|
||||
|
||||
/**
|
||||
* @brief Checks whether phy module has all bits in @p mask set.
|
||||
*
|
||||
* @return true if all bits in @p mask are set; false otherwise.
|
||||
*/
|
||||
bool phy_module_has_clock_bits(uint32_t mask);
|
||||
|
||||
#undef __PERIPH_CTRL_DEPRECATE_ATTR
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -358,6 +358,29 @@ void IRAM_ATTR modem_clock_module_disable(periph_module_t module)
|
||||
modem_clock_device_disable(MODEM_CLOCK_instance(), deps);
|
||||
}
|
||||
|
||||
uint32_t IRAM_ATTR modem_clock_module_bits_get(periph_module_t module)
|
||||
{
|
||||
assert(IS_MODEM_MODULE(module));
|
||||
uint32_t val = 0;
|
||||
switch (module)
|
||||
{
|
||||
#if SOC_WIFI_SUPPORTED
|
||||
case PERIPH_WIFI_MODULE:
|
||||
#endif
|
||||
#if SOC_BT_SUPPORTED
|
||||
case PERIPH_BT_MODULE:
|
||||
#endif
|
||||
#if SOC_IEEE802154_SUPPORTED
|
||||
case PERIPH_IEEE802154_MODULE:
|
||||
#endif
|
||||
case PERIPH_PHY_MODULE:
|
||||
val = modem_syscon_ll_clk_conf1_get(MODEM_CLOCK_instance()->hal->syscon_dev);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
void modem_clock_deselect_all_module_lp_clock_source(void)
|
||||
{
|
||||
#if SOC_WIFI_SUPPORTED
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#ifdef __PERIPH_CTRL_ALLOW_LEGACY_API
|
||||
#include "hal/clk_gate_ll.h"
|
||||
#endif
|
||||
#include "esp_log.h"
|
||||
|
||||
// TODO: [ESP32C61] IDF-9513, modem support
|
||||
#if SOC_MODEM_CLOCK_IS_INDEPENDENT && SOC_MODEM_CLOCK_SUPPORTED
|
||||
@@ -211,4 +212,23 @@ IRAM_ATTR void phy_module_disable(void)
|
||||
portEXIT_CRITICAL_SAFE(&periph_spinlock);
|
||||
#endif
|
||||
}
|
||||
|
||||
IRAM_ATTR bool phy_module_has_clock_bits(uint32_t mask)
|
||||
{
|
||||
uint32_t val = 0;
|
||||
#if SOC_MODEM_CLOCK_IS_INDEPENDENT
|
||||
val = modem_clock_module_bits_get(PERIPH_PHY_MODULE);
|
||||
#else
|
||||
#if SOC_WIFI_SUPPORTED || SOC_BT_SUPPORTED
|
||||
val = DPORT_REG_READ(periph_ll_get_clk_en_reg(PERIPH_WIFI_BT_COMMON_MODULE));
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
#endif
|
||||
if ((val & mask) != mask) {
|
||||
ESP_LOGW("periph_ctrl", "phy module clock bits 0x%x, required 0x%x", val, mask);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#endif //#if SOC_BT_SUPPORTED || SOC_WIFI_SUPPORTED || SOC_IEEE802154_SUPPORTED
|
||||
|
||||
Reference in New Issue
Block a user