dpll_core.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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 "dpll_nl.h"
  12. #define DPLL_REGISTERED XA_MARK_1
  13. /**
  14. * struct dpll_device - stores DPLL device internal data
  15. * @id: unique id number for device given by dpll subsystem
  16. * @device_idx: id given by dev driver
  17. * @clock_id: unique identifier (clock_id) of a dpll
  18. * @module: module of creator
  19. * @type: type of a dpll
  20. * @pin_refs: stores pins registered within a dpll
  21. * @refcount: refcount
  22. * @registration_list: list of registered ops and priv data of dpll owners
  23. **/
  24. struct dpll_device {
  25. u32 id;
  26. u32 device_idx;
  27. u64 clock_id;
  28. struct module *module;
  29. enum dpll_type type;
  30. struct xarray pin_refs;
  31. refcount_t refcount;
  32. struct list_head registration_list;
  33. };
  34. /**
  35. * struct dpll_pin - structure for a dpll pin
  36. * @id: unique id number for pin given by dpll subsystem
  37. * @pin_idx: index of a pin given by dev driver
  38. * @clock_id: clock_id of creator
  39. * @module: module of creator
  40. * @dpll_refs: hold referencees to dplls pin was registered with
  41. * @parent_refs: hold references to parent pins pin was registered with
  42. * @prop: pin properties copied from the registerer
  43. * @rclk_dev_name: holds name of device when pin can recover clock from it
  44. * @refcount: refcount
  45. * @rcu: rcu_head for kfree_rcu()
  46. **/
  47. struct dpll_pin {
  48. u32 id;
  49. u32 pin_idx;
  50. u64 clock_id;
  51. struct module *module;
  52. struct xarray dpll_refs;
  53. struct xarray parent_refs;
  54. struct dpll_pin_properties prop;
  55. refcount_t refcount;
  56. struct rcu_head rcu;
  57. };
  58. /**
  59. * struct dpll_pin_ref - structure for referencing either dpll or pins
  60. * @dpll: pointer to a dpll
  61. * @pin: pointer to a pin
  62. * @registration_list: list of ops and priv data registered with the ref
  63. * @refcount: refcount
  64. **/
  65. struct dpll_pin_ref {
  66. union {
  67. struct dpll_device *dpll;
  68. struct dpll_pin *pin;
  69. };
  70. struct list_head registration_list;
  71. refcount_t refcount;
  72. };
  73. void *dpll_priv(struct dpll_device *dpll);
  74. void *dpll_pin_on_dpll_priv(struct dpll_device *dpll, struct dpll_pin *pin);
  75. void *dpll_pin_on_pin_priv(struct dpll_pin *parent, struct dpll_pin *pin);
  76. const struct dpll_device_ops *dpll_device_ops(struct dpll_device *dpll);
  77. struct dpll_device *dpll_device_get_by_id(int id);
  78. const struct dpll_pin_ops *dpll_pin_ops(struct dpll_pin_ref *ref);
  79. struct dpll_pin_ref *dpll_xa_ref_dpll_first(struct xarray *xa_refs);
  80. extern struct xarray dpll_device_xa;
  81. extern struct xarray dpll_pin_xa;
  82. extern struct mutex dpll_lock;
  83. #endif