Commit | Line | Data |
---|---|---|
4752544a | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
aa4f886f SH |
2 | /* |
3 | * SCMI Message Protocol driver header | |
4 | * | |
48dc16e2 | 5 | * Copyright (C) 2018-2021 ARM Ltd. |
aa4f886f | 6 | */ |
70771c69 SH |
7 | |
8 | #ifndef _LINUX_SCMI_PROTOCOL_H | |
9 | #define _LINUX_SCMI_PROTOCOL_H | |
10 | ||
1fe00b8b | 11 | #include <linux/bitfield.h> |
933c5044 | 12 | #include <linux/device.h> |
e7c215f3 | 13 | #include <linux/notifier.h> |
aa4f886f SH |
14 | #include <linux/types.h> |
15 | ||
4314f9f4 CM |
16 | #define SCMI_MAX_STR_SIZE 64 |
17 | #define SCMI_SHORT_NAME_MAX_SIZE 16 | |
18 | #define SCMI_MAX_NUM_RATES 16 | |
b6f20ff8 SH |
19 | |
20 | /** | |
21 | * struct scmi_revision_info - version information structure | |
22 | * | |
23 | * @major_ver: Major ABI version. Change here implies risk of backward | |
24 | * compatibility break. | |
25 | * @minor_ver: Minor ABI version. Change here implies new feature addition, | |
26 | * or compatible change in ABI. | |
27 | * @num_protocols: Number of protocols that are implemented, excluding the | |
28 | * base protocol. | |
29 | * @num_agents: Number of agents in the system. | |
30 | * @impl_ver: A vendor-specific implementation version. | |
31 | * @vendor_id: A vendor identifier(Null terminated ASCII string) | |
32 | * @sub_vendor_id: A sub-vendor identifier(Null terminated ASCII string) | |
33 | */ | |
34 | struct scmi_revision_info { | |
35 | u16 major_ver; | |
36 | u16 minor_ver; | |
37 | u8 num_protocols; | |
38 | u8 num_agents; | |
39 | u32 impl_ver; | |
4314f9f4 CM |
40 | char vendor_id[SCMI_SHORT_NAME_MAX_SIZE]; |
41 | char sub_vendor_id[SCMI_SHORT_NAME_MAX_SIZE]; | |
b6f20ff8 SH |
42 | }; |
43 | ||
5f6c6430 SH |
44 | struct scmi_clock_info { |
45 | char name[SCMI_MAX_STR_SIZE]; | |
18f295b7 | 46 | unsigned int enable_latency; |
5f6c6430 | 47 | bool rate_discrete; |
7aa75496 CM |
48 | bool rate_changed_notifications; |
49 | bool rate_change_requested_notifications; | |
dc36561e PF |
50 | bool state_ctrl_forbidden; |
51 | bool rate_ctrl_forbidden; | |
52 | bool parent_ctrl_forbidden; | |
e4ad2b01 | 53 | bool extended_config; |
5f6c6430 SH |
54 | union { |
55 | struct { | |
56 | int num_rates; | |
57 | u64 rates[SCMI_MAX_NUM_RATES]; | |
58 | } list; | |
59 | struct { | |
60 | u64 min_rate; | |
61 | u64 max_rate; | |
62 | u64 step_size; | |
63 | } range; | |
64 | }; | |
77bbfe60 PF |
65 | int num_parents; |
66 | u32 *parents; | |
5f6c6430 SH |
67 | }; |
68 | ||
5e0fd202 LL |
69 | enum scmi_power_scale { |
70 | SCMI_POWER_BOGOWATTS, | |
71 | SCMI_POWER_MILLIWATTS, | |
72 | SCMI_POWER_MICROWATTS | |
73 | }; | |
74 | ||
a9e3fbfa | 75 | struct scmi_handle; |
23934efe CM |
76 | struct scmi_device; |
77 | struct scmi_protocol_handle; | |
a9e3fbfa | 78 | |
62092c42 CM |
79 | enum scmi_clock_oem_config { |
80 | SCMI_CLOCK_CFG_DUTY_CYCLE = 0x1, | |
81 | SCMI_CLOCK_CFG_PHASE, | |
82 | SCMI_CLOCK_CFG_OEM_START = 0x80, | |
83 | SCMI_CLOCK_CFG_OEM_END = 0xFF, | |
84 | }; | |
85 | ||
5f6c6430 | 86 | /** |
887281c7 | 87 | * struct scmi_clk_proto_ops - represents the various operations provided |
5f6c6430 SH |
88 | * by SCMI Clock Protocol |
89 | * | |
90 | * @count_get: get the count of clocks provided by SCMI | |
91 | * @info_get: get the information of the specified clock | |
92 | * @rate_get: request the current clock rate of a clock | |
93 | * @rate_set: set the clock rate of a clock | |
94 | * @enable: enables the specified clock | |
95 | * @disable: disables the specified clock | |
34592bf0 | 96 | * @state_get: get the status of the specified clock |
141b4fa0 CM |
97 | * @config_oem_get: get the value of an OEM specific clock config |
98 | * @config_oem_set: set the value of an OEM specific clock config | |
77bbfe60 PF |
99 | * @parent_get: get the parent id of a clk |
100 | * @parent_set: set the parent of a clock | |
5f6c6430 | 101 | */ |
887281c7 CM |
102 | struct scmi_clk_proto_ops { |
103 | int (*count_get)(const struct scmi_protocol_handle *ph); | |
104 | ||
1ecb7d27 | 105 | const struct scmi_clock_info __must_check *(*info_get) |
887281c7 CM |
106 | (const struct scmi_protocol_handle *ph, u32 clk_id); |
107 | int (*rate_get)(const struct scmi_protocol_handle *ph, u32 clk_id, | |
108 | u64 *rate); | |
109 | int (*rate_set)(const struct scmi_protocol_handle *ph, u32 clk_id, | |
110 | u64 rate); | |
03a95cf2 CM |
111 | int (*enable)(const struct scmi_protocol_handle *ph, u32 clk_id, |
112 | bool atomic); | |
113 | int (*disable)(const struct scmi_protocol_handle *ph, u32 clk_id, | |
114 | bool atomic); | |
34592bf0 CM |
115 | int (*state_get)(const struct scmi_protocol_handle *ph, u32 clk_id, |
116 | bool *enabled, bool atomic); | |
141b4fa0 | 117 | int (*config_oem_get)(const struct scmi_protocol_handle *ph, u32 clk_id, |
62092c42 CM |
118 | enum scmi_clock_oem_config oem_type, |
119 | u32 *oem_val, u32 *attributes, bool atomic); | |
141b4fa0 | 120 | int (*config_oem_set)(const struct scmi_protocol_handle *ph, u32 clk_id, |
62092c42 CM |
121 | enum scmi_clock_oem_config oem_type, |
122 | u32 oem_val, bool atomic); | |
77bbfe60 PF |
123 | int (*parent_get)(const struct scmi_protocol_handle *ph, u32 clk_id, u32 *parent_id); |
124 | int (*parent_set)(const struct scmi_protocol_handle *ph, u32 clk_id, u32 parent_id); | |
887281c7 CM |
125 | }; |
126 | ||
3d99ed60 UH |
127 | struct scmi_perf_domain_info { |
128 | char name[SCMI_MAX_STR_SIZE]; | |
129 | bool set_perf; | |
130 | }; | |
131 | ||
a9e3fbfa | 132 | /** |
1fec5e6b | 133 | * struct scmi_perf_proto_ops - represents the various operations provided |
a9e3fbfa SH |
134 | * by SCMI Performance Protocol |
135 | * | |
e9090e70 | 136 | * @num_domains_get: gets the number of supported performance domains |
3d99ed60 | 137 | * @info_get: get the information of a performance domain |
a9e3fbfa SH |
138 | * @limits_set: sets limits on the performance level of a domain |
139 | * @limits_get: gets limits on the performance level of a domain | |
140 | * @level_set: sets the performance level of a domain | |
141 | * @level_get: gets the performance level of a domain | |
7859e08c | 142 | * @transition_latency_get: gets the DVFS transition latency for a given device |
ad86f7e9 PG |
143 | * @rate_limit_get: gets the minimum time (us) required between successive |
144 | * requests | |
7859e08c | 145 | * @device_opps_add: adds all the OPPs for a given device |
a9e3fbfa SH |
146 | * @freq_set: sets the frequency for a given device using sustained frequency |
147 | * to sustained performance level mapping | |
148 | * @freq_get: gets the frequency for a given device using sustained frequency | |
149 | * to sustained performance level mapping | |
1a63fe9a QP |
150 | * @est_power_get: gets the estimated power cost for a given performance domain |
151 | * at a given frequency | |
52f83955 SH |
152 | * @fast_switch_possible: indicates if fast DVFS switching is possible or not |
153 | * for a given device | |
2441caa8 PG |
154 | * @fast_switch_rate_limit: gets the minimum time (us) required between |
155 | * successive fast_switching requests | |
52f83955 SH |
156 | * @power_scale_mw_get: indicates if the power values provided are in milliWatts |
157 | * or in some other (abstract) scale | |
a9e3fbfa | 158 | */ |
1fec5e6b | 159 | struct scmi_perf_proto_ops { |
e9090e70 | 160 | int (*num_domains_get)(const struct scmi_protocol_handle *ph); |
3d99ed60 UH |
161 | const struct scmi_perf_domain_info __must_check *(*info_get) |
162 | (const struct scmi_protocol_handle *ph, u32 domain); | |
1fec5e6b CM |
163 | int (*limits_set)(const struct scmi_protocol_handle *ph, u32 domain, |
164 | u32 max_perf, u32 min_perf); | |
165 | int (*limits_get)(const struct scmi_protocol_handle *ph, u32 domain, | |
166 | u32 *max_perf, u32 *min_perf); | |
167 | int (*level_set)(const struct scmi_protocol_handle *ph, u32 domain, | |
168 | u32 level, bool poll); | |
169 | int (*level_get)(const struct scmi_protocol_handle *ph, u32 domain, | |
170 | u32 *level, bool poll); | |
1fec5e6b | 171 | int (*transition_latency_get)(const struct scmi_protocol_handle *ph, |
39dfa5b9 | 172 | u32 domain); |
ad86f7e9 PG |
173 | int (*rate_limit_get)(const struct scmi_protocol_handle *ph, |
174 | u32 domain, u32 *rate_limit); | |
1fec5e6b | 175 | int (*device_opps_add)(const struct scmi_protocol_handle *ph, |
39dfa5b9 | 176 | struct device *dev, u32 domain); |
1fec5e6b CM |
177 | int (*freq_set)(const struct scmi_protocol_handle *ph, u32 domain, |
178 | unsigned long rate, bool poll); | |
179 | int (*freq_get)(const struct scmi_protocol_handle *ph, u32 domain, | |
180 | unsigned long *rate, bool poll); | |
181 | int (*est_power_get)(const struct scmi_protocol_handle *ph, u32 domain, | |
182 | unsigned long *rate, unsigned long *power); | |
183 | bool (*fast_switch_possible)(const struct scmi_protocol_handle *ph, | |
39dfa5b9 | 184 | u32 domain); |
2441caa8 PG |
185 | int (*fast_switch_rate_limit)(const struct scmi_protocol_handle *ph, |
186 | u32 domain, u32 *rate_limit); | |
5e0fd202 | 187 | enum scmi_power_scale (*power_scale_get)(const struct scmi_protocol_handle *ph); |
1fec5e6b CM |
188 | }; |
189 | ||
76a65509 | 190 | /** |
9bc8069c | 191 | * struct scmi_power_proto_ops - represents the various operations provided |
76a65509 SH |
192 | * by SCMI Power Protocol |
193 | * | |
194 | * @num_domains_get: get the count of power domains provided by SCMI | |
195 | * @name_get: gets the name of a power domain | |
196 | * @state_set: sets the power state of a power domain | |
197 | * @state_get: gets the power state of a power domain | |
198 | */ | |
9bc8069c CM |
199 | struct scmi_power_proto_ops { |
200 | int (*num_domains_get)(const struct scmi_protocol_handle *ph); | |
992be5d3 CM |
201 | const char *(*name_get)(const struct scmi_protocol_handle *ph, |
202 | u32 domain); | |
76a65509 SH |
203 | #define SCMI_POWER_STATE_TYPE_SHIFT 30 |
204 | #define SCMI_POWER_STATE_ID_MASK (BIT(28) - 1) | |
205 | #define SCMI_POWER_STATE_PARAM(type, id) \ | |
206 | ((((type) & BIT(0)) << SCMI_POWER_STATE_TYPE_SHIFT) | \ | |
207 | ((id) & SCMI_POWER_STATE_ID_MASK)) | |
208 | #define SCMI_POWER_STATE_GENERIC_ON SCMI_POWER_STATE_PARAM(0, 0) | |
209 | #define SCMI_POWER_STATE_GENERIC_OFF SCMI_POWER_STATE_PARAM(1, 0) | |
9bc8069c CM |
210 | int (*state_set)(const struct scmi_protocol_handle *ph, u32 domain, |
211 | u32 state); | |
212 | int (*state_get)(const struct scmi_protocol_handle *ph, u32 domain, | |
213 | u32 *state); | |
214 | }; | |
215 | ||
e2083d36 | 216 | /** |
52f83955 | 217 | * struct scmi_sensor_reading - represent a timestamped read |
e2083d36 CM |
218 | * |
219 | * Used by @reading_get_timestamped method. | |
220 | * | |
221 | * @value: The signed value sensor read. | |
222 | * @timestamp: An unsigned timestamp for the sensor read, as provided by | |
223 | * SCMI platform. Set to zero when not available. | |
224 | */ | |
225 | struct scmi_sensor_reading { | |
226 | long long value; | |
227 | unsigned long long timestamp; | |
228 | }; | |
229 | ||
1fe00b8b | 230 | /** |
52f83955 | 231 | * struct scmi_range_attrs - specifies a sensor or axis values' range |
1fe00b8b CM |
232 | * @min_range: The minimum value which can be represented by the sensor/axis. |
233 | * @max_range: The maximum value which can be represented by the sensor/axis. | |
234 | */ | |
235 | struct scmi_range_attrs { | |
236 | long long min_range; | |
237 | long long max_range; | |
238 | }; | |
239 | ||
240 | /** | |
52f83955 | 241 | * struct scmi_sensor_axis_info - describes one sensor axes |
1fe00b8b CM |
242 | * @id: The axes ID. |
243 | * @type: Axes type. Chosen amongst one of @enum scmi_sensor_class. | |
244 | * @scale: Power-of-10 multiplier applied to the axis unit. | |
245 | * @name: NULL-terminated string representing axes name as advertised by | |
246 | * SCMI platform. | |
247 | * @extended_attrs: Flag to indicate the presence of additional extended | |
248 | * attributes for this axes. | |
249 | * @resolution: Extended attribute representing the resolution of the axes. | |
250 | * Set to 0 if not reported by this axes. | |
251 | * @exponent: Extended attribute representing the power-of-10 multiplier that | |
252 | * is applied to the resolution field. Set to 0 if not reported by | |
253 | * this axes. | |
254 | * @attrs: Extended attributes representing minimum and maximum values | |
255 | * measurable by this axes. Set to 0 if not reported by this sensor. | |
256 | */ | |
257 | struct scmi_sensor_axis_info { | |
258 | unsigned int id; | |
259 | unsigned int type; | |
260 | int scale; | |
261 | char name[SCMI_MAX_STR_SIZE]; | |
262 | bool extended_attrs; | |
263 | unsigned int resolution; | |
264 | int exponent; | |
265 | struct scmi_range_attrs attrs; | |
266 | }; | |
267 | ||
268 | /** | |
52f83955 SH |
269 | * struct scmi_sensor_intervals_info - describes number and type of available |
270 | * update intervals | |
1fe00b8b CM |
271 | * @segmented: Flag for segmented intervals' representation. When True there |
272 | * will be exactly 3 intervals in @desc, with each entry | |
273 | * representing a member of a segment in this order: | |
274 | * {lowest update interval, highest update interval, step size} | |
275 | * @count: Number of intervals described in @desc. | |
276 | * @desc: Array of @count interval descriptor bitmask represented as detailed in | |
277 | * the SCMI specification: it can be accessed using the accompanying | |
278 | * macros. | |
279 | * @prealloc_pool: A minimal preallocated pool of desc entries used to avoid | |
280 | * lesser-than-64-bytes dynamic allocation for small @count | |
281 | * values. | |
282 | */ | |
283 | struct scmi_sensor_intervals_info { | |
284 | bool segmented; | |
285 | unsigned int count; | |
286 | #define SCMI_SENS_INTVL_SEGMENT_LOW 0 | |
287 | #define SCMI_SENS_INTVL_SEGMENT_HIGH 1 | |
288 | #define SCMI_SENS_INTVL_SEGMENT_STEP 2 | |
289 | unsigned int *desc; | |
290 | #define SCMI_SENS_INTVL_GET_SECS(x) FIELD_GET(GENMASK(20, 5), (x)) | |
291 | #define SCMI_SENS_INTVL_GET_EXP(x) \ | |
292 | ({ \ | |
293 | int __signed_exp = FIELD_GET(GENMASK(4, 0), (x)); \ | |
294 | \ | |
295 | if (__signed_exp & BIT(4)) \ | |
296 | __signed_exp |= GENMASK(31, 5); \ | |
297 | __signed_exp; \ | |
298 | }) | |
299 | #define SCMI_MAX_PREALLOC_POOL 16 | |
300 | unsigned int prealloc_pool[SCMI_MAX_PREALLOC_POOL]; | |
301 | }; | |
302 | ||
303 | /** | |
304 | * struct scmi_sensor_info - represents information related to one of the | |
305 | * available sensors. | |
306 | * @id: Sensor ID. | |
307 | * @type: Sensor type. Chosen amongst one of @enum scmi_sensor_class. | |
308 | * @scale: Power-of-10 multiplier applied to the sensor unit. | |
309 | * @num_trip_points: Number of maximum configurable trip points. | |
310 | * @async: Flag for asynchronous read support. | |
311 | * @update: Flag for continuouos update notification support. | |
312 | * @timestamped: Flag for timestamped read support. | |
313 | * @tstamp_scale: Power-of-10 multiplier applied to the sensor timestamps to | |
314 | * represent it in seconds. | |
315 | * @num_axis: Number of supported axis if any. Reported as 0 for scalar sensors. | |
316 | * @axis: Pointer to an array of @num_axis descriptors. | |
317 | * @intervals: Descriptor of available update intervals. | |
318 | * @sensor_config: A bitmask reporting the current sensor configuration as | |
319 | * detailed in the SCMI specification: it can accessed and | |
320 | * modified through the accompanying macros. | |
321 | * @name: NULL-terminated string representing sensor name as advertised by | |
322 | * SCMI platform. | |
323 | * @extended_scalar_attrs: Flag to indicate the presence of additional extended | |
324 | * attributes for this sensor. | |
325 | * @sensor_power: Extended attribute representing the average power | |
326 | * consumed by the sensor in microwatts (uW) when it is active. | |
327 | * Reported here only for scalar sensors. | |
328 | * Set to 0 if not reported by this sensor. | |
329 | * @resolution: Extended attribute representing the resolution of the sensor. | |
330 | * Reported here only for scalar sensors. | |
331 | * Set to 0 if not reported by this sensor. | |
332 | * @exponent: Extended attribute representing the power-of-10 multiplier that is | |
333 | * applied to the resolution field. | |
334 | * Reported here only for scalar sensors. | |
335 | * Set to 0 if not reported by this sensor. | |
336 | * @scalar_attrs: Extended attributes representing minimum and maximum | |
337 | * measurable values by this sensor. | |
338 | * Reported here only for scalar sensors. | |
339 | * Set to 0 if not reported by this sensor. | |
340 | */ | |
5179c523 | 341 | struct scmi_sensor_info { |
1fe00b8b CM |
342 | unsigned int id; |
343 | unsigned int type; | |
344 | int scale; | |
345 | unsigned int num_trip_points; | |
d09aac0e | 346 | bool async; |
1fe00b8b CM |
347 | bool update; |
348 | bool timestamped; | |
349 | int tstamp_scale; | |
350 | unsigned int num_axis; | |
351 | struct scmi_sensor_axis_info *axis; | |
352 | struct scmi_sensor_intervals_info intervals; | |
7b83c5f4 CM |
353 | unsigned int sensor_config; |
354 | #define SCMI_SENS_CFG_UPDATE_SECS_MASK GENMASK(31, 16) | |
355 | #define SCMI_SENS_CFG_GET_UPDATE_SECS(x) \ | |
356 | FIELD_GET(SCMI_SENS_CFG_UPDATE_SECS_MASK, (x)) | |
357 | ||
358 | #define SCMI_SENS_CFG_UPDATE_EXP_MASK GENMASK(15, 11) | |
359 | #define SCMI_SENS_CFG_GET_UPDATE_EXP(x) \ | |
360 | ({ \ | |
361 | int __signed_exp = \ | |
362 | FIELD_GET(SCMI_SENS_CFG_UPDATE_EXP_MASK, (x)); \ | |
363 | \ | |
364 | if (__signed_exp & BIT(4)) \ | |
365 | __signed_exp |= GENMASK(31, 5); \ | |
366 | __signed_exp; \ | |
367 | }) | |
368 | ||
369 | #define SCMI_SENS_CFG_ROUND_MASK GENMASK(10, 9) | |
370 | #define SCMI_SENS_CFG_ROUND_AUTO 2 | |
371 | #define SCMI_SENS_CFG_ROUND_UP 1 | |
372 | #define SCMI_SENS_CFG_ROUND_DOWN 0 | |
373 | ||
374 | #define SCMI_SENS_CFG_TSTAMP_ENABLED_MASK BIT(1) | |
375 | #define SCMI_SENS_CFG_TSTAMP_ENABLE 1 | |
376 | #define SCMI_SENS_CFG_TSTAMP_DISABLE 0 | |
377 | #define SCMI_SENS_CFG_IS_TSTAMP_ENABLED(x) \ | |
378 | FIELD_GET(SCMI_SENS_CFG_TSTAMP_ENABLED_MASK, (x)) | |
379 | ||
380 | #define SCMI_SENS_CFG_SENSOR_ENABLED_MASK BIT(0) | |
381 | #define SCMI_SENS_CFG_SENSOR_ENABLE 1 | |
382 | #define SCMI_SENS_CFG_SENSOR_DISABLE 0 | |
5179c523 | 383 | char name[SCMI_MAX_STR_SIZE]; |
7b83c5f4 | 384 | #define SCMI_SENS_CFG_IS_ENABLED(x) FIELD_GET(BIT(0), (x)) |
1fe00b8b CM |
385 | bool extended_scalar_attrs; |
386 | unsigned int sensor_power; | |
387 | unsigned int resolution; | |
388 | int exponent; | |
389 | struct scmi_range_attrs scalar_attrs; | |
5179c523 SH |
390 | }; |
391 | ||
392 | /* | |
393 | * Partial list from Distributed Management Task Force (DMTF) specification: | |
394 | * DSP0249 (Platform Level Data Model specification) | |
395 | */ | |
396 | enum scmi_sensor_class { | |
397 | NONE = 0x0, | |
607a4672 | 398 | UNSPEC = 0x1, |
5179c523 | 399 | TEMPERATURE_C = 0x2, |
607a4672 SH |
400 | TEMPERATURE_F = 0x3, |
401 | TEMPERATURE_K = 0x4, | |
5179c523 SH |
402 | VOLTAGE = 0x5, |
403 | CURRENT = 0x6, | |
404 | POWER = 0x7, | |
405 | ENERGY = 0x8, | |
607a4672 SH |
406 | CHARGE = 0x9, |
407 | VOLTAMPERE = 0xA, | |
408 | NITS = 0xB, | |
409 | LUMENS = 0xC, | |
410 | LUX = 0xD, | |
411 | CANDELAS = 0xE, | |
412 | KPA = 0xF, | |
413 | PSI = 0x10, | |
414 | NEWTON = 0x11, | |
415 | CFM = 0x12, | |
416 | RPM = 0x13, | |
417 | HERTZ = 0x14, | |
418 | SECS = 0x15, | |
419 | MINS = 0x16, | |
420 | HOURS = 0x17, | |
421 | DAYS = 0x18, | |
422 | WEEKS = 0x19, | |
423 | MILS = 0x1A, | |
424 | INCHES = 0x1B, | |
425 | FEET = 0x1C, | |
426 | CUBIC_INCHES = 0x1D, | |
427 | CUBIC_FEET = 0x1E, | |
428 | METERS = 0x1F, | |
429 | CUBIC_CM = 0x20, | |
430 | CUBIC_METERS = 0x21, | |
431 | LITERS = 0x22, | |
432 | FLUID_OUNCES = 0x23, | |
433 | RADIANS = 0x24, | |
434 | STERADIANS = 0x25, | |
435 | REVOLUTIONS = 0x26, | |
436 | CYCLES = 0x27, | |
437 | GRAVITIES = 0x28, | |
438 | OUNCES = 0x29, | |
439 | POUNDS = 0x2A, | |
440 | FOOT_POUNDS = 0x2B, | |
441 | OUNCE_INCHES = 0x2C, | |
442 | GAUSS = 0x2D, | |
443 | GILBERTS = 0x2E, | |
444 | HENRIES = 0x2F, | |
445 | FARADS = 0x30, | |
446 | OHMS = 0x31, | |
447 | SIEMENS = 0x32, | |
448 | MOLES = 0x33, | |
449 | BECQUERELS = 0x34, | |
450 | PPM = 0x35, | |
451 | DECIBELS = 0x36, | |
452 | DBA = 0x37, | |
453 | DBC = 0x38, | |
454 | GRAYS = 0x39, | |
455 | SIEVERTS = 0x3A, | |
456 | COLOR_TEMP_K = 0x3B, | |
457 | BITS = 0x3C, | |
458 | BYTES = 0x3D, | |
459 | WORDS = 0x3E, | |
460 | DWORDS = 0x3F, | |
461 | QWORDS = 0x40, | |
462 | PERCENTAGE = 0x41, | |
463 | PASCALS = 0x42, | |
464 | COUNTS = 0x43, | |
465 | GRAMS = 0x44, | |
466 | NEWTON_METERS = 0x45, | |
467 | HITS = 0x46, | |
468 | MISSES = 0x47, | |
469 | RETRIES = 0x48, | |
470 | OVERRUNS = 0x49, | |
471 | UNDERRUNS = 0x4A, | |
472 | COLLISIONS = 0x4B, | |
473 | PACKETS = 0x4C, | |
474 | MESSAGES = 0x4D, | |
475 | CHARS = 0x4E, | |
476 | ERRORS = 0x4F, | |
477 | CORRECTED_ERRS = 0x50, | |
478 | UNCORRECTABLE_ERRS = 0x51, | |
479 | SQ_MILS = 0x52, | |
480 | SQ_INCHES = 0x53, | |
481 | SQ_FEET = 0x54, | |
482 | SQ_CM = 0x55, | |
483 | SQ_METERS = 0x56, | |
1fe00b8b CM |
484 | RADIANS_SEC = 0x57, |
485 | BPM = 0x58, | |
486 | METERS_SEC_SQUARED = 0x59, | |
487 | METERS_SEC = 0x5A, | |
488 | CUBIC_METERS_SEC = 0x5B, | |
489 | MM_MERCURY = 0x5C, | |
490 | RADIANS_SEC_SQUARED = 0x5D, | |
491 | OEM_UNIT = 0xFF | |
5179c523 SH |
492 | }; |
493 | ||
494 | /** | |
9694a7f6 | 495 | * struct scmi_sensor_proto_ops - represents the various operations provided |
5179c523 SH |
496 | * by SCMI Sensor Protocol |
497 | * | |
498 | * @count_get: get the count of sensors provided by SCMI | |
499 | * @info_get: get the information of the specified sensor | |
9eefa43a | 500 | * @trip_point_config: selects and configures a trip-point of interest |
5179c523 | 501 | * @reading_get: gets the current value of the sensor |
e2083d36 CM |
502 | * @reading_get_timestamped: gets the current value and timestamp, when |
503 | * available, of the sensor. (as of v3.0 spec) | |
504 | * Supports multi-axis sensors for sensors which | |
505 | * supports it and if the @reading array size of | |
506 | * @count entry equals the sensor num_axis | |
7b83c5f4 CM |
507 | * @config_get: Get sensor current configuration |
508 | * @config_set: Set sensor current configuration | |
5179c523 | 509 | */ |
9694a7f6 CM |
510 | struct scmi_sensor_proto_ops { |
511 | int (*count_get)(const struct scmi_protocol_handle *ph); | |
1ecb7d27 | 512 | const struct scmi_sensor_info __must_check *(*info_get) |
9694a7f6 CM |
513 | (const struct scmi_protocol_handle *ph, u32 sensor_id); |
514 | int (*trip_point_config)(const struct scmi_protocol_handle *ph, | |
515 | u32 sensor_id, u8 trip_id, u64 trip_value); | |
516 | int (*reading_get)(const struct scmi_protocol_handle *ph, u32 sensor_id, | |
517 | u64 *value); | |
518 | int (*reading_get_timestamped)(const struct scmi_protocol_handle *ph, | |
519 | u32 sensor_id, u8 count, | |
520 | struct scmi_sensor_reading *readings); | |
521 | int (*config_get)(const struct scmi_protocol_handle *ph, | |
522 | u32 sensor_id, u32 *sensor_config); | |
523 | int (*config_set)(const struct scmi_protocol_handle *ph, | |
524 | u32 sensor_id, u32 sensor_config); | |
525 | }; | |
526 | ||
95a15d80 | 527 | /** |
7e029344 | 528 | * struct scmi_reset_proto_ops - represents the various operations provided |
95a15d80 SH |
529 | * by SCMI Reset Protocol |
530 | * | |
531 | * @num_domains_get: get the count of reset domains provided by SCMI | |
532 | * @name_get: gets the name of a reset domain | |
533 | * @latency_get: gets the reset latency for the specified reset domain | |
534 | * @reset: resets the specified reset domain | |
535 | * @assert: explicitly assert reset signal of the specified reset domain | |
536 | * @deassert: explicitly deassert reset signal of the specified reset domain | |
537 | */ | |
7e029344 CM |
538 | struct scmi_reset_proto_ops { |
539 | int (*num_domains_get)(const struct scmi_protocol_handle *ph); | |
992be5d3 CM |
540 | const char *(*name_get)(const struct scmi_protocol_handle *ph, |
541 | u32 domain); | |
7e029344 CM |
542 | int (*latency_get)(const struct scmi_protocol_handle *ph, u32 domain); |
543 | int (*reset)(const struct scmi_protocol_handle *ph, u32 domain); | |
544 | int (*assert)(const struct scmi_protocol_handle *ph, u32 domain); | |
545 | int (*deassert)(const struct scmi_protocol_handle *ph, u32 domain); | |
546 | }; | |
547 | ||
4c74701b CM |
548 | enum scmi_voltage_level_mode { |
549 | SCMI_VOLTAGE_LEVEL_SET_AUTO, | |
550 | SCMI_VOLTAGE_LEVEL_SET_SYNC, | |
551 | }; | |
552 | ||
2add5cac CM |
553 | /** |
554 | * struct scmi_voltage_info - describe one available SCMI Voltage Domain | |
555 | * | |
556 | * @id: the domain ID as advertised by the platform | |
557 | * @segmented: defines the layout of the entries of array @levels_uv. | |
558 | * - when True the entries are to be interpreted as triplets, | |
559 | * each defining a segment representing a range of equally | |
560 | * space voltages: <lowest_volts>, <highest_volt>, <step_uV> | |
561 | * - when False the entries simply represent a single discrete | |
562 | * supported voltage level | |
563 | * @negative_volts_allowed: True if any of the entries of @levels_uv represent | |
564 | * a negative voltage. | |
4c74701b CM |
565 | * @async_level_set: True when the voltage domain supports asynchronous level |
566 | * set commands. | |
2add5cac CM |
567 | * @name: name assigned to the Voltage Domain by platform |
568 | * @num_levels: number of total entries in @levels_uv. | |
569 | * @levels_uv: array of entries describing the available voltage levels for | |
570 | * this domain. | |
571 | */ | |
572 | struct scmi_voltage_info { | |
573 | unsigned int id; | |
574 | bool segmented; | |
575 | bool negative_volts_allowed; | |
4c74701b | 576 | bool async_level_set; |
2add5cac CM |
577 | char name[SCMI_MAX_STR_SIZE]; |
578 | unsigned int num_levels; | |
579 | #define SCMI_VOLTAGE_SEGMENT_LOW 0 | |
580 | #define SCMI_VOLTAGE_SEGMENT_HIGH 1 | |
581 | #define SCMI_VOLTAGE_SEGMENT_STEP 2 | |
582 | int *levels_uv; | |
583 | }; | |
584 | ||
585 | /** | |
fe4894d9 | 586 | * struct scmi_voltage_proto_ops - represents the various operations provided |
2add5cac CM |
587 | * by SCMI Voltage Protocol |
588 | * | |
589 | * @num_domains_get: get the count of voltage domains provided by SCMI | |
590 | * @info_get: get the information of the specified domain | |
591 | * @config_set: set the config for the specified domain | |
592 | * @config_get: get the config of the specified domain | |
593 | * @level_set: set the voltage level for the specified domain | |
594 | * @level_get: get the voltage level of the specified domain | |
595 | */ | |
fe4894d9 CM |
596 | struct scmi_voltage_proto_ops { |
597 | int (*num_domains_get)(const struct scmi_protocol_handle *ph); | |
598 | const struct scmi_voltage_info __must_check *(*info_get) | |
599 | (const struct scmi_protocol_handle *ph, u32 domain_id); | |
600 | int (*config_set)(const struct scmi_protocol_handle *ph, u32 domain_id, | |
601 | u32 config); | |
602 | #define SCMI_VOLTAGE_ARCH_STATE_OFF 0x0 | |
603 | #define SCMI_VOLTAGE_ARCH_STATE_ON 0x7 | |
604 | int (*config_get)(const struct scmi_protocol_handle *ph, u32 domain_id, | |
605 | u32 *config); | |
606 | int (*level_set)(const struct scmi_protocol_handle *ph, u32 domain_id, | |
4c74701b | 607 | enum scmi_voltage_level_mode mode, s32 volt_uV); |
fe4894d9 CM |
608 | int (*level_get)(const struct scmi_protocol_handle *ph, u32 domain_id, |
609 | s32 *volt_uV); | |
610 | }; | |
611 | ||
0316f99c CM |
612 | /** |
613 | * struct scmi_powercap_info - Describe one available Powercap domain | |
614 | * | |
615 | * @id: Domain ID as advertised by the platform. | |
616 | * @notify_powercap_cap_change: CAP change notification support. | |
617 | * @notify_powercap_measurement_change: MEASUREMENTS change notifications | |
618 | * support. | |
619 | * @async_powercap_cap_set: Asynchronous CAP set support. | |
620 | * @powercap_cap_config: CAP configuration support. | |
621 | * @powercap_monitoring: Monitoring (measurements) support. | |
622 | * @powercap_pai_config: PAI configuration support. | |
623 | * @powercap_scale_mw: Domain reports power data in milliwatt units. | |
624 | * @powercap_scale_uw: Domain reports power data in microwatt units. | |
625 | * Note that, when both @powercap_scale_mw and | |
626 | * @powercap_scale_uw are set to false, the domain | |
627 | * reports power data on an abstract linear scale. | |
628 | * @name: name assigned to the Powercap Domain by platform. | |
629 | * @min_pai: Minimum configurable PAI. | |
630 | * @max_pai: Maximum configurable PAI. | |
631 | * @pai_step: Step size between two consecutive PAI values. | |
632 | * @min_power_cap: Minimum configurable CAP. | |
633 | * @max_power_cap: Maximum configurable CAP. | |
634 | * @power_cap_step: Step size between two consecutive CAP values. | |
635 | * @sustainable_power: Maximum sustainable power consumption for this domain | |
636 | * under normal conditions. | |
637 | * @accuracy: The accuracy with which the power is measured and reported in | |
638 | * integral multiples of 0.001 percent. | |
639 | * @parent_id: Identifier of the containing parent power capping domain, or the | |
640 | * value 0xFFFFFFFF if this powercap domain is a root domain not | |
641 | * contained in any other domain. | |
642 | */ | |
643 | struct scmi_powercap_info { | |
644 | unsigned int id; | |
645 | bool notify_powercap_cap_change; | |
646 | bool notify_powercap_measurement_change; | |
647 | bool async_powercap_cap_set; | |
648 | bool powercap_cap_config; | |
649 | bool powercap_monitoring; | |
650 | bool powercap_pai_config; | |
651 | bool powercap_scale_mw; | |
652 | bool powercap_scale_uw; | |
855aa26e | 653 | bool fastchannels; |
0316f99c CM |
654 | char name[SCMI_MAX_STR_SIZE]; |
655 | unsigned int min_pai; | |
656 | unsigned int max_pai; | |
657 | unsigned int pai_step; | |
658 | unsigned int min_power_cap; | |
659 | unsigned int max_power_cap; | |
660 | unsigned int power_cap_step; | |
661 | unsigned int sustainable_power; | |
662 | unsigned int accuracy; | |
663 | #define SCMI_POWERCAP_ROOT_ZONE_ID 0xFFFFFFFFUL | |
664 | unsigned int parent_id; | |
855aa26e | 665 | struct scmi_fc_info *fc_info; |
0316f99c CM |
666 | }; |
667 | ||
668 | /** | |
669 | * struct scmi_powercap_proto_ops - represents the various operations provided | |
670 | * by SCMI Powercap Protocol | |
671 | * | |
672 | * @num_domains_get: get the count of powercap domains provided by SCMI. | |
673 | * @info_get: get the information for the specified domain. | |
674 | * @cap_get: get the current CAP value for the specified domain. | |
758cd5fc CM |
675 | * On SCMI platforms supporting powercap zone disabling, this could |
676 | * report a zero value for a zone where powercapping is disabled. | |
0316f99c CM |
677 | * @cap_set: set the CAP value for the specified domain to the provided value; |
678 | * if the domain supports setting the CAP with an asynchronous command | |
679 | * this request will finally trigger an asynchronous transfer, but, if | |
680 | * @ignore_dresp here is set to true, this call will anyway return | |
681 | * immediately without waiting for the related delayed response. | |
758cd5fc CM |
682 | * Note that the powercap requested value must NOT be zero, even if |
683 | * the platform supports disabling a powercap by setting its cap to | |
684 | * zero (since SCMI v3.2): there are dedicated operations that should | |
685 | * be used for that. (@cap_enable_set/get) | |
686 | * @cap_enable_set: enable or disable the powercapping on the specified domain, | |
687 | * if supported by the SCMI platform implementation. | |
688 | * Note that, by the SCMI specification, the platform can | |
689 | * silently ignore our disable request and decide to enforce | |
690 | * anyway some other powercap value requested by another agent | |
691 | * on the system: for this reason @cap_get and @cap_enable_get | |
692 | * will always report the final platform view of the powercaps. | |
693 | * @cap_enable_get: get the current CAP enable status for the specified domain. | |
0316f99c CM |
694 | * @pai_get: get the current PAI value for the specified domain. |
695 | * @pai_set: set the PAI value for the specified domain to the provided value. | |
696 | * @measurements_get: retrieve the current average power measurements for the | |
697 | * specified domain and the related PAI upon which is | |
698 | * calculated. | |
699 | * @measurements_threshold_set: set the desired low and high power thresholds | |
700 | * to be used when registering for notification | |
701 | * of type POWERCAP_MEASUREMENTS_NOTIFY with this | |
702 | * powercap domain. | |
703 | * Note that this must be called at least once | |
704 | * before registering any callback with the usual | |
705 | * @scmi_notify_ops; moreover, in case this method | |
706 | * is called with measurement notifications already | |
707 | * enabled it will also trigger, transparently, a | |
708 | * proper update of the power thresholds configured | |
709 | * in the SCMI backend server. | |
710 | * @measurements_threshold_get: get the currently configured low and high power | |
711 | * thresholds used when registering callbacks for | |
712 | * notification POWERCAP_MEASUREMENTS_NOTIFY. | |
713 | */ | |
714 | struct scmi_powercap_proto_ops { | |
715 | int (*num_domains_get)(const struct scmi_protocol_handle *ph); | |
716 | const struct scmi_powercap_info __must_check *(*info_get) | |
717 | (const struct scmi_protocol_handle *ph, u32 domain_id); | |
718 | int (*cap_get)(const struct scmi_protocol_handle *ph, u32 domain_id, | |
719 | u32 *power_cap); | |
720 | int (*cap_set)(const struct scmi_protocol_handle *ph, u32 domain_id, | |
721 | u32 power_cap, bool ignore_dresp); | |
758cd5fc CM |
722 | int (*cap_enable_set)(const struct scmi_protocol_handle *ph, |
723 | u32 domain_id, bool enable); | |
724 | int (*cap_enable_get)(const struct scmi_protocol_handle *ph, | |
725 | u32 domain_id, bool *enable); | |
0316f99c CM |
726 | int (*pai_get)(const struct scmi_protocol_handle *ph, u32 domain_id, |
727 | u32 *pai); | |
728 | int (*pai_set)(const struct scmi_protocol_handle *ph, u32 domain_id, | |
729 | u32 pai); | |
730 | int (*measurements_get)(const struct scmi_protocol_handle *ph, | |
731 | u32 domain_id, u32 *average_power, u32 *pai); | |
732 | int (*measurements_threshold_set)(const struct scmi_protocol_handle *ph, | |
733 | u32 domain_id, u32 power_thresh_low, | |
734 | u32 power_thresh_high); | |
735 | int (*measurements_threshold_get)(const struct scmi_protocol_handle *ph, | |
736 | u32 domain_id, u32 *power_thresh_low, | |
737 | u32 *power_thresh_high); | |
738 | }; | |
739 | ||
2145af01 PF |
740 | enum scmi_pinctrl_selector_type { |
741 | PIN_TYPE = 0, | |
742 | GROUP_TYPE, | |
743 | FUNCTION_TYPE, | |
744 | }; | |
745 | ||
746 | enum scmi_pinctrl_conf_type { | |
747 | SCMI_PIN_DEFAULT = 0, | |
748 | SCMI_PIN_BIAS_BUS_HOLD = 1, | |
749 | SCMI_PIN_BIAS_DISABLE = 2, | |
750 | SCMI_PIN_BIAS_HIGH_IMPEDANCE = 3, | |
751 | SCMI_PIN_BIAS_PULL_UP = 4, | |
752 | SCMI_PIN_BIAS_PULL_DEFAULT = 5, | |
753 | SCMI_PIN_BIAS_PULL_DOWN = 6, | |
754 | SCMI_PIN_DRIVE_OPEN_DRAIN = 7, | |
755 | SCMI_PIN_DRIVE_OPEN_SOURCE = 8, | |
756 | SCMI_PIN_DRIVE_PUSH_PULL = 9, | |
757 | SCMI_PIN_DRIVE_STRENGTH = 10, | |
758 | SCMI_PIN_INPUT_DEBOUNCE = 11, | |
759 | SCMI_PIN_INPUT_MODE = 12, | |
760 | SCMI_PIN_PULL_MODE = 13, | |
761 | SCMI_PIN_INPUT_VALUE = 14, | |
762 | SCMI_PIN_INPUT_SCHMITT = 15, | |
763 | SCMI_PIN_LOW_POWER_MODE = 16, | |
764 | SCMI_PIN_OUTPUT_MODE = 17, | |
765 | SCMI_PIN_OUTPUT_VALUE = 18, | |
766 | SCMI_PIN_POWER_SOURCE = 19, | |
767 | SCMI_PIN_SLEW_RATE = 20, | |
768 | SCMI_PIN_OEM_START = 192, | |
769 | SCMI_PIN_OEM_END = 255, | |
770 | }; | |
771 | ||
772 | /** | |
773 | * struct scmi_pinctrl_proto_ops - represents the various operations provided | |
774 | * by SCMI Pinctrl Protocol | |
775 | * | |
776 | * @count_get: returns count of the registered elements in given type | |
777 | * @name_get: returns name by index of given type | |
778 | * @group_pins_get: returns the set of pins, assigned to the specified group | |
779 | * @function_groups_get: returns the set of groups, assigned to the specified | |
780 | * function | |
781 | * @mux_set: set muxing function for groups of pins | |
782 | * @settings_get_one: returns one configuration parameter for pin or group | |
783 | * specified by config_type | |
784 | * @settings_get_all: returns all configuration parameters for pin or group | |
785 | * @settings_conf: sets the configuration parameter for pin or group | |
786 | * @pin_request: aquire pin before selecting mux setting | |
787 | * @pin_free: frees pin, acquired by request_pin call | |
788 | */ | |
789 | struct scmi_pinctrl_proto_ops { | |
790 | int (*count_get)(const struct scmi_protocol_handle *ph, | |
791 | enum scmi_pinctrl_selector_type type); | |
792 | int (*name_get)(const struct scmi_protocol_handle *ph, u32 selector, | |
793 | enum scmi_pinctrl_selector_type type, | |
794 | const char **name); | |
795 | int (*group_pins_get)(const struct scmi_protocol_handle *ph, | |
796 | u32 selector, const unsigned int **pins, | |
797 | unsigned int *nr_pins); | |
798 | int (*function_groups_get)(const struct scmi_protocol_handle *ph, | |
799 | u32 selector, unsigned int *nr_groups, | |
800 | const unsigned int **groups); | |
801 | int (*mux_set)(const struct scmi_protocol_handle *ph, u32 selector, | |
802 | u32 group); | |
803 | int (*settings_get_one)(const struct scmi_protocol_handle *ph, | |
804 | u32 selector, | |
805 | enum scmi_pinctrl_selector_type type, | |
806 | enum scmi_pinctrl_conf_type config_type, | |
807 | u32 *config_value); | |
808 | int (*settings_get_all)(const struct scmi_protocol_handle *ph, | |
809 | u32 selector, | |
810 | enum scmi_pinctrl_selector_type type, | |
811 | unsigned int *nr_configs, | |
812 | enum scmi_pinctrl_conf_type *config_types, | |
813 | u32 *config_values); | |
814 | int (*settings_conf)(const struct scmi_protocol_handle *ph, | |
815 | u32 selector, enum scmi_pinctrl_selector_type type, | |
816 | unsigned int nr_configs, | |
817 | enum scmi_pinctrl_conf_type *config_type, | |
818 | u32 *config_value); | |
819 | int (*pin_request)(const struct scmi_protocol_handle *ph, u32 pin); | |
820 | int (*pin_free)(const struct scmi_protocol_handle *ph, u32 pin); | |
821 | }; | |
822 | ||
e7c215f3 CM |
823 | /** |
824 | * struct scmi_notify_ops - represents notifications' operations provided by | |
825 | * SCMI core | |
5ad3d1cf CM |
826 | * @devm_event_notifier_register: Managed registration of a notifier_block for |
827 | * the requested event | |
828 | * @devm_event_notifier_unregister: Managed unregistration of a notifier_block | |
829 | * for the requested event | |
aa1fd3e4 CM |
830 | * @event_notifier_register: Register a notifier_block for the requested event |
831 | * @event_notifier_unregister: Unregister a notifier_block for the requested | |
e7c215f3 CM |
832 | * event |
833 | * | |
834 | * A user can register/unregister its own notifier_block against the wanted | |
835 | * platform instance regarding the desired event identified by the | |
836 | * tuple: (proto_id, evt_id, src_id) using the provided register/unregister | |
837 | * interface where: | |
838 | * | |
5ad3d1cf CM |
839 | * @sdev: The scmi_device to use when calling the devres managed ops devm_ |
840 | * @handle: The handle identifying the platform instance to use, when not | |
841 | * calling the managed ops devm_ | |
e7c215f3 CM |
842 | * @proto_id: The protocol ID as in SCMI Specification |
843 | * @evt_id: The message ID of the desired event as in SCMI Specification | |
844 | * @src_id: A pointer to the desired source ID if different sources are | |
845 | * possible for the protocol (like domain_id, sensor_id...etc) | |
846 | * | |
847 | * @src_id can be provided as NULL if it simply does NOT make sense for | |
848 | * the protocol at hand, OR if the user is explicitly interested in | |
849 | * receiving notifications from ANY existent source associated to the | |
850 | * specified proto_id / evt_id. | |
851 | * | |
852 | * Received notifications are finally delivered to the registered users, | |
853 | * invoking the callback provided with the notifier_block *nb as follows: | |
854 | * | |
855 | * int user_cb(nb, evt_id, report) | |
856 | * | |
857 | * with: | |
858 | * | |
859 | * @nb: The notifier block provided by the user | |
860 | * @evt_id: The message ID of the delivered event | |
861 | * @report: A custom struct describing the specific event delivered | |
862 | */ | |
863 | struct scmi_notify_ops { | |
5ad3d1cf CM |
864 | int (*devm_event_notifier_register)(struct scmi_device *sdev, |
865 | u8 proto_id, u8 evt_id, | |
866 | const u32 *src_id, | |
867 | struct notifier_block *nb); | |
868 | int (*devm_event_notifier_unregister)(struct scmi_device *sdev, | |
5ad3d1cf | 869 | struct notifier_block *nb); |
aa1fd3e4 | 870 | int (*event_notifier_register)(const struct scmi_handle *handle, |
5ad3d1cf CM |
871 | u8 proto_id, u8 evt_id, |
872 | const u32 *src_id, | |
e7c215f3 | 873 | struct notifier_block *nb); |
aa1fd3e4 | 874 | int (*event_notifier_unregister)(const struct scmi_handle *handle, |
5ad3d1cf CM |
875 | u8 proto_id, u8 evt_id, |
876 | const u32 *src_id, | |
e7c215f3 CM |
877 | struct notifier_block *nb); |
878 | }; | |
879 | ||
aa4f886f SH |
880 | /** |
881 | * struct scmi_handle - Handle returned to ARM SCMI clients for usage. | |
882 | * | |
883 | * @dev: pointer to the SCMI device | |
b6f20ff8 | 884 | * @version: pointer to the structure containing SCMI version information |
d9107999 CM |
885 | * @devm_protocol_acquire: devres managed method to get hold of a protocol, |
886 | * causing its initialization and related resource | |
887 | * accounting | |
23934efe CM |
888 | * @devm_protocol_get: devres managed method to acquire a protocol and get specific |
889 | * operations and a dedicated protocol handler | |
890 | * @devm_protocol_put: devres managed method to release a protocol | |
69255e74 CM |
891 | * @is_transport_atomic: method to check if the underlying transport for this |
892 | * instance handle is configured to support atomic | |
893 | * transactions for commands. | |
894 | * Some users of the SCMI stack in the upper layers could | |
895 | * be interested to know if they can assume SCMI | |
896 | * command transactions associated to this handle will | |
897 | * never sleep and act accordingly. | |
05976c5f CM |
898 | * An optional atomic threshold value could be returned |
899 | * where configured. | |
e7c215f3 | 900 | * @notify_ops: pointer to set of notifications related operations |
aa4f886f SH |
901 | */ |
902 | struct scmi_handle { | |
903 | struct device *dev; | |
b6f20ff8 | 904 | struct scmi_revision_info *version; |
23934efe | 905 | |
d9107999 CM |
906 | int __must_check (*devm_protocol_acquire)(struct scmi_device *sdev, |
907 | u8 proto); | |
23934efe CM |
908 | const void __must_check * |
909 | (*devm_protocol_get)(struct scmi_device *sdev, u8 proto, | |
910 | struct scmi_protocol_handle **ph); | |
911 | void (*devm_protocol_put)(struct scmi_device *sdev, u8 proto); | |
05976c5f CM |
912 | bool (*is_transport_atomic)(const struct scmi_handle *handle, |
913 | unsigned int *atomic_threshold); | |
23934efe | 914 | |
82894c1d | 915 | const struct scmi_notify_ops *notify_ops; |
b6f20ff8 SH |
916 | }; |
917 | ||
918 | enum scmi_std_protocol { | |
919 | SCMI_PROTOCOL_BASE = 0x10, | |
920 | SCMI_PROTOCOL_POWER = 0x11, | |
921 | SCMI_PROTOCOL_SYSTEM = 0x12, | |
922 | SCMI_PROTOCOL_PERF = 0x13, | |
923 | SCMI_PROTOCOL_CLOCK = 0x14, | |
924 | SCMI_PROTOCOL_SENSOR = 0x15, | |
95a15d80 | 925 | SCMI_PROTOCOL_RESET = 0x16, |
2add5cac | 926 | SCMI_PROTOCOL_VOLTAGE = 0x17, |
0316f99c | 927 | SCMI_PROTOCOL_POWERCAP = 0x18, |
2145af01 | 928 | SCMI_PROTOCOL_PINCTRL = 0x19, |
aa4f886f | 929 | }; |
933c5044 | 930 | |
a8803055 CM |
931 | enum scmi_system_events { |
932 | SCMI_SYSTEM_SHUTDOWN, | |
933 | SCMI_SYSTEM_COLDRESET, | |
934 | SCMI_SYSTEM_WARMRESET, | |
935 | SCMI_SYSTEM_POWERUP, | |
936 | SCMI_SYSTEM_SUSPEND, | |
937 | SCMI_SYSTEM_MAX | |
938 | }; | |
939 | ||
933c5044 SH |
940 | struct scmi_device { |
941 | u32 id; | |
942 | u8 protocol_id; | |
ee7a9c9f | 943 | const char *name; |
933c5044 SH |
944 | struct device dev; |
945 | struct scmi_handle *handle; | |
946 | }; | |
947 | ||
948 | #define to_scmi_dev(d) container_of(d, struct scmi_device, dev) | |
949 | ||
933c5044 SH |
950 | struct scmi_device_id { |
951 | u8 protocol_id; | |
ee7a9c9f | 952 | const char *name; |
933c5044 SH |
953 | }; |
954 | ||
955 | struct scmi_driver { | |
956 | const char *name; | |
957 | int (*probe)(struct scmi_device *sdev); | |
958 | void (*remove)(struct scmi_device *sdev); | |
959 | const struct scmi_device_id *id_table; | |
960 | ||
961 | struct device_driver driver; | |
962 | }; | |
963 | ||
964 | #define to_scmi_driver(d) container_of(d, struct scmi_driver, driver) | |
965 | ||
66d90f6e | 966 | #if IS_REACHABLE(CONFIG_ARM_SCMI_PROTOCOL) |
933c5044 SH |
967 | int scmi_driver_register(struct scmi_driver *driver, |
968 | struct module *owner, const char *mod_name); | |
969 | void scmi_driver_unregister(struct scmi_driver *driver); | |
970 | #else | |
971 | static inline int | |
972 | scmi_driver_register(struct scmi_driver *driver, struct module *owner, | |
973 | const char *mod_name) | |
974 | { | |
975 | return -EINVAL; | |
976 | } | |
977 | ||
978 | static inline void scmi_driver_unregister(struct scmi_driver *driver) {} | |
979 | #endif /* CONFIG_ARM_SCMI_PROTOCOL */ | |
980 | ||
981 | #define scmi_register(driver) \ | |
982 | scmi_driver_register(driver, THIS_MODULE, KBUILD_MODNAME) | |
983 | #define scmi_unregister(driver) \ | |
984 | scmi_driver_unregister(driver) | |
985 | ||
986 | /** | |
987 | * module_scmi_driver() - Helper macro for registering a scmi driver | |
988 | * @__scmi_driver: scmi_driver structure | |
989 | * | |
990 | * Helper macro for scmi drivers to set up proper module init / exit | |
991 | * functions. Replaces module_init() and module_exit() and keeps people from | |
992 | * printing pointless things to the kernel log when their driver is loaded. | |
993 | */ | |
994 | #define module_scmi_driver(__scmi_driver) \ | |
995 | module_driver(__scmi_driver, scmi_register, scmi_unregister) | |
996 | ||
f5800e0b CM |
997 | /** |
998 | * module_scmi_protocol() - Helper macro for registering a scmi protocol | |
999 | * @__scmi_protocol: scmi_protocol structure | |
1000 | * | |
1001 | * Helper macro for scmi drivers to set up proper module init / exit | |
1002 | * functions. Replaces module_init() and module_exit() and keeps people from | |
1003 | * printing pointless things to the kernel log when their driver is loaded. | |
1004 | */ | |
1005 | #define module_scmi_protocol(__scmi_protocol) \ | |
1006 | module_driver(__scmi_protocol, \ | |
1007 | scmi_protocol_register, scmi_protocol_unregister) | |
1008 | ||
48dc16e2 CM |
1009 | struct scmi_protocol; |
1010 | int scmi_protocol_register(const struct scmi_protocol *proto); | |
1011 | void scmi_protocol_unregister(const struct scmi_protocol *proto); | |
70771c69 | 1012 | |
e27077bc CM |
1013 | /* SCMI Notification API - Custom Event Reports */ |
1014 | enum scmi_notification_events { | |
1015 | SCMI_EVENT_POWER_STATE_CHANGED = 0x0, | |
7aa75496 CM |
1016 | SCMI_EVENT_CLOCK_RATE_CHANGED = 0x0, |
1017 | SCMI_EVENT_CLOCK_RATE_CHANGE_REQUESTED = 0x1, | |
fb5086dc CM |
1018 | SCMI_EVENT_PERFORMANCE_LIMITS_CHANGED = 0x0, |
1019 | SCMI_EVENT_PERFORMANCE_LEVEL_CHANGED = 0x1, | |
128e3e93 | 1020 | SCMI_EVENT_SENSOR_TRIP_POINT_EVENT = 0x0, |
e3811190 | 1021 | SCMI_EVENT_SENSOR_UPDATE = 0x1, |
469ca182 | 1022 | SCMI_EVENT_RESET_ISSUED = 0x0, |
585dfab3 | 1023 | SCMI_EVENT_BASE_ERROR_EVENT = 0x0, |
a8803055 | 1024 | SCMI_EVENT_SYSTEM_POWER_STATE_NOTIFIER = 0x0, |
0316f99c CM |
1025 | SCMI_EVENT_POWERCAP_CAP_CHANGED = 0x0, |
1026 | SCMI_EVENT_POWERCAP_MEASUREMENTS_CHANGED = 0x1, | |
e27077bc CM |
1027 | }; |
1028 | ||
1029 | struct scmi_power_state_changed_report { | |
72a5eb9d CM |
1030 | ktime_t timestamp; |
1031 | unsigned int agent_id; | |
1032 | unsigned int domain_id; | |
1033 | unsigned int power_state; | |
e27077bc CM |
1034 | }; |
1035 | ||
7aa75496 CM |
1036 | struct scmi_clock_rate_notif_report { |
1037 | ktime_t timestamp; | |
1038 | unsigned int agent_id; | |
1039 | unsigned int clock_id; | |
1040 | unsigned long long rate; | |
1041 | }; | |
1042 | ||
a8803055 CM |
1043 | struct scmi_system_power_state_notifier_report { |
1044 | ktime_t timestamp; | |
1045 | unsigned int agent_id; | |
7097f298 | 1046 | #define SCMI_SYSPOWER_IS_REQUEST_GRACEFUL(flags) ((flags) & BIT(0)) |
a8803055 CM |
1047 | unsigned int flags; |
1048 | unsigned int system_state; | |
7097f298 | 1049 | unsigned int timeout; |
a8803055 CM |
1050 | }; |
1051 | ||
fb5086dc | 1052 | struct scmi_perf_limits_report { |
72a5eb9d CM |
1053 | ktime_t timestamp; |
1054 | unsigned int agent_id; | |
1055 | unsigned int domain_id; | |
1056 | unsigned int range_max; | |
1057 | unsigned int range_min; | |
22ffc748 CM |
1058 | unsigned long range_max_freq; |
1059 | unsigned long range_min_freq; | |
fb5086dc CM |
1060 | }; |
1061 | ||
1062 | struct scmi_perf_level_report { | |
72a5eb9d CM |
1063 | ktime_t timestamp; |
1064 | unsigned int agent_id; | |
1065 | unsigned int domain_id; | |
1066 | unsigned int performance_level; | |
22ffc748 | 1067 | unsigned long performance_level_freq; |
fb5086dc CM |
1068 | }; |
1069 | ||
128e3e93 | 1070 | struct scmi_sensor_trip_point_report { |
72a5eb9d CM |
1071 | ktime_t timestamp; |
1072 | unsigned int agent_id; | |
1073 | unsigned int sensor_id; | |
1074 | unsigned int trip_point_desc; | |
128e3e93 CM |
1075 | }; |
1076 | ||
e3811190 CM |
1077 | struct scmi_sensor_update_report { |
1078 | ktime_t timestamp; | |
1079 | unsigned int agent_id; | |
1080 | unsigned int sensor_id; | |
1081 | unsigned int readings_count; | |
1082 | struct scmi_sensor_reading readings[]; | |
1083 | }; | |
1084 | ||
469ca182 | 1085 | struct scmi_reset_issued_report { |
72a5eb9d CM |
1086 | ktime_t timestamp; |
1087 | unsigned int agent_id; | |
1088 | unsigned int domain_id; | |
1089 | unsigned int reset_state; | |
469ca182 CM |
1090 | }; |
1091 | ||
585dfab3 | 1092 | struct scmi_base_error_report { |
72a5eb9d CM |
1093 | ktime_t timestamp; |
1094 | unsigned int agent_id; | |
1095 | bool fatal; | |
1096 | unsigned int cmd_count; | |
1097 | unsigned long long reports[]; | |
585dfab3 CM |
1098 | }; |
1099 | ||
0316f99c CM |
1100 | struct scmi_powercap_cap_changed_report { |
1101 | ktime_t timestamp; | |
1102 | unsigned int agent_id; | |
1103 | unsigned int domain_id; | |
1104 | unsigned int power_cap; | |
1105 | unsigned int pai; | |
1106 | }; | |
1107 | ||
1108 | struct scmi_powercap_meas_changed_report { | |
1109 | ktime_t timestamp; | |
1110 | unsigned int agent_id; | |
1111 | unsigned int domain_id; | |
1112 | unsigned int power; | |
1113 | }; | |
70771c69 | 1114 | #endif /* _LINUX_SCMI_PROTOCOL_H */ |