xref: /linux-6.15/include/linux/pse-pd/pse.h (revision 3114b075)
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 // Copyright (c) 2022 Pengutronix, Oleksij Rempel <[email protected]>
4  */
5 #ifndef _LINUX_PSE_CONTROLLER_H
6 #define _LINUX_PSE_CONTROLLER_H
7 
8 #include <linux/ethtool.h>
9 #include <linux/list.h>
10 #include <uapi/linux/ethtool.h>
11 
12 struct module;
13 struct device_node;
14 struct of_phandle_args;
15 struct pse_control;
16 
17 /**
18  * struct pse_controller_dev - PSE controller entity that might
19  *                             provide multiple PSE controls
20  * @ops: a pointer to device specific struct pse_controller_ops
21  * @owner: kernel module of the PSE controller driver
22  * @list: internal list of PSE controller devices
23  * @pse_control_head: head of internal list of requested PSE controls
24  * @dev: corresponding driver model device struct
25  * @of_pse_n_cells: number of cells in PSE line specifiers
26  * @of_xlate: translation function to translate from specifier as found in the
27  *            device tree to id as given to the PSE control ops
28  * @nr_lines: number of PSE controls in this controller device
29  * @lock: Mutex for serialization access to the PSE controller
30  */
31 struct pse_controller_dev {
32 	const struct pse_controller_ops *ops;
33 	struct module *owner;
34 	struct list_head list;
35 	struct list_head pse_control_head;
36 	struct device *dev;
37 	int of_pse_n_cells;
38 	int (*of_xlate)(struct pse_controller_dev *pcdev,
39 			const struct of_phandle_args *pse_spec);
40 	unsigned int nr_lines;
41 	struct mutex lock;
42 };
43 
44 #if IS_ENABLED(CONFIG_PSE_CONTROLLER)
45 int pse_controller_register(struct pse_controller_dev *pcdev);
46 void pse_controller_unregister(struct pse_controller_dev *pcdev);
47 struct device;
48 int devm_pse_controller_register(struct device *dev,
49 				 struct pse_controller_dev *pcdev);
50 
51 struct pse_control *of_pse_control_get(struct device_node *node);
52 void pse_control_put(struct pse_control *psec);
53 
54 #else
55 
56 static inline struct pse_control *of_pse_control_get(struct device_node *node)
57 {
58 	return ERR_PTR(-ENOENT);
59 }
60 
61 static inline void pse_control_put(struct pse_control *psec)
62 {
63 }
64 
65 #endif
66 
67 #endif
68