clock.h 1.8 KB

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