cfg_clock_values.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2020 Savoir-faire Linux
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser General
5  * Public License v2.1. See the file LICENSE in the top level directory for more
6  * details.
7  */
8 
19 #ifndef CLK_MP1_CFG_CLOCK_VALUES_H
20 #define CLK_MP1_CFG_CLOCK_VALUES_H
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
30 #if IS_ACTIVE(CONFIG_BOARD_HAS_HSE)
31 #define CLOCK_PLL_SRC (CLOCK_HSE)
32 #else /* CLOCK_HSI */
33 #define CLOCK_PLL_SRC (CLOCK_HSI)
34 #endif
35 
36 #if IS_ACTIVE(CONFIG_USE_CLOCK_HSI)
37 #define CLOCK_CORECLOCK (CLOCK_HSI)
38 
39 #elif IS_ACTIVE(CONFIG_USE_CLOCK_HSE)
40 #if !IS_ACTIVE(CONFIG_BOARD_HAS_HSE)
41 #error "The board doesn't provide an HSE oscillator"
42 #endif
43 #define CLOCK_CORECLOCK (CLOCK_HSE)
44 
45 #elif IS_ACTIVE(CONFIG_USE_CLOCK_PLL)
46 #define CLOCK_CORECLOCK (((CLOCK_PLL_SRC / CONFIG_CLOCK_PLL_M) \
47  * CONFIG_CLOCK_PLL_N) / CONFIG_CLOCK_PLL_P)
48 #endif /* CONFIG_USE_CLOCK_PLL */
49 
50 #define CLOCK_PLLQ (((CLOCK_PLL_SRC / CONFIG_CLOCK_PLL_M) \
51  * CONFIG_CLOCK_PLL_N) / CONFIG_CLOCK_PLL_Q)
52 
53 #define CLOCK_APB1 (CLOCK_CORECLOCK \
54  / CONFIG_CLOCK_APB1_DIV)
55 #define CLOCK_APB2 (CLOCK_CORECLOCK \
56  / CONFIG_CLOCK_APB2_DIV)
57 
60 #ifdef __cplusplus
61 }
62 #endif
63 
64 #endif /* CLK_MP1_CFG_CLOCK_VALUES_H */
65