clk-uniphier.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /*
  2. * Copyright (C) 2016 Socionext Inc.
  3. * Author: Masahiro Yamada <yamada.masahiro@socionext.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. */
  15. #ifndef __CLK_UNIPHIER_H__
  16. #define __CLK_UNIPHIER_H__
  17. struct clk_hw;
  18. struct device;
  19. struct regmap;
  20. #define UNIPHIER_CLK_MUX_MAX_PARENTS 8
  21. enum uniphier_clk_type {
  22. UNIPHIER_CLK_TYPE_FIXED_FACTOR,
  23. UNIPHIER_CLK_TYPE_FIXED_RATE,
  24. UNIPHIER_CLK_TYPE_GATE,
  25. UNIPHIER_CLK_TYPE_MUX,
  26. };
  27. struct uniphier_clk_fixed_factor_data {
  28. const char *parent_name;
  29. unsigned int mult;
  30. unsigned int div;
  31. };
  32. struct uniphier_clk_fixed_rate_data {
  33. unsigned long fixed_rate;
  34. };
  35. struct uniphier_clk_gate_data {
  36. const char *parent_name;
  37. unsigned int reg;
  38. unsigned int bit;
  39. };
  40. struct uniphier_clk_mux_data {
  41. const char *parent_names[UNIPHIER_CLK_MUX_MAX_PARENTS];
  42. unsigned int num_parents;
  43. unsigned int reg;
  44. unsigned int masks[UNIPHIER_CLK_MUX_MAX_PARENTS];
  45. unsigned int vals[UNIPHIER_CLK_MUX_MAX_PARENTS];
  46. };
  47. struct uniphier_clk_data {
  48. const char *name;
  49. enum uniphier_clk_type type;
  50. int idx;
  51. union {
  52. struct uniphier_clk_fixed_factor_data factor;
  53. struct uniphier_clk_fixed_rate_data rate;
  54. struct uniphier_clk_gate_data gate;
  55. struct uniphier_clk_mux_data mux;
  56. } data;
  57. };
  58. #define UNIPHIER_CLK_FACTOR(_name, _idx, _parent, _mult, _div) \
  59. { \
  60. .name = (_name), \
  61. .type = UNIPHIER_CLK_TYPE_FIXED_FACTOR, \
  62. .idx = (_idx), \
  63. .data.factor = { \
  64. .parent_name = (_parent), \
  65. .mult = (_mult), \
  66. .div = (_div), \
  67. }, \
  68. }
  69. #define UNIPHIER_CLK_GATE(_name, _idx, _parent, _reg, _bit) \
  70. { \
  71. .name = (_name), \
  72. .type = UNIPHIER_CLK_TYPE_GATE, \
  73. .idx = (_idx), \
  74. .data.gate = { \
  75. .parent_name = (_parent), \
  76. .reg = (_reg), \
  77. .bit = (_bit), \
  78. }, \
  79. }
  80. struct clk_hw *uniphier_clk_register_fixed_factor(struct device *dev,
  81. const char *name,
  82. const struct uniphier_clk_fixed_factor_data *data);
  83. struct clk_hw *uniphier_clk_register_fixed_rate(struct device *dev,
  84. const char *name,
  85. const struct uniphier_clk_fixed_rate_data *data);
  86. struct clk_hw *uniphier_clk_register_gate(struct device *dev,
  87. struct regmap *regmap,
  88. const char *name,
  89. const struct uniphier_clk_gate_data *data);
  90. struct clk_hw *uniphier_clk_register_mux(struct device *dev,
  91. struct regmap *regmap,
  92. const char *name,
  93. const struct uniphier_clk_mux_data *data);
  94. extern const struct uniphier_clk_data uniphier_sld3_sys_clk_data[];
  95. extern const struct uniphier_clk_data uniphier_ld4_sys_clk_data[];
  96. extern const struct uniphier_clk_data uniphier_pro4_sys_clk_data[];
  97. extern const struct uniphier_clk_data uniphier_sld8_sys_clk_data[];
  98. extern const struct uniphier_clk_data uniphier_pro5_sys_clk_data[];
  99. extern const struct uniphier_clk_data uniphier_pxs2_sys_clk_data[];
  100. extern const struct uniphier_clk_data uniphier_ld11_sys_clk_data[];
  101. extern const struct uniphier_clk_data uniphier_ld20_sys_clk_data[];
  102. extern const struct uniphier_clk_data uniphier_sld3_mio_clk_data[];
  103. extern const struct uniphier_clk_data uniphier_pro5_sd_clk_data[];
  104. extern const struct uniphier_clk_data uniphier_ld4_peri_clk_data[];
  105. extern const struct uniphier_clk_data uniphier_pro4_peri_clk_data[];
  106. #endif /* __CLK_UNIPHIER_H__ */