• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: (GPL-2.0+ OR MIT) */
2 /*
3  * Copyright (c) 2019 Fuzhou Rockchip Electronics Co., Ltd
4  *
5  * author:
6  *	Alpha Lin, alpha.lin@rock-chips.com
7  *	Randy Li, randy.li@rock-chips.com
8  *	Ding Wei, leo.ding@rock-chips.com
9  *
10  */
11 #ifndef __ROCKCHIP_MPP_DEBUG_H__
12 #define __ROCKCHIP_MPP_DEBUG_H__
13 
14 #include <linux/types.h>
15 
16 /*
17  * debug flag usage:
18  * +------+-------------------+
19  * | 8bit |      24bit        |
20  * +------+-------------------+
21  *  0~23 bit is for different information type
22  * 24~31 bit is for information print format
23  */
24 
25 #define DEBUG_POWER				0x00000001
26 #define DEBUG_CLOCK				0x00000002
27 #define DEBUG_IRQ_STATUS			0x00000004
28 #define DEBUG_IOMMU				0x00000008
29 #define DEBUG_IOCTL				0x00000010
30 #define DEBUG_FUNCTION				0x00000020
31 #define DEBUG_REGISTER				0x00000040
32 #define DEBUG_EXTRA_INFO			0x00000080
33 #define DEBUG_TIMING				0x00000100
34 #define DEBUG_TASK_INFO				0x00000200
35 #define DEBUG_DUMP_ERR_REG			0x00000400
36 #define DEBUG_LINK_TABLE			0x00000800
37 
38 #define DEBUG_SET_REG				0x00001000
39 #define DEBUG_GET_REG				0x00002000
40 #define DEBUG_PPS_FILL				0x00004000
41 #define DEBUG_IRQ_CHECK				0x00008000
42 #define DEBUG_CACHE_32B				0x00010000
43 
44 #define DEBUG_RESET				0x00020000
45 #define DEBUG_SET_REG_L2			0x00040000
46 #define DEBUG_GET_REG_L2			0x00080000
47 #define DEBUG_GET_PERF_VAL			0x00100000
48 #define DEBUG_SRAM_INFO				0x00200000
49 
50 #define DEBUG_SESSION				0x00400000
51 #define DEBUG_DEVICE				0x00800000
52 
53 #define DEBUG_CCU				0x01000000
54 #define DEBUG_CORE				0x02000000
55 
56 #define PRINT_FUNCTION				0x80000000
57 #define PRINT_LINE				0x40000000
58 
59 /* reuse old debug bit flag */
60 #define DEBUG_PART_TIMING			0x00000080
61 #define DEBUG_SLICE				0x00000002
62 
63 extern unsigned int mpp_dev_debug;
64 
65 #define mpp_debug_unlikely(type)				\
66 		(unlikely(mpp_dev_debug & (type)))
67 
68 #define mpp_debug_func(type, fmt, args...)			\
69 	do {							\
70 		if (unlikely(mpp_dev_debug & (type))) {		\
71 			pr_info("%s:%d: " fmt,			\
72 				 __func__, __LINE__, ##args);	\
73 		}						\
74 	} while (0)
75 #define mpp_debug(type, fmt, args...)				\
76 	do {							\
77 		if (unlikely(mpp_dev_debug & (type))) {		\
78 			pr_info(fmt, ##args);			\
79 		}						\
80 	} while (0)
81 
82 #define mpp_debug_enter()					\
83 	do {							\
84 		if (unlikely(mpp_dev_debug & DEBUG_FUNCTION)) {	\
85 			pr_info("%s:%d: enter\n",		\
86 				 __func__, __LINE__);		\
87 		}						\
88 	} while (0)
89 
90 #define mpp_debug_leave()					\
91 	do {							\
92 		if (unlikely(mpp_dev_debug & DEBUG_FUNCTION)) {	\
93 			pr_info("%s:%d: leave\n",		\
94 				 __func__, __LINE__);		\
95 		}						\
96 	} while (0)
97 
98 #define mpp_err(fmt, args...)					\
99 		pr_err("%s:%d: " fmt, __func__, __LINE__, ##args)
100 
101 #define mpp_dbg_link_flow(fmt, args...)				\
102 	do {							\
103 		if (unlikely(mpp_dev_debug & DEBUG_LINK_TABLE)) {		\
104 			pr_info("%s:%d: " fmt,			\
105 				 __func__, __LINE__, ##args);	\
106 		}						\
107 	} while (0)
108 
109 #define mpp_dbg_session(fmt, args...)				\
110 	do {							\
111 		if (unlikely(mpp_dev_debug & DEBUG_SESSION)) {	\
112 			pr_info(fmt, ##args);			\
113 		}						\
114 	} while (0)
115 
116 #define mpp_dbg_ccu(fmt, args...)				\
117 	do {							\
118 		if (unlikely(mpp_dev_debug & DEBUG_CCU)) {	\
119 			pr_info("%s:%d: " fmt,			\
120 				 __func__, __LINE__, ##args);	\
121 		}						\
122 	} while (0)
123 
124 #define mpp_dbg_core(fmt, args...)				\
125 	do {							\
126 		if (unlikely(mpp_dev_debug & DEBUG_CORE)) {	\
127 			pr_info(fmt, ##args);			\
128 		}						\
129 	} while (0)
130 
131 #define mpp_dbg_slice(fmt, args...)				\
132 	do {							\
133 		if (unlikely(mpp_dev_debug & DEBUG_SLICE)) {	\
134 			pr_info(fmt, ##args);			\
135 		}						\
136 	} while (0)
137 
138 #endif
139