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 u32 ssram_base_addr; 44 u8 ssram_evts_used; 45 u8 curr_period; 46 u8 max_period; 47 u8 min_period; 48 u32 ssram_size; 49 50 }; 51 52 struct telemetry_plt_config { 53 struct telemetry_unit_config pss_config; 54 struct telemetry_unit_config ioss_config; 55 struct mutex telem_trace_lock; 56 struct mutex telem_lock; 57 bool telem_in_use; 58 }; 59 60 struct telemetry_core_ops { 61 int (*get_sampling_period)(u8 *pss_min_period, u8 *pss_max_period, 62 u8 *ioss_min_period, u8 *ioss_max_period); 63 64 int (*get_eventconfig)(struct telemetry_evtconfig *pss_evtconfig, 65 struct telemetry_evtconfig *ioss_evtconfig, 66 int pss_len, int ioss_len); 67 68 int (*update_events)(struct telemetry_evtconfig pss_evtconfig, 69 struct telemetry_evtconfig ioss_evtconfig); 70 71 int (*set_sampling_period)(u8 pss_period, u8 ioss_period); 72 73 int (*get_trace_verbosity)(enum telemetry_unit telem_unit, 74 u32 *verbosity); 75 76 int (*set_trace_verbosity)(enum telemetry_unit telem_unit, 77 u32 verbosity); 78 79 int (*raw_read_eventlog)(enum telemetry_unit telem_unit, 80 struct telemetry_evtlog *evtlog, 81 int len, int log_all_evts); 82 83 int (*read_eventlog)(enum telemetry_unit telem_unit, 84 struct telemetry_evtlog *evtlog, 85 int len, int log_all_evts); 86 87 int (*add_events)(u8 num_pss_evts, u8 num_ioss_evts, 88 u32 *pss_evtmap, u32 *ioss_evtmap); 89 90 int (*reset_events)(void); 91 }; 92 93 int telemetry_set_pltdata(const struct telemetry_core_ops *ops, 94 struct telemetry_plt_config *pltconfig); 95 96 int telemetry_clear_pltdata(void); 97 98 int telemetry_pltconfig_valid(void); 99 100 int telemetry_get_evtname(enum telemetry_unit telem_unit, 101 const char **name, int len); 102 103 int telemetry_update_events(struct telemetry_evtconfig pss_evtconfig, 104 struct telemetry_evtconfig ioss_evtconfig); 105 106 int telemetry_add_events(u8 num_pss_evts, u8 num_ioss_evts, 107 u32 *pss_evtmap, u32 *ioss_evtmap); 108 109 int telemetry_reset_events(void); 110 111 int telemetry_get_eventconfig(struct telemetry_evtconfig *pss_config, 112 struct telemetry_evtconfig *ioss_config, 113 int pss_len, int ioss_len); 114 115 int telemetry_read_events(enum telemetry_unit telem_unit, 116 struct telemetry_evtlog *evtlog, int len); 117 118 int telemetry_raw_read_events(enum telemetry_unit telem_unit, 119 struct telemetry_evtlog *evtlog, int len); 120 121 int telemetry_read_eventlog(enum telemetry_unit telem_unit, 122 struct telemetry_evtlog *evtlog, int len); 123 124 int telemetry_raw_read_eventlog(enum telemetry_unit telem_unit, 125 struct telemetry_evtlog *evtlog, int len); 126 127 int telemetry_get_sampling_period(u8 *pss_min_period, u8 *pss_max_period, 128 u8 *ioss_min_period, u8 *ioss_max_period); 129 130 int telemetry_set_sampling_period(u8 pss_period, u8 ioss_period); 131 132 int telemetry_set_trace_verbosity(enum telemetry_unit telem_unit, 133 u32 verbosity); 134 135 int telemetry_get_trace_verbosity(enum telemetry_unit telem_unit, 136 u32 *verbosity); 137 138 #endif /* INTEL_TELEMETRY_H */ 139