blob: 00196ee15e739155831d08c894f1f315dac1ff2e [file] [log] [blame]
Stephen Boyd49fc8252014-03-21 17:59:37 -07001/*
2 * Copyright (c) 2014, The Linux Foundation. All rights reserved.
3 *
4 * This software is licensed under the terms of the GNU General Public
5 * License version 2, as published by the Free Software Foundation, and
6 * may be copied, distributed, and modified under those terms.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 */
13#ifndef __QCOM_CLK_COMMON_H__
14#define __QCOM_CLK_COMMON_H__
15
16struct platform_device;
17struct regmap_config;
18struct clk_regmap;
19struct qcom_reset_map;
Stephen Boyd5b6b7492014-07-15 14:59:21 -070020struct regmap;
Stephen Boyd50c6a502014-09-04 13:21:50 -070021struct freq_tbl;
Georgi Djakov293d2e972015-03-20 18:30:26 +020022struct clk_hw;
Stephen Boyd49fc8252014-03-21 17:59:37 -070023
Rajendra Nayak400d9fd2016-09-29 14:05:45 +053024#define PLL_LOCK_COUNT_SHIFT 8
25#define PLL_LOCK_COUNT_MASK 0x3f
26#define PLL_BIAS_COUNT_SHIFT 14
27#define PLL_BIAS_COUNT_MASK 0x3f
28#define PLL_VOTE_FSM_ENA BIT(20)
29#define PLL_VOTE_FSM_RESET BIT(21)
30
Stephen Boyd49fc8252014-03-21 17:59:37 -070031struct qcom_cc_desc {
32 const struct regmap_config *config;
33 struct clk_regmap **clks;
34 size_t num_clks;
35 const struct qcom_reset_map *resets;
36 size_t num_resets;
Rajendra Nayak5e5cc242015-08-06 16:07:43 +053037 struct gdsc **gdscs;
38 size_t num_gdscs;
Stephen Boyd49fc8252014-03-21 17:59:37 -070039};
40
Abhishek Sahudf964012017-12-13 19:55:33 +053041/**
42 * struct parent_map - map table for source select configuration values
43 * @src: source
44 * @cfg: configuration value
45 */
46struct parent_map {
47 u8 src;
48 u8 cfg;
49};
50
Stephen Boyd50c6a502014-09-04 13:21:50 -070051extern const struct freq_tbl *qcom_find_freq(const struct freq_tbl *f,
52 unsigned long rate);
Rajendra Nayak081ba802016-11-21 12:07:11 +053053extern const struct freq_tbl *qcom_find_freq_floor(const struct freq_tbl *f,
54 unsigned long rate);
Rajendra Nayak400d9fd2016-09-29 14:05:45 +053055extern void
56qcom_pll_set_fsm_mode(struct regmap *m, u32 reg, u8 bias_count, u8 lock_count);
Georgi Djakov293d2e972015-03-20 18:30:26 +020057extern int qcom_find_src_index(struct clk_hw *hw, const struct parent_map *map,
58 u8 src);
Stephen Boyd50c6a502014-09-04 13:21:50 -070059
Stephen Boydee15faf2015-10-26 17:11:32 -070060extern int qcom_cc_register_board_clk(struct device *dev, const char *path,
61 const char *name, unsigned long rate);
62extern int qcom_cc_register_sleep_clk(struct device *dev);
63
Stephen Boyd5b6b7492014-07-15 14:59:21 -070064extern struct regmap *qcom_cc_map(struct platform_device *pdev,
65 const struct qcom_cc_desc *desc);
66extern int qcom_cc_really_probe(struct platform_device *pdev,
67 const struct qcom_cc_desc *desc,
68 struct regmap *regmap);
Stephen Boyd49fc8252014-03-21 17:59:37 -070069extern int qcom_cc_probe(struct platform_device *pdev,
70 const struct qcom_cc_desc *desc);
71
Stephen Boyd49fc8252014-03-21 17:59:37 -070072#endif