1 /* 2 * Arm SCP/MCP Software 3 * Copyright (c) 2015-2021, Arm Limited and Contributors. All rights reserved. 4 * 5 * SPDX-License-Identifier: BSD-3-Clause 6 * 7 * Description: 8 * SCMI Voltage Domain Management Protocol Support 9 */ 10 11 #ifndef INTERNAL_SCMI_VOLTAGE_DOMAIN_H 12 #define INTERNAL_SCMI_VOLTAGE_DOMAIN_H 13 14 #include <mod_voltage_domain.h> 15 16 #define SCMI_PROTOCOL_VERSION_VOLTD UINT32_C(0x10000) 17 18 /* 19 * Generic p2a 20 */ 21 struct scmi_voltd_generic_p2a { 22 int32_t status; 23 }; 24 25 /* 26 * Protocol Attributes 27 */ 28 29 #define SCMI_VOLTD_PROTOCOL_ATTRIBUTES_VOLTD_COUNT_MASK UINT32_C(0xFFFF) 30 #define SCMI_VOLTD_PROTOCOL_ATTRIBUTES_VOLTD_COUNT_MAX \ 31 (SCMI_VOLTD_PROTOCOL_ATTRIBUTES_VOLTD_COUNT_MASK + 1) 32 #define SCMI_VOLTD_PROTOCOL_ATTRIBUTES(_domain_count) \ 33 ((_domain_count) & SCMI_VOLTD_PROTOCOL_ATTRIBUTES_VOLTD_COUNT_MASK) 34 35 /* 36 * Voltage Domain Attributes 37 */ 38 39 struct scmi_voltd_attributes_a2p { 40 uint32_t domain_id; 41 }; 42 43 #define SCMI_VOLTD_NAME_LENGTH_MAX 16 44 45 struct scmi_voltd_attributes_p2a { 46 int32_t status; 47 uint32_t attributes; 48 char name[SCMI_VOLTD_NAME_LENGTH_MAX]; 49 }; 50 51 /* 52 * Get voltage level of a domain 53 */ 54 55 struct scmi_voltd_level_get_a2p { 56 uint32_t domain_id; 57 }; 58 59 struct scmi_voltd_level_get_p2a { 60 int32_t status; 61 int32_t voltage_level; 62 }; 63 64 /* 65 * Set voltage level of a domain 66 */ 67 68 struct scmi_voltd_level_set_a2p { 69 uint32_t domain_id; 70 uint32_t flags; 71 int32_t voltage_level; 72 }; 73 74 struct scmi_voltd_level_set_p2a { 75 int32_t status; 76 }; 77 78 /* 79 * Voltage Domain Config Set 80 */ 81 #define SCMI_VOLTD_CONFIG_MODE_TYPE_POS 0x03U 82 #define SCMI_VOLTD_CONFIG_MODE_TYPE_BIT (1U << SCMI_VOLTD_CONFIG_MODE_TYPE_POS) 83 #define SCMI_VOLTD_CONFIG_MODE_TYPE_IMPL SCMI_VOLTD_CONFIG_MODE_TYPE_BIT 84 #define SCMI_VOLTD_CONFIG_MODE_ID_MASK (SCMI_VOLTD_CONFIG_MODE_TYPE_BIT - 1U) 85 #define SCMI_VOLTD_CONFIG_MODE_TYPE_MASK \ 86 ((uint32_t) ~(SCMI_VOLTD_CONFIG_MODE_ID_MASK)) 87 88 enum scmi_voltd_mode_type { 89 SCMI_VOLTD_MODE_TYPE_ARCH = 0x0U, 90 SCMI_VOLTD_MODE_TYPE_IMPL = 0x08U, 91 }; 92 93 enum scmi_voltd_mode_id { 94 SCMI_VOLTD_MODE_ID_OFF = 0x0U, 95 SCMI_VOLTD_MODE_ID_ON = 0x07U, 96 }; 97 98 struct scmi_voltd_config_set_a2p { 99 uint32_t domain_id; 100 uint32_t config; 101 }; 102 103 struct scmi_voltd_config_set_p2a { 104 int32_t status; 105 }; 106 107 struct scmi_voltd_config_get_a2p { 108 uint32_t domain_id; 109 }; 110 111 struct scmi_voltd_config_get_p2a { 112 int32_t status; 113 uint32_t config; 114 }; 115 116 /* 117 * Voltage Domain Describe Levels 118 */ 119 120 #define SCMI_VOLTD_LEVEL_FORMAT_RANGE 1 121 #define SCMI_VOLTD_LEVEL_FORMAT_LIST 0 122 123 #define SCMI_VOLTD_DESCRIBE_LEVELS_REMAINING_POS 16 124 #define SCMI_VOLTD_DESCRIBE_LEVELS_FORMAT_POS 12 125 #define SCMI_VOLTD_DESCRIBE_LEVELS_COUNT_POS 0 126 127 #define SCMI_VOLTD_DESCRIBE_LEVELS_REMAINING_MASK \ 128 (UINT32_C(0xFFFF) << SCMI_VOLTD_DESCRIBE_LEVELS_REMAINING_POS) 129 #define SCMI_VOLTD_DESCRIBE_LEVELS_FORMAT_MASK \ 130 (UINT32_C(0x1) << SCMI_VOLTD_DESCRIBE_LEVELS_FORMAT_POS) 131 #define SCMI_VOLTD_DESCRIBE_LEVELS_COUNT_MASK \ 132 (UINT32_C(0xFFF) << SCMI_VOLTD_DESCRIBE_LEVELS_COUNT_POS) 133 134 #define SCMI_VOLTD_NUM_LEVELS_FLAGS(_count, _format, _remaining) \ 135 ( \ 136 (((_count) << SCMI_VOLTD_DESCRIBE_LEVELS_COUNT_POS) & \ 137 SCMI_VOLTD_DESCRIBE_LEVELS_COUNT_MASK) | \ 138 (((_remaining) << SCMI_VOLTD_DESCRIBE_LEVELS_REMAINING_POS) & \ 139 SCMI_VOLTD_DESCRIBE_LEVELS_REMAINING_MASK) | \ 140 (((_format) << SCMI_VOLTD_DESCRIBE_LEVELS_FORMAT_POS) & \ 141 SCMI_VOLTD_DESCRIBE_LEVELS_FORMAT_MASK) \ 142 ) 143 144 #define SCMI_VOLTD_LEVEL_RANGE_FLAGS \ 145 SCMI_VOLTD_NUM_LEVELS_FLAGS(3, SCMI_VOLTD_LEVEL_FORMAT_RANGE, 0); 146 147 #define SCMI_VOLTD_LEVEL_LIST_FLAGS(_cnt, _rem) \ 148 SCMI_VOLTD_NUM_LEVELS_FLAGS((_cnt), SCMI_VOLTD_LEVEL_FORMAT_LIST, (_rem)); 149 150 struct scmi_voltd_describe_levels_a2p { 151 uint32_t domain_id; 152 uint32_t level_index; 153 }; 154 155 struct scmi_voltd_describe_levels_p2a { 156 int32_t status; 157 uint32_t flags; 158 int32_t voltage[]; 159 }; 160 161 #endif /* INTERNAL_SCMI_VOLTAGE_DOMAIN_H */ 162