1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
2 /* Copyright(c) 2019-2020 Realtek Corporation
3 */
4
5 #ifndef __RTW89_DEBUG_H__
6 #define __RTW89_DEBUG_H__
7
8 #include "core.h"
9
10 enum rtw89_debug_mask {
11 RTW89_DBG_TXRX = BIT(0),
12 RTW89_DBG_RFK = BIT(1),
13 RTW89_DBG_RFK_TRACK = BIT(2),
14 RTW89_DBG_CFO = BIT(3),
15 RTW89_DBG_TSSI = BIT(4),
16 RTW89_DBG_TXPWR = BIT(5),
17 RTW89_DBG_HCI = BIT(6),
18 RTW89_DBG_RA = BIT(7),
19 RTW89_DBG_REGD = BIT(8),
20 RTW89_DBG_PHY_TRACK = BIT(9),
21 RTW89_DBG_DIG = BIT(10),
22 RTW89_DBG_SER = BIT(11),
23 RTW89_DBG_FW = BIT(12),
24 RTW89_DBG_BTC = BIT(13),
25 RTW89_DBG_BF = BIT(14),
26 RTW89_DBG_HW_SCAN = BIT(15),
27 RTW89_DBG_SAR = BIT(16),
28 RTW89_DBG_STATE = BIT(17),
29
30 RTW89_DBG_UNEXP = BIT(31),
31 };
32
33 enum rtw89_debug_mac_reg_sel {
34 RTW89_DBG_SEL_MAC_00,
35 RTW89_DBG_SEL_MAC_30,
36 RTW89_DBG_SEL_MAC_40,
37 RTW89_DBG_SEL_MAC_80,
38 RTW89_DBG_SEL_MAC_C0,
39 RTW89_DBG_SEL_MAC_E0,
40 RTW89_DBG_SEL_BB,
41 RTW89_DBG_SEL_IQK,
42 RTW89_DBG_SEL_RFC,
43 };
44
45 #ifdef CONFIG_RTW89_DEBUGFS
46 void rtw89_debugfs_init(struct rtw89_dev *rtwdev);
47 #else
rtw89_debugfs_init(struct rtw89_dev * rtwdev)48 static inline void rtw89_debugfs_init(struct rtw89_dev *rtwdev) {}
49 #endif
50
51 #define rtw89_info(rtwdev, a...) dev_info((rtwdev)->dev, ##a)
52 #define rtw89_warn(rtwdev, a...) dev_warn((rtwdev)->dev, ##a)
53 #define rtw89_err(rtwdev, a...) dev_err((rtwdev)->dev, ##a)
54
55 #ifdef CONFIG_RTW89_DEBUGMSG
56 extern unsigned int rtw89_debug_mask;
57 #define rtw89_debug(rtwdev, a...) __rtw89_debug(rtwdev, ##a)
58
59 __printf(3, 4)
60 void __rtw89_debug(struct rtw89_dev *rtwdev,
61 enum rtw89_debug_mask mask,
62 const char *fmt, ...);
rtw89_hex_dump(struct rtw89_dev * rtwdev,enum rtw89_debug_mask mask,const char * prefix_str,const void * buf,size_t len)63 static inline void rtw89_hex_dump(struct rtw89_dev *rtwdev,
64 enum rtw89_debug_mask mask,
65 const char *prefix_str,
66 const void *buf, size_t len)
67 {
68 if (!(rtw89_debug_mask & mask))
69 return;
70
71 print_hex_dump_bytes(prefix_str, DUMP_PREFIX_OFFSET, buf, len);
72 }
73 #else
rtw89_debug(struct rtw89_dev * rtwdev,enum rtw89_debug_mask mask,const char * fmt,...)74 static inline void rtw89_debug(struct rtw89_dev *rtwdev,
75 enum rtw89_debug_mask mask,
76 const char *fmt, ...) {}
rtw89_hex_dump(struct rtw89_dev * rtwdev,enum rtw89_debug_mask mask,const char * prefix_str,const void * buf,size_t len)77 static inline void rtw89_hex_dump(struct rtw89_dev *rtwdev,
78 enum rtw89_debug_mask mask,
79 const char *prefix_str,
80 const void *buf, size_t len) {}
81 #endif
82
83 #endif
84