@@ -22,6 +22,16 @@ struct scmi_clock_rate_set_reply {
22
22
uint32_t rate [2 ];
23
23
};
24
24
25
+ struct scmi_clock_parent_get_reply {
26
+ int32_t status ;
27
+ uint32_t parent_id ;
28
+ };
29
+
30
+ struct scmi_clock_parent_config {
31
+ uint32_t clk_id ;
32
+ uint32_t parent_id ;
33
+ };
34
+
25
35
int scmi_clock_rate_get (struct scmi_protocol * proto ,
26
36
uint32_t clk_id , uint32_t * rate )
27
37
{
@@ -61,6 +71,119 @@ int scmi_clock_rate_get(struct scmi_protocol *proto,
61
71
return 0 ;
62
72
}
63
73
74
+ int scmi_clock_rate_set (struct scmi_protocol * proto , struct scmi_clock_rate_config * cfg )
75
+ {
76
+ struct scmi_message msg , reply ;
77
+ int status , ret ;
78
+
79
+ /* sanity checks */
80
+ if (!proto || !cfg ) {
81
+ return - EINVAL ;
82
+ }
83
+
84
+ if (proto -> id != SCMI_PROTOCOL_CLOCK ) {
85
+ return - EINVAL ;
86
+ }
87
+
88
+ /* Currently ASYNC flag is not supported. */
89
+ if (cfg -> flags & SCMI_CLK_RATE_SET_FLAGS_ASYNC ) {
90
+ return - ENOTSUP ;
91
+ }
92
+
93
+ msg .hdr = SCMI_MESSAGE_HDR_MAKE (SCMI_CLK_MSG_CLOCK_RATE_SET , SCMI_COMMAND , proto -> id , 0x0 );
94
+ msg .len = sizeof (* cfg );
95
+ msg .content = cfg ;
96
+
97
+ reply .hdr = msg .hdr ;
98
+ reply .len = sizeof (status );
99
+ reply .content = & status ;
100
+
101
+ ret = scmi_send_message (proto , & msg , & reply );
102
+ if (ret < 0 ) {
103
+ return ret ;
104
+ }
105
+
106
+ if (status != SCMI_SUCCESS ) {
107
+ return scmi_status_to_errno (status );
108
+ }
109
+
110
+ return 0 ;
111
+ }
112
+
113
+ int scmi_clock_parent_get (struct scmi_protocol * proto , uint32_t clk_id , uint32_t * parent_id )
114
+ {
115
+ struct scmi_message msg , reply ;
116
+ int ret ;
117
+ struct scmi_clock_parent_get_reply reply_buffer ;
118
+
119
+ /* sanity checks */
120
+ if (!proto || !parent_id ) {
121
+ return - EINVAL ;
122
+ }
123
+
124
+ if (proto -> id != SCMI_PROTOCOL_CLOCK ) {
125
+ return - EINVAL ;
126
+ }
127
+
128
+ msg .hdr =
129
+ SCMI_MESSAGE_HDR_MAKE (SCMI_CLK_MSG_CLOCK_PARENT_GET , SCMI_COMMAND , proto -> id , 0x0 );
130
+ msg .len = sizeof (clk_id );
131
+ msg .content = & clk_id ;
132
+
133
+ reply .hdr = msg .hdr ;
134
+ reply .len = sizeof (reply_buffer );
135
+ reply .content = & reply_buffer ;
136
+
137
+ ret = scmi_send_message (proto , & msg , & reply );
138
+ if (ret < 0 ) {
139
+ return ret ;
140
+ }
141
+
142
+ if (reply_buffer .status != SCMI_SUCCESS ) {
143
+ return scmi_status_to_errno (reply_buffer .status );
144
+ }
145
+
146
+ * parent_id = reply_buffer .parent_id ;
147
+
148
+ return 0 ;
149
+ }
150
+
151
+ int scmi_clock_parent_set (struct scmi_protocol * proto , uint32_t clk_id , uint32_t parent_id )
152
+ {
153
+ struct scmi_clock_parent_config cfg = {.clk_id = clk_id , .parent_id = parent_id };
154
+ struct scmi_message msg , reply ;
155
+ int status , ret ;
156
+
157
+ /* sanity checks */
158
+ if (!proto ) {
159
+ return - EINVAL ;
160
+ }
161
+
162
+ if (proto -> id != SCMI_PROTOCOL_CLOCK ) {
163
+ return - EINVAL ;
164
+ }
165
+
166
+ msg .hdr =
167
+ SCMI_MESSAGE_HDR_MAKE (SCMI_CLK_MSG_CLOCK_PARENT_SET , SCMI_COMMAND , proto -> id , 0x0 );
168
+ msg .len = sizeof (cfg );
169
+ msg .content = & cfg ;
170
+
171
+ reply .hdr = msg .hdr ;
172
+ reply .len = sizeof (status );
173
+ reply .content = & status ;
174
+
175
+ ret = scmi_send_message (proto , & msg , & reply );
176
+ if (ret < 0 ) {
177
+ return ret ;
178
+ }
179
+
180
+ if (status != SCMI_SUCCESS ) {
181
+ return scmi_status_to_errno (status );
182
+ }
183
+
184
+ return 0 ;
185
+ }
186
+
64
187
int scmi_clock_config_set (struct scmi_protocol * proto ,
65
188
struct scmi_clock_config * cfg )
66
189
{
0 commit comments