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