1 // SPDX-License-Identifier: GPL-2.0
3 * System Control and Management Interface (SCMI) Performance Protocol
5 * Copyright (C) 2018-2021 ARM Ltd.
8 #define pr_fmt(fmt) "SCMI Notifications PERF - " fmt
10 #include <linux/bits.h>
13 #include <linux/io-64-nonatomic-hi-lo.h>
14 #include <linux/module.h>
15 #include <linux/platform_device.h>
16 #include <linux/pm_opp.h>
17 #include <linux/scmi_protocol.h>
18 #include <linux/sort.h>
23 enum scmi_performance_protocol_cmd {
24 PERF_DOMAIN_ATTRIBUTES = 0x3,
25 PERF_DESCRIBE_LEVELS = 0x4,
26 PERF_LIMITS_SET = 0x5,
27 PERF_LIMITS_GET = 0x6,
30 PERF_NOTIFY_LIMITS = 0x9,
31 PERF_NOTIFY_LEVEL = 0xa,
32 PERF_DESCRIBE_FASTCHANNEL = 0xb,
41 struct scmi_msg_resp_perf_attributes {
44 #define POWER_SCALE_IN_MILLIWATT(x) ((x) & BIT(0))
45 __le32 stats_addr_low;
46 __le32 stats_addr_high;
50 struct scmi_msg_resp_perf_domain_attributes {
52 #define SUPPORTS_SET_LIMITS(x) ((x) & BIT(31))
53 #define SUPPORTS_SET_PERF_LVL(x) ((x) & BIT(30))
54 #define SUPPORTS_PERF_LIMIT_NOTIFY(x) ((x) & BIT(29))
55 #define SUPPORTS_PERF_LEVEL_NOTIFY(x) ((x) & BIT(28))
56 #define SUPPORTS_PERF_FASTCHANNELS(x) ((x) & BIT(27))
58 __le32 sustained_freq_khz;
59 __le32 sustained_perf_level;
60 u8 name[SCMI_MAX_STR_SIZE];
63 struct scmi_msg_perf_describe_levels {
68 struct scmi_perf_set_limits {
74 struct scmi_perf_get_limits {
79 struct scmi_perf_set_level {
84 struct scmi_perf_notify_level_or_limits {
89 struct scmi_perf_limits_notify_payld {
96 struct scmi_perf_level_notify_payld {
99 __le32 performance_level;
102 struct scmi_msg_resp_perf_describe_levels {
104 __le16 num_remaining;
108 __le16 transition_latency_us;
113 struct scmi_perf_get_fc_info {
118 struct scmi_msg_resp_perf_desc_fc {
120 #define SUPPORTS_DOORBELL(x) ((x) & BIT(0))
121 #define DOORBELL_REG_WIDTH(x) FIELD_GET(GENMASK(2, 1), (x))
123 __le32 chan_addr_low;
124 __le32 chan_addr_high;
130 __le32 db_preserve_lmask;
131 __le32 db_preserve_hmask;
134 struct scmi_fc_db_info {
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;
150 struct perf_dom_info {
153 bool perf_limit_notify;
154 bool perf_level_notify;
155 bool perf_fastchannels;
157 u32 sustained_freq_khz;
158 u32 sustained_perf_level;
160 char name[SCMI_MAX_STR_SIZE];
161 struct scmi_opp opp[MAX_OPPS];
162 struct scmi_fc_info *fc_info;
165 struct scmi_perf_info {
171 struct perf_dom_info *dom_info;
174 static enum scmi_performance_protocol_cmd evt_2_cmd[] = {
179 static int scmi_perf_attributes_get(const struct scmi_protocol_handle *ph,
180 struct scmi_perf_info *pi)
184 struct scmi_msg_resp_perf_attributes *attr;
186 ret = ph->xops->xfer_get_init(ph, PROTOCOL_ATTRIBUTES, 0,
193 ret = ph->xops->do_xfer(ph, t);
195 u16 flags = le16_to_cpu(attr->flags);
197 pi->num_domains = le16_to_cpu(attr->num_domains);
198 pi->power_scale_mw = POWER_SCALE_IN_MILLIWATT(flags);
199 pi->stats_addr = le32_to_cpu(attr->stats_addr_low) |
200 (u64)le32_to_cpu(attr->stats_addr_high) << 32;
201 pi->stats_size = le32_to_cpu(attr->stats_size);
204 ph->xops->xfer_put(ph, t);
209 scmi_perf_domain_attributes_get(const struct scmi_protocol_handle *ph,
210 u32 domain, struct perf_dom_info *dom_info)
214 struct scmi_msg_resp_perf_domain_attributes *attr;
216 ret = ph->xops->xfer_get_init(ph, PERF_DOMAIN_ATTRIBUTES,
217 sizeof(domain), sizeof(*attr), &t);
221 put_unaligned_le32(domain, t->tx.buf);
224 ret = ph->xops->do_xfer(ph, t);
226 u32 flags = le32_to_cpu(attr->flags);
228 dom_info->set_limits = SUPPORTS_SET_LIMITS(flags);
229 dom_info->set_perf = SUPPORTS_SET_PERF_LVL(flags);
230 dom_info->perf_limit_notify = SUPPORTS_PERF_LIMIT_NOTIFY(flags);
231 dom_info->perf_level_notify = SUPPORTS_PERF_LEVEL_NOTIFY(flags);
232 dom_info->perf_fastchannels = SUPPORTS_PERF_FASTCHANNELS(flags);
233 dom_info->sustained_freq_khz =
234 le32_to_cpu(attr->sustained_freq_khz);
235 dom_info->sustained_perf_level =
236 le32_to_cpu(attr->sustained_perf_level);
237 if (!dom_info->sustained_freq_khz ||
238 !dom_info->sustained_perf_level)
239 /* CPUFreq converts to kHz, hence default 1000 */
240 dom_info->mult_factor = 1000;
242 dom_info->mult_factor =
243 (dom_info->sustained_freq_khz * 1000) /
244 dom_info->sustained_perf_level;
245 strlcpy(dom_info->name, attr->name, SCMI_MAX_STR_SIZE);
248 ph->xops->xfer_put(ph, t);
252 static int opp_cmp_func(const void *opp1, const void *opp2)
254 const struct scmi_opp *t1 = opp1, *t2 = opp2;
256 return t1->perf - t2->perf;
260 scmi_perf_describe_levels_get(const struct scmi_protocol_handle *ph, u32 domain,
261 struct perf_dom_info *perf_dom)
265 u16 num_returned, num_remaining;
267 struct scmi_opp *opp;
268 struct scmi_msg_perf_describe_levels *dom_info;
269 struct scmi_msg_resp_perf_describe_levels *level_info;
271 ret = ph->xops->xfer_get_init(ph, PERF_DESCRIBE_LEVELS,
272 sizeof(*dom_info), 0, &t);
276 dom_info = t->tx.buf;
277 level_info = t->rx.buf;
280 dom_info->domain = cpu_to_le32(domain);
281 /* Set the number of OPPs to be skipped/already read */
282 dom_info->level_index = cpu_to_le32(tot_opp_cnt);
284 ret = ph->xops->do_xfer(ph, t);
288 num_returned = le16_to_cpu(level_info->num_returned);
289 num_remaining = le16_to_cpu(level_info->num_remaining);
290 if (tot_opp_cnt + num_returned > MAX_OPPS) {
291 dev_err(ph->dev, "No. of OPPs exceeded MAX_OPPS");
295 opp = &perf_dom->opp[tot_opp_cnt];
296 for (cnt = 0; cnt < num_returned; cnt++, opp++) {
297 opp->perf = le32_to_cpu(level_info->opp[cnt].perf_val);
298 opp->power = le32_to_cpu(level_info->opp[cnt].power);
299 opp->trans_latency_us = le16_to_cpu
300 (level_info->opp[cnt].transition_latency_us);
302 dev_dbg(ph->dev, "Level %d Power %d Latency %dus\n",
303 opp->perf, opp->power, opp->trans_latency_us);
306 tot_opp_cnt += num_returned;
308 ph->xops->reset_rx_to_maxsz(ph, t);
310 * check for both returned and remaining to avoid infinite
311 * loop due to buggy firmware
313 } while (num_returned && num_remaining);
315 perf_dom->opp_count = tot_opp_cnt;
316 ph->xops->xfer_put(ph, t);
318 sort(perf_dom->opp, tot_opp_cnt, sizeof(*opp), opp_cmp_func, NULL);
322 #define SCMI_PERF_FC_RING_DB(w) \
327 val = ioread##w(db->addr) & db->mask; \
328 iowrite##w((u##w)db->set | val, db->addr); \
331 static void scmi_perf_fc_ring_db(struct scmi_fc_db_info *db)
333 if (!db || !db->addr)
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 */
344 SCMI_PERF_FC_RING_DB(64);
350 val = ioread64_hi_lo(db->addr) & db->mask;
351 iowrite64_hi_lo(db->set | val, db->addr);
356 static int scmi_perf_mb_limits_set(const struct scmi_protocol_handle *ph,
357 u32 domain, u32 max_perf, u32 min_perf)
361 struct scmi_perf_set_limits *limits;
363 ret = ph->xops->xfer_get_init(ph, PERF_LIMITS_SET,
364 sizeof(*limits), 0, &t);
369 limits->domain = cpu_to_le32(domain);
370 limits->max_level = cpu_to_le32(max_perf);
371 limits->min_level = cpu_to_le32(min_perf);
373 ret = ph->xops->do_xfer(ph, t);
375 ph->xops->xfer_put(ph, t);
379 static int scmi_perf_limits_set(const struct scmi_protocol_handle *ph,
380 u32 domain, u32 max_perf, u32 min_perf)
382 struct scmi_perf_info *pi = ph->get_priv(ph);
383 struct perf_dom_info *dom = pi->dom_info + domain;
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);
392 return scmi_perf_mb_limits_set(ph, domain, max_perf, min_perf);
395 static int scmi_perf_mb_limits_get(const struct scmi_protocol_handle *ph,
396 u32 domain, u32 *max_perf, u32 *min_perf)
400 struct scmi_perf_get_limits *limits;
402 ret = ph->xops->xfer_get_init(ph, PERF_LIMITS_GET,
403 sizeof(__le32), 0, &t);
407 put_unaligned_le32(domain, t->tx.buf);
409 ret = ph->xops->do_xfer(ph, t);
413 *max_perf = le32_to_cpu(limits->max_level);
414 *min_perf = le32_to_cpu(limits->min_level);
417 ph->xops->xfer_put(ph, t);
421 static int scmi_perf_limits_get(const struct scmi_protocol_handle *ph,
422 u32 domain, u32 *max_perf, u32 *min_perf)
424 struct scmi_perf_info *pi = ph->get_priv(ph);
425 struct perf_dom_info *dom = pi->dom_info + domain;
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);
433 return scmi_perf_mb_limits_get(ph, domain, max_perf, min_perf);
436 static int scmi_perf_mb_level_set(const struct scmi_protocol_handle *ph,
437 u32 domain, u32 level, bool poll)
441 struct scmi_perf_set_level *lvl;
443 ret = ph->xops->xfer_get_init(ph, PERF_LEVEL_SET, sizeof(*lvl), 0, &t);
447 t->hdr.poll_completion = poll;
449 lvl->domain = cpu_to_le32(domain);
450 lvl->level = cpu_to_le32(level);
452 ret = ph->xops->do_xfer(ph, t);
454 ph->xops->xfer_put(ph, t);
458 static int scmi_perf_level_set(const struct scmi_protocol_handle *ph,
459 u32 domain, u32 level, bool poll)
461 struct scmi_perf_info *pi = ph->get_priv(ph);
462 struct perf_dom_info *dom = pi->dom_info + domain;
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);
470 return scmi_perf_mb_level_set(ph, domain, level, poll);
473 static int scmi_perf_mb_level_get(const struct scmi_protocol_handle *ph,
474 u32 domain, u32 *level, bool poll)
479 ret = ph->xops->xfer_get_init(ph, PERF_LEVEL_GET,
480 sizeof(u32), sizeof(u32), &t);
484 t->hdr.poll_completion = poll;
485 put_unaligned_le32(domain, t->tx.buf);
487 ret = ph->xops->do_xfer(ph, t);
489 *level = get_unaligned_le32(t->rx.buf);
491 ph->xops->xfer_put(ph, t);
495 static int scmi_perf_level_get(const struct scmi_protocol_handle *ph,
496 u32 domain, u32 *level, bool poll)
498 struct scmi_perf_info *pi = ph->get_priv(ph);
499 struct perf_dom_info *dom = pi->dom_info + domain;
501 if (dom->fc_info && dom->fc_info->level_get_addr) {
502 *level = ioread32(dom->fc_info->level_get_addr);
506 return scmi_perf_mb_level_get(ph, domain, level, poll);
509 static int scmi_perf_level_limits_notify(const struct scmi_protocol_handle *ph,
510 u32 domain, int message_id,
515 struct scmi_perf_notify_level_or_limits *notify;
517 ret = ph->xops->xfer_get_init(ph, message_id, sizeof(*notify), 0, &t);
522 notify->domain = cpu_to_le32(domain);
523 notify->notify_enable = enable ? cpu_to_le32(BIT(0)) : 0;
525 ret = ph->xops->do_xfer(ph, t);
527 ph->xops->xfer_put(ph, t);
531 static bool scmi_perf_fc_size_is_valid(u32 msg, u32 size)
533 if ((msg == PERF_LEVEL_GET || msg == PERF_LEVEL_SET) && size == 4)
535 if ((msg == PERF_LIMITS_GET || msg == PERF_LIMITS_SET) && size == 8)
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)
551 struct scmi_fc_db_info *db;
552 struct scmi_perf_get_fc_info *info;
553 struct scmi_msg_resp_perf_desc_fc *resp;
558 ret = ph->xops->xfer_get_init(ph, PERF_DESCRIBE_FASTCHANNEL,
559 sizeof(*info), sizeof(*resp), &t);
564 info->domain = cpu_to_le32(domain);
565 info->message_id = cpu_to_le32(message_id);
567 ret = ph->xops->do_xfer(ph, t);
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))
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);
584 if (p_db && SUPPORTS_DOORBELL(flags)) {
585 db = devm_kzalloc(ph->dev, sizeof(*db), GFP_KERNEL);
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);
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;
605 ph->xops->xfer_put(ph, t);
608 static void scmi_perf_domain_init_fc(const struct scmi_protocol_handle *ph,
609 u32 domain, struct scmi_fc_info **p_fc)
611 struct scmi_fc_info *fc;
613 fc = devm_kzalloc(ph->dev, sizeof(*fc), GFP_KERNEL);
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);
628 /* Device specific ops */
629 static int scmi_dev_domain_id(struct device *dev)
631 struct of_phandle_args clkspec;
633 if (of_parse_phandle_with_args(dev->of_node, "clocks", "#clock-cells",
637 return clkspec.args[0];
640 static int scmi_dvfs_device_opps_add(const struct scmi_protocol_handle *ph,
643 int idx, ret, domain;
645 struct scmi_opp *opp;
646 struct perf_dom_info *dom;
647 struct scmi_perf_info *pi = ph->get_priv(ph);
649 domain = scmi_dev_domain_id(dev);
653 dom = pi->dom_info + domain;
655 for (opp = dom->opp, idx = 0; idx < dom->opp_count; idx++, opp++) {
656 freq = opp->perf * dom->mult_factor;
658 ret = dev_pm_opp_add(dev, freq, 0);
660 dev_warn(dev, "failed to add opp %luHz\n", freq);
663 freq = (--opp)->perf * dom->mult_factor;
664 dev_pm_opp_remove(dev, freq);
673 scmi_dvfs_transition_latency_get(const struct scmi_protocol_handle *ph,
676 struct perf_dom_info *dom;
677 struct scmi_perf_info *pi = ph->get_priv(ph);
678 int domain = scmi_dev_domain_id(dev);
683 dom = pi->dom_info + domain;
685 return dom->opp[dom->opp_count - 1].trans_latency_us * 1000;
688 static int scmi_dvfs_freq_set(const struct scmi_protocol_handle *ph, u32 domain,
689 unsigned long freq, bool poll)
691 struct scmi_perf_info *pi = ph->get_priv(ph);
692 struct perf_dom_info *dom = pi->dom_info + domain;
694 return scmi_perf_level_set(ph, domain, freq / dom->mult_factor, poll);
697 static int scmi_dvfs_freq_get(const struct scmi_protocol_handle *ph, u32 domain,
698 unsigned long *freq, bool poll)
702 struct scmi_perf_info *pi = ph->get_priv(ph);
703 struct perf_dom_info *dom = pi->dom_info + domain;
705 ret = scmi_perf_level_get(ph, domain, &level, poll);
707 *freq = level * dom->mult_factor;
712 static int scmi_dvfs_est_power_get(const struct scmi_protocol_handle *ph,
713 u32 domain, unsigned long *freq,
714 unsigned long *power)
716 struct scmi_perf_info *pi = ph->get_priv(ph);
717 struct perf_dom_info *dom;
718 unsigned long opp_freq;
719 int idx, ret = -EINVAL;
720 struct scmi_opp *opp;
722 dom = pi->dom_info + domain;
726 for (opp = dom->opp, idx = 0; idx < dom->opp_count; idx++, opp++) {
727 opp_freq = opp->perf * dom->mult_factor;
728 if (opp_freq < *freq)
740 static bool scmi_fast_switch_possible(const struct scmi_protocol_handle *ph,
743 struct perf_dom_info *dom;
744 struct scmi_perf_info *pi = ph->get_priv(ph);
746 dom = pi->dom_info + scmi_dev_domain_id(dev);
748 return dom->fc_info && dom->fc_info->level_set_addr;
751 static bool scmi_power_scale_mw_get(const struct scmi_protocol_handle *ph)
753 struct scmi_perf_info *pi = ph->get_priv(ph);
755 return pi->power_scale_mw;
758 static const struct scmi_perf_proto_ops perf_proto_ops = {
759 .limits_set = scmi_perf_limits_set,
760 .limits_get = scmi_perf_limits_get,
761 .level_set = scmi_perf_level_set,
762 .level_get = scmi_perf_level_get,
763 .device_domain_id = scmi_dev_domain_id,
764 .transition_latency_get = scmi_dvfs_transition_latency_get,
765 .device_opps_add = scmi_dvfs_device_opps_add,
766 .freq_set = scmi_dvfs_freq_set,
767 .freq_get = scmi_dvfs_freq_get,
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,
773 static int scmi_perf_set_notify_enabled(const struct scmi_protocol_handle *ph,
774 u8 evt_id, u32 src_id, bool enable)
778 if (evt_id >= ARRAY_SIZE(evt_2_cmd))
781 cmd_id = evt_2_cmd[evt_id];
782 ret = scmi_perf_level_limits_notify(ph, src_id, cmd_id, enable);
784 pr_debug("FAIL_ENABLED - evt[%X] dom[%d] - ret:%d\n",
785 evt_id, src_id, ret);
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)
798 case SCMI_EVENT_PERFORMANCE_LIMITS_CHANGED:
800 const struct scmi_perf_limits_notify_payld *p = payld;
801 struct scmi_perf_limits_report *r = report;
803 if (sizeof(*p) != payld_sz)
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;
815 case SCMI_EVENT_PERFORMANCE_LEVEL_CHANGED:
817 const struct scmi_perf_level_notify_payld *p = payld;
818 struct scmi_perf_level_report *r = report;
820 if (sizeof(*p) != payld_sz)
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;
838 static int scmi_perf_get_num_sources(const struct scmi_protocol_handle *ph)
840 struct scmi_perf_info *pi = ph->get_priv(ph);
845 return pi->num_domains;
848 static const struct scmi_event perf_events[] = {
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),
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),
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,
867 static const struct scmi_protocol_events perf_protocol_events = {
868 .queue_sz = SCMI_PROTO_QUEUE_SZ,
869 .ops = &perf_event_ops,
871 .num_events = ARRAY_SIZE(perf_events),
874 static int scmi_perf_protocol_init(const struct scmi_protocol_handle *ph)
878 struct scmi_perf_info *pinfo;
880 ph->xops->version_get(ph, &version);
882 dev_dbg(ph->dev, "Performance Version %d.%d\n",
883 PROTOCOL_REV_MAJOR(version), PROTOCOL_REV_MINOR(version));
885 pinfo = devm_kzalloc(ph->dev, sizeof(*pinfo), GFP_KERNEL);
889 scmi_perf_attributes_get(ph, pinfo);
891 pinfo->dom_info = devm_kcalloc(ph->dev, pinfo->num_domains,
892 sizeof(*pinfo->dom_info), GFP_KERNEL);
893 if (!pinfo->dom_info)
896 for (domain = 0; domain < pinfo->num_domains; domain++) {
897 struct perf_dom_info *dom = pinfo->dom_info + domain;
899 scmi_perf_domain_attributes_get(ph, domain, dom);
900 scmi_perf_describe_levels_get(ph, domain, dom);
902 if (dom->perf_fastchannels)
903 scmi_perf_domain_init_fc(ph, domain, &dom->fc_info);
906 pinfo->version = version;
908 return ph->set_priv(ph, pinfo);
911 static const struct scmi_protocol scmi_perf = {
912 .id = SCMI_PROTOCOL_PERF,
913 .owner = THIS_MODULE,
914 .instance_init = &scmi_perf_protocol_init,
915 .ops = &perf_proto_ops,
916 .events = &perf_protocol_events,
919 DEFINE_SCMI_PROTOCOL_REGISTER_UNREGISTER(perf, scmi_perf)