mmrm_debug.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef __MMRM_DEBUG__
  6. #define __MMRM_DEBUG__
  7. #include <linux/debugfs.h>
  8. #include <linux/printk.h>
  9. #ifndef MMRM_DBG_LABEL
  10. #define MMRM_DBG_LABEL "msm_mmrm"
  11. #endif
  12. #define MMRM_DBG_TAG MMRM_DBG_LABEL ": %4s: "
  13. /* To enable messages OR these values and
  14. * echo the result to debugfs file.
  15. */
  16. enum mmrm_msg_prio {
  17. MMRM_ERR = 0x000001,
  18. MMRM_HIGH = 0x000002,
  19. MMRM_LOW = 0x000004,
  20. MMRM_WARN = 0x000008,
  21. MMRM_POWER = 0x000010,
  22. MMRM_PRINTK = 0x010000,
  23. MMRM_FTRACE = 0x020000,
  24. };
  25. extern int msm_mmrm_debug;
  26. extern u8 msm_mmrm_allow_multiple_register;
  27. #define dprintk(__level, __fmt, ...) \
  28. do { \
  29. if (msm_mmrm_debug & __level) { \
  30. if (msm_mmrm_debug & MMRM_PRINTK) { \
  31. pr_info(MMRM_DBG_TAG __fmt, \
  32. get_debug_level_str(__level), \
  33. ##__VA_ARGS__); \
  34. } \
  35. } \
  36. } while (0)
  37. #define d_mpr_e(__fmt, ...) dprintk(MMRM_ERR, __fmt, ##__VA_ARGS__)
  38. #define d_mpr_h(__fmt, ...) dprintk(MMRM_HIGH, __fmt, ##__VA_ARGS__)
  39. #define d_mpr_l(__fmt, ...) dprintk(MMRM_LOW, __fmt, ##__VA_ARGS__)
  40. #define d_mpr_w(__fmt, ...) dprintk(MMRM_WARN, __fmt, ##__VA_ARGS__)
  41. #define d_mpr_p(__fmt, ...) dprintk(MMRM_POWER, __fmt, ##__VA_ARGS__)
  42. static inline char *get_debug_level_str(int level)
  43. {
  44. switch (level) {
  45. case MMRM_ERR:
  46. return "err ";
  47. case MMRM_HIGH:
  48. return "high";
  49. case MMRM_LOW:
  50. return "low ";
  51. case MMRM_WARN:
  52. return "warn";
  53. case MMRM_POWER:
  54. return "power";
  55. default:
  56. return "????";
  57. }
  58. }
  59. struct dentry *msm_mmrm_debugfs_init(void);
  60. void msm_mmrm_debugfs_deinit(struct dentry *dir);
  61. #endif