clk.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /*
  2. * Hisilicon Hi3620 clock gate driver
  3. *
  4. * Copyright (c) 2012-2013 Hisilicon Limited.
  5. * Copyright (c) 2012-2013 Linaro Limited.
  6. *
  7. * Author: Haojian Zhuang <haojian.zhuang@linaro.org>
  8. * Xin Li <li.xin@linaro.org>
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License along
  21. * with this program; if not, write to the Free Software Foundation, Inc.,
  22. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  23. *
  24. */
  25. #ifndef __HISI_CLK_H
  26. #define __HISI_CLK_H
  27. #include <linux/clk-provider.h>
  28. #include <linux/io.h>
  29. #include <linux/spinlock.h>
  30. struct hisi_clock_data {
  31. struct clk_onecell_data clk_data;
  32. void __iomem *base;
  33. };
  34. struct hisi_fixed_rate_clock {
  35. unsigned int id;
  36. char *name;
  37. const char *parent_name;
  38. unsigned long flags;
  39. unsigned long fixed_rate;
  40. };
  41. struct hisi_fixed_factor_clock {
  42. unsigned int id;
  43. char *name;
  44. const char *parent_name;
  45. unsigned long mult;
  46. unsigned long div;
  47. unsigned long flags;
  48. };
  49. struct hisi_mux_clock {
  50. unsigned int id;
  51. const char *name;
  52. const char *const *parent_names;
  53. u8 num_parents;
  54. unsigned long flags;
  55. unsigned long offset;
  56. u8 shift;
  57. u8 width;
  58. u8 mux_flags;
  59. u32 *table;
  60. const char *alias;
  61. };
  62. struct hisi_divider_clock {
  63. unsigned int id;
  64. const char *name;
  65. const char *parent_name;
  66. unsigned long flags;
  67. unsigned long offset;
  68. u8 shift;
  69. u8 width;
  70. u8 div_flags;
  71. struct clk_div_table *table;
  72. const char *alias;
  73. };
  74. struct hi6220_divider_clock {
  75. unsigned int id;
  76. const char *name;
  77. const char *parent_name;
  78. unsigned long flags;
  79. unsigned long offset;
  80. u8 shift;
  81. u8 width;
  82. u32 mask_bit;
  83. const char *alias;
  84. };
  85. struct hisi_gate_clock {
  86. unsigned int id;
  87. const char *name;
  88. const char *parent_name;
  89. unsigned long flags;
  90. unsigned long offset;
  91. u8 bit_idx;
  92. u8 gate_flags;
  93. const char *alias;
  94. };
  95. struct clk *hisi_register_clkgate_sep(struct device *, const char *,
  96. const char *, unsigned long,
  97. void __iomem *, u8,
  98. u8, spinlock_t *);
  99. struct clk *hi6220_register_clkdiv(struct device *dev, const char *name,
  100. const char *parent_name, unsigned long flags, void __iomem *reg,
  101. u8 shift, u8 width, u32 mask_bit, spinlock_t *lock);
  102. struct hisi_clock_data *hisi_clk_init(struct device_node *, int);
  103. void hisi_clk_register_fixed_rate(struct hisi_fixed_rate_clock *,
  104. int, struct hisi_clock_data *);
  105. void hisi_clk_register_fixed_factor(struct hisi_fixed_factor_clock *,
  106. int, struct hisi_clock_data *);
  107. void hisi_clk_register_mux(struct hisi_mux_clock *, int,
  108. struct hisi_clock_data *);
  109. void hisi_clk_register_divider(struct hisi_divider_clock *,
  110. int, struct hisi_clock_data *);
  111. void hisi_clk_register_gate(struct hisi_gate_clock *,
  112. int, struct hisi_clock_data *);
  113. void hisi_clk_register_gate_sep(struct hisi_gate_clock *,
  114. int, struct hisi_clock_data *);
  115. void hi6220_clk_register_divider(struct hi6220_divider_clock *,
  116. int, struct hisi_clock_data *);
  117. #endif /* __HISI_CLK_H */