xref: /optee_os/core/lib/scmi-server/include/scmi_agent_configuration.h (revision c9a214b74d8c39349681c23c5486e510a0599c3c)
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*
3  * Copyright (c) 2023-2025, STMicroelectronics
4  */
5 
6 #ifndef SCMI_AGENT_CONFIGURATION_H
7 #define SCMI_AGENT_CONFIGURATION_H
8 
9 #include <drivers/clk.h>
10 #include <drivers/rstctrl.h>
11 #include <stdbool.h>
12 #include <stddef.h>
13 
14 /* Structure used to describe the SCMI agents */
15 
16 /*
17  * struct scmi_clock - Description of a clock domain
18  * @name: Domain name
19  * @clk: Clock instance controlled by the domain
20  * @enabled: Default state of the clock
21  */
22 struct scmi_clock {
23 	const char *name;
24 	struct clk *clk;
25 	bool enabled;
26 };
27 
28 /*
29  * struct scmi_reset - Description of a reset domain
30  * @name: Domain name
31  * @rstctrl: Reset controlled by the domain
32  */
33 struct scmi_reset {
34 	const char *name;
35 	struct rstctrl *rstctrl;
36 };
37 
38 /*
39  * struct scpfw_channel_config - SCMI channel resources
40  * @name: Channel name
41  * @channel_id: ID for the channel in OP-TEE SCMI bindings
42  * @clock: Description of the clocks exposed on the channel
43  * @clock_count: Number of cells of @clock
44  * @reset: Description of the reset conntrollers exposed on the channel
45  * @reset_count: Number of cells of @reset
46  */
47 struct scpfw_channel_config {
48 	const char *name;
49 	unsigned int channel_id;
50 	struct scmi_clock *clock;
51 	size_t clock_count;
52 	struct scmi_reset *reset;
53 	size_t reset_count;
54 };
55 
56 /*
57  * struct scpfw_agent_config - SCMI agent description
58  * @name: Agent name exposed through SCMI
59  * @agent_id: Agent ID exposed through SCMI
60  * @channel_config: Channels exposed by the agent
61  * @channel_count: Number of cells in @channel_config
62  *
63  * There is currently a constraint that mandates @agent_id is the
64  * index minus 1 of the agent in array struct scpfw_config::agent_config
65  * This is because there is no config data for agent ID 0 that is
66  * reserved as the ID of the SCMI server itself in SCP-firmware.
67  */
68 struct scpfw_agent_config {
69 	const char *name;
70 	unsigned int agent_id;
71 	struct scpfw_channel_config *channel_config;
72 	size_t channel_count;
73 };
74 
75 /*
76  * struct scpfw_config - SCP firmware configuration root node
77  * @agent_config: Agents exposed with SCMI
78  * @agent_count: Number of cells in @agent_config
79  */
80 struct scpfw_config {
81 	struct scpfw_agent_config *agent_config;
82 	size_t agent_count;
83 };
84 
85 #ifdef CFG_SCMI_SCPFW_FROM_DT
86 /* Get the platform configuration data for the SCP firmware */
87 struct scpfw_config *scmi_scpfw_get_configuration(void);
88 
89 /* Release resources allocated to create SCP-firmware configuration data */
90 void scmi_scpfw_release_configuration(void);
91 
92 #else
scmi_scpfw_get_configuration(void)93 static inline struct scpfw_config *scmi_scpfw_get_configuration(void)
94 {
95 	return NULL;
96 }
97 
scmi_scpfw_release_configuration(void)98 static inline void scmi_scpfw_release_configuration(void)
99 {
100 }
101 #endif /* CFG_SCMI_SCPFW_FROM_DT */
102 
103 #endif /* SCMI_AGENT_CONFIGURATION_H */
104