clk-alpha-pll.h 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* Copyright (c) 2015, 2018, 2021, The Linux Foundation. All rights reserved. */
  3. /* Copyright (c) 2022-2023, Qualcomm Innovation Center, Inc. All rights reserved. */
  4. #ifndef __QCOM_CLK_ALPHA_PLL_H__
  5. #define __QCOM_CLK_ALPHA_PLL_H__
  6. #include <linux/clk-provider.h>
  7. #include "clk-regmap.h"
  8. /* Alpha PLL types */
  9. enum {
  10. CLK_ALPHA_PLL_TYPE_DEFAULT,
  11. CLK_ALPHA_PLL_TYPE_HUAYRA,
  12. CLK_ALPHA_PLL_TYPE_BRAMMO,
  13. CLK_ALPHA_PLL_TYPE_FABIA,
  14. CLK_ALPHA_PLL_TYPE_TRION,
  15. CLK_ALPHA_PLL_TYPE_LUCID = CLK_ALPHA_PLL_TYPE_TRION,
  16. CLK_ALPHA_PLL_TYPE_AGERA,
  17. CLK_ALPHA_PLL_TYPE_ZONDA,
  18. CLK_ALPHA_PLL_TYPE_ZONDA_EVO,
  19. CLK_ALPHA_PLL_TYPE_ZONDA_5LPE,
  20. CLK_ALPHA_PLL_TYPE_REGERA,
  21. CLK_ALPHA_PLL_TYPE_LUCID_EVO,
  22. CLK_ALPHA_PLL_TYPE_LUCID_OLE,
  23. CLK_ALPHA_PLL_TYPE_RIVIAN_EVO,
  24. CLK_ALPHA_PLL_TYPE_RIVIAN_OLE = CLK_ALPHA_PLL_TYPE_RIVIAN_EVO,
  25. CLK_ALPHA_PLL_TYPE_DEFAULT_EVO,
  26. CLK_ALPHA_PLL_TYPE_BRAMMO_EVO,
  27. CLK_ALPHA_PLL_TYPE_LUCID_5LPE,
  28. CLK_ALPHA_PLL_TYPE_MAX,
  29. };
  30. enum {
  31. PLL_OFF_MODE,
  32. PLL_OFF_L_VAL,
  33. PLL_OFF_CAL_L_VAL,
  34. PLL_OFF_ALPHA_VAL,
  35. PLL_OFF_ALPHA_VAL_U,
  36. PLL_OFF_USER_CTL,
  37. PLL_OFF_USER_CTL_U,
  38. PLL_OFF_USER_CTL_U1,
  39. PLL_OFF_CONFIG_CTL,
  40. PLL_OFF_CONFIG_CTL_U,
  41. PLL_OFF_CONFIG_CTL_U1,
  42. PLL_OFF_TEST_CTL,
  43. PLL_OFF_TEST_CTL_U,
  44. PLL_OFF_TEST_CTL_U1,
  45. PLL_OFF_TEST_CTL_U2,
  46. PLL_OFF_STATE,
  47. PLL_OFF_STATUS,
  48. PLL_OFF_OPMODE,
  49. PLL_OFF_FRAC,
  50. PLL_OFF_CAL_VAL,
  51. PLL_OFF_SSC_DELTA_ALPHA,
  52. PLL_OFF_SSC_NUM_STEPS,
  53. PLL_OFF_SSC_UPDATE_RATE,
  54. PLL_OFF_MAX_REGS
  55. };
  56. extern const u8 clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_MAX][PLL_OFF_MAX_REGS];
  57. struct pll_vco_data {
  58. unsigned long freq;
  59. u8 post_div_val;
  60. };
  61. struct pll_vco {
  62. unsigned long min_freq;
  63. unsigned long max_freq;
  64. u32 val;
  65. };
  66. #define VCO(a, b, c) { \
  67. .val = a,\
  68. .min_freq = b,\
  69. .max_freq = c,\
  70. }
  71. /**
  72. * struct clk_alpha_pll - phase locked loop (PLL)
  73. * @offset: base address of registers
  74. * @vco_table: array of VCO settings
  75. * @soft_vote: soft voting variable for multiple PLL software instances
  76. * @soft_vote_mask: soft voting mask for multiple PLL software instances
  77. * @regs: alpha pll register map (see @clk_alpha_pll_regs)
  78. * @vco_data: array of VCO data settings like post div
  79. * @clkr: regmap clock handle
  80. */
  81. struct clk_alpha_pll {
  82. u32 offset;
  83. const u8 *regs;
  84. struct alpha_pll_config *config;
  85. const struct pll_vco *vco_table;
  86. size_t num_vco;
  87. u32 *soft_vote;
  88. u32 soft_vote_mask;
  89. /* Soft voting values */
  90. #define PLL_SOFT_VOTE_PRIMARY BIT(0)
  91. #define PLL_SOFT_VOTE_CPU BIT(1)
  92. #define PLL_SOFT_VOTE_AUX BIT(2)
  93. const struct pll_vco_data *vco_data;
  94. size_t num_vco_data;
  95. #define SUPPORTS_OFFLINE_REQ BIT(0)
  96. #define SUPPORTS_FSM_MODE BIT(2)
  97. /*
  98. * Some PLLs support dynamically updating their rate without disabling
  99. * the PLL first. Set this flag to enable this support.
  100. */
  101. #define SUPPORTS_DYNAMIC_UPDATE BIT(3)
  102. #define SUPPORTS_FSM_LEGACY_MODE BIT(4)
  103. #define DISABLE_TO_OFF BIT(5)
  104. #define SUPPORTS_SLEW BIT(4)
  105. #define BYPASS_LATCH BIT(6)
  106. #define ENABLE_IN_PREPARE BIT(6)
  107. u8 flags;
  108. struct clk_regmap clkr;
  109. unsigned long min_supported_freq;
  110. };
  111. /**
  112. * struct clk_alpha_pll_postdiv - phase locked loop (PLL) post-divider
  113. * @offset: base address of registers
  114. * @regs: alpha pll register map (see @clk_alpha_pll_regs)
  115. * @width: width of post-divider
  116. * @post_div_shift: shift to differentiate between odd & even post-divider
  117. * @post_div_table: table with PLL odd and even post-divider settings
  118. * @num_post_div: Number of PLL post-divider settings
  119. *
  120. * @clkr: regmap clock handle
  121. */
  122. struct clk_alpha_pll_postdiv {
  123. u32 offset;
  124. u8 width;
  125. const u8 *regs;
  126. struct clk_regmap clkr;
  127. int post_div_shift;
  128. const struct clk_div_table *post_div_table;
  129. size_t num_post_div;
  130. };
  131. struct alpha_pll_config {
  132. u32 l;
  133. u32 cal_l;
  134. u32 cal_l_ringosc;
  135. u32 alpha;
  136. u32 alpha_hi;
  137. u32 config_ctl_val;
  138. u32 config_ctl_hi_val;
  139. u32 config_ctl_hi1_val;
  140. u32 user_ctl_val;
  141. u32 user_ctl_hi_val;
  142. u32 user_ctl_hi1_val;
  143. u32 test_ctl_val;
  144. u32 test_ctl_hi_val;
  145. u32 test_ctl_hi1_val;
  146. u32 test_ctl_hi2_val;
  147. u32 main_output_mask;
  148. u32 aux_output_mask;
  149. u32 aux2_output_mask;
  150. u32 early_output_mask;
  151. u32 alpha_en_mask;
  152. u32 alpha_mode_mask;
  153. u32 pre_div_val;
  154. u32 pre_div_mask;
  155. u32 post_div_val;
  156. u32 post_div_mask;
  157. u32 test_ctl_mask;
  158. u32 test_ctl_hi_mask;
  159. u32 vco_val;
  160. u32 vco_mask;
  161. };
  162. extern const struct clk_ops clk_alpha_pll_ops;
  163. extern const struct clk_ops clk_alpha_pll_fixed_ops;
  164. extern const struct clk_ops clk_alpha_pll_hwfsm_ops;
  165. extern const struct clk_ops clk_alpha_pll_postdiv_ops;
  166. extern const struct clk_ops clk_alpha_pll_huayra_ops;
  167. extern const struct clk_ops clk_alpha_pll_postdiv_ro_ops;
  168. extern const struct clk_ops clk_alpha_pll_fabia_ops;
  169. extern const struct clk_ops clk_alpha_pll_fixed_fabia_ops;
  170. extern const struct clk_ops clk_alpha_pll_postdiv_fabia_ops;
  171. extern const struct clk_ops clk_alpha_pll_trion_ops;
  172. extern const struct clk_ops clk_alpha_pll_fixed_trion_ops;
  173. extern const struct clk_ops clk_alpha_pll_postdiv_trion_ops;
  174. extern const struct clk_ops clk_alpha_pll_lucid_ops;
  175. #define clk_alpha_pll_fixed_lucid_ops clk_alpha_pll_fixed_trion_ops
  176. extern const struct clk_ops clk_alpha_pll_postdiv_lucid_ops;
  177. extern const struct clk_ops clk_alpha_pll_agera_ops;
  178. extern const struct clk_ops clk_alpha_pll_lucid_5lpe_ops;
  179. extern const struct clk_ops clk_alpha_pll_fixed_lucid_5lpe_ops;
  180. extern const struct clk_ops clk_alpha_pll_postdiv_lucid_5lpe_ops;
  181. extern const struct clk_ops clk_alpha_pll_slew_ops;
  182. extern const struct clk_ops clk_alpha_pll_zonda_ops;
  183. #define clk_alpha_pll_postdiv_zonda_ops clk_alpha_pll_postdiv_fabia_ops
  184. extern const struct clk_ops clk_alpha_pll_zonda_5lpe_ops;
  185. extern const struct clk_ops clk_regera_pll_ops;
  186. extern const struct clk_ops clk_alpha_pll_lucid_evo_ops;
  187. extern const struct clk_ops clk_alpha_pll_reset_lucid_evo_ops;
  188. extern const struct clk_ops clk_alpha_pll_fixed_lucid_evo_ops;
  189. extern const struct clk_ops clk_alpha_pll_zonda_evo_ops;
  190. extern const struct clk_ops clk_alpha_pll_fixed_zonda_evo_ops;
  191. extern const struct clk_ops clk_alpha_pll_postdiv_zonda_evo_ops;
  192. extern const struct clk_ops clk_alpha_pll_postdiv_lucid_evo_ops;
  193. #define clk_alpha_pll_lucid_ole_ops clk_alpha_pll_lucid_evo_ops
  194. #define clk_alpha_pll_fixed_lucid_ole_ops clk_alpha_pll_fixed_lucid_evo_ops
  195. #define clk_alpha_pll_postdiv_lucid_ole_ops clk_alpha_pll_postdiv_lucid_evo_ops
  196. extern const struct clk_ops clk_alpha_pll_crm_lucid_evo_ops;
  197. extern const struct clk_ops clk_alpha_pll_crm_fixed_lucid_evo_ops;
  198. extern const struct clk_ops clk_alpha_pll_crm_postdiv_lucid_evo_ops;
  199. #define clk_alpha_pll_crm_lucid_ole_ops clk_alpha_pll_crm_lucid_evo_ops
  200. #define clk_alpha_pll_crm_fixed_lucid_ole_ops clk_alpha_pll_crm_fixed_lucid_evo_ops
  201. #define clk_alpha_pll_crm_postdiv_lucid_ole_ops clk_alpha_pll_crm_postdiv_lucid_evo_ops
  202. extern const struct clk_ops clk_alpha_pll_rivian_evo_ops;
  203. #define clk_alpha_pll_rivian_ole_ops clk_alpha_pll_rivian_evo_ops
  204. #define clk_alpha_pll_postdiv_rivian_evo_ops clk_alpha_pll_postdiv_fabia_ops
  205. void clk_alpha_pll_configure(struct clk_alpha_pll *pll, struct regmap *regmap,
  206. const struct alpha_pll_config *config);
  207. void clk_fabia_pll_configure(struct clk_alpha_pll *pll, struct regmap *regmap,
  208. const struct alpha_pll_config *config);
  209. void clk_trion_pll_configure(struct clk_alpha_pll *pll, struct regmap *regmap,
  210. const struct alpha_pll_config *config);
  211. void clk_agera_pll_configure(struct clk_alpha_pll *pll, struct regmap *regmap,
  212. const struct alpha_pll_config *config);
  213. #define clk_lucid_pll_configure(pll, regmap, config) \
  214. clk_trion_pll_configure(pll, regmap, config)
  215. void clk_zonda_pll_configure(struct clk_alpha_pll *pll, struct regmap *regmap,
  216. const struct alpha_pll_config *config);
  217. #define clk_zonda_5lpe_pll_configure clk_zonda_pll_configure
  218. int clk_regera_pll_configure(struct clk_alpha_pll *pll, struct regmap *regmap,
  219. const struct alpha_pll_config *config);
  220. int clk_lucid_evo_pll_configure(struct clk_alpha_pll *pll,
  221. struct regmap *regmap,
  222. const struct alpha_pll_config *config);
  223. #define clk_lucid_ole_pll_configure(pll, regmap, config) \
  224. clk_lucid_evo_pll_configure(pll, regmap, config)
  225. int clk_rivian_evo_pll_configure(struct clk_alpha_pll *pll,
  226. struct regmap *regmap,
  227. const struct alpha_pll_config *config);
  228. #define clk_rivian_ole_pll_configure clk_rivian_evo_pll_configure
  229. int clk_zonda_evo_pll_configure(struct clk_alpha_pll *pll,
  230. struct regmap *regmap,
  231. const struct alpha_pll_config *config);
  232. int clk_lucid_5lpe_pll_configure(struct clk_alpha_pll *pll,
  233. struct regmap *regmap,
  234. const struct alpha_pll_config *config);
  235. #endif