clock.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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/clk.h>
  6. #include <linux/err.h>
  7. struct clk;
  8. struct clk_ops {
  9. void (*init)(struct clk *clk);
  10. int (*enable)(struct clk *clk);
  11. void (*disable)(struct clk *clk);
  12. unsigned long (*recalc)(struct clk *clk);
  13. int (*set_rate)(struct clk *clk, unsigned long rate, int algo_id);
  14. int (*set_parent)(struct clk *clk, struct clk *parent);
  15. long (*round_rate)(struct clk *clk, unsigned long rate);
  16. };
  17. struct clk {
  18. struct list_head node;
  19. const char *name;
  20. int id;
  21. struct module *owner;
  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. };
  35. struct clk_lookup {
  36. struct list_head node;
  37. const char *dev_id;
  38. const char *con_id;
  39. struct clk *clk;
  40. };
  41. #define CLK_ENABLE_ON_INIT (1 << 0)
  42. /* Should be defined by processor-specific code */
  43. void __deprecated arch_init_clk_ops(struct clk_ops **, int type);
  44. int __init arch_clk_init(void);
  45. /* arch/sh/kernel/cpu/clock.c */
  46. int clk_init(void);
  47. unsigned long followparent_recalc(struct clk *);
  48. void recalculate_root_clocks(void);
  49. void propagate_rate(struct clk *);
  50. int clk_reparent(struct clk *child, struct clk *parent);
  51. int clk_register(struct clk *);
  52. void clk_unregister(struct clk *);
  53. /* arch/sh/kernel/cpu/clock-cpg.c */
  54. int __init __deprecated cpg_clk_init(void);
  55. /* the exported API, in addition to clk_set_rate */
  56. /**
  57. * clk_set_rate_ex - set the clock rate for a clock source, with additional parameter
  58. * @clk: clock source
  59. * @rate: desired clock rate in Hz
  60. * @algo_id: algorithm id to be passed down to ops->set_rate
  61. *
  62. * Returns success (0) or negative errno.
  63. */
  64. int clk_set_rate_ex(struct clk *clk, unsigned long rate, int algo_id);
  65. enum clk_sh_algo_id {
  66. NO_CHANGE = 0,
  67. IUS_N1_N1,
  68. IUS_322,
  69. IUS_522,
  70. IUS_N11,
  71. SB_N1,
  72. SB3_N1,
  73. SB3_32,
  74. SB3_43,
  75. SB3_54,
  76. BP_N1,
  77. IP_N1,
  78. };
  79. struct clk_div_mult_table {
  80. unsigned int *divisors;
  81. unsigned int nr_divisors;
  82. unsigned int *multipliers;
  83. unsigned int nr_multipliers;
  84. };
  85. struct cpufreq_frequency_table;
  86. void clk_rate_table_build(struct clk *clk,
  87. struct cpufreq_frequency_table *freq_table,
  88. int nr_freqs,
  89. struct clk_div_mult_table *src_table,
  90. unsigned long *bitmap);
  91. long clk_rate_table_round(struct clk *clk,
  92. struct cpufreq_frequency_table *freq_table,
  93. unsigned long rate);
  94. #endif /* __ASM_SH_CLOCK_H */