xref: /linux/arch/x86/include/asm/intel_telemetry.h (revision 3a39d672e7f48b8d6b91a09afa4b55352773b4b5)
12025cf9eSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
2378f956eSSouvik Kumar Chakravarty /*
3378f956eSSouvik Kumar Chakravarty  * Intel SOC Telemetry Driver Header File
4378f956eSSouvik Kumar Chakravarty  * Copyright (C) 2015, Intel Corporation.
5378f956eSSouvik Kumar Chakravarty  * All Rights Reserved.
6378f956eSSouvik Kumar Chakravarty  */
7378f956eSSouvik Kumar Chakravarty #ifndef INTEL_TELEMETRY_H
8378f956eSSouvik Kumar Chakravarty #define INTEL_TELEMETRY_H
9378f956eSSouvik Kumar Chakravarty 
10378f956eSSouvik Kumar Chakravarty #define TELEM_MAX_EVENTS_SRAM		28
11378f956eSSouvik Kumar Chakravarty #define TELEM_MAX_OS_ALLOCATED_EVENTS	20
12378f956eSSouvik Kumar Chakravarty 
13*c912ac66SMika Westerberg #include <linux/platform_data/x86/intel_scu_ipc.h>
1468c73fb2SMika Westerberg 
15378f956eSSouvik Kumar Chakravarty enum telemetry_unit {
16378f956eSSouvik Kumar Chakravarty 	TELEM_PSS = 0,
17378f956eSSouvik Kumar Chakravarty 	TELEM_IOSS,
18378f956eSSouvik Kumar Chakravarty 	TELEM_UNIT_NONE
19378f956eSSouvik Kumar Chakravarty };
20378f956eSSouvik Kumar Chakravarty 
21378f956eSSouvik Kumar Chakravarty struct telemetry_evtlog {
22378f956eSSouvik Kumar Chakravarty 	u32 telem_evtid;
23378f956eSSouvik Kumar Chakravarty 	u64 telem_evtlog;
24378f956eSSouvik Kumar Chakravarty };
25378f956eSSouvik Kumar Chakravarty 
26378f956eSSouvik Kumar Chakravarty struct telemetry_evtconfig {
27378f956eSSouvik Kumar Chakravarty 	/* Array of Event-IDs to Enable */
28378f956eSSouvik Kumar Chakravarty 	u32 *evtmap;
29378f956eSSouvik Kumar Chakravarty 
30378f956eSSouvik Kumar Chakravarty 	/* Number of Events (<29) in evtmap */
31378f956eSSouvik Kumar Chakravarty 	u8 num_evts;
32378f956eSSouvik Kumar Chakravarty 
33378f956eSSouvik Kumar Chakravarty 	/* Sampling period */
34378f956eSSouvik Kumar Chakravarty 	u8 period;
35378f956eSSouvik Kumar Chakravarty };
36378f956eSSouvik Kumar Chakravarty 
37378f956eSSouvik Kumar Chakravarty struct telemetry_evtmap {
38378f956eSSouvik Kumar Chakravarty 	const char *name;
39378f956eSSouvik Kumar Chakravarty 	u32 evt_id;
40378f956eSSouvik Kumar Chakravarty };
41378f956eSSouvik Kumar Chakravarty 
42378f956eSSouvik Kumar Chakravarty struct telemetry_unit_config {
43378f956eSSouvik Kumar Chakravarty 	struct telemetry_evtmap *telem_evts;
44378f956eSSouvik Kumar Chakravarty 	void __iomem *regmap;
45378f956eSSouvik Kumar Chakravarty 	u8 ssram_evts_used;
46378f956eSSouvik Kumar Chakravarty 	u8 curr_period;
47378f956eSSouvik Kumar Chakravarty 	u8 max_period;
48378f956eSSouvik Kumar Chakravarty 	u8 min_period;
49378f956eSSouvik Kumar Chakravarty };
50378f956eSSouvik Kumar Chakravarty 
51378f956eSSouvik Kumar Chakravarty struct telemetry_plt_config {
52378f956eSSouvik Kumar Chakravarty 	struct telemetry_unit_config pss_config;
53378f956eSSouvik Kumar Chakravarty 	struct telemetry_unit_config ioss_config;
54378f956eSSouvik Kumar Chakravarty 	struct mutex telem_trace_lock;
55378f956eSSouvik Kumar Chakravarty 	struct mutex telem_lock;
5625f1ca31SMika Westerberg 	struct intel_pmc_dev *pmc;
5768c73fb2SMika Westerberg 	struct intel_scu_ipc_dev *scu;
58378f956eSSouvik Kumar Chakravarty 	bool telem_in_use;
59378f956eSSouvik Kumar Chakravarty };
60378f956eSSouvik Kumar Chakravarty 
61378f956eSSouvik Kumar Chakravarty struct telemetry_core_ops {
62378f956eSSouvik Kumar Chakravarty 	int (*get_sampling_period)(u8 *pss_min_period, u8 *pss_max_period,
63378f956eSSouvik Kumar Chakravarty 				   u8 *ioss_min_period, u8 *ioss_max_period);
64378f956eSSouvik Kumar Chakravarty 
65378f956eSSouvik Kumar Chakravarty 	int (*get_eventconfig)(struct telemetry_evtconfig *pss_evtconfig,
66378f956eSSouvik Kumar Chakravarty 			       struct telemetry_evtconfig *ioss_evtconfig,
67378f956eSSouvik Kumar Chakravarty 			       int pss_len, int ioss_len);
68378f956eSSouvik Kumar Chakravarty 
69378f956eSSouvik Kumar Chakravarty 	int (*update_events)(struct telemetry_evtconfig pss_evtconfig,
70378f956eSSouvik Kumar Chakravarty 			     struct telemetry_evtconfig ioss_evtconfig);
71378f956eSSouvik Kumar Chakravarty 
72378f956eSSouvik Kumar Chakravarty 	int (*set_sampling_period)(u8 pss_period, u8 ioss_period);
73378f956eSSouvik Kumar Chakravarty 
74378f956eSSouvik Kumar Chakravarty 	int (*get_trace_verbosity)(enum telemetry_unit telem_unit,
75378f956eSSouvik Kumar Chakravarty 				   u32 *verbosity);
76378f956eSSouvik Kumar Chakravarty 
77378f956eSSouvik Kumar Chakravarty 	int (*set_trace_verbosity)(enum telemetry_unit telem_unit,
78378f956eSSouvik Kumar Chakravarty 				   u32 verbosity);
79378f956eSSouvik Kumar Chakravarty 
80378f956eSSouvik Kumar Chakravarty 	int (*raw_read_eventlog)(enum telemetry_unit telem_unit,
81378f956eSSouvik Kumar Chakravarty 				 struct telemetry_evtlog *evtlog,
82378f956eSSouvik Kumar Chakravarty 				 int len, int log_all_evts);
83378f956eSSouvik Kumar Chakravarty 
84378f956eSSouvik Kumar Chakravarty 	int (*read_eventlog)(enum telemetry_unit telem_unit,
85378f956eSSouvik Kumar Chakravarty 			     struct telemetry_evtlog *evtlog,
86378f956eSSouvik Kumar Chakravarty 			     int len, int log_all_evts);
87378f956eSSouvik Kumar Chakravarty 
88378f956eSSouvik Kumar Chakravarty 	int (*add_events)(u8 num_pss_evts, u8 num_ioss_evts,
89378f956eSSouvik Kumar Chakravarty 			  u32 *pss_evtmap, u32 *ioss_evtmap);
90378f956eSSouvik Kumar Chakravarty 
91378f956eSSouvik Kumar Chakravarty 	int (*reset_events)(void);
92378f956eSSouvik Kumar Chakravarty };
93378f956eSSouvik Kumar Chakravarty 
94775d054aSJulia Lawall int telemetry_set_pltdata(const struct telemetry_core_ops *ops,
95378f956eSSouvik Kumar Chakravarty 			  struct telemetry_plt_config *pltconfig);
96378f956eSSouvik Kumar Chakravarty 
97378f956eSSouvik Kumar Chakravarty int telemetry_clear_pltdata(void);
98378f956eSSouvik Kumar Chakravarty 
990759a873SMika Westerberg struct telemetry_plt_config *telemetry_get_pltdata(void);
100378f956eSSouvik Kumar Chakravarty 
101378f956eSSouvik Kumar Chakravarty int telemetry_get_evtname(enum telemetry_unit telem_unit,
102378f956eSSouvik Kumar Chakravarty 			  const char **name, int len);
103378f956eSSouvik Kumar Chakravarty 
104378f956eSSouvik Kumar Chakravarty int telemetry_update_events(struct telemetry_evtconfig pss_evtconfig,
105378f956eSSouvik Kumar Chakravarty 			    struct telemetry_evtconfig ioss_evtconfig);
106378f956eSSouvik Kumar Chakravarty 
107378f956eSSouvik Kumar Chakravarty int telemetry_add_events(u8 num_pss_evts, u8 num_ioss_evts,
108378f956eSSouvik Kumar Chakravarty 			 u32 *pss_evtmap, u32 *ioss_evtmap);
109378f956eSSouvik Kumar Chakravarty 
110378f956eSSouvik Kumar Chakravarty int telemetry_reset_events(void);
111378f956eSSouvik Kumar Chakravarty 
112378f956eSSouvik Kumar Chakravarty int telemetry_get_eventconfig(struct telemetry_evtconfig *pss_config,
113378f956eSSouvik Kumar Chakravarty 			      struct telemetry_evtconfig *ioss_config,
114378f956eSSouvik Kumar Chakravarty 			      int pss_len, int ioss_len);
115378f956eSSouvik Kumar Chakravarty 
116378f956eSSouvik Kumar Chakravarty int telemetry_read_events(enum telemetry_unit telem_unit,
117378f956eSSouvik Kumar Chakravarty 			  struct telemetry_evtlog *evtlog, int len);
118378f956eSSouvik Kumar Chakravarty 
119378f956eSSouvik Kumar Chakravarty int telemetry_raw_read_events(enum telemetry_unit telem_unit,
120378f956eSSouvik Kumar Chakravarty 			      struct telemetry_evtlog *evtlog, int len);
121378f956eSSouvik Kumar Chakravarty 
122378f956eSSouvik Kumar Chakravarty int telemetry_read_eventlog(enum telemetry_unit telem_unit,
123378f956eSSouvik Kumar Chakravarty 			    struct telemetry_evtlog *evtlog, int len);
124378f956eSSouvik Kumar Chakravarty 
125378f956eSSouvik Kumar Chakravarty int telemetry_raw_read_eventlog(enum telemetry_unit telem_unit,
126378f956eSSouvik Kumar Chakravarty 				struct telemetry_evtlog *evtlog, int len);
127378f956eSSouvik Kumar Chakravarty 
128378f956eSSouvik Kumar Chakravarty int telemetry_get_sampling_period(u8 *pss_min_period, u8 *pss_max_period,
129378f956eSSouvik Kumar Chakravarty 				  u8 *ioss_min_period, u8 *ioss_max_period);
130378f956eSSouvik Kumar Chakravarty 
131378f956eSSouvik Kumar Chakravarty int telemetry_set_sampling_period(u8 pss_period, u8 ioss_period);
132378f956eSSouvik Kumar Chakravarty 
133378f956eSSouvik Kumar Chakravarty int telemetry_set_trace_verbosity(enum telemetry_unit telem_unit,
134378f956eSSouvik Kumar Chakravarty 				  u32 verbosity);
135378f956eSSouvik Kumar Chakravarty 
136378f956eSSouvik Kumar Chakravarty int telemetry_get_trace_verbosity(enum telemetry_unit telem_unit,
137378f956eSSouvik Kumar Chakravarty 				  u32 *verbosity);
138378f956eSSouvik Kumar Chakravarty 
139378f956eSSouvik Kumar Chakravarty #endif /* INTEL_TELEMETRY_H */
140