debug.h 2.1 KB

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