applespi_trace.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * MacBook (Pro) SPI keyboard and touchpad driver
  4. *
  5. * Copyright (c) 2015-2019 Federico Lorenzi
  6. * Copyright (c) 2017-2019 Ronald Tschalär
  7. */
  8. #undef TRACE_SYSTEM
  9. #define TRACE_SYSTEM applespi
  10. #if !defined(_APPLESPI_TRACE_H_) || defined(TRACE_HEADER_MULTI_READ)
  11. #define _APPLESPI_TRACE_H_
  12. #include <linux/types.h>
  13. #include <linux/tracepoint.h>
  14. #include "applespi.h"
  15. DECLARE_EVENT_CLASS(dump_message_template,
  16. TP_PROTO(enum applespi_evt_type evt_type,
  17. enum applespi_pkt_type pkt_type,
  18. u8 *buf,
  19. size_t len),
  20. TP_ARGS(evt_type, pkt_type, buf, len),
  21. TP_STRUCT__entry(
  22. __field(enum applespi_evt_type, evt_type)
  23. __field(enum applespi_pkt_type, pkt_type)
  24. __field(size_t, len)
  25. __dynamic_array(u8, buf, len)
  26. ),
  27. TP_fast_assign(
  28. __entry->evt_type = evt_type;
  29. __entry->pkt_type = pkt_type;
  30. __entry->len = len;
  31. memcpy(__get_dynamic_array(buf), buf, len);
  32. ),
  33. TP_printk("%-6s: %s",
  34. __print_symbolic(__entry->pkt_type,
  35. { PT_READ, "read" },
  36. { PT_WRITE, "write" },
  37. { PT_STATUS, "status" }
  38. ),
  39. __print_hex(__get_dynamic_array(buf), __entry->len))
  40. );
  41. #define DEFINE_DUMP_MESSAGE_EVENT(name) \
  42. DEFINE_EVENT(dump_message_template, name, \
  43. TP_PROTO(enum applespi_evt_type evt_type, \
  44. enum applespi_pkt_type pkt_type, \
  45. u8 *buf, \
  46. size_t len), \
  47. TP_ARGS(evt_type, pkt_type, buf, len) \
  48. )
  49. DEFINE_DUMP_MESSAGE_EVENT(applespi_tp_ini_cmd);
  50. DEFINE_DUMP_MESSAGE_EVENT(applespi_backlight_cmd);
  51. DEFINE_DUMP_MESSAGE_EVENT(applespi_caps_lock_cmd);
  52. DEFINE_DUMP_MESSAGE_EVENT(applespi_keyboard_data);
  53. DEFINE_DUMP_MESSAGE_EVENT(applespi_touchpad_data);
  54. DEFINE_DUMP_MESSAGE_EVENT(applespi_unknown_data);
  55. DEFINE_DUMP_MESSAGE_EVENT(applespi_bad_crc);
  56. TRACE_EVENT(applespi_irq_received,
  57. TP_PROTO(enum applespi_evt_type evt_type,
  58. enum applespi_pkt_type pkt_type),
  59. TP_ARGS(evt_type, pkt_type),
  60. TP_STRUCT__entry(
  61. __field(enum applespi_evt_type, evt_type)
  62. __field(enum applespi_pkt_type, pkt_type)
  63. ),
  64. TP_fast_assign(
  65. __entry->evt_type = evt_type;
  66. __entry->pkt_type = pkt_type;
  67. ),
  68. "\n"
  69. );
  70. #endif /* _APPLESPI_TRACE_H_ */
  71. /* This part must be outside protection */
  72. #undef TRACE_INCLUDE_PATH
  73. #define TRACE_INCLUDE_PATH ../../drivers/input/keyboard
  74. #define TRACE_INCLUDE_FILE applespi_trace
  75. #include <trace/define_trace.h>