blob: 342a65ae7f4d57a833a20b26127d71a3fe863bb6 [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,
Peng Fan3b5eaad2025-04-28 18:37:30 +0800740 SCMI_CLOCK_PARENT_SET = 0xD,
Etienne Carriere78928e12020-09-09 18:44:04 +0200741};
742
Etienne Carriere4c4ec902022-02-21 09:22:42 +0100743#define SCMI_CLK_PROTO_ATTR_COUNT_MASK GENMASK(15, 0)
Etienne Carriere78928e12020-09-09 18:44:04 +0200744#define SCMI_CLK_RATE_ASYNC_NOTIFY BIT(0)
745#define SCMI_CLK_RATE_ASYNC_NORESP (BIT(0) | BIT(1))
746#define SCMI_CLK_RATE_ROUND_DOWN 0
747#define SCMI_CLK_RATE_ROUND_UP BIT(2)
748#define SCMI_CLK_RATE_ROUND_CLOSEST BIT(3)
749
Etienne Carriere4c4ec902022-02-21 09:22:42 +0100750#define SCMI_CLOCK_NAME_LENGTH_MAX 16
751
752/**
753 * struct scmi_clk_get_nb_out - Response for SCMI_PROTOCOL_ATTRIBUTES command
754 * @status: SCMI command status
755 * @attributes: Attributes of the clock protocol, mainly number of clocks exposed
756 */
757struct scmi_clk_protocol_attr_out {
758 s32 status;
759 u32 attributes;
760};
761
762/**
763 * struct scmi_clk_attribute_in - Message payload for SCMI_CLOCK_ATTRIBUTES command
764 * @clock_id: SCMI clock ID
765 */
766struct scmi_clk_attribute_in {
767 u32 clock_id;
768};
769
770/**
771 * struct scmi_clk_get_nb_out - Response payload for SCMI_CLOCK_ATTRIBUTES command
772 * @status: SCMI command status
773 * @attributes: clock attributes
774 * @clock_name: name of the clock
775 */
776struct scmi_clk_attribute_out {
777 s32 status;
778 u32 attributes;
779 char clock_name[SCMI_CLOCK_NAME_LENGTH_MAX];
780};
781
Etienne Carriere78928e12020-09-09 18:44:04 +0200782/**
783 * struct scmi_clk_state_in - Message payload for CLOCK_CONFIG_SET command
784 * @clock_id: SCMI clock ID
785 * @attributes: Attributes of the targets clock state
786 */
787struct scmi_clk_state_in {
788 u32 clock_id;
789 u32 attributes;
790};
791
792/**
793 * struct scmi_clk_state_out - Response payload for CLOCK_CONFIG_SET command
794 * @status: SCMI command status
795 */
796struct scmi_clk_state_out {
797 s32 status;
798};
799
800/**
801 * struct scmi_clk_state_in - Message payload for CLOCK_RATE_GET command
802 * @clock_id: SCMI clock ID
803 * @attributes: Attributes of the targets clock state
804 */
805struct scmi_clk_rate_get_in {
806 u32 clock_id;
807};
808
809/**
810 * struct scmi_clk_rate_get_out - Response payload for CLOCK_RATE_GET command
811 * @status: SCMI command status
812 * @rate_lsb: 32bit LSB of the clock rate in Hertz
813 * @rate_msb: 32bit MSB of the clock rate in Hertz
814 */
815struct scmi_clk_rate_get_out {
816 s32 status;
817 u32 rate_lsb;
818 u32 rate_msb;
819};
820
821/**
822 * struct scmi_clk_state_in - Message payload for CLOCK_RATE_SET command
Etienne Carriere78928e12020-09-09 18:44:04 +0200823 * @flags: Flags for the clock rate set request
Clément Légerd5e3abb2021-10-13 16:00:04 +0200824 * @clock_id: SCMI clock ID
Etienne Carriere78928e12020-09-09 18:44:04 +0200825 * @rate_lsb: 32bit LSB of the clock rate in Hertz
826 * @rate_msb: 32bit MSB of the clock rate in Hertz
827 */
828struct scmi_clk_rate_set_in {
Etienne Carriere78928e12020-09-09 18:44:04 +0200829 u32 flags;
Clément Légerd5e3abb2021-10-13 16:00:04 +0200830 u32 clock_id;
Etienne Carriere78928e12020-09-09 18:44:04 +0200831 u32 rate_lsb;
832 u32 rate_msb;
833};
834
835/**
836 * struct scmi_clk_rate_set_out - Response payload for CLOCK_RATE_SET command
837 * @status: SCMI command status
838 */
839struct scmi_clk_rate_set_out {
840 s32 status;
841};
842
Peng Fan3b5eaad2025-04-28 18:37:30 +0800843/**
844 * struct scmi_clk_parent_state_in - Message payload for CLOCK_PARENT_SET command
845 * @clock_id: SCMI clock ID
846 * @parent_clk: SCMI clock ID
847 */
848struct scmi_clk_parent_set_in {
849 u32 clock_id;
850 u32 parent_clk;
851};
852
853/**
854 * struct scmi_clk_parent_set_out - Response payload for CLOCK_PARENT_SET command
855 * @status: SCMI command status
856 */
857struct scmi_clk_parent_set_out {
858 s32 status;
859};
860
Etienne Carrierec6e9af32020-09-09 18:44:06 +0200861/*
862 * SCMI Reset Domain Protocol
863 */
864
865enum scmi_reset_domain_message_id {
866 SCMI_RESET_DOMAIN_ATTRIBUTES = 0x3,
867 SCMI_RESET_DOMAIN_RESET = 0x4,
868};
869
870#define SCMI_RD_NAME_LEN 16
871
872#define SCMI_RD_ATTRIBUTES_FLAG_ASYNC BIT(31)
873#define SCMI_RD_ATTRIBUTES_FLAG_NOTIF BIT(30)
874
875#define SCMI_RD_RESET_FLAG_ASYNC BIT(2)
876#define SCMI_RD_RESET_FLAG_ASSERT BIT(1)
877#define SCMI_RD_RESET_FLAG_CYCLE BIT(0)
878
879/**
880 * struct scmi_rd_attr_in - Payload for RESET_DOMAIN_ATTRIBUTES message
881 * @domain_id: SCMI reset domain ID
882 */
883struct scmi_rd_attr_in {
884 u32 domain_id;
885};
886
887/**
888 * struct scmi_rd_attr_out - Payload for RESET_DOMAIN_ATTRIBUTES response
889 * @status: SCMI command status
890 * @attributes: Retrieved attributes of the reset domain
891 * @latency: Reset cycle max lantency
892 * @name: Reset domain name
893 */
894struct scmi_rd_attr_out {
895 s32 status;
896 u32 attributes;
897 u32 latency;
898 char name[SCMI_RD_NAME_LEN];
899};
900
901/**
902 * struct scmi_rd_reset_in - Message payload for RESET command
903 * @domain_id: SCMI reset domain ID
904 * @flags: Flags for the reset request
905 * @reset_state: Reset target state
906 */
907struct scmi_rd_reset_in {
908 u32 domain_id;
909 u32 flags;
910 u32 reset_state;
911};
912
913/**
914 * struct scmi_rd_reset_out - Response payload for RESET command
915 * @status: SCMI command status
916 */
917struct scmi_rd_reset_out {
918 s32 status;
919};
920
Etienne Carriered68663a2021-03-08 22:38:06 +0100921/*
922 * SCMI Voltage Domain Protocol
923 */
924
925enum scmi_voltage_domain_message_id {
926 SCMI_VOLTAGE_DOMAIN_ATTRIBUTES = 0x3,
927 SCMI_VOLTAGE_DOMAIN_CONFIG_SET = 0x5,
928 SCMI_VOLTAGE_DOMAIN_CONFIG_GET = 0x6,
929 SCMI_VOLTAGE_DOMAIN_LEVEL_SET = 0x7,
930 SCMI_VOLTAGE_DOMAIN_LEVEL_GET = 0x8,
931};
932
933#define SCMI_VOLTD_NAME_LEN 16
934
935#define SCMI_VOLTD_CONFIG_MASK GENMASK(3, 0)
936#define SCMI_VOLTD_CONFIG_OFF 0
937#define SCMI_VOLTD_CONFIG_ON 0x7
938
939/**
940 * struct scmi_voltd_attr_in - Payload for VOLTAGE_DOMAIN_ATTRIBUTES message
941 * @domain_id: SCMI voltage domain ID
942 */
943struct scmi_voltd_attr_in {
944 u32 domain_id;
945};
946
947/**
948 * struct scmi_voltd_attr_out - Payload for VOLTAGE_DOMAIN_ATTRIBUTES response
949 * @status: SCMI command status
950 * @attributes: Retrieved attributes of the voltage domain
951 * @name: Voltage domain name
952 */
953struct scmi_voltd_attr_out {
954 s32 status;
955 u32 attributes;
956 char name[SCMI_VOLTD_NAME_LEN];
957};
958
959/**
960 * struct scmi_voltd_config_set_in - Message payload for VOLTAGE_CONFIG_SET cmd
961 * @domain_id: SCMI voltage domain ID
962 * @config: Configuration data of the voltage domain
963 */
964struct scmi_voltd_config_set_in {
965 u32 domain_id;
966 u32 config;
967};
968
969/**
970 * struct scmi_voltd_config_set_out - Response for VOLTAGE_CONFIG_SET command
971 * @status: SCMI command status
972 */
973struct scmi_voltd_config_set_out {
974 s32 status;
975};
976
977/**
978 * struct scmi_voltd_config_get_in - Message payload for VOLTAGE_CONFIG_GET cmd
979 * @domain_id: SCMI voltage domain ID
980 */
981struct scmi_voltd_config_get_in {
982 u32 domain_id;
983};
984
985/**
986 * struct scmi_voltd_config_get_out - Response for VOLTAGE_CONFIG_GET command
987 * @status: SCMI command status
988 * @config: Configuration data of the voltage domain
989 */
990struct scmi_voltd_config_get_out {
991 s32 status;
992 u32 config;
993};
994
995/**
996 * struct scmi_voltd_level_set_in - Message payload for VOLTAGE_LEVEL_SET cmd
997 * @domain_id: SCMI voltage domain ID
998 * @flags: Parameter flags for configuring target level
999 * @voltage_level: Target voltage level in microvolts (uV)
1000 */
1001struct scmi_voltd_level_set_in {
1002 u32 domain_id;
1003 u32 flags;
1004 s32 voltage_level;
1005};
1006
1007/**
1008 * struct scmi_voltd_level_set_out - Response for VOLTAGE_LEVEL_SET command
1009 * @status: SCMI command status
1010 */
1011struct scmi_voltd_level_set_out {
1012 s32 status;
1013};
1014
1015/**
1016 * struct scmi_voltd_level_get_in - Message payload for VOLTAGE_LEVEL_GET cmd
1017 * @domain_id: SCMI voltage domain ID
1018 */
1019struct scmi_voltd_level_get_in {
1020 u32 domain_id;
1021};
1022
1023/**
1024 * struct scmi_voltd_level_get_out - Response for VOLTAGE_LEVEL_GET command
1025 * @status: SCMI command status
1026 * @voltage_level: Voltage level in microvolts (uV)
1027 */
1028struct scmi_voltd_level_get_out {
1029 s32 status;
1030 s32 voltage_level;
1031};
1032
Alice Guoaeb03192025-04-28 18:37:26 +08001033/* SCMI Pinctrl Protocol */
1034enum scmi_pinctrl_message_id {
1035 SCMI_MSG_PINCTRL_CONFIG_SET = 0x6
1036};
1037
1038struct scmi_pin_config {
1039 u32 type;
1040 u32 val;
1041};
1042
1043/**
1044 * struct scmi_pad_config_set_in - Message payload for PAD_CONFIG_SET command
1045 * @identifier: Identifier for the pin or group.
1046 * @function_id: Identifier for the function selected to be enabled
1047 * for the selected pin or group. This field is set to
1048 * 0xFFFFFFFF if no function should be enabled by the
1049 * pin or group.
1050 * @attributes: Bits[31:11] Reserved, must be zero.
1051 * Bit[10] Function valid.
1052 * Bits[9:2] Number of configurations to set.
1053 * Bits[1:0] Selector: Whether the identifier field
1054 * refers to a pin or a group.
1055 * @configs: Array of configurations.
1056 */
1057struct scmi_pinctrl_config_set_in {
1058 u32 identifier;
1059 u32 function_id;
1060 u32 attributes;
1061 struct scmi_pin_config configs[4];
1062};
1063
1064struct scmi_pinctrl_config_set_out {
1065 s32 status;
1066};
1067
Peng Fan06f837a2025-04-28 18:37:29 +08001068/* SCMI Perf Protocol */
1069enum scmi_perf_message_id {
1070 SCMI_PERF_DOMAIN_ATTRIBUTES = 0x3,
1071 SCMI_PERF_DESCRIBE_LEVELS = 0x4,
1072 SCMI_PERF_LIMITS_SET = 0x5,
1073 SCMI_PERF_LIMITS_GET = 0x6,
1074 SCMI_PERF_LEVEL_SET = 0x7,
1075 SCMI_PERF_LEVEL_GET = 0x8
1076};
1077
1078struct scmi_perf_in {
1079 u32 domain_id;
1080 u32 perf_level;
1081};
1082
1083struct scmi_perf_out {
1084 s32 status;
1085};
Etienne Carriere02fd1262020-09-09 18:44:00 +02001086#endif /* _SCMI_PROTOCOLS_H */