Skip to content

Commit

Permalink
[nrf fromlist] drivers: retained_mem: nrf: make ram_ctrl variant expl…
Browse files Browse the repository at this point in the history
…icit

Updated retained_mem driver variant exposes vendor-specific API,
rather than executing implicitly during boot.

Upstream PR #: 82262

Signed-off-by: Nikodem Kastelik <[email protected]>
  • Loading branch information
nika-nordic authored and carlescufi committed Dec 4, 2024
1 parent 2e974fb commit 0819c8e
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
5 changes: 2 additions & 3 deletions drivers/retained_mem/retained_mem_nrf_ram_ctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include <zephyr/devicetree.h>
#include <zephyr/kernel.h>
#include <zephyr/drivers/retained_mem/nrf_retained_mem.h>

#include <helpers/nrfx_ram_ctrl.h>

Expand All @@ -22,7 +23,7 @@ static const struct ret_mem_region ret_mem_regions[] = {
DT_FOREACH_STATUS_OKAY(zephyr_retained_ram, _BUILD_MEM_REGION)
};

static int retained_mem_nrf_init(void)
int z_nrf_retained_mem_retention_apply(void)
{
const struct ret_mem_region *rmr;

Expand All @@ -33,5 +34,3 @@ static int retained_mem_nrf_init(void)

return 0;
}

SYS_INIT(retained_mem_nrf_init, PRE_KERNEL_1, 0);
36 changes: 36 additions & 0 deletions include/zephyr/drivers/retained_mem/nrf_retained_mem.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright (c) 2024 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/

#ifndef ZEPHYR_INCLUDE_DRIVERS_RETAINED_MEM_NRF_RETAINED_MEM_H
#define ZEPHYR_INCLUDE_DRIVERS_RETAINED_MEM_NRF_RETAINED_MEM_H

#ifdef __cplusplus
extern "C" {
#endif

#include <zephyr/drivers/retained_mem.h>

#if defined(CONFIG_RETAINED_MEM_NRF_RAM_CTRL) || defined(__DOXYGEN__)
/** @brief Apply memory retention settings.
*
* Memory retention settings to apply are derived from devicetree configuration.
*
* @retval 0 if the retention settings were applied successfully.
* @retval -ENOTSUP if retention configuration is not present in devicetree.
*/
int z_nrf_retained_mem_retention_apply(void);
#else
static inline int z_nrf_retained_mem_retention_apply(void)
{
return -ENOTSUP;
}
#endif

#ifdef __cplusplus
}
#endif

#endif /* ZEPHYR_INCLUDE_DRIVERS_RETAINED_MEM_NRF_RETAINED_MEM_H */

0 comments on commit 0819c8e

Please sign in to comment.