dpll_core.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (c) 2023 Meta Platforms, Inc. and affiliates
  4. * Copyright (c) 2023 Intel and affiliates
  5. */
  6. #ifndef __DPLL_CORE_H__
  7. #define __DPLL_CORE_H__
  8. #include <linux/dpll.h>
  9. #include <linux/list.h>
  10. #include <linux/refcount.h>
  11. #include <linux/ref_tracker.h>
  12. #include "dpll_nl.h"
  13. #define DPLL_REGISTERED XA_MARK_1
  14. /**
  15. * struct dpll_device - stores DPLL device internal data
  16. * @id: unique id number for device given by dpll subsystem
  17. * @device_idx: id given by dev driver
  18. * @clock_id: unique identifier (clock_id) of a dpll
  19. * @module: module of creator
  20. * @type: type of a dpll
  21. * @pin_refs: stores pins registered within a dpll
  22. * @refcount: refcount
  23. * @refcnt_tracker: ref_tracker directory for debugging reference leaks
  24. * @registration_list: list of registered ops and priv data of dpll owners
  25. **/
  26. struct dpll_device {
  27. u32 id;
  28. u32 device_idx;
  29. u64 clock_id;
  30. struct module *module;
  31. enum dpll_type type;
  32. struct xarray pin_refs;
  33. refcount_t refcount;
  34. struct ref_tracker_dir refcnt_tracker;
  35. struct list_head registration_list;
  36. };
  37. /**
  38. * struct dpll_pin - structure for a dpll pin
  39. * @id: unique id number for pin given by dpll subsystem
  40. * @pin_idx: index of a pin given by dev driver
  41. * @clock_id: clock_id of creator
  42. * @module: module of creator
  43. * @fwnode: optional reference to firmware node
  44. * @dpll_refs: hold referencees to dplls pin was registered with
  45. * @parent_refs: hold references to parent pins pin was registered with
  46. * @ref_sync_pins: hold references to pins for Reference SYNC feature
  47. * @prop: pin properties copied from the registerer
  48. * @refcount: refcount
  49. * @refcnt_tracker: ref_tracker directory for debugging reference leaks
  50. * @rcu: rcu_head for kfree_rcu()
  51. **/
  52. struct dpll_pin {
  53. u32 id;
  54. u32 pin_idx;
  55. u64 clock_id;
  56. struct module *module;
  57. struct fwnode_handle *fwnode;
  58. struct xarray dpll_refs;
  59. struct xarray parent_refs;
  60. struct xarray ref_sync_pins;
  61. struct dpll_pin_properties prop;
  62. refcount_t refcount;
  63. struct ref_tracker_dir refcnt_tracker;
  64. struct rcu_head rcu;
  65. };
  66. /**
  67. * struct dpll_pin_ref - structure for referencing either dpll or pins
  68. * @dpll: pointer to a dpll
  69. * @pin: pointer to a pin
  70. * @registration_list: list of ops and priv data registered with the ref
  71. * @refcount: refcount
  72. **/
  73. struct dpll_pin_ref {
  74. union {
  75. struct dpll_device *dpll;
  76. struct dpll_pin *pin;
  77. };
  78. struct list_head registration_list;
  79. refcount_t refcount;
  80. };
  81. void *dpll_priv(struct dpll_device *dpll);
  82. void *dpll_pin_on_dpll_priv(struct dpll_device *dpll, struct dpll_pin *pin);
  83. void *dpll_pin_on_pin_priv(struct dpll_pin *parent, struct dpll_pin *pin);
  84. const struct dpll_device_ops *dpll_device_ops(struct dpll_device *dpll);
  85. struct dpll_device *dpll_device_get_by_id(int id);
  86. const struct dpll_pin_ops *dpll_pin_ops(struct dpll_pin_ref *ref);
  87. struct dpll_pin_ref *dpll_xa_ref_dpll_first(struct xarray *xa_refs);
  88. extern struct xarray dpll_device_xa;
  89. extern struct xarray dpll_pin_xa;
  90. extern struct mutex dpll_lock;
  91. void dpll_device_notify(struct dpll_device *dpll, unsigned long action);
  92. void dpll_pin_notify(struct dpll_pin *pin, unsigned long action);
  93. #endif