xref: /rk3399_ARM-atf/include/drivers/clk.h (revision 0567eca0b940f0636ddd284a1a50f815ac6636d5)
1847c6bc8SGabriel Fernandez /*
2847c6bc8SGabriel Fernandez  * Copyright (c) 2021, STMicroelectronics - All Rights Reserved
3847c6bc8SGabriel Fernandez  *
4847c6bc8SGabriel Fernandez  * SPDX-License-Identifier: BSD-3-Clause
5847c6bc8SGabriel Fernandez  */
6847c6bc8SGabriel Fernandez 
7847c6bc8SGabriel Fernandez #ifndef CLK_H
8847c6bc8SGabriel Fernandez #define CLK_H
9847c6bc8SGabriel Fernandez 
10847c6bc8SGabriel Fernandez #include <stdbool.h>
11847c6bc8SGabriel Fernandez 
12847c6bc8SGabriel Fernandez struct clk_ops {
13847c6bc8SGabriel Fernandez 	int (*enable)(unsigned long id);
14847c6bc8SGabriel Fernandez 	void (*disable)(unsigned long id);
15847c6bc8SGabriel Fernandez 	unsigned long (*get_rate)(unsigned long id);
16*19f9e2e6SGhennadi Procopciuc 	int (*set_rate)(unsigned long id, unsigned long rate,
17*19f9e2e6SGhennadi Procopciuc 			unsigned long *orate);
18847c6bc8SGabriel Fernandez 	int (*get_parent)(unsigned long id);
19a2c6016fSGhennadi Procopciuc 	int (*set_parent)(unsigned long id, unsigned long parent_id);
20847c6bc8SGabriel Fernandez 	bool (*is_enabled)(unsigned long id);
21847c6bc8SGabriel Fernandez };
22847c6bc8SGabriel Fernandez 
23847c6bc8SGabriel Fernandez int clk_enable(unsigned long id);
24847c6bc8SGabriel Fernandez void clk_disable(unsigned long id);
25847c6bc8SGabriel Fernandez unsigned long clk_get_rate(unsigned long id);
26*19f9e2e6SGhennadi Procopciuc int clk_set_rate(unsigned long id, unsigned long rate, unsigned long *orate);
27847c6bc8SGabriel Fernandez bool clk_is_enabled(unsigned long id);
28847c6bc8SGabriel Fernandez int clk_get_parent(unsigned long id);
29a2c6016fSGhennadi Procopciuc int clk_set_parent(unsigned long id, unsigned long parent_id);
30847c6bc8SGabriel Fernandez 
31847c6bc8SGabriel Fernandez void clk_register(const struct clk_ops *ops);
32847c6bc8SGabriel Fernandez 
33847c6bc8SGabriel Fernandez #endif /* CLK_H */
34