cfg_clock_common.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_COMMON_H
20 #define CLK_MP1_CFG_CLOCK_COMMON_H
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
30 /* Select the desired system clock source between PLL, HSE or HSI */
31 #ifndef CONFIG_USE_CLOCK_PLL
32 #if IS_ACTIVE(CONFIG_USE_CLOCK_HSE) || IS_ACTIVE(CONFIG_USE_CLOCK_HSI)
33 #define CONFIG_USE_CLOCK_PLL 0
34 #else
35 #define CONFIG_USE_CLOCK_PLL 1 /* Use PLL by default */
36 #endif
37 #endif /* CONFIG_USE_CLOCK_PLL */
38 
39 #ifndef CONFIG_USE_CLOCK_HSE
40 #define CONFIG_USE_CLOCK_HSE 0
41 #endif /* CONFIG_USE_CLOCK_HSE */
42 
43 #ifndef CONFIG_USE_CLOCK_HSI
44 #define CONFIG_USE_CLOCK_HSI 0
45 #endif /* CONFIG_USE_CLOCK_HSI */
46 
47 #if IS_ACTIVE(CONFIG_USE_CLOCK_PLL) && \
48  (IS_ACTIVE(CONFIG_USE_CLOCK_HSE) || IS_ACTIVE(CONFIG_USE_CLOCK_HSI))
49 #error "Cannot use PLL as clock source with other clock configurations"
50 #endif
51 
52 #if IS_ACTIVE(CONFIG_USE_CLOCK_HSE) && \
53  (IS_ACTIVE(CONFIG_USE_CLOCK_PLL) || IS_ACTIVE(CONFIG_USE_CLOCK_HSI))
54 #error "Cannot use HSE as clock source with other clock configurations"
55 #endif
56 
57 #if IS_ACTIVE(CONFIG_USE_CLOCK_HSI) && \
58  (IS_ACTIVE(CONFIG_USE_CLOCK_PLL) || IS_ACTIVE(CONFIG_USE_CLOCK_HSE))
59 #error "Cannot use HSI as clock source with other clock configurations"
60 #endif
61 
62 #ifndef CONFIG_BOARD_HAS_HSE
63 #define CONFIG_BOARD_HAS_HSE 0
64 #endif
65 
66 #ifndef CLOCK_HSE
67 #define CLOCK_HSE MHZ(24)
68 #endif
69 
70 #define CLOCK_HSI MHZ(64)
71 
72 #ifdef __cplusplus
73 }
74 #endif
75 
76 #endif /* CLK_MP1_CFG_CLOCK_COMMON_H */
77