Skip to content

Commit 940e4a5

Browse files
Revert "[nrf fromlist] soc: nordic: Add LRCCONF management"
This reverts commit 1cc6e15. Signed-off-by: Adam Kondraciuk <[email protected]>
1 parent 7ef7b81 commit 940e4a5

File tree

10 files changed

+109
-240
lines changed

10 files changed

+109
-240
lines changed

drivers/clock_control/clock_control_nrf2_common.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*/
55

66
#include "clock_control_nrf2_common.h"
7+
#include <hal/nrf_lrcconf.h>
78

89
#include <zephyr/logging/log.h>
910
LOG_MODULE_REGISTER(clock_control_nrf2, CONFIG_CLOCK_CONTROL_LOG_LEVEL);
@@ -24,6 +25,9 @@ LOG_MODULE_REGISTER(clock_control_nrf2, CONFIG_CLOCK_CONTROL_LOG_LEVEL);
2425
*/
2526
STRUCT_CLOCK_CONFIG(generic, ONOFF_CNT_MAX);
2627

28+
static sys_slist_t poweron_main_list;
29+
static struct k_spinlock poweron_main_lock;
30+
2731
static void update_config(struct clock_config_generic *cfg)
2832
{
2933
atomic_val_t prev_flags = atomic_or(&cfg->flags, FLAG_UPDATE_NEEDED);
@@ -159,3 +163,34 @@ int api_nosys_on_off(const struct device *dev, clock_control_subsys_t sys)
159163

160164
return -ENOSYS;
161165
}
166+
167+
void clock_request_lrcconf_poweron_main(struct clock_lrcconf_sink *sink)
168+
{
169+
K_SPINLOCK(&poweron_main_lock) {
170+
if (sys_slist_len(&poweron_main_list) == 0) {
171+
LOG_DBG("%s forced on", "main domain");
172+
NRF_LRCCONF010->POWERON &= ~LRCCONF_POWERON_MAIN_Msk;
173+
NRF_LRCCONF010->POWERON |= LRCCONF_POWERON_MAIN_AlwaysOn;
174+
}
175+
176+
sys_slist_find_and_remove(&poweron_main_list, &sink->node);
177+
sys_slist_append(&poweron_main_list, &sink->node);
178+
}
179+
}
180+
181+
void clock_release_lrcconf_poweron_main(struct clock_lrcconf_sink *sink)
182+
{
183+
K_SPINLOCK(&poweron_main_lock) {
184+
if (!sys_slist_find_and_remove(&poweron_main_list, &sink->node)) {
185+
K_SPINLOCK_BREAK;
186+
}
187+
188+
if (sys_slist_len(&poweron_main_list) > 0) {
189+
K_SPINLOCK_BREAK;
190+
}
191+
192+
LOG_DBG("%s automatic", "main domain");
193+
NRF_LRCCONF010->POWERON &= ~LRCCONF_POWERON_MAIN_Msk;
194+
NRF_LRCCONF010->POWERON |= LRCCONF_POWERON_MAIN_Automatic;
195+
}
196+
}

drivers/clock_control/clock_control_nrf2_common.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,14 @@ void clock_config_update_end(void *clk_cfg, int status);
7575

7676
int api_nosys_on_off(const struct device *dev, clock_control_subsys_t sys);
7777

78+
struct clock_lrcconf_sink {
79+
sys_snode_t node;
80+
};
81+
82+
/**
83+
* @brief Request or release lrcconf main power domain
84+
*/
85+
void clock_request_lrcconf_poweron_main(struct clock_lrcconf_sink *sink);
86+
void clock_release_lrcconf_poweron_main(struct clock_lrcconf_sink *sink);
87+
7888
#endif /* ZEPHYR_DRIVERS_CLOCK_CONTROL_NRF2_COMMON_H_ */

drivers/clock_control/clock_control_nrf2_fll16m.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include "clock_control_nrf2_common.h"
99
#include <zephyr/devicetree.h>
1010
#include <zephyr/drivers/clock_control/nrf_clock_control.h>
11-
#include <soc_lrcconf.h>
11+
#include <hal/nrf_lrcconf.h>
1212

1313
#include <zephyr/logging/log.h>
1414
LOG_MODULE_DECLARE(clock_control_nrf2, CONFIG_CLOCK_CONTROL_LOG_LEVEL);
@@ -64,7 +64,7 @@ static const struct clock_options {
6464
struct fll16m_dev_data {
6565
STRUCT_CLOCK_CONFIG(fll16m, ARRAY_SIZE(clock_options)) clk_cfg;
6666
struct onoff_client hfxo_cli;
67-
sys_snode_t fll16m_node;
67+
struct clock_lrcconf_sink lrcconf_sink;
6868
};
6969

7070
struct fll16m_dev_config {
@@ -76,13 +76,13 @@ static void activate_fll16m_mode(struct fll16m_dev_data *dev_data, uint8_t mode)
7676
/* TODO: change to nrf_lrcconf_* function when such is available. */
7777

7878
if (mode != FLL16M_MODE_DEFAULT) {
79-
soc_lrcconf_poweron_request(&dev_data->fll16m_node, NRF_LRCCONF_POWER_MAIN);
79+
clock_request_lrcconf_poweron_main(&dev_data->lrcconf_sink);
8080
}
8181

8282
NRF_LRCCONF010->CLKCTRL[0].SRC = mode;
8383

8484
if (mode == FLL16M_MODE_DEFAULT) {
85-
soc_lrcconf_poweron_release(&dev_data->fll16m_node, NRF_LRCCONF_POWER_MAIN);
85+
clock_release_lrcconf_poweron_main(&dev_data->lrcconf_sink);
8686
}
8787

8888
nrf_lrcconf_task_trigger(NRF_LRCCONF010, NRF_LRCCONF_TASK_CLKSTART_0);

drivers/clock_control/clock_control_nrf2_hfxo.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include <zephyr/logging/log.h>
1212
LOG_MODULE_DECLARE(clock_control_nrf2, CONFIG_CLOCK_CONTROL_LOG_LEVEL);
1313

14-
#include <soc_lrcconf.h>
14+
#include <hal/nrf_lrcconf.h>
1515

1616
BUILD_ASSERT(DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT) == 1,
1717
"multiple instances not supported");
@@ -20,7 +20,7 @@ struct dev_data_hfxo {
2020
struct onoff_manager mgr;
2121
onoff_notify_fn notify;
2222
struct k_timer timer;
23-
sys_snode_t hfxo_node;
23+
struct clock_lrcconf_sink lrcconf_sink;
2424
};
2525

2626
struct dev_config_hfxo {
@@ -58,7 +58,7 @@ static void onoff_start_hfxo(struct onoff_manager *mgr, onoff_notify_fn notify)
5858
dev_data->notify = notify;
5959

6060
nrf_lrcconf_event_clear(NRF_LRCCONF010, NRF_LRCCONF_EVENT_HFXOSTARTED);
61-
soc_lrcconf_poweron_request(&dev_data->hfxo_node, NRF_LRCCONF_POWER_MAIN);
61+
clock_request_lrcconf_poweron_main(&dev_data->lrcconf_sink);
6262
nrf_lrcconf_task_trigger(NRF_LRCCONF010, NRF_LRCCONF_TASK_REQHFXO);
6363

6464
/* Due to a hardware issue, the HFXOSTARTED event is currently
@@ -74,7 +74,7 @@ static void onoff_stop_hfxo(struct onoff_manager *mgr, onoff_notify_fn notify)
7474
CONTAINER_OF(mgr, struct dev_data_hfxo, mgr);
7575

7676
nrf_lrcconf_task_trigger(NRF_LRCCONF010, NRF_LRCCONF_TASK_STOPREQHFXO);
77-
soc_lrcconf_poweron_release(&dev_data->hfxo_node, NRF_LRCCONF_POWER_MAIN);
77+
clock_release_lrcconf_poweron_main(&dev_data->lrcconf_sink);
7878
notify(mgr, 0);
7979
}
8080

soc/nordic/common/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ if(CONFIG_ARM)
1212
endif()
1313

1414
zephyr_library_sources_ifdef(CONFIG_POWEROFF poweroff.c)
15-
if(CONFIG_ARM)
16-
zephyr_library_sources_ifdef(CONFIG_NRF_PLATFORM_HALTIUM soc_lrcconf.c)
17-
endif()
1815

1916
if((CONFIG_SOC_SERIES_NRF54HX OR CONFIG_SOC_SERIES_NRF92X) AND CONFIG_CPU_HAS_CUSTOM_FIXED_SOC_MPU_REGIONS)
2017
zephyr_library_sources(nrf54hx_nrf92x_mpu_regions.c)

soc/nordic/common/soc_lrcconf.c

Lines changed: 0 additions & 61 deletions
This file was deleted.

soc/nordic/common/soc_lrcconf.h

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)