1 /*
2  * Copyright (c) 2019 STMicroelectronics
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 /**
8  * @file
9  * @brief System/hardware module for STM32L4 processor
10  */
11 
12 #include <kernel.h>
13 #include <device.h>
14 #include <init.h>
15 #include <soc.h>
16 #include <stm32_ll_bus.h>
17 #include <arch/cpu.h>
18 #include <arch/arm/aarch32/cortex_m/cmsis.h>
19 
20 /**
21  * @brief Perform basic hardware initialization at boot.
22  *
23  * This needs to be run from the very beginning.
24  * So the init priority has to be 0 (zero).
25  *
26  * @return 0
27  */
stm32m4_init(const struct device * arg)28 static int stm32m4_init(const struct device *arg)
29 {
30 	uint32_t key;
31 
32 	ARG_UNUSED(arg);
33 
34 	key = irq_lock();
35 
36 	/* Install default handler that simply resets the CPU
37 	 * if configured in the kernel, NOP otherwise
38 	 */
39 	NMI_INIT();
40 
41 	irq_unlock(key);
42 
43 	/*HW semaphore Clock enable*/
44 	LL_AHB3_GRP1_EnableClock(LL_AHB3_GRP1_PERIPH_HSEM);
45 
46 	/* Update CMSIS SystemCoreClock variable (HCLK) */
47 	SystemCoreClock = 209000000;
48 
49 	return 0;
50 }
51 
52 SYS_INIT(stm32m4_init, PRE_KERNEL_1, 0);
53