linux/drivers/usb/typec/tipd/trace.h

/* SPDX-License-Identifier: GPL-2.0+ */
/*
 * Driver for TI TPS6598x USB Power Delivery controller family
 *
 * Copyright (C) 2020 Purism SPC
 * Author: Guido Günther <[email protected]>
 */

#undef TRACE_SYSTEM
#define TRACE_SYSTEM

#if !defined(_TPS6598X_TRACE_H_) || defined(TRACE_HEADER_MULTI_READ)
#define _TPS6598X_TRACE_H_

#include "tps6598x.h"

#include <linux/stringify.h>
#include <linux/types.h>
#include <linux/tracepoint.h>

#define show_irq_flags(flags)

#define show_cd321x_irq_flags(flags)

#define show_tps25750_irq_flags(flags)

#define TPS6598X_STATUS_FLAGS_MASK

#define TPS25750_STATUS_FLAGS_MASK

#define show_status_conn_state(status)

#define show_status_pp_switch_state(status)

#define show_status_power_sources(status)

#define show_status_vbus_status(status)

#define show_status_usb_host_present(status)

#define show_status_legacy(status)

#define show_status_flags(flags)

#define show_tps25750_status_flags(flags)

#define show_power_status_source_sink(power_status)

#define show_power_status_typec_status(power_status)

#define show_power_status_bc12_status(power_status)

#define show_tps25750_power_status_charger_detect_status(power_status)

#define TPS_DATA_STATUS_FLAGS_MASK

#define show_data_status_flags(data_status)

#define show_data_status_dp_pin_assignment(data_status)

#define maybe_show_data_status_dp_pin_assignment(data_status)

TRACE_EVENT(tps6598x_irq,
	    TP_PROTO(u64 event1,
		     u64 event2),
	    TP_ARGS(event1, event2),

	    TP_STRUCT__entry(
			     __field(u64, event1)
			     __field(u64, event2)
			     ),

	    TP_fast_assign(
			   __entry->event1 = event1;
			   __entry->event2 = event2;
			   ),

	    TP_printk("event1=%s, event2=%s",
		      show_irq_flags(__entry->event1),
		      show_irq_flags(__entry->event2))
);

TRACE_EVENT(cd321x_irq,
	    TP_PROTO(u64 event),
	    TP_ARGS(event),

	    TP_STRUCT__entry(
			     __field(u64, event)
			     ),

	    TP_fast_assign(
			   __entry->event = event;
			   ),

	    TP_printk("event=%s",
		      show_cd321x_irq_flags(__entry->event))
);

TRACE_EVENT(tps25750_irq,
	    TP_PROTO(u64 event),
	    TP_ARGS(event),

	    TP_STRUCT__entry(
			     __field(u64, event)
			     ),

	    TP_fast_assign(
			   __entry->event = event;
			   ),

	    TP_printk("event=%s", show_tps25750_irq_flags(__entry->event))
);

TRACE_EVENT(tps6598x_status,
	    TP_PROTO(u32 status),
	    TP_ARGS(status),

	    TP_STRUCT__entry(
			     __field(u32, status)
			     ),

	    TP_fast_assign(
			   __entry->status = status;
			   ),

	    TP_printk("conn: %s, pp_5v0: %s, pp_hv: %s, pp_ext: %s, pp_cable: %s, "
		      "pwr-src: %s, vbus: %s, usb-host: %s, legacy: %s, flags: %s",
		      show_status_conn_state(__entry->status),
		      show_status_pp_switch_state(TPS_STATUS_PP_5V0_SWITCH(__entry->status)),
		      show_status_pp_switch_state(TPS_STATUS_PP_HV_SWITCH(__entry->status)),
		      show_status_pp_switch_state(TPS_STATUS_PP_EXT_SWITCH(__entry->status)),
		      show_status_pp_switch_state(TPS_STATUS_PP_CABLE_SWITCH(__entry->status)),
		      show_status_power_sources(__entry->status),
		      show_status_vbus_status(__entry->status),
		      show_status_usb_host_present(__entry->status),
		      show_status_legacy(__entry->status),
		      show_status_flags(__entry->status)
		    )
);

TRACE_EVENT(tps25750_status,
	    TP_PROTO(u32 status),
	    TP_ARGS(status),

	    TP_STRUCT__entry(
			     __field(u32, status)
			     ),

	    TP_fast_assign(
			   __entry->status = status;
			   ),

	    TP_printk("conn: %s, vbus: %s, usb-host: %s, legacy: %s, flags: %s",
		      show_status_conn_state(__entry->status),
		      show_status_vbus_status(__entry->status),
		      show_status_usb_host_present(__entry->status),
		      show_status_legacy(__entry->status),
		      show_tps25750_status_flags(__entry->status)
		    )
);

TRACE_EVENT(tps6598x_power_status,
	    TP_PROTO(u16 power_status),
	    TP_ARGS(power_status),

	    TP_STRUCT__entry(
			     __field(u16, power_status)
			     ),

	    TP_fast_assign(
			   __entry->power_status = power_status;
			   ),

	    TP_printk("conn: %d, pwr-role: %s, typec: %s, bc: %s",
		      !!TPS_POWER_STATUS_CONNECTION(__entry->power_status),
		      show_power_status_source_sink(__entry->power_status),
		      show_power_status_typec_status(__entry->power_status),
		      show_power_status_bc12_status(__entry->power_status)
		    )
);

TRACE_EVENT(tps25750_power_status,
	    TP_PROTO(u16 power_status),
	    TP_ARGS(power_status),

	    TP_STRUCT__entry(
			     __field(u16, power_status)
			     ),

	    TP_fast_assign(
			   __entry->power_status = power_status;
			   ),

	    TP_printk("conn: %d, pwr-role: %s, typec: %s, charger detect: %s",
		      !!TPS_POWER_STATUS_CONNECTION(__entry->power_status),
		      show_power_status_source_sink(__entry->power_status),
		      show_power_status_typec_status(__entry->power_status),
		      show_tps25750_power_status_charger_detect_status(__entry->power_status)
		    )
);

TRACE_EVENT(tps6598x_data_status,
	    TP_PROTO(u32 data_status),
	    TP_ARGS(data_status),

	    TP_STRUCT__entry(
			     __field(u32, data_status)
			     ),

	    TP_fast_assign(
			   __entry->data_status = data_status;
			   ),

	    TP_printk("%s%s%s",
		      show_data_status_flags(__entry->data_status),
		      __entry->data_status & TPS_DATA_STATUS_DP_CONNECTION ? ", DP pinout " : "",
		      maybe_show_data_status_dp_pin_assignment(__entry->data_status)
		    )
);

#endif /* _TPS6598X_TRACE_H_ */

/* This part must be outside protection */
#undef TRACE_INCLUDE_FILE
#define TRACE_INCLUDE_FILE
#undef TRACE_INCLUDE_PATH
#define TRACE_INCLUDE_PATH
#include <trace/define_trace.h>