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 **/ 28 struct 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 * @prop: pin properties copied from the registerer 48 * @rclk_dev_name: holds name of device when pin can recover clock from it 49 * @refcount: refcount 50 **/ 51 struct dpll_pin { 52 u32 id; 53 u32 pin_idx; 54 u64 clock_id; 55 struct module *module; 56 struct xarray dpll_refs; 57 struct xarray parent_refs; 58 struct dpll_pin_properties prop; 59 refcount_t refcount; 60 }; 61 62 /** 63 * struct dpll_pin_ref - structure for referencing either dpll or pins 64 * @dpll: pointer to a dpll 65 * @pin: pointer to a pin 66 * @registration_list: list of ops and priv data registered with the ref 67 * @refcount: refcount 68 **/ 69 struct dpll_pin_ref { 70 union { 71 struct dpll_device *dpll; 72 struct dpll_pin *pin; 73 }; 74 struct list_head registration_list; 75 refcount_t refcount; 76 }; 77 78 void *dpll_priv(struct dpll_device *dpll); 79 void *dpll_pin_on_dpll_priv(struct dpll_device *dpll, struct dpll_pin *pin); 80 void *dpll_pin_on_pin_priv(struct dpll_pin *parent, struct dpll_pin *pin); 81 82 const struct dpll_device_ops *dpll_device_ops(struct dpll_device *dpll); 83 struct dpll_device *dpll_device_get_by_id(int id); 84 const struct dpll_pin_ops *dpll_pin_ops(struct dpll_pin_ref *ref); 85 struct dpll_pin_ref *dpll_xa_ref_dpll_first(struct xarray *xa_refs); 86 extern struct xarray dpll_device_xa; 87 extern struct xarray dpll_pin_xa; 88 extern struct mutex dpll_lock; 89 #endif 90