This source file includes following definitions.
- scmi_driver_register
- scmi_driver_unregister
1
2
3
4
5
6
7 #include <linux/device.h>
8 #include <linux/types.h>
9
10 #define SCMI_MAX_STR_SIZE 16
11 #define SCMI_MAX_NUM_RATES 16
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 struct scmi_revision_info {
28 u16 major_ver;
29 u16 minor_ver;
30 u8 num_protocols;
31 u8 num_agents;
32 u32 impl_ver;
33 char vendor_id[SCMI_MAX_STR_SIZE];
34 char sub_vendor_id[SCMI_MAX_STR_SIZE];
35 };
36
37 struct scmi_clock_info {
38 char name[SCMI_MAX_STR_SIZE];
39 bool rate_discrete;
40 union {
41 struct {
42 int num_rates;
43 u64 rates[SCMI_MAX_NUM_RATES];
44 } list;
45 struct {
46 u64 min_rate;
47 u64 max_rate;
48 u64 step_size;
49 } range;
50 };
51 };
52
53 struct scmi_handle;
54
55
56
57
58
59
60
61
62
63
64
65
66 struct scmi_clk_ops {
67 int (*count_get)(const struct scmi_handle *handle);
68
69 const struct scmi_clock_info *(*info_get)
70 (const struct scmi_handle *handle, u32 clk_id);
71 int (*rate_get)(const struct scmi_handle *handle, u32 clk_id,
72 u64 *rate);
73 int (*rate_set)(const struct scmi_handle *handle, u32 clk_id,
74 u64 rate);
75 int (*enable)(const struct scmi_handle *handle, u32 clk_id);
76 int (*disable)(const struct scmi_handle *handle, u32 clk_id);
77 };
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97 struct scmi_perf_ops {
98 int (*limits_set)(const struct scmi_handle *handle, u32 domain,
99 u32 max_perf, u32 min_perf);
100 int (*limits_get)(const struct scmi_handle *handle, u32 domain,
101 u32 *max_perf, u32 *min_perf);
102 int (*level_set)(const struct scmi_handle *handle, u32 domain,
103 u32 level, bool poll);
104 int (*level_get)(const struct scmi_handle *handle, u32 domain,
105 u32 *level, bool poll);
106 int (*device_domain_id)(struct device *dev);
107 int (*transition_latency_get)(const struct scmi_handle *handle,
108 struct device *dev);
109 int (*device_opps_add)(const struct scmi_handle *handle,
110 struct device *dev);
111 int (*freq_set)(const struct scmi_handle *handle, u32 domain,
112 unsigned long rate, bool poll);
113 int (*freq_get)(const struct scmi_handle *handle, u32 domain,
114 unsigned long *rate, bool poll);
115 int (*est_power_get)(const struct scmi_handle *handle, u32 domain,
116 unsigned long *rate, unsigned long *power);
117 };
118
119
120
121
122
123
124
125
126
127
128 struct scmi_power_ops {
129 int (*num_domains_get)(const struct scmi_handle *handle);
130 char *(*name_get)(const struct scmi_handle *handle, u32 domain);
131 #define SCMI_POWER_STATE_TYPE_SHIFT 30
132 #define SCMI_POWER_STATE_ID_MASK (BIT(28) - 1)
133 #define SCMI_POWER_STATE_PARAM(type, id) \
134 ((((type) & BIT(0)) << SCMI_POWER_STATE_TYPE_SHIFT) | \
135 ((id) & SCMI_POWER_STATE_ID_MASK))
136 #define SCMI_POWER_STATE_GENERIC_ON SCMI_POWER_STATE_PARAM(0, 0)
137 #define SCMI_POWER_STATE_GENERIC_OFF SCMI_POWER_STATE_PARAM(1, 0)
138 int (*state_set)(const struct scmi_handle *handle, u32 domain,
139 u32 state);
140 int (*state_get)(const struct scmi_handle *handle, u32 domain,
141 u32 *state);
142 };
143
144 struct scmi_sensor_info {
145 u32 id;
146 u8 type;
147 s8 scale;
148 u8 num_trip_points;
149 bool async;
150 char name[SCMI_MAX_STR_SIZE];
151 };
152
153
154
155
156
157 enum scmi_sensor_class {
158 NONE = 0x0,
159 TEMPERATURE_C = 0x2,
160 VOLTAGE = 0x5,
161 CURRENT = 0x6,
162 POWER = 0x7,
163 ENERGY = 0x8,
164 };
165
166
167
168
169
170
171
172
173
174
175
176
177 struct scmi_sensor_ops {
178 int (*count_get)(const struct scmi_handle *handle);
179
180 const struct scmi_sensor_info *(*info_get)
181 (const struct scmi_handle *handle, u32 sensor_id);
182 int (*trip_point_notify)(const struct scmi_handle *handle,
183 u32 sensor_id, bool enable);
184 int (*trip_point_config)(const struct scmi_handle *handle,
185 u32 sensor_id, u8 trip_id, u64 trip_value);
186 int (*reading_get)(const struct scmi_handle *handle, u32 sensor_id,
187 u64 *value);
188 };
189
190
191
192
193
194
195
196
197
198
199
200
201 struct scmi_reset_ops {
202 int (*num_domains_get)(const struct scmi_handle *handle);
203 char *(*name_get)(const struct scmi_handle *handle, u32 domain);
204 int (*latency_get)(const struct scmi_handle *handle, u32 domain);
205 int (*reset)(const struct scmi_handle *handle, u32 domain);
206 int (*assert)(const struct scmi_handle *handle, u32 domain);
207 int (*deassert)(const struct scmi_handle *handle, u32 domain);
208 };
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231 struct scmi_handle {
232 struct device *dev;
233 struct scmi_revision_info *version;
234 struct scmi_perf_ops *perf_ops;
235 struct scmi_clk_ops *clk_ops;
236 struct scmi_power_ops *power_ops;
237 struct scmi_sensor_ops *sensor_ops;
238 struct scmi_reset_ops *reset_ops;
239
240 void *perf_priv;
241 void *clk_priv;
242 void *power_priv;
243 void *sensor_priv;
244 void *reset_priv;
245 };
246
247 enum scmi_std_protocol {
248 SCMI_PROTOCOL_BASE = 0x10,
249 SCMI_PROTOCOL_POWER = 0x11,
250 SCMI_PROTOCOL_SYSTEM = 0x12,
251 SCMI_PROTOCOL_PERF = 0x13,
252 SCMI_PROTOCOL_CLOCK = 0x14,
253 SCMI_PROTOCOL_SENSOR = 0x15,
254 SCMI_PROTOCOL_RESET = 0x16,
255 };
256
257 struct scmi_device {
258 u32 id;
259 u8 protocol_id;
260 struct device dev;
261 struct scmi_handle *handle;
262 };
263
264 #define to_scmi_dev(d) container_of(d, struct scmi_device, dev)
265
266 struct scmi_device *
267 scmi_device_create(struct device_node *np, struct device *parent, int protocol);
268 void scmi_device_destroy(struct scmi_device *scmi_dev);
269
270 struct scmi_device_id {
271 u8 protocol_id;
272 };
273
274 struct scmi_driver {
275 const char *name;
276 int (*probe)(struct scmi_device *sdev);
277 void (*remove)(struct scmi_device *sdev);
278 const struct scmi_device_id *id_table;
279
280 struct device_driver driver;
281 };
282
283 #define to_scmi_driver(d) container_of(d, struct scmi_driver, driver)
284
285 #ifdef CONFIG_ARM_SCMI_PROTOCOL
286 int scmi_driver_register(struct scmi_driver *driver,
287 struct module *owner, const char *mod_name);
288 void scmi_driver_unregister(struct scmi_driver *driver);
289 #else
290 static inline int
291 scmi_driver_register(struct scmi_driver *driver, struct module *owner,
292 const char *mod_name)
293 {
294 return -EINVAL;
295 }
296
297 static inline void scmi_driver_unregister(struct scmi_driver *driver) {}
298 #endif
299
300 #define scmi_register(driver) \
301 scmi_driver_register(driver, THIS_MODULE, KBUILD_MODNAME)
302 #define scmi_unregister(driver) \
303 scmi_driver_unregister(driver)
304
305
306
307
308
309
310
311
312
313 #define module_scmi_driver(__scmi_driver) \
314 module_driver(__scmi_driver, scmi_register, scmi_unregister)
315
316 typedef int (*scmi_prot_init_fn_t)(struct scmi_handle *);
317 int scmi_protocol_register(int protocol_id, scmi_prot_init_fn_t fn);
318 void scmi_protocol_unregister(int protocol_id);