Skip to content
Open
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
1 change: 0 additions & 1 deletion drivers/display/Kconfig.stm32_ltdc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ menuconfig STM32_LTDC
default y
depends on DT_HAS_ST_STM32_LTDC_ENABLED
select USE_STM32_HAL_LTDC
select USE_STM32_HAL_RIF if SOC_SERIES_STM32N6X
select CACHE_MANAGEMENT if CPU_HAS_DCACHE
select PINCTRL
select RESET
Expand Down
12 changes: 0 additions & 12 deletions drivers/display/display_stm32_ltdc.c
Original file line number Diff line number Diff line change
Expand Up @@ -357,9 +357,6 @@ static int stm32_ltdc_init(const struct device *dev)
int err;
const struct display_stm32_ltdc_config *config = dev->config;
struct display_stm32_ltdc_data *data = dev->data;
#if defined(CONFIG_SOC_SERIES_STM32N6X)
RIMC_MasterConfig_t rimc = {0};
#endif

/* Configure and set display on/off GPIO */
if (config->disp_on_gpio.port) {
Expand Down Expand Up @@ -459,15 +456,6 @@ static int stm32_ltdc_init(const struct device *dev)
return err;
}

#if defined(CONFIG_SOC_SERIES_STM32N6X)
/* Configure RIF for LTDC layer 1 */
rimc.MasterCID = RIF_CID_1;
rimc.SecPriv = RIF_ATTRIBUTE_SEC | RIF_ATTRIBUTE_PRIV;
HAL_RIF_RIMC_ConfigMasterAttributes(RIF_MASTER_INDEX_LTDC1, &rimc);
HAL_RIF_RISC_SetSlaveSecureAttributes(RIF_RISC_PERIPH_INDEX_LTDCL1,
RIF_ATTRIBUTE_SEC | RIF_ATTRIBUTE_PRIV);
#endif

/* Disable layer 2, since it not used */
__HAL_LTDC_LAYER_DISABLE(&data->hltdc, LTDC_LAYER_2);

Expand Down
1 change: 0 additions & 1 deletion drivers/ethernet/Kconfig.stm32_hal
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ menuconfig ETH_STM32_HAL
default y
depends on DT_HAS_ST_STM32_ETHERNET_ENABLED
select USE_STM32_HAL_ETH
select USE_STM32_HAL_RIF if SOC_SERIES_STM32N6X
select NOCACHE_MEMORY if (SOC_SERIES_STM32H7X && CPU_CORTEX_M7) || SOC_SERIES_STM32N6X
select HWINFO
select ETH_DSA_SUPPORT_DEPRECATED
Expand Down
31 changes: 0 additions & 31 deletions drivers/ethernet/eth_stm32_hal_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,32 +140,6 @@ static void generate_mac(uint8_t *mac_addr)
#endif
}

#if DT_HAS_COMPAT_STATUS_OKAY(st_stm32n6_ethernet)
/**
* Configures the RISAF (RIF Security Attribute Framework) for Ethernet on STM32N6.
* This function sets up the master and slave security attributes for the Ethernet peripheral.
*/

static void RISAF_Config(void)
{
/* Define and initialize the master configuration structure */
RIMC_MasterConfig_t RIMC_master = {0};

/* Enable the clock for the RIFSC (RIF Security Controller) */
__HAL_RCC_RIFSC_CLK_ENABLE();

RIMC_master.MasterCID = RIF_CID_1;
RIMC_master.SecPriv = RIF_ATTRIBUTE_SEC | RIF_ATTRIBUTE_PRIV;

/* Configure the master attributes for the Ethernet peripheral (ETH1) */
HAL_RIF_RIMC_ConfigMasterAttributes(RIF_MASTER_INDEX_ETH1, &RIMC_master);

/* Set the secure and privileged attributes for the Ethernet peripheral (ETH1) as a slave */
HAL_RIF_RISC_SetSlaveSecureAttributes(RIF_RISC_PERIPH_INDEX_ETH1,
RIF_ATTRIBUTE_SEC | RIF_ATTRIBUTE_PRIV);
}
#endif

static int eth_initialize(const struct device *dev)
{
struct eth_stm32_hal_dev_data *dev_data = dev->data;
Expand All @@ -178,11 +152,6 @@ static int eth_initialize(const struct device *dev)
return -ENODEV;
}

#if DT_HAS_COMPAT_STATUS_OKAY(st_stm32n6_ethernet)
/* RISAF Configuration */
RISAF_Config();
#endif

/* enable clock */
ret = clock_control_on(DEVICE_DT_GET(STM32_CLOCK_CONTROL_NODE),
(clock_control_subsys_t)&cfg->pclken);
Expand Down
1 change: 0 additions & 1 deletion drivers/video/Kconfig.stm32_dcmipp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ config VIDEO_STM32_DCMIPP
default y
depends on DT_HAS_ST_STM32_DCMIPP_ENABLED
select USE_STM32_HAL_DCMIPP
select USE_STM32_HAL_RIF if SOC_SERIES_STM32N6X
select RESET
select PINCTRL
help
Expand Down
1 change: 0 additions & 1 deletion drivers/video/Kconfig.stm32_jpeg
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,5 @@ config VIDEO_STM32_JPEG
select USE_STM32_HAL_JPEG
select USE_STM32_HAL_DMA
select USE_STM32_HAL_DMA_EX
select USE_STM32_HAL_RIF if SOC_SERIES_STM32N6X
help
Enable driver for STM32 JPEG HW Codec peripheral
1 change: 0 additions & 1 deletion drivers/video/Kconfig.stm32_venc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ config VIDEO_STM32_VENC
depends on VIDEO_ENCODER_H264
select HAS_STM32LIB
select USE_STM32_LL_VENC
select USE_STM32_HAL_RIF if SOC_SERIES_STM32N6X
select RESET
help
Enable driver for STM32 video encoder peripheral.
Expand Down
12 changes: 0 additions & 12 deletions drivers/video/video_stm32_dcmipp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1694,10 +1694,6 @@ static int stm32_dcmipp_init(const struct device *dev)

int err;

#if defined(CONFIG_SOC_SERIES_STM32N6X)
RIMC_MasterConfig_t rimc = {0};
#endif

dcmipp->enabled_pipe = 0;

#if defined(STM32_DCMIPP_HAS_PIXEL_PIPES)
Expand Down Expand Up @@ -1736,14 +1732,6 @@ static int stm32_dcmipp_init(const struct device *dev)
/* Run IRQ init */
cfg->irq_config(dev);

#if defined(CONFIG_SOC_SERIES_STM32N6X)
rimc.MasterCID = RIF_CID_1;
rimc.SecPriv = RIF_ATTRIBUTE_SEC | RIF_ATTRIBUTE_PRIV;
HAL_RIF_RIMC_ConfigMasterAttributes(RIF_MASTER_INDEX_DCMIPP, &rimc);
HAL_RIF_RISC_SetSlaveSecureAttributes(RIF_RISC_PERIPH_INDEX_DCMIPP,
RIF_ATTRIBUTE_SEC | RIF_ATTRIBUTE_PRIV);
#endif

/* Initialize DCMI peripheral */
err = HAL_DCMIPP_Init(&dcmipp->hdcmipp);
if (err != HAL_OK) {
Expand Down
5 changes: 0 additions & 5 deletions drivers/video/video_stm32_jpeg.c
Original file line number Diff line number Diff line change
Expand Up @@ -521,11 +521,6 @@ static int stm32_jpeg_init(const struct device *dev)
/* Run IRQ init */
cfg->irq_config(dev);

#if defined(CONFIG_SOC_SERIES_STM32N6X)
HAL_RIF_RISC_SetSlaveSecureAttributes(RIF_RISC_PERIPH_INDEX_JPEG,
RIF_ATTRIBUTE_PRIV | RIF_ATTRIBUTE_SEC);
#endif

/* Initialise default input / output formats */
k_mutex_init(&data->lock);
k_fifo_init(&data->m2m.in.fifo_in);
Expand Down
21 changes: 0 additions & 21 deletions drivers/video/video_stm32_venc.c
Original file line number Diff line number Diff line change
Expand Up @@ -841,25 +841,6 @@ static const struct stm32_venc_config stm32_venc_config_0 = {
.irq_config = stm32_venc_irq_config_func,
};

static void risaf_config(void)
{
/* Define and initialize the master configuration structure */
RIMC_MasterConfig_t rimc_master = {0};

/* Enable the clock for the RIFSC (RIF Security Controller) */
__HAL_RCC_RIFSC_CLK_ENABLE();

rimc_master.MasterCID = RIF_CID_1;
rimc_master.SecPriv = RIF_ATTRIBUTE_SEC | RIF_ATTRIBUTE_PRIV;

/* Configure the master attributes for the video encoder peripheral (VENC) */
HAL_RIF_RIMC_ConfigMasterAttributes(RIF_MASTER_INDEX_VENC, &rimc_master);

/* Set the secure and privileged attributes for the VENC as a slave */
HAL_RIF_RISC_SetSlaveSecureAttributes(RIF_RISC_PERIPH_INDEX_VENC,
RIF_ATTRIBUTE_SEC | RIF_ATTRIBUTE_PRIV);
}

static int stm32_venc_init(const struct device *dev)
{
const struct stm32_venc_config *config = dev->config;
Expand Down Expand Up @@ -890,8 +871,6 @@ static int stm32_venc_init(const struct device *dev)
/* Run IRQ init */
config->irq_config(dev);

risaf_config();

LOG_DBG("CPU frequency : %d", HAL_RCC_GetCpuClockFreq() / 1000000);
LOG_DBG("sysclk frequency : %d", HAL_RCC_GetSysClockFreq() / 1000000);
LOG_DBG("pclk5 frequency : %d", HAL_RCC_GetPCLK5Freq() / 1000000);
Expand Down
11 changes: 10 additions & 1 deletion soc/st/stm32/stm32n6x/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ config SOC_SERIES_STM32N6X
# MPU_GAP_FILLING is default when !USERSPACE, select it in the other case as well.
select MPU_GAP_FILLING if USERSPACE
select CPU_HAS_CUSTOM_FIXED_SOC_MPU_REGIONS if USERSPACE && !XIP
select USE_STM32_HAL_RIF if STM32N6_RIF_OPEN

if SOC_SERIES_STM32N6X

Expand All @@ -31,9 +32,17 @@ config STM32N6_BOOT_SERIAL

config STM32N6_NPU
bool "Neural-ART accelerator (NPU)"
select USE_STM32_HAL_RIF
select RESET
default y
depends on DT_HAS_ST_STM32_NPU_ENABLED

config STM32N6_RIF_OPEN
bool "Configure the RIF with all OPEN access"
default y
depends on TRUSTED_EXECUTION_SECURE
help
When this option is enabled, the RIMC of all masters and the RISC of all slaves are
configured during SoC initialization. Zephyr running with Secure privileges has full
access to all SoC resources.

endif # SOC_SERIES_STM32N6X
13 changes: 0 additions & 13 deletions soc/st/stm32/stm32n6x/npu/npu_stm32n6.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,6 @@ struct npu_stm32_cfg {
const struct reset_dt_spec reset_cacheaxi;
};

static void npu_risaf_config(void)
{
RIMC_MasterConfig_t RIMC_master = {0};

RIMC_master.MasterCID = RIF_CID_1;
RIMC_master.SecPriv = RIF_ATTRIBUTE_SEC | RIF_ATTRIBUTE_PRIV;
HAL_RIF_RIMC_ConfigMasterAttributes(RIF_MASTER_INDEX_NPU, &RIMC_master);
HAL_RIF_RISC_SetSlaveSecureAttributes(RIF_RISC_PERIPH_INDEX_NPU,
RIF_ATTRIBUTE_SEC | RIF_ATTRIBUTE_PRIV);
}

static int npu_stm32_init(const struct device *dev)
{
const struct device *const clk = DEVICE_DT_GET(STM32_CLOCK_CONTROL_NODE);
Expand All @@ -61,8 +50,6 @@ static int npu_stm32_init(const struct device *dev)
(void)reset_line_toggle_dt(&cfg->reset_npu);
(void)reset_line_toggle_dt(&cfg->reset_cacheaxi);

npu_risaf_config();

return 0;
}

Expand Down
45 changes: 45 additions & 0 deletions soc/st/stm32/stm32n6x/soc.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,46 @@ void soc_reset_hook(void)
}
#endif

#define RIF_MASTER_CID1_SEC_PRIV(device) \
do { \
RIMC_MasterConfig_t rimc = { \
.MasterCID = RIF_CID_1, \
.SecPriv = RIF_ATTRIBUTE_SEC | RIF_ATTRIBUTE_PRIV, \
}; \
HAL_RIF_RIMC_ConfigMasterAttributes(RIF_MASTER_INDEX_##device, &rimc); \
} while (0)

#define RIF_SLAVE_SEC_PRIV(device) \
HAL_RIF_RISC_SetSlaveSecureAttributes(RIF_RISC_PERIPH_INDEX_##device, \
RIF_ATTRIBUTE_SEC | RIF_ATTRIBUTE_PRIV)

static void soc_rif_config(void)
{
/* Enable the clock for the RIFSC (RIF Security Controller) */
__HAL_RCC_RIFSC_CLK_ENABLE();

/* DCMIPP */
RIF_MASTER_CID1_SEC_PRIV(DCMIPP);
RIF_SLAVE_SEC_PRIV(DCMIPP);
/* DMA2D */
RIF_MASTER_CID1_SEC_PRIV(DMA2D);
RIF_SLAVE_SEC_PRIV(DMA2D);
/* ETH */
RIF_MASTER_CID1_SEC_PRIV(ETH1);
RIF_SLAVE_SEC_PRIV(ETH1);
/* JPEG */
RIF_SLAVE_SEC_PRIV(JPEG);
/* LTDC Layer 1 */
RIF_MASTER_CID1_SEC_PRIV(LTDC1);
RIF_SLAVE_SEC_PRIV(LTDCL1);
/* NPU */
RIF_MASTER_CID1_SEC_PRIV(NPU);
RIF_SLAVE_SEC_PRIV(NPU);
/* VENC */
RIF_MASTER_CID1_SEC_PRIV(VENC);
RIF_SLAVE_SEC_PRIV(VENC);
}

/**
* @brief Perform basic hardware initialization at boot.
*
Expand Down Expand Up @@ -66,4 +106,9 @@ void soc_early_init_hook(void)
/* Set Vdd IO2 and IO3 to 1.8V */
LL_PWR_SetVddIO2VoltageRange(LL_PWR_VDDIO_VOLTAGE_RANGE_1V8);
LL_PWR_SetVddIO3VoltageRange(LL_PWR_VDDIO_VOLTAGE_RANGE_1V8);

/* RIF configuration */
if (IS_ENABLED(CONFIG_STM32N6_RIF_OPEN)) {
soc_rif_config();
}
}