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