Lines Matching +full:am654 +full:- +full:mailbox

1 // SPDX-License-Identifier: GPL-2.0
5 * Copyright (C) 2015-2022 Texas Instruments Incorporated - https://www.ti.com/
22 #include <linux/soc/ti/ti-msgmgr.h>
34 * struct ti_sci_xfer - Structure representing a message flow
38 * Since we work with request-ACK protocol, we can
51 * struct ti_sci_xfers_info - Structure to manage transfer information
69 * struct ti_sci_desc - Description of SoC integration
84 * struct ti_sci_info - Structure representing a TI SCI instance
93 * @cl: Mailbox Client
94 * @chan_tx: Transmit mailbox channel
95 * @chan_rx: Receive mailbox channel
129 * ti_sci_debug_show() - Helper to dump the debug log
137 struct ti_sci_info *info = s->private; in ti_sci_debug_show()
139 memcpy_fromio(info->debug_buffer, info->debug_region, in ti_sci_debug_show()
140 info->debug_region_size); in ti_sci_debug_show()
145 * in the buffer as is - we expect the messages to be self explanatory. in ti_sci_debug_show()
147 seq_puts(s, info->debug_buffer); in ti_sci_debug_show()
155 * ti_sci_debugfs_create() - Create log debug file
164 struct device *dev = &pdev->dev; in ti_sci_debugfs_create()
171 info->debug_region = devm_ioremap_resource(dev, res); in ti_sci_debugfs_create()
172 if (IS_ERR(info->debug_region)) in ti_sci_debugfs_create()
174 info->debug_region_size = resource_size(res); in ti_sci_debugfs_create()
176 info->debug_buffer = devm_kcalloc(dev, info->debug_region_size + 1, in ti_sci_debugfs_create()
178 if (!info->debug_buffer) in ti_sci_debugfs_create()
179 return -ENOMEM; in ti_sci_debugfs_create()
181 info->debug_buffer[info->debug_region_size] = 0; in ti_sci_debugfs_create()
183 info->d = debugfs_create_file(strncat(debug_name, dev_name(dev), in ti_sci_debugfs_create()
184 sizeof(debug_name) - in ti_sci_debugfs_create()
187 if (IS_ERR(info->d)) in ti_sci_debugfs_create()
188 return PTR_ERR(info->d); in ti_sci_debugfs_create()
191 info->debug_region, info->debug_region_size, res); in ti_sci_debugfs_create()
196 * ti_sci_debugfs_destroy() - clean up log debug file
203 if (IS_ERR(info->debug_region)) in ti_sci_debugfs_destroy()
206 debugfs_remove(info->d); in ti_sci_debugfs_destroy()
222 * ti_sci_dump_header_dbg() - Helper to dump a message header.
230 hdr->type, hdr->host, hdr->seq, hdr->flags); in ti_sci_dump_header_dbg()
234 * ti_sci_rx_callback() - mailbox client callback for receive messages
236 * @m: mailbox message
247 struct device *dev = info->dev; in ti_sci_rx_callback()
248 struct ti_sci_xfers_info *minfo = &info->minfo; in ti_sci_rx_callback()
250 struct ti_sci_msg_hdr *hdr = (struct ti_sci_msg_hdr *)mbox_msg->buf; in ti_sci_rx_callback()
254 xfer_id = hdr->seq; in ti_sci_rx_callback()
260 if (!test_bit(xfer_id, minfo->xfer_alloc_table)) { in ti_sci_rx_callback()
265 xfer = &minfo->xfer_block[xfer_id]; in ti_sci_rx_callback()
268 if (mbox_msg->len > info->desc->max_msg_size) { in ti_sci_rx_callback()
270 mbox_msg->len, info->desc->max_msg_size); in ti_sci_rx_callback()
274 if (mbox_msg->len < xfer->rx_len) { in ti_sci_rx_callback()
276 mbox_msg->len, xfer->rx_len); in ti_sci_rx_callback()
283 memcpy(xfer->xfer_buf, mbox_msg->buf, xfer->rx_len); in ti_sci_rx_callback()
284 complete(&xfer->done); in ti_sci_rx_callback()
288 * ti_sci_get_one_xfer() - Allocate one message
309 struct ti_sci_xfers_info *minfo = &info->minfo; in ti_sci_get_one_xfer()
319 if (rx_message_size > info->desc->max_msg_size || in ti_sci_get_one_xfer()
320 tx_message_size > info->desc->max_msg_size || in ti_sci_get_one_xfer()
322 return ERR_PTR(-ERANGE); in ti_sci_get_one_xfer()
329 timeout = msecs_to_jiffies(info->desc->max_rx_timeout_ms) * 5; in ti_sci_get_one_xfer()
330 ret = down_timeout(&minfo->sem_xfer_count, timeout); in ti_sci_get_one_xfer()
335 spin_lock_irqsave(&minfo->xfer_lock, flags); in ti_sci_get_one_xfer()
336 bit_pos = find_first_zero_bit(minfo->xfer_alloc_table, in ti_sci_get_one_xfer()
337 info->desc->max_msgs); in ti_sci_get_one_xfer()
338 set_bit(bit_pos, minfo->xfer_alloc_table); in ti_sci_get_one_xfer()
339 spin_unlock_irqrestore(&minfo->xfer_lock, flags); in ti_sci_get_one_xfer()
343 * fit in hdr.seq - NOTE: this improves access latencies in ti_sci_get_one_xfer()
350 xfer = &minfo->xfer_block[xfer_id]; in ti_sci_get_one_xfer()
352 hdr = (struct ti_sci_msg_hdr *)xfer->tx_message.buf; in ti_sci_get_one_xfer()
353 xfer->tx_message.len = tx_message_size; in ti_sci_get_one_xfer()
354 xfer->tx_message.chan_rx = info->chan_rx; in ti_sci_get_one_xfer()
355 xfer->tx_message.timeout_rx_ms = info->desc->max_rx_timeout_ms; in ti_sci_get_one_xfer()
356 xfer->rx_len = (u8)rx_message_size; in ti_sci_get_one_xfer()
358 reinit_completion(&xfer->done); in ti_sci_get_one_xfer()
360 hdr->seq = xfer_id; in ti_sci_get_one_xfer()
361 hdr->type = msg_type; in ti_sci_get_one_xfer()
362 hdr->host = info->host_id; in ti_sci_get_one_xfer()
363 hdr->flags = msg_flags; in ti_sci_get_one_xfer()
369 * ti_sci_put_one_xfer() - Release a message
382 hdr = (struct ti_sci_msg_hdr *)xfer->tx_message.buf; in ti_sci_put_one_xfer()
383 xfer_id = hdr->seq; in ti_sci_put_one_xfer()
390 spin_lock_irqsave(&minfo->xfer_lock, flags); in ti_sci_put_one_xfer()
391 clear_bit(xfer_id, minfo->xfer_alloc_table); in ti_sci_put_one_xfer()
392 spin_unlock_irqrestore(&minfo->xfer_lock, flags); in ti_sci_put_one_xfer()
395 up(&minfo->sem_xfer_count); in ti_sci_put_one_xfer()
399 * ti_sci_do_xfer() - Do one transfer
403 * Return: -ETIMEDOUT in case of no response, if transmit error,
412 struct device *dev = info->dev; in ti_sci_do_xfer()
415 ret = mbox_send_message(info->chan_tx, &xfer->tx_message); in ti_sci_do_xfer()
421 if (!info->is_suspending) { in ti_sci_do_xfer()
423 timeout = msecs_to_jiffies(info->desc->max_rx_timeout_ms); in ti_sci_do_xfer()
424 if (!wait_for_completion_timeout(&xfer->done, timeout)) in ti_sci_do_xfer()
425 ret = -ETIMEDOUT; in ti_sci_do_xfer()
433 info->desc->max_rx_timeout_ms * 1000, in ti_sci_do_xfer()
434 false, &xfer->done); in ti_sci_do_xfer()
437 if (ret == -ETIMEDOUT || !done_state) { in ti_sci_do_xfer()
443 * NOTE: we might prefer not to need the mailbox ticker to manage the in ti_sci_do_xfer()
445 * Unfortunately, we have to kick the mailbox framework after we have in ti_sci_do_xfer()
448 mbox_client_txdone(info->chan_tx, ret); in ti_sci_do_xfer()
454 * ti_sci_cmd_get_revision() - command to get the revision of the SCI entity
463 struct device *dev = info->dev; in ti_sci_cmd_get_revision()
464 struct ti_sci_handle *handle = &info->handle; in ti_sci_cmd_get_revision()
465 struct ti_sci_version_info *ver = &handle->version; in ti_sci_cmd_get_revision()
480 rev_info = (struct ti_sci_msg_resp_version *)xfer->xfer_buf; in ti_sci_cmd_get_revision()
488 ver->abi_major = rev_info->abi_major; in ti_sci_cmd_get_revision()
489 ver->abi_minor = rev_info->abi_minor; in ti_sci_cmd_get_revision()
490 ver->firmware_revision = rev_info->firmware_revision; in ti_sci_cmd_get_revision()
491 strncpy(ver->firmware_description, rev_info->firmware_description, in ti_sci_cmd_get_revision()
492 sizeof(ver->firmware_description)); in ti_sci_cmd_get_revision()
495 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_get_revision()
500 * ti_sci_is_response_ack() - Generic ACK/NACK message checkup
509 return hdr->flags & TI_SCI_FLAG_RESP_GENERIC_ACK ? true : false; in ti_sci_is_response_ack()
513 * ti_sci_set_device_state() - Set device state helper
534 return -EINVAL; in ti_sci_set_device_state()
537 dev = info->dev; in ti_sci_set_device_state()
547 req = (struct ti_sci_msg_req_set_device_state *)xfer->xfer_buf; in ti_sci_set_device_state()
548 req->id = id; in ti_sci_set_device_state()
549 req->state = state; in ti_sci_set_device_state()
557 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_set_device_state()
559 ret = ti_sci_is_response_ack(resp) ? 0 : -ENODEV; in ti_sci_set_device_state()
562 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_set_device_state()
568 * ti_sci_get_device_state() - Get device state helper
592 return -EINVAL; in ti_sci_get_device_state()
595 return -EINVAL; in ti_sci_get_device_state()
598 dev = info->dev; in ti_sci_get_device_state()
608 req = (struct ti_sci_msg_req_get_device_state *)xfer->xfer_buf; in ti_sci_get_device_state()
609 req->id = id; in ti_sci_get_device_state()
617 resp = (struct ti_sci_msg_resp_get_device_state *)xfer->xfer_buf; in ti_sci_get_device_state()
619 ret = -ENODEV; in ti_sci_get_device_state()
624 *clcnt = resp->context_loss_count; in ti_sci_get_device_state()
626 *resets = resp->resets; in ti_sci_get_device_state()
628 *p_state = resp->programmed_state; in ti_sci_get_device_state()
630 *c_state = resp->current_state; in ti_sci_get_device_state()
632 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_get_device_state()
638 * ti_sci_cmd_get_device() - command to request for device managed by TISCI
643 * Request for the device - NOTE: the client MUST maintain integrity of
656 * ti_sci_cmd_get_device_exclusive() - command to request for device managed by
662 * Request for the device - NOTE: the client MUST maintain integrity of
677 * ti_sci_cmd_idle_device() - Command to idle a device managed by TISCI
681 * Request for the device - NOTE: the client MUST maintain integrity of
694 * ti_sci_cmd_idle_device_exclusive() - Command to idle a device managed by
700 * Request for the device - NOTE: the client MUST maintain integrity of
715 * ti_sci_cmd_put_device() - command to release a device managed by TISCI
719 * Request for the device - NOTE: the client MUST maintain integrity of
732 * ti_sci_cmd_dev_is_valid() - Is the device valid
748 * ti_sci_cmd_dev_get_clcnt() - Get context loss counter
762 * ti_sci_cmd_dev_is_idle() - Check if the device is requested to be idle
776 return -EINVAL; in ti_sci_cmd_dev_is_idle()
788 * ti_sci_cmd_dev_is_stop() - Check if the device is requested to be stopped
803 return -EINVAL; in ti_sci_cmd_dev_is_stop()
819 * ti_sci_cmd_dev_is_on() - Check if the device is requested to be ON
834 return -EINVAL; in ti_sci_cmd_dev_is_on()
850 * ti_sci_cmd_dev_is_trans() - Check if the device is currently transitioning
864 return -EINVAL; in ti_sci_cmd_dev_is_trans()
876 * ti_sci_cmd_set_device_resets() - command to set resets for device managed
897 return -EINVAL; in ti_sci_cmd_set_device_resets()
900 dev = info->dev; in ti_sci_cmd_set_device_resets()
910 req = (struct ti_sci_msg_req_set_device_resets *)xfer->xfer_buf; in ti_sci_cmd_set_device_resets()
911 req->id = id; in ti_sci_cmd_set_device_resets()
912 req->resets = reset_state; in ti_sci_cmd_set_device_resets()
920 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_cmd_set_device_resets()
922 ret = ti_sci_is_response_ack(resp) ? 0 : -ENODEV; in ti_sci_cmd_set_device_resets()
925 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_set_device_resets()
931 * ti_sci_cmd_get_device_resets() - Get reset state for device managed
947 * ti_sci_set_clock_state() - Set clock state helper
972 return -EINVAL; in ti_sci_set_clock_state()
975 dev = info->dev; in ti_sci_set_clock_state()
985 req = (struct ti_sci_msg_req_set_clock_state *)xfer->xfer_buf; in ti_sci_set_clock_state()
986 req->dev_id = dev_id; in ti_sci_set_clock_state()
988 req->clk_id = clk_id; in ti_sci_set_clock_state()
990 req->clk_id = 255; in ti_sci_set_clock_state()
991 req->clk_id_32 = clk_id; in ti_sci_set_clock_state()
993 req->request_state = state; in ti_sci_set_clock_state()
1001 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_set_clock_state()
1003 ret = ti_sci_is_response_ack(resp) ? 0 : -ENODEV; in ti_sci_set_clock_state()
1006 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_set_clock_state()
1012 * ti_sci_cmd_get_clock_state() - Get clock state helper
1037 return -EINVAL; in ti_sci_cmd_get_clock_state()
1040 return -EINVAL; in ti_sci_cmd_get_clock_state()
1043 dev = info->dev; in ti_sci_cmd_get_clock_state()
1053 req = (struct ti_sci_msg_req_get_clock_state *)xfer->xfer_buf; in ti_sci_cmd_get_clock_state()
1054 req->dev_id = dev_id; in ti_sci_cmd_get_clock_state()
1056 req->clk_id = clk_id; in ti_sci_cmd_get_clock_state()
1058 req->clk_id = 255; in ti_sci_cmd_get_clock_state()
1059 req->clk_id_32 = clk_id; in ti_sci_cmd_get_clock_state()
1068 resp = (struct ti_sci_msg_resp_get_clock_state *)xfer->xfer_buf; in ti_sci_cmd_get_clock_state()
1071 ret = -ENODEV; in ti_sci_cmd_get_clock_state()
1076 *programmed_state = resp->programmed_state; in ti_sci_cmd_get_clock_state()
1078 *current_state = resp->current_state; in ti_sci_cmd_get_clock_state()
1081 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_get_clock_state()
1087 * ti_sci_cmd_get_clock() - Get control of a clock from TI SCI
1114 * ti_sci_cmd_idle_clock() - Idle a clock which is in our control
1134 * ti_sci_cmd_put_clock() - Release a clock from our control back to TISCI
1154 * ti_sci_cmd_clk_is_auto() - Is the clock being auto managed
1171 return -EINVAL; in ti_sci_cmd_clk_is_auto()
1182 * ti_sci_cmd_clk_is_on() - Is the clock ON
1200 return -EINVAL; in ti_sci_cmd_clk_is_on()
1215 * ti_sci_cmd_clk_is_off() - Is the clock OFF
1233 return -EINVAL; in ti_sci_cmd_clk_is_off()
1248 * ti_sci_cmd_clk_set_parent() - Set the clock source of a specific device clock
1271 return -EINVAL; in ti_sci_cmd_clk_set_parent()
1274 dev = info->dev; in ti_sci_cmd_clk_set_parent()
1284 req = (struct ti_sci_msg_req_set_clock_parent *)xfer->xfer_buf; in ti_sci_cmd_clk_set_parent()
1285 req->dev_id = dev_id; in ti_sci_cmd_clk_set_parent()
1287 req->clk_id = clk_id; in ti_sci_cmd_clk_set_parent()
1289 req->clk_id = 255; in ti_sci_cmd_clk_set_parent()
1290 req->clk_id_32 = clk_id; in ti_sci_cmd_clk_set_parent()
1293 req->parent_id = parent_id; in ti_sci_cmd_clk_set_parent()
1295 req->parent_id = 255; in ti_sci_cmd_clk_set_parent()
1296 req->parent_id_32 = parent_id; in ti_sci_cmd_clk_set_parent()
1305 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_cmd_clk_set_parent()
1307 ret = ti_sci_is_response_ack(resp) ? 0 : -ENODEV; in ti_sci_cmd_clk_set_parent()
1310 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_clk_set_parent()
1316 * ti_sci_cmd_clk_get_parent() - Get current parent clock source
1339 return -EINVAL; in ti_sci_cmd_clk_get_parent()
1342 dev = info->dev; in ti_sci_cmd_clk_get_parent()
1352 req = (struct ti_sci_msg_req_get_clock_parent *)xfer->xfer_buf; in ti_sci_cmd_clk_get_parent()
1353 req->dev_id = dev_id; in ti_sci_cmd_clk_get_parent()
1355 req->clk_id = clk_id; in ti_sci_cmd_clk_get_parent()
1357 req->clk_id = 255; in ti_sci_cmd_clk_get_parent()
1358 req->clk_id_32 = clk_id; in ti_sci_cmd_clk_get_parent()
1367 resp = (struct ti_sci_msg_resp_get_clock_parent *)xfer->xfer_buf; in ti_sci_cmd_clk_get_parent()
1370 ret = -ENODEV; in ti_sci_cmd_clk_get_parent()
1372 if (resp->parent_id < 255) in ti_sci_cmd_clk_get_parent()
1373 *parent_id = resp->parent_id; in ti_sci_cmd_clk_get_parent()
1375 *parent_id = resp->parent_id_32; in ti_sci_cmd_clk_get_parent()
1379 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_clk_get_parent()
1385 * ti_sci_cmd_clk_get_num_parents() - Get num parents of the current clk source
1409 return -EINVAL; in ti_sci_cmd_clk_get_num_parents()
1412 dev = info->dev; in ti_sci_cmd_clk_get_num_parents()
1422 req = (struct ti_sci_msg_req_get_clock_num_parents *)xfer->xfer_buf; in ti_sci_cmd_clk_get_num_parents()
1423 req->dev_id = dev_id; in ti_sci_cmd_clk_get_num_parents()
1425 req->clk_id = clk_id; in ti_sci_cmd_clk_get_num_parents()
1427 req->clk_id = 255; in ti_sci_cmd_clk_get_num_parents()
1428 req->clk_id_32 = clk_id; in ti_sci_cmd_clk_get_num_parents()
1437 resp = (struct ti_sci_msg_resp_get_clock_num_parents *)xfer->xfer_buf; in ti_sci_cmd_clk_get_num_parents()
1440 ret = -ENODEV; in ti_sci_cmd_clk_get_num_parents()
1442 if (resp->num_parents < 255) in ti_sci_cmd_clk_get_num_parents()
1443 *num_parents = resp->num_parents; in ti_sci_cmd_clk_get_num_parents()
1445 *num_parents = resp->num_parents_32; in ti_sci_cmd_clk_get_num_parents()
1449 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_clk_get_num_parents()
1455 * ti_sci_cmd_clk_get_match_freq() - Find a good match for frequency
1488 return -EINVAL; in ti_sci_cmd_clk_get_match_freq()
1491 dev = info->dev; in ti_sci_cmd_clk_get_match_freq()
1501 req = (struct ti_sci_msg_req_query_clock_freq *)xfer->xfer_buf; in ti_sci_cmd_clk_get_match_freq()
1502 req->dev_id = dev_id; in ti_sci_cmd_clk_get_match_freq()
1504 req->clk_id = clk_id; in ti_sci_cmd_clk_get_match_freq()
1506 req->clk_id = 255; in ti_sci_cmd_clk_get_match_freq()
1507 req->clk_id_32 = clk_id; in ti_sci_cmd_clk_get_match_freq()
1509 req->min_freq_hz = min_freq; in ti_sci_cmd_clk_get_match_freq()
1510 req->target_freq_hz = target_freq; in ti_sci_cmd_clk_get_match_freq()
1511 req->max_freq_hz = max_freq; in ti_sci_cmd_clk_get_match_freq()
1519 resp = (struct ti_sci_msg_resp_query_clock_freq *)xfer->xfer_buf; in ti_sci_cmd_clk_get_match_freq()
1522 ret = -ENODEV; in ti_sci_cmd_clk_get_match_freq()
1524 *match_freq = resp->freq_hz; in ti_sci_cmd_clk_get_match_freq()
1527 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_clk_get_match_freq()
1533 * ti_sci_cmd_clk_set_freq() - Set a frequency for clock
1564 return -EINVAL; in ti_sci_cmd_clk_set_freq()
1567 dev = info->dev; in ti_sci_cmd_clk_set_freq()
1577 req = (struct ti_sci_msg_req_set_clock_freq *)xfer->xfer_buf; in ti_sci_cmd_clk_set_freq()
1578 req->dev_id = dev_id; in ti_sci_cmd_clk_set_freq()
1580 req->clk_id = clk_id; in ti_sci_cmd_clk_set_freq()
1582 req->clk_id = 255; in ti_sci_cmd_clk_set_freq()
1583 req->clk_id_32 = clk_id; in ti_sci_cmd_clk_set_freq()
1585 req->min_freq_hz = min_freq; in ti_sci_cmd_clk_set_freq()
1586 req->target_freq_hz = target_freq; in ti_sci_cmd_clk_set_freq()
1587 req->max_freq_hz = max_freq; in ti_sci_cmd_clk_set_freq()
1595 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_cmd_clk_set_freq()
1597 ret = ti_sci_is_response_ack(resp) ? 0 : -ENODEV; in ti_sci_cmd_clk_set_freq()
1600 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_clk_set_freq()
1606 * ti_sci_cmd_clk_get_freq() - Get current frequency
1629 return -EINVAL; in ti_sci_cmd_clk_get_freq()
1632 dev = info->dev; in ti_sci_cmd_clk_get_freq()
1642 req = (struct ti_sci_msg_req_get_clock_freq *)xfer->xfer_buf; in ti_sci_cmd_clk_get_freq()
1643 req->dev_id = dev_id; in ti_sci_cmd_clk_get_freq()
1645 req->clk_id = clk_id; in ti_sci_cmd_clk_get_freq()
1647 req->clk_id = 255; in ti_sci_cmd_clk_get_freq()
1648 req->clk_id_32 = clk_id; in ti_sci_cmd_clk_get_freq()
1657 resp = (struct ti_sci_msg_resp_get_clock_freq *)xfer->xfer_buf; in ti_sci_cmd_clk_get_freq()
1660 ret = -ENODEV; in ti_sci_cmd_clk_get_freq()
1662 *freq = resp->freq_hz; in ti_sci_cmd_clk_get_freq()
1665 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_clk_get_freq()
1682 return -EINVAL; in ti_sci_cmd_core_reboot()
1685 dev = info->dev; in ti_sci_cmd_core_reboot()
1695 req = (struct ti_sci_msg_req_reboot *)xfer->xfer_buf; in ti_sci_cmd_core_reboot()
1703 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_cmd_core_reboot()
1706 ret = -ENODEV; in ti_sci_cmd_core_reboot()
1711 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_core_reboot()
1717 * ti_sci_get_resource_range - Helper to get a range of resources assigned
1744 return -EINVAL; in ti_sci_get_resource_range()
1747 dev = info->dev; in ti_sci_get_resource_range()
1758 req = (struct ti_sci_msg_req_get_resource_range *)xfer->xfer_buf; in ti_sci_get_resource_range()
1759 req->secondary_host = s_host; in ti_sci_get_resource_range()
1760 req->type = dev_id & MSG_RM_RESOURCE_TYPE_MASK; in ti_sci_get_resource_range()
1761 req->subtype = subtype & MSG_RM_RESOURCE_SUBTYPE_MASK; in ti_sci_get_resource_range()
1769 resp = (struct ti_sci_msg_resp_get_resource_range *)xfer->xfer_buf; in ti_sci_get_resource_range()
1772 ret = -ENODEV; in ti_sci_get_resource_range()
1773 } else if (!resp->range_num && !resp->range_num_sec) { in ti_sci_get_resource_range()
1775 ret = -ENODEV; in ti_sci_get_resource_range()
1777 desc->start = resp->range_start; in ti_sci_get_resource_range()
1778 desc->num = resp->range_num; in ti_sci_get_resource_range()
1779 desc->start_sec = resp->range_start_sec; in ti_sci_get_resource_range()
1780 desc->num_sec = resp->range_num_sec; in ti_sci_get_resource_range()
1784 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_get_resource_range()
1790 * ti_sci_cmd_get_resource_range - Get a range of resources assigned to host
1811 * ti_sci_cmd_get_resource_range_from_shost - Get a range of resources
1832 * ti_sci_manage_irq() - Helper api to configure/release the irq route between
1866 return -EINVAL; in ti_sci_manage_irq()
1869 dev = info->dev; in ti_sci_manage_irq()
1878 req = (struct ti_sci_msg_req_manage_irq *)xfer->xfer_buf; in ti_sci_manage_irq()
1879 req->valid_params = valid_params; in ti_sci_manage_irq()
1880 req->src_id = src_id; in ti_sci_manage_irq()
1881 req->src_index = src_index; in ti_sci_manage_irq()
1882 req->dst_id = dst_id; in ti_sci_manage_irq()
1883 req->dst_host_irq = dst_host_irq; in ti_sci_manage_irq()
1884 req->ia_id = ia_id; in ti_sci_manage_irq()
1885 req->vint = vint; in ti_sci_manage_irq()
1886 req->global_event = global_event; in ti_sci_manage_irq()
1887 req->vint_status_bit = vint_status_bit; in ti_sci_manage_irq()
1888 req->secondary_host = s_host; in ti_sci_manage_irq()
1896 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_manage_irq()
1898 ret = ti_sci_is_response_ack(resp) ? 0 : -ENODEV; in ti_sci_manage_irq()
1901 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_manage_irq()
1907 * ti_sci_set_irq() - Helper api to configure the irq route between the
1941 * ti_sci_free_irq() - Helper api to free the irq route between the
1975 * ti_sci_cmd_set_irq() - Configure a host irq route between the requested
1997 * ti_sci_cmd_set_event_map() - Configure an event based irq route between the
2023 * ti_sci_cmd_free_irq() - Free a host irq route between the between the
2045 * ti_sci_cmd_free_event_map() - Free an event map between the requested source
2071 * ti_sci_cmd_rm_ring_cfg() - Configure a NAVSS ring
2091 return -EINVAL; in ti_sci_cmd_rm_ring_cfg()
2094 dev = info->dev; in ti_sci_cmd_rm_ring_cfg()
2104 req = (struct ti_sci_msg_rm_ring_cfg_req *)xfer->xfer_buf; in ti_sci_cmd_rm_ring_cfg()
2105 req->valid_params = params->valid_params; in ti_sci_cmd_rm_ring_cfg()
2106 req->nav_id = params->nav_id; in ti_sci_cmd_rm_ring_cfg()
2107 req->index = params->index; in ti_sci_cmd_rm_ring_cfg()
2108 req->addr_lo = params->addr_lo; in ti_sci_cmd_rm_ring_cfg()
2109 req->addr_hi = params->addr_hi; in ti_sci_cmd_rm_ring_cfg()
2110 req->count = params->count; in ti_sci_cmd_rm_ring_cfg()
2111 req->mode = params->mode; in ti_sci_cmd_rm_ring_cfg()
2112 req->size = params->size; in ti_sci_cmd_rm_ring_cfg()
2113 req->order_id = params->order_id; in ti_sci_cmd_rm_ring_cfg()
2114 req->virtid = params->virtid; in ti_sci_cmd_rm_ring_cfg()
2115 req->asel = params->asel; in ti_sci_cmd_rm_ring_cfg()
2123 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_cmd_rm_ring_cfg()
2124 ret = ti_sci_is_response_ack(resp) ? 0 : -EINVAL; in ti_sci_cmd_rm_ring_cfg()
2127 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_rm_ring_cfg()
2128 dev_dbg(dev, "RM_RA:config ring %u ret:%d\n", params->index, ret); in ti_sci_cmd_rm_ring_cfg()
2133 * ti_sci_cmd_rm_psil_pair() - Pair PSI-L source to destination thread
2137 * @src_thread: Source PSI-L thread ID
2138 * @dst_thread: Destination PSI-L thread ID
2155 return -EINVAL; in ti_sci_cmd_rm_psil_pair()
2158 dev = info->dev; in ti_sci_cmd_rm_psil_pair()
2168 req = (struct ti_sci_msg_psil_pair *)xfer->xfer_buf; in ti_sci_cmd_rm_psil_pair()
2169 req->nav_id = nav_id; in ti_sci_cmd_rm_psil_pair()
2170 req->src_thread = src_thread; in ti_sci_cmd_rm_psil_pair()
2171 req->dst_thread = dst_thread; in ti_sci_cmd_rm_psil_pair()
2179 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_cmd_rm_psil_pair()
2180 ret = ti_sci_is_response_ack(resp) ? 0 : -EINVAL; in ti_sci_cmd_rm_psil_pair()
2183 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_rm_psil_pair()
2189 * ti_sci_cmd_rm_psil_unpair() - Unpair PSI-L source from destination thread
2193 * @src_thread: Source PSI-L thread ID
2194 * @dst_thread: Destination PSI-L thread ID
2211 return -EINVAL; in ti_sci_cmd_rm_psil_unpair()
2214 dev = info->dev; in ti_sci_cmd_rm_psil_unpair()
2224 req = (struct ti_sci_msg_psil_unpair *)xfer->xfer_buf; in ti_sci_cmd_rm_psil_unpair()
2225 req->nav_id = nav_id; in ti_sci_cmd_rm_psil_unpair()
2226 req->src_thread = src_thread; in ti_sci_cmd_rm_psil_unpair()
2227 req->dst_thread = dst_thread; in ti_sci_cmd_rm_psil_unpair()
2235 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_cmd_rm_psil_unpair()
2236 ret = ti_sci_is_response_ack(resp) ? 0 : -EINVAL; in ti_sci_cmd_rm_psil_unpair()
2239 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_rm_psil_unpair()
2245 * ti_sci_cmd_rm_udmap_tx_ch_cfg() - Configure a UDMAP TX channel
2266 return -EINVAL; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2269 dev = info->dev; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2279 req = (struct ti_sci_msg_rm_udmap_tx_ch_cfg_req *)xfer->xfer_buf; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2280 req->valid_params = params->valid_params; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2281 req->nav_id = params->nav_id; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2282 req->index = params->index; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2283 req->tx_pause_on_err = params->tx_pause_on_err; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2284 req->tx_filt_einfo = params->tx_filt_einfo; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2285 req->tx_filt_pswords = params->tx_filt_pswords; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2286 req->tx_atype = params->tx_atype; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2287 req->tx_chan_type = params->tx_chan_type; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2288 req->tx_supr_tdpkt = params->tx_supr_tdpkt; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2289 req->tx_fetch_size = params->tx_fetch_size; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2290 req->tx_credit_count = params->tx_credit_count; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2291 req->txcq_qnum = params->txcq_qnum; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2292 req->tx_priority = params->tx_priority; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2293 req->tx_qos = params->tx_qos; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2294 req->tx_orderid = params->tx_orderid; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2295 req->fdepth = params->fdepth; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2296 req->tx_sched_priority = params->tx_sched_priority; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2297 req->tx_burst_size = params->tx_burst_size; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2298 req->tx_tdtype = params->tx_tdtype; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2299 req->extended_ch_type = params->extended_ch_type; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2307 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2308 ret = ti_sci_is_response_ack(resp) ? 0 : -EINVAL; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2311 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2312 dev_dbg(dev, "TX_CH_CFG: chn %u ret:%u\n", params->index, ret); in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2317 * ti_sci_cmd_rm_udmap_rx_ch_cfg() - Configure a UDMAP RX channel
2338 return -EINVAL; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2341 dev = info->dev; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2351 req = (struct ti_sci_msg_rm_udmap_rx_ch_cfg_req *)xfer->xfer_buf; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2352 req->valid_params = params->valid_params; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2353 req->nav_id = params->nav_id; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2354 req->index = params->index; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2355 req->rx_fetch_size = params->rx_fetch_size; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2356 req->rxcq_qnum = params->rxcq_qnum; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2357 req->rx_priority = params->rx_priority; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2358 req->rx_qos = params->rx_qos; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2359 req->rx_orderid = params->rx_orderid; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2360 req->rx_sched_priority = params->rx_sched_priority; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2361 req->flowid_start = params->flowid_start; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2362 req->flowid_cnt = params->flowid_cnt; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2363 req->rx_pause_on_err = params->rx_pause_on_err; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2364 req->rx_atype = params->rx_atype; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2365 req->rx_chan_type = params->rx_chan_type; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2366 req->rx_ignore_short = params->rx_ignore_short; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2367 req->rx_ignore_long = params->rx_ignore_long; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2368 req->rx_burst_size = params->rx_burst_size; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2376 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2377 ret = ti_sci_is_response_ack(resp) ? 0 : -EINVAL; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2380 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2381 dev_dbg(dev, "RX_CH_CFG: chn %u ret:%d\n", params->index, ret); in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2386 * ti_sci_cmd_rm_udmap_rx_flow_cfg() - Configure UDMAP RX FLOW
2407 return -EINVAL; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2410 dev = info->dev; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2420 req = (struct ti_sci_msg_rm_udmap_flow_cfg_req *)xfer->xfer_buf; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2421 req->valid_params = params->valid_params; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2422 req->nav_id = params->nav_id; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2423 req->flow_index = params->flow_index; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2424 req->rx_einfo_present = params->rx_einfo_present; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2425 req->rx_psinfo_present = params->rx_psinfo_present; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2426 req->rx_error_handling = params->rx_error_handling; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2427 req->rx_desc_type = params->rx_desc_type; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2428 req->rx_sop_offset = params->rx_sop_offset; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2429 req->rx_dest_qnum = params->rx_dest_qnum; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2430 req->rx_src_tag_hi = params->rx_src_tag_hi; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2431 req->rx_src_tag_lo = params->rx_src_tag_lo; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2432 req->rx_dest_tag_hi = params->rx_dest_tag_hi; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2433 req->rx_dest_tag_lo = params->rx_dest_tag_lo; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2434 req->rx_src_tag_hi_sel = params->rx_src_tag_hi_sel; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2435 req->rx_src_tag_lo_sel = params->rx_src_tag_lo_sel; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2436 req->rx_dest_tag_hi_sel = params->rx_dest_tag_hi_sel; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2437 req->rx_dest_tag_lo_sel = params->rx_dest_tag_lo_sel; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2438 req->rx_fdq0_sz0_qnum = params->rx_fdq0_sz0_qnum; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2439 req->rx_fdq1_qnum = params->rx_fdq1_qnum; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2440 req->rx_fdq2_qnum = params->rx_fdq2_qnum; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2441 req->rx_fdq3_qnum = params->rx_fdq3_qnum; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2442 req->rx_ps_location = params->rx_ps_location; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2450 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2451 ret = ti_sci_is_response_ack(resp) ? 0 : -EINVAL; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2454 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2455 dev_dbg(info->dev, "RX_FL_CFG: %u ret:%d\n", params->flow_index, ret); in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2460 * ti_sci_cmd_proc_request() - Command to request a physical processor control
2477 return -EINVAL; in ti_sci_cmd_proc_request()
2482 dev = info->dev; in ti_sci_cmd_proc_request()
2492 req = (struct ti_sci_msg_req_proc_request *)xfer->xfer_buf; in ti_sci_cmd_proc_request()
2493 req->processor_id = proc_id; in ti_sci_cmd_proc_request()
2501 resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf; in ti_sci_cmd_proc_request()
2503 ret = ti_sci_is_response_ack(resp) ? 0 : -ENODEV; in ti_sci_cmd_proc_request()
2506 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_proc_request()
2512 * ti_sci_cmd_proc_release() - Command to release a physical processor control
2529 return -EINVAL; in ti_sci_cmd_proc_release()
2534 dev = info->dev; in ti_sci_cmd_proc_release()
2544 req = (struct ti_sci_msg_req_proc_release *)xfer->xfer_buf; in ti_sci_cmd_proc_release()
2545 req->processor_id = proc_id; in ti_sci_cmd_proc_release()
2553 resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf; in ti_sci_cmd_proc_release()
2555 ret = ti_sci_is_response_ack(resp) ? 0 : -ENODEV; in ti_sci_cmd_proc_release()
2558 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_proc_release()
2564 * ti_sci_cmd_proc_handover() - Command to handover a physical processor
2584 return -EINVAL; in ti_sci_cmd_proc_handover()
2589 dev = info->dev; in ti_sci_cmd_proc_handover()
2599 req = (struct ti_sci_msg_req_proc_handover *)xfer->xfer_buf; in ti_sci_cmd_proc_handover()
2600 req->processor_id = proc_id; in ti_sci_cmd_proc_handover()
2601 req->host_id = host_id; in ti_sci_cmd_proc_handover()
2609 resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf; in ti_sci_cmd_proc_handover()
2611 ret = ti_sci_is_response_ack(resp) ? 0 : -ENODEV; in ti_sci_cmd_proc_handover()
2614 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_proc_handover()
2620 * ti_sci_cmd_proc_set_config() - Command to set the processor boot
2642 return -EINVAL; in ti_sci_cmd_proc_set_config()
2647 dev = info->dev; in ti_sci_cmd_proc_set_config()
2657 req = (struct ti_sci_msg_req_set_config *)xfer->xfer_buf; in ti_sci_cmd_proc_set_config()
2658 req->processor_id = proc_id; in ti_sci_cmd_proc_set_config()
2659 req->bootvector_low = bootvector & TI_SCI_ADDR_LOW_MASK; in ti_sci_cmd_proc_set_config()
2660 req->bootvector_high = (bootvector & TI_SCI_ADDR_HIGH_MASK) >> in ti_sci_cmd_proc_set_config()
2662 req->config_flags_set = config_flags_set; in ti_sci_cmd_proc_set_config()
2663 req->config_flags_clear = config_flags_clear; in ti_sci_cmd_proc_set_config()
2671 resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf; in ti_sci_cmd_proc_set_config()
2673 ret = ti_sci_is_response_ack(resp) ? 0 : -ENODEV; in ti_sci_cmd_proc_set_config()
2676 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_proc_set_config()
2682 * ti_sci_cmd_proc_set_control() - Command to set the processor boot
2703 return -EINVAL; in ti_sci_cmd_proc_set_control()
2708 dev = info->dev; in ti_sci_cmd_proc_set_control()
2718 req = (struct ti_sci_msg_req_set_ctrl *)xfer->xfer_buf; in ti_sci_cmd_proc_set_control()
2719 req->processor_id = proc_id; in ti_sci_cmd_proc_set_control()
2720 req->control_flags_set = control_flags_set; in ti_sci_cmd_proc_set_control()
2721 req->control_flags_clear = control_flags_clear; in ti_sci_cmd_proc_set_control()
2729 resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf; in ti_sci_cmd_proc_set_control()
2731 ret = ti_sci_is_response_ack(resp) ? 0 : -ENODEV; in ti_sci_cmd_proc_set_control()
2734 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_proc_set_control()
2740 * ti_sci_cmd_get_boot_status() - Command to get the processor boot status
2758 return -EINVAL; in ti_sci_cmd_proc_get_status()
2763 dev = info->dev; in ti_sci_cmd_proc_get_status()
2773 req = (struct ti_sci_msg_req_get_status *)xfer->xfer_buf; in ti_sci_cmd_proc_get_status()
2774 req->processor_id = proc_id; in ti_sci_cmd_proc_get_status()
2782 resp = (struct ti_sci_msg_resp_get_status *)xfer->tx_message.buf; in ti_sci_cmd_proc_get_status()
2785 ret = -ENODEV; in ti_sci_cmd_proc_get_status()
2787 *bv = (resp->bootvector_low & TI_SCI_ADDR_LOW_MASK) | in ti_sci_cmd_proc_get_status()
2788 (((u64)resp->bootvector_high << TI_SCI_ADDR_HIGH_SHIFT) & in ti_sci_cmd_proc_get_status()
2790 *cfg_flags = resp->config_flags; in ti_sci_cmd_proc_get_status()
2791 *ctrl_flags = resp->control_flags; in ti_sci_cmd_proc_get_status()
2792 *sts_flags = resp->status_flags; in ti_sci_cmd_proc_get_status()
2796 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_proc_get_status()
2802 * ti_sci_setup_ops() - Setup the operations structures
2807 struct ti_sci_ops *ops = &info->handle.ops; in ti_sci_setup_ops()
2808 struct ti_sci_core_ops *core_ops = &ops->core_ops; in ti_sci_setup_ops()
2809 struct ti_sci_dev_ops *dops = &ops->dev_ops; in ti_sci_setup_ops()
2810 struct ti_sci_clk_ops *cops = &ops->clk_ops; in ti_sci_setup_ops()
2811 struct ti_sci_rm_core_ops *rm_core_ops = &ops->rm_core_ops; in ti_sci_setup_ops()
2812 struct ti_sci_rm_irq_ops *iops = &ops->rm_irq_ops; in ti_sci_setup_ops()
2813 struct ti_sci_rm_ringacc_ops *rops = &ops->rm_ring_ops; in ti_sci_setup_ops()
2814 struct ti_sci_rm_psil_ops *psilops = &ops->rm_psil_ops; in ti_sci_setup_ops()
2815 struct ti_sci_rm_udmap_ops *udmap_ops = &ops->rm_udmap_ops; in ti_sci_setup_ops()
2816 struct ti_sci_proc_ops *pops = &ops->proc_ops; in ti_sci_setup_ops()
2818 core_ops->reboot_device = ti_sci_cmd_core_reboot; in ti_sci_setup_ops()
2820 dops->get_device = ti_sci_cmd_get_device; in ti_sci_setup_ops()
2821 dops->get_device_exclusive = ti_sci_cmd_get_device_exclusive; in ti_sci_setup_ops()
2822 dops->idle_device = ti_sci_cmd_idle_device; in ti_sci_setup_ops()
2823 dops->idle_device_exclusive = ti_sci_cmd_idle_device_exclusive; in ti_sci_setup_ops()
2824 dops->put_device = ti_sci_cmd_put_device; in ti_sci_setup_ops()
2826 dops->is_valid = ti_sci_cmd_dev_is_valid; in ti_sci_setup_ops()
2827 dops->get_context_loss_count = ti_sci_cmd_dev_get_clcnt; in ti_sci_setup_ops()
2828 dops->is_idle = ti_sci_cmd_dev_is_idle; in ti_sci_setup_ops()
2829 dops->is_stop = ti_sci_cmd_dev_is_stop; in ti_sci_setup_ops()
2830 dops->is_on = ti_sci_cmd_dev_is_on; in ti_sci_setup_ops()
2831 dops->is_transitioning = ti_sci_cmd_dev_is_trans; in ti_sci_setup_ops()
2832 dops->set_device_resets = ti_sci_cmd_set_device_resets; in ti_sci_setup_ops()
2833 dops->get_device_resets = ti_sci_cmd_get_device_resets; in ti_sci_setup_ops()
2835 cops->get_clock = ti_sci_cmd_get_clock; in ti_sci_setup_ops()
2836 cops->idle_clock = ti_sci_cmd_idle_clock; in ti_sci_setup_ops()
2837 cops->put_clock = ti_sci_cmd_put_clock; in ti_sci_setup_ops()
2838 cops->is_auto = ti_sci_cmd_clk_is_auto; in ti_sci_setup_ops()
2839 cops->is_on = ti_sci_cmd_clk_is_on; in ti_sci_setup_ops()
2840 cops->is_off = ti_sci_cmd_clk_is_off; in ti_sci_setup_ops()
2842 cops->set_parent = ti_sci_cmd_clk_set_parent; in ti_sci_setup_ops()
2843 cops->get_parent = ti_sci_cmd_clk_get_parent; in ti_sci_setup_ops()
2844 cops->get_num_parents = ti_sci_cmd_clk_get_num_parents; in ti_sci_setup_ops()
2846 cops->get_best_match_freq = ti_sci_cmd_clk_get_match_freq; in ti_sci_setup_ops()
2847 cops->set_freq = ti_sci_cmd_clk_set_freq; in ti_sci_setup_ops()
2848 cops->get_freq = ti_sci_cmd_clk_get_freq; in ti_sci_setup_ops()
2850 rm_core_ops->get_range = ti_sci_cmd_get_resource_range; in ti_sci_setup_ops()
2851 rm_core_ops->get_range_from_shost = in ti_sci_setup_ops()
2854 iops->set_irq = ti_sci_cmd_set_irq; in ti_sci_setup_ops()
2855 iops->set_event_map = ti_sci_cmd_set_event_map; in ti_sci_setup_ops()
2856 iops->free_irq = ti_sci_cmd_free_irq; in ti_sci_setup_ops()
2857 iops->free_event_map = ti_sci_cmd_free_event_map; in ti_sci_setup_ops()
2859 rops->set_cfg = ti_sci_cmd_rm_ring_cfg; in ti_sci_setup_ops()
2861 psilops->pair = ti_sci_cmd_rm_psil_pair; in ti_sci_setup_ops()
2862 psilops->unpair = ti_sci_cmd_rm_psil_unpair; in ti_sci_setup_ops()
2864 udmap_ops->tx_ch_cfg = ti_sci_cmd_rm_udmap_tx_ch_cfg; in ti_sci_setup_ops()
2865 udmap_ops->rx_ch_cfg = ti_sci_cmd_rm_udmap_rx_ch_cfg; in ti_sci_setup_ops()
2866 udmap_ops->rx_flow_cfg = ti_sci_cmd_rm_udmap_rx_flow_cfg; in ti_sci_setup_ops()
2868 pops->request = ti_sci_cmd_proc_request; in ti_sci_setup_ops()
2869 pops->release = ti_sci_cmd_proc_release; in ti_sci_setup_ops()
2870 pops->handover = ti_sci_cmd_proc_handover; in ti_sci_setup_ops()
2871 pops->set_config = ti_sci_cmd_proc_set_config; in ti_sci_setup_ops()
2872 pops->set_control = ti_sci_cmd_proc_set_control; in ti_sci_setup_ops()
2873 pops->get_status = ti_sci_cmd_proc_get_status; in ti_sci_setup_ops()
2877 * ti_sci_get_handle() - Get the TI SCI handle for a device
2884 * -EPROBE_DEFER if the instance is not ready
2885 * -ENODEV if the required node handler is missing
2886 * -EINVAL if invalid conditions are encountered.
2897 return ERR_PTR(-EINVAL); in ti_sci_get_handle()
2899 ti_sci_np = of_get_parent(dev->of_node); in ti_sci_get_handle()
2902 return ERR_PTR(-EINVAL); in ti_sci_get_handle()
2908 if (ti_sci_np == info->dev->of_node) { in ti_sci_get_handle()
2909 handle = &info->handle; in ti_sci_get_handle()
2910 info->users++; in ti_sci_get_handle()
2918 return ERR_PTR(-EPROBE_DEFER); in ti_sci_get_handle()
2925 * ti_sci_put_handle() - Release the handle acquired by ti_sci_get_handle
2934 * if null was passed, it returns -EINVAL;
2943 return -EINVAL; in ti_sci_put_handle()
2947 if (!WARN_ON(!info->users)) in ti_sci_put_handle()
2948 info->users--; in ti_sci_put_handle()
2967 * devm_ti_sci_get_handle() - Managed get handle
2984 return ERR_PTR(-ENOMEM); in devm_ti_sci_get_handle()
2999 * ti_sci_get_by_phandle() - Get the TI SCI handle using DT phandle
3007 * -EPROBE_DEFER if the instance is not ready
3008 * -ENODEV if the required node handler is missing
3009 * -EINVAL if invalid conditions are encountered.
3021 return ERR_PTR(-EINVAL); in ti_sci_get_by_phandle()
3026 return ERR_PTR(-ENODEV); in ti_sci_get_by_phandle()
3031 if (ti_sci_np == info->dev->of_node) { in ti_sci_get_by_phandle()
3032 handle = &info->handle; in ti_sci_get_by_phandle()
3033 info->users++; in ti_sci_get_by_phandle()
3041 return ERR_PTR(-EPROBE_DEFER); in ti_sci_get_by_phandle()
3048 * devm_ti_sci_get_by_phandle() - Managed get handle using phandle
3067 return ERR_PTR(-ENOMEM); in devm_ti_sci_get_by_phandle()
3082 * ti_sci_get_free_resource() - Get a free resource from TISCI resource.
3092 raw_spin_lock_irqsave(&res->lock, flags); in ti_sci_get_free_resource()
3093 for (set = 0; set < res->sets; set++) { in ti_sci_get_free_resource()
3094 struct ti_sci_resource_desc *desc = &res->desc[set]; in ti_sci_get_free_resource()
3095 int res_count = desc->num + desc->num_sec; in ti_sci_get_free_resource()
3097 free_bit = find_first_zero_bit(desc->res_map, res_count); in ti_sci_get_free_resource()
3099 set_bit(free_bit, desc->res_map); in ti_sci_get_free_resource()
3100 raw_spin_unlock_irqrestore(&res->lock, flags); in ti_sci_get_free_resource()
3102 if (desc->num && free_bit < desc->num) in ti_sci_get_free_resource()
3103 return desc->start + free_bit; in ti_sci_get_free_resource()
3105 return desc->start_sec + free_bit; in ti_sci_get_free_resource()
3108 raw_spin_unlock_irqrestore(&res->lock, flags); in ti_sci_get_free_resource()
3115 * ti_sci_release_resource() - Release a resource from TISCI resource.
3124 raw_spin_lock_irqsave(&res->lock, flags); in ti_sci_release_resource()
3125 for (set = 0; set < res->sets; set++) { in ti_sci_release_resource()
3126 struct ti_sci_resource_desc *desc = &res->desc[set]; in ti_sci_release_resource()
3128 if (desc->num && desc->start <= id && in ti_sci_release_resource()
3129 (desc->start + desc->num) > id) in ti_sci_release_resource()
3130 clear_bit(id - desc->start, desc->res_map); in ti_sci_release_resource()
3131 else if (desc->num_sec && desc->start_sec <= id && in ti_sci_release_resource()
3132 (desc->start_sec + desc->num_sec) > id) in ti_sci_release_resource()
3133 clear_bit(id - desc->start_sec, desc->res_map); in ti_sci_release_resource()
3135 raw_spin_unlock_irqrestore(&res->lock, flags); in ti_sci_release_resource()
3140 * ti_sci_get_num_resources() - Get the number of resources in TISCI resource
3149 for (set = 0; set < res->sets; set++) in ti_sci_get_num_resources()
3150 count += res->desc[set].num + res->desc[set].num_sec; in ti_sci_get_num_resources()
3157 * devm_ti_sci_get_resource_sets() - Get a TISCI resources assigned to a device
3178 return ERR_PTR(-ENOMEM); in devm_ti_sci_get_resource_sets()
3180 res->sets = sets; in devm_ti_sci_get_resource_sets()
3181 res->desc = devm_kcalloc(dev, res->sets, sizeof(*res->desc), in devm_ti_sci_get_resource_sets()
3183 if (!res->desc) in devm_ti_sci_get_resource_sets()
3184 return ERR_PTR(-ENOMEM); in devm_ti_sci_get_resource_sets()
3186 for (i = 0; i < res->sets; i++) { in devm_ti_sci_get_resource_sets()
3187 ret = handle->ops.rm_core_ops.get_range(handle, dev_id, in devm_ti_sci_get_resource_sets()
3189 &res->desc[i]); in devm_ti_sci_get_resource_sets()
3193 memset(&res->desc[i], 0, sizeof(res->desc[i])); in devm_ti_sci_get_resource_sets()
3198 dev_id, sub_types[i], res->desc[i].start, in devm_ti_sci_get_resource_sets()
3199 res->desc[i].num, res->desc[i].start_sec, in devm_ti_sci_get_resource_sets()
3200 res->desc[i].num_sec); in devm_ti_sci_get_resource_sets()
3203 res_count = res->desc[i].num + res->desc[i].num_sec; in devm_ti_sci_get_resource_sets()
3204 res->desc[i].res_map = in devm_ti_sci_get_resource_sets()
3206 sizeof(*res->desc[i].res_map), GFP_KERNEL); in devm_ti_sci_get_resource_sets()
3207 if (!res->desc[i].res_map) in devm_ti_sci_get_resource_sets()
3208 return ERR_PTR(-ENOMEM); in devm_ti_sci_get_resource_sets()
3210 raw_spin_lock_init(&res->lock); in devm_ti_sci_get_resource_sets()
3215 return ERR_PTR(-EINVAL); in devm_ti_sci_get_resource_sets()
3219 * devm_ti_sci_get_of_resource() - Get a TISCI resource assigned to a device
3245 return ERR_PTR(-ENOMEM); in devm_ti_sci_get_of_resource()
3257 * devm_ti_sci_get_resource() - Get a resource range assigned to the device
3278 const struct ti_sci_handle *handle = &info->handle; in tisci_reboot_handler()
3288 info->is_suspending = is_suspending; in ti_sci_set_is_suspending()
3325 /* Description for AM654 */
3336 {.compatible = "ti,k2g-sci", .data = &ti_sci_pmmc_k2g_desc},
3337 {.compatible = "ti,am654-sci", .data = &ti_sci_pmmc_am654_desc},
3344 struct device *dev = &pdev->dev; in ti_sci_probe()
3351 int ret = -EINVAL; in ti_sci_probe()
3359 return -EINVAL; in ti_sci_probe()
3361 desc = of_id->data; in ti_sci_probe()
3365 return -ENOMEM; in ti_sci_probe()
3367 info->dev = dev; in ti_sci_probe()
3368 info->desc = desc; in ti_sci_probe()
3369 ret = of_property_read_u32(dev->of_node, "ti,host-id", &h_id); in ti_sci_probe()
3372 info->host_id = info->desc->default_host_id; in ti_sci_probe()
3376 info->host_id = info->desc->default_host_id; in ti_sci_probe()
3378 info->host_id = h_id; in ti_sci_probe()
3382 reboot = of_property_read_bool(dev->of_node, in ti_sci_probe()
3383 "ti,system-reboot-controller"); in ti_sci_probe()
3384 INIT_LIST_HEAD(&info->node); in ti_sci_probe()
3385 minfo = &info->minfo; in ti_sci_probe()
3388 * Pre-allocate messages in ti_sci_probe()
3392 if (WARN_ON(desc->max_msgs >= in ti_sci_probe()
3393 1 << 8 * sizeof(((struct ti_sci_msg_hdr *)0)->seq))) in ti_sci_probe()
3394 return -EINVAL; in ti_sci_probe()
3396 minfo->xfer_block = devm_kcalloc(dev, in ti_sci_probe()
3397 desc->max_msgs, in ti_sci_probe()
3398 sizeof(*minfo->xfer_block), in ti_sci_probe()
3400 if (!minfo->xfer_block) in ti_sci_probe()
3401 return -ENOMEM; in ti_sci_probe()
3403 minfo->xfer_alloc_table = devm_kcalloc(dev, in ti_sci_probe()
3404 BITS_TO_LONGS(desc->max_msgs), in ti_sci_probe()
3407 if (!minfo->xfer_alloc_table) in ti_sci_probe()
3408 return -ENOMEM; in ti_sci_probe()
3409 bitmap_zero(minfo->xfer_alloc_table, desc->max_msgs); in ti_sci_probe()
3411 /* Pre-initialize the buffer pointer to pre-allocated buffers */ in ti_sci_probe()
3412 for (i = 0, xfer = minfo->xfer_block; i < desc->max_msgs; i++, xfer++) { in ti_sci_probe()
3413 xfer->xfer_buf = devm_kcalloc(dev, 1, desc->max_msg_size, in ti_sci_probe()
3415 if (!xfer->xfer_buf) in ti_sci_probe()
3416 return -ENOMEM; in ti_sci_probe()
3418 xfer->tx_message.buf = xfer->xfer_buf; in ti_sci_probe()
3419 init_completion(&xfer->done); in ti_sci_probe()
3428 cl = &info->cl; in ti_sci_probe()
3429 cl->dev = dev; in ti_sci_probe()
3430 cl->tx_block = false; in ti_sci_probe()
3431 cl->rx_callback = ti_sci_rx_callback; in ti_sci_probe()
3432 cl->knows_txdone = true; in ti_sci_probe()
3434 spin_lock_init(&minfo->xfer_lock); in ti_sci_probe()
3435 sema_init(&minfo->sem_xfer_count, desc->max_msgs); in ti_sci_probe()
3437 info->chan_rx = mbox_request_channel_byname(cl, "rx"); in ti_sci_probe()
3438 if (IS_ERR(info->chan_rx)) { in ti_sci_probe()
3439 ret = PTR_ERR(info->chan_rx); in ti_sci_probe()
3443 info->chan_tx = mbox_request_channel_byname(cl, "tx"); in ti_sci_probe()
3444 if (IS_ERR(info->chan_tx)) { in ti_sci_probe()
3445 ret = PTR_ERR(info->chan_tx); in ti_sci_probe()
3457 info->nb.notifier_call = tisci_reboot_handler; in ti_sci_probe()
3458 info->nb.priority = 128; in ti_sci_probe()
3460 ret = register_restart_handler(&info->nb); in ti_sci_probe()
3468 info->handle.version.abi_major, info->handle.version.abi_minor, in ti_sci_probe()
3469 info->handle.version.firmware_revision, in ti_sci_probe()
3470 info->handle.version.firmware_description); in ti_sci_probe()
3473 list_add_tail(&info->node, &ti_sci_list); in ti_sci_probe()
3476 return of_platform_populate(dev->of_node, NULL, NULL, dev); in ti_sci_probe()
3478 if (!IS_ERR(info->chan_tx)) in ti_sci_probe()
3479 mbox_free_channel(info->chan_tx); in ti_sci_probe()
3480 if (!IS_ERR(info->chan_rx)) in ti_sci_probe()
3481 mbox_free_channel(info->chan_rx); in ti_sci_probe()
3482 debugfs_remove(info->d); in ti_sci_probe()
3489 struct device *dev = &pdev->dev; in ti_sci_remove()
3496 if (info->nb.notifier_call) in ti_sci_remove()
3497 unregister_restart_handler(&info->nb); in ti_sci_remove()
3500 if (info->users) in ti_sci_remove()
3501 ret = -EBUSY; in ti_sci_remove()
3503 list_del(&info->node); in ti_sci_remove()
3510 mbox_free_channel(info->chan_tx); in ti_sci_remove()
3511 mbox_free_channel(info->chan_rx); in ti_sci_remove()
3521 .name = "ti-sci",
3531 MODULE_ALIAS("platform:ti-sci");