1 /*
2  * Arm SCP/MCP Software
3  * Copyright (c) 2019-2021, Arm Limited and Contributors. All rights reserved.
4  *
5  * SPDX-License-Identifier: BSD-3-Clause
6  */
7 
8 #include "config_dvfs.h"
9 #include "config_power_domain.h"
10 #include "config_resource_perms.h"
11 #include "config_sensor.h"
12 #include "juno_clock.h"
13 #include "juno_scmi.h"
14 
15 #ifdef BUILD_HAS_MOD_SCMI_RESET_DOMAIN
16 #    include <mod_juno_reset_domain.h>
17 #endif
18 
19 #include <mod_resource_perms.h>
20 #include <mod_scmi_std.h>
21 
22 #include <fwk_element.h>
23 #include <fwk_id.h>
24 #include <fwk_macros.h>
25 #include <fwk_module.h>
26 #include <fwk_module_idx.h>
27 
28 /*!
29  * If the agent wants to modify permissions at run-time these tables
30  * must be allocated in wrtiable memory.
31  */
32 
33 /*!
34  * Agent 0 gets access to all resources.
35  */
36 #define AGENT_IDX(agent_id) (agent_id - 1)
37 
38 /*!
39  * Note that permissions are denied when a bit is set, the
40  * permissions tables are being added for Juno as an example only.
41  */
42 static struct mod_res_agent_protocol_permissions agent_protocol_permissions[] =
43     {
44         [AGENT_IDX(JUNO_SCMI_AGENT_IDX_OSPM)] =
45             {
46                 .protocols =
47                     (mod_res_perms_t)MOD_RES_PERMS_SCMI_ALL_PROTOCOLS_ALLOWED,
48             },
49 
50         /* PSCI agent has no access to clock, perf and sensor protocol */
51         [AGENT_IDX(JUNO_SCMI_AGENT_IDX_PSCI)] =
52             {
53                 .protocols = MOD_RES_PERMS_SCMI_CLOCK_PROTOCOL_DENIED |
54                     MOD_RES_PERMS_SCMI_PERF_PROTOCOL_DENIED |
55                     MOD_RES_PERMS_SCMI_SENSOR_PROTOCOL_DENIED,
56             },
57     };
58 
59 /*
60  * Messages have an index offset from 0x3 as all agents can access
61  * the VERSION/ATTRIBUTES/MSG_ATTRIBUTES messages for all
62  * protocols, hence message 0x3 maps to bit[0], message 0x4 maps
63  * to bit[1], etc.
64  */
65 static struct mod_res_agent_msg_permissions agent_msg_permissions[] = {
66     [AGENT_IDX(JUNO_SCMI_AGENT_IDX_OSPM)] = {
67         .messages = {
68         /* Example, Base, disable unused msg 12 */
69         [MOD_RES_PERMS_SCMI_BASE_MESSAGE_IDX] =
70             (1 << 12),  /* Example, Base, disable unused msg 12 */
71         /* Power Domain */
72         [MOD_RES_PERMS_SCMI_POWER_DOMAIN_MESSAGE_IDX] = 0x0,
73         /* System Power Domain */
74         [MOD_RES_PERMS_SCMI_SYS_POWER_MESSAGE_IDX] = 0x0,
75         /* Performance */
76         [MOD_RES_PERMS_SCMI_PERF_MESSAGE_IDX] = 0x0,
77         /* Clocks */
78         [MOD_RES_PERMS_SCMI_CLOCK_MESSAGE_IDX] = 0x0,
79         /* Sensors */
80         [MOD_RES_PERMS_SCMI_SENSOR_MESSAGE_IDX] = 0x0,
81         /* Reset Domains */
82         [MOD_RES_PERMS_SCMI_RESET_DOMAIN_MESSAGE_IDX] = 0x0,
83         }
84     },
85     [AGENT_IDX(JUNO_SCMI_AGENT_IDX_PSCI)] = {
86         .messages = {
87         [MOD_RES_PERMS_SCMI_BASE_MESSAGE_IDX] = 0x0,
88         [MOD_RES_PERMS_SCMI_POWER_DOMAIN_MESSAGE_IDX] = 0x0,
89         [MOD_RES_PERMS_SCMI_SYS_POWER_MESSAGE_IDX] = 0x0,
90         [MOD_RES_PERMS_SCMI_PERF_MESSAGE_IDX] =
91             ((1 << (MOD_SCMI_PERF_DOMAIN_ATTRIBUTES -
92                     MOD_RES_PERMS_SCMI_PERF_BITMASK_IDX)) |
93              /* DESCRIBE_LEVELS is required for some reason ... */
94              (0 << (MOD_SCMI_PERF_DESCRIBE_LEVELS -
95                     MOD_RES_PERMS_SCMI_PERF_BITMASK_IDX)) |
96              (1 << (MOD_SCMI_PERF_LIMITS_SET -
97                     MOD_RES_PERMS_SCMI_PERF_BITMASK_IDX)) |
98              (1 << (MOD_SCMI_PERF_LIMITS_GET -
99                     MOD_RES_PERMS_SCMI_PERF_BITMASK_IDX)) |
100              (1 << (MOD_SCMI_PERF_LEVEL_SET -
101                     MOD_RES_PERMS_SCMI_PERF_BITMASK_IDX)) |
102              (1 << (MOD_SCMI_PERF_LEVEL_GET -
103                     MOD_RES_PERMS_SCMI_PERF_BITMASK_IDX)) |
104              (1 << (MOD_SCMI_PERF_NOTIFY_LIMITS -
105                     MOD_RES_PERMS_SCMI_PERF_BITMASK_IDX)) |
106              (1 << (MOD_SCMI_PERF_NOTIFY_LEVEL -
107                     MOD_RES_PERMS_SCMI_PERF_BITMASK_IDX)) |
108              (1 << (MOD_SCMI_PERF_DESCRIBE_FAST_CHANNEL -
109                     MOD_RES_PERMS_SCMI_PERF_BITMASK_IDX))),
110         /* Clocks, no access */
111         [MOD_RES_PERMS_SCMI_CLOCK_MESSAGE_IDX] = 0xff,
112         [MOD_RES_PERMS_SCMI_SENSOR_MESSAGE_IDX] = 0x0,
113         [MOD_RES_PERMS_SCMI_RESET_DOMAIN_MESSAGE_IDX] = 0x0,
114         }
115     },
116 };
117 
118 /*
119  * Protocols have an index offset from SCMI_BASE protocol, 0x10
120  * Note that the BASE and SYSTEM_POWER protocols are managed
121  * on a protocol:command basis, there is no resource permissions
122  * associated with the protocols.
123  */
124 
125 /*
126  * We are tracking 5 SCMI Clock Protocol commands
127  *
128  *  0, SCMI_CLOCK_ATTRIBUTES
129  *  1, SCMI_CLOCK_RATE_GET
130  *  2, SCMI_CLOCK_RATE_SET
131  *  3, SCMI_CLOCK_CONFIG_SET
132  *  4, SCMI_CLOCK_DESCRIBE_RATES
133  */
134 #define JUNO_CLOCK_RESOURCE_CMDS 5
135 #define JUNO_CLOCK_RESOURCE_ELEMENTS \
136     ((JUNO_CLOCK_IDX_COUNT >> MOD_RES_PERMS_TYPE_SHIFT) + 1)
137 static mod_res_perms_t scmi_clock_perms[]
138     [JUNO_CLOCK_RESOURCE_CMDS][JUNO_CLOCK_RESOURCE_ELEMENTS] = {
139         /* SCMI_PROTOCOL_ID_CLOCK */
140         /* 0, SCMI_CLOCK_ATTRIBUTES */
141         /* 1, SCMI_CLOCK_RATE_GET */
142         /* 2, SCMI_CLOCK_RATE_SET */
143         /* 3, SCMI_CLOCK_CONFIG_SET */
144         /* 4, SCMI_CLOCK_DESCRIBE_RATES */
145         [AGENT_IDX(JUNO_SCMI_AGENT_IDX_OSPM)] = {
146             [MOD_RES_PERMS_SCMI_CLOCK_ATTRIBUTES_IDX][0] = 0x0,
147             /*
148              * Clocks 0, 1, 2, 4 do not allow set commands,
149              * Clocks 3 and 5 allow rate_set/config_set
150              */
151             [MOD_RES_PERMS_SCMI_CLOCK_RATE_SET_IDX][0] =
152                 ((1 << 0) | (1 << 1) | (1 << 2) | (1 << 4)),
153             [MOD_RES_PERMS_SCMI_CLOCK_RATE_GET_IDX][0] = 0x0,
154             [MOD_RES_PERMS_SCMI_CLOCK_CONFIG_SET_IDX][0] = 0x0,
155             [MOD_RES_PERMS_SCMI_CLOCK_DESCRIBE_RATE_IDX][0] = 0x0,
156         },
157         [AGENT_IDX(JUNO_SCMI_AGENT_IDX_PSCI)] = {
158             /* No access to clocks for PSCI agent, so bits [4:0] set  */
159             [MOD_RES_PERMS_SCMI_CLOCK_ATTRIBUTES_IDX][0] = 0x1f,
160             [MOD_RES_PERMS_SCMI_CLOCK_RATE_SET_IDX][0] = 0x1f,
161             [MOD_RES_PERMS_SCMI_CLOCK_RATE_GET_IDX][0] = 0x1f,
162             [MOD_RES_PERMS_SCMI_CLOCK_CONFIG_SET_IDX][0] = 0x1f,
163             [MOD_RES_PERMS_SCMI_CLOCK_DESCRIBE_RATE_IDX][0] = 0x1f,
164         },
165 };
166 
167 /*
168  * We are tracking 4 SCMI Power Domain Protocol commands
169  *
170  *  0, SCMI_PD_POWER_DOMAIN_ATTRIBUTES
171  *  1, SCMI_PD_POWER_STATE_SET
172  *  2, SCMI_PD_POWER_STATE_GET
173  *  3, SCMI_PD_POWER_STATE_NOTIFY
174  */
175 #define JUNO_PD_RESOURCE_CMDS 4
176 #define JUNO_PD_RESOURCE_ELEMENTS \
177     ((POWER_DOMAIN_IDX_COUNT >> MOD_RES_PERMS_TYPE_SHIFT) + 1)
178 static mod_res_perms_t
179     scmi_pd_perms[][JUNO_PD_RESOURCE_CMDS][JUNO_PD_RESOURCE_ELEMENTS] = {
180         /* SCMI_PROTOCOL_ID_POWER_DOMAIN */
181         /* 0, SCMI_PD_POWER_DOMAIN_ATTRIBUTES */
182         /* 1, SCMI_PD_POWER_STATE_SET */
183         /* 2, SCMI_PD_POWER_STATE_GET */
184         /* 3, SCMI_PD_POWER_STATE_NOTIFY */
185         /* For Juno, resource_id == power domain ID */
186         [AGENT_IDX(JUNO_SCMI_AGENT_IDX_OSPM)] = {
187                 [MOD_RES_PERMS_SCMI_POWER_DOMAIN_ATTRIBUTES_IDX][0] = 0x0,
188                 [MOD_RES_PERMS_SCMI_POWER_DOMAIN_STATE_SET_IDX][0] = 0x0,
189                 [MOD_RES_PERMS_SCMI_POWER_DOMAIN_STATE_GET_IDX][0] = 0x0,
190                 [MOD_RES_PERMS_SCMI_POWER_DOMAIN_STATE_NOTIFY_IDX][0] = 0x0,
191             },
192         [AGENT_IDX(JUNO_SCMI_AGENT_IDX_PSCI)] = {
193                 [MOD_RES_PERMS_SCMI_POWER_DOMAIN_ATTRIBUTES_IDX][0] = 0x0,
194                 [MOD_RES_PERMS_SCMI_POWER_DOMAIN_STATE_SET_IDX][0] = 0x0,
195                 [MOD_RES_PERMS_SCMI_POWER_DOMAIN_STATE_GET_IDX][0] = 0x0,
196                 [MOD_RES_PERMS_SCMI_POWER_DOMAIN_STATE_NOTIFY_IDX][0] = 0x0,
197             },
198 };
199 
200 /*
201  * We are tracking 9 SCMI Performance Protocol commands
202  *
203  * 0, SCMI_PERF_DOMAIN_ATTRIBUTES
204  * 1, SCMI_PERF_DESCRIBE_LEVELS
205  * 2, SCMI_PERF_LIMITS_SET
206  * 3, SCMI_PERF_LIMITS_GET
207  * 4, SCMI_PERF_LEVEL_SET
208  * 5, SCMI_PERF_LEVEL_GET
209  * 6, SCMI_PERF_NOTIFY_LIMITS
210  * 7, SCMI_PERF_NOTIFY_LEVEL
211  * 8, SCMI_PERF_DESCRIBE_FAST_CHANNEL
212  */
213 #define JUNO_PERF_RESOURCE_CMDS 9
214 #define JUNO_PERF_RESOURCE_ELEMENTS \
215     ((DVFS_ELEMENT_IDX_COUNT >> MOD_RES_PERMS_TYPE_SHIFT) + 1)
216 static mod_res_perms_t
217     scmi_perf_perms[][JUNO_PERF_RESOURCE_CMDS][JUNO_PERF_RESOURCE_ELEMENTS] = {
218         /* SCMI_PROTOCOL_ID_PERF */
219         /* 0, SCMI_PERF_DOMAIN_ATTRIBUTES */
220         /* 1, SCMI_PERF_DESCRIBE_LEVELS */
221         /* 2, SCMI_PERF_LIMITS_SET */
222         /* 3, SCMI_PERF_LIMITS_GET */
223         /* 4, SCMI_PERF_LEVEL_SET */
224         /* 5, SCMI_PERF_LEVEL_GET */
225         /* 6, SCMI_PERF_NOTIFY_LIMITS */
226         /* 7, SCMI_PERF_NOTIFY_LEVEL */
227         /* 8, SCMI_PERF_DESCRIBE_FAST_CHANNEL */
228         /*
229          * For Juno, resource_id == performance domain_id
230          * see mod_scmi_perf_domain_config domains[]
231          */
232         [AGENT_IDX(JUNO_SCMI_AGENT_IDX_OSPM)] = {
233             [MOD_RES_PERMS_SCMI_PERF_ATTRIBUTES_IDX][0] = 0x0,
234             [MOD_RES_PERMS_SCMI_PERF_DESCRIBE_LEVELS_IDX][0] = 0x0,
235             [MOD_RES_PERMS_SCMI_PERF_LIMITS_SET_IDX][0] = 0x0,
236             [MOD_RES_PERMS_SCMI_PERF_LIMITS_GET_IDX][0] = 0x0,
237             [MOD_RES_PERMS_SCMI_PERF_LEVEL_SET_IDX][0] = 0x0,
238             [MOD_RES_PERMS_SCMI_PERF_LEVEL_GET_IDX][0] = 0x0,
239             [MOD_RES_PERMS_SCMI_PERF_NOTIFY_LIMITS_IDX][0] = 0x0,
240             [MOD_RES_PERMS_SCMI_PERF_NOTIFY_LEVEL_IDX][0] = 0x0,
241             [MOD_RES_PERMS_SCMI_PERF_DESCRIBE_FAST_CHANNEL_IDX][0] = 0x0,
242         },
243         [AGENT_IDX(JUNO_SCMI_AGENT_IDX_PSCI)] = {
244             [MOD_RES_PERMS_SCMI_PERF_ATTRIBUTES_IDX][0] = 0x0,
245             [MOD_RES_PERMS_SCMI_PERF_DESCRIBE_LEVELS_IDX][0] = 0x0,
246             [MOD_RES_PERMS_SCMI_PERF_LIMITS_SET_IDX][0] = 0x0,
247             [MOD_RES_PERMS_SCMI_PERF_LIMITS_GET_IDX][0] = 0x0,
248             [MOD_RES_PERMS_SCMI_PERF_LEVEL_SET_IDX][0] = 0x0,
249             [MOD_RES_PERMS_SCMI_PERF_LEVEL_GET_IDX][0] = 0x0,
250             [MOD_RES_PERMS_SCMI_PERF_NOTIFY_LIMITS_IDX][0] = 0x0,
251             [MOD_RES_PERMS_SCMI_PERF_NOTIFY_LEVEL_IDX][0] = 0x0,
252             [MOD_RES_PERMS_SCMI_PERF_DESCRIBE_FAST_CHANNEL_IDX][0] = 0x0,
253         },
254 };
255 
256 /*
257  * We are tracking 4 SCMI Sensor Protocol commands
258  *
259  * 0, SCMI_SENSOR_DESCRIPTION_GET
260  * 1, SCMI_SENSOR_TRIP_POINT_NOTIFY
261  * 2, SCMI_SENSOR_TRIP_POINT_CONFIG
262  * 3, SCMI_SENSOR_READING_GET
263  */
264 #define JUNO_SENSOR_RESOURCE_CMDS 4
265 #define JUNO_SENSOR_RESOURCE_ELEMENTS \
266     ((MOD_JUNO_R1_R2_SENSOR_IDX_COUNT >> MOD_RES_PERMS_TYPE_SHIFT) + 1)
267 static mod_res_perms_t
268     scmi_sensor_perms[][JUNO_SENSOR_RESOURCE_CMDS]
269         [JUNO_SENSOR_RESOURCE_ELEMENTS] = {
270             /* SCMI_PROTOCOL_ID_SENSOR */
271             /* 0, SCMI_SENSOR_DESCRIPTION_GET */
272             /* 1, SCMI_SENSOR_TRIP_POINT_NOTIFY */
273             /* 2, SCMI_SENSOR_TRIP_POINT_CONFIG */
274             /* 3, SCMI_SENSOR_READING_GET */
275             [AGENT_IDX(JUNO_SCMI_AGENT_IDX_OSPM)] = {
276                 [MOD_RES_PERMS_SCMI_SENSOR_DESCRIPTION_GET_IDX][0] = 0x0,
277                 [MOD_RES_PERMS_SCMI_SENSOR_TRIP_POINT_NOTIFY_IDX][0] = 0x0,
278                 [MOD_RES_PERMS_SCMI_SENSOR_TRIP_POINT_CONFIG_IDX][0] = 0x0,
279                 [MOD_RES_PERMS_SCMI_SENSOR_READING_GET_IDX][0] = 0x0,
280             },
281             [AGENT_IDX(JUNO_SCMI_AGENT_IDX_PSCI)] = {
282                 [MOD_RES_PERMS_SCMI_SENSOR_DESCRIPTION_GET_IDX][0] = 0x0,
283                 [MOD_RES_PERMS_SCMI_SENSOR_TRIP_POINT_NOTIFY_IDX][0] = 0x0,
284                 [MOD_RES_PERMS_SCMI_SENSOR_TRIP_POINT_CONFIG_IDX][0] = 0x0,
285                 [MOD_RES_PERMS_SCMI_SENSOR_READING_GET_IDX][0] = 0x0,
286             },
287     };
288 
289 /*
290  * We are tracking 3 SCMI Reset Domain Protocol commands
291  *
292  * 0, MOD_SCMI_RESET_DOMAIN_ATTRIBUTES
293  * 1, MOD_SCMI_RESET_REQUEST
294  * 2, MOD_SCMI_RESET_NOTIFY
295  */
296 #ifdef BUILD_HAS_MOD_SCMI_RESET_DOMAIN
297 
298 #    define JUNO_RESET_DOMAIN_RESOURCE_CMDS 3
299 #    define JUNO_RESET_DOMAIN_RESOURCE_ELEMENTS \
300         ((JUNO_RESET_DOMAIN_IDX_COUNT >> MOD_RES_PERMS_TYPE_SHIFT) + 1)
301 static mod_res_perms_t
302     scmi_reset_domain_perms[] [JUNO_RESET_DOMAIN_RESOURCE_CMDS]
303         [JUNO_RESET_DOMAIN_RESOURCE_ELEMENTS] = {
304      /* SCMI_PROTOCOL_ID_RESET_DOMAIN */
305      /* 0, MOD_SCMI_RESET_DOMAIN_ATTRIBUTES */
306      /* 1, MOD_SCMI_RESET_REQUEST */
307      /* 2, MOD_SCMI_RESET_NOTIFY */
308      [AGENT_IDX(JUNO_SCMI_AGENT_IDX_OSPM)] = {
309          [MOD_RES_PERMS_SCMI_RESET_DOMAIN_ATTRIBUTES_IDX][0] = 0x0,
310          [MOD_RES_PERMS_SCMI_RESET_DOMAIN_RESET_REQUEST_IDX][0] = 0x0,
311          [MOD_RES_PERMS_SCMI_RESET_DOMAIN_RESET_NOTIFY_IDX][0] = 0x0,
312      },
313      [AGENT_IDX(JUNO_SCMI_AGENT_IDX_PSCI)] = {
314          [MOD_RES_PERMS_SCMI_RESET_DOMAIN_ATTRIBUTES_IDX][0] = 0x0,
315          [MOD_RES_PERMS_SCMI_RESET_DOMAIN_RESET_REQUEST_IDX][0] = 0x0,
316          [MOD_RES_PERMS_SCMI_RESET_DOMAIN_RESET_NOTIFY_IDX][0] = 0x0,
317      },
318  };
319 
320 #endif
321 
322 /*
323  * Juno Platform Permissions
324  */
325 static struct mod_res_agent_permission agent_permissions = {
326     .agent_protocol_permissions = agent_protocol_permissions,
327     .agent_msg_permissions = agent_msg_permissions,
328     .scmi_clock_perms = &scmi_clock_perms[0][0][0],
329     .scmi_pd_perms = &scmi_pd_perms[0][0][0],
330     .scmi_perf_perms = &scmi_perf_perms[0][0][0],
331     .scmi_sensor_perms = &scmi_sensor_perms[0][0][0],
332 #ifdef BUILD_HAS_MOD_SCMI_RESET_DOMAIN
333     .scmi_reset_domain_perms = &scmi_reset_domain_perms[0][0][0],
334 #endif
335 };
336 
337 /*
338  * Juno Platform devices
339  *
340  * Note that a device must be terminated with
341  *  {FWK_ID_NONE, MOD_RES_DOMAIN_DEVICE_INVALID}
342  *
343  */
344 static struct mod_res_domain_device devices_cpu[] = {
345     {
346         .device_id =
347             FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_SCMI_PERF, DVFS_ELEMENT_IDX_BIG),
348         .type = MOD_RES_PERF_DOMAIN_DEVICE,
349     },
350     {
351         .device_id = FWK_ID_ELEMENT_INIT(
352             FWK_MODULE_IDX_SCMI_CLOCK,
353             JUNO_CLOCK_IDX_BIGCLK),
354         .type = MOD_RES_CLOCK_DOMAIN_DEVICE,
355     },
356     {
357         .device_id = FWK_ID_ELEMENT_INIT(
358             FWK_MODULE_IDX_SCMI_POWER_DOMAIN,
359             POWER_DOMAIN_IDX_BIG_CPU0),
360         .type = MOD_RES_POWER_DOMAIN_DEVICE,
361     },
362     {
363         .device_id = FWK_ID_ELEMENT_INIT(
364             FWK_MODULE_IDX_SCMI_POWER_DOMAIN,
365             POWER_DOMAIN_IDX_BIG_CPU1),
366         .type = MOD_RES_POWER_DOMAIN_DEVICE,
367     },
368     {
369         .device_id = FWK_ID_ELEMENT_INIT(
370             FWK_MODULE_IDX_SCMI_POWER_DOMAIN,
371             POWER_DOMAIN_IDX_BIG_SSTOP),
372         .type = MOD_RES_POWER_DOMAIN_DEVICE,
373     },
374     {
375         .device_id = FWK_ID_ELEMENT_INIT(
376             FWK_MODULE_IDX_SCMI_PERF,
377             DVFS_ELEMENT_IDX_LITTLE),
378         .type = MOD_RES_PERF_DOMAIN_DEVICE,
379     },
380     {
381         .device_id = FWK_ID_ELEMENT_INIT(
382             FWK_MODULE_IDX_SCMI_CLOCK,
383             JUNO_CLOCK_IDX_LITTLECLK),
384         .type = MOD_RES_CLOCK_DOMAIN_DEVICE,
385     },
386     {
387         .device_id = FWK_ID_ELEMENT_INIT(
388             FWK_MODULE_IDX_SCMI_POWER_DOMAIN,
389             POWER_DOMAIN_IDX_LITTLE_CPU0),
390         .type = MOD_RES_POWER_DOMAIN_DEVICE,
391     },
392     {
393         .device_id = FWK_ID_ELEMENT_INIT(
394             FWK_MODULE_IDX_SCMI_POWER_DOMAIN,
395             POWER_DOMAIN_IDX_LITTLE_CPU1),
396         .type = MOD_RES_POWER_DOMAIN_DEVICE,
397     },
398     {
399         .device_id = FWK_ID_ELEMENT_INIT(
400             FWK_MODULE_IDX_SCMI_POWER_DOMAIN,
401             POWER_DOMAIN_IDX_LITTLE_CPU2),
402         .type = MOD_RES_POWER_DOMAIN_DEVICE,
403     },
404     {
405         .device_id = FWK_ID_ELEMENT_INIT(
406             FWK_MODULE_IDX_SCMI_POWER_DOMAIN,
407             POWER_DOMAIN_IDX_LITTLE_CPU3),
408         .type = MOD_RES_POWER_DOMAIN_DEVICE,
409     },
410     {
411         .device_id = FWK_ID_ELEMENT_INIT(
412             FWK_MODULE_IDX_SCMI_POWER_DOMAIN,
413             POWER_DOMAIN_IDX_LITTLE_SSTOP),
414         .type = MOD_RES_POWER_DOMAIN_DEVICE,
415     },
416     {
417         .device_id = FWK_ID_NONE_INIT,
418         .type = MOD_RES_DOMAIN_DEVICE_INVALID,
419     },
420 };
421 
422 static struct mod_res_domain_device devices_gpu[] = {
423     {
424         .device_id =
425             FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_SCMI_PERF, DVFS_ELEMENT_IDX_GPU),
426         .type = MOD_RES_PERF_DOMAIN_DEVICE,
427     },
428     {
429         .device_id = FWK_ID_ELEMENT_INIT(
430             FWK_MODULE_IDX_SCMI_CLOCK,
431             JUNO_CLOCK_IDX_GPUCLK),
432         .type = MOD_RES_CLOCK_DOMAIN_DEVICE,
433     },
434     {
435         .device_id = FWK_ID_ELEMENT_INIT(
436             FWK_MODULE_IDX_SCMI_POWER_DOMAIN,
437             POWER_DOMAIN_IDX_GPUTOP),
438         .type = MOD_RES_POWER_DOMAIN_DEVICE,
439     },
440     {
441         .device_id = FWK_ID_NONE_INIT,
442         .type = MOD_RES_DOMAIN_DEVICE_INVALID,
443     },
444 };
445 
446 static struct mod_res_domain_device devices_io[] = {
447     {
448         .device_id = FWK_ID_ELEMENT_INIT(
449             FWK_MODULE_IDX_SCMI_CLOCK,
450             JUNO_CLOCK_IDX_HDLCD0),
451         .type = MOD_RES_CLOCK_DOMAIN_DEVICE,
452     },
453     {
454         .device_id = FWK_ID_ELEMENT_INIT(
455             FWK_MODULE_IDX_SCMI_CLOCK,
456             JUNO_CLOCK_IDX_HDLCD1),
457         .type = MOD_RES_CLOCK_DOMAIN_DEVICE,
458     },
459     {
460         .device_id = FWK_ID_ELEMENT_INIT(
461             FWK_MODULE_IDX_SCMI_CLOCK,
462             JUNO_CLOCK_IDX_I2SCLK),
463         .type = MOD_RES_CLOCK_DOMAIN_DEVICE,
464     },
465 #ifdef BUILD_HAS_MOD_SCMI_RESET_DOMAIN
466     {
467         .device_id = FWK_ID_ELEMENT_INIT(
468             FWK_MODULE_IDX_RESET_DOMAIN,
469             JUNO_RESET_DOMAIN_IDX_UART),
470         .type = MOD_RES_RESET_DOMAIN_DEVICE,
471     },
472 #endif
473     {
474         .device_id = FWK_ID_NONE_INIT,
475         .type = MOD_RES_DOMAIN_DEVICE_INVALID,
476     },
477 };
478 
479 static struct mod_res_device juno_devices[] = {
480     {
481         .device_id = (uint16_t)JUNO_RES_PERMS_DEVICES_CPU,
482         .domain_devices = devices_cpu,
483     },
484     {
485         .device_id = (uint16_t)JUNO_RES_PERMS_DEVICES_GPU,
486         .domain_devices = devices_gpu,
487     },
488     {
489         .device_id = (uint16_t)JUNO_RES_PERMS_DEVICES_IO,
490         .domain_devices = devices_io,
491     },
492     { 0 },
493 };
494 
495 struct fwk_module_config config_resource_perms = {
496     .data =
497         &(struct mod_res_resource_perms_config){
498             .agent_permissions = (uintptr_t)&agent_permissions,
499             .agent_count = (uint32_t)JUNO_SCMI_AGENT_IDX_COUNT,
500             .protocol_count = 7,
501             .clock_count = (uint32_t)JUNO_CLOCK_IDX_COUNT,
502             .sensor_count = (uint32_t)MOD_JUNO_R0_SENSOR_IDX_COUNT,
503             .pd_count = (uint32_t)POWER_DOMAIN_IDX_COUNT,
504             .perf_count = (uint32_t)DVFS_ELEMENT_IDX_COUNT,
505             .perf_cmd_count = JUNO_PERF_RESOURCE_CMDS,
506             .perf_resource_count = JUNO_PERF_RESOURCE_ELEMENTS,
507             .device_count = (uint32_t)JUNO_RES_PERMS_DEVICES_COUNT,
508 #ifdef BUILD_HAS_MOD_SCMI_RESET_DOMAIN
509             .reset_domain_count = JUNO_RESET_DOMAIN_IDX_COUNT,
510 #endif
511             .domain_devices = (uintptr_t)&juno_devices,
512         },
513 };
514