Skip to content

Commit 132444c

Browse files
committed
Merge branch 'feat/support_esp32h21_modem_clock' into 'master'
feat(esp_hw_support): support esp32h21 modem clock Closes PM-348 See merge request espressif/esp-idf!37082
2 parents 548caad + d305628 commit 132444c

File tree

12 files changed

+1768
-1
lines changed

12 files changed

+1768
-1
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
// The LL layer for ESP32-H21 LP CLKRST & LP PERI register operations
8+
9+
#pragma once
10+
11+
#include <stdbool.h>
12+
#include <stdlib.h>
13+
#include "soc/soc.h"
14+
#include "soc/lp_clkrst_struct.h"
15+
#include "soc/lpperi_struct.h"
16+
17+
#ifdef __cplusplus
18+
extern "C" {
19+
#endif
20+
21+
__attribute__((always_inline))
22+
static inline void lp_clkrst_ll_enable_ble_rtc_timer_slow_osc(lp_clkrst_dev_t *hw, bool en)
23+
{
24+
hw->lpperi.clkrst_lp_sel_osc_slow = en;
25+
}
26+
27+
__attribute__((always_inline))
28+
static inline void lp_clkrst_ll_enable_ble_rtc_timer_fast_osc(lp_clkrst_dev_t *hw, bool en)
29+
{
30+
hw->lpperi.clkrst_lp_sel_osc_fast = en;
31+
}
32+
33+
__attribute__((always_inline))
34+
static inline void lp_clkrst_ll_enable_ble_rtc_timer_main_xtal(lp_clkrst_dev_t *hw, bool en)
35+
{
36+
hw->lpperi.clkrst_lp_sel_xtal = en;
37+
}
38+
39+
__attribute__((always_inline))
40+
static inline void lp_clkrst_ll_enable_ble_rtc_timer_32k_xtal(lp_clkrst_dev_t *hw, bool en)
41+
{
42+
hw->lpperi.clkrst_lp_sel_xtal32k = en;
43+
}
44+
45+
__attribute__((always_inline))
46+
static inline void lp_clkrst_ll_set_ble_rtc_timer_divisor_value(lp_clkrst_dev_t *hw, uint32_t value)
47+
{
48+
hw->lpperi.clkrst_lp_bletimer_div_num = value;
49+
}
50+
51+
__attribute__((always_inline))
52+
static inline uint32_t lp_clkrst_ll_get_ble_rtc_timer_divisor_value(lp_clkrst_dev_t *hw)
53+
{
54+
return hw->lpperi.clkrst_lp_bletimer_div_num;
55+
}
56+
57+
__attribute__((always_inline))
58+
static inline void lp_clkrst_ll_select_modem_32k_clock_source(lp_clkrst_dev_t *hw, uint32_t src)
59+
{
60+
hw->lpperi.clkrst_lp_bletimer_32k_sel = src;
61+
}
62+
63+
__attribute__((always_inline))
64+
static inline void _lp_clkrst_ll_enable_rng_clock(bool en)
65+
{
66+
LPPERI.clk_en.rng_ck_en = en;
67+
}
68+
69+
/// LPPERI.clk_en is a shared register, so this function must be used in an atomic way
70+
#define lp_clkrst_ll_enable_rng_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; _lp_clkrst_ll_enable_rng_clock(__VA_ARGS__)
71+
72+
#ifdef __cplusplus
73+
}
74+
#endif
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
// The LL layer for ESP32-H21 MODEM LPCON register operations
8+
9+
#pragma once
10+
11+
#include <stdlib.h>
12+
#include <stdbool.h>
13+
#include "soc/soc.h"
14+
#include "hal/assert.h"
15+
#include "modem/modem_lpcon_struct.h"
16+
#include "hal/modem_clock_types.h"
17+
18+
#ifdef __cplusplus
19+
extern "C" {
20+
#endif
21+
22+
__attribute__((always_inline))
23+
static inline void modem_lpcon_ll_enable_test_clk(modem_lpcon_dev_t *hw, bool en)
24+
{
25+
hw->test_conf.clk_en = en;
26+
}
27+
28+
__attribute__((always_inline))
29+
static inline void modem_lpcon_ll_enable_coex_lpclk_slow_osc(modem_lpcon_dev_t *hw, bool en)
30+
{
31+
hw->coex_lp_clk_conf.clk_coex_lp_sel_osc_slow = en;
32+
}
33+
34+
__attribute__((always_inline))
35+
static inline void modem_lpcon_ll_enable_coex_lpclk_fast_osc(modem_lpcon_dev_t *hw, bool en)
36+
{
37+
hw->coex_lp_clk_conf.clk_coex_lp_sel_osc_fast = en;
38+
}
39+
40+
__attribute__((always_inline))
41+
static inline void modem_lpcon_ll_enable_coex_lpclk_main_xtal(modem_lpcon_dev_t *hw, bool en)
42+
{
43+
hw->coex_lp_clk_conf.clk_coex_lp_sel_xtal = en;
44+
}
45+
46+
__attribute__((always_inline))
47+
static inline void modem_lpcon_ll_enable_coex_lpclk_32k_xtal(modem_lpcon_dev_t *hw, bool en)
48+
{
49+
hw->coex_lp_clk_conf.clk_coex_lp_sel_xtal32k = en;
50+
}
51+
52+
__attribute__((always_inline))
53+
static inline void modem_lpcon_ll_set_coex_lpclk_divisor_value(modem_lpcon_dev_t *hw, uint32_t value)
54+
{
55+
hw->coex_lp_clk_conf.clk_coex_lp_div_num = value;
56+
}
57+
58+
__attribute__((always_inline))
59+
static inline uint32_t modem_lpcon_ll_get_coex_lpclk_divisor_value(modem_lpcon_dev_t *hw)
60+
{
61+
return hw->coex_lp_clk_conf.clk_coex_lp_div_num;
62+
}
63+
64+
__attribute__((always_inline))
65+
static inline void modem_lpcon_ll_enable_coex_clock(modem_lpcon_dev_t *hw, bool en)
66+
{
67+
hw->clk_conf.clk_coex_en = en;
68+
}
69+
70+
__attribute__((always_inline))
71+
static inline void modem_lpcon_ll_enable_fe_mem_clock(modem_lpcon_dev_t *hw, bool en)
72+
{
73+
hw->clk_conf.clk_fe_mem_en = en;
74+
}
75+
76+
__attribute__((always_inline))
77+
static inline void modem_lpcon_ll_enable_coex_force_clock(modem_lpcon_dev_t *hw, bool en)
78+
{
79+
hw->clk_conf_force_on.clk_coex_fo = en;
80+
}
81+
82+
__attribute__((always_inline))
83+
static inline void modem_lpcon_ll_enable_fe_mem_force_clock(modem_lpcon_dev_t *hw, bool en)
84+
{
85+
hw->clk_conf_force_on.clk_fe_mem_fo = en;
86+
}
87+
88+
__attribute__((always_inline))
89+
static inline void modem_lpcon_ll_reset_coex(modem_lpcon_dev_t *hw)
90+
{
91+
hw->rst_conf.rst_coex = 1;
92+
hw->rst_conf.rst_coex = 0;
93+
}
94+
95+
__attribute__((always_inline))
96+
static inline void modem_lpcon_ll_reset_all(modem_lpcon_dev_t *hw)
97+
{
98+
hw->rst_conf.val = 0xf;
99+
hw->rst_conf.val = 0;
100+
}
101+
102+
__attribute__((always_inline))
103+
static inline uint32_t modem_lpcon_ll_get_date(modem_lpcon_dev_t *hw)
104+
{
105+
return hw->date.val;
106+
}
107+
108+
#ifdef __cplusplus
109+
}
110+
#endif

0 commit comments

Comments
 (0)