1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (c) 2023 Meta Platforms, Inc. and affiliates
4 * Copyright (c) 2023 Intel and affiliates
7 #ifndef __DPLL_CORE_H__
8 #define __DPLL_CORE_H__
10 #include <linux/dpll.h>
11 #include <linux/list.h>
12 #include <linux/refcount.h>
15 #define DPLL_REGISTERED XA_MARK_1
18 * struct dpll_device - stores DPLL device internal data
19 * @id: unique id number for device given by dpll subsystem
20 * @device_idx: id given by dev driver
21 * @clock_id: unique identifier (clock_id) of a dpll
22 * @module: module of creator
23 * @type: type of a dpll
24 * @pin_refs: stores pins registered within a dpll
26 * @registration_list: list of registered ops and priv data of dpll owners
32 struct module
*module
;
34 struct xarray pin_refs
;
36 struct list_head registration_list
;
40 * struct dpll_pin - structure for a dpll pin
41 * @id: unique id number for pin given by dpll subsystem
42 * @pin_idx: index of a pin given by dev driver
43 * @clock_id: clock_id of creator
44 * @module: module of creator
45 * @dpll_refs: hold referencees to dplls pin was registered with
46 * @parent_refs: hold references to parent pins pin was registered with
47 * @prop: pin properties copied from the registerer
48 * @rclk_dev_name: holds name of device when pin can recover clock from it
50 * @rcu: rcu_head for kfree_rcu()
56 struct module
*module
;
57 struct xarray dpll_refs
;
58 struct xarray parent_refs
;
59 struct dpll_pin_properties prop
;
65 * struct dpll_pin_ref - structure for referencing either dpll or pins
66 * @dpll: pointer to a dpll
67 * @pin: pointer to a pin
68 * @registration_list: list of ops and priv data registered with the ref
73 struct dpll_device
*dpll
;
76 struct list_head registration_list
;
80 void *dpll_priv(struct dpll_device
*dpll
);
81 void *dpll_pin_on_dpll_priv(struct dpll_device
*dpll
, struct dpll_pin
*pin
);
82 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
;