Stephen Boyd | 49fc825 | 2014-03-21 17:59:37 -0700 | [diff] [blame] | 1 | /* |
Deepak Katragadda | 7abd931 | 2016-12-21 14:18:00 -0800 | [diff] [blame] | 2 | * Copyright (c) 2014-2017, The Linux Foundation. All rights reserved. |
Stephen Boyd | 49fc825 | 2014-03-21 17:59:37 -0700 | [diff] [blame] | 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 | |
Deepak Katragadda | 88c266f | 2016-11-02 14:46:56 -0700 | [diff] [blame] | 16 | #include <linux/reset-controller.h> |
Taniya Das | 1e69ca1 | 2017-04-13 15:19:58 +0530 | [diff] [blame^] | 17 | #include "clk-rcg.h" |
Deepak Katragadda | 88c266f | 2016-11-02 14:46:56 -0700 | [diff] [blame] | 18 | |
Stephen Boyd | 49fc825 | 2014-03-21 17:59:37 -0700 | [diff] [blame] | 19 | struct platform_device; |
| 20 | struct regmap_config; |
| 21 | struct clk_regmap; |
| 22 | struct qcom_reset_map; |
Stephen Boyd | 5b6b749 | 2014-07-15 14:59:21 -0700 | [diff] [blame] | 23 | struct regmap; |
Stephen Boyd | 50c6a50 | 2014-09-04 13:21:50 -0700 | [diff] [blame] | 24 | struct freq_tbl; |
Georgi Djakov | 293d2e97 | 2015-03-20 18:30:26 +0200 | [diff] [blame] | 25 | struct clk_hw; |
| 26 | struct parent_map; |
Stephen Boyd | 49fc825 | 2014-03-21 17:59:37 -0700 | [diff] [blame] | 27 | |
| 28 | struct 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 Nayak | 5e5cc24 | 2015-08-06 16:07:43 +0530 | [diff] [blame] | 34 | struct gdsc **gdscs; |
| 35 | size_t num_gdscs; |
Stephen Boyd | 49fc825 | 2014-03-21 17:59:37 -0700 | [diff] [blame] | 36 | }; |
| 37 | |
Deepak Katragadda | 88c266f | 2016-11-02 14:46:56 -0700 | [diff] [blame] | 38 | struct clk_dummy { |
| 39 | struct clk_hw hw; |
| 40 | struct reset_controller_dev reset; |
| 41 | unsigned long rrate; |
| 42 | }; |
| 43 | |
Taniya Das | 1e69ca1 | 2017-04-13 15:19:58 +0530 | [diff] [blame^] | 44 | struct clk_dfs { |
| 45 | struct clk_rcg2 *rcg; |
| 46 | u8 rcg_flags; |
| 47 | }; |
| 48 | |
| 49 | struct qcom_cc_dfs_desc { |
| 50 | struct clk_dfs *clks; |
| 51 | size_t num_clks; |
| 52 | }; |
| 53 | |
Stephen Boyd | 50c6a50 | 2014-09-04 13:21:50 -0700 | [diff] [blame] | 54 | extern const struct freq_tbl *qcom_find_freq(const struct freq_tbl *f, |
| 55 | unsigned long rate); |
Georgi Djakov | 293d2e97 | 2015-03-20 18:30:26 +0200 | [diff] [blame] | 56 | extern int qcom_find_src_index(struct clk_hw *hw, const struct parent_map *map, |
| 57 | u8 src); |
Stephen Boyd | 50c6a50 | 2014-09-04 13:21:50 -0700 | [diff] [blame] | 58 | |
Stephen Boyd | ee15faf | 2015-10-26 17:11:32 -0700 | [diff] [blame] | 59 | extern int qcom_cc_register_board_clk(struct device *dev, const char *path, |
| 60 | const char *name, unsigned long rate); |
| 61 | extern int qcom_cc_register_sleep_clk(struct device *dev); |
| 62 | |
Stephen Boyd | 5b6b749 | 2014-07-15 14:59:21 -0700 | [diff] [blame] | 63 | extern struct regmap *qcom_cc_map(struct platform_device *pdev, |
| 64 | const struct qcom_cc_desc *desc); |
| 65 | extern int qcom_cc_really_probe(struct platform_device *pdev, |
| 66 | const struct qcom_cc_desc *desc, |
| 67 | struct regmap *regmap); |
Stephen Boyd | 49fc825 | 2014-03-21 17:59:37 -0700 | [diff] [blame] | 68 | extern int qcom_cc_probe(struct platform_device *pdev, |
| 69 | const struct qcom_cc_desc *desc); |
Taniya Das | 1e69ca1 | 2017-04-13 15:19:58 +0530 | [diff] [blame^] | 70 | |
| 71 | extern int qcom_cc_register_rcg_dfs(struct platform_device *pdev, |
| 72 | const struct qcom_cc_dfs_desc *desc); |
| 73 | |
Taniya Das | 5d12118 | 2016-06-06 15:52:09 +0530 | [diff] [blame] | 74 | extern struct clk_ops clk_dummy_ops; |
Deepak Katragadda | 7abd931 | 2016-12-21 14:18:00 -0800 | [diff] [blame] | 75 | |
| 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 Boyd | 49fc825 | 2014-03-21 17:59:37 -0700 | [diff] [blame] | 79 | #endif |