clk-uclass.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. * Copyright (c) 2015 Google, Inc
  3. * Written by Simon Glass <sjg@chromium.org>
  4. * Copyright (c) 2016, NVIDIA CORPORATION.
  5. *
  6. * SPDX-License-Identifier: GPL-2.0+
  7. */
  8. #ifndef _CLK_UCLASS_H
  9. #define _CLK_UCLASS_H
  10. /* See clk.h for background documentation. */
  11. #include <clk.h>
  12. struct ofnode_phandle_args;
  13. /**
  14. * struct clk_ops - The functions that a clock driver must implement.
  15. */
  16. struct clk_ops {
  17. /**
  18. * of_xlate - Translate a client's device-tree (OF) clock specifier.
  19. *
  20. * The clock core calls this function as the first step in implementing
  21. * a client's clk_get_by_*() call.
  22. *
  23. * If this function pointer is set to NULL, the clock core will use a
  24. * default implementation, which assumes #clock-cells = <1>, and that
  25. * the DT cell contains a simple integer clock ID.
  26. *
  27. * At present, the clock API solely supports device-tree. If this
  28. * changes, other xxx_xlate() functions may be added to support those
  29. * other mechanisms.
  30. *
  31. * @clock: The clock struct to hold the translation result.
  32. * @args: The clock specifier values from device tree.
  33. * @return 0 if OK, or a negative error code.
  34. */
  35. int (*of_xlate)(struct clk *clock,
  36. struct ofnode_phandle_args *args);
  37. /**
  38. * request - Request a translated clock.
  39. *
  40. * The clock core calls this function as the second step in
  41. * implementing a client's clk_get_by_*() call, following a successful
  42. * xxx_xlate() call, or as the only step in implementing a client's
  43. * clk_request() call.
  44. *
  45. * @clock: The clock struct to request; this has been fille in by
  46. * a previoux xxx_xlate() function call, or by the caller
  47. * of clk_request().
  48. * @return 0 if OK, or a negative error code.
  49. */
  50. int (*request)(struct clk *clock);
  51. /**
  52. * free - Free a previously requested clock.
  53. *
  54. * This is the implementation of the client clk_free() API.
  55. *
  56. * @clock: The clock to free.
  57. * @return 0 if OK, or a negative error code.
  58. */
  59. int (*free)(struct clk *clock);
  60. /**
  61. * get_rate() - Get current clock rate.
  62. *
  63. * @clk: The clock to query.
  64. * @return clock rate in Hz, or -ve error code
  65. */
  66. ulong (*get_rate)(struct clk *clk);
  67. /**
  68. * set_rate() - Set current clock rate.
  69. *
  70. * @clk: The clock to manipulate.
  71. * @rate: New clock rate in Hz.
  72. * @return new rate, or -ve error code.
  73. */
  74. ulong (*set_rate)(struct clk *clk, ulong rate);
  75. /**
  76. * set_parent() - Set current clock parent
  77. *
  78. * @clk: The clock to manipulate.
  79. * @parent: New clock parent.
  80. * @return zero on success, or -ve error code.
  81. */
  82. int (*set_parent)(struct clk *clk, struct clk *parent);
  83. /**
  84. * enable() - Enable a clock.
  85. *
  86. * @clk: The clock to manipulate.
  87. * @return zero on success, or -ve error code.
  88. */
  89. int (*enable)(struct clk *clk);
  90. /**
  91. * disable() - Disable a clock.
  92. *
  93. * @clk: The clock to manipulate.
  94. * @return zero on success, or -ve error code.
  95. */
  96. int (*disable)(struct clk *clk);
  97. };
  98. #endif