dtpm.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (C) 2020 Linaro Ltd
  4. *
  5. * Author: Daniel Lezcano <[email protected]>
  6. */
  7. #ifndef ___DTPM_H__
  8. #define ___DTPM_H__
  9. #include <linux/powercap.h>
  10. #define MAX_DTPM_DESCR 8
  11. #define MAX_DTPM_CONSTRAINTS 1
  12. struct dtpm {
  13. struct powercap_zone zone;
  14. struct dtpm *parent;
  15. struct list_head sibling;
  16. struct list_head children;
  17. struct dtpm_ops *ops;
  18. unsigned long flags;
  19. u64 power_limit;
  20. u64 power_max;
  21. u64 power_min;
  22. int weight;
  23. };
  24. struct dtpm_ops {
  25. u64 (*set_power_uw)(struct dtpm *, u64);
  26. u64 (*get_power_uw)(struct dtpm *);
  27. int (*update_power_uw)(struct dtpm *);
  28. void (*release)(struct dtpm *);
  29. };
  30. struct device_node;
  31. struct dtpm_subsys_ops {
  32. const char *name;
  33. int (*init)(void);
  34. void (*exit)(void);
  35. int (*setup)(struct dtpm *, struct device_node *);
  36. };
  37. enum DTPM_NODE_TYPE {
  38. DTPM_NODE_VIRTUAL = 0,
  39. DTPM_NODE_DT,
  40. };
  41. struct dtpm_node {
  42. enum DTPM_NODE_TYPE type;
  43. const char *name;
  44. struct dtpm_node *parent;
  45. };
  46. static inline struct dtpm *to_dtpm(struct powercap_zone *zone)
  47. {
  48. return container_of(zone, struct dtpm, zone);
  49. }
  50. int dtpm_update_power(struct dtpm *dtpm);
  51. int dtpm_release_zone(struct powercap_zone *pcz);
  52. void dtpm_init(struct dtpm *dtpm, struct dtpm_ops *ops);
  53. void dtpm_unregister(struct dtpm *dtpm);
  54. int dtpm_register(const char *name, struct dtpm *dtpm, struct dtpm *parent);
  55. int dtpm_create_hierarchy(struct of_device_id *dtpm_match_table);
  56. void dtpm_destroy_hierarchy(void);
  57. #endif