Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
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
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 **/
30struct 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 * @fwnode: optional reference to firmware node
49 * @dpll_refs: hold referencees to dplls pin was registered with
50 * @parent_refs: hold references to parent pins pin was registered with
51 * @ref_sync_pins: hold references to pins for Reference SYNC feature
52 * @prop: pin properties copied from the registerer
53 * @refcount: refcount
54 * @refcnt_tracker: ref_tracker directory for debugging reference leaks
55 * @rcu: rcu_head for kfree_rcu()
56 **/
57struct dpll_pin {
58 u32 id;
59 u32 pin_idx;
60 u64 clock_id;
61 struct module *module;
62 struct fwnode_handle *fwnode;
63 struct xarray dpll_refs;
64 struct xarray parent_refs;
65 struct xarray ref_sync_pins;
66 struct dpll_pin_properties prop;
67 refcount_t refcount;
68 struct ref_tracker_dir refcnt_tracker;
69 struct rcu_head rcu;
70};
71
72/**
73 * struct dpll_pin_ref - structure for referencing either dpll or pins
74 * @dpll: pointer to a dpll
75 * @pin: pointer to a pin
76 * @registration_list: list of ops and priv data registered with the ref
77 * @refcount: refcount
78 **/
79struct dpll_pin_ref {
80 union {
81 struct dpll_device *dpll;
82 struct dpll_pin *pin;
83 };
84 struct list_head registration_list;
85 refcount_t refcount;
86};
87
88void *dpll_priv(struct dpll_device *dpll);
89void *dpll_pin_on_dpll_priv(struct dpll_device *dpll, struct dpll_pin *pin);
90void *dpll_pin_on_pin_priv(struct dpll_pin *parent, struct dpll_pin *pin);
91
92const struct dpll_device_ops *dpll_device_ops(struct dpll_device *dpll);
93struct dpll_device *dpll_device_get_by_id(int id);
94const struct dpll_pin_ops *dpll_pin_ops(struct dpll_pin_ref *ref);
95struct dpll_pin_ref *dpll_xa_ref_dpll_first(struct xarray *xa_refs);
96extern struct xarray dpll_device_xa;
97extern struct xarray dpll_pin_xa;
98extern struct mutex dpll_lock;
99
100void dpll_device_notify(struct dpll_device *dpll, unsigned long action);
101void dpll_pin_notify(struct dpll_pin *pin, unsigned long action);
102
103#endif