clk-alpha-pll.h 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  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_PONGO_ELU,
  27. CLK_ALPHA_PLL_TYPE_PONGO_EKO_T = CLK_ALPHA_PLL_TYPE_PONGO_ELU,
  28. CLK_ALPHA_PLL_TYPE_TAYCAN_ELU,
  29. CLK_ALPHA_PLL_TYPE_TAYCAN_EKO_T = CLK_ALPHA_PLL_TYPE_TAYCAN_ELU,
  30. CLK_ALPHA_PLL_TYPE_RIVIAN_EVO,
  31. CLK_ALPHA_PLL_TYPE_RIVIAN_ELU,
  32. CLK_ALPHA_PLL_TYPE_RIVIAN_EKO_T = CLK_ALPHA_PLL_TYPE_RIVIAN_ELU,
  33. CLK_ALPHA_PLL_TYPE_DEFAULT_EVO,
  34. CLK_ALPHA_PLL_TYPE_BRAMMO_EVO,
  35. CLK_ALPHA_PLL_TYPE_STROMER,
  36. CLK_ALPHA_PLL_TYPE_STROMER_PLUS,
  37. CLK_ALPHA_PLL_TYPE_NSS_HUAYRA,
  38. CLK_ALPHA_PLL_TYPE_MAX,
  39. };
  40. enum {
  41. PLL_OFF_L_VAL,
  42. PLL_OFF_CAL_L_VAL,
  43. PLL_OFF_ALPHA_VAL,
  44. PLL_OFF_ALPHA_VAL_U,
  45. PLL_OFF_USER_CTL,
  46. PLL_OFF_USER_CTL_U,
  47. PLL_OFF_USER_CTL_U1,
  48. PLL_OFF_CONFIG_CTL,
  49. PLL_OFF_CONFIG_CTL_U,
  50. PLL_OFF_CONFIG_CTL_U1,
  51. PLL_OFF_CONFIG_CTL_U2,
  52. PLL_OFF_TEST_CTL,
  53. PLL_OFF_TEST_CTL_U,
  54. PLL_OFF_TEST_CTL_U1,
  55. PLL_OFF_TEST_CTL_U2,
  56. PLL_OFF_TEST_CTL_U3,
  57. PLL_OFF_STATE,
  58. PLL_OFF_STATUS,
  59. PLL_OFF_OPMODE,
  60. PLL_OFF_FRAC,
  61. PLL_OFF_CAL_VAL,
  62. PLL_OFF_MAX_REGS
  63. };
  64. extern const u8 clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_MAX][PLL_OFF_MAX_REGS];
  65. struct pll_vco {
  66. unsigned long min_freq;
  67. unsigned long max_freq;
  68. u32 val;
  69. };
  70. #define VCO(a, b, c) { \
  71. .val = a,\
  72. .min_freq = b,\
  73. .max_freq = c,\
  74. }
  75. /**
  76. * struct clk_alpha_pll - phase locked loop (PLL)
  77. * @offset: base address of registers
  78. * @regs: alpha pll register map (see @clk_alpha_pll_regs)
  79. * @config: array of pll settings
  80. * @vco_table: array of VCO settings
  81. * @num_vco: number of VCO settings in @vco_table
  82. * @flags: bitmask to indicate features supported by the hardware
  83. * @clkr: regmap clock handle
  84. */
  85. struct clk_alpha_pll {
  86. u32 offset;
  87. const u8 *regs;
  88. const struct alpha_pll_config *config;
  89. const struct pll_vco *vco_table;
  90. size_t num_vco;
  91. #define SUPPORTS_OFFLINE_REQ BIT(0)
  92. #define SUPPORTS_FSM_MODE BIT(2)
  93. #define SUPPORTS_DYNAMIC_UPDATE BIT(3)
  94. #define SUPPORTS_FSM_LEGACY_MODE BIT(4)
  95. u8 flags;
  96. struct clk_regmap clkr;
  97. };
  98. /**
  99. * struct clk_alpha_pll_postdiv - phase locked loop (PLL) post-divider
  100. * @offset: base address of registers
  101. * @regs: alpha pll register map (see @clk_alpha_pll_regs)
  102. * @width: width of post-divider
  103. * @post_div_shift: shift to differentiate between odd & even post-divider
  104. * @post_div_table: table with PLL odd and even post-divider settings
  105. * @num_post_div: Number of PLL post-divider settings
  106. *
  107. * @clkr: regmap clock handle
  108. */
  109. struct clk_alpha_pll_postdiv {
  110. u32 offset;
  111. u8 width;
  112. const u8 *regs;
  113. struct clk_regmap clkr;
  114. int post_div_shift;
  115. const struct clk_div_table *post_div_table;
  116. size_t num_post_div;
  117. };
  118. struct alpha_pll_config {
  119. u32 l;
  120. u32 cal_l;
  121. u32 alpha;
  122. u32 alpha_hi;
  123. u32 config_ctl_val;
  124. u32 config_ctl_hi_val;
  125. u32 config_ctl_hi1_val;
  126. u32 config_ctl_hi2_val;
  127. u32 user_ctl_val;
  128. u32 user_ctl_hi_val;
  129. u32 user_ctl_hi1_val;
  130. u32 test_ctl_val;
  131. u32 test_ctl_mask;
  132. u32 test_ctl_hi_val;
  133. u32 test_ctl_hi_mask;
  134. u32 test_ctl_hi1_val;
  135. u32 test_ctl_hi2_val;
  136. u32 test_ctl_hi3_val;
  137. u32 main_output_mask;
  138. u32 aux_output_mask;
  139. u32 aux2_output_mask;
  140. u32 early_output_mask;
  141. u32 alpha_en_mask;
  142. u32 alpha_mode_mask;
  143. u32 pre_div_val;
  144. u32 pre_div_mask;
  145. u32 post_div_val;
  146. u32 post_div_mask;
  147. u32 vco_val;
  148. u32 vco_mask;
  149. u32 status_val;
  150. u32 status_mask;
  151. u32 lock_det;
  152. };
  153. extern const struct clk_ops clk_alpha_pll_ops;
  154. extern const struct clk_ops clk_alpha_pll_fixed_ops;
  155. extern const struct clk_ops clk_alpha_pll_hwfsm_ops;
  156. extern const struct clk_ops clk_alpha_pll_postdiv_ops;
  157. extern const struct clk_ops clk_alpha_pll_huayra_ops;
  158. extern const struct clk_ops clk_alpha_pll_postdiv_ro_ops;
  159. extern const struct clk_ops clk_alpha_pll_stromer_ops;
  160. extern const struct clk_ops clk_alpha_pll_stromer_plus_ops;
  161. extern const struct clk_ops clk_alpha_pll_fabia_ops;
  162. extern const struct clk_ops clk_alpha_pll_fixed_fabia_ops;
  163. extern const struct clk_ops clk_alpha_pll_postdiv_fabia_ops;
  164. extern const struct clk_ops clk_alpha_pll_trion_ops;
  165. extern const struct clk_ops clk_alpha_pll_fixed_trion_ops;
  166. extern const struct clk_ops clk_alpha_pll_postdiv_trion_ops;
  167. extern const struct clk_ops clk_alpha_pll_lucid_ops;
  168. #define clk_alpha_pll_fixed_lucid_ops clk_alpha_pll_fixed_trion_ops
  169. extern const struct clk_ops clk_alpha_pll_postdiv_lucid_ops;
  170. extern const struct clk_ops clk_alpha_pll_agera_ops;
  171. extern const struct clk_ops clk_alpha_pll_lucid_5lpe_ops;
  172. extern const struct clk_ops clk_alpha_pll_fixed_lucid_5lpe_ops;
  173. extern const struct clk_ops clk_alpha_pll_postdiv_lucid_5lpe_ops;
  174. extern const struct clk_ops clk_alpha_pll_zonda_ops;
  175. #define clk_alpha_pll_postdiv_zonda_ops clk_alpha_pll_postdiv_fabia_ops
  176. #define clk_alpha_pll_zonda_ole_ops clk_alpha_pll_zonda_ops
  177. extern const struct clk_ops clk_alpha_pll_lucid_evo_ops;
  178. #define clk_alpha_pll_taycan_elu_ops clk_alpha_pll_lucid_evo_ops
  179. #define clk_alpha_pll_taycan_eko_t_ops clk_alpha_pll_lucid_evo_ops
  180. extern const struct clk_ops clk_alpha_pll_reset_lucid_evo_ops;
  181. #define clk_alpha_pll_reset_lucid_ole_ops clk_alpha_pll_reset_lucid_evo_ops
  182. extern const struct clk_ops clk_alpha_pll_fixed_lucid_evo_ops;
  183. #define clk_alpha_pll_fixed_lucid_ole_ops clk_alpha_pll_fixed_lucid_evo_ops
  184. #define clk_alpha_pll_fixed_taycan_elu_ops clk_alpha_pll_fixed_lucid_evo_ops
  185. #define clk_alpha_pll_fixed_taycan_eko_t_ops clk_alpha_pll_fixed_lucid_evo_ops
  186. extern const struct clk_ops clk_alpha_pll_postdiv_lucid_evo_ops;
  187. #define clk_alpha_pll_postdiv_lucid_ole_ops clk_alpha_pll_postdiv_lucid_evo_ops
  188. #define clk_alpha_pll_postdiv_taycan_elu_ops clk_alpha_pll_postdiv_lucid_evo_ops
  189. #define clk_alpha_pll_postdiv_taycan_eko_t_ops clk_alpha_pll_postdiv_lucid_evo_ops
  190. extern const struct clk_ops clk_alpha_pll_pongo_elu_ops;
  191. #define clk_alpha_pll_pongo_eko_t_ops clk_alpha_pll_pongo_elu_ops
  192. extern const struct clk_ops clk_alpha_pll_rivian_evo_ops;
  193. #define clk_alpha_pll_postdiv_rivian_evo_ops clk_alpha_pll_postdiv_fabia_ops
  194. #define clk_alpha_pll_rivian_elu_ops clk_alpha_pll_rivian_evo_ops
  195. #define clk_alpha_pll_rivian_eko_t_ops clk_alpha_pll_rivian_evo_ops
  196. extern const struct clk_ops clk_alpha_pll_regera_ops;
  197. extern const struct clk_ops clk_alpha_pll_slew_ops;
  198. void clk_alpha_pll_configure(struct clk_alpha_pll *pll, struct regmap *regmap,
  199. const struct alpha_pll_config *config);
  200. void clk_huayra_2290_pll_configure(struct clk_alpha_pll *pll, struct regmap *regmap,
  201. const struct alpha_pll_config *config);
  202. void clk_fabia_pll_configure(struct clk_alpha_pll *pll, struct regmap *regmap,
  203. const struct alpha_pll_config *config);
  204. void clk_trion_pll_configure(struct clk_alpha_pll *pll, struct regmap *regmap,
  205. const struct alpha_pll_config *config);
  206. void clk_agera_pll_configure(struct clk_alpha_pll *pll, struct regmap *regmap,
  207. const struct alpha_pll_config *config);
  208. #define clk_lucid_pll_configure(pll, regmap, config) \
  209. clk_trion_pll_configure(pll, regmap, config)
  210. void clk_zonda_pll_configure(struct clk_alpha_pll *pll, struct regmap *regmap,
  211. const struct alpha_pll_config *config);
  212. void clk_lucid_5lpe_pll_configure(struct clk_alpha_pll *pll, struct regmap *regmap,
  213. const struct alpha_pll_config *config);
  214. void clk_lucid_evo_pll_configure(struct clk_alpha_pll *pll, struct regmap *regmap,
  215. const struct alpha_pll_config *config);
  216. void clk_lucid_ole_pll_configure(struct clk_alpha_pll *pll, struct regmap *regmap,
  217. const struct alpha_pll_config *config);
  218. void clk_pongo_elu_pll_configure(struct clk_alpha_pll *pll, struct regmap *regmap,
  219. const struct alpha_pll_config *config);
  220. #define clk_taycan_elu_pll_configure(pll, regmap, config) \
  221. clk_lucid_evo_pll_configure(pll, regmap, config)
  222. #define clk_taycan_eko_t_pll_configure(pll, regmap, config) \
  223. clk_lucid_evo_pll_configure(pll, regmap, config)
  224. void clk_rivian_evo_pll_configure(struct clk_alpha_pll *pll, struct regmap *regmap,
  225. const struct alpha_pll_config *config);
  226. void clk_stromer_pll_configure(struct clk_alpha_pll *pll, struct regmap *regmap,
  227. const struct alpha_pll_config *config);
  228. void clk_regera_pll_configure(struct clk_alpha_pll *pll, struct regmap *regmap,
  229. const struct alpha_pll_config *config);
  230. void qcom_clk_alpha_pll_configure(struct clk_alpha_pll *pll, struct regmap *regmap);
  231. #endif