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