Lines Matching +full:sci +full:- +full:dev +full:- +full:id

1 // SPDX-License-Identifier: GPL-2.0
5 * Copyright (C) 2015-2022 Texas Instruments Incorporated - https://www.ti.com/
25 #include <linux/soc/ti/ti-msgmgr.h>
31 /* List of all TI SCI devices active in system */
37 * struct ti_sci_xfer - Structure representing a message flow
41 * Since we work with request-ACK protocol, we can
54 * struct ti_sci_xfers_info - Structure to manage transfer information
72 * struct ti_sci_desc - Description of SoC integration
87 * struct ti_sci_info - Structure representing a TI SCI instance
88 * @dev: Device pointer
95 * @handle: Instance of TI SCI handle to send to clients.
101 * @host_id: Host ID
105 struct device *dev; member
130 * ti_sci_debug_show() - Helper to dump the debug log
138 struct ti_sci_info *info = s->private; in ti_sci_debug_show()
140 memcpy_fromio(info->debug_buffer, info->debug_region, in ti_sci_debug_show()
141 info->debug_region_size); in ti_sci_debug_show()
146 * in the buffer as is - we expect the messages to be self explanatory. in ti_sci_debug_show()
148 seq_puts(s, info->debug_buffer); in ti_sci_debug_show()
156 * ti_sci_debugfs_create() - Create log debug file
158 * @info: Pointer to SCI entity information
165 struct device *dev = &pdev->dev; in ti_sci_debugfs_create() local
172 info->debug_region = devm_ioremap_resource(dev, res); in ti_sci_debugfs_create()
173 if (IS_ERR(info->debug_region)) in ti_sci_debugfs_create()
175 info->debug_region_size = resource_size(res); in ti_sci_debugfs_create()
177 info->debug_buffer = devm_kcalloc(dev, info->debug_region_size + 1, in ti_sci_debugfs_create()
179 if (!info->debug_buffer) in ti_sci_debugfs_create()
180 return -ENOMEM; in ti_sci_debugfs_create()
182 info->debug_buffer[info->debug_region_size] = 0; in ti_sci_debugfs_create()
185 dev_name(dev)); in ti_sci_debugfs_create()
186 info->d = debugfs_create_file(debug_name, 0444, NULL, info, in ti_sci_debugfs_create()
188 if (IS_ERR(info->d)) in ti_sci_debugfs_create()
189 return PTR_ERR(info->d); in ti_sci_debugfs_create()
191 dev_dbg(dev, "Debug region => %p, size = %zu bytes, resource: %pr\n", in ti_sci_debugfs_create()
192 info->debug_region, info->debug_region_size, res); in ti_sci_debugfs_create()
197 static inline int ti_sci_debugfs_create(struct platform_device *dev, in ti_sci_debugfs_create() argument
203 static inline void ti_sci_debugfs_destroy(struct platform_device *dev, in ti_sci_debugfs_destroy() argument
210 * ti_sci_dump_header_dbg() - Helper to dump a message header.
211 * @dev: Device pointer corresponding to the SCI entity
214 static inline void ti_sci_dump_header_dbg(struct device *dev, in ti_sci_dump_header_dbg() argument
217 dev_dbg(dev, "MSGHDR:type=0x%04x host=0x%02x seq=0x%02x flags=0x%08x\n", in ti_sci_dump_header_dbg()
218 hdr->type, hdr->host, hdr->seq, hdr->flags); in ti_sci_dump_header_dbg()
222 * ti_sci_rx_callback() - mailbox client callback for receive messages
235 struct device *dev = info->dev; in ti_sci_rx_callback() local
236 struct ti_sci_xfers_info *minfo = &info->minfo; in ti_sci_rx_callback()
238 struct ti_sci_msg_hdr *hdr = (struct ti_sci_msg_hdr *)mbox_msg->buf; in ti_sci_rx_callback()
242 xfer_id = hdr->seq; in ti_sci_rx_callback()
248 if (!test_bit(xfer_id, minfo->xfer_alloc_table)) { in ti_sci_rx_callback()
249 dev_err(dev, "Message for %d is not expected!\n", xfer_id); in ti_sci_rx_callback()
253 xfer = &minfo->xfer_block[xfer_id]; in ti_sci_rx_callback()
256 if (mbox_msg->len > info->desc->max_msg_size) { in ti_sci_rx_callback()
257 dev_err(dev, "Unable to handle %zu xfer(max %d)\n", in ti_sci_rx_callback()
258 mbox_msg->len, info->desc->max_msg_size); in ti_sci_rx_callback()
259 ti_sci_dump_header_dbg(dev, hdr); in ti_sci_rx_callback()
262 if (mbox_msg->len < xfer->rx_len) { in ti_sci_rx_callback()
263 dev_err(dev, "Recv xfer %zu < expected %d length\n", in ti_sci_rx_callback()
264 mbox_msg->len, xfer->rx_len); in ti_sci_rx_callback()
265 ti_sci_dump_header_dbg(dev, hdr); in ti_sci_rx_callback()
269 ti_sci_dump_header_dbg(dev, hdr); in ti_sci_rx_callback()
271 memcpy(xfer->xfer_buf, mbox_msg->buf, xfer->rx_len); in ti_sci_rx_callback()
272 complete(&xfer->done); in ti_sci_rx_callback()
276 * ti_sci_get_one_xfer() - Allocate one message
277 * @info: Pointer to SCI entity information
287 * for the SCI entity. Further, this also holds a spinlock to maintain integrity
297 struct ti_sci_xfers_info *minfo = &info->minfo; in ti_sci_get_one_xfer()
307 if (rx_message_size > info->desc->max_msg_size || in ti_sci_get_one_xfer()
308 tx_message_size > info->desc->max_msg_size || in ti_sci_get_one_xfer()
310 return ERR_PTR(-ERANGE); in ti_sci_get_one_xfer()
317 timeout = msecs_to_jiffies(info->desc->max_rx_timeout_ms) * 5; in ti_sci_get_one_xfer()
318 ret = down_timeout(&minfo->sem_xfer_count, timeout); in ti_sci_get_one_xfer()
323 spin_lock_irqsave(&minfo->xfer_lock, flags); in ti_sci_get_one_xfer()
324 bit_pos = find_first_zero_bit(minfo->xfer_alloc_table, in ti_sci_get_one_xfer()
325 info->desc->max_msgs); in ti_sci_get_one_xfer()
326 set_bit(bit_pos, minfo->xfer_alloc_table); in ti_sci_get_one_xfer()
327 spin_unlock_irqrestore(&minfo->xfer_lock, flags); in ti_sci_get_one_xfer()
331 * fit in hdr.seq - NOTE: this improves access latencies in ti_sci_get_one_xfer()
338 xfer = &minfo->xfer_block[xfer_id]; in ti_sci_get_one_xfer()
340 hdr = (struct ti_sci_msg_hdr *)xfer->tx_message.buf; in ti_sci_get_one_xfer()
341 xfer->tx_message.len = tx_message_size; in ti_sci_get_one_xfer()
342 xfer->tx_message.chan_rx = info->chan_rx; in ti_sci_get_one_xfer()
343 xfer->tx_message.timeout_rx_ms = info->desc->max_rx_timeout_ms; in ti_sci_get_one_xfer()
344 xfer->rx_len = (u8)rx_message_size; in ti_sci_get_one_xfer()
346 reinit_completion(&xfer->done); in ti_sci_get_one_xfer()
348 hdr->seq = xfer_id; in ti_sci_get_one_xfer()
349 hdr->type = msg_type; in ti_sci_get_one_xfer()
350 hdr->host = info->host_id; in ti_sci_get_one_xfer()
351 hdr->flags = msg_flags; in ti_sci_get_one_xfer()
357 * ti_sci_put_one_xfer() - Release a message
370 hdr = (struct ti_sci_msg_hdr *)xfer->tx_message.buf; in ti_sci_put_one_xfer()
371 xfer_id = hdr->seq; in ti_sci_put_one_xfer()
378 spin_lock_irqsave(&minfo->xfer_lock, flags); in ti_sci_put_one_xfer()
379 clear_bit(xfer_id, minfo->xfer_alloc_table); in ti_sci_put_one_xfer()
380 spin_unlock_irqrestore(&minfo->xfer_lock, flags); in ti_sci_put_one_xfer()
383 up(&minfo->sem_xfer_count); in ti_sci_put_one_xfer()
387 * ti_sci_do_xfer() - Do one transfer
388 * @info: Pointer to SCI entity information
391 * Return: -ETIMEDOUT in case of no response, if transmit error,
400 struct device *dev = info->dev; in ti_sci_do_xfer() local
403 ret = mbox_send_message(info->chan_tx, &xfer->tx_message); in ti_sci_do_xfer()
411 timeout = msecs_to_jiffies(info->desc->max_rx_timeout_ms); in ti_sci_do_xfer()
412 if (!wait_for_completion_timeout(&xfer->done, timeout)) in ti_sci_do_xfer()
413 ret = -ETIMEDOUT; in ti_sci_do_xfer()
421 info->desc->max_rx_timeout_ms * 1000, in ti_sci_do_xfer()
422 false, &xfer->done); in ti_sci_do_xfer()
425 if (ret == -ETIMEDOUT) in ti_sci_do_xfer()
426 dev_err(dev, "Mbox timedout in resp(caller: %pS)\n", in ti_sci_do_xfer()
435 mbox_client_txdone(info->chan_tx, ret); in ti_sci_do_xfer()
441 * ti_sci_cmd_get_revision() - command to get the revision of the SCI entity
442 * @info: Pointer to SCI entity information
444 * Updates the SCI information in the internal data structure.
450 struct device *dev = info->dev; in ti_sci_cmd_get_revision() local
451 struct ti_sci_handle *handle = &info->handle; in ti_sci_cmd_get_revision()
452 struct ti_sci_version_info *ver = &handle->version; in ti_sci_cmd_get_revision()
463 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_cmd_get_revision()
467 rev_info = (struct ti_sci_msg_resp_version *)xfer->xfer_buf; in ti_sci_cmd_get_revision()
471 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_cmd_get_revision()
475 ver->abi_major = rev_info->abi_major; in ti_sci_cmd_get_revision()
476 ver->abi_minor = rev_info->abi_minor; in ti_sci_cmd_get_revision()
477 ver->firmware_revision = rev_info->firmware_revision; in ti_sci_cmd_get_revision()
478 strscpy(ver->firmware_description, rev_info->firmware_description, in ti_sci_cmd_get_revision()
479 sizeof(ver->firmware_description)); in ti_sci_cmd_get_revision()
482 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_get_revision()
487 * ti_sci_is_response_ack() - Generic ACK/NACK message checkup
496 return hdr->flags & TI_SCI_FLAG_RESP_GENERIC_ACK ? true : false; in ti_sci_is_response_ack()
500 * ti_sci_set_device_state() - Set device state helper
501 * @handle: pointer to TI SCI handle
502 * @id: Device identifier
509 u32 id, u32 flags, u8 state) in ti_sci_set_device_state() argument
515 struct device *dev; in ti_sci_set_device_state() local
521 return -EINVAL; in ti_sci_set_device_state()
524 dev = info->dev; in ti_sci_set_device_state()
531 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_set_device_state()
534 req = (struct ti_sci_msg_req_set_device_state *)xfer->xfer_buf; in ti_sci_set_device_state()
535 req->id = id; in ti_sci_set_device_state()
536 req->state = state; in ti_sci_set_device_state()
540 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_set_device_state()
544 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_set_device_state()
546 ret = ti_sci_is_response_ack(resp) ? 0 : -ENODEV; in ti_sci_set_device_state()
549 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_set_device_state()
555 * ti_sci_get_device_state() - Get device state helper
557 * @id: Device Identifier
566 u32 id, u32 *clcnt, u32 *resets, in ti_sci_get_device_state() argument
573 struct device *dev; in ti_sci_get_device_state() local
579 return -EINVAL; in ti_sci_get_device_state()
582 return -EINVAL; in ti_sci_get_device_state()
585 dev = info->dev; in ti_sci_get_device_state()
592 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_get_device_state()
595 req = (struct ti_sci_msg_req_get_device_state *)xfer->xfer_buf; in ti_sci_get_device_state()
596 req->id = id; in ti_sci_get_device_state()
600 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_get_device_state()
604 resp = (struct ti_sci_msg_resp_get_device_state *)xfer->xfer_buf; in ti_sci_get_device_state()
606 ret = -ENODEV; in ti_sci_get_device_state()
611 *clcnt = resp->context_loss_count; in ti_sci_get_device_state()
613 *resets = resp->resets; in ti_sci_get_device_state()
615 *p_state = resp->programmed_state; in ti_sci_get_device_state()
617 *c_state = resp->current_state; in ti_sci_get_device_state()
619 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_get_device_state()
625 * ti_sci_cmd_get_device() - command to request for device managed by TISCI
628 * @id: Device Identifier
630 * Request for the device - NOTE: the client MUST maintain integrity of
636 static int ti_sci_cmd_get_device(const struct ti_sci_handle *handle, u32 id) in ti_sci_cmd_get_device() argument
638 return ti_sci_set_device_state(handle, id, 0, in ti_sci_cmd_get_device()
643 * ti_sci_cmd_get_device_exclusive() - command to request for device managed by
647 * @id: Device Identifier
649 * Request for the device - NOTE: the client MUST maintain integrity of
656 u32 id) in ti_sci_cmd_get_device_exclusive() argument
658 return ti_sci_set_device_state(handle, id, in ti_sci_cmd_get_device_exclusive()
664 * ti_sci_cmd_idle_device() - Command to idle a device managed by TISCI
666 * @id: Device Identifier
668 * Request for the device - NOTE: the client MUST maintain integrity of
674 static int ti_sci_cmd_idle_device(const struct ti_sci_handle *handle, u32 id) in ti_sci_cmd_idle_device() argument
676 return ti_sci_set_device_state(handle, id, 0, in ti_sci_cmd_idle_device()
681 * ti_sci_cmd_idle_device_exclusive() - Command to idle a device managed by
685 * @id: Device Identifier
687 * Request for the device - NOTE: the client MUST maintain integrity of
694 u32 id) in ti_sci_cmd_idle_device_exclusive() argument
696 return ti_sci_set_device_state(handle, id, in ti_sci_cmd_idle_device_exclusive()
702 * ti_sci_cmd_put_device() - command to release a device managed by TISCI
704 * @id: Device Identifier
706 * Request for the device - NOTE: the client MUST maintain integrity of
712 static int ti_sci_cmd_put_device(const struct ti_sci_handle *handle, u32 id) in ti_sci_cmd_put_device() argument
714 return ti_sci_set_device_state(handle, id, in ti_sci_cmd_put_device()
719 * ti_sci_cmd_dev_is_valid() - Is the device valid
721 * @id: Device Identifier
723 * Return: 0 if all went fine and the device ID is valid, else return
726 static int ti_sci_cmd_dev_is_valid(const struct ti_sci_handle *handle, u32 id) in ti_sci_cmd_dev_is_valid() argument
730 /* check the device state which will also tell us if the ID is valid */ in ti_sci_cmd_dev_is_valid()
731 return ti_sci_get_device_state(handle, id, NULL, NULL, NULL, &unused); in ti_sci_cmd_dev_is_valid()
735 * ti_sci_cmd_dev_get_clcnt() - Get context loss counter
737 * @id: Device Identifier
742 static int ti_sci_cmd_dev_get_clcnt(const struct ti_sci_handle *handle, u32 id, in ti_sci_cmd_dev_get_clcnt() argument
745 return ti_sci_get_device_state(handle, id, count, NULL, NULL, NULL); in ti_sci_cmd_dev_get_clcnt()
749 * ti_sci_cmd_dev_is_idle() - Check if the device is requested to be idle
751 * @id: Device Identifier
756 static int ti_sci_cmd_dev_is_idle(const struct ti_sci_handle *handle, u32 id, in ti_sci_cmd_dev_is_idle() argument
763 return -EINVAL; in ti_sci_cmd_dev_is_idle()
765 ret = ti_sci_get_device_state(handle, id, NULL, NULL, &state, NULL); in ti_sci_cmd_dev_is_idle()
775 * ti_sci_cmd_dev_is_stop() - Check if the device is requested to be stopped
777 * @id: Device Identifier
783 static int ti_sci_cmd_dev_is_stop(const struct ti_sci_handle *handle, u32 id, in ti_sci_cmd_dev_is_stop() argument
790 return -EINVAL; in ti_sci_cmd_dev_is_stop()
793 ti_sci_get_device_state(handle, id, NULL, NULL, &p_state, &c_state); in ti_sci_cmd_dev_is_stop()
806 * ti_sci_cmd_dev_is_on() - Check if the device is requested to be ON
808 * @id: Device Identifier
814 static int ti_sci_cmd_dev_is_on(const struct ti_sci_handle *handle, u32 id, in ti_sci_cmd_dev_is_on() argument
821 return -EINVAL; in ti_sci_cmd_dev_is_on()
824 ti_sci_get_device_state(handle, id, NULL, NULL, &p_state, &c_state); in ti_sci_cmd_dev_is_on()
837 * ti_sci_cmd_dev_is_trans() - Check if the device is currently transitioning
839 * @id: Device Identifier
844 static int ti_sci_cmd_dev_is_trans(const struct ti_sci_handle *handle, u32 id, in ti_sci_cmd_dev_is_trans() argument
851 return -EINVAL; in ti_sci_cmd_dev_is_trans()
853 ret = ti_sci_get_device_state(handle, id, NULL, NULL, NULL, &state); in ti_sci_cmd_dev_is_trans()
863 * ti_sci_cmd_set_device_resets() - command to set resets for device managed
866 * @id: Device Identifier
872 u32 id, u32 reset_state) in ti_sci_cmd_set_device_resets() argument
878 struct device *dev; in ti_sci_cmd_set_device_resets() local
884 return -EINVAL; in ti_sci_cmd_set_device_resets()
887 dev = info->dev; in ti_sci_cmd_set_device_resets()
894 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_cmd_set_device_resets()
897 req = (struct ti_sci_msg_req_set_device_resets *)xfer->xfer_buf; in ti_sci_cmd_set_device_resets()
898 req->id = id; in ti_sci_cmd_set_device_resets()
899 req->resets = reset_state; in ti_sci_cmd_set_device_resets()
903 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_cmd_set_device_resets()
907 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_cmd_set_device_resets()
909 ret = ti_sci_is_response_ack(resp) ? 0 : -ENODEV; in ti_sci_cmd_set_device_resets()
912 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_set_device_resets()
918 * ti_sci_cmd_get_device_resets() - Get reset state for device managed
921 * @id: Device Identifier
927 u32 id, u32 *reset_state) in ti_sci_cmd_get_device_resets() argument
929 return ti_sci_get_device_state(handle, id, NULL, reset_state, NULL, in ti_sci_cmd_get_device_resets()
934 * ti_sci_set_clock_state() - Set clock state helper
935 * @handle: pointer to TI SCI handle
953 struct device *dev; in ti_sci_set_clock_state() local
959 return -EINVAL; in ti_sci_set_clock_state()
962 dev = info->dev; in ti_sci_set_clock_state()
969 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_set_clock_state()
972 req = (struct ti_sci_msg_req_set_clock_state *)xfer->xfer_buf; in ti_sci_set_clock_state()
973 req->dev_id = dev_id; in ti_sci_set_clock_state()
975 req->clk_id = clk_id; in ti_sci_set_clock_state()
977 req->clk_id = 255; in ti_sci_set_clock_state()
978 req->clk_id_32 = clk_id; in ti_sci_set_clock_state()
980 req->request_state = state; in ti_sci_set_clock_state()
984 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_set_clock_state()
988 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_set_clock_state()
990 ret = ti_sci_is_response_ack(resp) ? 0 : -ENODEV; in ti_sci_set_clock_state()
993 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_set_clock_state()
999 * ti_sci_cmd_get_clock_state() - Get clock state helper
1000 * @handle: pointer to TI SCI handle
1018 struct device *dev; in ti_sci_cmd_get_clock_state() local
1024 return -EINVAL; in ti_sci_cmd_get_clock_state()
1027 return -EINVAL; in ti_sci_cmd_get_clock_state()
1030 dev = info->dev; in ti_sci_cmd_get_clock_state()
1037 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_cmd_get_clock_state()
1040 req = (struct ti_sci_msg_req_get_clock_state *)xfer->xfer_buf; in ti_sci_cmd_get_clock_state()
1041 req->dev_id = dev_id; in ti_sci_cmd_get_clock_state()
1043 req->clk_id = clk_id; in ti_sci_cmd_get_clock_state()
1045 req->clk_id = 255; in ti_sci_cmd_get_clock_state()
1046 req->clk_id_32 = clk_id; in ti_sci_cmd_get_clock_state()
1051 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_cmd_get_clock_state()
1055 resp = (struct ti_sci_msg_resp_get_clock_state *)xfer->xfer_buf; in ti_sci_cmd_get_clock_state()
1058 ret = -ENODEV; in ti_sci_cmd_get_clock_state()
1063 *programmed_state = resp->programmed_state; in ti_sci_cmd_get_clock_state()
1065 *current_state = resp->current_state; in ti_sci_cmd_get_clock_state()
1068 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_get_clock_state()
1074 * ti_sci_cmd_get_clock() - Get control of a clock from TI SCI
1075 * @handle: pointer to TI SCI handle
1101 * ti_sci_cmd_idle_clock() - Idle a clock which is in our control
1102 * @handle: pointer to TI SCI handle
1121 * ti_sci_cmd_put_clock() - Release a clock from our control back to TISCI
1122 * @handle: pointer to TI SCI handle
1141 * ti_sci_cmd_clk_is_auto() - Is the clock being auto managed
1142 * @handle: pointer to TI SCI handle
1158 return -EINVAL; in ti_sci_cmd_clk_is_auto()
1169 * ti_sci_cmd_clk_is_on() - Is the clock ON
1170 * @handle: pointer to TI SCI handle
1187 return -EINVAL; in ti_sci_cmd_clk_is_on()
1202 * ti_sci_cmd_clk_is_off() - Is the clock OFF
1203 * @handle: pointer to TI SCI handle
1220 return -EINVAL; in ti_sci_cmd_clk_is_off()
1235 * ti_sci_cmd_clk_set_parent() - Set the clock source of a specific device clock
1236 * @handle: pointer to TI SCI handle
1252 struct device *dev; in ti_sci_cmd_clk_set_parent() local
1258 return -EINVAL; in ti_sci_cmd_clk_set_parent()
1261 dev = info->dev; in ti_sci_cmd_clk_set_parent()
1268 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_cmd_clk_set_parent()
1271 req = (struct ti_sci_msg_req_set_clock_parent *)xfer->xfer_buf; in ti_sci_cmd_clk_set_parent()
1272 req->dev_id = dev_id; in ti_sci_cmd_clk_set_parent()
1274 req->clk_id = clk_id; in ti_sci_cmd_clk_set_parent()
1276 req->clk_id = 255; in ti_sci_cmd_clk_set_parent()
1277 req->clk_id_32 = clk_id; in ti_sci_cmd_clk_set_parent()
1280 req->parent_id = parent_id; in ti_sci_cmd_clk_set_parent()
1282 req->parent_id = 255; in ti_sci_cmd_clk_set_parent()
1283 req->parent_id_32 = parent_id; in ti_sci_cmd_clk_set_parent()
1288 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_cmd_clk_set_parent()
1292 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_cmd_clk_set_parent()
1294 ret = ti_sci_is_response_ack(resp) ? 0 : -ENODEV; in ti_sci_cmd_clk_set_parent()
1297 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_clk_set_parent()
1303 * ti_sci_cmd_clk_get_parent() - Get current parent clock source
1304 * @handle: pointer to TI SCI handle
1320 struct device *dev; in ti_sci_cmd_clk_get_parent() local
1326 return -EINVAL; in ti_sci_cmd_clk_get_parent()
1329 dev = info->dev; in ti_sci_cmd_clk_get_parent()
1336 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_cmd_clk_get_parent()
1339 req = (struct ti_sci_msg_req_get_clock_parent *)xfer->xfer_buf; in ti_sci_cmd_clk_get_parent()
1340 req->dev_id = dev_id; in ti_sci_cmd_clk_get_parent()
1342 req->clk_id = clk_id; in ti_sci_cmd_clk_get_parent()
1344 req->clk_id = 255; in ti_sci_cmd_clk_get_parent()
1345 req->clk_id_32 = clk_id; in ti_sci_cmd_clk_get_parent()
1350 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_cmd_clk_get_parent()
1354 resp = (struct ti_sci_msg_resp_get_clock_parent *)xfer->xfer_buf; in ti_sci_cmd_clk_get_parent()
1357 ret = -ENODEV; in ti_sci_cmd_clk_get_parent()
1359 if (resp->parent_id < 255) in ti_sci_cmd_clk_get_parent()
1360 *parent_id = resp->parent_id; in ti_sci_cmd_clk_get_parent()
1362 *parent_id = resp->parent_id_32; in ti_sci_cmd_clk_get_parent()
1366 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_clk_get_parent()
1372 * ti_sci_cmd_clk_get_num_parents() - Get num parents of the current clk source
1373 * @handle: pointer to TI SCI handle
1390 struct device *dev; in ti_sci_cmd_clk_get_num_parents() local
1396 return -EINVAL; in ti_sci_cmd_clk_get_num_parents()
1399 dev = info->dev; in ti_sci_cmd_clk_get_num_parents()
1406 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_cmd_clk_get_num_parents()
1409 req = (struct ti_sci_msg_req_get_clock_num_parents *)xfer->xfer_buf; in ti_sci_cmd_clk_get_num_parents()
1410 req->dev_id = dev_id; in ti_sci_cmd_clk_get_num_parents()
1412 req->clk_id = clk_id; in ti_sci_cmd_clk_get_num_parents()
1414 req->clk_id = 255; in ti_sci_cmd_clk_get_num_parents()
1415 req->clk_id_32 = clk_id; in ti_sci_cmd_clk_get_num_parents()
1420 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_cmd_clk_get_num_parents()
1424 resp = (struct ti_sci_msg_resp_get_clock_num_parents *)xfer->xfer_buf; in ti_sci_cmd_clk_get_num_parents()
1427 ret = -ENODEV; in ti_sci_cmd_clk_get_num_parents()
1429 if (resp->num_parents < 255) in ti_sci_cmd_clk_get_num_parents()
1430 *num_parents = resp->num_parents; in ti_sci_cmd_clk_get_num_parents()
1432 *num_parents = resp->num_parents_32; in ti_sci_cmd_clk_get_num_parents()
1436 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_clk_get_num_parents()
1442 * ti_sci_cmd_clk_get_match_freq() - Find a good match for frequency
1443 * @handle: pointer to TI SCI handle
1469 struct device *dev; in ti_sci_cmd_clk_get_match_freq() local
1475 return -EINVAL; in ti_sci_cmd_clk_get_match_freq()
1478 dev = info->dev; in ti_sci_cmd_clk_get_match_freq()
1485 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_cmd_clk_get_match_freq()
1488 req = (struct ti_sci_msg_req_query_clock_freq *)xfer->xfer_buf; in ti_sci_cmd_clk_get_match_freq()
1489 req->dev_id = dev_id; in ti_sci_cmd_clk_get_match_freq()
1491 req->clk_id = clk_id; in ti_sci_cmd_clk_get_match_freq()
1493 req->clk_id = 255; in ti_sci_cmd_clk_get_match_freq()
1494 req->clk_id_32 = clk_id; in ti_sci_cmd_clk_get_match_freq()
1496 req->min_freq_hz = min_freq; in ti_sci_cmd_clk_get_match_freq()
1497 req->target_freq_hz = target_freq; in ti_sci_cmd_clk_get_match_freq()
1498 req->max_freq_hz = max_freq; in ti_sci_cmd_clk_get_match_freq()
1502 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_cmd_clk_get_match_freq()
1506 resp = (struct ti_sci_msg_resp_query_clock_freq *)xfer->xfer_buf; in ti_sci_cmd_clk_get_match_freq()
1509 ret = -ENODEV; in ti_sci_cmd_clk_get_match_freq()
1511 *match_freq = resp->freq_hz; in ti_sci_cmd_clk_get_match_freq()
1514 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_clk_get_match_freq()
1520 * ti_sci_cmd_clk_set_freq() - Set a frequency for clock
1521 * @handle: pointer to TI SCI handle
1545 struct device *dev; in ti_sci_cmd_clk_set_freq() local
1551 return -EINVAL; in ti_sci_cmd_clk_set_freq()
1554 dev = info->dev; in ti_sci_cmd_clk_set_freq()
1561 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_cmd_clk_set_freq()
1564 req = (struct ti_sci_msg_req_set_clock_freq *)xfer->xfer_buf; in ti_sci_cmd_clk_set_freq()
1565 req->dev_id = dev_id; in ti_sci_cmd_clk_set_freq()
1567 req->clk_id = clk_id; in ti_sci_cmd_clk_set_freq()
1569 req->clk_id = 255; in ti_sci_cmd_clk_set_freq()
1570 req->clk_id_32 = clk_id; in ti_sci_cmd_clk_set_freq()
1572 req->min_freq_hz = min_freq; in ti_sci_cmd_clk_set_freq()
1573 req->target_freq_hz = target_freq; in ti_sci_cmd_clk_set_freq()
1574 req->max_freq_hz = max_freq; in ti_sci_cmd_clk_set_freq()
1578 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_cmd_clk_set_freq()
1582 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_cmd_clk_set_freq()
1584 ret = ti_sci_is_response_ack(resp) ? 0 : -ENODEV; in ti_sci_cmd_clk_set_freq()
1587 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_clk_set_freq()
1593 * ti_sci_cmd_clk_get_freq() - Get current frequency
1594 * @handle: pointer to TI SCI handle
1610 struct device *dev; in ti_sci_cmd_clk_get_freq() local
1616 return -EINVAL; in ti_sci_cmd_clk_get_freq()
1619 dev = info->dev; in ti_sci_cmd_clk_get_freq()
1626 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_cmd_clk_get_freq()
1629 req = (struct ti_sci_msg_req_get_clock_freq *)xfer->xfer_buf; in ti_sci_cmd_clk_get_freq()
1630 req->dev_id = dev_id; in ti_sci_cmd_clk_get_freq()
1632 req->clk_id = clk_id; in ti_sci_cmd_clk_get_freq()
1634 req->clk_id = 255; in ti_sci_cmd_clk_get_freq()
1635 req->clk_id_32 = clk_id; in ti_sci_cmd_clk_get_freq()
1640 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_cmd_clk_get_freq()
1644 resp = (struct ti_sci_msg_resp_get_clock_freq *)xfer->xfer_buf; in ti_sci_cmd_clk_get_freq()
1647 ret = -ENODEV; in ti_sci_cmd_clk_get_freq()
1649 *freq = resp->freq_hz; in ti_sci_cmd_clk_get_freq()
1652 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_clk_get_freq()
1663 struct device *dev; in ti_sci_cmd_core_reboot() local
1669 return -EINVAL; in ti_sci_cmd_core_reboot()
1672 dev = info->dev; in ti_sci_cmd_core_reboot()
1679 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_cmd_core_reboot()
1682 req = (struct ti_sci_msg_req_reboot *)xfer->xfer_buf; in ti_sci_cmd_core_reboot()
1686 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_cmd_core_reboot()
1690 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_cmd_core_reboot()
1693 ret = -ENODEV; in ti_sci_cmd_core_reboot()
1698 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_core_reboot()
1704 * ti_sci_get_resource_range - Helper to get a range of resources assigned
1708 * @dev_id: TISCI device ID.
1711 * @s_host: Host processor ID to which the resources are allocated
1725 struct device *dev; in ti_sci_get_resource_range() local
1731 return -EINVAL; in ti_sci_get_resource_range()
1734 dev = info->dev; in ti_sci_get_resource_range()
1741 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_get_resource_range()
1745 req = (struct ti_sci_msg_req_get_resource_range *)xfer->xfer_buf; in ti_sci_get_resource_range()
1746 req->secondary_host = s_host; in ti_sci_get_resource_range()
1747 req->type = dev_id & MSG_RM_RESOURCE_TYPE_MASK; in ti_sci_get_resource_range()
1748 req->subtype = subtype & MSG_RM_RESOURCE_SUBTYPE_MASK; in ti_sci_get_resource_range()
1752 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_get_resource_range()
1756 resp = (struct ti_sci_msg_resp_get_resource_range *)xfer->xfer_buf; in ti_sci_get_resource_range()
1759 ret = -ENODEV; in ti_sci_get_resource_range()
1760 } else if (!resp->range_num && !resp->range_num_sec) { in ti_sci_get_resource_range()
1762 ret = -ENODEV; in ti_sci_get_resource_range()
1764 desc->start = resp->range_start; in ti_sci_get_resource_range()
1765 desc->num = resp->range_num; in ti_sci_get_resource_range()
1766 desc->start_sec = resp->range_start_sec; in ti_sci_get_resource_range()
1767 desc->num_sec = resp->range_num_sec; in ti_sci_get_resource_range()
1771 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_get_resource_range()
1777 * ti_sci_cmd_get_resource_range - Get a range of resources assigned to host
1778 * that is same as ti sci interface host.
1780 * @dev_id: TISCI device ID.
1798 * ti_sci_cmd_get_resource_range_from_shost - Get a range of resources
1801 * @dev_id: TISCI device ID.
1804 * @s_host: Host processor ID to which the resources are allocated
1819 * ti_sci_manage_irq() - Helper api to configure/release the irq route between
1823 * @src_id: Device ID of the IRQ source
1825 * @dst_id: Device ID of the IRQ destination
1827 * @ia_id: Device ID of the IA, if the IRQ flows through this IA
1831 * @s_host: Secondary host ID to which the irq/event is being
1847 struct device *dev; in ti_sci_manage_irq() local
1853 return -EINVAL; in ti_sci_manage_irq()
1856 dev = info->dev; in ti_sci_manage_irq()
1862 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_manage_irq()
1865 req = (struct ti_sci_msg_req_manage_irq *)xfer->xfer_buf; in ti_sci_manage_irq()
1866 req->valid_params = valid_params; in ti_sci_manage_irq()
1867 req->src_id = src_id; in ti_sci_manage_irq()
1868 req->src_index = src_index; in ti_sci_manage_irq()
1869 req->dst_id = dst_id; in ti_sci_manage_irq()
1870 req->dst_host_irq = dst_host_irq; in ti_sci_manage_irq()
1871 req->ia_id = ia_id; in ti_sci_manage_irq()
1872 req->vint = vint; in ti_sci_manage_irq()
1873 req->global_event = global_event; in ti_sci_manage_irq()
1874 req->vint_status_bit = vint_status_bit; in ti_sci_manage_irq()
1875 req->secondary_host = s_host; in ti_sci_manage_irq()
1879 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_manage_irq()
1883 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_manage_irq()
1885 ret = ti_sci_is_response_ack(resp) ? 0 : -ENODEV; in ti_sci_manage_irq()
1888 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_manage_irq()
1894 * ti_sci_set_irq() - Helper api to configure the irq route between the
1898 * @src_id: Device ID of the IRQ source
1900 * @dst_id: Device ID of the IRQ destination
1902 * @ia_id: Device ID of the IA, if the IRQ flows through this IA
1906 * @s_host: Secondary host ID to which the irq/event is being
1928 * ti_sci_free_irq() - Helper api to free the irq route between the
1932 * @src_id: Device ID of the IRQ source
1934 * @dst_id: Device ID of the IRQ destination
1936 * @ia_id: Device ID of the IA, if the IRQ flows through this IA
1940 * @s_host: Secondary host ID to which the irq/event is being
1962 * ti_sci_cmd_set_irq() - Configure a host irq route between the requested
1965 * @src_id: Device ID of the IRQ source
1967 * @dst_id: Device ID of the IRQ destination
1982 * ti_sci_cmd_set_event_map() - Configure an event based irq route between the
1985 * @src_id: Device ID of the IRQ source
1987 * @ia_id: Device ID of the IA, if the IRQ flows through this IA
2008 * ti_sci_cmd_free_irq() - Free a host irq route between the between the
2011 * @src_id: Device ID of the IRQ source
2013 * @dst_id: Device ID of the IRQ destination
2028 * ti_sci_cmd_free_event_map() - Free an event map between the requested source
2031 * @src_id: Device ID of the IRQ source
2033 * @ia_id: Device ID of the IA, if the IRQ flows through this IA
2054 * ti_sci_cmd_rm_ring_cfg() - Configure a NAVSS ring
2055 * @handle: Pointer to TI SCI handle.
2070 struct device *dev; in ti_sci_cmd_rm_ring_cfg() local
2074 return -EINVAL; in ti_sci_cmd_rm_ring_cfg()
2077 dev = info->dev; in ti_sci_cmd_rm_ring_cfg()
2084 dev_err(dev, "RM_RA:Message config failed(%d)\n", ret); in ti_sci_cmd_rm_ring_cfg()
2087 req = (struct ti_sci_msg_rm_ring_cfg_req *)xfer->xfer_buf; in ti_sci_cmd_rm_ring_cfg()
2088 req->valid_params = params->valid_params; in ti_sci_cmd_rm_ring_cfg()
2089 req->nav_id = params->nav_id; in ti_sci_cmd_rm_ring_cfg()
2090 req->index = params->index; in ti_sci_cmd_rm_ring_cfg()
2091 req->addr_lo = params->addr_lo; in ti_sci_cmd_rm_ring_cfg()
2092 req->addr_hi = params->addr_hi; in ti_sci_cmd_rm_ring_cfg()
2093 req->count = params->count; in ti_sci_cmd_rm_ring_cfg()
2094 req->mode = params->mode; in ti_sci_cmd_rm_ring_cfg()
2095 req->size = params->size; in ti_sci_cmd_rm_ring_cfg()
2096 req->order_id = params->order_id; in ti_sci_cmd_rm_ring_cfg()
2097 req->virtid = params->virtid; in ti_sci_cmd_rm_ring_cfg()
2098 req->asel = params->asel; in ti_sci_cmd_rm_ring_cfg()
2102 dev_err(dev, "RM_RA:Mbox config send fail %d\n", ret); in ti_sci_cmd_rm_ring_cfg()
2106 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_cmd_rm_ring_cfg()
2107 ret = ti_sci_is_response_ack(resp) ? 0 : -EINVAL; in ti_sci_cmd_rm_ring_cfg()
2110 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_rm_ring_cfg()
2111 dev_dbg(dev, "RM_RA:config ring %u ret:%d\n", params->index, ret); in ti_sci_cmd_rm_ring_cfg()
2116 * ti_sci_cmd_rm_psil_pair() - Pair PSI-L source to destination thread
2117 * @handle: Pointer to TI SCI handle.
2118 * @nav_id: Device ID of Navigator Subsystem which should be used for
2120 * @src_thread: Source PSI-L thread ID
2121 * @dst_thread: Destination PSI-L thread ID
2132 struct device *dev; in ti_sci_cmd_rm_psil_pair() local
2138 return -EINVAL; in ti_sci_cmd_rm_psil_pair()
2141 dev = info->dev; in ti_sci_cmd_rm_psil_pair()
2148 dev_err(dev, "RM_PSIL:Message reconfig failed(%d)\n", ret); in ti_sci_cmd_rm_psil_pair()
2151 req = (struct ti_sci_msg_psil_pair *)xfer->xfer_buf; in ti_sci_cmd_rm_psil_pair()
2152 req->nav_id = nav_id; in ti_sci_cmd_rm_psil_pair()
2153 req->src_thread = src_thread; in ti_sci_cmd_rm_psil_pair()
2154 req->dst_thread = dst_thread; in ti_sci_cmd_rm_psil_pair()
2158 dev_err(dev, "RM_PSIL:Mbox send fail %d\n", ret); in ti_sci_cmd_rm_psil_pair()
2162 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_cmd_rm_psil_pair()
2163 ret = ti_sci_is_response_ack(resp) ? 0 : -EINVAL; in ti_sci_cmd_rm_psil_pair()
2166 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_rm_psil_pair()
2172 * ti_sci_cmd_rm_psil_unpair() - Unpair PSI-L source from destination thread
2173 * @handle: Pointer to TI SCI handle.
2174 * @nav_id: Device ID of Navigator Subsystem which should be used for
2176 * @src_thread: Source PSI-L thread ID
2177 * @dst_thread: Destination PSI-L thread ID
2188 struct device *dev; in ti_sci_cmd_rm_psil_unpair() local
2194 return -EINVAL; in ti_sci_cmd_rm_psil_unpair()
2197 dev = info->dev; in ti_sci_cmd_rm_psil_unpair()
2204 dev_err(dev, "RM_PSIL:Message reconfig failed(%d)\n", ret); in ti_sci_cmd_rm_psil_unpair()
2207 req = (struct ti_sci_msg_psil_unpair *)xfer->xfer_buf; in ti_sci_cmd_rm_psil_unpair()
2208 req->nav_id = nav_id; in ti_sci_cmd_rm_psil_unpair()
2209 req->src_thread = src_thread; in ti_sci_cmd_rm_psil_unpair()
2210 req->dst_thread = dst_thread; in ti_sci_cmd_rm_psil_unpair()
2214 dev_err(dev, "RM_PSIL:Mbox send fail %d\n", ret); in ti_sci_cmd_rm_psil_unpair()
2218 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_cmd_rm_psil_unpair()
2219 ret = ti_sci_is_response_ack(resp) ? 0 : -EINVAL; in ti_sci_cmd_rm_psil_unpair()
2222 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_rm_psil_unpair()
2228 * ti_sci_cmd_rm_udmap_tx_ch_cfg() - Configure a UDMAP TX channel
2229 * @handle: Pointer to TI SCI handle.
2245 struct device *dev; in ti_sci_cmd_rm_udmap_tx_ch_cfg() local
2249 return -EINVAL; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2252 dev = info->dev; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2259 dev_err(dev, "Message TX_CH_CFG alloc failed(%d)\n", ret); in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2262 req = (struct ti_sci_msg_rm_udmap_tx_ch_cfg_req *)xfer->xfer_buf; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2263 req->valid_params = params->valid_params; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2264 req->nav_id = params->nav_id; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2265 req->index = params->index; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2266 req->tx_pause_on_err = params->tx_pause_on_err; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2267 req->tx_filt_einfo = params->tx_filt_einfo; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2268 req->tx_filt_pswords = params->tx_filt_pswords; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2269 req->tx_atype = params->tx_atype; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2270 req->tx_chan_type = params->tx_chan_type; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2271 req->tx_supr_tdpkt = params->tx_supr_tdpkt; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2272 req->tx_fetch_size = params->tx_fetch_size; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2273 req->tx_credit_count = params->tx_credit_count; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2274 req->txcq_qnum = params->txcq_qnum; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2275 req->tx_priority = params->tx_priority; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2276 req->tx_qos = params->tx_qos; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2277 req->tx_orderid = params->tx_orderid; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2278 req->fdepth = params->fdepth; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2279 req->tx_sched_priority = params->tx_sched_priority; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2280 req->tx_burst_size = params->tx_burst_size; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2281 req->tx_tdtype = params->tx_tdtype; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2282 req->extended_ch_type = params->extended_ch_type; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2286 dev_err(dev, "Mbox send TX_CH_CFG fail %d\n", ret); in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2290 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2291 ret = ti_sci_is_response_ack(resp) ? 0 : -EINVAL; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2294 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2295 dev_dbg(dev, "TX_CH_CFG: chn %u ret:%u\n", params->index, ret); in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2300 * ti_sci_cmd_rm_udmap_rx_ch_cfg() - Configure a UDMAP RX channel
2301 * @handle: Pointer to TI SCI handle.
2317 struct device *dev; in ti_sci_cmd_rm_udmap_rx_ch_cfg() local
2321 return -EINVAL; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2324 dev = info->dev; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2331 dev_err(dev, "Message RX_CH_CFG alloc failed(%d)\n", ret); in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2334 req = (struct ti_sci_msg_rm_udmap_rx_ch_cfg_req *)xfer->xfer_buf; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2335 req->valid_params = params->valid_params; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2336 req->nav_id = params->nav_id; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2337 req->index = params->index; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2338 req->rx_fetch_size = params->rx_fetch_size; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2339 req->rxcq_qnum = params->rxcq_qnum; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2340 req->rx_priority = params->rx_priority; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2341 req->rx_qos = params->rx_qos; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2342 req->rx_orderid = params->rx_orderid; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2343 req->rx_sched_priority = params->rx_sched_priority; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2344 req->flowid_start = params->flowid_start; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2345 req->flowid_cnt = params->flowid_cnt; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2346 req->rx_pause_on_err = params->rx_pause_on_err; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2347 req->rx_atype = params->rx_atype; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2348 req->rx_chan_type = params->rx_chan_type; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2349 req->rx_ignore_short = params->rx_ignore_short; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2350 req->rx_ignore_long = params->rx_ignore_long; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2351 req->rx_burst_size = params->rx_burst_size; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2355 dev_err(dev, "Mbox send RX_CH_CFG fail %d\n", ret); in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2359 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2360 ret = ti_sci_is_response_ack(resp) ? 0 : -EINVAL; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2363 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2364 dev_dbg(dev, "RX_CH_CFG: chn %u ret:%d\n", params->index, ret); in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2369 * ti_sci_cmd_rm_udmap_rx_flow_cfg() - Configure UDMAP RX FLOW
2370 * @handle: Pointer to TI SCI handle.
2386 struct device *dev; in ti_sci_cmd_rm_udmap_rx_flow_cfg() local
2390 return -EINVAL; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2393 dev = info->dev; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2400 dev_err(dev, "RX_FL_CFG: Message alloc failed(%d)\n", ret); in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2403 req = (struct ti_sci_msg_rm_udmap_flow_cfg_req *)xfer->xfer_buf; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2404 req->valid_params = params->valid_params; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2405 req->nav_id = params->nav_id; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2406 req->flow_index = params->flow_index; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2407 req->rx_einfo_present = params->rx_einfo_present; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2408 req->rx_psinfo_present = params->rx_psinfo_present; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2409 req->rx_error_handling = params->rx_error_handling; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2410 req->rx_desc_type = params->rx_desc_type; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2411 req->rx_sop_offset = params->rx_sop_offset; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2412 req->rx_dest_qnum = params->rx_dest_qnum; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2413 req->rx_src_tag_hi = params->rx_src_tag_hi; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2414 req->rx_src_tag_lo = params->rx_src_tag_lo; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2415 req->rx_dest_tag_hi = params->rx_dest_tag_hi; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2416 req->rx_dest_tag_lo = params->rx_dest_tag_lo; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2417 req->rx_src_tag_hi_sel = params->rx_src_tag_hi_sel; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2418 req->rx_src_tag_lo_sel = params->rx_src_tag_lo_sel; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2419 req->rx_dest_tag_hi_sel = params->rx_dest_tag_hi_sel; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2420 req->rx_dest_tag_lo_sel = params->rx_dest_tag_lo_sel; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2421 req->rx_fdq0_sz0_qnum = params->rx_fdq0_sz0_qnum; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2422 req->rx_fdq1_qnum = params->rx_fdq1_qnum; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2423 req->rx_fdq2_qnum = params->rx_fdq2_qnum; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2424 req->rx_fdq3_qnum = params->rx_fdq3_qnum; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2425 req->rx_ps_location = params->rx_ps_location; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2429 dev_err(dev, "RX_FL_CFG: Mbox send fail %d\n", ret); in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2433 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2434 ret = ti_sci_is_response_ack(resp) ? 0 : -EINVAL; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2437 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2438 dev_dbg(info->dev, "RX_FL_CFG: %u ret:%d\n", params->flow_index, ret); in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2443 * ti_sci_cmd_proc_request() - Command to request a physical processor control
2444 * @handle: Pointer to TI SCI handle
2445 * @proc_id: Processor ID this request is for
2456 struct device *dev; in ti_sci_cmd_proc_request() local
2460 return -EINVAL; in ti_sci_cmd_proc_request()
2465 dev = info->dev; in ti_sci_cmd_proc_request()
2472 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_cmd_proc_request()
2475 req = (struct ti_sci_msg_req_proc_request *)xfer->xfer_buf; in ti_sci_cmd_proc_request()
2476 req->processor_id = proc_id; in ti_sci_cmd_proc_request()
2480 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_cmd_proc_request()
2484 resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf; in ti_sci_cmd_proc_request()
2486 ret = ti_sci_is_response_ack(resp) ? 0 : -ENODEV; in ti_sci_cmd_proc_request()
2489 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_proc_request()
2495 * ti_sci_cmd_proc_release() - Command to release a physical processor control
2496 * @handle: Pointer to TI SCI handle
2497 * @proc_id: Processor ID this request is for
2508 struct device *dev; in ti_sci_cmd_proc_release() local
2512 return -EINVAL; in ti_sci_cmd_proc_release()
2517 dev = info->dev; in ti_sci_cmd_proc_release()
2524 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_cmd_proc_release()
2527 req = (struct ti_sci_msg_req_proc_release *)xfer->xfer_buf; in ti_sci_cmd_proc_release()
2528 req->processor_id = proc_id; in ti_sci_cmd_proc_release()
2532 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_cmd_proc_release()
2536 resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf; in ti_sci_cmd_proc_release()
2538 ret = ti_sci_is_response_ack(resp) ? 0 : -ENODEV; in ti_sci_cmd_proc_release()
2541 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_proc_release()
2547 * ti_sci_cmd_proc_handover() - Command to handover a physical processor
2550 * @handle: Pointer to TI SCI handle
2551 * @proc_id: Processor ID this request is for
2552 * @host_id: Host ID to get the control of the processor
2563 struct device *dev; in ti_sci_cmd_proc_handover() local
2567 return -EINVAL; in ti_sci_cmd_proc_handover()
2572 dev = info->dev; in ti_sci_cmd_proc_handover()
2579 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_cmd_proc_handover()
2582 req = (struct ti_sci_msg_req_proc_handover *)xfer->xfer_buf; in ti_sci_cmd_proc_handover()
2583 req->processor_id = proc_id; in ti_sci_cmd_proc_handover()
2584 req->host_id = host_id; in ti_sci_cmd_proc_handover()
2588 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_cmd_proc_handover()
2592 resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf; in ti_sci_cmd_proc_handover()
2594 ret = ti_sci_is_response_ack(resp) ? 0 : -ENODEV; in ti_sci_cmd_proc_handover()
2597 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_proc_handover()
2603 * ti_sci_cmd_proc_set_config() - Command to set the processor boot
2605 * @handle: Pointer to TI SCI handle
2606 * @proc_id: Processor ID this request is for
2622 struct device *dev; in ti_sci_cmd_proc_set_config() local
2626 return -EINVAL; in ti_sci_cmd_proc_set_config()
2631 dev = info->dev; in ti_sci_cmd_proc_set_config()
2638 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_cmd_proc_set_config()
2641 req = (struct ti_sci_msg_req_set_config *)xfer->xfer_buf; in ti_sci_cmd_proc_set_config()
2642 req->processor_id = proc_id; in ti_sci_cmd_proc_set_config()
2643 req->bootvector_low = bootvector & TI_SCI_ADDR_LOW_MASK; in ti_sci_cmd_proc_set_config()
2644 req->bootvector_high = (bootvector & TI_SCI_ADDR_HIGH_MASK) >> in ti_sci_cmd_proc_set_config()
2646 req->config_flags_set = config_flags_set; in ti_sci_cmd_proc_set_config()
2647 req->config_flags_clear = config_flags_clear; in ti_sci_cmd_proc_set_config()
2651 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_cmd_proc_set_config()
2655 resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf; in ti_sci_cmd_proc_set_config()
2657 ret = ti_sci_is_response_ack(resp) ? 0 : -ENODEV; in ti_sci_cmd_proc_set_config()
2660 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_proc_set_config()
2666 * ti_sci_cmd_proc_set_control() - Command to set the processor boot
2668 * @handle: Pointer to TI SCI handle
2669 * @proc_id: Processor ID this request is for
2683 struct device *dev; in ti_sci_cmd_proc_set_control() local
2687 return -EINVAL; in ti_sci_cmd_proc_set_control()
2692 dev = info->dev; in ti_sci_cmd_proc_set_control()
2699 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_cmd_proc_set_control()
2702 req = (struct ti_sci_msg_req_set_ctrl *)xfer->xfer_buf; in ti_sci_cmd_proc_set_control()
2703 req->processor_id = proc_id; in ti_sci_cmd_proc_set_control()
2704 req->control_flags_set = control_flags_set; in ti_sci_cmd_proc_set_control()
2705 req->control_flags_clear = control_flags_clear; in ti_sci_cmd_proc_set_control()
2709 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_cmd_proc_set_control()
2713 resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf; in ti_sci_cmd_proc_set_control()
2715 ret = ti_sci_is_response_ack(resp) ? 0 : -ENODEV; in ti_sci_cmd_proc_set_control()
2718 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_proc_set_control()
2724 * ti_sci_cmd_proc_get_status() - Command to get the processor boot status
2725 * @handle: Pointer to TI SCI handle
2726 * @proc_id: Processor ID this request is for
2742 struct device *dev; in ti_sci_cmd_proc_get_status() local
2746 return -EINVAL; in ti_sci_cmd_proc_get_status()
2751 dev = info->dev; in ti_sci_cmd_proc_get_status()
2758 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_cmd_proc_get_status()
2761 req = (struct ti_sci_msg_req_get_status *)xfer->xfer_buf; in ti_sci_cmd_proc_get_status()
2762 req->processor_id = proc_id; in ti_sci_cmd_proc_get_status()
2766 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_cmd_proc_get_status()
2770 resp = (struct ti_sci_msg_resp_get_status *)xfer->tx_message.buf; in ti_sci_cmd_proc_get_status()
2773 ret = -ENODEV; in ti_sci_cmd_proc_get_status()
2775 *bv = (resp->bootvector_low & TI_SCI_ADDR_LOW_MASK) | in ti_sci_cmd_proc_get_status()
2776 (((u64)resp->bootvector_high << TI_SCI_ADDR_HIGH_SHIFT) & in ti_sci_cmd_proc_get_status()
2778 *cfg_flags = resp->config_flags; in ti_sci_cmd_proc_get_status()
2779 *ctrl_flags = resp->control_flags; in ti_sci_cmd_proc_get_status()
2780 *sts_flags = resp->status_flags; in ti_sci_cmd_proc_get_status()
2784 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_proc_get_status()
2790 * ti_sci_setup_ops() - Setup the operations structures
2795 struct ti_sci_ops *ops = &info->handle.ops; in ti_sci_setup_ops()
2796 struct ti_sci_core_ops *core_ops = &ops->core_ops; in ti_sci_setup_ops()
2797 struct ti_sci_dev_ops *dops = &ops->dev_ops; in ti_sci_setup_ops()
2798 struct ti_sci_clk_ops *cops = &ops->clk_ops; in ti_sci_setup_ops()
2799 struct ti_sci_rm_core_ops *rm_core_ops = &ops->rm_core_ops; in ti_sci_setup_ops()
2800 struct ti_sci_rm_irq_ops *iops = &ops->rm_irq_ops; in ti_sci_setup_ops()
2801 struct ti_sci_rm_ringacc_ops *rops = &ops->rm_ring_ops; in ti_sci_setup_ops()
2802 struct ti_sci_rm_psil_ops *psilops = &ops->rm_psil_ops; in ti_sci_setup_ops()
2803 struct ti_sci_rm_udmap_ops *udmap_ops = &ops->rm_udmap_ops; in ti_sci_setup_ops()
2804 struct ti_sci_proc_ops *pops = &ops->proc_ops; in ti_sci_setup_ops()
2806 core_ops->reboot_device = ti_sci_cmd_core_reboot; in ti_sci_setup_ops()
2808 dops->get_device = ti_sci_cmd_get_device; in ti_sci_setup_ops()
2809 dops->get_device_exclusive = ti_sci_cmd_get_device_exclusive; in ti_sci_setup_ops()
2810 dops->idle_device = ti_sci_cmd_idle_device; in ti_sci_setup_ops()
2811 dops->idle_device_exclusive = ti_sci_cmd_idle_device_exclusive; in ti_sci_setup_ops()
2812 dops->put_device = ti_sci_cmd_put_device; in ti_sci_setup_ops()
2814 dops->is_valid = ti_sci_cmd_dev_is_valid; in ti_sci_setup_ops()
2815 dops->get_context_loss_count = ti_sci_cmd_dev_get_clcnt; in ti_sci_setup_ops()
2816 dops->is_idle = ti_sci_cmd_dev_is_idle; in ti_sci_setup_ops()
2817 dops->is_stop = ti_sci_cmd_dev_is_stop; in ti_sci_setup_ops()
2818 dops->is_on = ti_sci_cmd_dev_is_on; in ti_sci_setup_ops()
2819 dops->is_transitioning = ti_sci_cmd_dev_is_trans; in ti_sci_setup_ops()
2820 dops->set_device_resets = ti_sci_cmd_set_device_resets; in ti_sci_setup_ops()
2821 dops->get_device_resets = ti_sci_cmd_get_device_resets; in ti_sci_setup_ops()
2823 cops->get_clock = ti_sci_cmd_get_clock; in ti_sci_setup_ops()
2824 cops->idle_clock = ti_sci_cmd_idle_clock; in ti_sci_setup_ops()
2825 cops->put_clock = ti_sci_cmd_put_clock; in ti_sci_setup_ops()
2826 cops->is_auto = ti_sci_cmd_clk_is_auto; in ti_sci_setup_ops()
2827 cops->is_on = ti_sci_cmd_clk_is_on; in ti_sci_setup_ops()
2828 cops->is_off = ti_sci_cmd_clk_is_off; in ti_sci_setup_ops()
2830 cops->set_parent = ti_sci_cmd_clk_set_parent; in ti_sci_setup_ops()
2831 cops->get_parent = ti_sci_cmd_clk_get_parent; in ti_sci_setup_ops()
2832 cops->get_num_parents = ti_sci_cmd_clk_get_num_parents; in ti_sci_setup_ops()
2834 cops->get_best_match_freq = ti_sci_cmd_clk_get_match_freq; in ti_sci_setup_ops()
2835 cops->set_freq = ti_sci_cmd_clk_set_freq; in ti_sci_setup_ops()
2836 cops->get_freq = ti_sci_cmd_clk_get_freq; in ti_sci_setup_ops()
2838 rm_core_ops->get_range = ti_sci_cmd_get_resource_range; in ti_sci_setup_ops()
2839 rm_core_ops->get_range_from_shost = in ti_sci_setup_ops()
2842 iops->set_irq = ti_sci_cmd_set_irq; in ti_sci_setup_ops()
2843 iops->set_event_map = ti_sci_cmd_set_event_map; in ti_sci_setup_ops()
2844 iops->free_irq = ti_sci_cmd_free_irq; in ti_sci_setup_ops()
2845 iops->free_event_map = ti_sci_cmd_free_event_map; in ti_sci_setup_ops()
2847 rops->set_cfg = ti_sci_cmd_rm_ring_cfg; in ti_sci_setup_ops()
2849 psilops->pair = ti_sci_cmd_rm_psil_pair; in ti_sci_setup_ops()
2850 psilops->unpair = ti_sci_cmd_rm_psil_unpair; in ti_sci_setup_ops()
2852 udmap_ops->tx_ch_cfg = ti_sci_cmd_rm_udmap_tx_ch_cfg; in ti_sci_setup_ops()
2853 udmap_ops->rx_ch_cfg = ti_sci_cmd_rm_udmap_rx_ch_cfg; in ti_sci_setup_ops()
2854 udmap_ops->rx_flow_cfg = ti_sci_cmd_rm_udmap_rx_flow_cfg; in ti_sci_setup_ops()
2856 pops->request = ti_sci_cmd_proc_request; in ti_sci_setup_ops()
2857 pops->release = ti_sci_cmd_proc_release; in ti_sci_setup_ops()
2858 pops->handover = ti_sci_cmd_proc_handover; in ti_sci_setup_ops()
2859 pops->set_config = ti_sci_cmd_proc_set_config; in ti_sci_setup_ops()
2860 pops->set_control = ti_sci_cmd_proc_set_control; in ti_sci_setup_ops()
2861 pops->get_status = ti_sci_cmd_proc_get_status; in ti_sci_setup_ops()
2865 * ti_sci_get_handle() - Get the TI SCI handle for a device
2866 * @dev: Pointer to device for which we want SCI handle
2869 * and is expected to be maintained by caller of TI SCI protocol library.
2872 * -EPROBE_DEFER if the instance is not ready
2873 * -ENODEV if the required node handler is missing
2874 * -EINVAL if invalid conditions are encountered.
2876 const struct ti_sci_handle *ti_sci_get_handle(struct device *dev) in ti_sci_get_handle() argument
2882 if (!dev) { in ti_sci_get_handle()
2884 return ERR_PTR(-EINVAL); in ti_sci_get_handle()
2886 ti_sci_np = of_get_parent(dev->of_node); in ti_sci_get_handle()
2888 dev_err(dev, "No OF information\n"); in ti_sci_get_handle()
2889 return ERR_PTR(-EINVAL); in ti_sci_get_handle()
2894 if (ti_sci_np == info->dev->of_node) { in ti_sci_get_handle()
2895 handle = &info->handle; in ti_sci_get_handle()
2896 info->users++; in ti_sci_get_handle()
2904 return ERR_PTR(-EPROBE_DEFER); in ti_sci_get_handle()
2911 * ti_sci_put_handle() - Release the handle acquired by ti_sci_get_handle
2915 * and is expected to be maintained by caller of TI SCI protocol library.
2920 * if null was passed, it returns -EINVAL;
2929 return -EINVAL; in ti_sci_put_handle()
2933 if (!WARN_ON(!info->users)) in ti_sci_put_handle()
2934 info->users--; in ti_sci_put_handle()
2941 static void devm_ti_sci_release(struct device *dev, void *res) in devm_ti_sci_release() argument
2949 dev_err(dev, "failed to put handle %d\n", ret); in devm_ti_sci_release()
2953 * devm_ti_sci_get_handle() - Managed get handle
2954 * @dev: device for which we want SCI handle for.
2959 * and is expected to be maintained by caller of TI SCI protocol library.
2963 const struct ti_sci_handle *devm_ti_sci_get_handle(struct device *dev) in devm_ti_sci_get_handle() argument
2970 return ERR_PTR(-ENOMEM); in devm_ti_sci_get_handle()
2971 handle = ti_sci_get_handle(dev); in devm_ti_sci_get_handle()
2975 devres_add(dev, ptr); in devm_ti_sci_get_handle()
2985 * ti_sci_get_by_phandle() - Get the TI SCI handle using DT phandle
2990 * and is expected to be maintained by caller of TI SCI protocol library.
2993 * -EPROBE_DEFER if the instance is not ready
2994 * -ENODEV if the required node handler is missing
2995 * -EINVAL if invalid conditions are encountered.
3006 return ERR_PTR(-EINVAL); in ti_sci_get_by_phandle()
3011 return ERR_PTR(-ENODEV); in ti_sci_get_by_phandle()
3015 if (ti_sci_np == info->dev->of_node) { in ti_sci_get_by_phandle()
3016 handle = &info->handle; in ti_sci_get_by_phandle()
3017 info->users++; in ti_sci_get_by_phandle()
3025 return ERR_PTR(-EPROBE_DEFER); in ti_sci_get_by_phandle()
3032 * devm_ti_sci_get_by_phandle() - Managed get handle using phandle
3033 * @dev: Device pointer requesting TISCI handle
3039 * and is expected to be maintained by caller of TI SCI protocol library.
3043 const struct ti_sci_handle *devm_ti_sci_get_by_phandle(struct device *dev, in devm_ti_sci_get_by_phandle() argument
3051 return ERR_PTR(-ENOMEM); in devm_ti_sci_get_by_phandle()
3052 handle = ti_sci_get_by_phandle(dev_of_node(dev), property); in devm_ti_sci_get_by_phandle()
3056 devres_add(dev, ptr); in devm_ti_sci_get_by_phandle()
3066 * ti_sci_get_free_resource() - Get a free resource from TISCI resource.
3076 raw_spin_lock_irqsave(&res->lock, flags); in ti_sci_get_free_resource()
3077 for (set = 0; set < res->sets; set++) { in ti_sci_get_free_resource()
3078 struct ti_sci_resource_desc *desc = &res->desc[set]; in ti_sci_get_free_resource()
3079 int res_count = desc->num + desc->num_sec; in ti_sci_get_free_resource()
3081 free_bit = find_first_zero_bit(desc->res_map, res_count); in ti_sci_get_free_resource()
3083 __set_bit(free_bit, desc->res_map); in ti_sci_get_free_resource()
3084 raw_spin_unlock_irqrestore(&res->lock, flags); in ti_sci_get_free_resource()
3086 if (desc->num && free_bit < desc->num) in ti_sci_get_free_resource()
3087 return desc->start + free_bit; in ti_sci_get_free_resource()
3089 return desc->start_sec + free_bit; in ti_sci_get_free_resource()
3092 raw_spin_unlock_irqrestore(&res->lock, flags); in ti_sci_get_free_resource()
3099 * ti_sci_release_resource() - Release a resource from TISCI resource.
3101 * @id: Resource id to be released.
3103 void ti_sci_release_resource(struct ti_sci_resource *res, u16 id) in ti_sci_release_resource() argument
3108 raw_spin_lock_irqsave(&res->lock, flags); in ti_sci_release_resource()
3109 for (set = 0; set < res->sets; set++) { in ti_sci_release_resource()
3110 struct ti_sci_resource_desc *desc = &res->desc[set]; in ti_sci_release_resource()
3112 if (desc->num && desc->start <= id && in ti_sci_release_resource()
3113 (desc->start + desc->num) > id) in ti_sci_release_resource()
3114 __clear_bit(id - desc->start, desc->res_map); in ti_sci_release_resource()
3115 else if (desc->num_sec && desc->start_sec <= id && in ti_sci_release_resource()
3116 (desc->start_sec + desc->num_sec) > id) in ti_sci_release_resource()
3117 __clear_bit(id - desc->start_sec, desc->res_map); in ti_sci_release_resource()
3119 raw_spin_unlock_irqrestore(&res->lock, flags); in ti_sci_release_resource()
3124 * ti_sci_get_num_resources() - Get the number of resources in TISCI resource
3133 for (set = 0; set < res->sets; set++) in ti_sci_get_num_resources()
3134 count += res->desc[set].num + res->desc[set].num_sec; in ti_sci_get_num_resources()
3141 * devm_ti_sci_get_resource_sets() - Get a TISCI resources assigned to a device
3143 * @dev: Device pointer to which the resource is assigned
3144 * @dev_id: TISCI device id to which the resource is assigned
3153 struct device *dev, u32 dev_id, u32 *sub_types, in devm_ti_sci_get_resource_sets() argument
3160 res = devm_kzalloc(dev, sizeof(*res), GFP_KERNEL); in devm_ti_sci_get_resource_sets()
3162 return ERR_PTR(-ENOMEM); in devm_ti_sci_get_resource_sets()
3164 res->sets = sets; in devm_ti_sci_get_resource_sets()
3165 res->desc = devm_kcalloc(dev, res->sets, sizeof(*res->desc), in devm_ti_sci_get_resource_sets()
3167 if (!res->desc) in devm_ti_sci_get_resource_sets()
3168 return ERR_PTR(-ENOMEM); in devm_ti_sci_get_resource_sets()
3170 for (i = 0; i < res->sets; i++) { in devm_ti_sci_get_resource_sets()
3171 ret = handle->ops.rm_core_ops.get_range(handle, dev_id, in devm_ti_sci_get_resource_sets()
3173 &res->desc[i]); in devm_ti_sci_get_resource_sets()
3175 dev_dbg(dev, "dev = %d subtype %d not allocated for this host\n", in devm_ti_sci_get_resource_sets()
3177 memset(&res->desc[i], 0, sizeof(res->desc[i])); in devm_ti_sci_get_resource_sets()
3181 dev_dbg(dev, "dev/sub_type: %d/%d, start/num: %d/%d | %d/%d\n", in devm_ti_sci_get_resource_sets()
3182 dev_id, sub_types[i], res->desc[i].start, in devm_ti_sci_get_resource_sets()
3183 res->desc[i].num, res->desc[i].start_sec, in devm_ti_sci_get_resource_sets()
3184 res->desc[i].num_sec); in devm_ti_sci_get_resource_sets()
3187 res_count = res->desc[i].num + res->desc[i].num_sec; in devm_ti_sci_get_resource_sets()
3188 res->desc[i].res_map = devm_bitmap_zalloc(dev, res_count, in devm_ti_sci_get_resource_sets()
3190 if (!res->desc[i].res_map) in devm_ti_sci_get_resource_sets()
3191 return ERR_PTR(-ENOMEM); in devm_ti_sci_get_resource_sets()
3193 raw_spin_lock_init(&res->lock); in devm_ti_sci_get_resource_sets()
3198 return ERR_PTR(-EINVAL); in devm_ti_sci_get_resource_sets()
3202 * devm_ti_sci_get_of_resource() - Get a TISCI resource assigned to a device
3204 * @dev: Device pointer to which the resource is assigned
3205 * @dev_id: TISCI device id to which the resource is assigned
3213 struct device *dev, u32 dev_id, char *of_prop) in devm_ti_sci_get_of_resource() argument
3219 sets = of_property_count_elems_of_size(dev_of_node(dev), of_prop, in devm_ti_sci_get_of_resource()
3222 dev_err(dev, "%s resource type ids not available\n", of_prop); in devm_ti_sci_get_of_resource()
3228 return ERR_PTR(-ENOMEM); in devm_ti_sci_get_of_resource()
3230 of_property_read_u32_array(dev_of_node(dev), of_prop, sub_types, sets); in devm_ti_sci_get_of_resource()
3231 res = devm_ti_sci_get_resource_sets(handle, dev, dev_id, sub_types, in devm_ti_sci_get_of_resource()
3240 * devm_ti_sci_get_resource() - Get a resource range assigned to the device
3242 * @dev: Device pointer to which the resource is assigned
3243 * @dev_id: TISCI device id to which the resource is assigned
3250 devm_ti_sci_get_resource(const struct ti_sci_handle *handle, struct device *dev, in devm_ti_sci_get_resource() argument
3253 return devm_ti_sci_get_resource_sets(handle, dev, dev_id, &sub_type, 1); in devm_ti_sci_get_resource()
3261 const struct ti_sci_handle *handle = &info->handle; in tisci_reboot_handler()
3290 {.compatible = "ti,k2g-sci", .data = &ti_sci_pmmc_k2g_desc},
3291 {.compatible = "ti,am654-sci", .data = &ti_sci_pmmc_am654_desc},
3298 struct device *dev = &pdev->dev; in ti_sci_probe() local
3304 int ret = -EINVAL; in ti_sci_probe()
3309 desc = device_get_match_data(dev); in ti_sci_probe()
3311 info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL); in ti_sci_probe()
3313 return -ENOMEM; in ti_sci_probe()
3315 info->dev = dev; in ti_sci_probe()
3316 info->desc = desc; in ti_sci_probe()
3317 ret = of_property_read_u32(dev->of_node, "ti,host-id", &h_id); in ti_sci_probe()
3320 info->host_id = info->desc->default_host_id; in ti_sci_probe()
3323 dev_warn(dev, "Host ID 0 is reserved for firmware\n"); in ti_sci_probe()
3324 info->host_id = info->desc->default_host_id; in ti_sci_probe()
3326 info->host_id = h_id; in ti_sci_probe()
3330 reboot = of_property_read_bool(dev->of_node, in ti_sci_probe()
3331 "ti,system-reboot-controller"); in ti_sci_probe()
3332 INIT_LIST_HEAD(&info->node); in ti_sci_probe()
3333 minfo = &info->minfo; in ti_sci_probe()
3336 * Pre-allocate messages in ti_sci_probe()
3340 if (WARN_ON(desc->max_msgs >= in ti_sci_probe()
3341 1 << 8 * sizeof(((struct ti_sci_msg_hdr *)0)->seq))) in ti_sci_probe()
3342 return -EINVAL; in ti_sci_probe()
3344 minfo->xfer_block = devm_kcalloc(dev, in ti_sci_probe()
3345 desc->max_msgs, in ti_sci_probe()
3346 sizeof(*minfo->xfer_block), in ti_sci_probe()
3348 if (!minfo->xfer_block) in ti_sci_probe()
3349 return -ENOMEM; in ti_sci_probe()
3351 minfo->xfer_alloc_table = devm_bitmap_zalloc(dev, in ti_sci_probe()
3352 desc->max_msgs, in ti_sci_probe()
3354 if (!minfo->xfer_alloc_table) in ti_sci_probe()
3355 return -ENOMEM; in ti_sci_probe()
3357 /* Pre-initialize the buffer pointer to pre-allocated buffers */ in ti_sci_probe()
3358 for (i = 0, xfer = minfo->xfer_block; i < desc->max_msgs; i++, xfer++) { in ti_sci_probe()
3359 xfer->xfer_buf = devm_kcalloc(dev, 1, desc->max_msg_size, in ti_sci_probe()
3361 if (!xfer->xfer_buf) in ti_sci_probe()
3362 return -ENOMEM; in ti_sci_probe()
3364 xfer->tx_message.buf = xfer->xfer_buf; in ti_sci_probe()
3365 init_completion(&xfer->done); in ti_sci_probe()
3370 dev_warn(dev, "Failed to create debug file\n"); in ti_sci_probe()
3374 cl = &info->cl; in ti_sci_probe()
3375 cl->dev = dev; in ti_sci_probe()
3376 cl->tx_block = false; in ti_sci_probe()
3377 cl->rx_callback = ti_sci_rx_callback; in ti_sci_probe()
3378 cl->knows_txdone = true; in ti_sci_probe()
3380 spin_lock_init(&minfo->xfer_lock); in ti_sci_probe()
3381 sema_init(&minfo->sem_xfer_count, desc->max_msgs); in ti_sci_probe()
3383 info->chan_rx = mbox_request_channel_byname(cl, "rx"); in ti_sci_probe()
3384 if (IS_ERR(info->chan_rx)) { in ti_sci_probe()
3385 ret = PTR_ERR(info->chan_rx); in ti_sci_probe()
3389 info->chan_tx = mbox_request_channel_byname(cl, "tx"); in ti_sci_probe()
3390 if (IS_ERR(info->chan_tx)) { in ti_sci_probe()
3391 ret = PTR_ERR(info->chan_tx); in ti_sci_probe()
3396 dev_err(dev, "Unable to communicate with TISCI(%d)\n", ret); in ti_sci_probe()
3403 info->nb.notifier_call = tisci_reboot_handler; in ti_sci_probe()
3404 info->nb.priority = 128; in ti_sci_probe()
3406 ret = register_restart_handler(&info->nb); in ti_sci_probe()
3408 dev_err(dev, "reboot registration fail(%d)\n", ret); in ti_sci_probe()
3413 dev_info(dev, "ABI: %d.%d (firmware rev 0x%04x '%s')\n", in ti_sci_probe()
3414 info->handle.version.abi_major, info->handle.version.abi_minor, in ti_sci_probe()
3415 info->handle.version.firmware_revision, in ti_sci_probe()
3416 info->handle.version.firmware_description); in ti_sci_probe()
3419 list_add_tail(&info->node, &ti_sci_list); in ti_sci_probe()
3422 return of_platform_populate(dev->of_node, NULL, NULL, dev); in ti_sci_probe()
3424 if (!IS_ERR(info->chan_tx)) in ti_sci_probe()
3425 mbox_free_channel(info->chan_tx); in ti_sci_probe()
3426 if (!IS_ERR(info->chan_rx)) in ti_sci_probe()
3427 mbox_free_channel(info->chan_rx); in ti_sci_probe()
3428 debugfs_remove(info->d); in ti_sci_probe()
3435 .name = "ti-sci",
3443 MODULE_DESCRIPTION("TI System Control Interface(SCI) driver");
3445 MODULE_ALIAS("platform:ti-sci");