xref: /OK3568_Linux_fs/kernel/drivers/video/rockchip/rve/include/rve_debugger.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Copyright (C) Rockchip Electronics Co., Ltd.
4  *
5  * Author:
6  *	Cerf Yu <cerf.yu@rock-chips.com>
7  *	Huang Lee <Putin.li@rock-chips.com>
8  */
9 
10 #ifndef _RVE_DEBUGGER_H_
11 #define _RVE_DEBUGGER_H_
12 
13 #ifdef CONFIG_ROCKCHIP_RVE_DEBUGGER
14 
15 extern int RVE_DEBUG_MONITOR;
16 extern int RVE_DEBUG_REG;
17 extern int RVE_DEBUG_MSG;
18 extern int RVE_DEBUG_TIME;
19 extern int RVE_DEBUG_CHECK_MODE;
20 extern int RVE_DEBUG_NONUSE;
21 extern int RVE_DEBUG_INT_FLAG;
22 
23 #define DEBUGGER_EN(name) (unlikely(RVE_DEBUG_##name ? true : false))
24 
25 /*
26  * struct rve_debugger - RVE debugger information
27  *
28  * This structure represents a debugger to be created by the rve driver
29  * or core.
30  */
31 struct rve_debugger {
32 #ifdef CONFIG_ROCKCHIP_RVE_DEBUG_FS
33 	/* Directory of debugfs file */
34 	struct dentry *debugfs_dir;
35 	struct list_head debugfs_entry_list;
36 	struct mutex debugfs_lock;
37 #endif
38 
39 #ifdef CONFIG_ROCKCHIP_RVE_PROC_FS
40 	/* Directory of procfs file */
41 	struct proc_dir_entry *procfs_dir;
42 	struct list_head procfs_entry_list;
43 	struct mutex procfs_lock;
44 #endif
45 };
46 
47 /*
48  * struct rve_debugger_list - debugfs/procfs info list entry
49  *
50  * This structure represents a debugfs/procfs file to be created by the rve
51  * driver or core.
52  */
53 struct rve_debugger_list {
54 	/* File name */
55 	const char *name;
56 	/*
57 	 * Show callback. &seq_file->private will be set to the &struct
58 	 * rve_debugger_node corresponding to the instance of this info
59 	 * on a given &struct rve_debugger.
60 	 */
61 	int (*show)(struct seq_file *seq, void *data);
62 	/*
63 	 * Write callback. &seq_file->private will be set to the &struct
64 	 * rve_debugger_node corresponding to the instance of this info
65 	 * on a given &struct rve_debugger.
66 	 */
67 	ssize_t (*write)(struct file *file, const char __user *ubuf,
68 		size_t len, loff_t *offp);
69 	/* Procfs/Debugfs private data. */
70 	void *data;
71 };
72 
73 /*
74  * struct rve_debugger_node - Nodes for debugfs/procfs
75  *
76  * This structure represents each instance of procfs/debugfs created from the
77  * template.
78  */
79 struct rve_debugger_node {
80 	struct rve_debugger *debugger;
81 
82 	/* template for this node. */
83 	const struct rve_debugger_list *info_ent;
84 
85 	/* Each Procfs/Debugfs file. */
86 #ifdef CONFIG_ROCKCHIP_RVE_DEBUG_FS
87 	struct dentry *dent;
88 #endif
89 
90 #ifdef CONFIG_ROCKCHIP_RVE_PROC_FS
91 	struct proc_dir_entry *pent;
92 #endif
93 
94 	struct list_head list;
95 };
96 
97 #ifdef CONFIG_ROCKCHIP_RVE_DEBUG_FS
98 int rve_debugfs_init(void);
99 int rve_debugfs_remove(void);
100 #else
rve_debugfs_remove(void)101 static inline int rve_debugfs_remove(void)
102 {
103 	return 0;
104 }
rve_debugfs_init(void)105 static inline int rve_debugfs_init(void)
106 {
107 	return 0;
108 }
109 #endif /* #ifdef CONFIG_ROCKCHIP_RVE_DEBUG_FS */
110 
111 #ifdef CONFIG_ROCKCHIP_RVE_PROC_FS
112 int rve_procfs_remove(void);
113 int rve_procfs_init(void);
114 #else
rve_procfs_remove(void)115 static inline int rve_procfs_remove(void)
116 {
117 	return 0;
118 }
rve_procfs_init(void)119 static inline int rve_procfs_init(void)
120 {
121 	return 0;
122 }
123 #endif /* #ifdef CONFIG_ROCKCHIP_RVE_PROC_FS */
124 
125 #else
126 
127 #define DEBUGGER_EN(name) (unlikely(false))
128 
129 #endif /* #ifdef CONFIG_ROCKCHIP_RVE_DEBUGGER */
130 
131 #endif /* #ifndef _RVE_DEBUGGER_H_ */
132 
133