clk-alpha-pll.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (c) 2015, 2018, 2021 The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #ifndef __QCOM_CLK_ALPHA_PLL_H__
  7. #define __QCOM_CLK_ALPHA_PLL_H__
  8. #include <linux/clk-provider.h>
  9. #include "clk-regmap.h"
  10. /* Alpha PLL types */
  11. enum {
  12. CLK_ALPHA_PLL_TYPE_DEFAULT,
  13. CLK_ALPHA_PLL_TYPE_HUAYRA,
  14. CLK_ALPHA_PLL_TYPE_HUAYRA_APSS,
  15. CLK_ALPHA_PLL_TYPE_HUAYRA_2290,
  16. CLK_ALPHA_PLL_TYPE_BRAMMO,
  17. CLK_ALPHA_PLL_TYPE_FABIA,
  18. CLK_ALPHA_PLL_TYPE_TRION,
  19. CLK_ALPHA_PLL_TYPE_LUCID = CLK_ALPHA_PLL_TYPE_TRION,
  20. CLK_ALPHA_PLL_TYPE_AGERA,
  21. CLK_ALPHA_PLL_TYPE_ZONDA,
  22. CLK_ALPHA_PLL_TYPE_REGERA = CLK_ALPHA_PLL_TYPE_ZONDA,
  23. CLK_ALPHA_PLL_TYPE_ZONDA_OLE,
  24. CLK_ALPHA_PLL_TYPE_LUCID_EVO,
  25. CLK_ALPHA_PLL_TYPE_LUCID_OLE,
  26. CLK_ALPHA_PLL_TYPE_RIVIAN_EVO,
  27. CLK_ALPHA_PLL_TYPE_DEFAULT_EVO,
  28. CLK_ALPHA_PLL_TYPE_BRAMMO_EVO,
  29. CLK_ALPHA_PLL_TYPE_STROMER,
  30. CLK_ALPHA_PLL_TYPE_STROMER_PLUS,
  31. CLK_ALPHA_PLL_TYPE_NSS_HUAYRA,
  32. CLK_ALPHA_PLL_TYPE_MAX,
  33. };
  34. enum {
  35. PLL_OFF_L_VAL,
  36. PLL_OFF_CAL_L_VAL,
  37. PLL_OFF_ALPHA_VAL,
  38. PLL_OFF_ALPHA_VAL_U,
  39. PLL_OFF_USER_CTL,
  40. PLL_OFF_USER_CTL_U,
  41. PLL_OFF_USER_CTL_U1,
  42. PLL_OFF_CONFIG_CTL,
  43. PLL_OFF_CONFIG_CTL_U,
  44. PLL_OFF_CONFIG_CTL_U1,
  45. PLL_OFF_CONFIG_CTL_U2,
  46. PLL_OFF_TEST_CTL,
  47. PLL_OFF_TEST_CTL_U,
  48. PLL_OFF_TEST_CTL_U1,
  49. PLL_OFF_TEST_CTL_U2,
  50. PLL_OFF_STATE,
  51. PLL_OFF_STATUS,
  52. PLL_OFF_OPMODE,
  53. PLL_OFF_FRAC,
  54. PLL_OFF_CAL_VAL,
  55. PLL_OFF_MAX_REGS
  56. };
  57. extern const u8 clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_MAX][PLL_OFF_MAX_REGS];
  58. struct pll_vco {
  59. unsigned long min_freq;
  60. unsigned long max_freq;
  61. u32 val;
  62. };
  63. #define VCO(a, b, c) { \
  64. .val = a,\
  65. .min_freq = b,\
  66. .max_freq = c,\
  67. }
  68. /**
  69. * struct clk_alpha_pll - phase locked loop (PLL)
  70. * @offset: base address of registers
  71. * @regs: alpha pll register map (see @clk_alpha_pll_regs)
  72. * @vco_table: array of VCO settings
  73. * @num_vco: number of VCO settings in @vco_table
  74. * @flags: bitmask to indicate features supported by the hardware
  75. * @clkr: regmap clock handle
  76. */
  77. struct clk_alpha_pll {
  78. u32 offset;
  79. const u8 *regs;
  80. const struct pll_vco *vco_table;
  81. size_t num_vco;
  82. #define SUPPORTS_OFFLINE_REQ BIT(0)
  83. #define SUPPORTS_FSM_MODE BIT(2)
  84. #define SUPPORTS_DYNAMIC_UPDATE BIT(3)
  85. #define SUPPORTS_FSM_LEGACY_MODE BIT(4)
  86. u8 flags;
  87. struct clk_regmap clkr;
  88. };
  89. /**
  90. * struct clk_alpha_pll_postdiv - phase locked loop (PLL) post-divider
  91. * @offset: base address of registers
  92. * @regs: alpha pll register map (see @clk_alpha_pll_regs)
  93. * @width: width of post-divider
  94. * @post_div_shift: shift to differentiate between odd & even post-divider
  95. * @post_div_table: table with PLL odd and even post-divider settings
  96. * @num_post_div: Number of PLL post-divider settings
  97. *
  98. * @clkr: regmap clock handle
  99. */
  100. struct clk_alpha_pll_postdiv {
  101. u32 offset;
  102. u8 width;
  103. const u8 *regs;
  104. struct clk_regmap clkr;
  105. int post_div_shift;
  106. const struct clk_div_table *post_div_table;
  107. size_t num_post_div;
  108. };
  109. struct alpha_pll_config {
  110. u32 l;
  111. u32 alpha;
  112. u32 alpha_hi;
  113. u32 config_ctl_val;
  114. u32 config_ctl_hi_val;
  115. u32 config_ctl_hi1_val;
  116. u32 config_ctl_hi2_val;
  117. u32 user_ctl_val;
  118. u32 user_ctl_hi_val;
  119. u32 user_ctl_hi1_val;
  120. u32 test_ctl_val;
  121. u32 test_ctl_mask;
  122. u32 test_ctl_hi_val;
  123. u32 test_ctl_hi_mask;
  124. u32 test_ctl_hi1_val;
  125. u32 test_ctl_hi2_val;
  126. u32 main_output_mask;
  127. u32 aux_output_mask;
  128. u32 aux2_output_mask;
  129. u32 early_output_mask;
  130. u32 alpha_en_mask;
  131. u32 alpha_mode_mask;
  132. u32 pre_div_val;
  133. u32 pre_div_mask;
  134. u32 post_div_val;
  135. u32 post_div_mask;
  136. u32 vco_val;
  137. u32 vco_mask;
  138. u32 status_val;
  139. u32 status_mask;
  140. u32 lock_det;
  141. };
  142. extern const struct clk_ops clk_alpha_pll_ops;
  143. extern const struct clk_ops clk_alpha_pll_fixed_ops;
  144. extern const struct clk_ops clk_alpha_pll_hwfsm_ops;
  145. extern const struct clk_ops clk_alpha_pll_postdiv_ops;
  146. extern const struct clk_ops clk_alpha_pll_huayra_ops;
  147. extern const struct clk_ops clk_alpha_pll_postdiv_ro_ops;
  148. extern const struct clk_ops clk_alpha_pll_stromer_ops;
  149. extern const struct clk_ops clk_alpha_pll_stromer_plus_ops;
  150. extern const struct clk_ops clk_alpha_pll_fabia_ops;
  151. extern const struct clk_ops clk_alpha_pll_fixed_fabia_ops;
  152. extern const struct clk_ops clk_alpha_pll_postdiv_fabia_ops;
  153. extern const struct clk_ops clk_alpha_pll_trion_ops;
  154. extern const struct clk_ops clk_alpha_pll_fixed_trion_ops;
  155. extern const struct clk_ops clk_alpha_pll_postdiv_trion_ops;
  156. extern const struct clk_ops clk_alpha_pll_lucid_ops;
  157. #define clk_alpha_pll_fixed_lucid_ops clk_alpha_pll_fixed_trion_ops
  158. extern const struct clk_ops clk_alpha_pll_postdiv_lucid_ops;
  159. extern const struct clk_ops clk_alpha_pll_agera_ops;
  160. extern const struct clk_ops clk_alpha_pll_lucid_5lpe_ops;
  161. extern const struct clk_ops clk_alpha_pll_fixed_lucid_5lpe_ops;
  162. extern const struct clk_ops clk_alpha_pll_postdiv_lucid_5lpe_ops;
  163. extern const struct clk_ops clk_alpha_pll_zonda_ops;
  164. #define clk_alpha_pll_postdiv_zonda_ops clk_alpha_pll_postdiv_fabia_ops
  165. #define clk_alpha_pll_zonda_ole_ops clk_alpha_pll_zonda_ops
  166. extern const struct clk_ops clk_alpha_pll_lucid_evo_ops;
  167. extern const struct clk_ops clk_alpha_pll_reset_lucid_evo_ops;
  168. #define clk_alpha_pll_reset_lucid_ole_ops clk_alpha_pll_reset_lucid_evo_ops
  169. extern const struct clk_ops clk_alpha_pll_fixed_lucid_evo_ops;
  170. #define clk_alpha_pll_fixed_lucid_ole_ops clk_alpha_pll_fixed_lucid_evo_ops
  171. extern const struct clk_ops clk_alpha_pll_postdiv_lucid_evo_ops;
  172. #define clk_alpha_pll_postdiv_lucid_ole_ops clk_alpha_pll_postdiv_lucid_evo_ops
  173. extern const struct clk_ops clk_alpha_pll_rivian_evo_ops;
  174. #define clk_alpha_pll_postdiv_rivian_evo_ops clk_alpha_pll_postdiv_fabia_ops
  175. extern const struct clk_ops clk_alpha_pll_regera_ops;
  176. void clk_alpha_pll_configure(struct clk_alpha_pll *pll, struct regmap *regmap,
  177. const struct alpha_pll_config *config);
  178. void clk_huayra_2290_pll_configure(struct clk_alpha_pll *pll, struct regmap *regmap,
  179. const struct alpha_pll_config *config);
  180. void clk_fabia_pll_configure(struct clk_alpha_pll *pll, struct regmap *regmap,
  181. const struct alpha_pll_config *config);
  182. void clk_trion_pll_configure(struct clk_alpha_pll *pll, struct regmap *regmap,
  183. const struct alpha_pll_config *config);
  184. void clk_agera_pll_configure(struct clk_alpha_pll *pll, struct regmap *regmap,
  185. const struct alpha_pll_config *config);
  186. #define clk_lucid_pll_configure(pll, regmap, config) \
  187. clk_trion_pll_configure(pll, regmap, config)
  188. void clk_zonda_pll_configure(struct clk_alpha_pll *pll, struct regmap *regmap,
  189. const struct alpha_pll_config *config);
  190. void clk_lucid_5lpe_pll_configure(struct clk_alpha_pll *pll, struct regmap *regmap,
  191. const struct alpha_pll_config *config);
  192. void clk_lucid_evo_pll_configure(struct clk_alpha_pll *pll, struct regmap *regmap,
  193. const struct alpha_pll_config *config);
  194. void clk_lucid_ole_pll_configure(struct clk_alpha_pll *pll, struct regmap *regmap,
  195. const struct alpha_pll_config *config);
  196. void clk_rivian_evo_pll_configure(struct clk_alpha_pll *pll, struct regmap *regmap,
  197. const struct alpha_pll_config *config);
  198. void clk_stromer_pll_configure(struct clk_alpha_pll *pll, struct regmap *regmap,
  199. const struct alpha_pll_config *config);
  200. void clk_regera_pll_configure(struct clk_alpha_pll *pll, struct regmap *regmap,
  201. const struct alpha_pll_config *config);
  202. #endif