clock.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. 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 module *owner;
  23. struct clk *parent;
  24. struct clk_ops *ops;
  25. struct kref kref;
  26. unsigned long rate;
  27. unsigned long flags;
  28. unsigned long arch_flags;
  29. };
  30. #define CLK_ALWAYS_ENABLED (1 << 0)
  31. #define CLK_RATE_PROPAGATES (1 << 1)
  32. /* Should be defined by processor-specific code */
  33. void arch_init_clk_ops(struct clk_ops **, int type);
  34. int __init arch_clk_init(void);
  35. /* arch/sh/kernel/cpu/clock.c */
  36. int clk_init(void);
  37. void clk_recalc_rate(struct clk *);
  38. int clk_register(struct clk *);
  39. void clk_unregister(struct clk *);
  40. static inline int clk_always_enable(const char *id)
  41. {
  42. struct clk *clk;
  43. int ret;
  44. clk = clk_get(NULL, id);
  45. if (IS_ERR(clk))
  46. return PTR_ERR(clk);
  47. ret = clk_enable(clk);
  48. if (ret)
  49. clk_put(clk);
  50. return ret;
  51. }
  52. /* the exported API, in addition to clk_set_rate */
  53. /**
  54. * clk_set_rate_ex - set the clock rate for a clock source, with additional parameter
  55. * @clk: clock source
  56. * @rate: desired clock rate in Hz
  57. * @algo_id: algorithm id to be passed down to ops->set_rate
  58. *
  59. * Returns success (0) or negative errno.
  60. */
  61. int clk_set_rate_ex(struct clk *clk, unsigned long rate, int algo_id);
  62. enum clk_sh_algo_id {
  63. NO_CHANGE = 0,
  64. IUS_N1_N1,
  65. IUS_322,
  66. IUS_522,
  67. IUS_N11,
  68. SB_N1,
  69. SB3_N1,
  70. SB3_32,
  71. SB3_43,
  72. SB3_54,
  73. BP_N1,
  74. IP_N1,
  75. };
  76. #endif /* __ASM_SH_CLOCK_H */