1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 /* 3 * Intel SOC Telemetry Driver Header File 4 * Copyright (C) 2015, Intel Corporation. 5 * All Rights Reserved. 6 */ 7 #ifndef INTEL_TELEMETRY_H 8 #define INTEL_TELEMETRY_H 9 10 #define TELEM_MAX_EVENTS_SRAM 28 11 #define TELEM_MAX_OS_ALLOCATED_EVENTS 20 12 13 #include <asm/intel_scu_ipc.h> 14 15 enum telemetry_unit { 16 TELEM_PSS = 0, 17 TELEM_IOSS, 18 TELEM_UNIT_NONE 19 }; 20 21 struct telemetry_evtlog { 22 u32 telem_evtid; 23 u64 telem_evtlog; 24 }; 25 26 struct telemetry_evtconfig { 27 /* Array of Event-IDs to Enable */ 28 u32 *evtmap; 29 30 /* Number of Events (<29) in evtmap */ 31 u8 num_evts; 32 33 /* Sampling period */ 34 u8 period; 35 }; 36 37 struct telemetry_evtmap { 38 const char *name; 39 u32 evt_id; 40 }; 41 42 struct telemetry_unit_config { 43 struct telemetry_evtmap *telem_evts; 44 void __iomem *regmap; 45 u8 ssram_evts_used; 46 u8 curr_period; 47 u8 max_period; 48 u8 min_period; 49 }; 50 51 struct telemetry_plt_config { 52 struct telemetry_unit_config pss_config; 53 struct telemetry_unit_config ioss_config; 54 struct mutex telem_trace_lock; 55 struct mutex telem_lock; 56 struct intel_pmc_dev *pmc; 57 struct intel_scu_ipc_dev *scu; 58 bool telem_in_use; 59 }; 60 61 struct telemetry_core_ops { 62 int (*get_sampling_period)(u8 *pss_min_period, u8 *pss_max_period, 63 u8 *ioss_min_period, u8 *ioss_max_period); 64 65 int (*get_eventconfig)(struct telemetry_evtconfig *pss_evtconfig, 66 struct telemetry_evtconfig *ioss_evtconfig, 67 int pss_len, int ioss_len); 68 69 int (*update_events)(struct telemetry_evtconfig pss_evtconfig, 70 struct telemetry_evtconfig ioss_evtconfig); 71 72 int (*set_sampling_period)(u8 pss_period, u8 ioss_period); 73 74 int (*get_trace_verbosity)(enum telemetry_unit telem_unit, 75 u32 *verbosity); 76 77 int (*set_trace_verbosity)(enum telemetry_unit telem_unit, 78 u32 verbosity); 79 80 int (*raw_read_eventlog)(enum telemetry_unit telem_unit, 81 struct telemetry_evtlog *evtlog, 82 int len, int log_all_evts); 83 84 int (*read_eventlog)(enum telemetry_unit telem_unit, 85 struct telemetry_evtlog *evtlog, 86 int len, int log_all_evts); 87 88 int (*add_events)(u8 num_pss_evts, u8 num_ioss_evts, 89 u32 *pss_evtmap, u32 *ioss_evtmap); 90 91 int (*reset_events)(void); 92 }; 93 94 int telemetry_set_pltdata(const struct telemetry_core_ops *ops, 95 struct telemetry_plt_config *pltconfig); 96 97 int telemetry_clear_pltdata(void); 98 99 struct telemetry_plt_config *telemetry_get_pltdata(void); 100 101 int telemetry_get_evtname(enum telemetry_unit telem_unit, 102 const char **name, int len); 103 104 int telemetry_update_events(struct telemetry_evtconfig pss_evtconfig, 105 struct telemetry_evtconfig ioss_evtconfig); 106 107 int telemetry_add_events(u8 num_pss_evts, u8 num_ioss_evts, 108 u32 *pss_evtmap, u32 *ioss_evtmap); 109 110 int telemetry_reset_events(void); 111 112 int telemetry_get_eventconfig(struct telemetry_evtconfig *pss_config, 113 struct telemetry_evtconfig *ioss_config, 114 int pss_len, int ioss_len); 115 116 int telemetry_read_events(enum telemetry_unit telem_unit, 117 struct telemetry_evtlog *evtlog, int len); 118 119 int telemetry_raw_read_events(enum telemetry_unit telem_unit, 120 struct telemetry_evtlog *evtlog, int len); 121 122 int telemetry_read_eventlog(enum telemetry_unit telem_unit, 123 struct telemetry_evtlog *evtlog, int len); 124 125 int telemetry_raw_read_eventlog(enum telemetry_unit telem_unit, 126 struct telemetry_evtlog *evtlog, int len); 127 128 int telemetry_get_sampling_period(u8 *pss_min_period, u8 *pss_max_period, 129 u8 *ioss_min_period, u8 *ioss_max_period); 130 131 int telemetry_set_sampling_period(u8 pss_period, u8 ioss_period); 132 133 int telemetry_set_trace_verbosity(enum telemetry_unit telem_unit, 134 u32 verbosity); 135 136 int telemetry_get_trace_verbosity(enum telemetry_unit telem_unit, 137 u32 *verbosity); 138 139 #endif /* INTEL_TELEMETRY_H */ 140