Skip to content

Commit aa753e6

Browse files
authored
Merge branch 'main' into feature-credentials-size
2 parents ef7e3cb + ba1d06f commit aa753e6

File tree

7 files changed

+310
-21
lines changed

7 files changed

+310
-21
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
* Copyright (c) 2024 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/* Only GPIOs 1..11 are supported for PORT1 in nRF54H20DK board, for now
8+
* remove this as Wi-Fi SR co-existence is not yet supported on this board.
9+
* The external SR RF switch may not even be present on this board.
10+
*/
11+
&nrf70 {
12+
/delete-property/ srrf-switch-gpios;
13+
};

drivers/clock_control/clock_control_nrf2_hfxo.c

Lines changed: 97 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ struct dev_data_hfxo {
2121
onoff_notify_fn notify;
2222
struct k_timer timer;
2323
sys_snode_t hfxo_node;
24+
#if defined(CONFIG_ZERO_LATENCY_IRQS)
25+
uint16_t request_count;
26+
#endif /* CONFIG_ZERO_LATENCY_IRQS */
2427
};
2528

2629
struct dev_config_hfxo {
@@ -29,6 +32,23 @@ struct dev_config_hfxo {
2932
k_timeout_t start_up_time;
3033
};
3134

35+
#if defined(CONFIG_ZERO_LATENCY_IRQS)
36+
static uint32_t full_irq_lock(void)
37+
{
38+
uint32_t mcu_critical_state;
39+
40+
mcu_critical_state = __get_PRIMASK();
41+
__disable_irq();
42+
43+
return mcu_critical_state;
44+
}
45+
46+
static void full_irq_unlock(uint32_t mcu_critical_state)
47+
{
48+
__set_PRIMASK(mcu_critical_state);
49+
}
50+
#endif /* CONFIG_ZERO_LATENCY_IRQS */
51+
3252
static void hfxo_start_up_timer_handler(struct k_timer *timer)
3353
{
3454
struct dev_data_hfxo *dev_data =
@@ -48,6 +68,40 @@ static void hfxo_start_up_timer_handler(struct k_timer *timer)
4868
}
4969
}
5070

71+
static void start_hfxo(struct dev_data_hfxo *dev_data)
72+
{
73+
nrf_lrcconf_event_clear(NRF_LRCCONF010, NRF_LRCCONF_EVENT_HFXOSTARTED);
74+
soc_lrcconf_poweron_request(&dev_data->hfxo_node, NRF_LRCCONF_POWER_MAIN);
75+
nrf_lrcconf_task_trigger(NRF_LRCCONF010, NRF_LRCCONF_TASK_REQHFXO);
76+
}
77+
78+
static void request_hfxo(struct dev_data_hfxo *dev_data)
79+
{
80+
#if defined(CONFIG_ZERO_LATENCY_IRQS)
81+
unsigned int key;
82+
83+
key = full_irq_lock();
84+
if (dev_data->request_count == 0) {
85+
start_hfxo(dev_data);
86+
}
87+
88+
dev_data->request_count++;
89+
full_irq_unlock(key);
90+
#else
91+
start_hfxo(dev_data);
92+
#endif /* CONFIG_ZERO_LATENCY_IRQS */
93+
}
94+
95+
#if IS_ENABLED(CONFIG_ZERO_LATENCY_IRQS)
96+
void nrf_clock_control_hfxo_request(void)
97+
{
98+
const struct device *dev = DEVICE_DT_INST_GET(0);
99+
struct dev_data_hfxo *dev_data = dev->data;
100+
101+
request_hfxo(dev_data);
102+
}
103+
#endif /* CONFIG_ZERO_LATENCY_IRQS */
104+
51105
static void onoff_start_hfxo(struct onoff_manager *mgr, onoff_notify_fn notify)
52106
{
53107
struct dev_data_hfxo *dev_data =
@@ -56,10 +110,7 @@ static void onoff_start_hfxo(struct onoff_manager *mgr, onoff_notify_fn notify)
56110
const struct dev_config_hfxo *dev_config = dev->config;
57111

58112
dev_data->notify = notify;
59-
60-
nrf_lrcconf_event_clear(NRF_LRCCONF010, NRF_LRCCONF_EVENT_HFXOSTARTED);
61-
soc_lrcconf_poweron_request(&dev_data->hfxo_node, NRF_LRCCONF_POWER_MAIN);
62-
nrf_lrcconf_task_trigger(NRF_LRCCONF010, NRF_LRCCONF_TASK_REQHFXO);
113+
request_hfxo(dev_data);
63114

64115
/* Due to a hardware issue, the HFXOSTARTED event is currently
65116
* unreliable. Hence the timer is used to simply wait the expected
@@ -68,13 +119,53 @@ static void onoff_start_hfxo(struct onoff_manager *mgr, onoff_notify_fn notify)
68119
k_timer_start(&dev_data->timer, dev_config->start_up_time, K_NO_WAIT);
69120
}
70121

122+
static void stop_hfxo(struct dev_data_hfxo *dev_data)
123+
{
124+
nrf_lrcconf_task_trigger(NRF_LRCCONF010, NRF_LRCCONF_TASK_STOPREQHFXO);
125+
soc_lrcconf_poweron_release(&dev_data->hfxo_node, NRF_LRCCONF_POWER_MAIN);
126+
}
127+
128+
static void release_hfxo(struct dev_data_hfxo *dev_data)
129+
{
130+
#if IS_ENABLED(CONFIG_ZERO_LATENCY_IRQS)
131+
unsigned int key;
132+
133+
key = full_irq_lock();
134+
if (dev_data->request_count < 1) {
135+
full_irq_unlock(key);
136+
/* Misuse of the API, release without request? */
137+
__ASSERT_NO_MSG(false);
138+
/* In case asserts are disabled early return due to no requests pending */
139+
return;
140+
}
141+
142+
dev_data->request_count--;
143+
if (dev_data->request_count < 1) {
144+
stop_hfxo(dev_data);
145+
}
146+
147+
full_irq_unlock(key);
148+
#else
149+
stop_hfxo(dev_data);
150+
#endif /* CONFIG_ZERO_LATENCY_IRQS */
151+
}
152+
153+
#if IS_ENABLED(CONFIG_ZERO_LATENCY_IRQS)
154+
void nrf_clock_control_hfxo_release(void)
155+
{
156+
const struct device *dev = DEVICE_DT_INST_GET(0);
157+
struct dev_data_hfxo *dev_data = dev->data;
158+
159+
release_hfxo(dev_data);
160+
}
161+
#endif /* IS_ENABLED(CONFIG_ZERO_LATENCY_IRQS) */
162+
71163
static void onoff_stop_hfxo(struct onoff_manager *mgr, onoff_notify_fn notify)
72164
{
73165
struct dev_data_hfxo *dev_data =
74166
CONTAINER_OF(mgr, struct dev_data_hfxo, mgr);
75167

76-
nrf_lrcconf_task_trigger(NRF_LRCCONF010, NRF_LRCCONF_TASK_STOPREQHFXO);
77-
soc_lrcconf_poweron_release(&dev_data->hfxo_node, NRF_LRCCONF_POWER_MAIN);
168+
release_hfxo(dev_data);
78169
notify(mgr, 0);
79170
}
80171

drivers/wifi/nrf_wifi/Kconfig.nrfwifi

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,12 @@ config NRF70_SR_COEX
201201

202202
config NRF70_SR_COEX_RF_SWITCH
203203
bool "GPIO configuration to control SR side RF switch position"
204+
depends on $(dt_node_has_prop,nrf70, srrf-switch-gpios)
205+
depends on NRF70_SR_COEX
206+
help
207+
Select this option to enable GPIO configuration to control SR side RF switch position.
208+
If this GPIO is asserted (1), the SR side RF switch is connected to the Wi-Fi side (shared antenna).
209+
If this GPIO is de-asserted (0), the SR side RF switch is connected to the SR side (separate antenna).
204210

205211
config NRF70_WORKQ_STACK_SIZE
206212
int "Stack size for workqueue"

drivers/wifi/nrf_wifi/src/coex.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,10 +247,8 @@ int nrf_wifi_config_sr_switch(bool separate_antennas)
247247

248248
if (separate_antennas) {
249249
gpio_pin_set_dt(&sr_rf_switch_spec, 0x0);
250-
LOG_INF("GPIO P1.10 set to 0");
251250
} else {
252251
gpio_pin_set_dt(&sr_rf_switch_spec, 0x1);
253-
LOG_INF("GPIO P1.10 set to 1");
254252
}
255253

256254
return 0;

include/zephyr/drivers/clock_control/nrf_clock_control.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,30 @@ int nrf_clock_control_cancel_or_release(const struct device *dev,
317317
return api->cancel_or_release(dev, spec, cli);
318318
}
319319

320+
/** @brief Request the HFXO from Zero Latency Interrupt context.
321+
*
322+
* Function is optimized for use in Zero Latency Interrupt context.
323+
* It does not give notification when the HFXO is ready, so each
324+
* user must put the request early enough to make sure the HFXO
325+
* ramp-up has finished on time.
326+
*
327+
* This function uses reference counting so the caller must ensure
328+
* that every nrf_clock_control_hfxo_request() call has a matching
329+
* nrf_clock_control_hfxo_release() call.
330+
*/
331+
void nrf_clock_control_hfxo_request(void);
332+
333+
/** @brief Release the HFXO from Zero Latency Interrupt context.
334+
*
335+
* Function is optimized for use in Zero Latency Interrupt context.
336+
*
337+
* Calls to this function must be coupled with prior calls
338+
* to nrf_clock_control_hfxo_request(), because it uses basic
339+
* reference counting to make sure the HFXO is released when
340+
* there are no more pending requests.
341+
*/
342+
void nrf_clock_control_hfxo_release(void);
343+
320344
#endif /* defined(CONFIG_CLOCK_CONTROL_NRF2) */
321345

322346
/** @brief Get clock frequency that is used for the given node.

0 commit comments

Comments
 (0)