clock.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*
  2. * linux/include/asm-arm/hardware/clock.h
  3. *
  4. * Copyright (C) 2004 ARM Limited.
  5. * Written by Deep Blue Solutions Limited.
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. */
  11. #ifndef ASMARM_CLOCK_H
  12. #define ASMARM_CLOCK_H
  13. struct device;
  14. /*
  15. * The base API.
  16. */
  17. /*
  18. * struct clk - an machine class defined object / cookie.
  19. */
  20. struct clk;
  21. /**
  22. * clk_get - lookup and obtain a reference to a clock producer.
  23. * @dev: device for clock "consumer"
  24. * @id: device ID
  25. *
  26. * Returns a struct clk corresponding to the clock producer, or
  27. * valid IS_ERR() condition containing errno.
  28. */
  29. struct clk *clk_get(struct device *dev, const char *id);
  30. /**
  31. * clk_enable - inform the system when the clock source should be running.
  32. * @clk: clock source
  33. *
  34. * If the clock can not be enabled/disabled, this should return success.
  35. *
  36. * Returns success (0) or negative errno.
  37. */
  38. int clk_enable(struct clk *clk);
  39. /**
  40. * clk_disable - inform the system when the clock source is no longer required.
  41. * @clk: clock source
  42. */
  43. void clk_disable(struct clk *clk);
  44. /**
  45. * clk_use - increment the use count
  46. * @clk: clock source
  47. *
  48. * Returns success (0) or negative errno.
  49. */
  50. int clk_use(struct clk *clk);
  51. /**
  52. * clk_unuse - decrement the use count
  53. * @clk: clock source
  54. */
  55. void clk_unuse(struct clk *clk);
  56. /**
  57. * clk_get_rate - obtain the current clock rate (in Hz) for a clock source.
  58. * This is only valid once the clock source has been enabled.
  59. * @clk: clock source
  60. */
  61. unsigned long clk_get_rate(struct clk *clk);
  62. /**
  63. * clk_put - "free" the clock source
  64. * @clk: clock source
  65. */
  66. void clk_put(struct clk *clk);
  67. /*
  68. * The remaining APIs are optional for machine class support.
  69. */
  70. /**
  71. * clk_round_rate - adjust a rate to the exact rate a clock can provide
  72. * @clk: clock source
  73. * @rate: desired clock rate in Hz
  74. *
  75. * Returns rounded clock rate in Hz, or negative errno.
  76. */
  77. long clk_round_rate(struct clk *clk, unsigned long rate);
  78. /**
  79. * clk_set_rate - set the clock rate for a clock source
  80. * @clk: clock source
  81. * @rate: desired clock rate in Hz
  82. *
  83. * Returns success (0) or negative errno.
  84. */
  85. int clk_set_rate(struct clk *clk, unsigned long rate);
  86. /**
  87. * clk_set_parent - set the parent clock source for this clock
  88. * @clk: clock source
  89. * @parent: parent clock source
  90. *
  91. * Returns success (0) or negative errno.
  92. */
  93. int clk_set_parent(struct clk *clk, struct clk *parent);
  94. /**
  95. * clk_get_parent - get the parent clock source for this clock
  96. * @clk: clock source
  97. *
  98. * Returns struct clk corresponding to parent clock source, or
  99. * valid IS_ERR() condition containing errno.
  100. */
  101. struct clk *clk_get_parent(struct clk *clk);
  102. #endif