Skip to content

drivers: memc: memc_nxp_flexram.h: Move to the public includes directory #85954

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

Merged
merged 2 commits into from
Apr 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions doc/releases/migration-guide-4.2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,17 @@ Stepper
* Refactored the ``stepper_enable(const struct device * dev, bool enable)`` function to
:c:func:`stepper_enable` & :c:func:`stepper_disable`.

Misc
====

* Moved file ``drivers/memc/memc_nxp_flexram.h`` to
:zephyr_file:`include/zephyr/drivers/misc/flexram/nxp_flexram.h` so that the
file can be included using ``<zephyr/drivers/misc/flexram/nxp_flexram.h>``.
Modification to CMakeList.txt to use include this driver is no longer
required.
* All memc_flexram_* namespaced things including kconfigs and C API
have been changed to just flexram_*.

Bluetooth
*********

Expand Down
1 change: 0 additions & 1 deletion drivers/memc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ zephyr_library_sources_ifdef(CONFIG_MEMC_MCUX_FLEXSPI_S27KS0641 memc_mcux_flexsp
zephyr_library_sources_ifdef(CONFIG_MEMC_MCUX_FLEXSPI_APS6408L memc_mcux_flexspi_aps6408l.c)
zephyr_library_sources_ifdef(CONFIG_MEMC_MCUX_FLEXSPI_APS6404L memc_mcux_flexspi_aps6404l.c)
zephyr_library_sources_ifdef(CONFIG_MEMC_MCUX_FLEXSPI_IS66WVQ8M4 memc_mcux_flexspi_is66wvq8m4.c)
zephyr_library_sources_ifdef(CONFIG_MEMC_NXP_FLEXRAM memc_nxp_flexram.c)
zephyr_library_sources_ifdef(CONFIG_MEMC_RENESAS_RA_SDRAM memc_renesas_ra_sdram.c)

zephyr_library_sources_ifdef(CONFIG_MEMC_SAM_SMC memc_sam_smc.c)
Expand Down
19 changes: 0 additions & 19 deletions drivers/memc/Kconfig.mcux
Original file line number Diff line number Diff line change
Expand Up @@ -66,22 +66,3 @@ choice MEMC_LOG_LEVEL_CHOICE
endchoice

endif # DT_HAS_NXP_IMX_FLEXSPI_ENABLED


if DT_HAS_NXP_FLEXRAM_ENABLED

config MEMC_NXP_FLEXRAM
bool
default y

config MEMC_NXP_FLEXRAM_MAGIC_ADDR_API
bool "NXP FlexRAM magic addr API"
help
Enable API to use flexRAM magic address functionality

config MEMC_NXP_FLEXRAM_ERROR_INTERRUPT
bool "NXP FlexRAM error interrupt"
help
Allow flexram to generate error interrupts

endif # DT_HAS_NXP_FLEXRAM_ENABLED
1 change: 1 addition & 0 deletions drivers/misc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ add_subdirectory_ifdef(CONFIG_ARM_ETHOS_U ethos_u)
add_subdirectory_ifdef(CONFIG_FT800 ft8xx)
add_subdirectory_ifdef(CONFIG_GROVE_LCD_RGB grove_lcd_rgb)
add_subdirectory_ifdef(CONFIG_PIO_RPI_PICO pio_rpi_pico)
add_subdirectory_ifdef(CONFIG_NXP_FLEXRAM nxp_flexram)
add_subdirectory_ifdef(CONFIG_NXP_S32_EMIOS nxp_s32_emios)
add_subdirectory_ifdef(CONFIG_TIMEAWARE_GPIO timeaware_gpio)
add_subdirectory_ifdef(CONFIG_DEVMUX devmux)
Expand Down
1 change: 1 addition & 0 deletions drivers/misc/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ menu "Miscellaneous Drivers"
source "drivers/misc/ft8xx/Kconfig"
source "drivers/misc/grove_lcd_rgb/Kconfig"
source "drivers/misc/pio_rpi_pico/Kconfig"
source "drivers/misc/nxp_flexram/Kconfig"
source "drivers/misc/nxp_s32_emios/Kconfig"
source "drivers/misc/timeaware_gpio/Kconfig"
source "drivers/misc/devmux/Kconfig"
Expand Down
8 changes: 8 additions & 0 deletions drivers/misc/nxp_flexram/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Copyright 2025 NXP
# SPDX-License-Identifier: Apache-2.0

zephyr_library()

zephyr_library_sources(
nxp_flexram.c
)
24 changes: 24 additions & 0 deletions drivers/misc/nxp_flexram/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright (c) 2021 Basalte bv
# Copyright (c) 2023, ithinx GmbH
# Copyright (c) 2023, Tonies GmbH
# Copyright 2020-2023, 2025 NXP
# SPDX-License-Identifier: Apache-2.0

config NXP_FLEXRAM
bool
default y if DT_HAS_NXP_FLEXRAM_ENABLED

if NXP_FLEXRAM

config NXP_FLEXRAM_MAGIC_ADDR_API
bool "NXP FlexRAM magic addr API"
depends on SOC_SERIES_IMXRT11XX
help
Enable API to use flexRAM magic address functionality

config NXP_FLEXRAM_ERROR_INTERRUPT
bool "NXP FlexRAM error interrupt"
help
Allow flexram to generate error interrupts

endif # NXP_FLEXRAM
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

#include "memc_nxp_flexram.h"
#include <zephyr/drivers/misc/flexram/nxp_flexram.h>
#include <zephyr/dt-bindings/memory-controller/nxp,flexram.h>
#include <zephyr/devicetree.h>
#include <zephyr/init.h>
Expand All @@ -15,7 +15,7 @@
#include "fsl_device_registers.h"


#if defined(CONFIG_MEMC_NXP_FLEXRAM_MAGIC_ADDR_API)
#if defined(CONFIG_NXP_FLEXRAM_MAGIC_ADDR_API)
BUILD_ASSERT(DT_PROP(FLEXRAM_DT_NODE, flexram_has_magic_addr),
"SOC does not support magic flexram addresses");
#endif
Expand Down Expand Up @@ -92,7 +92,7 @@ static FLEXRAM_Type *const base = (FLEXRAM_Type *) DT_REG_ADDR(FLEXRAM_DT_NODE);
static flexram_callback_t flexram_callback;
static void *flexram_user_data;

void memc_flexram_register_callback(flexram_callback_t callback, void *user_data)
void flexram_register_callback(flexram_callback_t callback, void *user_data)
{
flexram_callback = callback;
flexram_user_data = user_data;
Expand All @@ -106,7 +106,7 @@ static void nxp_flexram_isr(void *arg)
return;
}

#if defined(CONFIG_MEMC_NXP_FLEXRAM_ERROR_INTERRUPT)
#if defined(CONFIG_NXP_FLEXRAM_ERROR_INTERRUPT)
if (base->INT_STATUS & FLEXRAM_INT_STATUS_OCRAM_ERR_STATUS_MASK) {
base->INT_STATUS |= FLEXRAM_INT_STATUS_OCRAM_ERR_STATUS_MASK;
flexram_callback(flexram_ocram_access_error, flexram_user_data);
Expand All @@ -119,9 +119,9 @@ static void nxp_flexram_isr(void *arg)
base->INT_STATUS |= FLEXRAM_INT_STATUS_ITCM_ERR_STATUS_MASK;
flexram_callback(flexram_itcm_access_error, flexram_user_data);
}
#endif /* CONFIG_MEMC_NXP_FLEXRAM_ERROR_INTERRUPT */
#endif /* CONFIG_NXP_FLEXRAM_ERROR_INTERRUPT */

#if defined(CONFIG_MEMC_NXP_FLEXRAM_MAGIC_ADDR_API)
#if defined(CONFIG_NXP_FLEXRAM_MAGIC_ADDR_API)
if (base->INT_STATUS & FLEXRAM_INT_STATUS_OCRAM_MAM_STATUS_MASK) {
base->INT_STATUS |= FLEXRAM_INT_STATUS_OCRAM_MAM_STATUS_MASK;
flexram_callback(flexram_ocram_magic_addr, flexram_user_data);
Expand All @@ -134,11 +134,11 @@ static void nxp_flexram_isr(void *arg)
base->INT_STATUS |= FLEXRAM_INT_STATUS_ITCM_MAM_STATUS_MASK;
flexram_callback(flexram_itcm_magic_addr, flexram_user_data);
}
#endif /* CONFIG_MEMC_NXP_FLEXRAM_MAGIC_ADDR_API */
#endif /* CONFIG_NXP_FLEXRAM_MAGIC_ADDR_API */
}

#if defined(CONFIG_MEMC_NXP_FLEXRAM_MAGIC_ADDR_API)
int memc_flexram_set_ocram_magic_addr(uint32_t ocram_addr)
#if defined(CONFIG_NXP_FLEXRAM_MAGIC_ADDR_API)
int flexram_set_ocram_magic_addr(uint32_t ocram_addr)
{
#ifdef OCRAM_DT_NODE
ocram_addr -= DT_REG_ADDR(OCRAM_DT_NODE);
Expand All @@ -156,7 +156,7 @@ int memc_flexram_set_ocram_magic_addr(uint32_t ocram_addr)
#endif
}

int memc_flexram_set_itcm_magic_addr(uint32_t itcm_addr)
int flexram_set_itcm_magic_addr(uint32_t itcm_addr)
{
#ifdef ITCM_DT_NODE
itcm_addr -= DT_REG_ADDR(ITCM_DT_NODE);
Expand All @@ -174,7 +174,7 @@ int memc_flexram_set_itcm_magic_addr(uint32_t itcm_addr)
#endif
}

int memc_flexram_set_dtcm_magic_addr(uint32_t dtcm_addr)
int flexram_set_dtcm_magic_addr(uint32_t dtcm_addr)
{
#ifdef DTCM_DT_NODE
dtcm_addr -= DT_REG_ADDR(DTCM_DT_NODE);
Expand All @@ -191,7 +191,7 @@ int memc_flexram_set_dtcm_magic_addr(uint32_t dtcm_addr)
return -ENODEV;
#endif
}
#endif /* CONFIG_MEMC_NXP_FLEXRAM_MAGIC_ADDR_API */
#endif /* CONFIG_NXP_FLEXRAM_MAGIC_ADDR_API */

#endif /* FLEXRAM_INTERRUPTS_USED */

Expand All @@ -204,20 +204,20 @@ static int nxp_flexram_init(void)
base->TCM_CTRL |= FLEXRAM_TCM_CTRL_TCM_RWAIT_EN_MASK;
}

#if defined(CONFIG_MEMC_NXP_FLEXRAM_ERROR_INTERRUPT)
#if defined(CONFIG_NXP_FLEXRAM_ERROR_INTERRUPT)
base->INT_SIG_EN |= FLEXRAM_INT_SIG_EN_OCRAM_ERR_SIG_EN_MASK;
base->INT_SIG_EN |= FLEXRAM_INT_SIG_EN_DTCM_ERR_SIG_EN_MASK;
base->INT_SIG_EN |= FLEXRAM_INT_SIG_EN_ITCM_ERR_SIG_EN_MASK;
base->INT_STAT_EN |= FLEXRAM_INT_STAT_EN_OCRAM_ERR_STAT_EN_MASK;
base->INT_STAT_EN |= FLEXRAM_INT_STAT_EN_DTCM_ERR_STAT_EN_MASK;
base->INT_STAT_EN |= FLEXRAM_INT_STAT_EN_ITCM_ERR_STAT_EN_MASK;
#endif /* CONFIG_MEMC_NXP_FLEXRAM_ERROR_INTERRUPT */
#endif /* CONFIG_NXP_FLEXRAM_ERROR_INTERRUPT */

#if defined(CONFIG_MEMC_NXP_FLEXRAM_MAGIC_ADDR_API)
#if defined(CONFIG_NXP_FLEXRAM_MAGIC_ADDR_API)
base->INT_SIG_EN |= FLEXRAM_INT_SIG_EN_OCRAM_MAM_SIG_EN_MASK;
base->INT_SIG_EN |= FLEXRAM_INT_SIG_EN_DTCM_MAM_SIG_EN_MASK;
base->INT_SIG_EN |= FLEXRAM_INT_SIG_EN_ITCM_MAM_SIG_EN_MASK;
#endif /* CONFIG_MEMC_NXP_FLEXRAM_MAGIC_ADDR_API */
#endif /* CONFIG_NXP_FLEXRAM_MAGIC_ADDR_API */

#ifdef FLEXRAM_INTERRUPTS_USED
IRQ_CONNECT(DT_IRQN(FLEXRAM_DT_NODE), DT_IRQ(FLEXRAM_DT_NODE, priority),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
#define FLEXRAM_DT_NODE DT_INST(0, nxp_flexram)
#define IOMUXC_GPR_DT_NODE DT_NODELABEL(iomuxcgpr)

#if defined(CONFIG_MEMC_NXP_FLEXRAM_MAGIC_ADDR_API) || \
defined(CONFIG_MEMC_NXP_FLEXRAM_ERROR_INTERRUPT)
#if defined(CONFIG_NXP_FLEXRAM_MAGIC_ADDR_API) || \
defined(CONFIG_NXP_FLEXRAM_ERROR_INTERRUPT)
#define FLEXRAM_INTERRUPTS_USED
#endif

Expand All @@ -20,22 +20,22 @@
#endif

#ifdef FLEXRAM_INTERRUPTS_USED
enum memc_flexram_interrupt_cause {
#ifdef CONFIG_MEMC_NXP_FLEXRAM_ERROR_INTERRUPT
enum flexram_interrupt_cause {
#ifdef CONFIG_NXP_FLEXRAM_ERROR_INTERRUPT
flexram_ocram_access_error,
flexram_itcm_access_error,
flexram_dtcm_access_error,
#endif
#ifdef CONFIG_MEMC_NXP_FLEXRAM_MAGIC_ADDR_API
#ifdef CONFIG_NXP_FLEXRAM_MAGIC_ADDR_API
flexram_ocram_magic_addr,
flexram_itcm_magic_addr,
flexram_dtcm_magic_addr,
#endif /* CONFIG_MEMC_NXP_FLEXRAM_MAGIC_ADDR_API */
#endif /* CONFIG_NXP_FLEXRAM_MAGIC_ADDR_API */
};

typedef void (*flexram_callback_t)(enum memc_flexram_interrupt_cause, void *user_data);
typedef void (*flexram_callback_t)(enum flexram_interrupt_cause, void *user_data);

void memc_flexram_register_callback(flexram_callback_t callback, void *user_data);
void flexram_register_callback(flexram_callback_t callback, void *user_data);
#endif /* FLEXRAM_INTERRUPTS_USED */

#ifdef FLEXRAM_RUNTIME_BANKS_USED
Expand All @@ -46,7 +46,7 @@ void memc_flexram_register_callback(flexram_callback_t callback, void *user_data
*/
#define GPR_FLEXRAM_REG_FILL(node_id, prop, idx) \
(((uint32_t)DT_PROP_BY_IDX(node_id, prop, idx)) << (2 * idx))
static inline void memc_flexram_dt_partition(void)
static inline void flexram_dt_partition(void)
{
/* iomuxc_gpr must be const (in ROM region) because used in reconfiguring ram */
static IOMUXC_GPR_Type *const iomuxc_gpr =
Expand All @@ -65,7 +65,7 @@ static inline void memc_flexram_dt_partition(void)
}
#endif /* FLEXRAM_RUNTIME_BANKS_USED */

#ifdef CONFIG_MEMC_NXP_FLEXRAM_MAGIC_ADDR_API
#ifdef CONFIG_NXP_FLEXRAM_MAGIC_ADDR_API
/** @brief Sets magic address for OCRAM
*
* Magic address allows core interrupt from FlexRAM when address
Expand All @@ -76,7 +76,7 @@ static inline void memc_flexram_dt_partition(void)
* @retval -EINVAL if ocram_addr is not in OCRAM
* @retval -ENODEV if there is no OCRAM allocation in flexram
*/
int memc_flexram_set_ocram_magic_addr(uint32_t ocram_addr);
int flexram_set_ocram_magic_addr(uint32_t ocram_addr);

/** @brief Sets magic address for ITCM
*
Expand All @@ -88,7 +88,7 @@ int memc_flexram_set_ocram_magic_addr(uint32_t ocram_addr);
* @retval -EINVAL if itcm_addr is not in ITCM
* @retval -ENODEV if there is no ITCM allocation in flexram
*/
int memc_flexram_set_itcm_magic_addr(uint32_t itcm_addr);
int flexram_set_itcm_magic_addr(uint32_t itcm_addr);

/** @brief Sets magic address for DTCM
*
Expand All @@ -100,6 +100,6 @@ int memc_flexram_set_itcm_magic_addr(uint32_t itcm_addr);
* @retval -EINVAL if dtcm_addr is not in DTCM
* @retval -ENODEV if there is no DTCM allocation in flexram
*/
int memc_flexram_set_dtcm_magic_addr(uint32_t dtcm_addr);
int flexram_set_dtcm_magic_addr(uint32_t dtcm_addr);

#endif /* CONFIG_MEMC_NXP_FLEXRAM_MAGIC_ADDR_API */
#endif /* CONFIG_NXP_FLEXRAM_MAGIC_ADDR_API */
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,4 @@ cmake_minimum_required(VERSION 3.20.0)
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(magic_addr)

zephyr_library_include_directories(${ZEPHYR_BASE}/drivers/memc)

target_sources(app PRIVATE src/main.c)
2 changes: 1 addition & 1 deletion samples/boards/nxp/mimxrt1170_evk_cm7/magic_addr/prj.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
CONFIG_MEMC_NXP_FLEXRAM_MAGIC_ADDR_API=y
CONFIG_NXP_FLEXRAM_MAGIC_ADDR_API=y
CONFIG_CONSOLE_SUBSYS=y
CONFIG_CONSOLE_GETCHAR=y
8 changes: 4 additions & 4 deletions samples/boards/nxp/mimxrt1170_evk_cm7/magic_addr/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include <stdio.h>
#include <zephyr/linker/section_tags.h>
#include "memc_nxp_flexram.h"
#include <zephyr/drivers/misc/flexram/nxp_flexram.h>
#include <zephyr/kernel.h>
#include <zephyr/console/console.h>
#include <zephyr/cache.h>
Expand All @@ -16,7 +16,7 @@ K_SEM_DEFINE(dtcm_magic, 0, 1);
__dtcm_bss_section uint8_t var;
int cnt;

void flexram_magic_addr_isr_cb(enum memc_flexram_interrupt_cause cause,
void flexram_magic_addr_isr_cb(enum flexram_interrupt_cause cause,
void *data)
{
ARG_UNUSED(data);
Expand All @@ -29,7 +29,7 @@ void flexram_magic_addr_isr_cb(enum memc_flexram_interrupt_cause cause,

int main(void)
{
memc_flexram_register_callback(flexram_magic_addr_isr_cb, NULL);
flexram_register_callback(flexram_magic_addr_isr_cb, NULL);

console_init();

Expand All @@ -38,7 +38,7 @@ int main(void)

uint32_t dtcm_addr = (uint32_t)&var;

memc_flexram_set_dtcm_magic_addr(dtcm_addr);
flexram_set_dtcm_magic_addr(dtcm_addr);

uint8_t tmp;

Expand Down
2 changes: 1 addition & 1 deletion soc/nxp/imxrt/imxrt10xx/soc.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include "usb.h"
#endif

#include "memc_nxp_flexram.h"
#include <zephyr/drivers/misc/flexram/nxp_flexram.h>

#include <cmsis_core.h>

Expand Down
2 changes: 1 addition & 1 deletion soc/nxp/imxrt/imxrt11xx/soc.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ LOG_MODULE_REGISTER(soc, CONFIG_SOC_LOG_LEVEL);
#include "usb_phy.h"
#include "usb.h"
#endif
#include "memc_nxp_flexram.h"
#include <zephyr/drivers/misc/flexram/nxp_flexram.h>

#include <cmsis_core.h>

Expand Down