clk-alpha-pll.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /*
  2. * Copyright (c) 2015, 2018, 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. #ifndef __QCOM_CLK_ALPHA_PLL_H__
  14. #define __QCOM_CLK_ALPHA_PLL_H__
  15. #include <linux/clk-provider.h>
  16. #include "clk-regmap.h"
  17. /* Alpha PLL types */
  18. enum {
  19. CLK_ALPHA_PLL_TYPE_DEFAULT,
  20. CLK_ALPHA_PLL_TYPE_HUAYRA,
  21. CLK_ALPHA_PLL_TYPE_BRAMMO,
  22. CLK_ALPHA_PLL_TYPE_FABIA,
  23. CLK_ALPHA_PLL_TYPE_MAX,
  24. };
  25. enum {
  26. PLL_OFF_L_VAL,
  27. PLL_OFF_ALPHA_VAL,
  28. PLL_OFF_ALPHA_VAL_U,
  29. PLL_OFF_USER_CTL,
  30. PLL_OFF_USER_CTL_U,
  31. PLL_OFF_CONFIG_CTL,
  32. PLL_OFF_CONFIG_CTL_U,
  33. PLL_OFF_TEST_CTL,
  34. PLL_OFF_TEST_CTL_U,
  35. PLL_OFF_STATUS,
  36. PLL_OFF_OPMODE,
  37. PLL_OFF_FRAC,
  38. PLL_OFF_MAX_REGS
  39. };
  40. extern const u8 clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_MAX][PLL_OFF_MAX_REGS];
  41. struct pll_vco {
  42. unsigned long min_freq;
  43. unsigned long max_freq;
  44. u32 val;
  45. };
  46. /**
  47. * struct clk_alpha_pll - phase locked loop (PLL)
  48. * @offset: base address of registers
  49. * @vco_table: array of VCO settings
  50. * @regs: alpha pll register map (see @clk_alpha_pll_regs)
  51. * @clkr: regmap clock handle
  52. */
  53. struct clk_alpha_pll {
  54. u32 offset;
  55. const u8 *regs;
  56. const struct pll_vco *vco_table;
  57. size_t num_vco;
  58. #define SUPPORTS_OFFLINE_REQ BIT(0)
  59. #define SUPPORTS_FSM_MODE BIT(2)
  60. #define SUPPORTS_DYNAMIC_UPDATE BIT(3)
  61. u8 flags;
  62. struct clk_regmap clkr;
  63. };
  64. /**
  65. * struct clk_alpha_pll_postdiv - phase locked loop (PLL) post-divider
  66. * @offset: base address of registers
  67. * @regs: alpha pll register map (see @clk_alpha_pll_regs)
  68. * @width: width of post-divider
  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. *
  73. * @clkr: regmap clock handle
  74. */
  75. struct clk_alpha_pll_postdiv {
  76. u32 offset;
  77. u8 width;
  78. const u8 *regs;
  79. struct clk_regmap clkr;
  80. int post_div_shift;
  81. const struct clk_div_table *post_div_table;
  82. size_t num_post_div;
  83. };
  84. struct alpha_pll_config {
  85. u32 l;
  86. u32 alpha;
  87. u32 alpha_hi;
  88. u32 config_ctl_val;
  89. u32 config_ctl_hi_val;
  90. u32 main_output_mask;
  91. u32 aux_output_mask;
  92. u32 aux2_output_mask;
  93. u32 early_output_mask;
  94. u32 alpha_en_mask;
  95. u32 alpha_mode_mask;
  96. u32 pre_div_val;
  97. u32 pre_div_mask;
  98. u32 post_div_val;
  99. u32 post_div_mask;
  100. u32 vco_val;
  101. u32 vco_mask;
  102. };
  103. extern const struct clk_ops clk_alpha_pll_ops;
  104. extern const struct clk_ops clk_alpha_pll_hwfsm_ops;
  105. extern const struct clk_ops clk_alpha_pll_postdiv_ops;
  106. extern const struct clk_ops clk_alpha_pll_huayra_ops;
  107. extern const struct clk_ops clk_alpha_pll_postdiv_ro_ops;
  108. extern const struct clk_ops clk_alpha_pll_fabia_ops;
  109. extern const struct clk_ops clk_alpha_pll_fixed_fabia_ops;
  110. extern const struct clk_ops clk_alpha_pll_postdiv_fabia_ops;
  111. void clk_alpha_pll_configure(struct clk_alpha_pll *pll, struct regmap *regmap,
  112. const struct alpha_pll_config *config);
  113. void clk_fabia_pll_configure(struct clk_alpha_pll *pll, struct regmap *regmap,
  114. const struct alpha_pll_config *config);
  115. #endif