power-domain-uclass.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (c) 2016, NVIDIA CORPORATION.
  4. */
  5. #ifndef _POWER_DOMAIN_UCLASS_H
  6. #define _POWER_DOMAIN_UCLASS_H
  7. /* See power-domain.h for background documentation. */
  8. #include <power-domain.h>
  9. struct udevice;
  10. /**
  11. * struct power_domain_ops - The functions that a power domain controller driver
  12. * must implement.
  13. */
  14. struct power_domain_ops {
  15. /**
  16. * of_xlate - Translate a client's device-tree (OF) power domain
  17. * specifier.
  18. *
  19. * The power domain core calls this function as the first step in
  20. * implementing a client's power_domain_get() call.
  21. *
  22. * If this function pointer is set to NULL, the power domain core will
  23. * use a default implementation, which assumes #power-domain-cells =
  24. * <1>, and that the DT cell contains a simple integer power domain ID.
  25. *
  26. * At present, the power domain API solely supports device-tree. If
  27. * this changes, other xxx_xlate() functions may be added to support
  28. * those other mechanisms.
  29. *
  30. * @power_domain: The power domain struct to hold the
  31. * translation result.
  32. * @args: The power domain specifier values from device
  33. * tree.
  34. * @return 0 if OK, or a negative error code.
  35. */
  36. int (*of_xlate)(struct power_domain *power_domain,
  37. struct ofnode_phandle_args *args);
  38. /**
  39. * request - Request a translated power domain.
  40. *
  41. * The power domain core calls this function as the second step in
  42. * implementing a client's power_domain_get() call, following a
  43. * successful xxx_xlate() call.
  44. *
  45. * @power_domain: The power domain to request; this has been
  46. * filled in by a previous xxx_xlate() function
  47. * call.
  48. * @return 0 if OK, or a negative error code.
  49. */
  50. int (*request)(struct power_domain *power_domain);
  51. /**
  52. * free - Free a previously requested power domain.
  53. *
  54. * This is the implementation of the client power_domain_free() API.
  55. *
  56. * @power_domain: The power domain to free.
  57. * @return 0 if OK, or a negative error code.
  58. */
  59. int (*free)(struct power_domain *power_domain);
  60. /**
  61. * on - Power on a power domain.
  62. *
  63. * @power_domain: The power domain to turn on.
  64. * @return 0 if OK, or a negative error code.
  65. */
  66. int (*on)(struct power_domain *power_domain);
  67. /**
  68. * off - Power off a power domain.
  69. *
  70. * @power_domain: The power domain to turn off.
  71. * @return 0 if OK, or a negative error code.
  72. */
  73. int (*off)(struct power_domain *power_domain);
  74. };
  75. #endif