clock.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. #ifndef __ASM_SH_CLOCK_H
  2. #define __ASM_SH_CLOCK_H
  3. #include <linux/list.h>
  4. #include <linux/seq_file.h>
  5. #include <linux/cpufreq.h>
  6. #include <linux/clk.h>
  7. #include <linux/err.h>
  8. struct clk;
  9. struct clk_ops {
  10. void (*init)(struct clk *clk);
  11. int (*enable)(struct clk *clk);
  12. void (*disable)(struct clk *clk);
  13. unsigned long (*recalc)(struct clk *clk);
  14. int (*set_rate)(struct clk *clk, unsigned long rate, int algo_id);
  15. int (*set_parent)(struct clk *clk, struct clk *parent);
  16. long (*round_rate)(struct clk *clk, unsigned long rate);
  17. };
  18. struct clk {
  19. struct list_head node;
  20. const char *name;
  21. int id;
  22. struct clk *parent;
  23. struct clk_ops *ops;
  24. struct list_head children;
  25. struct list_head sibling; /* node for children */
  26. int usecount;
  27. unsigned long rate;
  28. unsigned long flags;
  29. void __iomem *enable_reg;
  30. unsigned int enable_bit;
  31. unsigned long arch_flags;
  32. void *priv;
  33. struct dentry *dentry;
  34. struct cpufreq_frequency_table *freq_table;
  35. };
  36. #define CLK_ENABLE_ON_INIT (1 << 0)
  37. /* Should be defined by processor-specific code */
  38. void __deprecated arch_init_clk_ops(struct clk_ops **, int type);
  39. int __init arch_clk_init(void);
  40. /* arch/sh/kernel/cpu/clock.c */
  41. int clk_init(void);
  42. unsigned long followparent_recalc(struct clk *);
  43. void recalculate_root_clocks(void);
  44. void propagate_rate(struct clk *);
  45. int clk_reparent(struct clk *child, struct clk *parent);
  46. int clk_register(struct clk *);
  47. void clk_unregister(struct clk *);
  48. /* arch/sh/kernel/cpu/clock-cpg.c */
  49. int __init __deprecated cpg_clk_init(void);
  50. /* the exported API, in addition to clk_set_rate */
  51. /**
  52. * clk_set_rate_ex - set the clock rate for a clock source, with additional parameter
  53. * @clk: clock source
  54. * @rate: desired clock rate in Hz
  55. * @algo_id: algorithm id to be passed down to ops->set_rate
  56. *
  57. * Returns success (0) or negative errno.
  58. */
  59. int clk_set_rate_ex(struct clk *clk, unsigned long rate, int algo_id);
  60. enum clk_sh_algo_id {
  61. NO_CHANGE = 0,
  62. IUS_N1_N1,
  63. IUS_322,
  64. IUS_522,
  65. IUS_N11,
  66. SB_N1,
  67. SB3_N1,
  68. SB3_32,
  69. SB3_43,
  70. SB3_54,
  71. BP_N1,
  72. IP_N1,
  73. };
  74. struct clk_div_mult_table {
  75. unsigned int *divisors;
  76. unsigned int nr_divisors;
  77. unsigned int *multipliers;
  78. unsigned int nr_multipliers;
  79. };
  80. struct cpufreq_frequency_table;
  81. void clk_rate_table_build(struct clk *clk,
  82. struct cpufreq_frequency_table *freq_table,
  83. int nr_freqs,
  84. struct clk_div_mult_table *src_table,
  85. unsigned long *bitmap);
  86. long clk_rate_table_round(struct clk *clk,
  87. struct cpufreq_frequency_table *freq_table,
  88. unsigned long rate);
  89. int clk_rate_table_find(struct clk *clk,
  90. struct cpufreq_frequency_table *freq_table,
  91. unsigned long rate);
  92. #define SH_CLK_MSTP32(_parent, _enable_reg, _enable_bit, _flags) \
  93. { \
  94. .parent = _parent, \
  95. .enable_reg = (void __iomem *)_enable_reg, \
  96. .enable_bit = _enable_bit, \
  97. .flags = _flags, \
  98. }
  99. int sh_clk_mstp32_register(struct clk *clks, int nr);
  100. #define SH_CLK_DIV4(_parent, _reg, _shift, _div_bitmap, _flags) \
  101. { \
  102. .parent = _parent, \
  103. .enable_reg = (void __iomem *)_reg, \
  104. .enable_bit = _shift, \
  105. .arch_flags = _div_bitmap, \
  106. .flags = _flags, \
  107. }
  108. struct clk_div4_table {
  109. struct clk_div_mult_table *div_mult_table;
  110. void (*kick)(struct clk *clk);
  111. };
  112. int sh_clk_div4_register(struct clk *clks, int nr,
  113. struct clk_div4_table *table);
  114. int sh_clk_div4_enable_register(struct clk *clks, int nr,
  115. struct clk_div4_table *table);
  116. int sh_clk_div4_reparent_register(struct clk *clks, int nr,
  117. struct clk_div4_table *table);
  118. #define SH_CLK_DIV6(_parent, _reg, _flags) \
  119. { \
  120. .parent = _parent, \
  121. .enable_reg = (void __iomem *)_reg, \
  122. .flags = _flags, \
  123. }
  124. int sh_clk_div6_register(struct clk *clks, int nr);
  125. #endif /* __ASM_SH_CLOCK_H */