.. | .. |
---|
2 | 2 | /* |
---|
3 | 3 | * System Control and Management Interface (SCMI) Performance Protocol |
---|
4 | 4 | * |
---|
5 | | - * Copyright (C) 2018 ARM Ltd. |
---|
| 5 | + * Copyright (C) 2018-2020 ARM Ltd. |
---|
6 | 6 | */ |
---|
7 | 7 | |
---|
| 8 | +#define pr_fmt(fmt) "SCMI Notifications PERF - " fmt |
---|
| 9 | + |
---|
| 10 | +#include <linux/bits.h> |
---|
8 | 11 | #include <linux/of.h> |
---|
| 12 | +#include <linux/io.h> |
---|
| 13 | +#include <linux/io-64-nonatomic-hi-lo.h> |
---|
| 14 | +#include <linux/module.h> |
---|
9 | 15 | #include <linux/platform_device.h> |
---|
10 | 16 | #include <linux/pm_opp.h> |
---|
| 17 | +#include <linux/scmi_protocol.h> |
---|
11 | 18 | #include <linux/sort.h> |
---|
12 | 19 | |
---|
13 | 20 | #include "common.h" |
---|
| 21 | +#include "notify.h" |
---|
14 | 22 | |
---|
15 | 23 | enum scmi_performance_protocol_cmd { |
---|
16 | 24 | PERF_DOMAIN_ATTRIBUTES = 0x3, |
---|
.. | .. |
---|
21 | 29 | PERF_LEVEL_GET = 0x8, |
---|
22 | 30 | PERF_NOTIFY_LIMITS = 0x9, |
---|
23 | 31 | PERF_NOTIFY_LEVEL = 0xa, |
---|
| 32 | + PERF_DESCRIBE_FASTCHANNEL = 0xb, |
---|
24 | 33 | }; |
---|
25 | 34 | |
---|
26 | 35 | struct scmi_opp { |
---|
.. | .. |
---|
44 | 53 | #define SUPPORTS_SET_PERF_LVL(x) ((x) & BIT(30)) |
---|
45 | 54 | #define SUPPORTS_PERF_LIMIT_NOTIFY(x) ((x) & BIT(29)) |
---|
46 | 55 | #define SUPPORTS_PERF_LEVEL_NOTIFY(x) ((x) & BIT(28)) |
---|
| 56 | +#define SUPPORTS_PERF_FASTCHANNELS(x) ((x) & BIT(27)) |
---|
47 | 57 | __le32 rate_limit_us; |
---|
48 | 58 | __le32 sustained_freq_khz; |
---|
49 | 59 | __le32 sustained_perf_level; |
---|
.. | .. |
---|
76 | 86 | __le32 notify_enable; |
---|
77 | 87 | }; |
---|
78 | 88 | |
---|
| 89 | +struct scmi_perf_limits_notify_payld { |
---|
| 90 | + __le32 agent_id; |
---|
| 91 | + __le32 domain_id; |
---|
| 92 | + __le32 range_max; |
---|
| 93 | + __le32 range_min; |
---|
| 94 | +}; |
---|
| 95 | + |
---|
| 96 | +struct scmi_perf_level_notify_payld { |
---|
| 97 | + __le32 agent_id; |
---|
| 98 | + __le32 domain_id; |
---|
| 99 | + __le32 performance_level; |
---|
| 100 | +}; |
---|
| 101 | + |
---|
79 | 102 | struct scmi_msg_resp_perf_describe_levels { |
---|
80 | 103 | __le16 num_returned; |
---|
81 | 104 | __le16 num_remaining; |
---|
.. | .. |
---|
84 | 107 | __le32 power; |
---|
85 | 108 | __le16 transition_latency_us; |
---|
86 | 109 | __le16 reserved; |
---|
87 | | - } opp[0]; |
---|
| 110 | + } opp[]; |
---|
| 111 | +}; |
---|
| 112 | + |
---|
| 113 | +struct scmi_perf_get_fc_info { |
---|
| 114 | + __le32 domain; |
---|
| 115 | + __le32 message_id; |
---|
| 116 | +}; |
---|
| 117 | + |
---|
| 118 | +struct scmi_msg_resp_perf_desc_fc { |
---|
| 119 | + __le32 attr; |
---|
| 120 | +#define SUPPORTS_DOORBELL(x) ((x) & BIT(0)) |
---|
| 121 | +#define DOORBELL_REG_WIDTH(x) FIELD_GET(GENMASK(2, 1), (x)) |
---|
| 122 | + __le32 rate_limit; |
---|
| 123 | + __le32 chan_addr_low; |
---|
| 124 | + __le32 chan_addr_high; |
---|
| 125 | + __le32 chan_size; |
---|
| 126 | + __le32 db_addr_low; |
---|
| 127 | + __le32 db_addr_high; |
---|
| 128 | + __le32 db_set_lmask; |
---|
| 129 | + __le32 db_set_hmask; |
---|
| 130 | + __le32 db_preserve_lmask; |
---|
| 131 | + __le32 db_preserve_hmask; |
---|
| 132 | +}; |
---|
| 133 | + |
---|
| 134 | +struct scmi_fc_db_info { |
---|
| 135 | + int width; |
---|
| 136 | + u64 set; |
---|
| 137 | + u64 mask; |
---|
| 138 | + void __iomem *addr; |
---|
| 139 | +}; |
---|
| 140 | + |
---|
| 141 | +struct scmi_fc_info { |
---|
| 142 | + void __iomem *level_set_addr; |
---|
| 143 | + void __iomem *limit_set_addr; |
---|
| 144 | + void __iomem *level_get_addr; |
---|
| 145 | + void __iomem *limit_get_addr; |
---|
| 146 | + struct scmi_fc_db_info *level_set_db; |
---|
| 147 | + struct scmi_fc_db_info *limit_set_db; |
---|
88 | 148 | }; |
---|
89 | 149 | |
---|
90 | 150 | struct perf_dom_info { |
---|
.. | .. |
---|
92 | 152 | bool set_perf; |
---|
93 | 153 | bool perf_limit_notify; |
---|
94 | 154 | bool perf_level_notify; |
---|
| 155 | + bool perf_fastchannels; |
---|
95 | 156 | u32 opp_count; |
---|
96 | 157 | u32 sustained_freq_khz; |
---|
97 | 158 | u32 sustained_perf_level; |
---|
98 | 159 | u32 mult_factor; |
---|
99 | 160 | char name[SCMI_MAX_STR_SIZE]; |
---|
100 | 161 | struct scmi_opp opp[MAX_OPPS]; |
---|
| 162 | + struct scmi_fc_info *fc_info; |
---|
101 | 163 | }; |
---|
102 | 164 | |
---|
103 | 165 | struct scmi_perf_info { |
---|
.. | .. |
---|
109 | 171 | struct perf_dom_info *dom_info; |
---|
110 | 172 | }; |
---|
111 | 173 | |
---|
112 | | -static int scmi_perf_attributes_get(const struct scmi_handle *handle, |
---|
| 174 | +static enum scmi_performance_protocol_cmd evt_2_cmd[] = { |
---|
| 175 | + PERF_NOTIFY_LIMITS, |
---|
| 176 | + PERF_NOTIFY_LEVEL, |
---|
| 177 | +}; |
---|
| 178 | + |
---|
| 179 | +static int scmi_perf_attributes_get(const struct scmi_protocol_handle *ph, |
---|
113 | 180 | struct scmi_perf_info *pi) |
---|
114 | 181 | { |
---|
115 | 182 | int ret; |
---|
116 | 183 | struct scmi_xfer *t; |
---|
117 | 184 | struct scmi_msg_resp_perf_attributes *attr; |
---|
118 | 185 | |
---|
119 | | - ret = scmi_xfer_get_init(handle, PROTOCOL_ATTRIBUTES, |
---|
120 | | - SCMI_PROTOCOL_PERF, 0, sizeof(*attr), &t); |
---|
| 186 | + ret = ph->xops->xfer_get_init(ph, PROTOCOL_ATTRIBUTES, 0, |
---|
| 187 | + sizeof(*attr), &t); |
---|
121 | 188 | if (ret) |
---|
122 | 189 | return ret; |
---|
123 | 190 | |
---|
124 | 191 | attr = t->rx.buf; |
---|
125 | 192 | |
---|
126 | | - ret = scmi_do_xfer(handle, t); |
---|
| 193 | + ret = ph->xops->do_xfer(ph, t); |
---|
127 | 194 | if (!ret) { |
---|
128 | 195 | u16 flags = le16_to_cpu(attr->flags); |
---|
129 | 196 | |
---|
.. | .. |
---|
134 | 201 | pi->stats_size = le32_to_cpu(attr->stats_size); |
---|
135 | 202 | } |
---|
136 | 203 | |
---|
137 | | - scmi_xfer_put(handle, t); |
---|
| 204 | + ph->xops->xfer_put(ph, t); |
---|
138 | 205 | return ret; |
---|
139 | 206 | } |
---|
140 | 207 | |
---|
141 | 208 | static int |
---|
142 | | -scmi_perf_domain_attributes_get(const struct scmi_handle *handle, u32 domain, |
---|
143 | | - struct perf_dom_info *dom_info) |
---|
| 209 | +scmi_perf_domain_attributes_get(const struct scmi_protocol_handle *ph, |
---|
| 210 | + u32 domain, struct perf_dom_info *dom_info) |
---|
144 | 211 | { |
---|
145 | 212 | int ret; |
---|
146 | 213 | struct scmi_xfer *t; |
---|
147 | 214 | struct scmi_msg_resp_perf_domain_attributes *attr; |
---|
148 | 215 | |
---|
149 | | - ret = scmi_xfer_get_init(handle, PERF_DOMAIN_ATTRIBUTES, |
---|
150 | | - SCMI_PROTOCOL_PERF, sizeof(domain), |
---|
151 | | - sizeof(*attr), &t); |
---|
| 216 | + ret = ph->xops->xfer_get_init(ph, PERF_DOMAIN_ATTRIBUTES, |
---|
| 217 | + sizeof(domain), sizeof(*attr), &t); |
---|
152 | 218 | if (ret) |
---|
153 | 219 | return ret; |
---|
154 | 220 | |
---|
155 | 221 | put_unaligned_le32(domain, t->tx.buf); |
---|
156 | 222 | attr = t->rx.buf; |
---|
157 | 223 | |
---|
158 | | - ret = scmi_do_xfer(handle, t); |
---|
| 224 | + ret = ph->xops->do_xfer(ph, t); |
---|
159 | 225 | if (!ret) { |
---|
160 | 226 | u32 flags = le32_to_cpu(attr->flags); |
---|
161 | 227 | |
---|
.. | .. |
---|
163 | 229 | dom_info->set_perf = SUPPORTS_SET_PERF_LVL(flags); |
---|
164 | 230 | dom_info->perf_limit_notify = SUPPORTS_PERF_LIMIT_NOTIFY(flags); |
---|
165 | 231 | dom_info->perf_level_notify = SUPPORTS_PERF_LEVEL_NOTIFY(flags); |
---|
| 232 | + dom_info->perf_fastchannels = SUPPORTS_PERF_FASTCHANNELS(flags); |
---|
166 | 233 | dom_info->sustained_freq_khz = |
---|
167 | 234 | le32_to_cpu(attr->sustained_freq_khz); |
---|
168 | 235 | dom_info->sustained_perf_level = |
---|
.. | .. |
---|
178 | 245 | strlcpy(dom_info->name, attr->name, SCMI_MAX_STR_SIZE); |
---|
179 | 246 | } |
---|
180 | 247 | |
---|
181 | | - scmi_xfer_put(handle, t); |
---|
| 248 | + ph->xops->xfer_put(ph, t); |
---|
182 | 249 | return ret; |
---|
183 | 250 | } |
---|
184 | 251 | |
---|
.. | .. |
---|
190 | 257 | } |
---|
191 | 258 | |
---|
192 | 259 | static int |
---|
193 | | -scmi_perf_describe_levels_get(const struct scmi_handle *handle, u32 domain, |
---|
| 260 | +scmi_perf_describe_levels_get(const struct scmi_protocol_handle *ph, u32 domain, |
---|
194 | 261 | struct perf_dom_info *perf_dom) |
---|
195 | 262 | { |
---|
196 | 263 | int ret, cnt; |
---|
.. | .. |
---|
201 | 268 | struct scmi_msg_perf_describe_levels *dom_info; |
---|
202 | 269 | struct scmi_msg_resp_perf_describe_levels *level_info; |
---|
203 | 270 | |
---|
204 | | - ret = scmi_xfer_get_init(handle, PERF_DESCRIBE_LEVELS, |
---|
205 | | - SCMI_PROTOCOL_PERF, sizeof(*dom_info), 0, &t); |
---|
| 271 | + ret = ph->xops->xfer_get_init(ph, PERF_DESCRIBE_LEVELS, |
---|
| 272 | + sizeof(*dom_info), 0, &t); |
---|
206 | 273 | if (ret) |
---|
207 | 274 | return ret; |
---|
208 | 275 | |
---|
.. | .. |
---|
214 | 281 | /* Set the number of OPPs to be skipped/already read */ |
---|
215 | 282 | dom_info->level_index = cpu_to_le32(tot_opp_cnt); |
---|
216 | 283 | |
---|
217 | | - ret = scmi_do_xfer(handle, t); |
---|
| 284 | + ret = ph->xops->do_xfer(ph, t); |
---|
218 | 285 | if (ret) |
---|
219 | 286 | break; |
---|
220 | 287 | |
---|
221 | 288 | num_returned = le16_to_cpu(level_info->num_returned); |
---|
222 | 289 | num_remaining = le16_to_cpu(level_info->num_remaining); |
---|
223 | 290 | if (tot_opp_cnt + num_returned > MAX_OPPS) { |
---|
224 | | - dev_err(handle->dev, "No. of OPPs exceeded MAX_OPPS"); |
---|
| 291 | + dev_err(ph->dev, "No. of OPPs exceeded MAX_OPPS"); |
---|
225 | 292 | break; |
---|
226 | 293 | } |
---|
227 | 294 | |
---|
.. | .. |
---|
232 | 299 | opp->trans_latency_us = le16_to_cpu |
---|
233 | 300 | (level_info->opp[cnt].transition_latency_us); |
---|
234 | 301 | |
---|
235 | | - dev_dbg(handle->dev, "Level %d Power %d Latency %dus\n", |
---|
| 302 | + dev_dbg(ph->dev, "Level %d Power %d Latency %dus\n", |
---|
236 | 303 | opp->perf, opp->power, opp->trans_latency_us); |
---|
237 | 304 | } |
---|
238 | 305 | |
---|
239 | 306 | tot_opp_cnt += num_returned; |
---|
| 307 | + |
---|
| 308 | + ph->xops->reset_rx_to_maxsz(ph, t); |
---|
240 | 309 | /* |
---|
241 | 310 | * check for both returned and remaining to avoid infinite |
---|
242 | 311 | * loop due to buggy firmware |
---|
.. | .. |
---|
244 | 313 | } while (num_returned && num_remaining); |
---|
245 | 314 | |
---|
246 | 315 | perf_dom->opp_count = tot_opp_cnt; |
---|
247 | | - scmi_xfer_put(handle, t); |
---|
| 316 | + ph->xops->xfer_put(ph, t); |
---|
248 | 317 | |
---|
249 | 318 | sort(perf_dom->opp, tot_opp_cnt, sizeof(*opp), opp_cmp_func, NULL); |
---|
250 | 319 | return ret; |
---|
251 | 320 | } |
---|
252 | 321 | |
---|
253 | | -static int scmi_perf_limits_set(const struct scmi_handle *handle, u32 domain, |
---|
254 | | - u32 max_perf, u32 min_perf) |
---|
| 322 | +#define SCMI_PERF_FC_RING_DB(w) \ |
---|
| 323 | +do { \ |
---|
| 324 | + u##w val = 0; \ |
---|
| 325 | + \ |
---|
| 326 | + if (db->mask) \ |
---|
| 327 | + val = ioread##w(db->addr) & db->mask; \ |
---|
| 328 | + iowrite##w((u##w)db->set | val, db->addr); \ |
---|
| 329 | +} while (0) |
---|
| 330 | + |
---|
| 331 | +static void scmi_perf_fc_ring_db(struct scmi_fc_db_info *db) |
---|
| 332 | +{ |
---|
| 333 | + if (!db || !db->addr) |
---|
| 334 | + return; |
---|
| 335 | + |
---|
| 336 | + if (db->width == 1) |
---|
| 337 | + SCMI_PERF_FC_RING_DB(8); |
---|
| 338 | + else if (db->width == 2) |
---|
| 339 | + SCMI_PERF_FC_RING_DB(16); |
---|
| 340 | + else if (db->width == 4) |
---|
| 341 | + SCMI_PERF_FC_RING_DB(32); |
---|
| 342 | + else /* db->width == 8 */ |
---|
| 343 | +#ifdef CONFIG_64BIT |
---|
| 344 | + SCMI_PERF_FC_RING_DB(64); |
---|
| 345 | +#else |
---|
| 346 | + { |
---|
| 347 | + u64 val = 0; |
---|
| 348 | + |
---|
| 349 | + if (db->mask) |
---|
| 350 | + val = ioread64_hi_lo(db->addr) & db->mask; |
---|
| 351 | + iowrite64_hi_lo(db->set | val, db->addr); |
---|
| 352 | + } |
---|
| 353 | +#endif |
---|
| 354 | +} |
---|
| 355 | + |
---|
| 356 | +static int scmi_perf_mb_limits_set(const struct scmi_protocol_handle *ph, |
---|
| 357 | + u32 domain, u32 max_perf, u32 min_perf) |
---|
255 | 358 | { |
---|
256 | 359 | int ret; |
---|
257 | 360 | struct scmi_xfer *t; |
---|
258 | 361 | struct scmi_perf_set_limits *limits; |
---|
259 | 362 | |
---|
260 | | - ret = scmi_xfer_get_init(handle, PERF_LIMITS_SET, SCMI_PROTOCOL_PERF, |
---|
261 | | - sizeof(*limits), 0, &t); |
---|
| 363 | + ret = ph->xops->xfer_get_init(ph, PERF_LIMITS_SET, |
---|
| 364 | + sizeof(*limits), 0, &t); |
---|
262 | 365 | if (ret) |
---|
263 | 366 | return ret; |
---|
264 | 367 | |
---|
.. | .. |
---|
267 | 370 | limits->max_level = cpu_to_le32(max_perf); |
---|
268 | 371 | limits->min_level = cpu_to_le32(min_perf); |
---|
269 | 372 | |
---|
270 | | - ret = scmi_do_xfer(handle, t); |
---|
| 373 | + ret = ph->xops->do_xfer(ph, t); |
---|
271 | 374 | |
---|
272 | | - scmi_xfer_put(handle, t); |
---|
| 375 | + ph->xops->xfer_put(ph, t); |
---|
273 | 376 | return ret; |
---|
274 | 377 | } |
---|
275 | 378 | |
---|
276 | | -static int scmi_perf_limits_get(const struct scmi_handle *handle, u32 domain, |
---|
277 | | - u32 *max_perf, u32 *min_perf) |
---|
| 379 | +static int scmi_perf_limits_set(const struct scmi_protocol_handle *ph, |
---|
| 380 | + u32 domain, u32 max_perf, u32 min_perf) |
---|
| 381 | +{ |
---|
| 382 | + struct scmi_perf_info *pi = ph->get_priv(ph); |
---|
| 383 | + struct perf_dom_info *dom = pi->dom_info + domain; |
---|
| 384 | + |
---|
| 385 | + if (dom->fc_info && dom->fc_info->limit_set_addr) { |
---|
| 386 | + iowrite32(max_perf, dom->fc_info->limit_set_addr); |
---|
| 387 | + iowrite32(min_perf, dom->fc_info->limit_set_addr + 4); |
---|
| 388 | + scmi_perf_fc_ring_db(dom->fc_info->limit_set_db); |
---|
| 389 | + return 0; |
---|
| 390 | + } |
---|
| 391 | + |
---|
| 392 | + return scmi_perf_mb_limits_set(ph, domain, max_perf, min_perf); |
---|
| 393 | +} |
---|
| 394 | + |
---|
| 395 | +static int scmi_perf_mb_limits_get(const struct scmi_protocol_handle *ph, |
---|
| 396 | + u32 domain, u32 *max_perf, u32 *min_perf) |
---|
278 | 397 | { |
---|
279 | 398 | int ret; |
---|
280 | 399 | struct scmi_xfer *t; |
---|
281 | 400 | struct scmi_perf_get_limits *limits; |
---|
282 | 401 | |
---|
283 | | - ret = scmi_xfer_get_init(handle, PERF_LIMITS_GET, SCMI_PROTOCOL_PERF, |
---|
284 | | - sizeof(__le32), 0, &t); |
---|
| 402 | + ret = ph->xops->xfer_get_init(ph, PERF_LIMITS_GET, |
---|
| 403 | + sizeof(__le32), 0, &t); |
---|
285 | 404 | if (ret) |
---|
286 | 405 | return ret; |
---|
287 | 406 | |
---|
288 | 407 | put_unaligned_le32(domain, t->tx.buf); |
---|
289 | 408 | |
---|
290 | | - ret = scmi_do_xfer(handle, t); |
---|
| 409 | + ret = ph->xops->do_xfer(ph, t); |
---|
291 | 410 | if (!ret) { |
---|
292 | 411 | limits = t->rx.buf; |
---|
293 | 412 | |
---|
.. | .. |
---|
295 | 414 | *min_perf = le32_to_cpu(limits->min_level); |
---|
296 | 415 | } |
---|
297 | 416 | |
---|
298 | | - scmi_xfer_put(handle, t); |
---|
| 417 | + ph->xops->xfer_put(ph, t); |
---|
299 | 418 | return ret; |
---|
300 | 419 | } |
---|
301 | 420 | |
---|
302 | | -static int scmi_perf_level_set(const struct scmi_handle *handle, u32 domain, |
---|
303 | | - u32 level, bool poll) |
---|
| 421 | +static int scmi_perf_limits_get(const struct scmi_protocol_handle *ph, |
---|
| 422 | + u32 domain, u32 *max_perf, u32 *min_perf) |
---|
| 423 | +{ |
---|
| 424 | + struct scmi_perf_info *pi = ph->get_priv(ph); |
---|
| 425 | + struct perf_dom_info *dom = pi->dom_info + domain; |
---|
| 426 | + |
---|
| 427 | + if (dom->fc_info && dom->fc_info->limit_get_addr) { |
---|
| 428 | + *max_perf = ioread32(dom->fc_info->limit_get_addr); |
---|
| 429 | + *min_perf = ioread32(dom->fc_info->limit_get_addr + 4); |
---|
| 430 | + return 0; |
---|
| 431 | + } |
---|
| 432 | + |
---|
| 433 | + return scmi_perf_mb_limits_get(ph, domain, max_perf, min_perf); |
---|
| 434 | +} |
---|
| 435 | + |
---|
| 436 | +static int scmi_perf_mb_level_set(const struct scmi_protocol_handle *ph, |
---|
| 437 | + u32 domain, u32 level, bool poll) |
---|
304 | 438 | { |
---|
305 | 439 | int ret; |
---|
306 | 440 | struct scmi_xfer *t; |
---|
307 | 441 | struct scmi_perf_set_level *lvl; |
---|
308 | 442 | |
---|
309 | | - ret = scmi_xfer_get_init(handle, PERF_LEVEL_SET, SCMI_PROTOCOL_PERF, |
---|
310 | | - sizeof(*lvl), 0, &t); |
---|
| 443 | + ret = ph->xops->xfer_get_init(ph, PERF_LEVEL_SET, sizeof(*lvl), 0, &t); |
---|
311 | 444 | if (ret) |
---|
312 | 445 | return ret; |
---|
313 | 446 | |
---|
.. | .. |
---|
316 | 449 | lvl->domain = cpu_to_le32(domain); |
---|
317 | 450 | lvl->level = cpu_to_le32(level); |
---|
318 | 451 | |
---|
319 | | - ret = scmi_do_xfer(handle, t); |
---|
| 452 | + ret = ph->xops->do_xfer(ph, t); |
---|
320 | 453 | |
---|
321 | | - scmi_xfer_put(handle, t); |
---|
| 454 | + ph->xops->xfer_put(ph, t); |
---|
322 | 455 | return ret; |
---|
323 | 456 | } |
---|
324 | 457 | |
---|
325 | | -static int scmi_perf_level_get(const struct scmi_handle *handle, u32 domain, |
---|
326 | | - u32 *level, bool poll) |
---|
| 458 | +static int scmi_perf_level_set(const struct scmi_protocol_handle *ph, |
---|
| 459 | + u32 domain, u32 level, bool poll) |
---|
| 460 | +{ |
---|
| 461 | + struct scmi_perf_info *pi = ph->get_priv(ph); |
---|
| 462 | + struct perf_dom_info *dom = pi->dom_info + domain; |
---|
| 463 | + |
---|
| 464 | + if (dom->fc_info && dom->fc_info->level_set_addr) { |
---|
| 465 | + iowrite32(level, dom->fc_info->level_set_addr); |
---|
| 466 | + scmi_perf_fc_ring_db(dom->fc_info->level_set_db); |
---|
| 467 | + return 0; |
---|
| 468 | + } |
---|
| 469 | + |
---|
| 470 | + return scmi_perf_mb_level_set(ph, domain, level, poll); |
---|
| 471 | +} |
---|
| 472 | + |
---|
| 473 | +static int scmi_perf_mb_level_get(const struct scmi_protocol_handle *ph, |
---|
| 474 | + u32 domain, u32 *level, bool poll) |
---|
327 | 475 | { |
---|
328 | 476 | int ret; |
---|
329 | 477 | struct scmi_xfer *t; |
---|
330 | 478 | |
---|
331 | | - ret = scmi_xfer_get_init(handle, PERF_LEVEL_GET, SCMI_PROTOCOL_PERF, |
---|
332 | | - sizeof(u32), sizeof(u32), &t); |
---|
| 479 | + ret = ph->xops->xfer_get_init(ph, PERF_LEVEL_GET, |
---|
| 480 | + sizeof(u32), sizeof(u32), &t); |
---|
333 | 481 | if (ret) |
---|
334 | 482 | return ret; |
---|
335 | 483 | |
---|
336 | 484 | t->hdr.poll_completion = poll; |
---|
337 | 485 | put_unaligned_le32(domain, t->tx.buf); |
---|
338 | 486 | |
---|
339 | | - ret = scmi_do_xfer(handle, t); |
---|
| 487 | + ret = ph->xops->do_xfer(ph, t); |
---|
340 | 488 | if (!ret) |
---|
341 | 489 | *level = get_unaligned_le32(t->rx.buf); |
---|
342 | 490 | |
---|
343 | | - scmi_xfer_put(handle, t); |
---|
| 491 | + ph->xops->xfer_put(ph, t); |
---|
344 | 492 | return ret; |
---|
| 493 | +} |
---|
| 494 | + |
---|
| 495 | +static int scmi_perf_level_get(const struct scmi_protocol_handle *ph, |
---|
| 496 | + u32 domain, u32 *level, bool poll) |
---|
| 497 | +{ |
---|
| 498 | + struct scmi_perf_info *pi = ph->get_priv(ph); |
---|
| 499 | + struct perf_dom_info *dom = pi->dom_info + domain; |
---|
| 500 | + |
---|
| 501 | + if (dom->fc_info && dom->fc_info->level_get_addr) { |
---|
| 502 | + *level = ioread32(dom->fc_info->level_get_addr); |
---|
| 503 | + return 0; |
---|
| 504 | + } |
---|
| 505 | + |
---|
| 506 | + return scmi_perf_mb_level_get(ph, domain, level, poll); |
---|
| 507 | +} |
---|
| 508 | + |
---|
| 509 | +static int scmi_perf_level_limits_notify(const struct scmi_protocol_handle *ph, |
---|
| 510 | + u32 domain, int message_id, |
---|
| 511 | + bool enable) |
---|
| 512 | +{ |
---|
| 513 | + int ret; |
---|
| 514 | + struct scmi_xfer *t; |
---|
| 515 | + struct scmi_perf_notify_level_or_limits *notify; |
---|
| 516 | + |
---|
| 517 | + ret = ph->xops->xfer_get_init(ph, message_id, sizeof(*notify), 0, &t); |
---|
| 518 | + if (ret) |
---|
| 519 | + return ret; |
---|
| 520 | + |
---|
| 521 | + notify = t->tx.buf; |
---|
| 522 | + notify->domain = cpu_to_le32(domain); |
---|
| 523 | + notify->notify_enable = enable ? cpu_to_le32(BIT(0)) : 0; |
---|
| 524 | + |
---|
| 525 | + ret = ph->xops->do_xfer(ph, t); |
---|
| 526 | + |
---|
| 527 | + ph->xops->xfer_put(ph, t); |
---|
| 528 | + return ret; |
---|
| 529 | +} |
---|
| 530 | + |
---|
| 531 | +static bool scmi_perf_fc_size_is_valid(u32 msg, u32 size) |
---|
| 532 | +{ |
---|
| 533 | + if ((msg == PERF_LEVEL_GET || msg == PERF_LEVEL_SET) && size == 4) |
---|
| 534 | + return true; |
---|
| 535 | + if ((msg == PERF_LIMITS_GET || msg == PERF_LIMITS_SET) && size == 8) |
---|
| 536 | + return true; |
---|
| 537 | + return false; |
---|
| 538 | +} |
---|
| 539 | + |
---|
| 540 | +static void |
---|
| 541 | +scmi_perf_domain_desc_fc(const struct scmi_protocol_handle *ph, u32 domain, |
---|
| 542 | + u32 message_id, void __iomem **p_addr, |
---|
| 543 | + struct scmi_fc_db_info **p_db) |
---|
| 544 | +{ |
---|
| 545 | + int ret; |
---|
| 546 | + u32 flags; |
---|
| 547 | + u64 phys_addr; |
---|
| 548 | + u8 size; |
---|
| 549 | + void __iomem *addr; |
---|
| 550 | + struct scmi_xfer *t; |
---|
| 551 | + struct scmi_fc_db_info *db; |
---|
| 552 | + struct scmi_perf_get_fc_info *info; |
---|
| 553 | + struct scmi_msg_resp_perf_desc_fc *resp; |
---|
| 554 | + |
---|
| 555 | + if (!p_addr) |
---|
| 556 | + return; |
---|
| 557 | + |
---|
| 558 | + ret = ph->xops->xfer_get_init(ph, PERF_DESCRIBE_FASTCHANNEL, |
---|
| 559 | + sizeof(*info), sizeof(*resp), &t); |
---|
| 560 | + if (ret) |
---|
| 561 | + return; |
---|
| 562 | + |
---|
| 563 | + info = t->tx.buf; |
---|
| 564 | + info->domain = cpu_to_le32(domain); |
---|
| 565 | + info->message_id = cpu_to_le32(message_id); |
---|
| 566 | + |
---|
| 567 | + ret = ph->xops->do_xfer(ph, t); |
---|
| 568 | + if (ret) |
---|
| 569 | + goto err_xfer; |
---|
| 570 | + |
---|
| 571 | + resp = t->rx.buf; |
---|
| 572 | + flags = le32_to_cpu(resp->attr); |
---|
| 573 | + size = le32_to_cpu(resp->chan_size); |
---|
| 574 | + if (!scmi_perf_fc_size_is_valid(message_id, size)) |
---|
| 575 | + goto err_xfer; |
---|
| 576 | + |
---|
| 577 | + phys_addr = le32_to_cpu(resp->chan_addr_low); |
---|
| 578 | + phys_addr |= (u64)le32_to_cpu(resp->chan_addr_high) << 32; |
---|
| 579 | + addr = devm_ioremap(ph->dev, phys_addr, size); |
---|
| 580 | + if (!addr) |
---|
| 581 | + goto err_xfer; |
---|
| 582 | + *p_addr = addr; |
---|
| 583 | + |
---|
| 584 | + if (p_db && SUPPORTS_DOORBELL(flags)) { |
---|
| 585 | + db = devm_kzalloc(ph->dev, sizeof(*db), GFP_KERNEL); |
---|
| 586 | + if (!db) |
---|
| 587 | + goto err_xfer; |
---|
| 588 | + |
---|
| 589 | + size = 1 << DOORBELL_REG_WIDTH(flags); |
---|
| 590 | + phys_addr = le32_to_cpu(resp->db_addr_low); |
---|
| 591 | + phys_addr |= (u64)le32_to_cpu(resp->db_addr_high) << 32; |
---|
| 592 | + addr = devm_ioremap(ph->dev, phys_addr, size); |
---|
| 593 | + if (!addr) |
---|
| 594 | + goto err_xfer; |
---|
| 595 | + |
---|
| 596 | + db->addr = addr; |
---|
| 597 | + db->width = size; |
---|
| 598 | + db->set = le32_to_cpu(resp->db_set_lmask); |
---|
| 599 | + db->set |= (u64)le32_to_cpu(resp->db_set_hmask) << 32; |
---|
| 600 | + db->mask = le32_to_cpu(resp->db_preserve_lmask); |
---|
| 601 | + db->mask |= (u64)le32_to_cpu(resp->db_preserve_hmask) << 32; |
---|
| 602 | + *p_db = db; |
---|
| 603 | + } |
---|
| 604 | +err_xfer: |
---|
| 605 | + ph->xops->xfer_put(ph, t); |
---|
| 606 | +} |
---|
| 607 | + |
---|
| 608 | +static void scmi_perf_domain_init_fc(const struct scmi_protocol_handle *ph, |
---|
| 609 | + u32 domain, struct scmi_fc_info **p_fc) |
---|
| 610 | +{ |
---|
| 611 | + struct scmi_fc_info *fc; |
---|
| 612 | + |
---|
| 613 | + fc = devm_kzalloc(ph->dev, sizeof(*fc), GFP_KERNEL); |
---|
| 614 | + if (!fc) |
---|
| 615 | + return; |
---|
| 616 | + |
---|
| 617 | + scmi_perf_domain_desc_fc(ph, domain, PERF_LEVEL_SET, |
---|
| 618 | + &fc->level_set_addr, &fc->level_set_db); |
---|
| 619 | + scmi_perf_domain_desc_fc(ph, domain, PERF_LEVEL_GET, |
---|
| 620 | + &fc->level_get_addr, NULL); |
---|
| 621 | + scmi_perf_domain_desc_fc(ph, domain, PERF_LIMITS_SET, |
---|
| 622 | + &fc->limit_set_addr, &fc->limit_set_db); |
---|
| 623 | + scmi_perf_domain_desc_fc(ph, domain, PERF_LIMITS_GET, |
---|
| 624 | + &fc->limit_get_addr, NULL); |
---|
| 625 | + *p_fc = fc; |
---|
345 | 626 | } |
---|
346 | 627 | |
---|
347 | 628 | /* Device specific ops */ |
---|
.. | .. |
---|
356 | 637 | return clkspec.args[0]; |
---|
357 | 638 | } |
---|
358 | 639 | |
---|
359 | | -static int scmi_dvfs_device_opps_add(const struct scmi_handle *handle, |
---|
| 640 | +static int scmi_dvfs_device_opps_add(const struct scmi_protocol_handle *ph, |
---|
360 | 641 | struct device *dev) |
---|
361 | 642 | { |
---|
362 | 643 | int idx, ret, domain; |
---|
363 | 644 | unsigned long freq; |
---|
364 | 645 | struct scmi_opp *opp; |
---|
365 | 646 | struct perf_dom_info *dom; |
---|
366 | | - struct scmi_perf_info *pi = handle->perf_priv; |
---|
| 647 | + struct scmi_perf_info *pi = ph->get_priv(ph); |
---|
367 | 648 | |
---|
368 | 649 | domain = scmi_dev_domain_id(dev); |
---|
369 | 650 | if (domain < 0) |
---|
.. | .. |
---|
388 | 669 | return 0; |
---|
389 | 670 | } |
---|
390 | 671 | |
---|
391 | | -static int scmi_dvfs_transition_latency_get(const struct scmi_handle *handle, |
---|
392 | | - struct device *dev) |
---|
| 672 | +static int |
---|
| 673 | +scmi_dvfs_transition_latency_get(const struct scmi_protocol_handle *ph, |
---|
| 674 | + struct device *dev) |
---|
393 | 675 | { |
---|
394 | 676 | struct perf_dom_info *dom; |
---|
395 | | - struct scmi_perf_info *pi = handle->perf_priv; |
---|
| 677 | + struct scmi_perf_info *pi = ph->get_priv(ph); |
---|
396 | 678 | int domain = scmi_dev_domain_id(dev); |
---|
397 | 679 | |
---|
398 | 680 | if (domain < 0) |
---|
.. | .. |
---|
403 | 685 | return dom->opp[dom->opp_count - 1].trans_latency_us * 1000; |
---|
404 | 686 | } |
---|
405 | 687 | |
---|
406 | | -static int scmi_dvfs_freq_set(const struct scmi_handle *handle, u32 domain, |
---|
| 688 | +static int scmi_dvfs_freq_set(const struct scmi_protocol_handle *ph, u32 domain, |
---|
407 | 689 | unsigned long freq, bool poll) |
---|
408 | 690 | { |
---|
409 | | - struct scmi_perf_info *pi = handle->perf_priv; |
---|
| 691 | + struct scmi_perf_info *pi = ph->get_priv(ph); |
---|
410 | 692 | struct perf_dom_info *dom = pi->dom_info + domain; |
---|
411 | 693 | |
---|
412 | | - return scmi_perf_level_set(handle, domain, freq / dom->mult_factor, |
---|
413 | | - poll); |
---|
| 694 | + return scmi_perf_level_set(ph, domain, freq / dom->mult_factor, poll); |
---|
414 | 695 | } |
---|
415 | 696 | |
---|
416 | | -static int scmi_dvfs_freq_get(const struct scmi_handle *handle, u32 domain, |
---|
| 697 | +static int scmi_dvfs_freq_get(const struct scmi_protocol_handle *ph, u32 domain, |
---|
417 | 698 | unsigned long *freq, bool poll) |
---|
418 | 699 | { |
---|
419 | 700 | int ret; |
---|
420 | 701 | u32 level; |
---|
421 | | - struct scmi_perf_info *pi = handle->perf_priv; |
---|
| 702 | + struct scmi_perf_info *pi = ph->get_priv(ph); |
---|
422 | 703 | struct perf_dom_info *dom = pi->dom_info + domain; |
---|
423 | 704 | |
---|
424 | | - ret = scmi_perf_level_get(handle, domain, &level, poll); |
---|
| 705 | + ret = scmi_perf_level_get(ph, domain, &level, poll); |
---|
425 | 706 | if (!ret) |
---|
426 | 707 | *freq = level * dom->mult_factor; |
---|
427 | 708 | |
---|
428 | 709 | return ret; |
---|
429 | 710 | } |
---|
430 | 711 | |
---|
431 | | -static int scmi_dvfs_est_power_get(const struct scmi_handle *handle, u32 domain, |
---|
432 | | - unsigned long *freq, unsigned long *power) |
---|
| 712 | +static int scmi_dvfs_est_power_get(const struct scmi_protocol_handle *ph, |
---|
| 713 | + u32 domain, unsigned long *freq, |
---|
| 714 | + unsigned long *power) |
---|
433 | 715 | { |
---|
434 | | - struct scmi_perf_info *pi = handle->perf_priv; |
---|
| 716 | + struct scmi_perf_info *pi = ph->get_priv(ph); |
---|
435 | 717 | struct perf_dom_info *dom; |
---|
436 | 718 | unsigned long opp_freq; |
---|
437 | 719 | int idx, ret = -EINVAL; |
---|
.. | .. |
---|
455 | 737 | return ret; |
---|
456 | 738 | } |
---|
457 | 739 | |
---|
458 | | -static struct scmi_perf_ops perf_ops = { |
---|
| 740 | +static bool scmi_fast_switch_possible(const struct scmi_protocol_handle *ph, |
---|
| 741 | + struct device *dev) |
---|
| 742 | +{ |
---|
| 743 | + struct perf_dom_info *dom; |
---|
| 744 | + struct scmi_perf_info *pi = ph->get_priv(ph); |
---|
| 745 | + |
---|
| 746 | + dom = pi->dom_info + scmi_dev_domain_id(dev); |
---|
| 747 | + |
---|
| 748 | + return dom->fc_info && dom->fc_info->level_set_addr; |
---|
| 749 | +} |
---|
| 750 | + |
---|
| 751 | +static bool scmi_power_scale_mw_get(const struct scmi_protocol_handle *ph) |
---|
| 752 | +{ |
---|
| 753 | + struct scmi_perf_info *pi = ph->get_priv(ph); |
---|
| 754 | + |
---|
| 755 | + return pi->power_scale_mw; |
---|
| 756 | +} |
---|
| 757 | + |
---|
| 758 | +static const struct scmi_perf_proto_ops perf_proto_ops = { |
---|
459 | 759 | .limits_set = scmi_perf_limits_set, |
---|
460 | 760 | .limits_get = scmi_perf_limits_get, |
---|
461 | 761 | .level_set = scmi_perf_level_set, |
---|
.. | .. |
---|
466 | 766 | .freq_set = scmi_dvfs_freq_set, |
---|
467 | 767 | .freq_get = scmi_dvfs_freq_get, |
---|
468 | 768 | .est_power_get = scmi_dvfs_est_power_get, |
---|
| 769 | + .fast_switch_possible = scmi_fast_switch_possible, |
---|
| 770 | + .power_scale_mw_get = scmi_power_scale_mw_get, |
---|
469 | 771 | }; |
---|
470 | 772 | |
---|
471 | | -static int scmi_perf_protocol_init(struct scmi_handle *handle) |
---|
| 773 | +static int scmi_perf_set_notify_enabled(const struct scmi_protocol_handle *ph, |
---|
| 774 | + u8 evt_id, u32 src_id, bool enable) |
---|
| 775 | +{ |
---|
| 776 | + int ret, cmd_id; |
---|
| 777 | + |
---|
| 778 | + if (evt_id >= ARRAY_SIZE(evt_2_cmd)) |
---|
| 779 | + return -EINVAL; |
---|
| 780 | + |
---|
| 781 | + cmd_id = evt_2_cmd[evt_id]; |
---|
| 782 | + ret = scmi_perf_level_limits_notify(ph, src_id, cmd_id, enable); |
---|
| 783 | + if (ret) |
---|
| 784 | + pr_debug("FAIL_ENABLED - evt[%X] dom[%d] - ret:%d\n", |
---|
| 785 | + evt_id, src_id, ret); |
---|
| 786 | + |
---|
| 787 | + return ret; |
---|
| 788 | +} |
---|
| 789 | + |
---|
| 790 | +static void *scmi_perf_fill_custom_report(const struct scmi_protocol_handle *ph, |
---|
| 791 | + u8 evt_id, ktime_t timestamp, |
---|
| 792 | + const void *payld, size_t payld_sz, |
---|
| 793 | + void *report, u32 *src_id) |
---|
| 794 | +{ |
---|
| 795 | + void *rep = NULL; |
---|
| 796 | + |
---|
| 797 | + switch (evt_id) { |
---|
| 798 | + case SCMI_EVENT_PERFORMANCE_LIMITS_CHANGED: |
---|
| 799 | + { |
---|
| 800 | + const struct scmi_perf_limits_notify_payld *p = payld; |
---|
| 801 | + struct scmi_perf_limits_report *r = report; |
---|
| 802 | + |
---|
| 803 | + if (sizeof(*p) != payld_sz) |
---|
| 804 | + break; |
---|
| 805 | + |
---|
| 806 | + r->timestamp = timestamp; |
---|
| 807 | + r->agent_id = le32_to_cpu(p->agent_id); |
---|
| 808 | + r->domain_id = le32_to_cpu(p->domain_id); |
---|
| 809 | + r->range_max = le32_to_cpu(p->range_max); |
---|
| 810 | + r->range_min = le32_to_cpu(p->range_min); |
---|
| 811 | + *src_id = r->domain_id; |
---|
| 812 | + rep = r; |
---|
| 813 | + break; |
---|
| 814 | + } |
---|
| 815 | + case SCMI_EVENT_PERFORMANCE_LEVEL_CHANGED: |
---|
| 816 | + { |
---|
| 817 | + const struct scmi_perf_level_notify_payld *p = payld; |
---|
| 818 | + struct scmi_perf_level_report *r = report; |
---|
| 819 | + |
---|
| 820 | + if (sizeof(*p) != payld_sz) |
---|
| 821 | + break; |
---|
| 822 | + |
---|
| 823 | + r->timestamp = timestamp; |
---|
| 824 | + r->agent_id = le32_to_cpu(p->agent_id); |
---|
| 825 | + r->domain_id = le32_to_cpu(p->domain_id); |
---|
| 826 | + r->performance_level = le32_to_cpu(p->performance_level); |
---|
| 827 | + *src_id = r->domain_id; |
---|
| 828 | + rep = r; |
---|
| 829 | + break; |
---|
| 830 | + } |
---|
| 831 | + default: |
---|
| 832 | + break; |
---|
| 833 | + } |
---|
| 834 | + |
---|
| 835 | + return rep; |
---|
| 836 | +} |
---|
| 837 | + |
---|
| 838 | +static int scmi_perf_get_num_sources(const struct scmi_protocol_handle *ph) |
---|
| 839 | +{ |
---|
| 840 | + struct scmi_perf_info *pi = ph->get_priv(ph); |
---|
| 841 | + |
---|
| 842 | + if (!pi) |
---|
| 843 | + return -EINVAL; |
---|
| 844 | + |
---|
| 845 | + return pi->num_domains; |
---|
| 846 | +} |
---|
| 847 | + |
---|
| 848 | +static const struct scmi_event perf_events[] = { |
---|
| 849 | + { |
---|
| 850 | + .id = SCMI_EVENT_PERFORMANCE_LIMITS_CHANGED, |
---|
| 851 | + .max_payld_sz = sizeof(struct scmi_perf_limits_notify_payld), |
---|
| 852 | + .max_report_sz = sizeof(struct scmi_perf_limits_report), |
---|
| 853 | + }, |
---|
| 854 | + { |
---|
| 855 | + .id = SCMI_EVENT_PERFORMANCE_LEVEL_CHANGED, |
---|
| 856 | + .max_payld_sz = sizeof(struct scmi_perf_level_notify_payld), |
---|
| 857 | + .max_report_sz = sizeof(struct scmi_perf_level_report), |
---|
| 858 | + }, |
---|
| 859 | +}; |
---|
| 860 | + |
---|
| 861 | +static const struct scmi_event_ops perf_event_ops = { |
---|
| 862 | + .get_num_sources = scmi_perf_get_num_sources, |
---|
| 863 | + .set_notify_enabled = scmi_perf_set_notify_enabled, |
---|
| 864 | + .fill_custom_report = scmi_perf_fill_custom_report, |
---|
| 865 | +}; |
---|
| 866 | + |
---|
| 867 | +static const struct scmi_protocol_events perf_protocol_events = { |
---|
| 868 | + .queue_sz = SCMI_PROTO_QUEUE_SZ, |
---|
| 869 | + .ops = &perf_event_ops, |
---|
| 870 | + .evts = perf_events, |
---|
| 871 | + .num_events = ARRAY_SIZE(perf_events), |
---|
| 872 | +}; |
---|
| 873 | + |
---|
| 874 | +static int scmi_perf_protocol_init(const struct scmi_protocol_handle *ph) |
---|
472 | 875 | { |
---|
473 | 876 | int domain; |
---|
474 | 877 | u32 version; |
---|
475 | 878 | struct scmi_perf_info *pinfo; |
---|
476 | 879 | |
---|
477 | | - scmi_version_get(handle, SCMI_PROTOCOL_PERF, &version); |
---|
| 880 | + ph->xops->version_get(ph, &version); |
---|
478 | 881 | |
---|
479 | | - dev_dbg(handle->dev, "Performance Version %d.%d\n", |
---|
| 882 | + dev_dbg(ph->dev, "Performance Version %d.%d\n", |
---|
480 | 883 | PROTOCOL_REV_MAJOR(version), PROTOCOL_REV_MINOR(version)); |
---|
481 | 884 | |
---|
482 | | - pinfo = devm_kzalloc(handle->dev, sizeof(*pinfo), GFP_KERNEL); |
---|
| 885 | + pinfo = devm_kzalloc(ph->dev, sizeof(*pinfo), GFP_KERNEL); |
---|
483 | 886 | if (!pinfo) |
---|
484 | 887 | return -ENOMEM; |
---|
485 | 888 | |
---|
486 | | - scmi_perf_attributes_get(handle, pinfo); |
---|
| 889 | + scmi_perf_attributes_get(ph, pinfo); |
---|
487 | 890 | |
---|
488 | | - pinfo->dom_info = devm_kcalloc(handle->dev, pinfo->num_domains, |
---|
| 891 | + pinfo->dom_info = devm_kcalloc(ph->dev, pinfo->num_domains, |
---|
489 | 892 | sizeof(*pinfo->dom_info), GFP_KERNEL); |
---|
490 | 893 | if (!pinfo->dom_info) |
---|
491 | 894 | return -ENOMEM; |
---|
.. | .. |
---|
493 | 896 | for (domain = 0; domain < pinfo->num_domains; domain++) { |
---|
494 | 897 | struct perf_dom_info *dom = pinfo->dom_info + domain; |
---|
495 | 898 | |
---|
496 | | - scmi_perf_domain_attributes_get(handle, domain, dom); |
---|
497 | | - scmi_perf_describe_levels_get(handle, domain, dom); |
---|
| 899 | + scmi_perf_domain_attributes_get(ph, domain, dom); |
---|
| 900 | + scmi_perf_describe_levels_get(ph, domain, dom); |
---|
| 901 | + |
---|
| 902 | + if (dom->perf_fastchannels) |
---|
| 903 | + scmi_perf_domain_init_fc(ph, domain, &dom->fc_info); |
---|
498 | 904 | } |
---|
499 | 905 | |
---|
500 | 906 | pinfo->version = version; |
---|
501 | | - handle->perf_ops = &perf_ops; |
---|
502 | | - handle->perf_priv = pinfo; |
---|
503 | 907 | |
---|
504 | | - return 0; |
---|
| 908 | + return ph->set_priv(ph, pinfo); |
---|
505 | 909 | } |
---|
506 | 910 | |
---|
507 | | -DEFINE_SCMI_PROTOCOL_REGISTER_UNREGISTER(SCMI_PROTOCOL_PERF, perf) |
---|
| 911 | +static const struct scmi_protocol scmi_perf = { |
---|
| 912 | + .id = SCMI_PROTOCOL_PERF, |
---|
| 913 | + .owner = THIS_MODULE, |
---|
| 914 | + .init_instance = &scmi_perf_protocol_init, |
---|
| 915 | + .ops = &perf_proto_ops, |
---|
| 916 | + .events = &perf_protocol_events, |
---|
| 917 | +}; |
---|
| 918 | + |
---|
| 919 | +DEFINE_SCMI_PROTOCOL_REGISTER_UNREGISTER(perf, scmi_perf) |
---|