blob: 66755f0f84fcb1cc8d63369bc70a0727bcc1127a [file] [log] [blame]
Taniya Dasf9419782018-07-16 11:24:32 +05301/* SPDX-License-Identifier: GPL-2.0 */
2/* Copyright (c) 2015, 2018, The Linux Foundation. All rights reserved. */
Stephen Boyd8ff1f4c2015-11-30 17:31:39 -08003
4#ifndef __QCOM_CLK_ALPHA_PLL_H__
5#define __QCOM_CLK_ALPHA_PLL_H__
6
7#include <linux/clk-provider.h>
8#include "clk-regmap.h"
9
Abhishek Sahu28d3f062017-09-28 23:20:40 +053010/* Alpha PLL types */
11enum {
12 CLK_ALPHA_PLL_TYPE_DEFAULT,
Abhishek Sahu134b55b2017-09-28 23:20:46 +053013 CLK_ALPHA_PLL_TYPE_HUAYRA,
Abhishek Sahuc23e8a12017-09-28 23:20:48 +053014 CLK_ALPHA_PLL_TYPE_BRAMMO,
Amit Nischal687d7a02018-03-08 12:48:14 +053015 CLK_ALPHA_PLL_TYPE_FABIA,
Abhishek Sahu28d3f062017-09-28 23:20:40 +053016 CLK_ALPHA_PLL_TYPE_MAX,
17};
18
19enum {
20 PLL_OFF_L_VAL,
21 PLL_OFF_ALPHA_VAL,
22 PLL_OFF_ALPHA_VAL_U,
23 PLL_OFF_USER_CTL,
24 PLL_OFF_USER_CTL_U,
25 PLL_OFF_CONFIG_CTL,
26 PLL_OFF_CONFIG_CTL_U,
27 PLL_OFF_TEST_CTL,
28 PLL_OFF_TEST_CTL_U,
29 PLL_OFF_STATUS,
Amit Nischal687d7a02018-03-08 12:48:14 +053030 PLL_OFF_OPMODE,
31 PLL_OFF_FRAC,
Abhishek Sahu28d3f062017-09-28 23:20:40 +053032 PLL_OFF_MAX_REGS
33};
34
35extern const u8 clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_MAX][PLL_OFF_MAX_REGS];
36
Stephen Boyd8ff1f4c2015-11-30 17:31:39 -080037struct pll_vco {
38 unsigned long min_freq;
39 unsigned long max_freq;
40 u32 val;
41};
42
43/**
44 * struct clk_alpha_pll - phase locked loop (PLL)
45 * @offset: base address of registers
46 * @vco_table: array of VCO settings
Abhishek Sahu28d3f062017-09-28 23:20:40 +053047 * @regs: alpha pll register map (see @clk_alpha_pll_regs)
Stephen Boyd8ff1f4c2015-11-30 17:31:39 -080048 * @clkr: regmap clock handle
49 */
50struct clk_alpha_pll {
51 u32 offset;
Abhishek Sahu28d3f062017-09-28 23:20:40 +053052 const u8 *regs;
Stephen Boyd8ff1f4c2015-11-30 17:31:39 -080053
54 const struct pll_vco *vco_table;
55 size_t num_vco;
Rajendra Nayakfeb65642016-09-29 14:05:42 +053056#define SUPPORTS_OFFLINE_REQ BIT(0)
Rajendra Nayak400d9fd2016-09-29 14:05:45 +053057#define SUPPORTS_FSM_MODE BIT(2)
Abhishek Sahu472796d2017-09-28 23:20:45 +053058#define SUPPORTS_DYNAMIC_UPDATE BIT(3)
Rajendra Nayakfeb65642016-09-29 14:05:42 +053059 u8 flags;
Stephen Boyd8ff1f4c2015-11-30 17:31:39 -080060
61 struct clk_regmap clkr;
62};
63
64/**
65 * struct clk_alpha_pll_postdiv - phase locked loop (PLL) post-divider
66 * @offset: base address of registers
Abhishek Sahu28d3f062017-09-28 23:20:40 +053067 * @regs: alpha pll register map (see @clk_alpha_pll_regs)
Stephen Boyd8ff1f4c2015-11-30 17:31:39 -080068 * @width: width of post-divider
Amit Nischal687d7a02018-03-08 12:48:14 +053069 * @post_div_shift: shift to differentiate between odd & even post-divider
70 * @post_div_table: table with PLL odd and even post-divider settings
71 * @num_post_div: Number of PLL post-divider settings
72 *
Stephen Boyd8ff1f4c2015-11-30 17:31:39 -080073 * @clkr: regmap clock handle
74 */
75struct clk_alpha_pll_postdiv {
76 u32 offset;
77 u8 width;
Abhishek Sahu28d3f062017-09-28 23:20:40 +053078 const u8 *regs;
Stephen Boyd8ff1f4c2015-11-30 17:31:39 -080079
80 struct clk_regmap clkr;
Amit Nischal687d7a02018-03-08 12:48:14 +053081 int post_div_shift;
82 const struct clk_div_table *post_div_table;
83 size_t num_post_div;
Stephen Boyd8ff1f4c2015-11-30 17:31:39 -080084};
85
Rajendra Nayak9f4e6272016-09-29 14:05:43 +053086struct alpha_pll_config {
87 u32 l;
88 u32 alpha;
Abhishek Sahuc45ae592017-09-28 23:20:44 +053089 u32 alpha_hi;
Rajendra Nayak9f4e6272016-09-29 14:05:43 +053090 u32 config_ctl_val;
91 u32 config_ctl_hi_val;
92 u32 main_output_mask;
93 u32 aux_output_mask;
94 u32 aux2_output_mask;
95 u32 early_output_mask;
Abhishek Sahuc45ae592017-09-28 23:20:44 +053096 u32 alpha_en_mask;
97 u32 alpha_mode_mask;
Rajendra Nayak9f4e6272016-09-29 14:05:43 +053098 u32 pre_div_val;
99 u32 pre_div_mask;
100 u32 post_div_val;
101 u32 post_div_mask;
102 u32 vco_val;
103 u32 vco_mask;
104};
105
Stephen Boyd8ff1f4c2015-11-30 17:31:39 -0800106extern const struct clk_ops clk_alpha_pll_ops;
Rajendra Nayakfeb65642016-09-29 14:05:42 +0530107extern const struct clk_ops clk_alpha_pll_hwfsm_ops;
Stephen Boyd8ff1f4c2015-11-30 17:31:39 -0800108extern const struct clk_ops clk_alpha_pll_postdiv_ops;
Abhishek Sahu134b55b2017-09-28 23:20:46 +0530109extern const struct clk_ops clk_alpha_pll_huayra_ops;
Abhishek Sahu23c68cc2017-09-28 23:20:50 +0530110extern const struct clk_ops clk_alpha_pll_postdiv_ro_ops;
Stephen Boyd8ff1f4c2015-11-30 17:31:39 -0800111
Amit Nischal687d7a02018-03-08 12:48:14 +0530112extern const struct clk_ops clk_alpha_pll_fabia_ops;
113extern const struct clk_ops clk_alpha_pll_fixed_fabia_ops;
114extern const struct clk_ops clk_alpha_pll_postdiv_fabia_ops;
115
Rajendra Nayak9f4e6272016-09-29 14:05:43 +0530116void clk_alpha_pll_configure(struct clk_alpha_pll *pll, struct regmap *regmap,
117 const struct alpha_pll_config *config);
Amit Nischal687d7a02018-03-08 12:48:14 +0530118void clk_fabia_pll_configure(struct clk_alpha_pll *pll, struct regmap *regmap,
119 const struct alpha_pll_config *config);
Rajendra Nayak9f4e6272016-09-29 14:05:43 +0530120
Stephen Boyd8ff1f4c2015-11-30 17:31:39 -0800121#endif