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 64
17 #define SCMI_SHORT_NAME_MAX_SIZE 16
18 #define SCMI_MAX_NUM_RATES 16
21 * struct scmi_revision_info - version information structure
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
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)
34 struct scmi_revision_info
{
40 char vendor_id
[SCMI_SHORT_NAME_MAX_SIZE
];
41 char sub_vendor_id
[SCMI_SHORT_NAME_MAX_SIZE
];
44 struct scmi_clock_info
{
45 char name
[SCMI_MAX_STR_SIZE
];
46 unsigned int enable_latency
;
48 bool rate_changed_notifications
;
49 bool rate_change_requested_notifications
;
50 bool state_ctrl_forbidden
;
51 bool rate_ctrl_forbidden
;
52 bool parent_ctrl_forbidden
;
57 u64 rates
[SCMI_MAX_NUM_RATES
];
69 enum scmi_power_scale
{
71 SCMI_POWER_MILLIWATTS
,
77 struct scmi_protocol_handle
;
79 enum scmi_clock_oem_config
{
80 SCMI_CLOCK_CFG_DUTY_CYCLE
= 0x1,
82 SCMI_CLOCK_CFG_OEM_START
= 0x80,
83 SCMI_CLOCK_CFG_OEM_END
= 0xFF,
87 * struct scmi_clk_proto_ops - represents the various operations provided
88 * by SCMI Clock Protocol
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
96 * @state_get: get the status of the specified clock
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
99 * @parent_get: get the parent id of a clk
100 * @parent_set: set the parent of a clock
102 struct scmi_clk_proto_ops
{
103 int (*count_get
)(const struct scmi_protocol_handle
*ph
);
105 const struct scmi_clock_info __must_check
*(*info_get
)
106 (const struct scmi_protocol_handle
*ph
, u32 clk_id
);
107 int (*rate_get
)(const struct scmi_protocol_handle
*ph
, u32 clk_id
,
109 int (*rate_set
)(const struct scmi_protocol_handle
*ph
, u32 clk_id
,
111 int (*enable
)(const struct scmi_protocol_handle
*ph
, u32 clk_id
,
113 int (*disable
)(const struct scmi_protocol_handle
*ph
, u32 clk_id
,
115 int (*state_get
)(const struct scmi_protocol_handle
*ph
, u32 clk_id
,
116 bool *enabled
, bool atomic
);
117 int (*config_oem_get
)(const struct scmi_protocol_handle
*ph
, u32 clk_id
,
118 enum scmi_clock_oem_config oem_type
,
119 u32
*oem_val
, u32
*attributes
, bool atomic
);
120 int (*config_oem_set
)(const struct scmi_protocol_handle
*ph
, u32 clk_id
,
121 enum scmi_clock_oem_config oem_type
,
122 u32 oem_val
, bool atomic
);
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
);
127 struct scmi_perf_domain_info
{
128 char name
[SCMI_MAX_STR_SIZE
];
133 * struct scmi_perf_proto_ops - represents the various operations provided
134 * by SCMI Performance Protocol
136 * @num_domains_get: gets the number of supported performance domains
137 * @info_get: get the information of a performance domain
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
142 * @transition_latency_get: gets the DVFS transition latency for a given device
143 * @rate_limit_get: gets the minimum time (us) required between successive
145 * @device_opps_add: adds all the OPPs for a given device
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
150 * @est_power_get: gets the estimated power cost for a given performance domain
151 * at a given frequency
152 * @fast_switch_possible: indicates if fast DVFS switching is possible or not
154 * @fast_switch_rate_limit: gets the minimum time (us) required between
155 * successive fast_switching requests
156 * @power_scale_mw_get: indicates if the power values provided are in milliWatts
157 * or in some other (abstract) scale
159 struct scmi_perf_proto_ops
{
160 int (*num_domains_get
)(const struct scmi_protocol_handle
*ph
);
161 const struct scmi_perf_domain_info __must_check
*(*info_get
)
162 (const struct scmi_protocol_handle
*ph
, u32 domain
);
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
);
171 int (*transition_latency_get
)(const struct scmi_protocol_handle
*ph
,
173 int (*rate_limit_get
)(const struct scmi_protocol_handle
*ph
,
174 u32 domain
, u32
*rate_limit
);
175 int (*device_opps_add
)(const struct scmi_protocol_handle
*ph
,
176 struct device
*dev
, u32 domain
);
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
,
185 int (*fast_switch_rate_limit
)(const struct scmi_protocol_handle
*ph
,
186 u32 domain
, u32
*rate_limit
);
187 enum scmi_power_scale (*power_scale_get
)(const struct scmi_protocol_handle
*ph
);
191 * struct scmi_power_proto_ops - represents the various operations provided
192 * by SCMI Power Protocol
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
199 struct scmi_power_proto_ops
{
200 int (*num_domains_get
)(const struct scmi_protocol_handle
*ph
);
201 const char *(*name_get
)(const struct scmi_protocol_handle
*ph
,
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)
210 int (*state_set
)(const struct scmi_protocol_handle
*ph
, u32 domain
,
212 int (*state_get
)(const struct scmi_protocol_handle
*ph
, u32 domain
,
217 * struct scmi_sensor_reading - represent a timestamped read
219 * Used by @reading_get_timestamped method.
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.
225 struct scmi_sensor_reading
{
227 unsigned long long timestamp
;
231 * struct scmi_range_attrs - specifies a sensor or axis values' range
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.
235 struct scmi_range_attrs
{
241 * struct scmi_sensor_axis_info - describes one sensor axes
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
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
254 * @attrs: Extended attributes representing minimum and maximum values
255 * measurable by this axes. Set to 0 if not reported by this sensor.
257 struct scmi_sensor_axis_info
{
261 char name
[SCMI_MAX_STR_SIZE
];
263 unsigned int resolution
;
265 struct scmi_range_attrs attrs
;
269 * struct scmi_sensor_intervals_info - describes number and type of available
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
279 * @prealloc_pool: A minimal preallocated pool of desc entries used to avoid
280 * lesser-than-64-bytes dynamic allocation for small @count
283 struct scmi_sensor_intervals_info
{
286 #define SCMI_SENS_INTVL_SEGMENT_LOW 0
287 #define SCMI_SENS_INTVL_SEGMENT_HIGH 1
288 #define SCMI_SENS_INTVL_SEGMENT_STEP 2
290 #define SCMI_SENS_INTVL_GET_SECS(x) FIELD_GET(GENMASK(20, 5), (x))
291 #define SCMI_SENS_INTVL_GET_EXP(x) \
293 int __signed_exp = FIELD_GET(GENMASK(4, 0), (x)); \
295 if (__signed_exp & BIT(4)) \
296 __signed_exp |= GENMASK(31, 5); \
299 #define SCMI_MAX_PREALLOC_POOL 16
300 unsigned int prealloc_pool
[SCMI_MAX_PREALLOC_POOL
];
304 * struct scmi_sensor_info - represents information related to one of the
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
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.
341 struct scmi_sensor_info
{
345 unsigned int num_trip_points
;
350 unsigned int num_axis
;
351 struct scmi_sensor_axis_info
*axis
;
352 struct scmi_sensor_intervals_info intervals
;
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))
358 #define SCMI_SENS_CFG_UPDATE_EXP_MASK GENMASK(15, 11)
359 #define SCMI_SENS_CFG_GET_UPDATE_EXP(x) \
362 FIELD_GET(SCMI_SENS_CFG_UPDATE_EXP_MASK, (x)); \
364 if (__signed_exp & BIT(4)) \
365 __signed_exp |= GENMASK(31, 5); \
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
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))
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
383 char name
[SCMI_MAX_STR_SIZE
];
384 #define SCMI_SENS_CFG_IS_ENABLED(x) FIELD_GET(BIT(0), (x))
385 bool extended_scalar_attrs
;
386 unsigned int sensor_power
;
387 unsigned int resolution
;
389 struct scmi_range_attrs scalar_attrs
;
393 * Partial list from Distributed Management Task Force (DMTF) specification:
394 * DSP0249 (Platform Level Data Model specification)
396 enum scmi_sensor_class
{
466 NEWTON_METERS
= 0x45,
477 CORRECTED_ERRS
= 0x50,
478 UNCORRECTABLE_ERRS
= 0x51,
486 METERS_SEC_SQUARED
= 0x59,
488 CUBIC_METERS_SEC
= 0x5B,
490 RADIANS_SEC_SQUARED
= 0x5D,
495 * struct scmi_sensor_proto_ops - represents the various operations provided
496 * by SCMI Sensor Protocol
498 * @count_get: get the count of sensors provided by SCMI
499 * @info_get: get the information of the specified sensor
500 * @trip_point_config: selects and configures a trip-point of interest
501 * @reading_get: gets the current value of the sensor
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
507 * @config_get: Get sensor current configuration
508 * @config_set: Set sensor current configuration
510 struct scmi_sensor_proto_ops
{
511 int (*count_get
)(const struct scmi_protocol_handle
*ph
);
512 const struct scmi_sensor_info __must_check
*(*info_get
)
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
,
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
);
528 * struct scmi_reset_proto_ops - represents the various operations provided
529 * by SCMI Reset Protocol
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
538 struct scmi_reset_proto_ops
{
539 int (*num_domains_get
)(const struct scmi_protocol_handle
*ph
);
540 const char *(*name_get
)(const struct scmi_protocol_handle
*ph
,
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
);
548 enum scmi_voltage_level_mode
{
549 SCMI_VOLTAGE_LEVEL_SET_AUTO
,
550 SCMI_VOLTAGE_LEVEL_SET_SYNC
,
554 * struct scmi_voltage_info - describe one available SCMI Voltage Domain
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.
565 * @async_level_set: True when the voltage domain supports asynchronous level
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
572 struct scmi_voltage_info
{
575 bool negative_volts_allowed
;
576 bool async_level_set
;
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
586 * struct scmi_voltage_proto_ops - represents the various operations provided
587 * by SCMI Voltage Protocol
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
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
,
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
,
606 int (*level_set
)(const struct scmi_protocol_handle
*ph
, u32 domain_id
,
607 enum scmi_voltage_level_mode mode
, s32 volt_uV
);
608 int (*level_get
)(const struct scmi_protocol_handle
*ph
, u32 domain_id
,
613 * struct scmi_powercap_info - Describe one available Powercap domain
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
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.
643 struct scmi_powercap_info
{
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
;
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
;
665 struct scmi_fc_info
*fc_info
;
669 * struct scmi_powercap_proto_ops - represents the various operations provided
670 * by SCMI Powercap Protocol
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.
675 * On SCMI platforms supporting powercap zone disabling, this could
676 * report a zero value for a zone where powercapping is disabled.
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.
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.
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
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
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.
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
,
720 int (*cap_set
)(const struct scmi_protocol_handle
*ph
, u32 domain_id
,
721 u32 power_cap
, bool ignore_dresp
);
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
);
726 int (*pai_get
)(const struct scmi_protocol_handle
*ph
, u32 domain_id
,
728 int (*pai_set
)(const struct scmi_protocol_handle
*ph
, u32 domain_id
,
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
);
740 enum scmi_pinctrl_selector_type
{
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,
773 * struct scmi_pinctrl_proto_ops - represents the various operations provided
774 * by SCMI Pinctrl Protocol
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
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
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
,
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
,
803 int (*settings_get_one
)(const struct scmi_protocol_handle
*ph
,
805 enum scmi_pinctrl_selector_type type
,
806 enum scmi_pinctrl_conf_type config_type
,
808 int (*settings_get_all
)(const struct scmi_protocol_handle
*ph
,
810 enum scmi_pinctrl_selector_type type
,
811 unsigned int *nr_configs
,
812 enum scmi_pinctrl_conf_type
*config_types
,
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
,
819 int (*pin_request
)(const struct scmi_protocol_handle
*ph
, u32 pin
);
820 int (*pin_free
)(const struct scmi_protocol_handle
*ph
, u32 pin
);
824 * struct scmi_notify_ops - represents notifications' operations provided by
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
830 * @event_notifier_register: Register a notifier_block for the requested event
831 * @event_notifier_unregister: Unregister a notifier_block for the requested
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
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_
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)
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.
852 * Received notifications are finally delivered to the registered users,
853 * invoking the callback provided with the notifier_block *nb as follows:
855 * int user_cb(nb, evt_id, report)
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
863 struct scmi_notify_ops
{
864 int (*devm_event_notifier_register
)(struct scmi_device
*sdev
,
865 u8 proto_id
, u8 evt_id
,
867 struct notifier_block
*nb
);
868 int (*devm_event_notifier_unregister
)(struct scmi_device
*sdev
,
869 struct notifier_block
*nb
);
870 int (*event_notifier_register
)(const struct scmi_handle
*handle
,
871 u8 proto_id
, u8 evt_id
,
873 struct notifier_block
*nb
);
874 int (*event_notifier_unregister
)(const struct scmi_handle
*handle
,
875 u8 proto_id
, u8 evt_id
,
877 struct notifier_block
*nb
);
881 * struct scmi_handle - Handle returned to ARM SCMI clients for usage.
883 * @dev: pointer to the SCMI device
884 * @version: pointer to the structure containing SCMI version information
885 * @devm_protocol_acquire: devres managed method to get hold of a protocol,
886 * causing its initialization and related resource
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
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.
898 * An optional atomic threshold value could be returned
900 * @notify_ops: pointer to set of notifications related operations
904 struct scmi_revision_info
*version
;
906 int __must_check (*devm_protocol_acquire
)(struct scmi_device
*sdev
,
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
);
912 bool (*is_transport_atomic
)(const struct scmi_handle
*handle
,
913 unsigned int *atomic_threshold
);
915 const struct scmi_notify_ops
*notify_ops
;
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,
925 SCMI_PROTOCOL_RESET
= 0x16,
926 SCMI_PROTOCOL_VOLTAGE
= 0x17,
927 SCMI_PROTOCOL_POWERCAP
= 0x18,
928 SCMI_PROTOCOL_PINCTRL
= 0x19,
931 enum scmi_system_events
{
932 SCMI_SYSTEM_SHUTDOWN
,
933 SCMI_SYSTEM_COLDRESET
,
934 SCMI_SYSTEM_WARMRESET
,
945 struct scmi_handle
*handle
;
948 #define to_scmi_dev(d) container_of_const(d, struct scmi_device, dev)
950 struct scmi_device_id
{
957 int (*probe
)(struct scmi_device
*sdev
);
958 void (*remove
)(struct scmi_device
*sdev
);
959 const struct scmi_device_id
*id_table
;
961 struct device_driver driver
;
964 #define to_scmi_driver(d) container_of(d, struct scmi_driver, driver)
966 #if IS_REACHABLE(CONFIG_ARM_SCMI_PROTOCOL)
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
);
972 scmi_driver_register(struct scmi_driver
*driver
, struct module
*owner
,
973 const char *mod_name
)
978 static inline void scmi_driver_unregister(struct scmi_driver
*driver
) {}
979 #endif /* CONFIG_ARM_SCMI_PROTOCOL */
981 #define scmi_register(driver) \
982 scmi_driver_register(driver, THIS_MODULE, KBUILD_MODNAME)
983 #define scmi_unregister(driver) \
984 scmi_driver_unregister(driver)
987 * module_scmi_driver() - Helper macro for registering a scmi driver
988 * @__scmi_driver: scmi_driver structure
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.
994 #define module_scmi_driver(__scmi_driver) \
995 module_driver(__scmi_driver, scmi_register, scmi_unregister)
998 * module_scmi_protocol() - Helper macro for registering a scmi protocol
999 * @__scmi_protocol: scmi_protocol structure
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.
1005 #define module_scmi_protocol(__scmi_protocol) \
1006 module_driver(__scmi_protocol, \
1007 scmi_protocol_register, scmi_protocol_unregister)
1009 struct scmi_protocol
;
1010 int scmi_protocol_register(const struct scmi_protocol
*proto
);
1011 void scmi_protocol_unregister(const struct scmi_protocol
*proto
);
1013 /* SCMI Notification API - Custom Event Reports */
1014 enum scmi_notification_events
{
1015 SCMI_EVENT_POWER_STATE_CHANGED
= 0x0,
1016 SCMI_EVENT_CLOCK_RATE_CHANGED
= 0x0,
1017 SCMI_EVENT_CLOCK_RATE_CHANGE_REQUESTED
= 0x1,
1018 SCMI_EVENT_PERFORMANCE_LIMITS_CHANGED
= 0x0,
1019 SCMI_EVENT_PERFORMANCE_LEVEL_CHANGED
= 0x1,
1020 SCMI_EVENT_SENSOR_TRIP_POINT_EVENT
= 0x0,
1021 SCMI_EVENT_SENSOR_UPDATE
= 0x1,
1022 SCMI_EVENT_RESET_ISSUED
= 0x0,
1023 SCMI_EVENT_BASE_ERROR_EVENT
= 0x0,
1024 SCMI_EVENT_SYSTEM_POWER_STATE_NOTIFIER
= 0x0,
1025 SCMI_EVENT_POWERCAP_CAP_CHANGED
= 0x0,
1026 SCMI_EVENT_POWERCAP_MEASUREMENTS_CHANGED
= 0x1,
1029 struct scmi_power_state_changed_report
{
1031 unsigned int agent_id
;
1032 unsigned int domain_id
;
1033 unsigned int power_state
;
1036 struct scmi_clock_rate_notif_report
{
1038 unsigned int agent_id
;
1039 unsigned int clock_id
;
1040 unsigned long long rate
;
1043 struct scmi_system_power_state_notifier_report
{
1045 unsigned int agent_id
;
1046 #define SCMI_SYSPOWER_IS_REQUEST_GRACEFUL(flags) ((flags) & BIT(0))
1048 unsigned int system_state
;
1049 unsigned int timeout
;
1052 struct scmi_perf_limits_report
{
1054 unsigned int agent_id
;
1055 unsigned int domain_id
;
1056 unsigned int range_max
;
1057 unsigned int range_min
;
1058 unsigned long range_max_freq
;
1059 unsigned long range_min_freq
;
1062 struct scmi_perf_level_report
{
1064 unsigned int agent_id
;
1065 unsigned int domain_id
;
1066 unsigned int performance_level
;
1067 unsigned long performance_level_freq
;
1070 struct scmi_sensor_trip_point_report
{
1072 unsigned int agent_id
;
1073 unsigned int sensor_id
;
1074 unsigned int trip_point_desc
;
1077 struct scmi_sensor_update_report
{
1079 unsigned int agent_id
;
1080 unsigned int sensor_id
;
1081 unsigned int readings_count
;
1082 struct scmi_sensor_reading readings
[];
1085 struct scmi_reset_issued_report
{
1087 unsigned int agent_id
;
1088 unsigned int domain_id
;
1089 unsigned int reset_state
;
1092 struct scmi_base_error_report
{
1094 unsigned int agent_id
;
1096 unsigned int cmd_count
;
1097 unsigned long long reports
[];
1100 struct scmi_powercap_cap_changed_report
{
1102 unsigned int agent_id
;
1103 unsigned int domain_id
;
1104 unsigned int power_cap
;
1108 struct scmi_powercap_meas_changed_report
{
1110 unsigned int agent_id
;
1111 unsigned int domain_id
;
1114 #endif /* _LINUX_SCMI_PROTOCOL_H */