-
Notifications
You must be signed in to change notification settings - Fork 636
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[nrf fromlist] soc: nordic: Add LRCCONF management
Due to the possibility of simultaneous accesess to LRCCONF registers, additional management is required. Upstream PR: zephyrproject-rtos/zephyr#79067 Signed-off-by: Adam Kondraciuk <[email protected]>
- Loading branch information
1 parent
96aa87c
commit b401917
Showing
11 changed files
with
174 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* 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; | ||
sys_slist_t poweron_main_list; | ||
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.