162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci/* Copyright (c) 2014, The Linux Foundation. All rights reserved. */
362306a36Sopenharmony_ci
462306a36Sopenharmony_ci#ifndef __QCOM_CLK_COMMON_H__
562306a36Sopenharmony_ci#define __QCOM_CLK_COMMON_H__
662306a36Sopenharmony_ci
762306a36Sopenharmony_cistruct platform_device;
862306a36Sopenharmony_cistruct regmap_config;
962306a36Sopenharmony_cistruct clk_regmap;
1062306a36Sopenharmony_cistruct qcom_reset_map;
1162306a36Sopenharmony_cistruct regmap;
1262306a36Sopenharmony_cistruct freq_tbl;
1362306a36Sopenharmony_cistruct clk_hw;
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ci#define PLL_LOCK_COUNT_SHIFT	8
1662306a36Sopenharmony_ci#define PLL_LOCK_COUNT_MASK	0x3f
1762306a36Sopenharmony_ci#define PLL_BIAS_COUNT_SHIFT	14
1862306a36Sopenharmony_ci#define PLL_BIAS_COUNT_MASK	0x3f
1962306a36Sopenharmony_ci#define PLL_VOTE_FSM_ENA	BIT(20)
2062306a36Sopenharmony_ci#define PLL_VOTE_FSM_RESET	BIT(21)
2162306a36Sopenharmony_ci
2262306a36Sopenharmony_cistruct qcom_cc_desc {
2362306a36Sopenharmony_ci	const struct regmap_config *config;
2462306a36Sopenharmony_ci	struct clk_regmap **clks;
2562306a36Sopenharmony_ci	size_t num_clks;
2662306a36Sopenharmony_ci	const struct qcom_reset_map *resets;
2762306a36Sopenharmony_ci	size_t num_resets;
2862306a36Sopenharmony_ci	struct gdsc **gdscs;
2962306a36Sopenharmony_ci	size_t num_gdscs;
3062306a36Sopenharmony_ci	struct clk_hw **clk_hws;
3162306a36Sopenharmony_ci	size_t num_clk_hws;
3262306a36Sopenharmony_ci};
3362306a36Sopenharmony_ci
3462306a36Sopenharmony_ci/**
3562306a36Sopenharmony_ci * struct parent_map - map table for source select configuration values
3662306a36Sopenharmony_ci * @src: source
3762306a36Sopenharmony_ci * @cfg: configuration value
3862306a36Sopenharmony_ci */
3962306a36Sopenharmony_cistruct parent_map {
4062306a36Sopenharmony_ci	u8 src;
4162306a36Sopenharmony_ci	u8 cfg;
4262306a36Sopenharmony_ci};
4362306a36Sopenharmony_ci
4462306a36Sopenharmony_ciextern const struct freq_tbl *qcom_find_freq(const struct freq_tbl *f,
4562306a36Sopenharmony_ci					     unsigned long rate);
4662306a36Sopenharmony_ciextern const struct freq_tbl *qcom_find_freq_floor(const struct freq_tbl *f,
4762306a36Sopenharmony_ci						   unsigned long rate);
4862306a36Sopenharmony_ciextern void
4962306a36Sopenharmony_ciqcom_pll_set_fsm_mode(struct regmap *m, u32 reg, u8 bias_count, u8 lock_count);
5062306a36Sopenharmony_ciextern int qcom_find_src_index(struct clk_hw *hw, const struct parent_map *map,
5162306a36Sopenharmony_ci			       u8 src);
5262306a36Sopenharmony_ciextern int qcom_find_cfg_index(struct clk_hw *hw, const struct parent_map *map,
5362306a36Sopenharmony_ci			       u8 cfg);
5462306a36Sopenharmony_ci
5562306a36Sopenharmony_ciextern int qcom_cc_register_board_clk(struct device *dev, const char *path,
5662306a36Sopenharmony_ci				      const char *name, unsigned long rate);
5762306a36Sopenharmony_ciextern int qcom_cc_register_sleep_clk(struct device *dev);
5862306a36Sopenharmony_ci
5962306a36Sopenharmony_ciextern struct regmap *qcom_cc_map(struct platform_device *pdev,
6062306a36Sopenharmony_ci				  const struct qcom_cc_desc *desc);
6162306a36Sopenharmony_ciextern int qcom_cc_really_probe(struct platform_device *pdev,
6262306a36Sopenharmony_ci				const struct qcom_cc_desc *desc,
6362306a36Sopenharmony_ci				struct regmap *regmap);
6462306a36Sopenharmony_ciextern int qcom_cc_probe(struct platform_device *pdev,
6562306a36Sopenharmony_ci			 const struct qcom_cc_desc *desc);
6662306a36Sopenharmony_ciextern int qcom_cc_probe_by_index(struct platform_device *pdev, int index,
6762306a36Sopenharmony_ci				  const struct qcom_cc_desc *desc);
6862306a36Sopenharmony_ci
6962306a36Sopenharmony_ci#endif
70