firmware: arm_scmi: Add SCMI v3.0 sensors timestamped reads
[linux-2.6-microblaze.git] / include / linux / scmi_protocol.h
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * SCMI Message Protocol driver header
4  *
5  * Copyright (C) 2018 ARM Ltd.
6  */
7
8 #ifndef _LINUX_SCMI_PROTOCOL_H
9 #define _LINUX_SCMI_PROTOCOL_H
10
11 #include <linux/bitfield.h>
12 #include <linux/device.h>
13 #include <linux/notifier.h>
14 #include <linux/types.h>
15
16 #define SCMI_MAX_STR_SIZE       16
17 #define SCMI_MAX_NUM_RATES      16
18
19 /**
20  * struct scmi_revision_info - version information structure
21  *
22  * @major_ver: Major ABI version. Change here implies risk of backward
23  *      compatibility break.
24  * @minor_ver: Minor ABI version. Change here implies new feature addition,
25  *      or compatible change in ABI.
26  * @num_protocols: Number of protocols that are implemented, excluding the
27  *      base protocol.
28  * @num_agents: Number of agents in the system.
29  * @impl_ver: A vendor-specific implementation version.
30  * @vendor_id: A vendor identifier(Null terminated ASCII string)
31  * @sub_vendor_id: A sub-vendor identifier(Null terminated ASCII string)
32  */
33 struct scmi_revision_info {
34         u16 major_ver;
35         u16 minor_ver;
36         u8 num_protocols;
37         u8 num_agents;
38         u32 impl_ver;
39         char vendor_id[SCMI_MAX_STR_SIZE];
40         char sub_vendor_id[SCMI_MAX_STR_SIZE];
41 };
42
43 struct scmi_clock_info {
44         char name[SCMI_MAX_STR_SIZE];
45         bool rate_discrete;
46         union {
47                 struct {
48                         int num_rates;
49                         u64 rates[SCMI_MAX_NUM_RATES];
50                 } list;
51                 struct {
52                         u64 min_rate;
53                         u64 max_rate;
54                         u64 step_size;
55                 } range;
56         };
57 };
58
59 struct scmi_handle;
60
61 /**
62  * struct scmi_clk_ops - represents the various operations provided
63  *      by SCMI Clock Protocol
64  *
65  * @count_get: get the count of clocks provided by SCMI
66  * @info_get: get the information of the specified clock
67  * @rate_get: request the current clock rate of a clock
68  * @rate_set: set the clock rate of a clock
69  * @enable: enables the specified clock
70  * @disable: disables the specified clock
71  */
72 struct scmi_clk_ops {
73         int (*count_get)(const struct scmi_handle *handle);
74
75         const struct scmi_clock_info *(*info_get)
76                 (const struct scmi_handle *handle, u32 clk_id);
77         int (*rate_get)(const struct scmi_handle *handle, u32 clk_id,
78                         u64 *rate);
79         int (*rate_set)(const struct scmi_handle *handle, u32 clk_id,
80                         u64 rate);
81         int (*enable)(const struct scmi_handle *handle, u32 clk_id);
82         int (*disable)(const struct scmi_handle *handle, u32 clk_id);
83 };
84
85 /**
86  * struct scmi_perf_ops - represents the various operations provided
87  *      by SCMI Performance Protocol
88  *
89  * @limits_set: sets limits on the performance level of a domain
90  * @limits_get: gets limits on the performance level of a domain
91  * @level_set: sets the performance level of a domain
92  * @level_get: gets the performance level of a domain
93  * @device_domain_id: gets the scmi domain id for a given device
94  * @transition_latency_get: gets the DVFS transition latency for a given device
95  * @device_opps_add: adds all the OPPs for a given device
96  * @freq_set: sets the frequency for a given device using sustained frequency
97  *      to sustained performance level mapping
98  * @freq_get: gets the frequency for a given device using sustained frequency
99  *      to sustained performance level mapping
100  * @est_power_get: gets the estimated power cost for a given performance domain
101  *      at a given frequency
102  */
103 struct scmi_perf_ops {
104         int (*limits_set)(const struct scmi_handle *handle, u32 domain,
105                           u32 max_perf, u32 min_perf);
106         int (*limits_get)(const struct scmi_handle *handle, u32 domain,
107                           u32 *max_perf, u32 *min_perf);
108         int (*level_set)(const struct scmi_handle *handle, u32 domain,
109                          u32 level, bool poll);
110         int (*level_get)(const struct scmi_handle *handle, u32 domain,
111                          u32 *level, bool poll);
112         int (*device_domain_id)(struct device *dev);
113         int (*transition_latency_get)(const struct scmi_handle *handle,
114                                       struct device *dev);
115         int (*device_opps_add)(const struct scmi_handle *handle,
116                                struct device *dev);
117         int (*freq_set)(const struct scmi_handle *handle, u32 domain,
118                         unsigned long rate, bool poll);
119         int (*freq_get)(const struct scmi_handle *handle, u32 domain,
120                         unsigned long *rate, bool poll);
121         int (*est_power_get)(const struct scmi_handle *handle, u32 domain,
122                              unsigned long *rate, unsigned long *power);
123         bool (*fast_switch_possible)(const struct scmi_handle *handle,
124                                      struct device *dev);
125 };
126
127 /**
128  * struct scmi_power_ops - represents the various operations provided
129  *      by SCMI Power Protocol
130  *
131  * @num_domains_get: get the count of power domains provided by SCMI
132  * @name_get: gets the name of a power domain
133  * @state_set: sets the power state of a power domain
134  * @state_get: gets the power state of a power domain
135  */
136 struct scmi_power_ops {
137         int (*num_domains_get)(const struct scmi_handle *handle);
138         char *(*name_get)(const struct scmi_handle *handle, u32 domain);
139 #define SCMI_POWER_STATE_TYPE_SHIFT     30
140 #define SCMI_POWER_STATE_ID_MASK        (BIT(28) - 1)
141 #define SCMI_POWER_STATE_PARAM(type, id) \
142         ((((type) & BIT(0)) << SCMI_POWER_STATE_TYPE_SHIFT) | \
143                 ((id) & SCMI_POWER_STATE_ID_MASK))
144 #define SCMI_POWER_STATE_GENERIC_ON     SCMI_POWER_STATE_PARAM(0, 0)
145 #define SCMI_POWER_STATE_GENERIC_OFF    SCMI_POWER_STATE_PARAM(1, 0)
146         int (*state_set)(const struct scmi_handle *handle, u32 domain,
147                          u32 state);
148         int (*state_get)(const struct scmi_handle *handle, u32 domain,
149                          u32 *state);
150 };
151
152 /**
153  * scmi_sensor_reading  - represent a timestamped read
154  *
155  * Used by @reading_get_timestamped method.
156  *
157  * @value: The signed value sensor read.
158  * @timestamp: An unsigned timestamp for the sensor read, as provided by
159  *             SCMI platform. Set to zero when not available.
160  */
161 struct scmi_sensor_reading {
162         long long value;
163         unsigned long long timestamp;
164 };
165
166 /**
167  * scmi_range_attrs  - specifies a sensor or axis values' range
168  * @min_range: The minimum value which can be represented by the sensor/axis.
169  * @max_range: The maximum value which can be represented by the sensor/axis.
170  */
171 struct scmi_range_attrs {
172         long long min_range;
173         long long max_range;
174 };
175
176 /**
177  * scmi_sensor_axis_info  - describes one sensor axes
178  * @id: The axes ID.
179  * @type: Axes type. Chosen amongst one of @enum scmi_sensor_class.
180  * @scale: Power-of-10 multiplier applied to the axis unit.
181  * @name: NULL-terminated string representing axes name as advertised by
182  *        SCMI platform.
183  * @extended_attrs: Flag to indicate the presence of additional extended
184  *                  attributes for this axes.
185  * @resolution: Extended attribute representing the resolution of the axes.
186  *              Set to 0 if not reported by this axes.
187  * @exponent: Extended attribute representing the power-of-10 multiplier that
188  *            is applied to the resolution field. Set to 0 if not reported by
189  *            this axes.
190  * @attrs: Extended attributes representing minimum and maximum values
191  *         measurable by this axes. Set to 0 if not reported by this sensor.
192  */
193 struct scmi_sensor_axis_info {
194         unsigned int id;
195         unsigned int type;
196         int scale;
197         char name[SCMI_MAX_STR_SIZE];
198         bool extended_attrs;
199         unsigned int resolution;
200         int exponent;
201         struct scmi_range_attrs attrs;
202 };
203
204 /**
205  * scmi_sensor_intervals_info  - describes number and type of available update
206  * intervals
207  * @segmented: Flag for segmented intervals' representation. When True there
208  *             will be exactly 3 intervals in @desc, with each entry
209  *             representing a member of a segment in this order:
210  *             {lowest update interval, highest update interval, step size}
211  * @count: Number of intervals described in @desc.
212  * @desc: Array of @count interval descriptor bitmask represented as detailed in
213  *        the SCMI specification: it can be accessed using the accompanying
214  *        macros.
215  * @prealloc_pool: A minimal preallocated pool of desc entries used to avoid
216  *                 lesser-than-64-bytes dynamic allocation for small @count
217  *                 values.
218  */
219 struct scmi_sensor_intervals_info {
220         bool segmented;
221         unsigned int count;
222 #define SCMI_SENS_INTVL_SEGMENT_LOW     0
223 #define SCMI_SENS_INTVL_SEGMENT_HIGH    1
224 #define SCMI_SENS_INTVL_SEGMENT_STEP    2
225         unsigned int *desc;
226 #define SCMI_SENS_INTVL_GET_SECS(x)             FIELD_GET(GENMASK(20, 5), (x))
227 #define SCMI_SENS_INTVL_GET_EXP(x)                                      \
228         ({                                                              \
229                 int __signed_exp = FIELD_GET(GENMASK(4, 0), (x));       \
230                                                                         \
231                 if (__signed_exp & BIT(4))                              \
232                         __signed_exp |= GENMASK(31, 5);                 \
233                 __signed_exp;                                           \
234         })
235 #define SCMI_MAX_PREALLOC_POOL                  16
236         unsigned int prealloc_pool[SCMI_MAX_PREALLOC_POOL];
237 };
238
239 /**
240  * struct scmi_sensor_info - represents information related to one of the
241  * available sensors.
242  * @id: Sensor ID.
243  * @type: Sensor type. Chosen amongst one of @enum scmi_sensor_class.
244  * @scale: Power-of-10 multiplier applied to the sensor unit.
245  * @num_trip_points: Number of maximum configurable trip points.
246  * @async: Flag for asynchronous read support.
247  * @update: Flag for continuouos update notification support.
248  * @timestamped: Flag for timestamped read support.
249  * @tstamp_scale: Power-of-10 multiplier applied to the sensor timestamps to
250  *                represent it in seconds.
251  * @num_axis: Number of supported axis if any. Reported as 0 for scalar sensors.
252  * @axis: Pointer to an array of @num_axis descriptors.
253  * @intervals: Descriptor of available update intervals.
254  * @sensor_config: A bitmask reporting the current sensor configuration as
255  *                 detailed in the SCMI specification: it can accessed and
256  *                 modified through the accompanying macros.
257  * @name: NULL-terminated string representing sensor name as advertised by
258  *        SCMI platform.
259  * @extended_scalar_attrs: Flag to indicate the presence of additional extended
260  *                         attributes for this sensor.
261  * @sensor_power: Extended attribute representing the average power
262  *                consumed by the sensor in microwatts (uW) when it is active.
263  *                Reported here only for scalar sensors.
264  *                Set to 0 if not reported by this sensor.
265  * @resolution: Extended attribute representing the resolution of the sensor.
266  *              Reported here only for scalar sensors.
267  *              Set to 0 if not reported by this sensor.
268  * @exponent: Extended attribute representing the power-of-10 multiplier that is
269  *            applied to the resolution field.
270  *            Reported here only for scalar sensors.
271  *            Set to 0 if not reported by this sensor.
272  * @scalar_attrs: Extended attributes representing minimum and maximum
273  *                measurable values by this sensor.
274  *                Reported here only for scalar sensors.
275  *                Set to 0 if not reported by this sensor.
276  */
277 struct scmi_sensor_info {
278         unsigned int id;
279         unsigned int type;
280         int scale;
281         unsigned int num_trip_points;
282         bool async;
283         bool update;
284         bool timestamped;
285         int tstamp_scale;
286         unsigned int num_axis;
287         struct scmi_sensor_axis_info *axis;
288         struct scmi_sensor_intervals_info intervals;
289         char name[SCMI_MAX_STR_SIZE];
290         bool extended_scalar_attrs;
291         unsigned int sensor_power;
292         unsigned int resolution;
293         int exponent;
294         struct scmi_range_attrs scalar_attrs;
295 };
296
297 /*
298  * Partial list from Distributed Management Task Force (DMTF) specification:
299  * DSP0249 (Platform Level Data Model specification)
300  */
301 enum scmi_sensor_class {
302         NONE = 0x0,
303         UNSPEC = 0x1,
304         TEMPERATURE_C = 0x2,
305         TEMPERATURE_F = 0x3,
306         TEMPERATURE_K = 0x4,
307         VOLTAGE = 0x5,
308         CURRENT = 0x6,
309         POWER = 0x7,
310         ENERGY = 0x8,
311         CHARGE = 0x9,
312         VOLTAMPERE = 0xA,
313         NITS = 0xB,
314         LUMENS = 0xC,
315         LUX = 0xD,
316         CANDELAS = 0xE,
317         KPA = 0xF,
318         PSI = 0x10,
319         NEWTON = 0x11,
320         CFM = 0x12,
321         RPM = 0x13,
322         HERTZ = 0x14,
323         SECS = 0x15,
324         MINS = 0x16,
325         HOURS = 0x17,
326         DAYS = 0x18,
327         WEEKS = 0x19,
328         MILS = 0x1A,
329         INCHES = 0x1B,
330         FEET = 0x1C,
331         CUBIC_INCHES = 0x1D,
332         CUBIC_FEET = 0x1E,
333         METERS = 0x1F,
334         CUBIC_CM = 0x20,
335         CUBIC_METERS = 0x21,
336         LITERS = 0x22,
337         FLUID_OUNCES = 0x23,
338         RADIANS = 0x24,
339         STERADIANS = 0x25,
340         REVOLUTIONS = 0x26,
341         CYCLES = 0x27,
342         GRAVITIES = 0x28,
343         OUNCES = 0x29,
344         POUNDS = 0x2A,
345         FOOT_POUNDS = 0x2B,
346         OUNCE_INCHES = 0x2C,
347         GAUSS = 0x2D,
348         GILBERTS = 0x2E,
349         HENRIES = 0x2F,
350         FARADS = 0x30,
351         OHMS = 0x31,
352         SIEMENS = 0x32,
353         MOLES = 0x33,
354         BECQUERELS = 0x34,
355         PPM = 0x35,
356         DECIBELS = 0x36,
357         DBA = 0x37,
358         DBC = 0x38,
359         GRAYS = 0x39,
360         SIEVERTS = 0x3A,
361         COLOR_TEMP_K = 0x3B,
362         BITS = 0x3C,
363         BYTES = 0x3D,
364         WORDS = 0x3E,
365         DWORDS = 0x3F,
366         QWORDS = 0x40,
367         PERCENTAGE = 0x41,
368         PASCALS = 0x42,
369         COUNTS = 0x43,
370         GRAMS = 0x44,
371         NEWTON_METERS = 0x45,
372         HITS = 0x46,
373         MISSES = 0x47,
374         RETRIES = 0x48,
375         OVERRUNS = 0x49,
376         UNDERRUNS = 0x4A,
377         COLLISIONS = 0x4B,
378         PACKETS = 0x4C,
379         MESSAGES = 0x4D,
380         CHARS = 0x4E,
381         ERRORS = 0x4F,
382         CORRECTED_ERRS = 0x50,
383         UNCORRECTABLE_ERRS = 0x51,
384         SQ_MILS = 0x52,
385         SQ_INCHES = 0x53,
386         SQ_FEET = 0x54,
387         SQ_CM = 0x55,
388         SQ_METERS = 0x56,
389         RADIANS_SEC = 0x57,
390         BPM = 0x58,
391         METERS_SEC_SQUARED = 0x59,
392         METERS_SEC = 0x5A,
393         CUBIC_METERS_SEC = 0x5B,
394         MM_MERCURY = 0x5C,
395         RADIANS_SEC_SQUARED = 0x5D,
396         OEM_UNIT = 0xFF
397 };
398
399 /**
400  * struct scmi_sensor_ops - represents the various operations provided
401  *      by SCMI Sensor Protocol
402  *
403  * @count_get: get the count of sensors provided by SCMI
404  * @info_get: get the information of the specified sensor
405  * @trip_point_config: selects and configures a trip-point of interest
406  * @reading_get: gets the current value of the sensor
407  * @reading_get_timestamped: gets the current value and timestamp, when
408  *                           available, of the sensor. (as of v3.0 spec)
409  *                           Supports multi-axis sensors for sensors which
410  *                           supports it and if the @reading array size of
411  *                           @count entry equals the sensor num_axis
412  */
413 struct scmi_sensor_ops {
414         int (*count_get)(const struct scmi_handle *handle);
415         const struct scmi_sensor_info *(*info_get)
416                 (const struct scmi_handle *handle, u32 sensor_id);
417         int (*trip_point_config)(const struct scmi_handle *handle,
418                                  u32 sensor_id, u8 trip_id, u64 trip_value);
419         int (*reading_get)(const struct scmi_handle *handle, u32 sensor_id,
420                            u64 *value);
421         int (*reading_get_timestamped)(const struct scmi_handle *handle,
422                                        u32 sensor_id, u8 count,
423                                        struct scmi_sensor_reading *readings);
424 };
425
426 /**
427  * struct scmi_reset_ops - represents the various operations provided
428  *      by SCMI Reset Protocol
429  *
430  * @num_domains_get: get the count of reset domains provided by SCMI
431  * @name_get: gets the name of a reset domain
432  * @latency_get: gets the reset latency for the specified reset domain
433  * @reset: resets the specified reset domain
434  * @assert: explicitly assert reset signal of the specified reset domain
435  * @deassert: explicitly deassert reset signal of the specified reset domain
436  */
437 struct scmi_reset_ops {
438         int (*num_domains_get)(const struct scmi_handle *handle);
439         char *(*name_get)(const struct scmi_handle *handle, u32 domain);
440         int (*latency_get)(const struct scmi_handle *handle, u32 domain);
441         int (*reset)(const struct scmi_handle *handle, u32 domain);
442         int (*assert)(const struct scmi_handle *handle, u32 domain);
443         int (*deassert)(const struct scmi_handle *handle, u32 domain);
444 };
445
446 /**
447  * struct scmi_notify_ops  - represents notifications' operations provided by
448  * SCMI core
449  * @register_event_notifier: Register a notifier_block for the requested event
450  * @unregister_event_notifier: Unregister a notifier_block for the requested
451  *                             event
452  *
453  * A user can register/unregister its own notifier_block against the wanted
454  * platform instance regarding the desired event identified by the
455  * tuple: (proto_id, evt_id, src_id) using the provided register/unregister
456  * interface where:
457  *
458  * @handle: The handle identifying the platform instance to use
459  * @proto_id: The protocol ID as in SCMI Specification
460  * @evt_id: The message ID of the desired event as in SCMI Specification
461  * @src_id: A pointer to the desired source ID if different sources are
462  *          possible for the protocol (like domain_id, sensor_id...etc)
463  *
464  * @src_id can be provided as NULL if it simply does NOT make sense for
465  * the protocol at hand, OR if the user is explicitly interested in
466  * receiving notifications from ANY existent source associated to the
467  * specified proto_id / evt_id.
468  *
469  * Received notifications are finally delivered to the registered users,
470  * invoking the callback provided with the notifier_block *nb as follows:
471  *
472  *      int user_cb(nb, evt_id, report)
473  *
474  * with:
475  *
476  * @nb: The notifier block provided by the user
477  * @evt_id: The message ID of the delivered event
478  * @report: A custom struct describing the specific event delivered
479  */
480 struct scmi_notify_ops {
481         int (*register_event_notifier)(const struct scmi_handle *handle,
482                                        u8 proto_id, u8 evt_id, u32 *src_id,
483                                        struct notifier_block *nb);
484         int (*unregister_event_notifier)(const struct scmi_handle *handle,
485                                          u8 proto_id, u8 evt_id, u32 *src_id,
486                                          struct notifier_block *nb);
487 };
488
489 /**
490  * struct scmi_handle - Handle returned to ARM SCMI clients for usage.
491  *
492  * @dev: pointer to the SCMI device
493  * @version: pointer to the structure containing SCMI version information
494  * @power_ops: pointer to set of power protocol operations
495  * @perf_ops: pointer to set of performance protocol operations
496  * @clk_ops: pointer to set of clock protocol operations
497  * @sensor_ops: pointer to set of sensor protocol operations
498  * @reset_ops: pointer to set of reset protocol operations
499  * @notify_ops: pointer to set of notifications related operations
500  * @perf_priv: pointer to private data structure specific to performance
501  *      protocol(for internal use only)
502  * @clk_priv: pointer to private data structure specific to clock
503  *      protocol(for internal use only)
504  * @power_priv: pointer to private data structure specific to power
505  *      protocol(for internal use only)
506  * @sensor_priv: pointer to private data structure specific to sensors
507  *      protocol(for internal use only)
508  * @reset_priv: pointer to private data structure specific to reset
509  *      protocol(for internal use only)
510  * @notify_priv: pointer to private data structure specific to notifications
511  *      (for internal use only)
512  */
513 struct scmi_handle {
514         struct device *dev;
515         struct scmi_revision_info *version;
516         const struct scmi_perf_ops *perf_ops;
517         const struct scmi_clk_ops *clk_ops;
518         const struct scmi_power_ops *power_ops;
519         const struct scmi_sensor_ops *sensor_ops;
520         const struct scmi_reset_ops *reset_ops;
521         const struct scmi_notify_ops *notify_ops;
522         /* for protocol internal use */
523         void *perf_priv;
524         void *clk_priv;
525         void *power_priv;
526         void *sensor_priv;
527         void *reset_priv;
528         void *notify_priv;
529         void *system_priv;
530 };
531
532 enum scmi_std_protocol {
533         SCMI_PROTOCOL_BASE = 0x10,
534         SCMI_PROTOCOL_POWER = 0x11,
535         SCMI_PROTOCOL_SYSTEM = 0x12,
536         SCMI_PROTOCOL_PERF = 0x13,
537         SCMI_PROTOCOL_CLOCK = 0x14,
538         SCMI_PROTOCOL_SENSOR = 0x15,
539         SCMI_PROTOCOL_RESET = 0x16,
540 };
541
542 enum scmi_system_events {
543         SCMI_SYSTEM_SHUTDOWN,
544         SCMI_SYSTEM_COLDRESET,
545         SCMI_SYSTEM_WARMRESET,
546         SCMI_SYSTEM_POWERUP,
547         SCMI_SYSTEM_SUSPEND,
548         SCMI_SYSTEM_MAX
549 };
550
551 struct scmi_device {
552         u32 id;
553         u8 protocol_id;
554         const char *name;
555         struct device dev;
556         struct scmi_handle *handle;
557 };
558
559 #define to_scmi_dev(d) container_of(d, struct scmi_device, dev)
560
561 struct scmi_device *
562 scmi_device_create(struct device_node *np, struct device *parent, int protocol,
563                    const char *name);
564 void scmi_device_destroy(struct scmi_device *scmi_dev);
565
566 struct scmi_device_id {
567         u8 protocol_id;
568         const char *name;
569 };
570
571 struct scmi_driver {
572         const char *name;
573         int (*probe)(struct scmi_device *sdev);
574         void (*remove)(struct scmi_device *sdev);
575         const struct scmi_device_id *id_table;
576
577         struct device_driver driver;
578 };
579
580 #define to_scmi_driver(d) container_of(d, struct scmi_driver, driver)
581
582 #if IS_REACHABLE(CONFIG_ARM_SCMI_PROTOCOL)
583 int scmi_driver_register(struct scmi_driver *driver,
584                          struct module *owner, const char *mod_name);
585 void scmi_driver_unregister(struct scmi_driver *driver);
586 #else
587 static inline int
588 scmi_driver_register(struct scmi_driver *driver, struct module *owner,
589                      const char *mod_name)
590 {
591         return -EINVAL;
592 }
593
594 static inline void scmi_driver_unregister(struct scmi_driver *driver) {}
595 #endif /* CONFIG_ARM_SCMI_PROTOCOL */
596
597 #define scmi_register(driver) \
598         scmi_driver_register(driver, THIS_MODULE, KBUILD_MODNAME)
599 #define scmi_unregister(driver) \
600         scmi_driver_unregister(driver)
601
602 /**
603  * module_scmi_driver() - Helper macro for registering a scmi driver
604  * @__scmi_driver: scmi_driver structure
605  *
606  * Helper macro for scmi drivers to set up proper module init / exit
607  * functions.  Replaces module_init() and module_exit() and keeps people from
608  * printing pointless things to the kernel log when their driver is loaded.
609  */
610 #define module_scmi_driver(__scmi_driver)       \
611         module_driver(__scmi_driver, scmi_register, scmi_unregister)
612
613 typedef int (*scmi_prot_init_fn_t)(struct scmi_handle *);
614 int scmi_protocol_register(int protocol_id, scmi_prot_init_fn_t fn);
615 void scmi_protocol_unregister(int protocol_id);
616
617 /* SCMI Notification API - Custom Event Reports */
618 enum scmi_notification_events {
619         SCMI_EVENT_POWER_STATE_CHANGED = 0x0,
620         SCMI_EVENT_PERFORMANCE_LIMITS_CHANGED = 0x0,
621         SCMI_EVENT_PERFORMANCE_LEVEL_CHANGED = 0x1,
622         SCMI_EVENT_SENSOR_TRIP_POINT_EVENT = 0x0,
623         SCMI_EVENT_RESET_ISSUED = 0x0,
624         SCMI_EVENT_BASE_ERROR_EVENT = 0x0,
625         SCMI_EVENT_SYSTEM_POWER_STATE_NOTIFIER = 0x0,
626 };
627
628 struct scmi_power_state_changed_report {
629         ktime_t         timestamp;
630         unsigned int    agent_id;
631         unsigned int    domain_id;
632         unsigned int    power_state;
633 };
634
635 struct scmi_system_power_state_notifier_report {
636         ktime_t         timestamp;
637         unsigned int    agent_id;
638         unsigned int    flags;
639         unsigned int    system_state;
640 };
641
642 struct scmi_perf_limits_report {
643         ktime_t         timestamp;
644         unsigned int    agent_id;
645         unsigned int    domain_id;
646         unsigned int    range_max;
647         unsigned int    range_min;
648 };
649
650 struct scmi_perf_level_report {
651         ktime_t         timestamp;
652         unsigned int    agent_id;
653         unsigned int    domain_id;
654         unsigned int    performance_level;
655 };
656
657 struct scmi_sensor_trip_point_report {
658         ktime_t         timestamp;
659         unsigned int    agent_id;
660         unsigned int    sensor_id;
661         unsigned int    trip_point_desc;
662 };
663
664 struct scmi_reset_issued_report {
665         ktime_t         timestamp;
666         unsigned int    agent_id;
667         unsigned int    domain_id;
668         unsigned int    reset_state;
669 };
670
671 struct scmi_base_error_report {
672         ktime_t                 timestamp;
673         unsigned int            agent_id;
674         bool                    fatal;
675         unsigned int            cmd_count;
676         unsigned long long      reports[];
677 };
678
679 #endif /* _LINUX_SCMI_PROTOCOL_H */