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