xref: /openbmc/linux/include/trace/events/power.h (revision b595076a)
1 #undef TRACE_SYSTEM
2 #define TRACE_SYSTEM power
3 
4 #if !defined(_TRACE_POWER_H) || defined(TRACE_HEADER_MULTI_READ)
5 #define _TRACE_POWER_H
6 
7 #include <linux/ktime.h>
8 #include <linux/tracepoint.h>
9 
10 #ifndef _TRACE_POWER_ENUM_
11 #define _TRACE_POWER_ENUM_
12 enum {
13 	POWER_NONE	= 0,
14 	POWER_CSTATE	= 1,	/* C-State */
15 	POWER_PSTATE	= 2,	/* Fequency change or DVFS */
16 	POWER_SSTATE	= 3,	/* Suspend */
17 };
18 #endif
19 
20 /*
21  * The power events are used for cpuidle & suspend (power_start, power_end)
22  *  and for cpufreq (power_frequency)
23  */
24 DECLARE_EVENT_CLASS(power,
25 
26 	TP_PROTO(unsigned int type, unsigned int state, unsigned int cpu_id),
27 
28 	TP_ARGS(type, state, cpu_id),
29 
30 	TP_STRUCT__entry(
31 		__field(	u64,		type		)
32 		__field(	u64,		state		)
33 		__field(	u64,		cpu_id		)
34 	),
35 
36 	TP_fast_assign(
37 		__entry->type = type;
38 		__entry->state = state;
39 		__entry->cpu_id = cpu_id;
40 	),
41 
42 	TP_printk("type=%lu state=%lu cpu_id=%lu", (unsigned long)__entry->type,
43 		(unsigned long)__entry->state, (unsigned long)__entry->cpu_id)
44 );
45 
46 DEFINE_EVENT(power, power_start,
47 
48 	TP_PROTO(unsigned int type, unsigned int state, unsigned int cpu_id),
49 
50 	TP_ARGS(type, state, cpu_id)
51 );
52 
53 DEFINE_EVENT(power, power_frequency,
54 
55 	TP_PROTO(unsigned int type, unsigned int state, unsigned int cpu_id),
56 
57 	TP_ARGS(type, state, cpu_id)
58 );
59 
60 TRACE_EVENT(power_end,
61 
62 	TP_PROTO(unsigned int cpu_id),
63 
64 	TP_ARGS(cpu_id),
65 
66 	TP_STRUCT__entry(
67 		__field(	u64,		cpu_id		)
68 	),
69 
70 	TP_fast_assign(
71 		__entry->cpu_id = cpu_id;
72 	),
73 
74 	TP_printk("cpu_id=%lu", (unsigned long)__entry->cpu_id)
75 
76 );
77 
78 /*
79  * The clock events are used for clock enable/disable and for
80  *  clock rate change
81  */
82 DECLARE_EVENT_CLASS(clock,
83 
84 	TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
85 
86 	TP_ARGS(name, state, cpu_id),
87 
88 	TP_STRUCT__entry(
89 		__string(       name,           name            )
90 		__field(        u64,            state           )
91 		__field(        u64,            cpu_id          )
92 	),
93 
94 	TP_fast_assign(
95 		__assign_str(name, name);
96 		__entry->state = state;
97 		__entry->cpu_id = cpu_id;
98 	),
99 
100 	TP_printk("%s state=%lu cpu_id=%lu", __get_str(name),
101 		(unsigned long)__entry->state, (unsigned long)__entry->cpu_id)
102 );
103 
104 DEFINE_EVENT(clock, clock_enable,
105 
106 	TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
107 
108 	TP_ARGS(name, state, cpu_id)
109 );
110 
111 DEFINE_EVENT(clock, clock_disable,
112 
113 	TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
114 
115 	TP_ARGS(name, state, cpu_id)
116 );
117 
118 DEFINE_EVENT(clock, clock_set_rate,
119 
120 	TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
121 
122 	TP_ARGS(name, state, cpu_id)
123 );
124 
125 /*
126  * The power domain events are used for power domains transitions
127  */
128 DECLARE_EVENT_CLASS(power_domain,
129 
130 	TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
131 
132 	TP_ARGS(name, state, cpu_id),
133 
134 	TP_STRUCT__entry(
135 		__string(       name,           name            )
136 		__field(        u64,            state           )
137 		__field(        u64,            cpu_id          )
138 	),
139 
140 	TP_fast_assign(
141 		__assign_str(name, name);
142 		__entry->state = state;
143 		__entry->cpu_id = cpu_id;
144 ),
145 
146 	TP_printk("%s state=%lu cpu_id=%lu", __get_str(name),
147 		(unsigned long)__entry->state, (unsigned long)__entry->cpu_id)
148 );
149 
150 DEFINE_EVENT(power_domain, power_domain_target,
151 
152 	TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
153 
154 	TP_ARGS(name, state, cpu_id)
155 );
156 
157 #endif /* _TRACE_POWER_H */
158 
159 /* This part must be outside protection */
160 #include <trace/define_trace.h>
161