clk.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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 **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 hisi_gate_clock {
  75. unsigned int id;
  76. const char *name;
  77. const char *parent_name;
  78. unsigned long flags;
  79. unsigned long offset;
  80. u8 bit_idx;
  81. u8 gate_flags;
  82. const char *alias;
  83. };
  84. struct clk *hisi_register_clkgate_sep(struct device *, const char *,
  85. const char *, unsigned long,
  86. void __iomem *, u8,
  87. u8, spinlock_t *);
  88. struct hisi_clock_data __init *hisi_clk_init(struct device_node *, int);
  89. void __init hisi_clk_register_fixed_rate(struct hisi_fixed_rate_clock *,
  90. int, struct hisi_clock_data *);
  91. void __init hisi_clk_register_fixed_factor(struct hisi_fixed_factor_clock *,
  92. int, struct hisi_clock_data *);
  93. void __init hisi_clk_register_mux(struct hisi_mux_clock *, int,
  94. struct hisi_clock_data *);
  95. void __init hisi_clk_register_divider(struct hisi_divider_clock *,
  96. int, struct hisi_clock_data *);
  97. void __init hisi_clk_register_gate(struct hisi_gate_clock *,
  98. int, struct hisi_clock_data *);
  99. void __init hisi_clk_register_gate_sep(struct hisi_gate_clock *,
  100. int, struct hisi_clock_data *);
  101. #endif /* __HISI_CLK_H */