/* SPDX-License-Identifier: GPL-2.0 */1/*2* Copyright (c) 2023 Meta Platforms, Inc. and affiliates3* Copyright (c) 2023 Intel and affiliates4*/56#ifndef __DPLL_CORE_H__7#define __DPLL_CORE_H__89#include <linux/dpll.h>10#include <linux/list.h>11#include <linux/refcount.h>12#include "dpll_nl.h"1314#define DPLL_REGISTERED XA_MARK_11516/**17* struct dpll_device - stores DPLL device internal data18* @id: unique id number for device given by dpll subsystem19* @device_idx: id given by dev driver20* @clock_id: unique identifier (clock_id) of a dpll21* @module: module of creator22* @type: type of a dpll23* @pin_refs: stores pins registered within a dpll24* @refcount: refcount25* @registration_list: list of registered ops and priv data of dpll owners26**/27struct dpll_device {28u32 id;29u32 device_idx;30u64 clock_id;31struct module *module;32enum dpll_type type;33struct xarray pin_refs;34refcount_t refcount;35struct list_head registration_list;36};3738/**39* struct dpll_pin - structure for a dpll pin40* @id: unique id number for pin given by dpll subsystem41* @pin_idx: index of a pin given by dev driver42* @clock_id: clock_id of creator43* @module: module of creator44* @dpll_refs: hold referencees to dplls pin was registered with45* @parent_refs: hold references to parent pins pin was registered with46* @ref_sync_pins: hold references to pins for Reference SYNC feature47* @prop: pin properties copied from the registerer48* @refcount: refcount49* @rcu: rcu_head for kfree_rcu()50**/51struct dpll_pin {52u32 id;53u32 pin_idx;54u64 clock_id;55struct module *module;56struct xarray dpll_refs;57struct xarray parent_refs;58struct xarray ref_sync_pins;59struct dpll_pin_properties prop;60refcount_t refcount;61struct rcu_head rcu;62};6364/**65* struct dpll_pin_ref - structure for referencing either dpll or pins66* @dpll: pointer to a dpll67* @pin: pointer to a pin68* @registration_list: list of ops and priv data registered with the ref69* @refcount: refcount70**/71struct dpll_pin_ref {72union {73struct dpll_device *dpll;74struct dpll_pin *pin;75};76struct list_head registration_list;77refcount_t refcount;78};7980void *dpll_priv(struct dpll_device *dpll);81void *dpll_pin_on_dpll_priv(struct dpll_device *dpll, struct dpll_pin *pin);82void *dpll_pin_on_pin_priv(struct dpll_pin *parent, struct dpll_pin *pin);8384const struct dpll_device_ops *dpll_device_ops(struct dpll_device *dpll);85struct dpll_device *dpll_device_get_by_id(int id);86const struct dpll_pin_ops *dpll_pin_ops(struct dpll_pin_ref *ref);87struct dpll_pin_ref *dpll_xa_ref_dpll_first(struct xarray *xa_refs);88extern struct xarray dpll_device_xa;89extern struct xarray dpll_pin_xa;90extern struct mutex dpll_lock;91#endif929394