-
Notifications
You must be signed in to change notification settings - Fork 8.4k
soc: nordic: Add LRCCONF management #79067
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| /* | ||
| * Copyright (c) 2024 Nordic Semiconductor ASA | ||
| * | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| #include <soc_lrcconf.h> | ||
| #include <zephyr/kernel.h> | ||
|
|
||
| static struct k_spinlock lock; | ||
| static sys_slist_t poweron_main_list; | ||
| static sys_slist_t poweron_active_list; | ||
|
|
||
| void soc_lrcconf_poweron_request(sys_snode_t *node, nrf_lrcconf_power_domain_mask_t domain) | ||
|
||
| { | ||
| __ASSERT(is_power_of_two(domain), "Only one bit can be set for the domain parameter"); | ||
|
|
||
| sys_slist_t *poweron_list; | ||
|
|
||
| if (domain == NRF_LRCCONF_POWER_MAIN) { | ||
| poweron_list = &poweron_main_list; | ||
| } else if (domain == NRF_LRCCONF_POWER_DOMAIN_0) { | ||
| poweron_list = &poweron_active_list; | ||
| } else { | ||
| return; | ||
| } | ||
|
|
||
| K_SPINLOCK(&lock) { | ||
| if (sys_slist_len(poweron_list) == 0) { | ||
| nrf_lrcconf_poweron_force_set(NRF_LRCCONF010, domain, true); | ||
| } | ||
|
|
||
| sys_slist_find_and_remove(poweron_list, node); | ||
| sys_slist_append(poweron_list, node); | ||
| } | ||
| } | ||
|
|
||
| void soc_lrcconf_poweron_release(sys_snode_t *node, nrf_lrcconf_power_domain_mask_t domain) | ||
| { | ||
| __ASSERT(is_power_of_two(domain), "Only one bit can be set for the domain parameter"); | ||
|
|
||
| sys_slist_t *poweron_list; | ||
|
|
||
| if (domain == NRF_LRCCONF_POWER_MAIN) { | ||
| poweron_list = &poweron_main_list; | ||
| } else if (domain == NRF_LRCCONF_POWER_DOMAIN_0) { | ||
| poweron_list = &poweron_active_list; | ||
| } else { | ||
| return; | ||
| } | ||
|
|
||
| K_SPINLOCK(&lock) { | ||
| if (!sys_slist_find_and_remove(poweron_list, node)) { | ||
| K_SPINLOCK_BREAK; | ||
| } | ||
|
|
||
| if (sys_slist_len(poweron_list) > 0) { | ||
| K_SPINLOCK_BREAK; | ||
| } | ||
| nrf_lrcconf_poweron_force_set(NRF_LRCCONF010, domain, false); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| /* | ||
| * Copyright (c) 2024 Nordic Semiconductor ASA | ||
| * | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| /** | ||
| * @file nRF SoC specific helpers for lrcconf management | ||
| */ | ||
|
|
||
| #ifndef ZEPHYR_SOC_NORDIC_COMMON_LRCCONF_H_ | ||
| #define ZEPHYR_SOC_NORDIC_COMMON_LRCCONF_H_ | ||
|
|
||
| #include <hal/nrf_lrcconf.h> | ||
|
|
||
| /** | ||
| * @brief Request lrcconf power domain | ||
| * | ||
| * @param node Pointer to the @ref sys_snode_t structure which is the ID of the | ||
| * requesting module. | ||
| * @param domain The mask that represents the power domain ID. | ||
| */ | ||
| void soc_lrcconf_poweron_request(sys_snode_t *node, nrf_lrcconf_power_domain_mask_t domain); | ||
|
|
||
| /** | ||
| * @brief Release lrcconf power domain | ||
| * | ||
| * @param node Pointer to the @ref sys_snode_t structure which is the ID of the | ||
| * requesting module. | ||
| * @param domain The mask that represents the power domain ID. | ||
| */ | ||
| void soc_lrcconf_poweron_release(sys_snode_t *node, nrf_lrcconf_power_domain_mask_t domain); | ||
|
|
||
| #endif /* ZEPHYR_SOC_NORDIC_COMMON_LRCCONF_H_ */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove also the
struct clock_lrcconf_sinkdefinition. There is no need to keep it as it can be replaced with justsys_snode_t.