clk-uclass.h 2.8 KB

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