clk-uclass.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. #include <fdtdec.h>
  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 fdtdec_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. * enable() - Enable a clock.
  77. *
  78. * @clk: The clock to manipulate.
  79. * @return zero on success, or -ve error code.
  80. */
  81. int (*enable)(struct clk *clk);
  82. /**
  83. * disable() - Disable a clock.
  84. *
  85. * @clk: The clock to manipulate.
  86. * @return zero on success, or -ve error code.
  87. */
  88. int (*disable)(struct clk *clk);
  89. };
  90. #endif