blob: 667e9069d0865debd755c32bfd4953d6f3253c1d [file] [log] [blame]
Stephen Boyd8ff1f4c2015-11-30 17:31:39 -08001/*
2 * Copyright (c) 2015, 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
14#ifndef __QCOM_CLK_ALPHA_PLL_H__
15#define __QCOM_CLK_ALPHA_PLL_H__
16
17#include <linux/clk-provider.h>
18#include "clk-regmap.h"
19
Abhishek Sahu28d3f062017-09-28 23:20:40 +053020/* Alpha PLL types */
21enum {
22 CLK_ALPHA_PLL_TYPE_DEFAULT,
Abhishek Sahu134b55b2017-09-28 23:20:46 +053023 CLK_ALPHA_PLL_TYPE_HUAYRA,
Abhishek Sahu28d3f062017-09-28 23:20:40 +053024 CLK_ALPHA_PLL_TYPE_MAX,
25};
26
27enum {
28 PLL_OFF_L_VAL,
29 PLL_OFF_ALPHA_VAL,
30 PLL_OFF_ALPHA_VAL_U,
31 PLL_OFF_USER_CTL,
32 PLL_OFF_USER_CTL_U,
33 PLL_OFF_CONFIG_CTL,
34 PLL_OFF_CONFIG_CTL_U,
35 PLL_OFF_TEST_CTL,
36 PLL_OFF_TEST_CTL_U,
37 PLL_OFF_STATUS,
38 PLL_OFF_MAX_REGS
39};
40
41extern const u8 clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_MAX][PLL_OFF_MAX_REGS];
42
Stephen Boyd8ff1f4c2015-11-30 17:31:39 -080043struct pll_vco {
44 unsigned long min_freq;
45 unsigned long max_freq;
46 u32 val;
47};
48
49/**
50 * struct clk_alpha_pll - phase locked loop (PLL)
51 * @offset: base address of registers
52 * @vco_table: array of VCO settings
Abhishek Sahu28d3f062017-09-28 23:20:40 +053053 * @regs: alpha pll register map (see @clk_alpha_pll_regs)
Stephen Boyd8ff1f4c2015-11-30 17:31:39 -080054 * @clkr: regmap clock handle
55 */
56struct clk_alpha_pll {
57 u32 offset;
Abhishek Sahu28d3f062017-09-28 23:20:40 +053058 const u8 *regs;
Stephen Boyd8ff1f4c2015-11-30 17:31:39 -080059
60 const struct pll_vco *vco_table;
61 size_t num_vco;
Rajendra Nayakfeb65642016-09-29 14:05:42 +053062#define SUPPORTS_OFFLINE_REQ BIT(0)
Rajendra Nayak400d9fd2016-09-29 14:05:45 +053063#define SUPPORTS_FSM_MODE BIT(2)
Abhishek Sahu472796d2017-09-28 23:20:45 +053064#define SUPPORTS_DYNAMIC_UPDATE BIT(3)
Rajendra Nayakfeb65642016-09-29 14:05:42 +053065 u8 flags;
Stephen Boyd8ff1f4c2015-11-30 17:31:39 -080066
67 struct clk_regmap clkr;
68};
69
70/**
71 * struct clk_alpha_pll_postdiv - phase locked loop (PLL) post-divider
72 * @offset: base address of registers
Abhishek Sahu28d3f062017-09-28 23:20:40 +053073 * @regs: alpha pll register map (see @clk_alpha_pll_regs)
Stephen Boyd8ff1f4c2015-11-30 17:31:39 -080074 * @width: width of post-divider
75 * @clkr: regmap clock handle
76 */
77struct clk_alpha_pll_postdiv {
78 u32 offset;
79 u8 width;
Abhishek Sahu28d3f062017-09-28 23:20:40 +053080 const u8 *regs;
Stephen Boyd8ff1f4c2015-11-30 17:31:39 -080081
82 struct clk_regmap clkr;
83};
84
Rajendra Nayak9f4e6272016-09-29 14:05:43 +053085struct alpha_pll_config {
86 u32 l;
87 u32 alpha;
Abhishek Sahuc45ae592017-09-28 23:20:44 +053088 u32 alpha_hi;
Rajendra Nayak9f4e6272016-09-29 14:05:43 +053089 u32 config_ctl_val;
90 u32 config_ctl_hi_val;
91 u32 main_output_mask;
92 u32 aux_output_mask;
93 u32 aux2_output_mask;
94 u32 early_output_mask;
Abhishek Sahuc45ae592017-09-28 23:20:44 +053095 u32 alpha_en_mask;
96 u32 alpha_mode_mask;
Rajendra Nayak9f4e6272016-09-29 14:05:43 +053097 u32 pre_div_val;
98 u32 pre_div_mask;
99 u32 post_div_val;
100 u32 post_div_mask;
101 u32 vco_val;
102 u32 vco_mask;
103};
104
Stephen Boyd8ff1f4c2015-11-30 17:31:39 -0800105extern const struct clk_ops clk_alpha_pll_ops;
Rajendra Nayakfeb65642016-09-29 14:05:42 +0530106extern const struct clk_ops clk_alpha_pll_hwfsm_ops;
Stephen Boyd8ff1f4c2015-11-30 17:31:39 -0800107extern const struct clk_ops clk_alpha_pll_postdiv_ops;
Abhishek Sahu134b55b2017-09-28 23:20:46 +0530108extern const struct clk_ops clk_alpha_pll_huayra_ops;
Stephen Boyd8ff1f4c2015-11-30 17:31:39 -0800109
Rajendra Nayak9f4e6272016-09-29 14:05:43 +0530110void clk_alpha_pll_configure(struct clk_alpha_pll *pll, struct regmap *regmap,
111 const struct alpha_pll_config *config);
112
Stephen Boyd8ff1f4c2015-11-30 17:31:39 -0800113#endif