Taniya Das | f941978 | 2018-07-16 11:24:32 +0530 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
| 2 | /* Copyright (c) 2015, 2018, The Linux Foundation. All rights reserved. */ |
Stephen Boyd | 8ff1f4c | 2015-11-30 17:31:39 -0800 | [diff] [blame] | 3 | |
| 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 Sahu | 28d3f06 | 2017-09-28 23:20:40 +0530 | [diff] [blame] | 10 | /* Alpha PLL types */ |
| 11 | enum { |
| 12 | CLK_ALPHA_PLL_TYPE_DEFAULT, |
Abhishek Sahu | 134b55b | 2017-09-28 23:20:46 +0530 | [diff] [blame] | 13 | CLK_ALPHA_PLL_TYPE_HUAYRA, |
Abhishek Sahu | c23e8a1 | 2017-09-28 23:20:48 +0530 | [diff] [blame] | 14 | CLK_ALPHA_PLL_TYPE_BRAMMO, |
Amit Nischal | 687d7a0 | 2018-03-08 12:48:14 +0530 | [diff] [blame] | 15 | CLK_ALPHA_PLL_TYPE_FABIA, |
Abhishek Sahu | 28d3f06 | 2017-09-28 23:20:40 +0530 | [diff] [blame] | 16 | CLK_ALPHA_PLL_TYPE_MAX, |
| 17 | }; |
| 18 | |
| 19 | enum { |
| 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 Nischal | 687d7a0 | 2018-03-08 12:48:14 +0530 | [diff] [blame] | 30 | PLL_OFF_OPMODE, |
| 31 | PLL_OFF_FRAC, |
Abhishek Sahu | 28d3f06 | 2017-09-28 23:20:40 +0530 | [diff] [blame] | 32 | PLL_OFF_MAX_REGS |
| 33 | }; |
| 34 | |
| 35 | extern const u8 clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_MAX][PLL_OFF_MAX_REGS]; |
| 36 | |
Stephen Boyd | 8ff1f4c | 2015-11-30 17:31:39 -0800 | [diff] [blame] | 37 | struct 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 Sahu | 28d3f06 | 2017-09-28 23:20:40 +0530 | [diff] [blame] | 47 | * @regs: alpha pll register map (see @clk_alpha_pll_regs) |
Stephen Boyd | 8ff1f4c | 2015-11-30 17:31:39 -0800 | [diff] [blame] | 48 | * @clkr: regmap clock handle |
| 49 | */ |
| 50 | struct clk_alpha_pll { |
| 51 | u32 offset; |
Abhishek Sahu | 28d3f06 | 2017-09-28 23:20:40 +0530 | [diff] [blame] | 52 | const u8 *regs; |
Stephen Boyd | 8ff1f4c | 2015-11-30 17:31:39 -0800 | [diff] [blame] | 53 | |
| 54 | const struct pll_vco *vco_table; |
| 55 | size_t num_vco; |
Rajendra Nayak | feb6564 | 2016-09-29 14:05:42 +0530 | [diff] [blame] | 56 | #define SUPPORTS_OFFLINE_REQ BIT(0) |
Rajendra Nayak | 400d9fd | 2016-09-29 14:05:45 +0530 | [diff] [blame] | 57 | #define SUPPORTS_FSM_MODE BIT(2) |
Abhishek Sahu | 472796d | 2017-09-28 23:20:45 +0530 | [diff] [blame] | 58 | #define SUPPORTS_DYNAMIC_UPDATE BIT(3) |
Rajendra Nayak | feb6564 | 2016-09-29 14:05:42 +0530 | [diff] [blame] | 59 | u8 flags; |
Stephen Boyd | 8ff1f4c | 2015-11-30 17:31:39 -0800 | [diff] [blame] | 60 | |
| 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 Sahu | 28d3f06 | 2017-09-28 23:20:40 +0530 | [diff] [blame] | 67 | * @regs: alpha pll register map (see @clk_alpha_pll_regs) |
Stephen Boyd | 8ff1f4c | 2015-11-30 17:31:39 -0800 | [diff] [blame] | 68 | * @width: width of post-divider |
Amit Nischal | 687d7a0 | 2018-03-08 12:48:14 +0530 | [diff] [blame] | 69 | * @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 Boyd | 8ff1f4c | 2015-11-30 17:31:39 -0800 | [diff] [blame] | 73 | * @clkr: regmap clock handle |
| 74 | */ |
| 75 | struct clk_alpha_pll_postdiv { |
| 76 | u32 offset; |
| 77 | u8 width; |
Abhishek Sahu | 28d3f06 | 2017-09-28 23:20:40 +0530 | [diff] [blame] | 78 | const u8 *regs; |
Stephen Boyd | 8ff1f4c | 2015-11-30 17:31:39 -0800 | [diff] [blame] | 79 | |
| 80 | struct clk_regmap clkr; |
Amit Nischal | 687d7a0 | 2018-03-08 12:48:14 +0530 | [diff] [blame] | 81 | int post_div_shift; |
| 82 | const struct clk_div_table *post_div_table; |
| 83 | size_t num_post_div; |
Stephen Boyd | 8ff1f4c | 2015-11-30 17:31:39 -0800 | [diff] [blame] | 84 | }; |
| 85 | |
Rajendra Nayak | 9f4e627 | 2016-09-29 14:05:43 +0530 | [diff] [blame] | 86 | struct alpha_pll_config { |
| 87 | u32 l; |
| 88 | u32 alpha; |
Abhishek Sahu | c45ae59 | 2017-09-28 23:20:44 +0530 | [diff] [blame] | 89 | u32 alpha_hi; |
Rajendra Nayak | 9f4e627 | 2016-09-29 14:05:43 +0530 | [diff] [blame] | 90 | 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 Sahu | c45ae59 | 2017-09-28 23:20:44 +0530 | [diff] [blame] | 96 | u32 alpha_en_mask; |
| 97 | u32 alpha_mode_mask; |
Rajendra Nayak | 9f4e627 | 2016-09-29 14:05:43 +0530 | [diff] [blame] | 98 | 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 Boyd | 8ff1f4c | 2015-11-30 17:31:39 -0800 | [diff] [blame] | 106 | extern const struct clk_ops clk_alpha_pll_ops; |
Rajendra Nayak | feb6564 | 2016-09-29 14:05:42 +0530 | [diff] [blame] | 107 | extern const struct clk_ops clk_alpha_pll_hwfsm_ops; |
Stephen Boyd | 8ff1f4c | 2015-11-30 17:31:39 -0800 | [diff] [blame] | 108 | extern const struct clk_ops clk_alpha_pll_postdiv_ops; |
Abhishek Sahu | 134b55b | 2017-09-28 23:20:46 +0530 | [diff] [blame] | 109 | extern const struct clk_ops clk_alpha_pll_huayra_ops; |
Abhishek Sahu | 23c68cc | 2017-09-28 23:20:50 +0530 | [diff] [blame] | 110 | extern const struct clk_ops clk_alpha_pll_postdiv_ro_ops; |
Stephen Boyd | 8ff1f4c | 2015-11-30 17:31:39 -0800 | [diff] [blame] | 111 | |
Amit Nischal | 687d7a0 | 2018-03-08 12:48:14 +0530 | [diff] [blame] | 112 | extern const struct clk_ops clk_alpha_pll_fabia_ops; |
| 113 | extern const struct clk_ops clk_alpha_pll_fixed_fabia_ops; |
| 114 | extern const struct clk_ops clk_alpha_pll_postdiv_fabia_ops; |
| 115 | |
Rajendra Nayak | 9f4e627 | 2016-09-29 14:05:43 +0530 | [diff] [blame] | 116 | void clk_alpha_pll_configure(struct clk_alpha_pll *pll, struct regmap *regmap, |
| 117 | const struct alpha_pll_config *config); |
Amit Nischal | 687d7a0 | 2018-03-08 12:48:14 +0530 | [diff] [blame] | 118 | void clk_fabia_pll_configure(struct clk_alpha_pll *pll, struct regmap *regmap, |
| 119 | const struct alpha_pll_config *config); |
Rajendra Nayak | 9f4e627 | 2016-09-29 14:05:43 +0530 | [diff] [blame] | 120 | |
Stephen Boyd | 8ff1f4c | 2015-11-30 17:31:39 -0800 | [diff] [blame] | 121 | #endif |