1 /* 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> 10 #include <asm/types.h> 11 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 18 enum 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, 26 SCMI_PROTOCOL_ID_VOLTAGE_DOMAIN = 0x17, 27 SCMI_PROTOCOL_ID_PINCTRL = 0x19, 28 SCMI_PROTOCOL_ID_IMX_MISC = 0x84, 29 }; 30 31 enum 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 45 /* 46 * Generic message IDs 47 */ 48 enum scmi_discovery_id { 49 SCMI_PROTOCOL_VERSION = 0x0, 50 SCMI_PROTOCOL_ATTRIBUTES = 0x1, 51 SCMI_PROTOCOL_MESSAGE_ATTRIBUTES = 0x2, 52 }; 53 54 enum scmi_imx_misc_message_id { 55 SCMI_MISC_ROM_PASSOVER_GET = 0x7 56 }; 57 58 /* 59 * SCMI Base Protocol 60 */ 61 #define SCMI_BASE_PROTOCOL_VERSION 0x20000 62 63 enum 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 */ 83 struct 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 */ 94 struct 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 */ 110 struct 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 */ 122 struct 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 */ 133 struct 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 */ 145 struct scmi_base_discover_list_protocols_out { 146 s32 status; 147 u32 num_protocols; 148 u32 protocols[]; 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 */ 158 struct 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 */ 173 struct 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 */ 189 struct 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 */ 205 struct 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 */ 215 struct 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 */ 385 int 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 */ 397 int 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 */ 411 int 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 */ 425 int 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 */ 438 int 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 */ 450 int 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 */ 461 int 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 */ 476 int 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 */ 491 int 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 */ 503 int 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 */ 517 int 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 */ 535 int 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 */ 550 int scmi_base_reset_agent_configuration(struct udevice *dev, u32 agent_id, 551 u32 flags); 552 553 /* 554 * 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 561 enum 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 */ 578 struct 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 */ 593 struct 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 */ 606 struct 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 */ 624 struct 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 */ 637 struct 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 */ 649 struct 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 */ 667 int 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 */ 679 int 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 */ 693 int 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 */ 706 int 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 */ 718 int 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 */ 729 int scmi_pwd_name_get(struct udevice *dev, u32 domain_id, u8 **name); 730 731 /* 732 * SCMI Clock Protocol 733 */ 734 #define CLOCK_PROTOCOL_VERSION_3_0 0x30000 735 736 enum scmi_clock_message_id { 737 SCMI_CLOCK_ATTRIBUTES = 0x3, 738 SCMI_CLOCK_RATE_SET = 0x5, 739 SCMI_CLOCK_RATE_GET = 0x6, 740 SCMI_CLOCK_CONFIG_SET = 0x7, 741 SCMI_CLOCK_PARENT_SET = 0xD, 742 SCMI_CLOCK_GET_PERMISSIONS = 0xF, 743 }; 744 745 #define SCMI_CLK_PROTO_ATTR_COUNT_MASK GENMASK(15, 0) 746 #define SCMI_CLK_RATE_ASYNC_NOTIFY BIT(0) 747 #define SCMI_CLK_RATE_ASYNC_NORESP (BIT(0) | BIT(1)) 748 #define SCMI_CLK_RATE_ROUND_DOWN 0 749 #define SCMI_CLK_RATE_ROUND_UP BIT(2) 750 #define SCMI_CLK_RATE_ROUND_CLOSEST BIT(3) 751 752 #define SCMI_CLOCK_NAME_LENGTH_MAX 16 753 754 /** 755 * struct scmi_clk_get_nb_out - Response for SCMI_PROTOCOL_ATTRIBUTES command 756 * @status: SCMI command status 757 * @attributes: Attributes of the clock protocol, mainly number of clocks exposed 758 */ 759 struct scmi_clk_protocol_attr_out { 760 s32 status; 761 u32 attributes; 762 }; 763 764 /** 765 * struct scmi_clk_attribute_in - Message payload for SCMI_CLOCK_ATTRIBUTES command 766 * @clock_id: SCMI clock ID 767 */ 768 struct scmi_clk_attribute_in { 769 u32 clock_id; 770 }; 771 772 /** 773 * struct scmi_clk_get_nb_out - Response payload for SCMI_CLOCK_ATTRIBUTES command 774 * @status: SCMI command status 775 * @attributes: clock attributes 776 * @clock_name: name of the clock 777 */ 778 struct scmi_clk_attribute_out { 779 s32 status; 780 u32 attributes; 781 #define CLK_HAS_RESTRICTIONS(x) ((x) & BIT(1)) 782 char clock_name[SCMI_CLOCK_NAME_LENGTH_MAX]; 783 }; 784 785 /** 786 * struct scmi_clk_get_nb_out_v2 - Response payload for SCMI_CLOCK_ATTRIBUTES command 787 * Clock management Protocol 2.0 788 * @status: SCMI command status 789 * @attributes: clock attributes 790 * @clock_name: name of the clock 791 * @clock_enable_delay: delay incurred by the platform to enable the clock 792 */ 793 struct scmi_clk_attribute_out_v2 { 794 s32 status; 795 u32 attributes; 796 char clock_name[SCMI_CLOCK_NAME_LENGTH_MAX]; 797 u32 clock_enable_delay; 798 }; 799 800 /** 801 * struct scmi_clk_state_in - Message payload for CLOCK_CONFIG_SET command 802 * @clock_id: SCMI clock ID 803 * @attributes: Attributes of the targets clock state 804 */ 805 struct scmi_clk_state_in { 806 u32 clock_id; 807 u32 attributes; 808 }; 809 810 /** 811 * struct scmi_clk_state_out - Response payload for CLOCK_CONFIG_SET command 812 * @status: SCMI command status 813 */ 814 struct scmi_clk_state_out { 815 s32 status; 816 }; 817 818 /** 819 * struct scmi_clk_state_in - Message payload for CLOCK_RATE_GET command 820 * @clock_id: SCMI clock ID 821 * @attributes: Attributes of the targets clock state 822 */ 823 struct scmi_clk_rate_get_in { 824 u32 clock_id; 825 }; 826 827 /** 828 * struct scmi_clk_rate_get_out - Response payload for CLOCK_RATE_GET command 829 * @status: SCMI command status 830 * @rate_lsb: 32bit LSB of the clock rate in Hertz 831 * @rate_msb: 32bit MSB of the clock rate in Hertz 832 */ 833 struct scmi_clk_rate_get_out { 834 s32 status; 835 u32 rate_lsb; 836 u32 rate_msb; 837 }; 838 839 /** 840 * struct scmi_clk_state_in - Message payload for CLOCK_RATE_SET command 841 * @flags: Flags for the clock rate set request 842 * @clock_id: SCMI clock ID 843 * @rate_lsb: 32bit LSB of the clock rate in Hertz 844 * @rate_msb: 32bit MSB of the clock rate in Hertz 845 */ 846 struct scmi_clk_rate_set_in { 847 u32 flags; 848 u32 clock_id; 849 u32 rate_lsb; 850 u32 rate_msb; 851 }; 852 853 /** 854 * struct scmi_clk_rate_set_out - Response payload for CLOCK_RATE_SET command 855 * @status: SCMI command status 856 */ 857 struct scmi_clk_rate_set_out { 858 s32 status; 859 }; 860 861 /** 862 * struct scmi_clk_parent_state_in - Message payload for CLOCK_PARENT_SET command 863 * @clock_id: SCMI clock ID 864 * @parent_clk: SCMI clock ID 865 */ 866 struct scmi_clk_parent_set_in { 867 u32 clock_id; 868 u32 parent_clk; 869 }; 870 871 /** 872 * struct scmi_clk_parent_set_out - Response payload for CLOCK_PARENT_SET command 873 * @status: SCMI command status 874 */ 875 struct scmi_clk_parent_set_out { 876 s32 status; 877 }; 878 879 /** 880 * @clock_id: Identifier for the clock device. 881 */ 882 struct scmi_clk_get_permissions_in { 883 u32 clock_id; 884 }; 885 886 /** 887 * @status: Negative 32-bit integers are used to return error status codes. 888 * @permissions: Bit[31] Clock state control, Bit[30] Clock parent control, 889 * Bit[29] Clock rate control, Bits[28:0] Reserved, must be zero. 890 */ 891 struct scmi_clk_get_permissions_out { 892 s32 status; 893 u32 permissions; 894 }; 895 896 #define SUPPORT_CLK_STAT_CONTROL BIT(31) 897 #define SUPPORT_CLK_PARENT_CONTROL BIT(30) 898 #define SUPPORT_CLK_RATE_CONTROL BIT(29) 899 900 /* 901 * SCMI Reset Domain Protocol 902 */ 903 904 enum scmi_reset_domain_message_id { 905 SCMI_RESET_DOMAIN_ATTRIBUTES = 0x3, 906 SCMI_RESET_DOMAIN_RESET = 0x4, 907 }; 908 909 #define SCMI_RD_NAME_LEN 16 910 911 #define SCMI_RD_ATTRIBUTES_FLAG_ASYNC BIT(31) 912 #define SCMI_RD_ATTRIBUTES_FLAG_NOTIF BIT(30) 913 914 #define SCMI_RD_RESET_FLAG_ASYNC BIT(2) 915 #define SCMI_RD_RESET_FLAG_ASSERT BIT(1) 916 #define SCMI_RD_RESET_FLAG_CYCLE BIT(0) 917 918 /** 919 * struct scmi_rd_attr_in - Payload for RESET_DOMAIN_ATTRIBUTES message 920 * @domain_id: SCMI reset domain ID 921 */ 922 struct scmi_rd_attr_in { 923 u32 domain_id; 924 }; 925 926 /** 927 * struct scmi_rd_attr_out - Payload for RESET_DOMAIN_ATTRIBUTES response 928 * @status: SCMI command status 929 * @attributes: Retrieved attributes of the reset domain 930 * @latency: Reset cycle max lantency 931 * @name: Reset domain name 932 */ 933 struct scmi_rd_attr_out { 934 s32 status; 935 u32 attributes; 936 u32 latency; 937 char name[SCMI_RD_NAME_LEN]; 938 }; 939 940 /** 941 * struct scmi_rd_reset_in - Message payload for RESET command 942 * @domain_id: SCMI reset domain ID 943 * @flags: Flags for the reset request 944 * @reset_state: Reset target state 945 */ 946 struct scmi_rd_reset_in { 947 u32 domain_id; 948 u32 flags; 949 u32 reset_state; 950 }; 951 952 /** 953 * struct scmi_rd_reset_out - Response payload for RESET command 954 * @status: SCMI command status 955 */ 956 struct scmi_rd_reset_out { 957 s32 status; 958 }; 959 960 /* 961 * SCMI Voltage Domain Protocol 962 */ 963 964 enum scmi_voltage_domain_message_id { 965 SCMI_VOLTAGE_DOMAIN_ATTRIBUTES = 0x3, 966 SCMI_VOLTAGE_DOMAIN_CONFIG_SET = 0x5, 967 SCMI_VOLTAGE_DOMAIN_CONFIG_GET = 0x6, 968 SCMI_VOLTAGE_DOMAIN_LEVEL_SET = 0x7, 969 SCMI_VOLTAGE_DOMAIN_LEVEL_GET = 0x8, 970 }; 971 972 #define SCMI_VOLTD_NAME_LEN 16 973 974 #define SCMI_VOLTD_CONFIG_MASK GENMASK(3, 0) 975 #define SCMI_VOLTD_CONFIG_OFF 0 976 #define SCMI_VOLTD_CONFIG_ON 0x7 977 978 /** 979 * struct scmi_voltd_attr_in - Payload for VOLTAGE_DOMAIN_ATTRIBUTES message 980 * @domain_id: SCMI voltage domain ID 981 */ 982 struct scmi_voltd_attr_in { 983 u32 domain_id; 984 }; 985 986 /** 987 * struct scmi_voltd_attr_out - Payload for VOLTAGE_DOMAIN_ATTRIBUTES response 988 * @status: SCMI command status 989 * @attributes: Retrieved attributes of the voltage domain 990 * @name: Voltage domain name 991 */ 992 struct scmi_voltd_attr_out { 993 s32 status; 994 u32 attributes; 995 char name[SCMI_VOLTD_NAME_LEN]; 996 }; 997 998 /** 999 * struct scmi_voltd_config_set_in - Message payload for VOLTAGE_CONFIG_SET cmd 1000 * @domain_id: SCMI voltage domain ID 1001 * @config: Configuration data of the voltage domain 1002 */ 1003 struct scmi_voltd_config_set_in { 1004 u32 domain_id; 1005 u32 config; 1006 }; 1007 1008 /** 1009 * struct scmi_voltd_config_set_out - Response for VOLTAGE_CONFIG_SET command 1010 * @status: SCMI command status 1011 */ 1012 struct scmi_voltd_config_set_out { 1013 s32 status; 1014 }; 1015 1016 /** 1017 * struct scmi_voltd_config_get_in - Message payload for VOLTAGE_CONFIG_GET cmd 1018 * @domain_id: SCMI voltage domain ID 1019 */ 1020 struct scmi_voltd_config_get_in { 1021 u32 domain_id; 1022 }; 1023 1024 /** 1025 * struct scmi_voltd_config_get_out - Response for VOLTAGE_CONFIG_GET command 1026 * @status: SCMI command status 1027 * @config: Configuration data of the voltage domain 1028 */ 1029 struct scmi_voltd_config_get_out { 1030 s32 status; 1031 u32 config; 1032 }; 1033 1034 /** 1035 * struct scmi_voltd_level_set_in - Message payload for VOLTAGE_LEVEL_SET cmd 1036 * @domain_id: SCMI voltage domain ID 1037 * @flags: Parameter flags for configuring target level 1038 * @voltage_level: Target voltage level in microvolts (uV) 1039 */ 1040 struct scmi_voltd_level_set_in { 1041 u32 domain_id; 1042 u32 flags; 1043 s32 voltage_level; 1044 }; 1045 1046 /** 1047 * struct scmi_voltd_level_set_out - Response for VOLTAGE_LEVEL_SET command 1048 * @status: SCMI command status 1049 */ 1050 struct scmi_voltd_level_set_out { 1051 s32 status; 1052 }; 1053 1054 /** 1055 * struct scmi_voltd_level_get_in - Message payload for VOLTAGE_LEVEL_GET cmd 1056 * @domain_id: SCMI voltage domain ID 1057 */ 1058 struct scmi_voltd_level_get_in { 1059 u32 domain_id; 1060 }; 1061 1062 /** 1063 * struct scmi_voltd_level_get_out - Response for VOLTAGE_LEVEL_GET command 1064 * @status: SCMI command status 1065 * @voltage_level: Voltage level in microvolts (uV) 1066 */ 1067 struct scmi_voltd_level_get_out { 1068 s32 status; 1069 s32 voltage_level; 1070 }; 1071 1072 /* SCMI Pinctrl Protocol */ 1073 enum scmi_pinctrl_message_id { 1074 SCMI_MSG_PINCTRL_CONFIG_SET = 0x6 1075 }; 1076 1077 struct scmi_pin_config { 1078 u32 type; 1079 u32 val; 1080 }; 1081 1082 /** 1083 * struct scmi_pad_config_set_in - Message payload for PAD_CONFIG_SET command 1084 * @identifier: Identifier for the pin or group. 1085 * @function_id: Identifier for the function selected to be enabled 1086 * for the selected pin or group. This field is set to 1087 * 0xFFFFFFFF if no function should be enabled by the 1088 * pin or group. 1089 * @attributes: Bits[31:11] Reserved, must be zero. 1090 * Bit[10] Function valid. 1091 * Bits[9:2] Number of configurations to set. 1092 * Bits[1:0] Selector: Whether the identifier field 1093 * refers to a pin or a group. 1094 * @configs: Array of configurations. 1095 */ 1096 struct scmi_pinctrl_config_set_in { 1097 u32 identifier; 1098 u32 function_id; 1099 u32 attributes; 1100 struct scmi_pin_config configs[4]; 1101 }; 1102 1103 struct scmi_pinctrl_config_set_out { 1104 s32 status; 1105 }; 1106 1107 /* SCMI Perf Protocol */ 1108 enum scmi_perf_message_id { 1109 SCMI_PERF_DOMAIN_ATTRIBUTES = 0x3, 1110 SCMI_PERF_DESCRIBE_LEVELS = 0x4, 1111 SCMI_PERF_LIMITS_SET = 0x5, 1112 SCMI_PERF_LIMITS_GET = 0x6, 1113 SCMI_PERF_LEVEL_SET = 0x7, 1114 SCMI_PERF_LEVEL_GET = 0x8 1115 }; 1116 1117 struct scmi_perf_in { 1118 u32 domain_id; 1119 u32 perf_level; 1120 }; 1121 1122 struct scmi_perf_out { 1123 s32 status; 1124 }; 1125 #endif /* _SCMI_PROTOCOLS_H */ 1126