blob: 34f272c448cf06fc7f1053e54c8469977a6e0a74 [file] [log] [blame]
Etienne Carriere02fd1262020-09-09 18:44:00 +02001/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
2/*
3 * Copyright (c) 2015-2019, Arm Limited and Contributors. All rights reserved.
4 * Copyright (C) 2019-2020, Linaro Limited
5 */
6#ifndef _SCMI_PROTOCOLS_H
7#define _SCMI_PROTOCOLS_H
8
9#include <linux/bitops.h>
Etienne Carriere78928e12020-09-09 18:44:04 +020010#include <asm/types.h>
Etienne Carriere02fd1262020-09-09 18:44:00 +020011
12/*
13 * Subset the SCMI protocols definition
14 * based on SCMI specification v2.0 (DEN0056B)
15 * https://developer.arm.com/docs/den0056/b
16 */
17
18enum scmi_std_protocol {
19 SCMI_PROTOCOL_ID_BASE = 0x10,
20 SCMI_PROTOCOL_ID_POWER_DOMAIN = 0x11,
21 SCMI_PROTOCOL_ID_SYSTEM = 0x12,
22 SCMI_PROTOCOL_ID_PERF = 0x13,
23 SCMI_PROTOCOL_ID_CLOCK = 0x14,
24 SCMI_PROTOCOL_ID_SENSOR = 0x15,
25 SCMI_PROTOCOL_ID_RESET_DOMAIN = 0x16,
Etienne Carriered68663a2021-03-08 22:38:06 +010026 SCMI_PROTOCOL_ID_VOLTAGE_DOMAIN = 0x17,
Alice Guoaeb03192025-04-28 18:37:26 +080027 SCMI_PROTOCOL_ID_PINCTRL = 0x19,
Peng Fan8cbe7002025-04-28 18:37:28 +080028 SCMI_PROTOCOL_ID_IMX_MISC = 0x84,
Etienne Carriere02fd1262020-09-09 18:44:00 +020029};
30
31enum scmi_status_code {
32 SCMI_SUCCESS = 0,
33 SCMI_NOT_SUPPORTED = -1,
34 SCMI_INVALID_PARAMETERS = -2,
35 SCMI_DENIED = -3,
36 SCMI_NOT_FOUND = -4,
37 SCMI_OUT_OF_RANGE = -5,
38 SCMI_BUSY = -6,
39 SCMI_COMMS_ERROR = -7,
40 SCMI_GENERIC_ERROR = -8,
41 SCMI_HARDWARE_ERROR = -9,
42 SCMI_PROTOCOL_ERROR = -10,
43};
44
Etienne Carriere78928e12020-09-09 18:44:04 +020045/*
Etienne Carriere4c4ec902022-02-21 09:22:42 +010046 * Generic message IDs
47 */
48enum scmi_discovery_id {
49 SCMI_PROTOCOL_VERSION = 0x0,
50 SCMI_PROTOCOL_ATTRIBUTES = 0x1,
51 SCMI_PROTOCOL_MESSAGE_ATTRIBUTES = 0x2,
52};
53
Peng Fan8cbe7002025-04-28 18:37:28 +080054enum scmi_imx_misc_message_id {
55 SCMI_MISC_ROM_PASSOVER_GET = 0x7
56};
57
Etienne Carriere4c4ec902022-02-21 09:22:42 +010058/*
AKASHI Takahirod1ce56a2023-10-11 19:07:00 +090059 * SCMI Base Protocol
60 */
61#define SCMI_BASE_PROTOCOL_VERSION 0x20000
62
63enum scmi_base_message_id {
64 SCMI_BASE_DISCOVER_VENDOR = 0x3,
65 SCMI_BASE_DISCOVER_SUB_VENDOR = 0x4,
66 SCMI_BASE_DISCOVER_IMPL_VERSION = 0x5,
67 SCMI_BASE_DISCOVER_LIST_PROTOCOLS = 0x6,
68 SCMI_BASE_DISCOVER_AGENT = 0x7,
69 SCMI_BASE_NOTIFY_ERRORS = 0x8,
70 SCMI_BASE_SET_DEVICE_PERMISSIONS = 0x9,
71 SCMI_BASE_SET_PROTOCOL_PERMISSIONS = 0xa,
72 SCMI_BASE_RESET_AGENT_CONFIGURATION = 0xb,
73};
74
75#define SCMI_BASE_NAME_LENGTH_MAX 16
76
77/**
78 * struct scmi_protocol_version_out - Response for SCMI_PROTOCOL_VERSION
79 * command
80 * @status: SCMI command status
81 * @version: Protocol version
82 */
83struct scmi_protocol_version_out {
84 s32 status;
85 u32 version;
86};
87
88/**
89 * struct scmi_protocol_attrs_out - Response for SCMI_PROTOCOL_ATTRIBUTES
90 * command
91 * @status: SCMI command status
92 * @attributes: Protocol attributes or implementation details
93 */
94struct scmi_protocol_attrs_out {
95 s32 status;
96 u32 attributes;
97};
98
99#define SCMI_PROTOCOL_ATTRS_NUM_AGENTS(attributes) \
100 (((attributes) & GENMASK(15, 8)) >> 8)
101#define SCMI_PROTOCOL_ATTRS_NUM_PROTOCOLS(attributes) \
102 ((attributes) & GENMASK(7, 0))
103
104/**
105 * struct scmi_protocol_msg_attrs_out - Response for
106 * SCMI_PROTOCOL_MESSAGE_ATTRIBUTES command
107 * @status: SCMI command status
108 * @attributes: Message-specific attributes
109 */
110struct scmi_protocol_msg_attrs_out {
111 s32 status;
112 u32 attributes;
113};
114
115/**
116 * struct scmi_base_discover_vendor_out - Response for
117 * SCMI_BASE_DISCOVER_VENDOR or
118 * SCMI_BASE_DISCOVER_SUB_VENDOR command
119 * @status: SCMI command status
120 * @vendor_identifier: Name of vendor or sub-vendor in string
121 */
122struct scmi_base_discover_vendor_out {
123 s32 status;
124 u8 vendor_identifier[SCMI_BASE_NAME_LENGTH_MAX];
125};
126
127/**
128 * struct scmi_base_discover_impl_version_out - Response for
129 * SCMI_BASE_DISCOVER_IMPL_VERSION command
130 * @status: SCMI command status
131 * @impl_version: Vendor-specific implementation version
132 */
133struct scmi_base_discover_impl_version_out {
134 s32 status;
135 u32 impl_version;
136};
137
138/**
139 * struct scmi_base_discover_list_protocols_out - Response for
140 * SCMI_BASE_DISCOVER_LIST_PROTOCOLS command
141 * @status: SCMI command status
142 * @num_protocols: Number of SCMI protocols in @protocol
143 * @protocols: Array of packed SCMI protocol ID's
144 */
145struct scmi_base_discover_list_protocols_out {
146 s32 status;
147 u32 num_protocols;
148 u32 protocols[3];
149};
150
151/**
152 * struct scmi_base_discover_agent_out - Response for
153 * SCMI_BASE_DISCOVER_AGENT command
154 * @status: SCMI command status
155 * @agent_id: SCMI agent ID
156 * @name: Name of agent in string
157 */
158struct scmi_base_discover_agent_out {
159 s32 status;
160 u32 agent_id;
161 u8 name[SCMI_BASE_NAME_LENGTH_MAX];
162};
163
164#define SCMI_BASE_NOTIFY_ERRORS_ENABLE BIT(0)
165
166/**
167 * struct scmi_base_set_device_permissions_in - Parameters for
168 * SCMI_BASE_SET_DEVICE_PERMISSIONS command
169 * @agent_id: SCMI agent ID
170 * @device_id: device ID
171 * @flags: A set of flags
172 */
173struct scmi_base_set_device_permissions_in {
174 u32 agent_id;
175 u32 device_id;
176 u32 flags;
177};
178
179#define SCMI_BASE_SET_DEVICE_PERMISSIONS_ACCESS BIT(0)
180
181/**
182 * struct scmi_base_set_protocol_permissions_in - Parameters for
183 * SCMI_BASE_SET_PROTOCOL_PERMISSIONS command
184 * @agent_id: SCMI agent ID
185 * @device_id: device ID
186 * @command_id: command ID
187 * @flags: A set of flags
188 */
189struct scmi_base_set_protocol_permissions_in {
190 u32 agent_id;
191 u32 device_id;
192 u32 command_id;
193 u32 flags;
194};
195
196#define SCMI_BASE_SET_PROTOCOL_PERMISSIONS_COMMAND GENMASK(7, 0)
197#define SCMI_BASE_SET_PROTOCOL_PERMISSIONS_ACCESS BIT(0)
198
199/**
200 * struct scmi_base_reset_agent_configuration_in - Parameters for
201 * SCMI_BASE_RESET_AGENT_CONFIGURATION command
202 * @agent_id: SCMI agent ID
203 * @flags: A set of flags
204 */
205struct scmi_base_reset_agent_configuration_in {
206 u32 agent_id;
207 u32 flags;
208};
209
210#define SCMI_BASE_RESET_ALL_ACCESS_PERMISSIONS BIT(0)
211
212/**
213 * struct scmi_base_ops - SCMI base protocol interfaces
214 */
215struct scmi_base_ops {
216 /**
217 * protocol_version - get Base protocol version
218 * @dev: SCMI protocol device
219 * @version: Pointer to SCMI protocol version
220 *
221 * Obtain the protocol version number in @version for Base protocol.
222 *
223 * Return: 0 on success, error code on failure
224 */
225 int (*protocol_version)(struct udevice *dev, u32 *version);
226 /**
227 * protocol_attrs - get protocol attributes
228 * @dev: SCMI protocol device
229 * @num_agents: Number of SCMI agents
230 * @num_protocols: Number of SCMI protocols
231 *
232 * Obtain the protocol attributes, the number of agents and the number
233 * of protocols, in @num_agents and @num_protocols respectively, that
234 * the device provides.
235 *
236 * Return: 0 on success, error code on failure
237 */
238 int (*protocol_attrs)(struct udevice *dev, u32 *num_agents,
239 u32 *num_protocols);
240 /**
241 * protocol_message_attrs - get message-specific attributes
242 * @dev: SCMI protocol device
243 * @message_id: SCMI message ID
244 * @attributes: Message-specific attributes
245 *
246 * Obtain the message-specific attributes in @attributes.
247 * This command succeeds if the message is implemented and available.
248 *
249 * Return: 0 on success, error code on failure
250 */
251 int (*protocol_message_attrs)(struct udevice *dev, u32 message_id,
252 u32 *attributes);
253 /**
254 * base_discover_vendor - get vendor name
255 * @dev: SCMI protocol device
256 * @vendor: Pointer to vendor name
257 *
258 * Obtain the vendor's name in @vendor.
259 * It is a caller's responsibility to free @vendor.
260 *
261 * Return: 0 on success, error code on failure
262 */
263 int (*base_discover_vendor)(struct udevice *dev, u8 **vendor);
264 /**
265 * base_discover_sub_vendor - get sub-vendor name
266 * @dev: SCMI protocol device
267 * @sub_vendor: Pointer to sub-vendor name
268 *
269 * Obtain the sub-vendor's name in @sub_vendor.
270 * It is a caller's responsibility to free @sub_vendor.
271 *
272 * Return: 0 on success, error code on failure
273 */
274 int (*base_discover_sub_vendor)(struct udevice *dev, u8 **sub_vendor);
275 /**
276 * base_discover_impl_version - get implementation version
277 * @dev: SCMI protocol device
278 * @impl_version: Pointer to implementation version
279 *
280 * Obtain the implementation version number in @impl_version.
281 *
282 * Return: 0 on success, error code on failure
283 */
284 int (*base_discover_impl_version)(struct udevice *dev,
285 u32 *impl_version);
286 /**
287 * base_discover_list_protocols - get list of protocols
288 * @dev: SCMI protocol device
289 * @protocols: Pointer to array of SCMI protocols
290 *
291 * Obtain the list of protocols provided in @protocols.
292 * The number of elements in @protocols always match to the number of
293 * protocols returned by smci_protocol_attrs() when this function
294 * succeeds.
295 * It is a caller's responsibility to free @protocols.
296 *
297 * Return: the number of protocols in @protocols on success,
298 * error code on failure
299 */
300 int (*base_discover_list_protocols)(struct udevice *dev,
301 u8 **protocols);
302 /**
303 * base_discover_agent - identify agent
304 * @dev: SCMI protocol device
305 * @agent_id: SCMI agent ID
306 * @ret_agent_id: Pointer to SCMI agent ID
307 * @name: Pointer to SCMI agent name
308 *
309 * Obtain the agent's name in @name. If @agent_id is equal to
310 * 0xffffffff, * this function returns the caller's agent id in
311 * @ret_agent_id.
312 * It is a caller's responsibility to free @name.
313 *
314 * Return: 0 on success, error code on failure
315 */
316 int (*base_discover_agent)(struct udevice *dev, u32 agent_id,
317 u32 *ret_agent_id, u8 **name);
318 /**
319 * base_notify_errors - configure error notification
320 * @dev: SCMI protocol device
321 * @enable: Operation
322 *
323 * Enable or disable error notification from SCMI firmware.
324 *
325 * Return: 0 on success, error code on failure
326 */
327 int (*base_notify_errors)(struct udevice *dev, u32 enable);
328 /**
329 * base_set_device_permissions - configure access permission to device
330 * @dev: SCMI protocol device
331 * @agent_id: SCMI agent ID
332 * @device_id: ID of device to access
333 * @flags: A set of flags
334 *
335 * Ask for allowing or denying access permission to the device,
336 * @device_id. The meaning of @flags is defined in SCMI specification.
337 *
338 * Return: 0 on success, error code on failure
339 */
340 int (*base_set_device_permissions)(struct udevice *dev, u32 agent_id,
341 u32 device_id, u32 flags);
342 /**
343 * base_set_protocol_permissions - configure access permission to
344 * protocol on device
345 * @dev: SCMI protocol device
346 * @agent_id: SCMI agent ID
347 * @device_id: ID of device to access
348 * @command_id: command ID
349 * @flags: A set of flags
350 *
351 * Ask for allowing or denying access permission to the protocol,
352 * @command_id, on the device, @device_id.
353 * The meaning of @flags is defined in SCMI specification.
354 *
355 * Return: 0 on success, error code on failure
356 */
357 int (*base_set_protocol_permissions)(struct udevice *dev, u32 agent_id,
358 u32 device_id, u32 command_id,
359 u32 flags);
360 /**
361 * base_reset_agent_configuration - reset resource settings
362 * @dev: SCMI protocol device
363 * @agent_id: SCMI agent ID
364 * @flags: A set of flags
365 *
366 * Reset all the resource settings against @agent_id.
367 * The meaning of @flags is defined in SCMI specification.
368 *
369 * Return: 0 on success, error code on failure
370 */
371 int (*base_reset_agent_configuration)(struct udevice *dev, u32 agent_id,
372 u32 flags);
373};
374
375/**
376 * scmi_generic_protocol_version - get protocol version
377 * @dev: SCMI protocol device
378 * @id: SCMI protocol ID
379 * @version: Pointer to SCMI protocol version
380 *
381 * Obtain the protocol version number in @version.
382 *
383 * Return: 0 on success, error code on failure
384 */
385int scmi_generic_protocol_version(struct udevice *dev,
386 enum scmi_std_protocol id, u32 *version);
387
388/**
389 * scmi_base_protocol_version - get Base protocol version
390 * @dev: SCMI protocol device
391 * @version: Pointer to SCMI protocol version
392 *
393 * Obtain the protocol version number in @version for Base protocol.
394 *
395 * Return: 0 on success, error code on failure
396 */
397int scmi_base_protocol_version(struct udevice *dev, u32 *version);
398
399/**
400 * scmi_protocol_attrs - get protocol attributes
401 * @dev: SCMI protocol device
402 * @num_agents: Number of SCMI agents
403 * @num_protocols: Number of SCMI protocols
404 *
405 * Obtain the protocol attributes, the number of agents and the number
406 * of protocols, in @num_agents and @num_protocols respectively, that
407 * the device provides.
408 *
409 * Return: 0 on success, error code on failure
410 */
411int scmi_base_protocol_attrs(struct udevice *dev, u32 *num_agents,
412 u32 *num_protocols);
413
414/**
415 * scmi_protocol_message_attrs - get message-specific attributes
416 * @dev: SCMI protocol device
417 * @message_id: SCMI message ID
418 * @attributes: Message-specific attributes
419 *
420 * Obtain the message-specific attributes in @attributes.
421 * This command succeeds if the message is implemented and available.
422 *
423 * Return: 0 on success, error code on failure
424 */
425int scmi_base_protocol_message_attrs(struct udevice *dev, u32 message_id,
426 u32 *attributes);
427
428/**
429 * scmi_base_discover_vendor - get vendor name
430 * @dev: SCMI protocol device
431 * @vendor: Pointer to vendor name
432 *
433 * Obtain the vendor's name in @vendor.
434 * It is a caller's responsibility to free @vendor.
435 *
436 * Return: 0 on success, error code on failure
437 */
438int scmi_base_discover_vendor(struct udevice *dev, u8 **vendor);
439
440/**
441 * scmi_base_discover_sub_vendor - get sub-vendor name
442 * @dev: SCMI protocol device
443 * @sub_vendor: Pointer to sub-vendor name
444 *
445 * Obtain the sub-vendor's name in @sub_vendor.
446 * It is a caller's responsibility to free @sub_vendor.
447 *
448 * Return: 0 on success, error code on failure
449 */
450int scmi_base_discover_sub_vendor(struct udevice *dev, u8 **sub_vendor);
451
452/**
453 * scmi_base_discover_impl_version - get implementation version
454 * @dev: SCMI protocol device
455 * @impl_version: Pointer to implementation version
456 *
457 * Obtain the implementation version number in @impl_version.
458 *
459 * Return: 0 on success, error code on failure
460 */
461int scmi_base_discover_impl_version(struct udevice *dev, u32 *impl_version);
462
463/**
464 * scmi_base_discover_list_protocols - get list of protocols
465 * @dev: SCMI protocol device
466 * @protocols: Pointer to array of SCMI protocols
467 *
468 * Obtain the list of protocols provided in @protocols.
469 * The number of elements in @protocols always match to the number of
470 * protocols returned by smci_protocol_attrs() when this function succeeds.
471 * It is a caller's responsibility to free @protocols.
472 *
473 * Return: the number of protocols in @protocols on success, error code on
474 * failure
475 */
476int scmi_base_discover_list_protocols(struct udevice *dev, u8 **protocols);
477
478/**
479 * scmi_base_discover_agent - identify agent
480 * @dev: SCMI protocol device
481 * @agent_id: SCMI agent ID
482 * @ret_agent_id: Pointer to SCMI agent ID
483 * @name: Pointer to SCMI agent name
484 *
485 * Obtain the agent's name in @name. If @agent_id is equal to 0xffffffff,
486 * this function returns the caller's agent id in @ret_agent_id.
487 * It is a caller's responsibility to free @name.
488 *
489 * Return: 0 on success, error code on failure
490 */
491int scmi_base_discover_agent(struct udevice *dev, u32 agent_id,
492 u32 *ret_agent_id, u8 **name);
493
494/**
495 * scmi_base_notify_errors - configure error notification
496 * @dev: SCMI protocol device
497 * @enable: Operation
498 *
499 * Enable or disable error notification from SCMI firmware.
500 *
501 * Return: 0 on success, error code on failure
502 */
503int scmi_base_notify_errors(struct udevice *dev, u32 enable);
504
505/**
506 * scmi_base_set_device_permissions - configure access permission to device
507 * @dev: SCMI protocol device
508 * @agent_id: SCMI agent ID
509 * @device_id: ID of device to access
510 * @flags: A set of flags
511 *
512 * Ask for allowing or denying access permission to the device, @device_id.
513 * The meaning of @flags is defined in SCMI specification.
514 *
515 * Return: 0 on success, error code on failure
516 */
517int scmi_base_set_device_permissions(struct udevice *dev, u32 agent_id,
518 u32 device_id, u32 flags);
519
520/**
521 * scmi_base_set_protocol_permissions - configure access permission to
522 * protocol on device
523 * @dev: SCMI protocol device
524 * @agent_id: SCMI agent ID
525 * @device_id: ID of device to access
526 * @command_id: SCMI command ID
527 * @flags: A set of flags
528 *
529 * Ask for allowing or denying access permission to the protocol, @command_id,
530 * on the device, @device_id.
531 * The meaning of @flags is defined in SCMI specification.
532 *
533 * Return: 0 on success, error code on failure
534 */
535int scmi_base_set_protocol_permissions(struct udevice *dev,
536 u32 agent_id, u32 device_id,
537 u32 command_id, u32 flags);
538
539/**
540 * scmi_base_reset_agent_configuration - reset resource settings
541 * @dev: SCMI protocol device
542 * @agent_id: SCMI agent ID
543 * @flags: A set of flags
544 *
545 * Reset all the resource settings against @agent_id.
546 * The meaning of @flags is defined in SCMI specification.
547 *
548 * Return: 0 on success, error code on failure
549 */
550int scmi_base_reset_agent_configuration(struct udevice *dev, u32 agent_id,
551 u32 flags);
552
553/*
AKASHI Takahiro8f00d022023-10-16 14:39:43 +0900554 * SCMI Power Domain Management Protocol
555 */
556
557#define SCMI_PWD_PROTOCOL_VERSION 0x30000
558#define SCMI_PWD_PSTATE_TYPE_LOST BIT(30)
559#define SCMI_PWD_PSTATE_ID GENMASK(27, 0)
560
561enum scmi_power_domain_message_id {
562 SCMI_PWD_ATTRIBUTES = 0x3,
563 SCMI_PWD_STATE_SET = 0x4,
564 SCMI_PWD_STATE_GET = 0x5,
565 SCMI_PWD_STATE_NOTIFY = 0x6,
566 SCMI_PWD_STATE_CHANGE_REQUESTED_NOTIFY = 0x7,
567 SCMI_PWD_NAME_GET = 0x8,
568};
569
570/**
571 * struct scmi_pwd_protocol_attrs_out
572 * @status: SCMI command status
573 * @attributes: Protocol attributes
574 * @stats_addr_low: Lower 32 bits of address of statistics memory region
575 * @stats_addr_high: Higher 32 bits of address of statistics memory region
576 * @stats_len: Length of statistics memory region
577 */
578struct scmi_pwd_protocol_attrs_out {
579 s32 status;
580 u32 attributes;
581 u32 stats_addr_low;
582 u32 stats_addr_high;
583 u32 stats_len;
584};
585
586#define SCMI_PWD_PROTO_ATTRS_NUM_PWD(attributes) ((attributes) & GENMASK(15, 0))
587
588/**
589 * struct scmi_pwd_protocol_msg_attrs_out
590 * @status: SCMI command status
591 * @attributes: Message-specific attributes
592 */
593struct scmi_pwd_protocol_msg_attrs_out {
594 s32 status;
595 u32 attributes;
596};
597
598#define SCMI_PWD_NAME_LENGTH_MAX 16
599
600/**
601 * struct scmi_pwd_attrs_out
602 * @status: SCMI command status
603 * @attributes: Power domain attributes
604 * @name: Name of power domain
605 */
606struct scmi_pwd_attrs_out {
607 s32 status;
608 u32 attributes;
609 u8 name[SCMI_PWD_NAME_LENGTH_MAX];
610};
611
612#define SCMI_PWD_ATTR_PSTATE_CHANGE_NOTIFY BIT(31)
613#define SCMI_PWD_ATTR_PSTATE_ASYNC BIT(30)
614#define SCMI_PWD_ATTR_PSTATE_SYNC BIT(29)
615#define SCMI_PWD_ATTR_PSTATE_CHANGE_RQ_NOTIFY BIT(28)
616#define SCMI_PWD_ATTR_EXTENDED_NAME BIT(27)
617
618/**
619 * struct scmi_pwd_state_set_in
620 * @flags: Flags
621 * @domain_id: Identifier of power domain
622 * @pstate: Power state of the domain
623 */
624struct scmi_pwd_state_set_in {
625 u32 flags;
626 u32 domain_id;
627 u32 pstate;
628};
629
630#define SCMI_PWD_SET_FLAGS_ASYNC BIT(0)
631
632/**
633 * struct scmi_pwd_state_get_out
634 * @status: SCMI command status
635 * @pstate: Power state of the domain
636 */
637struct scmi_pwd_state_get_out {
638 s32 status;
639 u32 pstate;
640};
641
642#define SCMI_PWD_EXTENDED_NAME_MAX 64
643/**
644 * struct scmi_pwd_name_get_out
645 * @status: SCMI command status
646 * @flags: Parameter flags
647 * @extended_name: Extended name of power domain
648 */
649struct scmi_pwd_name_get_out {
650 s32 status;
651 u32 flags;
652 u8 extended_name[SCMI_PWD_EXTENDED_NAME_MAX];
653};
654
655/**
656 * scmi_pwd_protocol_attrs - get protocol attributes
657 * @dev: SCMI protocol device
658 * @num_pwdoms: Number of power domains
659 * @stats_addr: Address of statistics memory region
660 * @stats_len: Length of statistics memory region
661 *
662 * Obtain the protocol attributes, the number of power domains and
663 * the information of statistics memory region.
664 *
665 * Return: 0 on success, error code on failure
666 */
667int scmi_pwd_protocol_attrs(struct udevice *dev, int *num_pwdoms,
668 u64 *stats_addr, size_t *stats_len);
669/**
670 * scmi_pwd_protocol_message_attrs - get message-specific attributes
671 * @dev: SCMI protocol device
672 * @message_id: SCMI message ID
673 * @attributes: Message-specific attributes
674 *
675 * Obtain the message-specific attributes in @attributes.
676 *
677 * Return: 0 on success, error code on failure
678 */
679int scmi_pwd_protocol_message_attrs(struct udevice *dev, s32 message_id,
680 u32 *attributes);
681/**
682 * scmi_pwd_attrs - get power domain attributes
683 * @dev: SCMI protocol device
684 * @domain_id: Identifier of power domain
685 * @attributes: Power domain attributes
686 * @name: Name of power domain
687 *
688 * Obtain the attributes of the given power domain, @domain_id, in @attributes
689 * as well as its name in @name.
690 *
691 * Return: 0 on success, error code on failure
692 */
693int scmi_pwd_attrs(struct udevice *dev, u32 message_id, u32 *attributes,
694 u8 **name);
695/**
696 * scmi_pwd_state_set - set power state
697 * @dev: SCMI protocol device
698 * @flags: Parameter flags
699 * @domain_id: Identifier of power domain
700 * @pstate: Power state
701 *
702 * Change the power state of the given power domain, @domain_id.
703 *
704 * Return: 0 on success, error code on failure
705 */
706int scmi_pwd_state_set(struct udevice *dev, u32 flags, u32 domain_id,
707 u32 pstate);
708/**
709 * scmi_pwd_state_get - get power state
710 * @dev: SCMI protocol device
711 * @domain_id: Identifier of power domain
712 * @pstate: Power state
713 *
714 * Obtain the power state of the given power domain, @domain_id.
715 *
716 * Return: 0 on success, error code on failure
717 */
718int scmi_pwd_state_get(struct udevice *dev, u32 domain_id, u32 *pstate);
719/**
720 * scmi_pwd_name_get - get extended name
721 * @dev: SCMI protocol device
722 * @domain_id: Identifier of power domain
723 * @name: Extended name of the domain
724 *
725 * Obtain the extended name of the given power domain, @domain_id, in @name.
726 *
727 * Return: 0 on success, error code on failure
728 */
729int scmi_pwd_name_get(struct udevice *dev, u32 domain_id, u8 **name);
730
731/*
Etienne Carriere78928e12020-09-09 18:44:04 +0200732 * SCMI Clock Protocol
733 */
734
735enum scmi_clock_message_id {
Etienne Carriere4c4ec902022-02-21 09:22:42 +0100736 SCMI_CLOCK_ATTRIBUTES = 0x3,
Etienne Carriere78928e12020-09-09 18:44:04 +0200737 SCMI_CLOCK_RATE_SET = 0x5,
738 SCMI_CLOCK_RATE_GET = 0x6,
739 SCMI_CLOCK_CONFIG_SET = 0x7,
740};
741
Etienne Carriere4c4ec902022-02-21 09:22:42 +0100742#define SCMI_CLK_PROTO_ATTR_COUNT_MASK GENMASK(15, 0)
Etienne Carriere78928e12020-09-09 18:44:04 +0200743#define SCMI_CLK_RATE_ASYNC_NOTIFY BIT(0)
744#define SCMI_CLK_RATE_ASYNC_NORESP (BIT(0) | BIT(1))
745#define SCMI_CLK_RATE_ROUND_DOWN 0
746#define SCMI_CLK_RATE_ROUND_UP BIT(2)
747#define SCMI_CLK_RATE_ROUND_CLOSEST BIT(3)
748
Etienne Carriere4c4ec902022-02-21 09:22:42 +0100749#define SCMI_CLOCK_NAME_LENGTH_MAX 16
750
751/**
752 * struct scmi_clk_get_nb_out - Response for SCMI_PROTOCOL_ATTRIBUTES command
753 * @status: SCMI command status
754 * @attributes: Attributes of the clock protocol, mainly number of clocks exposed
755 */
756struct scmi_clk_protocol_attr_out {
757 s32 status;
758 u32 attributes;
759};
760
761/**
762 * struct scmi_clk_attribute_in - Message payload for SCMI_CLOCK_ATTRIBUTES command
763 * @clock_id: SCMI clock ID
764 */
765struct scmi_clk_attribute_in {
766 u32 clock_id;
767};
768
769/**
770 * struct scmi_clk_get_nb_out - Response payload for SCMI_CLOCK_ATTRIBUTES command
771 * @status: SCMI command status
772 * @attributes: clock attributes
773 * @clock_name: name of the clock
774 */
775struct scmi_clk_attribute_out {
776 s32 status;
777 u32 attributes;
778 char clock_name[SCMI_CLOCK_NAME_LENGTH_MAX];
779};
780
Etienne Carriere78928e12020-09-09 18:44:04 +0200781/**
782 * struct scmi_clk_state_in - Message payload for CLOCK_CONFIG_SET command
783 * @clock_id: SCMI clock ID
784 * @attributes: Attributes of the targets clock state
785 */
786struct scmi_clk_state_in {
787 u32 clock_id;
788 u32 attributes;
789};
790
791/**
792 * struct scmi_clk_state_out - Response payload for CLOCK_CONFIG_SET command
793 * @status: SCMI command status
794 */
795struct scmi_clk_state_out {
796 s32 status;
797};
798
799/**
800 * struct scmi_clk_state_in - Message payload for CLOCK_RATE_GET command
801 * @clock_id: SCMI clock ID
802 * @attributes: Attributes of the targets clock state
803 */
804struct scmi_clk_rate_get_in {
805 u32 clock_id;
806};
807
808/**
809 * struct scmi_clk_rate_get_out - Response payload for CLOCK_RATE_GET command
810 * @status: SCMI command status
811 * @rate_lsb: 32bit LSB of the clock rate in Hertz
812 * @rate_msb: 32bit MSB of the clock rate in Hertz
813 */
814struct scmi_clk_rate_get_out {
815 s32 status;
816 u32 rate_lsb;
817 u32 rate_msb;
818};
819
820/**
821 * struct scmi_clk_state_in - Message payload for CLOCK_RATE_SET command
Etienne Carriere78928e12020-09-09 18:44:04 +0200822 * @flags: Flags for the clock rate set request
Clément Légerd5e3abb2021-10-13 16:00:04 +0200823 * @clock_id: SCMI clock ID
Etienne Carriere78928e12020-09-09 18:44:04 +0200824 * @rate_lsb: 32bit LSB of the clock rate in Hertz
825 * @rate_msb: 32bit MSB of the clock rate in Hertz
826 */
827struct scmi_clk_rate_set_in {
Etienne Carriere78928e12020-09-09 18:44:04 +0200828 u32 flags;
Clément Légerd5e3abb2021-10-13 16:00:04 +0200829 u32 clock_id;
Etienne Carriere78928e12020-09-09 18:44:04 +0200830 u32 rate_lsb;
831 u32 rate_msb;
832};
833
834/**
835 * struct scmi_clk_rate_set_out - Response payload for CLOCK_RATE_SET command
836 * @status: SCMI command status
837 */
838struct scmi_clk_rate_set_out {
839 s32 status;
840};
841
Etienne Carrierec6e9af32020-09-09 18:44:06 +0200842/*
843 * SCMI Reset Domain Protocol
844 */
845
846enum scmi_reset_domain_message_id {
847 SCMI_RESET_DOMAIN_ATTRIBUTES = 0x3,
848 SCMI_RESET_DOMAIN_RESET = 0x4,
849};
850
851#define SCMI_RD_NAME_LEN 16
852
853#define SCMI_RD_ATTRIBUTES_FLAG_ASYNC BIT(31)
854#define SCMI_RD_ATTRIBUTES_FLAG_NOTIF BIT(30)
855
856#define SCMI_RD_RESET_FLAG_ASYNC BIT(2)
857#define SCMI_RD_RESET_FLAG_ASSERT BIT(1)
858#define SCMI_RD_RESET_FLAG_CYCLE BIT(0)
859
860/**
861 * struct scmi_rd_attr_in - Payload for RESET_DOMAIN_ATTRIBUTES message
862 * @domain_id: SCMI reset domain ID
863 */
864struct scmi_rd_attr_in {
865 u32 domain_id;
866};
867
868/**
869 * struct scmi_rd_attr_out - Payload for RESET_DOMAIN_ATTRIBUTES response
870 * @status: SCMI command status
871 * @attributes: Retrieved attributes of the reset domain
872 * @latency: Reset cycle max lantency
873 * @name: Reset domain name
874 */
875struct scmi_rd_attr_out {
876 s32 status;
877 u32 attributes;
878 u32 latency;
879 char name[SCMI_RD_NAME_LEN];
880};
881
882/**
883 * struct scmi_rd_reset_in - Message payload for RESET command
884 * @domain_id: SCMI reset domain ID
885 * @flags: Flags for the reset request
886 * @reset_state: Reset target state
887 */
888struct scmi_rd_reset_in {
889 u32 domain_id;
890 u32 flags;
891 u32 reset_state;
892};
893
894/**
895 * struct scmi_rd_reset_out - Response payload for RESET command
896 * @status: SCMI command status
897 */
898struct scmi_rd_reset_out {
899 s32 status;
900};
901
Etienne Carriered68663a2021-03-08 22:38:06 +0100902/*
903 * SCMI Voltage Domain Protocol
904 */
905
906enum scmi_voltage_domain_message_id {
907 SCMI_VOLTAGE_DOMAIN_ATTRIBUTES = 0x3,
908 SCMI_VOLTAGE_DOMAIN_CONFIG_SET = 0x5,
909 SCMI_VOLTAGE_DOMAIN_CONFIG_GET = 0x6,
910 SCMI_VOLTAGE_DOMAIN_LEVEL_SET = 0x7,
911 SCMI_VOLTAGE_DOMAIN_LEVEL_GET = 0x8,
912};
913
914#define SCMI_VOLTD_NAME_LEN 16
915
916#define SCMI_VOLTD_CONFIG_MASK GENMASK(3, 0)
917#define SCMI_VOLTD_CONFIG_OFF 0
918#define SCMI_VOLTD_CONFIG_ON 0x7
919
920/**
921 * struct scmi_voltd_attr_in - Payload for VOLTAGE_DOMAIN_ATTRIBUTES message
922 * @domain_id: SCMI voltage domain ID
923 */
924struct scmi_voltd_attr_in {
925 u32 domain_id;
926};
927
928/**
929 * struct scmi_voltd_attr_out - Payload for VOLTAGE_DOMAIN_ATTRIBUTES response
930 * @status: SCMI command status
931 * @attributes: Retrieved attributes of the voltage domain
932 * @name: Voltage domain name
933 */
934struct scmi_voltd_attr_out {
935 s32 status;
936 u32 attributes;
937 char name[SCMI_VOLTD_NAME_LEN];
938};
939
940/**
941 * struct scmi_voltd_config_set_in - Message payload for VOLTAGE_CONFIG_SET cmd
942 * @domain_id: SCMI voltage domain ID
943 * @config: Configuration data of the voltage domain
944 */
945struct scmi_voltd_config_set_in {
946 u32 domain_id;
947 u32 config;
948};
949
950/**
951 * struct scmi_voltd_config_set_out - Response for VOLTAGE_CONFIG_SET command
952 * @status: SCMI command status
953 */
954struct scmi_voltd_config_set_out {
955 s32 status;
956};
957
958/**
959 * struct scmi_voltd_config_get_in - Message payload for VOLTAGE_CONFIG_GET cmd
960 * @domain_id: SCMI voltage domain ID
961 */
962struct scmi_voltd_config_get_in {
963 u32 domain_id;
964};
965
966/**
967 * struct scmi_voltd_config_get_out - Response for VOLTAGE_CONFIG_GET command
968 * @status: SCMI command status
969 * @config: Configuration data of the voltage domain
970 */
971struct scmi_voltd_config_get_out {
972 s32 status;
973 u32 config;
974};
975
976/**
977 * struct scmi_voltd_level_set_in - Message payload for VOLTAGE_LEVEL_SET cmd
978 * @domain_id: SCMI voltage domain ID
979 * @flags: Parameter flags for configuring target level
980 * @voltage_level: Target voltage level in microvolts (uV)
981 */
982struct scmi_voltd_level_set_in {
983 u32 domain_id;
984 u32 flags;
985 s32 voltage_level;
986};
987
988/**
989 * struct scmi_voltd_level_set_out - Response for VOLTAGE_LEVEL_SET command
990 * @status: SCMI command status
991 */
992struct scmi_voltd_level_set_out {
993 s32 status;
994};
995
996/**
997 * struct scmi_voltd_level_get_in - Message payload for VOLTAGE_LEVEL_GET cmd
998 * @domain_id: SCMI voltage domain ID
999 */
1000struct scmi_voltd_level_get_in {
1001 u32 domain_id;
1002};
1003
1004/**
1005 * struct scmi_voltd_level_get_out - Response for VOLTAGE_LEVEL_GET command
1006 * @status: SCMI command status
1007 * @voltage_level: Voltage level in microvolts (uV)
1008 */
1009struct scmi_voltd_level_get_out {
1010 s32 status;
1011 s32 voltage_level;
1012};
1013
Alice Guoaeb03192025-04-28 18:37:26 +08001014/* SCMI Pinctrl Protocol */
1015enum scmi_pinctrl_message_id {
1016 SCMI_MSG_PINCTRL_CONFIG_SET = 0x6
1017};
1018
1019struct scmi_pin_config {
1020 u32 type;
1021 u32 val;
1022};
1023
1024/**
1025 * struct scmi_pad_config_set_in - Message payload for PAD_CONFIG_SET command
1026 * @identifier: Identifier for the pin or group.
1027 * @function_id: Identifier for the function selected to be enabled
1028 * for the selected pin or group. This field is set to
1029 * 0xFFFFFFFF if no function should be enabled by the
1030 * pin or group.
1031 * @attributes: Bits[31:11] Reserved, must be zero.
1032 * Bit[10] Function valid.
1033 * Bits[9:2] Number of configurations to set.
1034 * Bits[1:0] Selector: Whether the identifier field
1035 * refers to a pin or a group.
1036 * @configs: Array of configurations.
1037 */
1038struct scmi_pinctrl_config_set_in {
1039 u32 identifier;
1040 u32 function_id;
1041 u32 attributes;
1042 struct scmi_pin_config configs[4];
1043};
1044
1045struct scmi_pinctrl_config_set_out {
1046 s32 status;
1047};
1048
Peng Fan06f837a2025-04-28 18:37:29 +08001049/* SCMI Perf Protocol */
1050enum scmi_perf_message_id {
1051 SCMI_PERF_DOMAIN_ATTRIBUTES = 0x3,
1052 SCMI_PERF_DESCRIBE_LEVELS = 0x4,
1053 SCMI_PERF_LIMITS_SET = 0x5,
1054 SCMI_PERF_LIMITS_GET = 0x6,
1055 SCMI_PERF_LEVEL_SET = 0x7,
1056 SCMI_PERF_LEVEL_GET = 0x8
1057};
1058
1059struct scmi_perf_in {
1060 u32 domain_id;
1061 u32 perf_level;
1062};
1063
1064struct scmi_perf_out {
1065 s32 status;
1066};
Etienne Carriere02fd1262020-09-09 18:44:00 +02001067#endif /* _SCMI_PROTOCOLS_H */