blob: 5e26763d153f74ed77b6fc9fd428c05c83be2d13 [file] [log] [blame]
Stephen Boyd49fc8252014-03-21 17:59:37 -07001/*
Deepak Katragadda7abd9312016-12-21 14:18:00 -08002 * Copyright (c) 2014-2017, The Linux Foundation. All rights reserved.
Stephen Boyd49fc8252014-03-21 17:59:37 -07003 *
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
Deepak Katragadda88c266f2016-11-02 14:46:56 -070016#include <linux/reset-controller.h>
Taniya Das1e69ca12017-04-13 15:19:58 +053017#include "clk-rcg.h"
Deepak Katragadda88c266f2016-11-02 14:46:56 -070018
Stephen Boyd49fc8252014-03-21 17:59:37 -070019struct platform_device;
20struct regmap_config;
21struct clk_regmap;
22struct qcom_reset_map;
Stephen Boyd5b6b7492014-07-15 14:59:21 -070023struct regmap;
Stephen Boyd50c6a502014-09-04 13:21:50 -070024struct freq_tbl;
Georgi Djakov293d2e972015-03-20 18:30:26 +020025struct clk_hw;
26struct parent_map;
Stephen Boyd49fc8252014-03-21 17:59:37 -070027
28struct qcom_cc_desc {
29 const struct regmap_config *config;
30 struct clk_regmap **clks;
31 size_t num_clks;
32 const struct qcom_reset_map *resets;
33 size_t num_resets;
Rajendra Nayak5e5cc242015-08-06 16:07:43 +053034 struct gdsc **gdscs;
35 size_t num_gdscs;
Stephen Boyd49fc8252014-03-21 17:59:37 -070036};
37
Deepak Katragadda88c266f2016-11-02 14:46:56 -070038struct clk_dummy {
39 struct clk_hw hw;
40 struct reset_controller_dev reset;
41 unsigned long rrate;
42};
43
Taniya Das1e69ca12017-04-13 15:19:58 +053044struct clk_dfs {
45 struct clk_rcg2 *rcg;
46 u8 rcg_flags;
47};
48
49struct qcom_cc_dfs_desc {
50 struct clk_dfs *clks;
51 size_t num_clks;
52};
53
Stephen Boyd50c6a502014-09-04 13:21:50 -070054extern const struct freq_tbl *qcom_find_freq(const struct freq_tbl *f,
55 unsigned long rate);
Georgi Djakov293d2e972015-03-20 18:30:26 +020056extern int qcom_find_src_index(struct clk_hw *hw, const struct parent_map *map,
57 u8 src);
Stephen Boyd50c6a502014-09-04 13:21:50 -070058
Stephen Boydee15faf2015-10-26 17:11:32 -070059extern int qcom_cc_register_board_clk(struct device *dev, const char *path,
60 const char *name, unsigned long rate);
61extern int qcom_cc_register_sleep_clk(struct device *dev);
62
Stephen Boyd5b6b7492014-07-15 14:59:21 -070063extern struct regmap *qcom_cc_map(struct platform_device *pdev,
64 const struct qcom_cc_desc *desc);
65extern int qcom_cc_really_probe(struct platform_device *pdev,
66 const struct qcom_cc_desc *desc,
67 struct regmap *regmap);
Stephen Boyd49fc8252014-03-21 17:59:37 -070068extern int qcom_cc_probe(struct platform_device *pdev,
69 const struct qcom_cc_desc *desc);
Taniya Das1e69ca12017-04-13 15:19:58 +053070
71extern int qcom_cc_register_rcg_dfs(struct platform_device *pdev,
72 const struct qcom_cc_dfs_desc *desc);
73
Taniya Das5d121182016-06-06 15:52:09 +053074extern struct clk_ops clk_dummy_ops;
Deepak Katragadda7abd9312016-12-21 14:18:00 -080075
76#define BM(msb, lsb) (((((uint32_t)-1) << (31-msb)) >> (31-msb+lsb)) << lsb)
77#define BVAL(msb, lsb, val) (((val) << lsb) & BM(msb, lsb))
78
Stephen Boyd49fc8252014-03-21 17:59:37 -070079#endif