1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright (c) 2014, The Linux Foundation. All rights reserved. */
3 
4 #ifndef __QCOM_CLK_COMMON_H__
5 #define __QCOM_CLK_COMMON_H__
6 
7 struct platform_device;
8 struct regmap_config;
9 struct clk_regmap;
10 struct qcom_reset_map;
11 struct regmap;
12 struct freq_tbl;
13 struct clk_hw;
14 
15 #define PLL_LOCK_COUNT_SHIFT	8
16 #define PLL_LOCK_COUNT_MASK	0x3f
17 #define PLL_BIAS_COUNT_SHIFT	14
18 #define PLL_BIAS_COUNT_MASK	0x3f
19 #define PLL_VOTE_FSM_ENA	BIT(20)
20 #define PLL_VOTE_FSM_RESET	BIT(21)
21 
22 struct qcom_cc_desc {
23 	const struct regmap_config *config;
24 	struct clk_regmap **clks;
25 	size_t num_clks;
26 	const struct qcom_reset_map *resets;
27 	size_t num_resets;
28 	struct gdsc **gdscs;
29 	size_t num_gdscs;
30 	struct clk_hw **clk_hws;
31 	size_t num_clk_hws;
32 };
33 
34 /**
35  * struct parent_map - map table for source select configuration values
36  * @src: source
37  * @cfg: configuration value
38  */
39 struct parent_map {
40 	u8 src;
41 	u8 cfg;
42 };
43 
44 extern const struct freq_tbl *qcom_find_freq(const struct freq_tbl *f,
45 					     unsigned long rate);
46 extern const struct freq_tbl *qcom_find_freq_floor(const struct freq_tbl *f,
47 						   unsigned long rate);
48 extern void
49 qcom_pll_set_fsm_mode(struct regmap *m, u32 reg, u8 bias_count, u8 lock_count);
50 extern int qcom_find_src_index(struct clk_hw *hw, const struct parent_map *map,
51 			       u8 src);
52 extern int qcom_find_cfg_index(struct clk_hw *hw, const struct parent_map *map,
53 			       u8 cfg);
54 
55 extern int qcom_cc_register_board_clk(struct device *dev, const char *path,
56 				      const char *name, unsigned long rate);
57 extern int qcom_cc_register_sleep_clk(struct device *dev);
58 
59 extern struct regmap *qcom_cc_map(struct platform_device *pdev,
60 				  const struct qcom_cc_desc *desc);
61 extern int qcom_cc_really_probe(struct platform_device *pdev,
62 				const struct qcom_cc_desc *desc,
63 				struct regmap *regmap);
64 extern int qcom_cc_probe(struct platform_device *pdev,
65 			 const struct qcom_cc_desc *desc);
66 extern int qcom_cc_probe_by_index(struct platform_device *pdev, int index,
67 				  const struct qcom_cc_desc *desc);
68 
69 #endif
70