Lines Matching +full:protocol +full:- +full:id
1 // SPDX-License-Identifier: GPL-2.0
3 * System Control and Management Interface (SCMI) Message Protocol driver
5 * SCMI Message Protocol is used between the System Control Processor(SCP)
7 * provides a mechanism for inter-processor communication between SCP's
14 * Copyright (C) 2018-2024 ARM Ltd.
25 #include <linux/io-64-nonatomic-hi-lo.h>
47 #define SCMI_VENDOR_MODULE_ALIAS_FMT "scmi-protocol-0x%02x-%s"
57 /* Track the unique id for the transfers for debug & profiling purpose */
63 * struct scmi_xfers_info - Structure to manage transfer information
71 * a number of xfers equal to the maximum allowed in-flight
74 * currently in-flight messages.
85 * struct scmi_protocol_instance - Describe an initialized protocol instance.
86 * @handle: Reference to the SCMI handle associated to this protocol instance.
87 * @proto: A reference to the protocol descriptor.
88 * @gid: A reference for per-protocol devres management.
89 * @users: A refcount to track effective users of this protocol.
90 * @priv: Reference for optional protocol private data.
91 * @version: Protocol version supported by the platform as detected at runtime.
92 * @negotiated_version: When the platform supports a newer protocol version,
96 * This field is NON-zero when a successful negotiation
98 * @ph: An embedded protocol handle that will be passed down to protocol
101 * Each protocol is initialized independently once for each SCMI platform in
118 * struct scmi_debug_info - Debug common info
134 * struct scmi_info - Structure representing a SCMI instance
136 * @id: A sequence number starting from zero identifying this instance
139 * @version: SCMI revision information containing protocol version,
140 * implementation version and (sub-)vendor identification.
144 * @tx_idr: IDR object to map protocol id to Tx channel info pointer
145 * @rx_idr: IDR object to map protocol id to Rx channel info pointer
147 * this SCMI instance: populated on protocol's first attempted
152 * base protocol
166 int id; member
286 proto = scmi_vendor_protocol_lookup(protocol_id, version->vendor_id, in scmi_vendor_protocol_get()
287 version->sub_vendor_id, in scmi_vendor_protocol_get()
288 version->impl_ver); in scmi_vendor_protocol_get()
293 protocol_id, version->vendor_id); in scmi_vendor_protocol_get()
297 protocol_id, version->vendor_id); in scmi_vendor_protocol_get()
299 pr_warn("Problem loading module for protocol 0x%x\n", in scmi_vendor_protocol_get()
306 version->vendor_id, in scmi_vendor_protocol_get()
307 version->sub_vendor_id, in scmi_vendor_protocol_get()
308 version->impl_ver); in scmi_vendor_protocol_get()
312 pr_info("Loaded SCMI Vendor Protocol 0x%x - %s %s %X\n", in scmi_vendor_protocol_get()
313 protocol_id, proto->vendor_id ?: "", in scmi_vendor_protocol_get()
314 proto->sub_vendor_id ?: "", proto->impl_ver); in scmi_vendor_protocol_get()
329 if (!proto || !try_module_get(proto->owner)) { in scmi_protocol_get()
330 pr_warn("SCMI Protocol 0x%x not found!\n", protocol_id); in scmi_protocol_get()
334 pr_debug("Found SCMI Protocol 0x%x\n", protocol_id); in scmi_protocol_get()
342 module_put(proto->owner); in scmi_protocol_put()
347 if (!proto->vendor_id) { in scmi_vendor_protocol_check()
348 pr_err("missing vendor_id for protocol 0x%x\n", proto->id); in scmi_vendor_protocol_check()
349 return -EINVAL; in scmi_vendor_protocol_check()
352 if (strlen(proto->vendor_id) >= SCMI_SHORT_NAME_MAX_SIZE) { in scmi_vendor_protocol_check()
353 pr_err("malformed vendor_id for protocol 0x%x\n", proto->id); in scmi_vendor_protocol_check()
354 return -EINVAL; in scmi_vendor_protocol_check()
357 if (proto->sub_vendor_id && in scmi_vendor_protocol_check()
358 strlen(proto->sub_vendor_id) >= SCMI_SHORT_NAME_MAX_SIZE) { in scmi_vendor_protocol_check()
359 pr_err("malformed sub_vendor_id for protocol 0x%x\n", in scmi_vendor_protocol_check()
360 proto->id); in scmi_vendor_protocol_check()
361 return -EINVAL; in scmi_vendor_protocol_check()
373 pr_err("invalid protocol\n"); in scmi_protocol_register()
374 return -EINVAL; in scmi_protocol_register()
377 if (!proto->instance_init) { in scmi_protocol_register()
378 pr_err("missing init for protocol 0x%x\n", proto->id); in scmi_protocol_register()
379 return -EINVAL; in scmi_protocol_register()
382 if (proto->id >= SCMI_PROTOCOL_VENDOR_BASE && in scmi_protocol_register()
384 return -EINVAL; in scmi_protocol_register()
387 * Calculate a protocol key to register this protocol with the core; in scmi_protocol_register()
390 key = scmi_protocol_key_calculate(proto->id, proto->vendor_id, in scmi_protocol_register()
391 proto->sub_vendor_id, in scmi_protocol_register()
392 proto->impl_ver); in scmi_protocol_register()
394 return -EINVAL; in scmi_protocol_register()
398 pr_err("unable to allocate SCMI protocol slot for 0x%x - err %d\n", in scmi_protocol_register()
399 proto->id, ret); in scmi_protocol_register()
403 pr_debug("Registered SCMI Protocol 0x%x - %s %s 0x%08X\n", in scmi_protocol_register()
404 proto->id, proto->vendor_id, proto->sub_vendor_id, in scmi_protocol_register()
405 proto->impl_ver); in scmi_protocol_register()
415 key = scmi_protocol_key_calculate(proto->id, proto->vendor_id, in scmi_protocol_unregister()
416 proto->sub_vendor_id, in scmi_protocol_unregister()
417 proto->impl_ver); in scmi_protocol_unregister()
423 pr_debug("Unregistered SCMI Protocol 0x%x\n", proto->id); in scmi_protocol_unregister()
428 * scmi_create_protocol_devices - Create devices for all pending requests for
431 * @np: The device node describing the protocol
433 * @prot_id: The protocol ID
436 * for the specified protocol.
444 mutex_lock(&info->devreq_mtx); in scmi_create_protocol_devices()
445 sdev = scmi_device_create(np, info->dev, prot_id, name); in scmi_create_protocol_devices()
447 dev_err(info->dev, in scmi_create_protocol_devices()
448 "failed to create device for protocol 0x%X (%s)\n", in scmi_create_protocol_devices()
450 mutex_unlock(&info->devreq_mtx); in scmi_create_protocol_devices()
456 mutex_lock(&info->devreq_mtx); in scmi_destroy_protocol_devices()
457 scmi_device_destroy(info->dev, prot_id, name); in scmi_destroy_protocol_devices()
458 mutex_unlock(&info->devreq_mtx); in scmi_destroy_protocol_devices()
466 info->notify_priv = priv; in scmi_notification_instance_data_set()
467 /* Ensure updated protocol private date are visible */ in scmi_notification_instance_data_set()
477 return info->notify_priv; in scmi_notification_instance_data_get()
481 * scmi_xfer_token_set - Reserve and set new token for the xfer at hand
487 * xfer->hdr.seq: picking a monotonically increasing value avoids immediate
488 * reuse of freshly completed or timed-out xfers, thus mitigating the risk
489 * of incorrect association of a late and expired xfer with a live in-flight
490 * transaction, both happening to re-use the same token identifier.
492 * Since platform is NOT required to answer our request in-order we should
495 * - exactly 'next_token' may be NOT available so pick xfer_id >= next_token
498 * - all tokens ahead upto (MSG_TOKEN_ID_MASK - 1) are used in-flight but we
502 * X = used in-flight
505 * ------
507 * |- xfer_id picked
508 * -----------+----------------------------------------------------------
510 * ----------------------------------------------------------------------
512 * |- next_token
514 * Out-of-order pending at start
515 * -----------------------------
517 * |- xfer_id picked, last_token fixed
518 * -----+----------------------------------------------------------------
520 * ----------------------------------------------------------------------
522 * |- next_token
525 * Out-of-order pending at end
526 * ---------------------------
528 * |- xfer_id picked, last_token fixed
529 * -----+----------------------------------------------------------------
531 * ----------------------------------------------------------------------
533 * |- next_token
545 * Pick a candidate monotonic token in range [0, MSG_TOKEN_MAX - 1] in scmi_xfer_token_set()
546 * using the pre-allocated transfer_id as a base. in scmi_xfer_token_set()
552 next_token = (xfer->transfer_id & (MSG_TOKEN_MAX - 1)); in scmi_xfer_token_set()
555 xfer_id = find_next_zero_bit(minfo->xfer_alloc_table, in scmi_xfer_token_set()
559 * After heavily out-of-order responses, there are no free in scmi_xfer_token_set()
563 xfer_id = find_next_zero_bit(minfo->xfer_alloc_table, in scmi_xfer_token_set()
567 * maximum number of (MSG_TOKEN_MAX - 1) in-flight messages in scmi_xfer_token_set()
568 * but we have not found any free token [0, MSG_TOKEN_MAX - 1]. in scmi_xfer_token_set()
571 return -ENOMEM; in scmi_xfer_token_set()
574 /* Update +/- last_token accordingly if we skipped some hole */ in scmi_xfer_token_set()
576 atomic_add((int)(xfer_id - next_token), &transfer_last_id); in scmi_xfer_token_set()
578 xfer->hdr.seq = (u16)xfer_id; in scmi_xfer_token_set()
584 * scmi_xfer_token_clear - Release the token
592 clear_bit(xfer->hdr.seq, minfo->xfer_alloc_table); in scmi_xfer_token_clear()
596 * scmi_xfer_inflight_register_unlocked - Register the xfer as in-flight
601 * Note that this helper assumes that the xfer to be registered as in-flight
611 /* Set in-flight */ in scmi_xfer_inflight_register_unlocked()
612 set_bit(xfer->hdr.seq, minfo->xfer_alloc_table); in scmi_xfer_inflight_register_unlocked()
613 hash_add(minfo->pending_xfers, &xfer->node, xfer->hdr.seq); in scmi_xfer_inflight_register_unlocked()
614 xfer->pending = true; in scmi_xfer_inflight_register_unlocked()
618 * scmi_xfer_inflight_register - Try to register an xfer as in-flight
626 * same sequence number is currently still registered as in-flight.
628 * Return: 0 on Success or -EBUSY if sequence number embedded in the xfer
637 spin_lock_irqsave(&minfo->xfer_lock, flags); in scmi_xfer_inflight_register()
638 if (!test_bit(xfer->hdr.seq, minfo->xfer_alloc_table)) in scmi_xfer_inflight_register()
641 ret = -EBUSY; in scmi_xfer_inflight_register()
642 spin_unlock_irqrestore(&minfo->xfer_lock, flags); in scmi_xfer_inflight_register()
648 * scmi_xfer_raw_inflight_register - An helper to register the given xfer as in
661 return scmi_xfer_inflight_register(xfer, &info->tx_minfo); in scmi_xfer_raw_inflight_register()
665 * scmi_xfer_pending_set - Pick a proper sequence number and mark the xfer
666 * as pending in-flight
679 spin_lock_irqsave(&minfo->xfer_lock, flags); in scmi_xfer_pending_set()
684 spin_unlock_irqrestore(&minfo->xfer_lock, flags); in scmi_xfer_pending_set()
690 * scmi_xfer_get() - Allocate one message
716 spin_lock_irqsave(&minfo->xfer_lock, flags); in scmi_xfer_get()
717 if (hlist_empty(&minfo->free_xfers)) { in scmi_xfer_get()
718 spin_unlock_irqrestore(&minfo->xfer_lock, flags); in scmi_xfer_get()
719 return ERR_PTR(-ENOMEM); in scmi_xfer_get()
723 xfer = hlist_entry(minfo->free_xfers.first, struct scmi_xfer, node); in scmi_xfer_get()
724 hlist_del_init(&xfer->node); in scmi_xfer_get()
730 xfer->transfer_id = atomic_inc_return(&transfer_last_id); in scmi_xfer_get()
732 refcount_set(&xfer->users, 1); in scmi_xfer_get()
733 atomic_set(&xfer->busy, SCMI_XFER_FREE); in scmi_xfer_get()
734 spin_unlock_irqrestore(&minfo->xfer_lock, flags); in scmi_xfer_get()
740 * scmi_xfer_raw_get - Helper to get a bare free xfer from the TX channel
746 * Return: A valid xfer on Success, or an error-pointer otherwise
753 xfer = scmi_xfer_get(handle, &info->tx_minfo); in scmi_xfer_raw_get()
755 xfer->flags |= SCMI_XFER_FLAG_IS_RAW; in scmi_xfer_raw_get()
761 * scmi_xfer_raw_channel_get - Helper to get a reference to the proper channel
765 * @protocol_id: Identifier of the protocol
767 * Note that in a regular SCMI stack, usually, a protocol has to be defined in
769 * protocol in range is allowed, re-using the Base channel, so as to enable
770 * fuzzing on any protocol without the need of a fully compiled DT.
780 cinfo = idr_find(&info->tx_idr, protocol_id); in scmi_xfer_raw_channel_get()
783 return ERR_PTR(-EINVAL); in scmi_xfer_raw_channel_get()
785 cinfo = idr_find(&info->tx_idr, SCMI_PROTOCOL_BASE); in scmi_xfer_raw_channel_get()
787 return ERR_PTR(-EINVAL); in scmi_xfer_raw_channel_get()
788 dev_warn_once(handle->dev, in scmi_xfer_raw_channel_get()
789 "Using Base channel for protocol 0x%X\n", in scmi_xfer_raw_channel_get()
797 * __scmi_xfer_put() - Release a message
812 spin_lock_irqsave(&minfo->xfer_lock, flags); in __scmi_xfer_put()
813 if (refcount_dec_and_test(&xfer->users)) { in __scmi_xfer_put()
814 if (xfer->pending) { in __scmi_xfer_put()
816 hash_del(&xfer->node); in __scmi_xfer_put()
817 xfer->pending = false; in __scmi_xfer_put()
819 hlist_add_head(&xfer->node, &minfo->free_xfers); in __scmi_xfer_put()
821 spin_unlock_irqrestore(&minfo->xfer_lock, flags); in __scmi_xfer_put()
825 * scmi_xfer_raw_put - Release an xfer that was taken by @scmi_xfer_raw_get
837 xfer->flags &= ~SCMI_XFER_FLAG_IS_RAW; in scmi_xfer_raw_put()
838 xfer->flags &= ~SCMI_XFER_FLAG_CHAN_SET; in scmi_xfer_raw_put()
839 return __scmi_xfer_put(&info->tx_minfo, xfer); in scmi_xfer_raw_put()
843 * scmi_xfer_lookup_unlocked - Helper to lookup an xfer_id
846 * @xfer_id: Token ID to lookup in @pending_xfers
859 if (test_bit(xfer_id, minfo->xfer_alloc_table)) in scmi_xfer_lookup_unlocked()
860 xfer = XFER_FIND(minfo->pending_xfers, xfer_id); in scmi_xfer_lookup_unlocked()
862 return xfer ?: ERR_PTR(-EINVAL); in scmi_xfer_lookup_unlocked()
866 * scmi_bad_message_trace - A helper to trace weird messages
874 * timed-out message that arrives and as such, can be traced only referring to
881 struct scmi_info *info = handle_to_scmi_info(cinfo->handle); in scmi_bad_message_trace()
898 trace_scmi_msg_dump(info->id, cinfo->id, in scmi_bad_message_trace()
905 * scmi_msg_response_validate - Validate message type against state of related
914 * related synchronous response (Out-of-Order Delayed Response) the missing
917 * SCMI transport can deliver such out-of-order responses.
919 * Context: Assumes to be called with xfer->lock already acquired.
930 * delayed response we're not prepared to handle: bail-out safely in scmi_msg_response_validate()
933 if (msg_type == MSG_TYPE_DELAYED_RESP && !xfer->async_done) { in scmi_msg_response_validate()
934 dev_err(cinfo->dev, in scmi_msg_response_validate()
936 xfer->hdr.seq); in scmi_msg_response_validate()
937 return -EINVAL; in scmi_msg_response_validate()
940 switch (xfer->state) { in scmi_msg_response_validate()
947 xfer->hdr.status = SCMI_SUCCESS; in scmi_msg_response_validate()
948 xfer->state = SCMI_XFER_RESP_OK; in scmi_msg_response_validate()
949 complete(&xfer->done); in scmi_msg_response_validate()
950 dev_warn(cinfo->dev, in scmi_msg_response_validate()
952 xfer->hdr.seq); in scmi_msg_response_validate()
957 return -EINVAL; in scmi_msg_response_validate()
961 return -EINVAL; in scmi_msg_response_validate()
968 * scmi_xfer_state_update - Update xfer state
981 xfer->hdr.type = msg_type; in scmi_xfer_state_update()
984 if (xfer->hdr.type == MSG_TYPE_COMMAND) in scmi_xfer_state_update()
985 xfer->state = SCMI_XFER_RESP_OK; in scmi_xfer_state_update()
987 xfer->state = SCMI_XFER_DRESP_OK; in scmi_xfer_state_update()
994 ret = atomic_cmpxchg(&xfer->busy, SCMI_XFER_FREE, SCMI_XFER_BUSY); in scmi_xfer_acquired()
1000 * scmi_xfer_command_acquire - Helper to lookup and acquire a command xfer
1017 struct scmi_info *info = handle_to_scmi_info(cinfo->handle); in scmi_xfer_command_acquire()
1018 struct scmi_xfers_info *minfo = &info->tx_minfo; in scmi_xfer_command_acquire()
1023 spin_lock_irqsave(&minfo->xfer_lock, flags); in scmi_xfer_command_acquire()
1026 dev_err(cinfo->dev, in scmi_xfer_command_acquire()
1029 spin_unlock_irqrestore(&minfo->xfer_lock, flags); in scmi_xfer_command_acquire()
1032 scmi_inc_count(info->dbg->counters, ERR_MSG_UNEXPECTED); in scmi_xfer_command_acquire()
1036 refcount_inc(&xfer->users); in scmi_xfer_command_acquire()
1037 spin_unlock_irqrestore(&minfo->xfer_lock, flags); in scmi_xfer_command_acquire()
1039 spin_lock_irqsave(&xfer->lock, flags); in scmi_xfer_command_acquire()
1052 spin_unlock_irqrestore(&xfer->lock, flags); in scmi_xfer_command_acquire()
1055 dev_err(cinfo->dev, in scmi_xfer_command_acquire()
1056 "Invalid message type:%d for %d - HDR:0x%X state:%d\n", in scmi_xfer_command_acquire()
1057 msg_type, xfer_id, msg_hdr, xfer->state); in scmi_xfer_command_acquire()
1060 scmi_inc_count(info->dbg->counters, ERR_MSG_INVALID); in scmi_xfer_command_acquire()
1064 xfer = ERR_PTR(-EINVAL); in scmi_xfer_command_acquire()
1073 atomic_set(&xfer->busy, SCMI_XFER_FREE); in scmi_xfer_command_release()
1074 __scmi_xfer_put(&info->tx_minfo, xfer); in scmi_xfer_command_release()
1080 if (!cinfo->is_p2a) { in scmi_clear_channel()
1081 dev_warn(cinfo->dev, "Invalid clear on A2P channel !\n"); in scmi_clear_channel()
1085 if (info->desc->ops->clear_channel) in scmi_clear_channel()
1086 info->desc->ops->clear_channel(cinfo); in scmi_clear_channel()
1093 struct device *dev = cinfo->dev; in scmi_handle_notification()
1094 struct scmi_info *info = handle_to_scmi_info(cinfo->handle); in scmi_handle_notification()
1095 struct scmi_xfers_info *minfo = &info->rx_minfo; in scmi_handle_notification()
1099 xfer = scmi_xfer_get(cinfo->handle, minfo); in scmi_handle_notification()
1105 scmi_inc_count(info->dbg->counters, ERR_MSG_NOMEM); in scmi_handle_notification()
1111 unpack_scmi_header(msg_hdr, &xfer->hdr); in scmi_handle_notification()
1113 /* Ensure order between xfer->priv store and following ops */ in scmi_handle_notification()
1114 smp_store_mb(xfer->priv, priv); in scmi_handle_notification()
1115 info->desc->ops->fetch_notification(cinfo, info->desc->max_msg_size, in scmi_handle_notification()
1118 trace_scmi_msg_dump(info->id, cinfo->id, xfer->hdr.protocol_id, in scmi_handle_notification()
1119 xfer->hdr.id, "NOTI", xfer->hdr.seq, in scmi_handle_notification()
1120 xfer->hdr.status, xfer->rx.buf, xfer->rx.len); in scmi_handle_notification()
1121 scmi_inc_count(info->dbg->counters, NOTIFICATION_OK); in scmi_handle_notification()
1123 scmi_notify(cinfo->handle, xfer->hdr.protocol_id, in scmi_handle_notification()
1124 xfer->hdr.id, xfer->rx.buf, xfer->rx.len, ts); in scmi_handle_notification()
1126 trace_scmi_rx_done(xfer->transfer_id, xfer->hdr.id, in scmi_handle_notification()
1127 xfer->hdr.protocol_id, xfer->hdr.seq, in scmi_handle_notification()
1131 xfer->hdr.seq = MSG_XTRACT_TOKEN(msg_hdr); in scmi_handle_notification()
1132 scmi_raw_message_report(info->raw, xfer, SCMI_RAW_NOTIF_QUEUE, in scmi_handle_notification()
1133 cinfo->id); in scmi_handle_notification()
1145 struct scmi_info *info = handle_to_scmi_info(cinfo->handle); in scmi_handle_response()
1150 scmi_raw_error_report(info->raw, cinfo, msg_hdr, priv); in scmi_handle_response()
1158 if (xfer->hdr.type == MSG_TYPE_DELAYED_RESP) in scmi_handle_response()
1159 xfer->rx.len = info->desc->max_msg_size; in scmi_handle_response()
1162 /* Ensure order between xfer->priv store and following ops */ in scmi_handle_response()
1163 smp_store_mb(xfer->priv, priv); in scmi_handle_response()
1164 info->desc->ops->fetch_response(cinfo, xfer); in scmi_handle_response()
1166 trace_scmi_msg_dump(info->id, cinfo->id, xfer->hdr.protocol_id, in scmi_handle_response()
1167 xfer->hdr.id, in scmi_handle_response()
1168 xfer->hdr.type == MSG_TYPE_DELAYED_RESP ? in scmi_handle_response()
1171 xfer->hdr.seq, xfer->hdr.status, in scmi_handle_response()
1172 xfer->rx.buf, xfer->rx.len); in scmi_handle_response()
1174 trace_scmi_rx_done(xfer->transfer_id, xfer->hdr.id, in scmi_handle_response()
1175 xfer->hdr.protocol_id, xfer->hdr.seq, in scmi_handle_response()
1176 xfer->hdr.type); in scmi_handle_response()
1178 if (xfer->hdr.type == MSG_TYPE_DELAYED_RESP) { in scmi_handle_response()
1180 complete(xfer->async_done); in scmi_handle_response()
1181 scmi_inc_count(info->dbg->counters, DELAYED_RESPONSE_OK); in scmi_handle_response()
1183 complete(&xfer->done); in scmi_handle_response()
1184 scmi_inc_count(info->dbg->counters, RESPONSE_OK); in scmi_handle_response()
1193 if (!xfer->hdr.poll_completion) in scmi_handle_response()
1194 scmi_raw_message_report(info->raw, xfer, in scmi_handle_response()
1196 cinfo->id); in scmi_handle_response()
1203 * scmi_rx_callback() - callback for receiving messages
1236 * xfer_put() - Release a transmit message
1238 * @ph: Pointer to SCMI protocol handle
1245 struct scmi_info *info = handle_to_scmi_info(pi->handle); in xfer_put()
1247 __scmi_xfer_put(&info->tx_minfo, xfer); in xfer_put()
1253 struct scmi_info *info = handle_to_scmi_info(cinfo->handle); in scmi_xfer_done_no_timeout()
1256 * Poll also on xfer->done so that polling can be forcibly terminated in scmi_xfer_done_no_timeout()
1257 * in case of out-of-order receptions of delayed responses in scmi_xfer_done_no_timeout()
1259 return info->desc->ops->poll_done(cinfo, xfer) || in scmi_xfer_done_no_timeout()
1260 try_wait_for_completion(&xfer->done) || in scmi_xfer_done_no_timeout()
1269 struct scmi_info *info = handle_to_scmi_info(cinfo->handle); in scmi_wait_for_reply()
1271 if (xfer->hdr.poll_completion) { in scmi_wait_for_reply()
1276 if (!desc->sync_cmds_completed_on_ret) { in scmi_wait_for_reply()
1287 "timed out in resp(caller: %pS) - polling\n", in scmi_wait_for_reply()
1289 ret = -ETIMEDOUT; in scmi_wait_for_reply()
1290 scmi_inc_count(info->dbg->counters, XFERS_RESPONSE_POLLED_TIMEOUT); in scmi_wait_for_reply()
1298 * Do not fetch_response if an out-of-order delayed in scmi_wait_for_reply()
1301 spin_lock_irqsave(&xfer->lock, flags); in scmi_wait_for_reply()
1302 if (xfer->state == SCMI_XFER_SENT_OK) { in scmi_wait_for_reply()
1303 desc->ops->fetch_response(cinfo, xfer); in scmi_wait_for_reply()
1304 xfer->state = SCMI_XFER_RESP_OK; in scmi_wait_for_reply()
1306 spin_unlock_irqrestore(&xfer->lock, flags); in scmi_wait_for_reply()
1309 trace_scmi_msg_dump(info->id, cinfo->id, in scmi_wait_for_reply()
1310 xfer->hdr.protocol_id, xfer->hdr.id, in scmi_wait_for_reply()
1313 xfer->hdr.seq, xfer->hdr.status, in scmi_wait_for_reply()
1314 xfer->rx.buf, xfer->rx.len); in scmi_wait_for_reply()
1315 scmi_inc_count(info->dbg->counters, RESPONSE_POLLED_OK); in scmi_wait_for_reply()
1318 scmi_raw_message_report(info->raw, xfer, in scmi_wait_for_reply()
1320 cinfo->id); in scmi_wait_for_reply()
1325 if (!wait_for_completion_timeout(&xfer->done, in scmi_wait_for_reply()
1329 ret = -ETIMEDOUT; in scmi_wait_for_reply()
1330 scmi_inc_count(info->dbg->counters, XFERS_RESPONSE_TIMEOUT); in scmi_wait_for_reply()
1338 * scmi_wait_for_message_response - An helper to group all the possible ways of
1344 * Chooses waiting strategy (sleep-waiting vs busy-waiting) depending on
1345 * configuration flags like xfer->hdr.poll_completion.
1352 struct scmi_info *info = handle_to_scmi_info(cinfo->handle); in scmi_wait_for_message_response()
1353 struct device *dev = info->dev; in scmi_wait_for_message_response()
1355 trace_scmi_xfer_response_wait(xfer->transfer_id, xfer->hdr.id, in scmi_wait_for_message_response()
1356 xfer->hdr.protocol_id, xfer->hdr.seq, in scmi_wait_for_message_response()
1357 info->desc->max_rx_timeout_ms, in scmi_wait_for_message_response()
1358 xfer->hdr.poll_completion); in scmi_wait_for_message_response()
1360 return scmi_wait_for_reply(dev, info->desc, cinfo, xfer, in scmi_wait_for_message_response()
1361 info->desc->max_rx_timeout_ms); in scmi_wait_for_message_response()
1365 * scmi_xfer_raw_wait_for_message_response - An helper to wait for a message
1379 struct scmi_info *info = handle_to_scmi_info(cinfo->handle); in scmi_xfer_raw_wait_for_message_response()
1380 struct device *dev = info->dev; in scmi_xfer_raw_wait_for_message_response()
1382 ret = scmi_wait_for_reply(dev, info->desc, cinfo, xfer, timeout_ms); in scmi_xfer_raw_wait_for_message_response()
1384 dev_dbg(dev, "timed out in RAW response - HDR:%08X\n", in scmi_xfer_raw_wait_for_message_response()
1385 pack_scmi_header(&xfer->hdr)); in scmi_xfer_raw_wait_for_message_response()
1391 * do_xfer() - Do one transfer
1393 * @ph: Pointer to SCMI protocol handle
1396 * Return: -ETIMEDOUT in case of no response, if transmit error,
1405 struct scmi_info *info = handle_to_scmi_info(pi->handle); in do_xfer()
1406 struct device *dev = info->dev; in do_xfer()
1410 if (xfer->hdr.poll_completion && in do_xfer()
1411 !is_transport_polling_capable(info->desc)) { in do_xfer()
1414 scmi_inc_count(info->dbg->counters, SENT_FAIL_POLLING_UNSUPPORTED); in do_xfer()
1415 return -EINVAL; in do_xfer()
1418 cinfo = idr_find(&info->tx_idr, pi->proto->id); in do_xfer()
1420 scmi_inc_count(info->dbg->counters, SENT_FAIL_CHANNEL_NOT_FOUND); in do_xfer()
1421 return -EINVAL; in do_xfer()
1424 if (is_polling_enabled(cinfo, info->desc)) in do_xfer()
1425 xfer->hdr.poll_completion = true; in do_xfer()
1428 * Initialise protocol id now from protocol handle to avoid it being in do_xfer()
1429 * overridden by mistake (or malice) by the protocol code mangling with in do_xfer()
1432 xfer->hdr.protocol_id = pi->proto->id; in do_xfer()
1433 reinit_completion(&xfer->done); in do_xfer()
1435 trace_scmi_xfer_begin(xfer->transfer_id, xfer->hdr.id, in do_xfer()
1436 xfer->hdr.protocol_id, xfer->hdr.seq, in do_xfer()
1437 xfer->hdr.poll_completion); in do_xfer()
1440 xfer->hdr.status = SCMI_SUCCESS; in do_xfer()
1441 xfer->state = SCMI_XFER_SENT_OK; in do_xfer()
1444 * on xfer->state due to the monotonically increasing tokens allocation, in do_xfer()
1445 * we must anyway ensure xfer->state initialization is not re-ordered in do_xfer()
1447 * ISR calling scmi_rx_callback() cannot see an old stale xfer->state. in do_xfer()
1451 ret = info->desc->ops->send_message(cinfo, xfer); in do_xfer()
1454 scmi_inc_count(info->dbg->counters, SENT_FAIL); in do_xfer()
1458 trace_scmi_msg_dump(info->id, cinfo->id, xfer->hdr.protocol_id, in do_xfer()
1459 xfer->hdr.id, "CMND", xfer->hdr.seq, in do_xfer()
1460 xfer->hdr.status, xfer->tx.buf, xfer->tx.len); in do_xfer()
1461 scmi_inc_count(info->dbg->counters, SENT_OK); in do_xfer()
1464 if (!ret && xfer->hdr.status) { in do_xfer()
1465 ret = scmi_to_linux_errno(xfer->hdr.status); in do_xfer()
1466 scmi_inc_count(info->dbg->counters, ERR_PROTOCOL); in do_xfer()
1469 if (info->desc->ops->mark_txdone) in do_xfer()
1470 info->desc->ops->mark_txdone(cinfo, ret, xfer); in do_xfer()
1472 trace_scmi_xfer_end(xfer->transfer_id, xfer->hdr.id, in do_xfer()
1473 xfer->hdr.protocol_id, xfer->hdr.seq, ret); in do_xfer()
1482 struct scmi_info *info = handle_to_scmi_info(pi->handle); in reset_rx_to_maxsz()
1484 xfer->rx.len = info->desc->max_msg_size; in reset_rx_to_maxsz()
1488 * do_xfer_with_response() - Do one transfer and wait until the delayed
1491 * @ph: Pointer to SCMI protocol handle
1495 * it could cause long busy-waiting here, so ignore polling for the delayed
1502 * attained at the protocol layer), but this would also have led to longer
1508 * Return: -ETIMEDOUT in case of no delayed response, if transmit error,
1517 xfer->async_done = &async_response; in do_xfer_with_response()
1525 WARN_ON_ONCE(xfer->hdr.poll_completion); in do_xfer_with_response()
1529 if (!wait_for_completion_timeout(xfer->async_done, timeout)) { in do_xfer_with_response()
1530 dev_err(ph->dev, in do_xfer_with_response()
1533 ret = -ETIMEDOUT; in do_xfer_with_response()
1534 } else if (xfer->hdr.status) { in do_xfer_with_response()
1535 ret = scmi_to_linux_errno(xfer->hdr.status); in do_xfer_with_response()
1539 xfer->async_done = NULL; in do_xfer_with_response()
1544 * xfer_get_init() - Allocate and initialise one message for transmit
1546 * @ph: Pointer to SCMI protocol handle
1565 struct scmi_info *info = handle_to_scmi_info(pi->handle); in xfer_get_init()
1566 struct scmi_xfers_info *minfo = &info->tx_minfo; in xfer_get_init()
1567 struct device *dev = info->dev; in xfer_get_init()
1570 if (rx_size > info->desc->max_msg_size || in xfer_get_init()
1571 tx_size > info->desc->max_msg_size) in xfer_get_init()
1572 return -ERANGE; in xfer_get_init()
1574 xfer = scmi_xfer_get(pi->handle, minfo); in xfer_get_init()
1581 /* Pick a sequence number and register this xfer as in-flight */ in xfer_get_init()
1584 dev_err(pi->handle->dev, in xfer_get_init()
1590 xfer->tx.len = tx_size; in xfer_get_init()
1591 xfer->rx.len = rx_size ? : info->desc->max_msg_size; in xfer_get_init()
1592 xfer->hdr.type = MSG_TYPE_COMMAND; in xfer_get_init()
1593 xfer->hdr.id = msg_id; in xfer_get_init()
1594 xfer->hdr.poll_completion = false; in xfer_get_init()
1602 * version_get() - command to get the revision of the SCMI entity
1604 * @ph: Pointer to SCMI protocol handle
1605 * @version: Holds returned version of protocol.
1623 rev_info = t->rx.buf; in version_get()
1632 * scmi_set_protocol_priv - Set protocol specific data at init time
1634 * @ph: A reference to the protocol handle.
1636 * @version: The detected protocol version for the core to register.
1645 pi->priv = priv; in scmi_set_protocol_priv()
1646 pi->version = version; in scmi_set_protocol_priv()
1652 * scmi_get_protocol_priv - Set protocol specific data at init time
1654 * @ph: A reference to the protocol handle.
1656 * Return: Protocol private data if any was set.
1662 return pi->priv; in scmi_get_protocol_priv()
1680 * scmi_common_extended_name_get - Common helper to get extended resources name
1681 * @ph: A protocol handle reference.
1682 * @cmd_id: The specific command ID to use.
1683 * @res_id: The specific resource ID to use.
1701 ret = ph->xops->xfer_get_init(ph, cmd_id, txlen, sizeof(*resp), &t); in scmi_common_extended_name_get()
1705 put_unaligned_le32(res_id, t->tx.buf); in scmi_common_extended_name_get()
1707 put_unaligned_le32(*flags, t->tx.buf + sizeof(res_id)); in scmi_common_extended_name_get()
1708 resp = t->rx.buf; in scmi_common_extended_name_get()
1710 ret = ph->xops->do_xfer(ph, t); in scmi_common_extended_name_get()
1712 strscpy(name, resp->name, len); in scmi_common_extended_name_get()
1714 ph->xops->xfer_put(ph, t); in scmi_common_extended_name_get()
1717 dev_warn(ph->dev, in scmi_common_extended_name_get()
1718 "Failed to get extended name - id:%u (ret:%d). Using %s\n", in scmi_common_extended_name_get()
1724 * scmi_common_get_max_msg_size - Get maximum message size
1725 * @ph: A protocol handle reference.
1727 * Return: Maximum message size for the current protocol.
1732 struct scmi_info *info = handle_to_scmi_info(pi->handle); in scmi_common_get_max_msg_size()
1734 return info->desc->max_msg_size; in scmi_common_get_max_msg_size()
1738 * struct scmi_iterator - Iterator descriptor
1740 * a proper custom command payload for each multi-part command request.
1742 * @process_response to parse the multi-part replies.
1745 * @ph: A reference to the associated protocol handle to be used.
1748 * internal routines and by the caller-provided @scmi_iterator_ops.
1770 i = devm_kzalloc(ph->dev, sizeof(*i), GFP_KERNEL); in scmi_iterator_init()
1772 return ERR_PTR(-ENOMEM); in scmi_iterator_init()
1774 i->ph = ph; in scmi_iterator_init()
1775 i->ops = ops; in scmi_iterator_init()
1776 i->priv = priv; in scmi_iterator_init()
1778 ret = ph->xops->xfer_get_init(ph, msg_id, tx_size, 0, &i->t); in scmi_iterator_init()
1780 devm_kfree(ph->dev, i); in scmi_iterator_init()
1784 i->state.max_resources = max_resources; in scmi_iterator_init()
1785 i->msg = i->t->tx.buf; in scmi_iterator_init()
1786 i->resp = i->t->rx.buf; in scmi_iterator_init()
1793 int ret = -EINVAL; in scmi_iterator_run()
1799 if (!i || !i->ops || !i->ph) in scmi_iterator_run()
1802 iops = i->ops; in scmi_iterator_run()
1803 ph = i->ph; in scmi_iterator_run()
1804 st = &i->state; in scmi_iterator_run()
1807 iops->prepare_message(i->msg, st->desc_index, i->priv); in scmi_iterator_run()
1808 ret = ph->xops->do_xfer(ph, i->t); in scmi_iterator_run()
1812 st->rx_len = i->t->rx.len; in scmi_iterator_run()
1813 ret = iops->update_state(st, i->resp, i->priv); in scmi_iterator_run()
1817 if (st->num_returned > st->max_resources - st->desc_index) { in scmi_iterator_run()
1818 dev_err(ph->dev, in scmi_iterator_run()
1820 st->max_resources); in scmi_iterator_run()
1821 ret = -EINVAL; in scmi_iterator_run()
1825 for (st->loop_idx = 0; st->loop_idx < st->num_returned; in scmi_iterator_run()
1826 st->loop_idx++) { in scmi_iterator_run()
1827 ret = iops->process_response(ph, i->resp, st, i->priv); in scmi_iterator_run()
1832 st->desc_index += st->num_returned; in scmi_iterator_run()
1833 ph->xops->reset_rx_to_maxsz(ph, i->t); in scmi_iterator_run()
1838 } while (st->num_returned && st->num_remaining); in scmi_iterator_run()
1842 ph->xops->xfer_put(ph, i->t); in scmi_iterator_run()
1843 devm_kfree(ph->dev, i); in scmi_iterator_run()
1887 ret = -EINVAL; in scmi_common_fastchannel_init()
1891 ret = ph->xops->xfer_get_init(ph, describe_id, in scmi_common_fastchannel_init()
1896 info = t->tx.buf; in scmi_common_fastchannel_init()
1897 info->domain = cpu_to_le32(domain); in scmi_common_fastchannel_init()
1898 info->message_id = cpu_to_le32(message_id); in scmi_common_fastchannel_init()
1905 ret = ph->xops->do_xfer(ph, t); in scmi_common_fastchannel_init()
1909 resp = t->rx.buf; in scmi_common_fastchannel_init()
1910 flags = le32_to_cpu(resp->attr); in scmi_common_fastchannel_init()
1911 size = le32_to_cpu(resp->chan_size); in scmi_common_fastchannel_init()
1913 ret = -EINVAL; in scmi_common_fastchannel_init()
1918 *rate_limit = le32_to_cpu(resp->rate_limit) & GENMASK(19, 0); in scmi_common_fastchannel_init()
1920 phys_addr = le32_to_cpu(resp->chan_addr_low); in scmi_common_fastchannel_init()
1921 phys_addr |= (u64)le32_to_cpu(resp->chan_addr_high) << 32; in scmi_common_fastchannel_init()
1922 addr = devm_ioremap(ph->dev, phys_addr, size); in scmi_common_fastchannel_init()
1924 ret = -EADDRNOTAVAIL; in scmi_common_fastchannel_init()
1931 db = devm_kzalloc(ph->dev, sizeof(*db), GFP_KERNEL); in scmi_common_fastchannel_init()
1933 ret = -ENOMEM; in scmi_common_fastchannel_init()
1938 phys_addr = le32_to_cpu(resp->db_addr_low); in scmi_common_fastchannel_init()
1939 phys_addr |= (u64)le32_to_cpu(resp->db_addr_high) << 32; in scmi_common_fastchannel_init()
1940 addr = devm_ioremap(ph->dev, phys_addr, size); in scmi_common_fastchannel_init()
1942 ret = -EADDRNOTAVAIL; in scmi_common_fastchannel_init()
1946 db->addr = addr; in scmi_common_fastchannel_init()
1947 db->width = size; in scmi_common_fastchannel_init()
1948 db->set = le32_to_cpu(resp->db_set_lmask); in scmi_common_fastchannel_init()
1949 db->set |= (u64)le32_to_cpu(resp->db_set_hmask) << 32; in scmi_common_fastchannel_init()
1950 db->mask = le32_to_cpu(resp->db_preserve_lmask); in scmi_common_fastchannel_init()
1951 db->mask |= (u64)le32_to_cpu(resp->db_preserve_hmask) << 32; in scmi_common_fastchannel_init()
1956 ph->xops->xfer_put(ph, t); in scmi_common_fastchannel_init()
1958 dev_dbg(ph->dev, in scmi_common_fastchannel_init()
1959 "Using valid FC for protocol %X [MSG_ID:%u / RES_ID:%u]\n", in scmi_common_fastchannel_init()
1960 pi->proto->id, message_id, domain); in scmi_common_fastchannel_init()
1965 devm_kfree(ph->dev, db); in scmi_common_fastchannel_init()
1971 ph->xops->xfer_put(ph, t); in scmi_common_fastchannel_init()
1974 dev_warn(ph->dev, in scmi_common_fastchannel_init()
1975 "Failed to get FC for protocol %X [MSG_ID:%u / RES_ID:%u] - ret:%d. Using regular messaging.\n", in scmi_common_fastchannel_init()
1976 pi->proto->id, message_id, domain, ret); in scmi_common_fastchannel_init()
1983 if (db->mask) \
1984 val = ioread##w(db->addr) & db->mask; \
1985 iowrite##w((u##w)db->set | val, db->addr); \
1990 if (!db || !db->addr) in scmi_common_fastchannel_db_ring()
1993 if (db->width == 1) in scmi_common_fastchannel_db_ring()
1995 else if (db->width == 2) in scmi_common_fastchannel_db_ring()
1997 else if (db->width == 4) in scmi_common_fastchannel_db_ring()
1999 else /* db->width == 8 */ in scmi_common_fastchannel_db_ring()
2004 * scmi_protocol_msg_check - Check protocol message attributes
2006 * @ph: A reference to the protocol handle.
2007 * @message_id: The ID of the message to check.
2011 * An helper to check protocol message attributes for a specific protocol
2027 put_unaligned_le32(message_id, t->tx.buf); in scmi_protocol_msg_check()
2030 *attributes = get_unaligned_le32(t->rx.buf); in scmi_protocol_msg_check()
2047 * scmi_revision_area_get - Retrieve version memory area.
2049 * @ph: A reference to the protocol handle.
2051 * A helper to grab the version memory area reference during SCMI Base protocol
2055 * instance underlying this protocol handle.
2062 return pi->handle->version; in scmi_revision_area_get()
2066 * scmi_protocol_version_negotiate - Negotiate protocol version
2068 * @ph: A reference to the protocol handle.
2070 * An helper to negotiate a protocol version different from the latest
2087 /* ... then attempt protocol version negotiation */ in scmi_protocol_version_negotiate()
2093 put_unaligned_le32(pi->proto->supported_version, t->tx.buf); in scmi_protocol_version_negotiate()
2096 pi->negotiated_version = pi->proto->supported_version; in scmi_protocol_version_negotiate()
2104 * scmi_alloc_init_protocol_instance - Allocate and initialize a protocol
2107 * @proto: The protocol descriptor.
2109 * Allocate a new protocol instance descriptor, using the provided @proto
2111 * all resources management is handled via a dedicated per-protocol devres
2115 * Return: A reference to a freshly allocated and initialized protocol instance
2123 int ret = -ENOMEM; in scmi_alloc_init_protocol_instance()
2126 const struct scmi_handle *handle = &info->handle; in scmi_alloc_init_protocol_instance()
2128 /* Protocol specific devres group */ in scmi_alloc_init_protocol_instance()
2129 gid = devres_open_group(handle->dev, NULL, GFP_KERNEL); in scmi_alloc_init_protocol_instance()
2135 pi = devm_kzalloc(handle->dev, sizeof(*pi), GFP_KERNEL); in scmi_alloc_init_protocol_instance()
2139 pi->gid = gid; in scmi_alloc_init_protocol_instance()
2140 pi->proto = proto; in scmi_alloc_init_protocol_instance()
2141 pi->handle = handle; in scmi_alloc_init_protocol_instance()
2142 pi->ph.dev = handle->dev; in scmi_alloc_init_protocol_instance()
2143 pi->ph.xops = &xfer_ops; in scmi_alloc_init_protocol_instance()
2144 pi->ph.hops = &helpers_ops; in scmi_alloc_init_protocol_instance()
2145 pi->ph.set_priv = scmi_set_protocol_priv; in scmi_alloc_init_protocol_instance()
2146 pi->ph.get_priv = scmi_get_protocol_priv; in scmi_alloc_init_protocol_instance()
2147 refcount_set(&pi->users, 1); in scmi_alloc_init_protocol_instance()
2148 /* proto->init is assured NON NULL by scmi_protocol_register */ in scmi_alloc_init_protocol_instance()
2149 ret = pi->proto->instance_init(&pi->ph); in scmi_alloc_init_protocol_instance()
2153 ret = idr_alloc(&info->protocols, pi, proto->id, proto->id + 1, in scmi_alloc_init_protocol_instance()
2155 if (ret != proto->id) in scmi_alloc_init_protocol_instance()
2162 if (pi->proto->events) { in scmi_alloc_init_protocol_instance()
2163 ret = scmi_register_protocol_events(handle, pi->proto->id, in scmi_alloc_init_protocol_instance()
2164 &pi->ph, in scmi_alloc_init_protocol_instance()
2165 pi->proto->events); in scmi_alloc_init_protocol_instance()
2167 dev_warn(handle->dev, in scmi_alloc_init_protocol_instance()
2168 "Protocol:%X - Events Registration Failed - err:%d\n", in scmi_alloc_init_protocol_instance()
2169 pi->proto->id, ret); in scmi_alloc_init_protocol_instance()
2172 devres_close_group(handle->dev, pi->gid); in scmi_alloc_init_protocol_instance()
2173 dev_dbg(handle->dev, "Initialized protocol: 0x%X\n", pi->proto->id); in scmi_alloc_init_protocol_instance()
2175 if (pi->version > proto->supported_version) { in scmi_alloc_init_protocol_instance()
2176 ret = scmi_protocol_version_negotiate(&pi->ph); in scmi_alloc_init_protocol_instance()
2178 dev_info(handle->dev, in scmi_alloc_init_protocol_instance()
2179 "Protocol 0x%X successfully negotiated version 0x%X\n", in scmi_alloc_init_protocol_instance()
2180 proto->id, pi->negotiated_version); in scmi_alloc_init_protocol_instance()
2182 dev_warn(handle->dev, in scmi_alloc_init_protocol_instance()
2183 "Detected UNSUPPORTED higher version 0x%X for protocol 0x%X.\n", in scmi_alloc_init_protocol_instance()
2184 pi->version, pi->proto->id); in scmi_alloc_init_protocol_instance()
2185 dev_warn(handle->dev, in scmi_alloc_init_protocol_instance()
2187 pi->proto->supported_version); in scmi_alloc_init_protocol_instance()
2194 /* Take care to put the protocol module's owner before releasing all */ in scmi_alloc_init_protocol_instance()
2196 devres_release_group(handle->dev, gid); in scmi_alloc_init_protocol_instance()
2202 * scmi_get_protocol_instance - Protocol initialization helper.
2204 * @protocol_id: The protocol being requested.
2206 * In case the required protocol has never been requested before for this
2208 * resource allocation with a dedicated per-protocol devres subgroup.
2210 * Return: A reference to an initialized protocol instance or error on failure:
2211 * in particular returns -EPROBE_DEFER when the desired protocol could
2220 mutex_lock(&info->protocols_mtx); in scmi_get_protocol_instance()
2221 pi = idr_find(&info->protocols, protocol_id); in scmi_get_protocol_instance()
2224 refcount_inc(&pi->users); in scmi_get_protocol_instance()
2228 /* Fails if protocol not registered on bus */ in scmi_get_protocol_instance()
2229 proto = scmi_protocol_get(protocol_id, &info->version); in scmi_get_protocol_instance()
2233 pi = ERR_PTR(-EPROBE_DEFER); in scmi_get_protocol_instance()
2235 mutex_unlock(&info->protocols_mtx); in scmi_get_protocol_instance()
2241 * scmi_protocol_acquire - Protocol acquire
2243 * @protocol_id: The protocol being requested.
2245 * Register a new user for the requested protocol on the specified SCMI
2248 * Return: 0 if protocol was acquired successfully.
2256 * scmi_protocol_release - Protocol de-initialization helper.
2258 * @protocol_id: The protocol being requested.
2260 * Remove one user for the specified protocol and triggers de-initialization
2261 * and resources de-allocation once the last user has gone.
2268 mutex_lock(&info->protocols_mtx); in scmi_protocol_release()
2269 pi = idr_find(&info->protocols, protocol_id); in scmi_protocol_release()
2273 if (refcount_dec_and_test(&pi->users)) { in scmi_protocol_release()
2274 void *gid = pi->gid; in scmi_protocol_release()
2276 if (pi->proto->events) in scmi_protocol_release()
2279 if (pi->proto->instance_deinit) in scmi_protocol_release()
2280 pi->proto->instance_deinit(&pi->ph); in scmi_protocol_release()
2282 idr_remove(&info->protocols, protocol_id); in scmi_protocol_release()
2284 scmi_protocol_put(pi->proto); in scmi_protocol_release()
2286 devres_release_group(handle->dev, gid); in scmi_protocol_release()
2287 dev_dbg(handle->dev, "De-Initialized protocol: 0x%X\n", in scmi_protocol_release()
2292 mutex_unlock(&info->protocols_mtx); in scmi_protocol_release()
2299 struct scmi_info *info = handle_to_scmi_info(pi->handle); in scmi_setup_protocol_implemented()
2301 info->protocols_imp = prot_imp; in scmi_setup_protocol_implemented()
2309 struct scmi_revision_info *rev = handle->version; in scmi_is_protocol_implemented()
2311 if (!info->protocols_imp) in scmi_is_protocol_implemented()
2314 for (i = 0; i < rev->num_protocols; i++) in scmi_is_protocol_implemented()
2315 if (info->protocols_imp[i] == prot_id) in scmi_is_protocol_implemented()
2329 scmi_protocol_release(dres->handle, dres->protocol_id); in scmi_devm_release_protocol()
2341 return ERR_PTR(-ENOMEM); in scmi_devres_protocol_instance_get()
2343 pi = scmi_get_protocol_instance(sdev->handle, protocol_id); in scmi_devres_protocol_instance_get()
2349 dres->handle = sdev->handle; in scmi_devres_protocol_instance_get()
2350 dres->protocol_id = protocol_id; in scmi_devres_protocol_instance_get()
2351 devres_add(&sdev->dev, dres); in scmi_devres_protocol_instance_get()
2357 * scmi_devm_protocol_get - Devres managed get protocol operations and handle
2360 * @protocol_id: The protocol being requested.
2361 * @ph: A pointer reference used to pass back the associated protocol handle.
2363 * Get hold of a protocol accounting for its usage, eventually triggering its
2364 * initialization, and returning the protocol specific operations and related
2365 * protocol handle which will be used as first argument in most of the
2367 * Being a devres based managed method, protocol hold will be automatically
2368 * released, and possibly de-initialized on last user, once the SCMI driver
2371 * Return: A reference to the requested protocol operations or error.
2381 return ERR_PTR(-EINVAL); in scmi_devm_protocol_get()
2387 *ph = &pi->ph; in scmi_devm_protocol_get()
2389 return pi->proto->ops; in scmi_devm_protocol_get()
2393 * scmi_devm_protocol_acquire - Devres managed helper to get hold of a protocol
2396 * @protocol_id: The protocol being requested.
2398 * Get hold of a protocol accounting for its usage, possibly triggering its
2399 * initialization but without getting access to its protocol specific operations
2402 * Being a devres based managed method, protocol hold will be automatically
2403 * released, and possibly de-initialized on last user, once the SCMI driver
2427 return dres->protocol_id == *((u8 *)data); in scmi_devm_protocol_match()
2431 * scmi_devm_protocol_put - Devres managed put protocol operations and handle
2434 * @protocol_id: The protocol being requested.
2436 * Explicitly release a protocol hold previously obtained calling the above
2443 ret = devres_release(&sdev->dev, scmi_devm_release_protocol, in scmi_devm_protocol_put()
2449 * scmi_is_transport_atomic - Method to check if underlying transport for an
2464 ret = info->desc->atomic_enabled && in scmi_is_transport_atomic()
2465 is_transport_polling_capable(info->desc); in scmi_is_transport_atomic()
2467 *atomic_threshold = info->desc->atomic_threshold; in scmi_is_transport_atomic()
2473 * scmi_handle_get() - Get the SCMI handle for a device
2478 * and is expected to be maintained by caller of SCMI protocol library.
2492 if (dev->parent == info->dev) { in scmi_handle_get()
2493 info->users++; in scmi_handle_get()
2494 handle = &info->handle; in scmi_handle_get()
2504 * scmi_handle_put() - Release the handle acquired by scmi_handle_get
2509 * and is expected to be maintained by caller of SCMI protocol library.
2513 * if null was passed, it returns -EINVAL;
2520 return -EINVAL; in scmi_handle_put()
2524 if (!WARN_ON(!info->users)) in scmi_handle_put()
2525 info->users--; in scmi_handle_put()
2543 scmi_dev->handle = scmi_handle_get(&scmi_dev->dev); in scmi_set_handle()
2544 if (scmi_dev->handle) in scmi_set_handle()
2545 scmi_device_link_add(&scmi_dev->dev, scmi_dev->handle->dev); in scmi_set_handle()
2553 struct device *dev = sinfo->dev; in __scmi_xfer_info_init()
2554 const struct scmi_desc *desc = sinfo->desc; in __scmi_xfer_info_init()
2556 /* Pre-allocated messages, no more than what hdr.seq can support */ in __scmi_xfer_info_init()
2557 if (WARN_ON(!info->max_msg || info->max_msg > MSG_TOKEN_MAX)) { in __scmi_xfer_info_init()
2559 "Invalid maximum messages %d, not in range [1 - %lu]\n", in __scmi_xfer_info_init()
2560 info->max_msg, MSG_TOKEN_MAX); in __scmi_xfer_info_init()
2561 return -EINVAL; in __scmi_xfer_info_init()
2564 hash_init(info->pending_xfers); in __scmi_xfer_info_init()
2567 info->xfer_alloc_table = devm_bitmap_zalloc(dev, MSG_TOKEN_MAX, in __scmi_xfer_info_init()
2569 if (!info->xfer_alloc_table) in __scmi_xfer_info_init()
2570 return -ENOMEM; in __scmi_xfer_info_init()
2574 * pre-initialize the buffer pointer to pre-allocated buffers and in __scmi_xfer_info_init()
2577 INIT_HLIST_HEAD(&info->free_xfers); in __scmi_xfer_info_init()
2578 for (i = 0; i < info->max_msg; i++) { in __scmi_xfer_info_init()
2581 return -ENOMEM; in __scmi_xfer_info_init()
2583 xfer->rx.buf = devm_kcalloc(dev, sizeof(u8), desc->max_msg_size, in __scmi_xfer_info_init()
2585 if (!xfer->rx.buf) in __scmi_xfer_info_init()
2586 return -ENOMEM; in __scmi_xfer_info_init()
2588 xfer->tx.buf = xfer->rx.buf; in __scmi_xfer_info_init()
2589 init_completion(&xfer->done); in __scmi_xfer_info_init()
2590 spin_lock_init(&xfer->lock); in __scmi_xfer_info_init()
2593 hlist_add_head(&xfer->node, &info->free_xfers); in __scmi_xfer_info_init()
2596 spin_lock_init(&info->xfer_lock); in __scmi_xfer_info_init()
2603 const struct scmi_desc *desc = sinfo->desc; in scmi_channels_max_msg_configure()
2605 if (!desc->ops->get_max_msg) { in scmi_channels_max_msg_configure()
2606 sinfo->tx_minfo.max_msg = desc->max_msg; in scmi_channels_max_msg_configure()
2607 sinfo->rx_minfo.max_msg = desc->max_msg; in scmi_channels_max_msg_configure()
2611 base_cinfo = idr_find(&sinfo->tx_idr, SCMI_PROTOCOL_BASE); in scmi_channels_max_msg_configure()
2613 return -EINVAL; in scmi_channels_max_msg_configure()
2614 sinfo->tx_minfo.max_msg = desc->ops->get_max_msg(base_cinfo); in scmi_channels_max_msg_configure()
2617 base_cinfo = idr_find(&sinfo->rx_idr, SCMI_PROTOCOL_BASE); in scmi_channels_max_msg_configure()
2619 sinfo->rx_minfo.max_msg = in scmi_channels_max_msg_configure()
2620 desc->ops->get_max_msg(base_cinfo); in scmi_channels_max_msg_configure()
2634 ret = __scmi_xfer_info_init(sinfo, &sinfo->tx_minfo); in scmi_xfer_info_init()
2635 if (!ret && !idr_is_empty(&sinfo->rx_idr)) in scmi_xfer_info_init()
2636 ret = __scmi_xfer_info_init(sinfo, &sinfo->rx_minfo); in scmi_xfer_info_init()
2652 idr = tx ? &info->tx_idr : &info->rx_idr; in scmi_chan_setup()
2654 if (!info->desc->ops->chan_available(of_node, idx)) { in scmi_chan_setup()
2657 return -EINVAL; in scmi_chan_setup()
2661 cinfo = devm_kzalloc(info->dev, sizeof(*cinfo), GFP_KERNEL); in scmi_chan_setup()
2663 return -ENOMEM; in scmi_chan_setup()
2665 cinfo->is_p2a = !tx; in scmi_chan_setup()
2666 cinfo->rx_timeout_ms = info->desc->max_rx_timeout_ms; in scmi_chan_setup()
2667 cinfo->max_msg_size = info->desc->max_msg_size; in scmi_chan_setup()
2673 tdev = scmi_device_create(of_node, info->dev, prot_id, name); in scmi_chan_setup()
2675 dev_err(info->dev, in scmi_chan_setup()
2677 devm_kfree(info->dev, cinfo); in scmi_chan_setup()
2678 return -EINVAL; in scmi_chan_setup()
2682 cinfo->id = prot_id; in scmi_chan_setup()
2683 cinfo->dev = &tdev->dev; in scmi_chan_setup()
2684 ret = info->desc->ops->chan_setup(cinfo, info->dev, tx); in scmi_chan_setup()
2687 scmi_device_destroy(info->dev, prot_id, name); in scmi_chan_setup()
2688 devm_kfree(info->dev, cinfo); in scmi_chan_setup()
2692 if (tx && is_polling_required(cinfo, info->desc)) { in scmi_chan_setup()
2693 if (is_transport_polling_capable(info->desc)) in scmi_chan_setup()
2694 dev_info(&tdev->dev, in scmi_chan_setup()
2695 "Enabled polling mode TX channel - prot_id:%d\n", in scmi_chan_setup()
2698 dev_warn(&tdev->dev, in scmi_chan_setup()
2705 dev_err(info->dev, in scmi_chan_setup()
2710 scmi_device_destroy(info->dev, prot_id, name); in scmi_chan_setup()
2711 devm_kfree(info->dev, cinfo); in scmi_chan_setup()
2716 cinfo->handle = &info->handle; in scmi_chan_setup()
2729 if (ret && ret != -ENOMEM) in scmi_txrx_setup()
2734 dev_err(info->dev, in scmi_txrx_setup()
2735 "failed to setup channel for protocol:0x%X\n", prot_id); in scmi_txrx_setup()
2741 * scmi_channels_setup - Helper to initialize all required channels
2752 * protocol defined in the DT, a distinct freshly initialized channel is
2753 * created only if the DT node for the protocol at hand describes a dedicated
2754 * channel: in all the other cases the common BASE protocol channel is reused.
2761 struct device_node *top_np = info->dev->of_node; in scmi_channels_setup()
2775 dev_err(info->dev, in scmi_channels_setup()
2776 "Out of range protocol %d\n", prot_id); in scmi_channels_setup()
2786 static int scmi_chan_destroy(int id, void *p, void *idr) in scmi_chan_destroy() argument
2790 if (cinfo->dev) { in scmi_chan_destroy()
2791 struct scmi_info *info = handle_to_scmi_info(cinfo->handle); in scmi_chan_destroy()
2792 struct scmi_device *sdev = to_scmi_dev(cinfo->dev); in scmi_chan_destroy()
2794 of_node_put(cinfo->dev->of_node); in scmi_chan_destroy()
2795 scmi_device_destroy(info->dev, id, sdev->name); in scmi_chan_destroy()
2796 cinfo->dev = NULL; in scmi_chan_destroy()
2799 idr_remove(idr, id); in scmi_chan_destroy()
2807 idr_for_each(idr, info->desc->ops->chan_free, idr); in scmi_cleanup_channels()
2817 scmi_cleanup_channels(info, &info->tx_idr); in scmi_cleanup_txrx_channels()
2819 scmi_cleanup_channels(info, &info->rx_idr); in scmi_cleanup_txrx_channels()
2829 if (!strncmp(sdev->name, "__scmi_transport_device", 23) || in scmi_bus_notifier()
2830 sdev->dev.parent != info->dev) in scmi_bus_notifier()
2839 scmi_handle_put(sdev->handle); in scmi_bus_notifier()
2840 sdev->handle = NULL; in scmi_bus_notifier()
2846 dev_dbg(info->dev, "Device %s (%s) is now %s\n", dev_name(&sdev->dev), in scmi_bus_notifier()
2847 sdev->name, action == BUS_NOTIFY_BIND_DRIVER ? in scmi_bus_notifier()
2860 np = idr_find(&info->active_protocols, id_table->protocol_id); in scmi_device_request_notifier()
2864 dev_dbg(info->dev, "%sRequested device (%s) for protocol 0x%x\n", in scmi_device_request_notifier()
2865 action == SCMI_BUS_NOTIFY_DEVICE_REQUEST ? "" : "UN-", in scmi_device_request_notifier()
2866 id_table->name, id_table->protocol_id); in scmi_device_request_notifier()
2870 scmi_create_protocol_devices(np, info, id_table->protocol_id, in scmi_device_request_notifier()
2871 id_table->name); in scmi_device_request_notifier()
2874 scmi_destroy_protocol_devices(info, id_table->protocol_id, in scmi_device_request_notifier()
2875 id_table->name); in scmi_device_request_notifier()
2904 struct scmi_debug_info *dbg = filp->private_data; in reset_all_on_write()
2907 atomic_set(&dbg->counters[i], 0); in reset_all_on_write()
2928 &dbg->counters[idx]); in scmi_debugfs_counters_setup()
2940 debugfs_remove_recursive(dbg->top_dentry); in scmi_debugfs_common_cleanup()
2941 kfree(dbg->name); in scmi_debugfs_common_cleanup()
2942 kfree(dbg->type); in scmi_debugfs_common_cleanup()
2952 dbg = devm_kzalloc(info->dev, sizeof(*dbg), GFP_KERNEL); in scmi_debugfs_common_setup()
2956 dbg->name = kstrdup(of_node_full_name(info->dev->of_node), GFP_KERNEL); in scmi_debugfs_common_setup()
2957 if (!dbg->name) { in scmi_debugfs_common_setup()
2958 devm_kfree(info->dev, dbg); in scmi_debugfs_common_setup()
2962 of_property_read_string(info->dev->of_node, "compatible", &c_ptr); in scmi_debugfs_common_setup()
2963 dbg->type = kstrdup(c_ptr, GFP_KERNEL); in scmi_debugfs_common_setup()
2964 if (!dbg->type) { in scmi_debugfs_common_setup()
2965 kfree(dbg->name); in scmi_debugfs_common_setup()
2966 devm_kfree(info->dev, dbg); in scmi_debugfs_common_setup()
2970 snprintf(top_dir, 16, "%d", info->id); in scmi_debugfs_common_setup()
2974 dbg->is_atomic = info->desc->atomic_enabled && in scmi_debugfs_common_setup()
2975 is_transport_polling_capable(info->desc); in scmi_debugfs_common_setup()
2978 (char **)&dbg->name); in scmi_debugfs_common_setup()
2981 (u32 *)&info->desc->atomic_threshold); in scmi_debugfs_common_setup()
2983 debugfs_create_str("type", 0400, trans, (char **)&dbg->type); in scmi_debugfs_common_setup()
2985 debugfs_create_bool("is_atomic", 0400, trans, &dbg->is_atomic); in scmi_debugfs_common_setup()
2988 (u32 *)&info->desc->max_rx_timeout_ms); in scmi_debugfs_common_setup()
2991 (u32 *)&info->desc->max_msg_size); in scmi_debugfs_common_setup()
2994 (u32 *)&info->tx_minfo.max_msg); in scmi_debugfs_common_setup()
2997 (u32 *)&info->rx_minfo.max_msg); in scmi_debugfs_common_setup()
3002 dbg->top_dentry = top_dentry; in scmi_debugfs_common_setup()
3004 if (devm_add_action_or_reset(info->dev, in scmi_debugfs_common_setup()
3013 int id, num_chans = 0, ret = 0; in scmi_debugfs_raw_mode_setup() local
3018 if (!info->dbg) in scmi_debugfs_raw_mode_setup()
3019 return -EINVAL; in scmi_debugfs_raw_mode_setup()
3022 idr_for_each_entry(&info->tx_idr, cinfo, id) { in scmi_debugfs_raw_mode_setup()
3028 dev_warn(info->dev, in scmi_debugfs_raw_mode_setup()
3029 "SCMI RAW - Error enumerating channels\n"); in scmi_debugfs_raw_mode_setup()
3033 if (!test_bit(cinfo->id, protos)) { in scmi_debugfs_raw_mode_setup()
3034 channels[num_chans++] = cinfo->id; in scmi_debugfs_raw_mode_setup()
3035 set_bit(cinfo->id, protos); in scmi_debugfs_raw_mode_setup()
3039 info->raw = scmi_raw_mode_init(&info->handle, info->dbg->top_dentry, in scmi_debugfs_raw_mode_setup()
3040 info->id, channels, num_chans, in scmi_debugfs_raw_mode_setup()
3041 info->desc, info->tx_minfo.max_msg); in scmi_debugfs_raw_mode_setup()
3042 if (IS_ERR(info->raw)) { in scmi_debugfs_raw_mode_setup()
3043 dev_err(info->dev, "Failed to initialize SCMI RAW Mode !\n"); in scmi_debugfs_raw_mode_setup()
3044 ret = PTR_ERR(info->raw); in scmi_debugfs_raw_mode_setup()
3045 info->raw = NULL; in scmi_debugfs_raw_mode_setup()
3057 if (!trans || !trans->supplier || !trans->core_ops) in scmi_transport_setup()
3060 if (!device_link_add(dev, trans->supplier, DL_FLAG_AUTOREMOVE_CONSUMER)) { in scmi_transport_setup()
3067 *trans->core_ops = &scmi_trans_core_ops; in scmi_transport_setup()
3069 dev_info(dev, "Using %s\n", dev_driver_string(trans->supplier)); in scmi_transport_setup()
3071 ret = of_property_read_u32(dev->of_node, "arm,max-rx-timeout-ms", in scmi_transport_setup()
3072 &trans->desc.max_rx_timeout_ms); in scmi_transport_setup()
3073 if (ret && ret != -EINVAL) in scmi_transport_setup()
3074 dev_err(dev, "Malformed arm,max-rx-timeout-ms DT property.\n"); in scmi_transport_setup()
3076 ret = of_property_read_u32(dev->of_node, "arm,max-msg-size", in scmi_transport_setup()
3077 &trans->desc.max_msg_size); in scmi_transport_setup()
3078 if (ret && ret != -EINVAL) in scmi_transport_setup()
3079 dev_err(dev, "Malformed arm,max-msg-size DT property.\n"); in scmi_transport_setup()
3081 ret = of_property_read_u32(dev->of_node, "arm,max-msg", in scmi_transport_setup()
3082 &trans->desc.max_msg); in scmi_transport_setup()
3083 if (ret && ret != -EINVAL) in scmi_transport_setup()
3084 dev_err(dev, "Malformed arm,max-msg DT property.\n"); in scmi_transport_setup()
3087 "SCMI max-rx-timeout: %dms / max-msg-size: %dbytes / max-msg: %d\n", in scmi_transport_setup()
3088 trans->desc.max_rx_timeout_ms, trans->desc.max_msg_size, in scmi_transport_setup()
3089 trans->desc.max_msg); in scmi_transport_setup()
3092 if (!of_property_read_u32(dev->of_node, "atomic-threshold-us", in scmi_transport_setup()
3093 &trans->desc.atomic_threshold)) in scmi_transport_setup()
3096 trans->desc.atomic_threshold); in scmi_transport_setup()
3098 return &trans->desc; in scmi_transport_setup()
3109 struct device *dev = &pdev->dev; in scmi_probe()
3110 struct device_node *child, *np = dev->of_node; in scmi_probe()
3115 ret = -EINVAL; in scmi_probe()
3121 return -ENOMEM; in scmi_probe()
3123 info->id = ida_alloc_min(&scmi_id, 0, GFP_KERNEL); in scmi_probe()
3124 if (info->id < 0) in scmi_probe()
3125 return info->id; in scmi_probe()
3127 info->dev = dev; in scmi_probe()
3128 info->desc = desc; in scmi_probe()
3129 info->bus_nb.notifier_call = scmi_bus_notifier; in scmi_probe()
3130 info->dev_req_nb.notifier_call = scmi_device_request_notifier; in scmi_probe()
3131 INIT_LIST_HEAD(&info->node); in scmi_probe()
3132 idr_init(&info->protocols); in scmi_probe()
3133 mutex_init(&info->protocols_mtx); in scmi_probe()
3134 idr_init(&info->active_protocols); in scmi_probe()
3135 mutex_init(&info->devreq_mtx); in scmi_probe()
3138 idr_init(&info->tx_idr); in scmi_probe()
3139 idr_init(&info->rx_idr); in scmi_probe()
3141 handle = &info->handle; in scmi_probe()
3142 handle->dev = info->dev; in scmi_probe()
3143 handle->version = &info->version; in scmi_probe()
3144 handle->devm_protocol_acquire = scmi_devm_protocol_acquire; in scmi_probe()
3145 handle->devm_protocol_get = scmi_devm_protocol_get; in scmi_probe()
3146 handle->devm_protocol_put = scmi_devm_protocol_put; in scmi_probe()
3147 handle->is_transport_atomic = scmi_is_transport_atomic; in scmi_probe()
3156 ret = bus_register_notifier(&scmi_bus_type, &info->bus_nb); in scmi_probe()
3163 &info->dev_req_nb); in scmi_probe()
3176 info->dbg = scmi_debugfs_common_setup(info); in scmi_probe()
3177 if (!info->dbg) in scmi_probe()
3198 if (info->desc->atomic_enabled && in scmi_probe()
3199 !is_transport_polling_capable(info->desc)) in scmi_probe()
3204 * Trigger SCMI Base protocol initialization. in scmi_probe()
3219 list_add_tail(&info->node, &scmi_list); in scmi_probe()
3229 dev_err(dev, "Out of range protocol %d\n", prot_id); in scmi_probe()
3232 dev_err(dev, "SCMI protocol %d not implemented\n", in scmi_probe()
3238 * Save this valid DT protocol descriptor amongst in scmi_probe()
3241 ret = idr_alloc(&info->active_protocols, child, in scmi_probe()
3244 dev_err(dev, "SCMI protocol %d already activated. Skip\n", in scmi_probe()
3257 scmi_raw_mode_cleanup(info->raw); in scmi_probe()
3258 scmi_notification_exit(&info->handle); in scmi_probe()
3261 &info->dev_req_nb); in scmi_probe()
3263 bus_unregister_notifier(&scmi_bus_type, &info->bus_nb); in scmi_probe()
3267 ida_free(&scmi_id, info->id); in scmi_probe()
3275 int id; in scmi_remove() local
3280 scmi_raw_mode_cleanup(info->raw); in scmi_remove()
3283 if (info->users) in scmi_remove()
3284 dev_warn(&pdev->dev, in scmi_remove()
3286 list_del(&info->node); in scmi_remove()
3289 scmi_notification_exit(&info->handle); in scmi_remove()
3291 mutex_lock(&info->protocols_mtx); in scmi_remove()
3292 idr_destroy(&info->protocols); in scmi_remove()
3293 mutex_unlock(&info->protocols_mtx); in scmi_remove()
3295 idr_for_each_entry(&info->active_protocols, child, id) in scmi_remove()
3297 idr_destroy(&info->active_protocols); in scmi_remove()
3300 &info->dev_req_nb); in scmi_remove()
3301 bus_unregister_notifier(&scmi_bus_type, &info->bus_nb); in scmi_remove()
3306 ida_free(&scmi_id, info->id); in scmi_remove()
3314 return sprintf(buf, "%u.%u\n", info->version.major_ver, in protocol_version_show()
3315 info->version.minor_ver); in protocol_version_show()
3324 return sprintf(buf, "0x%x\n", info->version.impl_ver); in firmware_version_show()
3333 return sprintf(buf, "%s\n", info->version.vendor_id); in vendor_id_show()
3342 return sprintf(buf, "%s\n", info->version.sub_vendor_id); in sub_vendor_id_show()
3357 .name = "arm-scmi",
3382 return -EINVAL; in scmi_driver_init()
3429 MODULE_ALIAS("platform:arm-scmi");
3431 MODULE_DESCRIPTION("ARM SCMI protocol driver");