xref: /linux/drivers/clk/sunxi-ng/ccu_frac.h (revision 26fbb4c8c7c3ee9a4c3b4de555a8587b5a19154e)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Copyright (c) 2016 Maxime Ripard. All rights reserved.
4  */
5 
6 #ifndef _CCU_FRAC_H_
7 #define _CCU_FRAC_H_
8 
9 #include <linux/clk-provider.h>
10 
11 #include "ccu_common.h"
12 
13 struct ccu_frac_internal {
14 	u32		enable;
15 	u32		select;
16 
17 	unsigned long	rates[2];
18 };
19 
20 #define _SUNXI_CCU_FRAC(_enable, _select, _rate1, _rate2)		\
21 	{								\
22 		.enable	= _enable,					\
23 		.select	= _select,					\
24 		.rates = { _rate1, _rate2 },				\
25 	}
26 
27 bool ccu_frac_helper_is_enabled(struct ccu_common *common,
28 				struct ccu_frac_internal *cf);
29 void ccu_frac_helper_enable(struct ccu_common *common,
30 			    struct ccu_frac_internal *cf);
31 void ccu_frac_helper_disable(struct ccu_common *common,
32 			     struct ccu_frac_internal *cf);
33 
34 bool ccu_frac_helper_has_rate(struct ccu_common *common,
35 			      struct ccu_frac_internal *cf,
36 			      unsigned long rate);
37 
38 unsigned long ccu_frac_helper_read_rate(struct ccu_common *common,
39 					struct ccu_frac_internal *cf);
40 
41 int ccu_frac_helper_set_rate(struct ccu_common *common,
42 			     struct ccu_frac_internal *cf,
43 			     unsigned long rate, u32 lock);
44 
45 #endif /* _CCU_FRAC_H_ */
46