at master 2.7 kB view raw
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 "dpll_nl.h" 14 15#define DPLL_REGISTERED XA_MARK_1 16 17/** 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 25 * @refcount: refcount 26 * @registration_list: list of registered ops and priv data of dpll owners 27 **/ 28struct dpll_device { 29 u32 id; 30 u32 device_idx; 31 u64 clock_id; 32 struct module *module; 33 enum dpll_type type; 34 struct xarray pin_refs; 35 refcount_t refcount; 36 struct list_head registration_list; 37}; 38 39/** 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 * @ref_sync_pins: hold references to pins for Reference SYNC feature 48 * @prop: pin properties copied from the registerer 49 * @refcount: refcount 50 * @rcu: rcu_head for kfree_rcu() 51 **/ 52struct dpll_pin { 53 u32 id; 54 u32 pin_idx; 55 u64 clock_id; 56 struct module *module; 57 struct xarray dpll_refs; 58 struct xarray parent_refs; 59 struct xarray ref_sync_pins; 60 struct dpll_pin_properties prop; 61 refcount_t refcount; 62 struct rcu_head rcu; 63}; 64 65/** 66 * struct dpll_pin_ref - structure for referencing either dpll or pins 67 * @dpll: pointer to a dpll 68 * @pin: pointer to a pin 69 * @registration_list: list of ops and priv data registered with the ref 70 * @refcount: refcount 71 **/ 72struct dpll_pin_ref { 73 union { 74 struct dpll_device *dpll; 75 struct dpll_pin *pin; 76 }; 77 struct list_head registration_list; 78 refcount_t refcount; 79}; 80 81void *dpll_priv(struct dpll_device *dpll); 82void *dpll_pin_on_dpll_priv(struct dpll_device *dpll, struct dpll_pin *pin); 83void *dpll_pin_on_pin_priv(struct dpll_pin *parent, struct dpll_pin *pin); 84 85const struct dpll_device_ops *dpll_device_ops(struct dpll_device *dpll); 86struct dpll_device *dpll_device_get_by_id(int id); 87const struct dpll_pin_ops *dpll_pin_ops(struct dpll_pin_ref *ref); 88struct dpll_pin_ref *dpll_xa_ref_dpll_first(struct xarray *xa_refs); 89extern struct xarray dpll_device_xa; 90extern struct xarray dpll_pin_xa; 91extern struct mutex dpll_lock; 92#endif