Skip to content

Commit

Permalink
Merge branch 'main' into feature-credentials-size
Browse files Browse the repository at this point in the history
  • Loading branch information
plskeggs authored Dec 19, 2024
2 parents ef7e3cb + ba1d06f commit aa753e6
Show file tree
Hide file tree
Showing 7 changed files with 310 additions and 21 deletions.
13 changes: 13 additions & 0 deletions boards/shields/nrf7002eb/boards/nrf54h20dk_nrf54h20_cpuapp.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* Copyright (c) 2024 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/

/* Only GPIOs 1..11 are supported for PORT1 in nRF54H20DK board, for now
* remove this as Wi-Fi SR co-existence is not yet supported on this board.
* The external SR RF switch may not even be present on this board.
*/
&nrf70 {
/delete-property/ srrf-switch-gpios;
};
103 changes: 97 additions & 6 deletions drivers/clock_control/clock_control_nrf2_hfxo.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ struct dev_data_hfxo {
onoff_notify_fn notify;
struct k_timer timer;
sys_snode_t hfxo_node;
#if defined(CONFIG_ZERO_LATENCY_IRQS)
uint16_t request_count;
#endif /* CONFIG_ZERO_LATENCY_IRQS */
};

struct dev_config_hfxo {
Expand All @@ -29,6 +32,23 @@ struct dev_config_hfxo {
k_timeout_t start_up_time;
};

#if defined(CONFIG_ZERO_LATENCY_IRQS)
static uint32_t full_irq_lock(void)
{
uint32_t mcu_critical_state;

mcu_critical_state = __get_PRIMASK();
__disable_irq();

return mcu_critical_state;
}

static void full_irq_unlock(uint32_t mcu_critical_state)
{
__set_PRIMASK(mcu_critical_state);
}
#endif /* CONFIG_ZERO_LATENCY_IRQS */

static void hfxo_start_up_timer_handler(struct k_timer *timer)
{
struct dev_data_hfxo *dev_data =
Expand All @@ -48,6 +68,40 @@ static void hfxo_start_up_timer_handler(struct k_timer *timer)
}
}

static void start_hfxo(struct dev_data_hfxo *dev_data)
{
nrf_lrcconf_event_clear(NRF_LRCCONF010, NRF_LRCCONF_EVENT_HFXOSTARTED);
soc_lrcconf_poweron_request(&dev_data->hfxo_node, NRF_LRCCONF_POWER_MAIN);
nrf_lrcconf_task_trigger(NRF_LRCCONF010, NRF_LRCCONF_TASK_REQHFXO);
}

static void request_hfxo(struct dev_data_hfxo *dev_data)
{
#if defined(CONFIG_ZERO_LATENCY_IRQS)
unsigned int key;

key = full_irq_lock();
if (dev_data->request_count == 0) {
start_hfxo(dev_data);
}

dev_data->request_count++;
full_irq_unlock(key);
#else
start_hfxo(dev_data);
#endif /* CONFIG_ZERO_LATENCY_IRQS */
}

#if IS_ENABLED(CONFIG_ZERO_LATENCY_IRQS)
void nrf_clock_control_hfxo_request(void)
{
const struct device *dev = DEVICE_DT_INST_GET(0);
struct dev_data_hfxo *dev_data = dev->data;

request_hfxo(dev_data);
}
#endif /* CONFIG_ZERO_LATENCY_IRQS */

static void onoff_start_hfxo(struct onoff_manager *mgr, onoff_notify_fn notify)
{
struct dev_data_hfxo *dev_data =
Expand All @@ -56,10 +110,7 @@ static void onoff_start_hfxo(struct onoff_manager *mgr, onoff_notify_fn notify)
const struct dev_config_hfxo *dev_config = dev->config;

dev_data->notify = notify;

nrf_lrcconf_event_clear(NRF_LRCCONF010, NRF_LRCCONF_EVENT_HFXOSTARTED);
soc_lrcconf_poweron_request(&dev_data->hfxo_node, NRF_LRCCONF_POWER_MAIN);
nrf_lrcconf_task_trigger(NRF_LRCCONF010, NRF_LRCCONF_TASK_REQHFXO);
request_hfxo(dev_data);

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

static void stop_hfxo(struct dev_data_hfxo *dev_data)
{
nrf_lrcconf_task_trigger(NRF_LRCCONF010, NRF_LRCCONF_TASK_STOPREQHFXO);
soc_lrcconf_poweron_release(&dev_data->hfxo_node, NRF_LRCCONF_POWER_MAIN);
}

static void release_hfxo(struct dev_data_hfxo *dev_data)
{
#if IS_ENABLED(CONFIG_ZERO_LATENCY_IRQS)
unsigned int key;

key = full_irq_lock();
if (dev_data->request_count < 1) {
full_irq_unlock(key);
/* Misuse of the API, release without request? */
__ASSERT_NO_MSG(false);
/* In case asserts are disabled early return due to no requests pending */
return;
}

dev_data->request_count--;
if (dev_data->request_count < 1) {
stop_hfxo(dev_data);
}

full_irq_unlock(key);
#else
stop_hfxo(dev_data);
#endif /* CONFIG_ZERO_LATENCY_IRQS */
}

#if IS_ENABLED(CONFIG_ZERO_LATENCY_IRQS)
void nrf_clock_control_hfxo_release(void)
{
const struct device *dev = DEVICE_DT_INST_GET(0);
struct dev_data_hfxo *dev_data = dev->data;

release_hfxo(dev_data);
}
#endif /* IS_ENABLED(CONFIG_ZERO_LATENCY_IRQS) */

static void onoff_stop_hfxo(struct onoff_manager *mgr, onoff_notify_fn notify)
{
struct dev_data_hfxo *dev_data =
CONTAINER_OF(mgr, struct dev_data_hfxo, mgr);

nrf_lrcconf_task_trigger(NRF_LRCCONF010, NRF_LRCCONF_TASK_STOPREQHFXO);
soc_lrcconf_poweron_release(&dev_data->hfxo_node, NRF_LRCCONF_POWER_MAIN);
release_hfxo(dev_data);
notify(mgr, 0);
}

Expand Down
6 changes: 6 additions & 0 deletions drivers/wifi/nrf_wifi/Kconfig.nrfwifi
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,12 @@ config NRF70_SR_COEX

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

config NRF70_WORKQ_STACK_SIZE
int "Stack size for workqueue"
Expand Down
2 changes: 0 additions & 2 deletions drivers/wifi/nrf_wifi/src/coex.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,8 @@ int nrf_wifi_config_sr_switch(bool separate_antennas)

if (separate_antennas) {
gpio_pin_set_dt(&sr_rf_switch_spec, 0x0);
LOG_INF("GPIO P1.10 set to 0");
} else {
gpio_pin_set_dt(&sr_rf_switch_spec, 0x1);
LOG_INF("GPIO P1.10 set to 1");
}

return 0;
Expand Down
24 changes: 24 additions & 0 deletions include/zephyr/drivers/clock_control/nrf_clock_control.h
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,30 @@ int nrf_clock_control_cancel_or_release(const struct device *dev,
return api->cancel_or_release(dev, spec, cli);
}

/** @brief Request the HFXO from Zero Latency Interrupt context.
*
* Function is optimized for use in Zero Latency Interrupt context.
* It does not give notification when the HFXO is ready, so each
* user must put the request early enough to make sure the HFXO
* ramp-up has finished on time.
*
* This function uses reference counting so the caller must ensure
* that every nrf_clock_control_hfxo_request() call has a matching
* nrf_clock_control_hfxo_release() call.
*/
void nrf_clock_control_hfxo_request(void);

/** @brief Release the HFXO from Zero Latency Interrupt context.
*
* Function is optimized for use in Zero Latency Interrupt context.
*
* Calls to this function must be coupled with prior calls
* to nrf_clock_control_hfxo_request(), because it uses basic
* reference counting to make sure the HFXO is released when
* there are no more pending requests.
*/
void nrf_clock_control_hfxo_release(void);

#endif /* defined(CONFIG_CLOCK_CONTROL_NRF2) */

/** @brief Get clock frequency that is used for the given node.
Expand Down
Loading

0 comments on commit aa753e6

Please sign in to comment.