Yann Gautier | 9aea69e | 2018-07-24 17:13:36 +0200 | [diff] [blame] | 1 | /* |
Yann Gautier | a2e2a30 | 2019-02-14 11:13:39 +0100 | [diff] [blame] | 2 | * Copyright (c) 2018-2019, STMicroelectronics - All Rights Reserved |
Yann Gautier | 9aea69e | 2018-07-24 17:13:36 +0200 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
Antonio Nino Diaz | 5eb8837 | 2018-11-08 10:20:19 +0000 | [diff] [blame] | 7 | #ifndef STM32MP1_CLK_H |
| 8 | #define STM32MP1_CLK_H |
Yann Gautier | 9aea69e | 2018-07-24 17:13:36 +0200 | [diff] [blame] | 9 | |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 10 | #include <arch_helpers.h> |
| 11 | |
Yann Gautier | 9aea69e | 2018-07-24 17:13:36 +0200 | [diff] [blame] | 12 | int stm32mp1_clk_probe(void); |
| 13 | int stm32mp1_clk_init(void); |
Yann Gautier | e4a3c35 | 2019-02-14 10:53:33 +0100 | [diff] [blame] | 14 | |
| 15 | bool stm32mp1_rcc_is_secure(void); |
Yann Gautier | ed34232 | 2019-02-15 17:33:27 +0100 | [diff] [blame] | 16 | bool stm32mp1_rcc_is_mckprot(void); |
Yann Gautier | e4a3c35 | 2019-02-14 10:53:33 +0100 | [diff] [blame] | 17 | |
| 18 | void __stm32mp1_clk_enable(unsigned long id, bool caller_is_secure); |
| 19 | void __stm32mp1_clk_disable(unsigned long id, bool caller_is_secure); |
| 20 | |
| 21 | static inline void stm32mp1_clk_enable_non_secure(unsigned long id) |
| 22 | { |
| 23 | __stm32mp1_clk_enable(id, false); |
| 24 | } |
| 25 | |
| 26 | static inline void stm32mp1_clk_enable_secure(unsigned long id) |
| 27 | { |
| 28 | __stm32mp1_clk_enable(id, true); |
| 29 | } |
| 30 | |
| 31 | static inline void stm32mp1_clk_disable_non_secure(unsigned long id) |
| 32 | { |
| 33 | __stm32mp1_clk_disable(id, false); |
| 34 | } |
| 35 | |
| 36 | static inline void stm32mp1_clk_disable_secure(unsigned long id) |
| 37 | { |
| 38 | __stm32mp1_clk_disable(id, true); |
| 39 | } |
| 40 | |
| 41 | unsigned int stm32mp1_clk_get_refcount(unsigned long id); |
| 42 | |
| 43 | /* SMP protection on RCC registers access */ |
| 44 | void stm32mp1_clk_rcc_regs_lock(void); |
| 45 | void stm32mp1_clk_rcc_regs_unlock(void); |
| 46 | |
Yann Gautier | 9aea69e | 2018-07-24 17:13:36 +0200 | [diff] [blame] | 47 | void stm32mp1_stgen_increment(unsigned long long offset_in_ms); |
| 48 | |
Antonio Nino Diaz | 5eb8837 | 2018-11-08 10:20:19 +0000 | [diff] [blame] | 49 | #endif /* STM32MP1_CLK_H */ |