1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * SCMI Message Protocol driver header
5 * Copyright (C) 2018-2021 ARM Ltd.
8 #ifndef _LINUX_SCMI_PROTOCOL_H
9 #define _LINUX_SCMI_PROTOCOL_H
11 #include <linux/bitfield.h>
12 #include <linux/device.h>
13 #include <linux/notifier.h>
14 #include <linux/types.h>
16 #define SCMI_MAX_STR_SIZE 16
17 #define SCMI_MAX_NUM_RATES 16
20 * struct scmi_revision_info - version information structure
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
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)
33 struct scmi_revision_info {
39 char vendor_id[SCMI_MAX_STR_SIZE];
40 char sub_vendor_id[SCMI_MAX_STR_SIZE];
43 struct scmi_clock_info {
44 char name[SCMI_MAX_STR_SIZE];
49 u64 rates[SCMI_MAX_NUM_RATES];
61 struct scmi_protocol_handle;
64 * struct scmi_clk_ops - represents the various operations provided
65 * by SCMI Clock Protocol
67 * @count_get: get the count of clocks provided by SCMI
68 * @info_get: get the information of the specified clock
69 * @rate_get: request the current clock rate of a clock
70 * @rate_set: set the clock rate of a clock
71 * @enable: enables the specified clock
72 * @disable: disables the specified clock
75 int (*count_get)(const struct scmi_handle *handle);
77 const struct scmi_clock_info *(*info_get)
78 (const struct scmi_handle *handle, u32 clk_id);
79 int (*rate_get)(const struct scmi_handle *handle, u32 clk_id,
81 int (*rate_set)(const struct scmi_handle *handle, u32 clk_id,
83 int (*enable)(const struct scmi_handle *handle, u32 clk_id);
84 int (*disable)(const struct scmi_handle *handle, u32 clk_id);
88 * struct scmi_perf_proto_ops - represents the various operations provided
89 * by SCMI Performance Protocol
91 * @limits_set: sets limits on the performance level of a domain
92 * @limits_get: gets limits on the performance level of a domain
93 * @level_set: sets the performance level of a domain
94 * @level_get: gets the performance level of a domain
95 * @device_domain_id: gets the scmi domain id for a given device
96 * @transition_latency_get: gets the DVFS transition latency for a given device
97 * @device_opps_add: adds all the OPPs for a given device
98 * @freq_set: sets the frequency for a given device using sustained frequency
99 * to sustained performance level mapping
100 * @freq_get: gets the frequency for a given device using sustained frequency
101 * to sustained performance level mapping
102 * @est_power_get: gets the estimated power cost for a given performance domain
103 * at a given frequency
105 struct scmi_perf_proto_ops {
106 int (*limits_set)(const struct scmi_protocol_handle *ph, u32 domain,
107 u32 max_perf, u32 min_perf);
108 int (*limits_get)(const struct scmi_protocol_handle *ph, u32 domain,
109 u32 *max_perf, u32 *min_perf);
110 int (*level_set)(const struct scmi_protocol_handle *ph, u32 domain,
111 u32 level, bool poll);
112 int (*level_get)(const struct scmi_protocol_handle *ph, u32 domain,
113 u32 *level, bool poll);
114 int (*device_domain_id)(struct device *dev);
115 int (*transition_latency_get)(const struct scmi_protocol_handle *ph,
117 int (*device_opps_add)(const struct scmi_protocol_handle *ph,
119 int (*freq_set)(const struct scmi_protocol_handle *ph, u32 domain,
120 unsigned long rate, bool poll);
121 int (*freq_get)(const struct scmi_protocol_handle *ph, u32 domain,
122 unsigned long *rate, bool poll);
123 int (*est_power_get)(const struct scmi_protocol_handle *ph, u32 domain,
124 unsigned long *rate, unsigned long *power);
125 bool (*fast_switch_possible)(const struct scmi_protocol_handle *ph,
127 bool (*power_scale_mw_get)(const struct scmi_protocol_handle *ph);
130 struct scmi_perf_ops {
131 int (*limits_set)(const struct scmi_handle *handle, u32 domain,
132 u32 max_perf, u32 min_perf);
133 int (*limits_get)(const struct scmi_handle *handle, u32 domain,
134 u32 *max_perf, u32 *min_perf);
135 int (*level_set)(const struct scmi_handle *handle, u32 domain,
136 u32 level, bool poll);
137 int (*level_get)(const struct scmi_handle *handle, u32 domain,
138 u32 *level, bool poll);
139 int (*device_domain_id)(struct device *dev);
140 int (*transition_latency_get)(const struct scmi_handle *handle,
142 int (*device_opps_add)(const struct scmi_handle *handle,
144 int (*freq_set)(const struct scmi_handle *handle, u32 domain,
145 unsigned long rate, bool poll);
146 int (*freq_get)(const struct scmi_handle *handle, u32 domain,
147 unsigned long *rate, bool poll);
148 int (*est_power_get)(const struct scmi_handle *handle, u32 domain,
149 unsigned long *rate, unsigned long *power);
150 bool (*fast_switch_possible)(const struct scmi_handle *handle,
152 bool (*power_scale_mw_get)(const struct scmi_handle *handle);
156 * struct scmi_power_ops - represents the various operations provided
157 * by SCMI Power Protocol
159 * @num_domains_get: get the count of power domains provided by SCMI
160 * @name_get: gets the name of a power domain
161 * @state_set: sets the power state of a power domain
162 * @state_get: gets the power state of a power domain
164 struct scmi_power_ops {
165 int (*num_domains_get)(const struct scmi_handle *handle);
166 char *(*name_get)(const struct scmi_handle *handle, u32 domain);
167 #define SCMI_POWER_STATE_TYPE_SHIFT 30
168 #define SCMI_POWER_STATE_ID_MASK (BIT(28) - 1)
169 #define SCMI_POWER_STATE_PARAM(type, id) \
170 ((((type) & BIT(0)) << SCMI_POWER_STATE_TYPE_SHIFT) | \
171 ((id) & SCMI_POWER_STATE_ID_MASK))
172 #define SCMI_POWER_STATE_GENERIC_ON SCMI_POWER_STATE_PARAM(0, 0)
173 #define SCMI_POWER_STATE_GENERIC_OFF SCMI_POWER_STATE_PARAM(1, 0)
174 int (*state_set)(const struct scmi_handle *handle, u32 domain,
176 int (*state_get)(const struct scmi_handle *handle, u32 domain,
181 * scmi_sensor_reading - represent a timestamped read
183 * Used by @reading_get_timestamped method.
185 * @value: The signed value sensor read.
186 * @timestamp: An unsigned timestamp for the sensor read, as provided by
187 * SCMI platform. Set to zero when not available.
189 struct scmi_sensor_reading {
191 unsigned long long timestamp;
195 * scmi_range_attrs - specifies a sensor or axis values' range
196 * @min_range: The minimum value which can be represented by the sensor/axis.
197 * @max_range: The maximum value which can be represented by the sensor/axis.
199 struct scmi_range_attrs {
205 * scmi_sensor_axis_info - describes one sensor axes
207 * @type: Axes type. Chosen amongst one of @enum scmi_sensor_class.
208 * @scale: Power-of-10 multiplier applied to the axis unit.
209 * @name: NULL-terminated string representing axes name as advertised by
211 * @extended_attrs: Flag to indicate the presence of additional extended
212 * attributes for this axes.
213 * @resolution: Extended attribute representing the resolution of the axes.
214 * Set to 0 if not reported by this axes.
215 * @exponent: Extended attribute representing the power-of-10 multiplier that
216 * is applied to the resolution field. Set to 0 if not reported by
218 * @attrs: Extended attributes representing minimum and maximum values
219 * measurable by this axes. Set to 0 if not reported by this sensor.
221 struct scmi_sensor_axis_info {
225 char name[SCMI_MAX_STR_SIZE];
227 unsigned int resolution;
229 struct scmi_range_attrs attrs;
233 * scmi_sensor_intervals_info - describes number and type of available update
235 * @segmented: Flag for segmented intervals' representation. When True there
236 * will be exactly 3 intervals in @desc, with each entry
237 * representing a member of a segment in this order:
238 * {lowest update interval, highest update interval, step size}
239 * @count: Number of intervals described in @desc.
240 * @desc: Array of @count interval descriptor bitmask represented as detailed in
241 * the SCMI specification: it can be accessed using the accompanying
243 * @prealloc_pool: A minimal preallocated pool of desc entries used to avoid
244 * lesser-than-64-bytes dynamic allocation for small @count
247 struct scmi_sensor_intervals_info {
250 #define SCMI_SENS_INTVL_SEGMENT_LOW 0
251 #define SCMI_SENS_INTVL_SEGMENT_HIGH 1
252 #define SCMI_SENS_INTVL_SEGMENT_STEP 2
254 #define SCMI_SENS_INTVL_GET_SECS(x) FIELD_GET(GENMASK(20, 5), (x))
255 #define SCMI_SENS_INTVL_GET_EXP(x) \
257 int __signed_exp = FIELD_GET(GENMASK(4, 0), (x)); \
259 if (__signed_exp & BIT(4)) \
260 __signed_exp |= GENMASK(31, 5); \
263 #define SCMI_MAX_PREALLOC_POOL 16
264 unsigned int prealloc_pool[SCMI_MAX_PREALLOC_POOL];
268 * struct scmi_sensor_info - represents information related to one of the
271 * @type: Sensor type. Chosen amongst one of @enum scmi_sensor_class.
272 * @scale: Power-of-10 multiplier applied to the sensor unit.
273 * @num_trip_points: Number of maximum configurable trip points.
274 * @async: Flag for asynchronous read support.
275 * @update: Flag for continuouos update notification support.
276 * @timestamped: Flag for timestamped read support.
277 * @tstamp_scale: Power-of-10 multiplier applied to the sensor timestamps to
278 * represent it in seconds.
279 * @num_axis: Number of supported axis if any. Reported as 0 for scalar sensors.
280 * @axis: Pointer to an array of @num_axis descriptors.
281 * @intervals: Descriptor of available update intervals.
282 * @sensor_config: A bitmask reporting the current sensor configuration as
283 * detailed in the SCMI specification: it can accessed and
284 * modified through the accompanying macros.
285 * @name: NULL-terminated string representing sensor name as advertised by
287 * @extended_scalar_attrs: Flag to indicate the presence of additional extended
288 * attributes for this sensor.
289 * @sensor_power: Extended attribute representing the average power
290 * consumed by the sensor in microwatts (uW) when it is active.
291 * Reported here only for scalar sensors.
292 * Set to 0 if not reported by this sensor.
293 * @resolution: Extended attribute representing the resolution of the sensor.
294 * Reported here only for scalar sensors.
295 * Set to 0 if not reported by this sensor.
296 * @exponent: Extended attribute representing the power-of-10 multiplier that is
297 * applied to the resolution field.
298 * Reported here only for scalar sensors.
299 * Set to 0 if not reported by this sensor.
300 * @scalar_attrs: Extended attributes representing minimum and maximum
301 * measurable values by this sensor.
302 * Reported here only for scalar sensors.
303 * Set to 0 if not reported by this sensor.
305 struct scmi_sensor_info {
309 unsigned int num_trip_points;
314 unsigned int num_axis;
315 struct scmi_sensor_axis_info *axis;
316 struct scmi_sensor_intervals_info intervals;
317 unsigned int sensor_config;
318 #define SCMI_SENS_CFG_UPDATE_SECS_MASK GENMASK(31, 16)
319 #define SCMI_SENS_CFG_GET_UPDATE_SECS(x) \
320 FIELD_GET(SCMI_SENS_CFG_UPDATE_SECS_MASK, (x))
322 #define SCMI_SENS_CFG_UPDATE_EXP_MASK GENMASK(15, 11)
323 #define SCMI_SENS_CFG_GET_UPDATE_EXP(x) \
326 FIELD_GET(SCMI_SENS_CFG_UPDATE_EXP_MASK, (x)); \
328 if (__signed_exp & BIT(4)) \
329 __signed_exp |= GENMASK(31, 5); \
333 #define SCMI_SENS_CFG_ROUND_MASK GENMASK(10, 9)
334 #define SCMI_SENS_CFG_ROUND_AUTO 2
335 #define SCMI_SENS_CFG_ROUND_UP 1
336 #define SCMI_SENS_CFG_ROUND_DOWN 0
338 #define SCMI_SENS_CFG_TSTAMP_ENABLED_MASK BIT(1)
339 #define SCMI_SENS_CFG_TSTAMP_ENABLE 1
340 #define SCMI_SENS_CFG_TSTAMP_DISABLE 0
341 #define SCMI_SENS_CFG_IS_TSTAMP_ENABLED(x) \
342 FIELD_GET(SCMI_SENS_CFG_TSTAMP_ENABLED_MASK, (x))
344 #define SCMI_SENS_CFG_SENSOR_ENABLED_MASK BIT(0)
345 #define SCMI_SENS_CFG_SENSOR_ENABLE 1
346 #define SCMI_SENS_CFG_SENSOR_DISABLE 0
347 char name[SCMI_MAX_STR_SIZE];
348 #define SCMI_SENS_CFG_IS_ENABLED(x) FIELD_GET(BIT(0), (x))
349 bool extended_scalar_attrs;
350 unsigned int sensor_power;
351 unsigned int resolution;
353 struct scmi_range_attrs scalar_attrs;
357 * Partial list from Distributed Management Task Force (DMTF) specification:
358 * DSP0249 (Platform Level Data Model specification)
360 enum scmi_sensor_class {
430 NEWTON_METERS = 0x45,
441 CORRECTED_ERRS = 0x50,
442 UNCORRECTABLE_ERRS = 0x51,
450 METERS_SEC_SQUARED = 0x59,
452 CUBIC_METERS_SEC = 0x5B,
454 RADIANS_SEC_SQUARED = 0x5D,
459 * struct scmi_sensor_ops - represents the various operations provided
460 * by SCMI Sensor Protocol
462 * @count_get: get the count of sensors provided by SCMI
463 * @info_get: get the information of the specified sensor
464 * @trip_point_config: selects and configures a trip-point of interest
465 * @reading_get: gets the current value of the sensor
466 * @reading_get_timestamped: gets the current value and timestamp, when
467 * available, of the sensor. (as of v3.0 spec)
468 * Supports multi-axis sensors for sensors which
469 * supports it and if the @reading array size of
470 * @count entry equals the sensor num_axis
471 * @config_get: Get sensor current configuration
472 * @config_set: Set sensor current configuration
474 struct scmi_sensor_ops {
475 int (*count_get)(const struct scmi_handle *handle);
476 const struct scmi_sensor_info *(*info_get)
477 (const struct scmi_handle *handle, u32 sensor_id);
478 int (*trip_point_config)(const struct scmi_handle *handle,
479 u32 sensor_id, u8 trip_id, u64 trip_value);
480 int (*reading_get)(const struct scmi_handle *handle, u32 sensor_id,
482 int (*reading_get_timestamped)(const struct scmi_handle *handle,
483 u32 sensor_id, u8 count,
484 struct scmi_sensor_reading *readings);
485 int (*config_get)(const struct scmi_handle *handle,
486 u32 sensor_id, u32 *sensor_config);
487 int (*config_set)(const struct scmi_handle *handle,
488 u32 sensor_id, u32 sensor_config);
492 * struct scmi_reset_ops - represents the various operations provided
493 * by SCMI Reset Protocol
495 * @num_domains_get: get the count of reset domains provided by SCMI
496 * @name_get: gets the name of a reset domain
497 * @latency_get: gets the reset latency for the specified reset domain
498 * @reset: resets the specified reset domain
499 * @assert: explicitly assert reset signal of the specified reset domain
500 * @deassert: explicitly deassert reset signal of the specified reset domain
502 struct scmi_reset_ops {
503 int (*num_domains_get)(const struct scmi_handle *handle);
504 char *(*name_get)(const struct scmi_handle *handle, u32 domain);
505 int (*latency_get)(const struct scmi_handle *handle, u32 domain);
506 int (*reset)(const struct scmi_handle *handle, u32 domain);
507 int (*assert)(const struct scmi_handle *handle, u32 domain);
508 int (*deassert)(const struct scmi_handle *handle, u32 domain);
512 * struct scmi_voltage_info - describe one available SCMI Voltage Domain
514 * @id: the domain ID as advertised by the platform
515 * @segmented: defines the layout of the entries of array @levels_uv.
516 * - when True the entries are to be interpreted as triplets,
517 * each defining a segment representing a range of equally
518 * space voltages: <lowest_volts>, <highest_volt>, <step_uV>
519 * - when False the entries simply represent a single discrete
520 * supported voltage level
521 * @negative_volts_allowed: True if any of the entries of @levels_uv represent
522 * a negative voltage.
523 * @attributes: represents Voltage Domain advertised attributes
524 * @name: name assigned to the Voltage Domain by platform
525 * @num_levels: number of total entries in @levels_uv.
526 * @levels_uv: array of entries describing the available voltage levels for
529 struct scmi_voltage_info {
532 bool negative_volts_allowed;
533 unsigned int attributes;
534 char name[SCMI_MAX_STR_SIZE];
535 unsigned int num_levels;
536 #define SCMI_VOLTAGE_SEGMENT_LOW 0
537 #define SCMI_VOLTAGE_SEGMENT_HIGH 1
538 #define SCMI_VOLTAGE_SEGMENT_STEP 2
543 * struct scmi_voltage_ops - represents the various operations provided
544 * by SCMI Voltage Protocol
546 * @num_domains_get: get the count of voltage domains provided by SCMI
547 * @info_get: get the information of the specified domain
548 * @config_set: set the config for the specified domain
549 * @config_get: get the config of the specified domain
550 * @level_set: set the voltage level for the specified domain
551 * @level_get: get the voltage level of the specified domain
553 struct scmi_voltage_ops {
554 int (*num_domains_get)(const struct scmi_handle *handle);
555 const struct scmi_voltage_info __must_check *(*info_get)
556 (const struct scmi_handle *handle, u32 domain_id);
557 int (*config_set)(const struct scmi_handle *handle, u32 domain_id,
559 #define SCMI_VOLTAGE_ARCH_STATE_OFF 0x0
560 #define SCMI_VOLTAGE_ARCH_STATE_ON 0x7
561 int (*config_get)(const struct scmi_handle *handle, u32 domain_id,
563 int (*level_set)(const struct scmi_handle *handle, u32 domain_id,
564 u32 flags, s32 volt_uV);
565 int (*level_get)(const struct scmi_handle *handle, u32 domain_id,
570 * struct scmi_notify_ops - represents notifications' operations provided by
572 * @devm_event_notifier_register: Managed registration of a notifier_block for
573 * the requested event
574 * @devm_event_notifier_unregister: Managed unregistration of a notifier_block
575 * for the requested event
576 * @register_event_notifier: Register a notifier_block for the requested event
577 * @unregister_event_notifier: Unregister a notifier_block for the requested
580 * A user can register/unregister its own notifier_block against the wanted
581 * platform instance regarding the desired event identified by the
582 * tuple: (proto_id, evt_id, src_id) using the provided register/unregister
585 * @sdev: The scmi_device to use when calling the devres managed ops devm_
586 * @handle: The handle identifying the platform instance to use, when not
587 * calling the managed ops devm_
588 * @proto_id: The protocol ID as in SCMI Specification
589 * @evt_id: The message ID of the desired event as in SCMI Specification
590 * @src_id: A pointer to the desired source ID if different sources are
591 * possible for the protocol (like domain_id, sensor_id...etc)
593 * @src_id can be provided as NULL if it simply does NOT make sense for
594 * the protocol at hand, OR if the user is explicitly interested in
595 * receiving notifications from ANY existent source associated to the
596 * specified proto_id / evt_id.
598 * Received notifications are finally delivered to the registered users,
599 * invoking the callback provided with the notifier_block *nb as follows:
601 * int user_cb(nb, evt_id, report)
605 * @nb: The notifier block provided by the user
606 * @evt_id: The message ID of the delivered event
607 * @report: A custom struct describing the specific event delivered
609 struct scmi_notify_ops {
610 int (*devm_event_notifier_register)(struct scmi_device *sdev,
611 u8 proto_id, u8 evt_id,
613 struct notifier_block *nb);
614 int (*devm_event_notifier_unregister)(struct scmi_device *sdev,
615 u8 proto_id, u8 evt_id,
617 struct notifier_block *nb);
618 int (*register_event_notifier)(const struct scmi_handle *handle,
619 u8 proto_id, u8 evt_id,
621 struct notifier_block *nb);
622 int (*unregister_event_notifier)(const struct scmi_handle *handle,
623 u8 proto_id, u8 evt_id,
625 struct notifier_block *nb);
629 * struct scmi_handle - Handle returned to ARM SCMI clients for usage.
631 * @dev: pointer to the SCMI device
632 * @version: pointer to the structure containing SCMI version information
633 * @power_ops: pointer to set of power protocol operations
634 * @perf_ops: pointer to set of performance protocol operations
635 * @clk_ops: pointer to set of clock protocol operations
636 * @sensor_ops: pointer to set of sensor protocol operations
637 * @reset_ops: pointer to set of reset protocol operations
638 * @voltage_ops: pointer to set of voltage protocol operations
639 * @devm_protocol_get: devres managed method to acquire a protocol and get specific
640 * operations and a dedicated protocol handler
641 * @devm_protocol_put: devres managed method to release a protocol
642 * @notify_ops: pointer to set of notifications related operations
643 * @clk_priv: pointer to private data structure specific to clock
644 * protocol(for internal use only)
645 * @power_priv: pointer to private data structure specific to power
646 * protocol(for internal use only)
647 * @sensor_priv: pointer to private data structure specific to sensors
648 * protocol(for internal use only)
649 * @reset_priv: pointer to private data structure specific to reset
650 * protocol(for internal use only)
651 * @voltage_priv: pointer to private data structure specific to voltage
652 * protocol(for internal use only)
653 * @notify_priv: pointer to private data structure specific to notifications
654 * (for internal use only)
658 struct scmi_revision_info *version;
659 const struct scmi_perf_ops *perf_ops;
660 const struct scmi_clk_ops *clk_ops;
661 const struct scmi_power_ops *power_ops;
662 const struct scmi_sensor_ops *sensor_ops;
663 const struct scmi_reset_ops *reset_ops;
664 const struct scmi_voltage_ops *voltage_ops;
666 const void __must_check *
667 (*devm_protocol_get)(struct scmi_device *sdev, u8 proto,
668 struct scmi_protocol_handle **ph);
669 void (*devm_protocol_put)(struct scmi_device *sdev, u8 proto);
671 const struct scmi_notify_ops *notify_ops;
672 /* for protocol internal use */
682 enum scmi_std_protocol {
683 SCMI_PROTOCOL_BASE = 0x10,
684 SCMI_PROTOCOL_POWER = 0x11,
685 SCMI_PROTOCOL_SYSTEM = 0x12,
686 SCMI_PROTOCOL_PERF = 0x13,
687 SCMI_PROTOCOL_CLOCK = 0x14,
688 SCMI_PROTOCOL_SENSOR = 0x15,
689 SCMI_PROTOCOL_RESET = 0x16,
690 SCMI_PROTOCOL_VOLTAGE = 0x17,
693 enum scmi_system_events {
694 SCMI_SYSTEM_SHUTDOWN,
695 SCMI_SYSTEM_COLDRESET,
696 SCMI_SYSTEM_WARMRESET,
707 struct scmi_handle *handle;
710 #define to_scmi_dev(d) container_of(d, struct scmi_device, dev)
713 scmi_device_create(struct device_node *np, struct device *parent, int protocol,
715 void scmi_device_destroy(struct scmi_device *scmi_dev);
717 struct scmi_device_id {
724 int (*probe)(struct scmi_device *sdev);
725 void (*remove)(struct scmi_device *sdev);
726 const struct scmi_device_id *id_table;
728 struct device_driver driver;
731 #define to_scmi_driver(d) container_of(d, struct scmi_driver, driver)
733 #if IS_REACHABLE(CONFIG_ARM_SCMI_PROTOCOL)
734 int scmi_driver_register(struct scmi_driver *driver,
735 struct module *owner, const char *mod_name);
736 void scmi_driver_unregister(struct scmi_driver *driver);
739 scmi_driver_register(struct scmi_driver *driver, struct module *owner,
740 const char *mod_name)
745 static inline void scmi_driver_unregister(struct scmi_driver *driver) {}
746 #endif /* CONFIG_ARM_SCMI_PROTOCOL */
748 #define scmi_register(driver) \
749 scmi_driver_register(driver, THIS_MODULE, KBUILD_MODNAME)
750 #define scmi_unregister(driver) \
751 scmi_driver_unregister(driver)
754 * module_scmi_driver() - Helper macro for registering a scmi driver
755 * @__scmi_driver: scmi_driver structure
757 * Helper macro for scmi drivers to set up proper module init / exit
758 * functions. Replaces module_init() and module_exit() and keeps people from
759 * printing pointless things to the kernel log when their driver is loaded.
761 #define module_scmi_driver(__scmi_driver) \
762 module_driver(__scmi_driver, scmi_register, scmi_unregister)
764 struct scmi_protocol;
765 int scmi_protocol_register(const struct scmi_protocol *proto);
766 void scmi_protocol_unregister(const struct scmi_protocol *proto);
768 /* SCMI Notification API - Custom Event Reports */
769 enum scmi_notification_events {
770 SCMI_EVENT_POWER_STATE_CHANGED = 0x0,
771 SCMI_EVENT_PERFORMANCE_LIMITS_CHANGED = 0x0,
772 SCMI_EVENT_PERFORMANCE_LEVEL_CHANGED = 0x1,
773 SCMI_EVENT_SENSOR_TRIP_POINT_EVENT = 0x0,
774 SCMI_EVENT_SENSOR_UPDATE = 0x1,
775 SCMI_EVENT_RESET_ISSUED = 0x0,
776 SCMI_EVENT_BASE_ERROR_EVENT = 0x0,
777 SCMI_EVENT_SYSTEM_POWER_STATE_NOTIFIER = 0x0,
780 struct scmi_power_state_changed_report {
782 unsigned int agent_id;
783 unsigned int domain_id;
784 unsigned int power_state;
787 struct scmi_system_power_state_notifier_report {
789 unsigned int agent_id;
791 unsigned int system_state;
794 struct scmi_perf_limits_report {
796 unsigned int agent_id;
797 unsigned int domain_id;
798 unsigned int range_max;
799 unsigned int range_min;
802 struct scmi_perf_level_report {
804 unsigned int agent_id;
805 unsigned int domain_id;
806 unsigned int performance_level;
809 struct scmi_sensor_trip_point_report {
811 unsigned int agent_id;
812 unsigned int sensor_id;
813 unsigned int trip_point_desc;
816 struct scmi_sensor_update_report {
818 unsigned int agent_id;
819 unsigned int sensor_id;
820 unsigned int readings_count;
821 struct scmi_sensor_reading readings[];
824 struct scmi_reset_issued_report {
826 unsigned int agent_id;
827 unsigned int domain_id;
828 unsigned int reset_state;
831 struct scmi_base_error_report {
833 unsigned int agent_id;
835 unsigned int cmd_count;
836 unsigned long long reports[];
839 #endif /* _LINUX_SCMI_PROTOCOL_H */