1 /* SPDX-License-Identifier: BSD-3-Clause */
2 /*
3 * Copyright (c) 2015-2019, Arm Limited and Contributors. All rights reserved.
4 * Copyright (c) 2019, Linaro Limited
5 */
6
7 #ifndef SCMI_MSG_VOLTAGE_DOMAIN_H
8 #define SCMI_MSG_VOLTAGE_DOMAIN_H
9
10 #include <stdint.h>
11 #include <util.h>
12
13 #include "common.h"
14
15 #define SCMI_PROTOCOL_VERSION_VOLTAGE_DOMAIN 0x30000
16
17 /*
18 * Identifiers of the SCMI Clock Management Protocol commands
19 */
20 enum scmi_voltd_command_id {
21 SCMI_VOLTAGE_DOMAIN_ATTRIBUTES = 0x3,
22 SCMI_VOLTAGE_DESCRIBE_LEVELS = 0x4,
23 SCMI_VOLTAGE_CONFIG_SET = 0x5,
24 SCMI_VOLTAGE_CONFIG_GET = 0x6,
25 SCMI_VOLTAGE_LEVEL_SET = 0x7,
26 SCMI_VOLTAGE_LEVEL_GET = 0x8,
27 };
28
29 #define SCMI_VOLTAGE_DOMAIN_COUNT_MASK GENMASK_32(15, 0)
30
31 struct scmi_voltd_protocol_attrs_p2a {
32 int32_t status;
33 uint32_t attributes;
34 };
35
36 struct scmi_voltd_attributes_a2p {
37 uint32_t domain_id;
38 };
39
40 #define SCMI_VOLTAGE_DOMAIN_NAME_MAX 16
41
42 struct scmi_voltd_attributes_p2a {
43 int32_t status;
44 uint32_t attributes;
45 char name[SCMI_VOLTAGE_DOMAIN_NAME_MAX];
46 };
47
48 struct scmi_voltd_describe_levels_a2p {
49 uint32_t domain_id;
50 uint32_t level_index;
51 };
52
53 #define SCMI_VOLTD_LEVELS_REMAINING_MASK GENMASK_32(31, 16)
54 #define SCMI_VOLTD_LEVELS_REMAINING_POS 16
55
56 #define SCMI_VOLTD_LEVELS_FORMAT_RANGE 1
57 #define SCMI_VOLTD_LEVELS_FORMAT_LIST 0
58 #define SCMI_VOLTD_LEVELS_FORMAT_MASK BIT(12)
59 #define SCMI_VOLTD_LEVELS_FORMAT_POS 12
60
61 #define SCMI_VOLTD_LEVELS_COUNT_MASK GENMASK_32(11, 0)
62
63 #define SCMI_VOLTAGE_DOMAIN_LEVELS_FLAGS(_count, _fmt, _rem_rates) \
64 ( \
65 ((_count) & SCMI_VOLTD_LEVELS_COUNT_MASK) | \
66 (((_rem_rates) << SCMI_VOLTD_LEVELS_REMAINING_POS) & \
67 SCMI_VOLTD_LEVELS_REMAINING_MASK) | \
68 (((_fmt) << SCMI_VOLTD_LEVELS_FORMAT_POS) & \
69 SCMI_VOLTD_LEVELS_FORMAT_MASK) \
70 )
71
72 struct scmi_voltd_level {
73 int32_t mircovolt;
74 };
75
76 struct scmi_voltd_describe_levels_p2a {
77 int32_t status;
78 uint32_t flags;
79 struct scmi_voltd_level voltage[];
80 };
81
82 struct scmi_voltd_level_set_a2p {
83 uint32_t domain_id;
84 uint32_t flags;
85 int32_t voltage_level;
86 };
87
88 struct scmi_voltd_level_set_p2a {
89 uint32_t status;
90 };
91
92 struct scmi_voltd_level_get_a2p {
93 uint32_t domain_id;
94 };
95
96 struct scmi_voltd_level_get_p2a {
97 int32_t status;
98 int32_t voltage_level;
99 };
100
101 #define SCMI_VOLTAGE_DOMAIN_CONFIG_MASK GENMASK_32(3, 0)
102
103 struct scmi_voltd_config_set_a2p {
104 uint32_t domain_id;
105 uint32_t config;
106 };
107
108 struct scmi_voltd_config_set_p2a {
109 uint32_t status;
110 };
111
112 struct scmi_voltd_config_get_a2p {
113 uint32_t domain_id;
114 };
115
116 struct scmi_voltd_config_get_p2a {
117 int32_t status;
118 uint32_t config;
119 };
120
121 #ifdef CFG_SCMI_MSG_VOLTAGE_DOMAIN
122 /*
123 * scmi_msg_get_voltd_handler - Return a handler for a voltage domain message
124 * @msg - message to process
125 * Return a function handler for the message or NULL
126 */
127 scmi_msg_handler_t scmi_msg_get_voltd_handler(struct scmi_msg *msg);
128 #else
129 static inline
scmi_msg_get_voltd_handler(struct scmi_msg * msg __unused)130 scmi_msg_handler_t scmi_msg_get_voltd_handler(struct scmi_msg *msg __unused)
131 {
132 return NULL;
133 }
134 #endif
135 #endif /* SCMI_MSG_CLOCK_H */
136