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