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 extern unsigned int mpp_dev_debug; 60 61 #define mpp_debug_unlikely(type) \ 62 (unlikely(mpp_dev_debug & (type))) 63 64 #define mpp_debug_func(type, fmt, args...) \ 65 do { \ 66 if (unlikely(mpp_dev_debug & (type))) { \ 67 pr_info("%s:%d: " fmt, \ 68 __func__, __LINE__, ##args); \ 69 } \ 70 } while (0) 71 #define mpp_debug(type, fmt, args...) \ 72 do { \ 73 if (unlikely(mpp_dev_debug & (type))) { \ 74 pr_info(fmt, ##args); \ 75 } \ 76 } while (0) 77 78 #define mpp_debug_enter() \ 79 do { \ 80 if (unlikely(mpp_dev_debug & DEBUG_FUNCTION)) { \ 81 pr_info("%s:%d: enter\n", \ 82 __func__, __LINE__); \ 83 } \ 84 } while (0) 85 86 #define mpp_debug_leave() \ 87 do { \ 88 if (unlikely(mpp_dev_debug & DEBUG_FUNCTION)) { \ 89 pr_info("%s:%d: leave\n", \ 90 __func__, __LINE__); \ 91 } \ 92 } while (0) 93 94 #define mpp_err(fmt, args...) \ 95 pr_err("%s:%d: " fmt, __func__, __LINE__, ##args) 96 97 #define mpp_dbg_link_flow(fmt, args...) \ 98 do { \ 99 if (unlikely(mpp_dev_debug & DEBUG_LINK_TABLE)) { \ 100 pr_info("%s:%d: " fmt, \ 101 __func__, __LINE__, ##args); \ 102 } \ 103 } while (0) 104 105 #define mpp_dbg_session(fmt, args...) \ 106 do { \ 107 if (unlikely(mpp_dev_debug & DEBUG_SESSION)) { \ 108 pr_info(fmt, ##args); \ 109 } \ 110 } while (0) 111 112 #define mpp_dbg_ccu(fmt, args...) \ 113 do { \ 114 if (unlikely(mpp_dev_debug & DEBUG_CCU)) { \ 115 pr_info("%s:%d: " fmt, \ 116 __func__, __LINE__, ##args); \ 117 } \ 118 } while (0) 119 120 #define mpp_dbg_core(fmt, args...) \ 121 do { \ 122 if (unlikely(mpp_dev_debug & DEBUG_CORE)) { \ 123 pr_info(fmt, ##args); \ 124 } \ 125 } while (0) 126 127 #endif 128