clock.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #ifndef __ASM_SH_CLOCK_H
  2. #define __ASM_SH_CLOCK_H
  3. #include <linux/kref.h>
  4. #include <linux/list.h>
  5. #include <linux/seq_file.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. void (*enable)(struct clk *clk);
  12. void (*disable)(struct clk *clk);
  13. void (*recalc)(struct clk *clk);
  14. int (*set_rate)(struct clk *clk, unsigned long rate, int algo_id);
  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 kref kref;
  25. unsigned long rate;
  26. unsigned long flags;
  27. unsigned long arch_flags;
  28. };
  29. #define CLK_ALWAYS_ENABLED (1 << 0)
  30. #define CLK_RATE_PROPAGATES (1 << 1)
  31. /* Should be defined by processor-specific code */
  32. void arch_init_clk_ops(struct clk_ops **, int type);
  33. /* arch/sh/kernel/cpu/clock.c */
  34. int clk_init(void);
  35. void clk_recalc_rate(struct clk *);
  36. int clk_register(struct clk *);
  37. void clk_unregister(struct clk *);
  38. static inline int clk_always_enable(const char *id)
  39. {
  40. struct clk *clk;
  41. int ret;
  42. clk = clk_get(NULL, id);
  43. if (IS_ERR(clk))
  44. return PTR_ERR(clk);
  45. ret = clk_enable(clk);
  46. if (ret)
  47. clk_put(clk);
  48. return ret;
  49. }
  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. #endif /* __ASM_SH_CLOCK_H */