zephyr/soc/st/stm32/stm32wbax/soc.c
Lubos Koudelka c80ace50f4 soc: st: stm32: adding option to enable prefetch buffer
For more effective code execution on STM32 devices is convenient
 to enable flash prefetch buffer.
To be enabled by default, possible to disable using kconfig.

Signed-off-by: Lubos Koudelka <lubos.koudelka@st.com>
2024-04-22 06:49:32 -07:00

61 lines
1.3 KiB
C

/*
* Copyright (c) 2023 STMicroelectronics
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @file
* @brief System/hardware module for STM32WBA processor
*/
#include <zephyr/device.h>
#include <zephyr/init.h>
#include <stm32_ll_bus.h>
#include <stm32_ll_pwr.h>
#include <stm32_ll_rcc.h>
#include <stm32_ll_icache.h>
#include <zephyr/arch/cpu.h>
#include <zephyr/irq.h>
#include <zephyr/logging/log.h>
#include <cmsis_core.h>
#define LOG_LEVEL CONFIG_SOC_LOG_LEVEL
LOG_MODULE_REGISTER(soc);
/**
* @brief Perform basic hardware initialization at boot.
*
* This needs to be run from the very beginning.
* So the init priority has to be 0 (zero).
*
* @return 0
*/
int stm32wba_init(void)
{
/* Enable instruction cache in 1-way (direct mapped cache) */
LL_ICACHE_SetMode(LL_ICACHE_1WAY);
LL_ICACHE_Enable();
#ifdef CONFIG_STM32_FLASH_PREFETCH
__HAL_FLASH_PREFETCH_BUFFER_ENABLE();
#endif
/* Update CMSIS SystemCoreClock variable (HCLK) */
/* At reset, system core clock is set to 16 MHz from HSI */
SystemCoreClock = 16000000;
/* Enable PWR */
LL_AHB4_GRP1_EnableClock(LL_AHB4_GRP1_PERIPH_PWR);
#if defined(CONFIG_POWER_SUPPLY_DIRECT_SMPS)
LL_PWR_SetRegulatorSupply(LL_PWR_SMPS_SUPPLY);
#elif defined(CONFIG_POWER_SUPPLY_LDO)
LL_PWR_SetRegulatorSupply(LL_PWR_LDO_SUPPLY);
#endif
return 0;
}
SYS_INIT(stm32wba_init, PRE_KERNEL_1, 0);