Lines Matching +full:tx +full:- +full:termination +full:- +full:fix

1 // SPDX-License-Identifier: GPL-2.0
5 * Copyright (C) 2015-2016 Texas Instruments Incorporated - https://www.ti.com/
21 #include <linux/soc/ti/ti-msgmgr.h>
33 * struct ti_sci_xfer - Structure representing a message flow
37 * Since we work with request-ACK protocol, we can
39 * use for the tx path.
50 * struct ti_sci_xfers_info - Structure to manage transfer information
68 * struct ti_sci_desc - Description of SoC integration
83 * struct ti_sci_info - Structure representing a TI SCI instance
127 * ti_sci_debug_show() - Helper to dump the debug log
135 struct ti_sci_info *info = s->private; in ti_sci_debug_show()
137 memcpy_fromio(info->debug_buffer, info->debug_region, in ti_sci_debug_show()
138 info->debug_region_size); in ti_sci_debug_show()
143 * in the buffer as is - we expect the messages to be self explanatory. in ti_sci_debug_show()
145 seq_puts(s, info->debug_buffer); in ti_sci_debug_show()
153 * ti_sci_debugfs_create() - Create log debug file
162 struct device *dev = &pdev->dev; in ti_sci_debugfs_create()
169 info->debug_region = devm_ioremap_resource(dev, res); in ti_sci_debugfs_create()
170 if (IS_ERR(info->debug_region)) in ti_sci_debugfs_create()
172 info->debug_region_size = resource_size(res); in ti_sci_debugfs_create()
174 info->debug_buffer = devm_kcalloc(dev, info->debug_region_size + 1, in ti_sci_debugfs_create()
176 if (!info->debug_buffer) in ti_sci_debugfs_create()
177 return -ENOMEM; in ti_sci_debugfs_create()
178 /* Setup NULL termination */ in ti_sci_debugfs_create()
179 info->debug_buffer[info->debug_region_size] = 0; in ti_sci_debugfs_create()
181 info->d = debugfs_create_file(strncat(debug_name, dev_name(dev), in ti_sci_debugfs_create()
182 sizeof(debug_name) - in ti_sci_debugfs_create()
185 if (IS_ERR(info->d)) in ti_sci_debugfs_create()
186 return PTR_ERR(info->d); in ti_sci_debugfs_create()
189 info->debug_region, info->debug_region_size, res); in ti_sci_debugfs_create()
194 * ti_sci_debugfs_destroy() - clean up log debug file
201 if (IS_ERR(info->debug_region)) in ti_sci_debugfs_destroy()
204 debugfs_remove(info->d); in ti_sci_debugfs_destroy()
220 * ti_sci_dump_header_dbg() - Helper to dump a message header.
228 hdr->type, hdr->host, hdr->seq, hdr->flags); in ti_sci_dump_header_dbg()
232 * ti_sci_rx_callback() - mailbox client callback for receive messages
245 struct device *dev = info->dev; in ti_sci_rx_callback()
246 struct ti_sci_xfers_info *minfo = &info->minfo; in ti_sci_rx_callback()
248 struct ti_sci_msg_hdr *hdr = (struct ti_sci_msg_hdr *)mbox_msg->buf; in ti_sci_rx_callback()
252 xfer_id = hdr->seq; in ti_sci_rx_callback()
258 if (!test_bit(xfer_id, minfo->xfer_alloc_table)) { in ti_sci_rx_callback()
263 xfer = &minfo->xfer_block[xfer_id]; in ti_sci_rx_callback()
266 if (mbox_msg->len > info->desc->max_msg_size) { in ti_sci_rx_callback()
268 mbox_msg->len, info->desc->max_msg_size); in ti_sci_rx_callback()
272 if (mbox_msg->len < xfer->rx_len) { in ti_sci_rx_callback()
274 mbox_msg->len, xfer->rx_len); in ti_sci_rx_callback()
281 memcpy(xfer->xfer_buf, mbox_msg->buf, xfer->rx_len); in ti_sci_rx_callback()
282 complete(&xfer->done); in ti_sci_rx_callback()
286 * ti_sci_get_one_xfer() - Allocate one message
307 struct ti_sci_xfers_info *minfo = &info->minfo; in ti_sci_get_one_xfer()
317 if (rx_message_size > info->desc->max_msg_size || in ti_sci_get_one_xfer()
318 tx_message_size > info->desc->max_msg_size || in ti_sci_get_one_xfer()
320 return ERR_PTR(-ERANGE); in ti_sci_get_one_xfer()
327 timeout = msecs_to_jiffies(info->desc->max_rx_timeout_ms) * 5; in ti_sci_get_one_xfer()
328 ret = down_timeout(&minfo->sem_xfer_count, timeout); in ti_sci_get_one_xfer()
333 spin_lock_irqsave(&minfo->xfer_lock, flags); in ti_sci_get_one_xfer()
334 bit_pos = find_first_zero_bit(minfo->xfer_alloc_table, in ti_sci_get_one_xfer()
335 info->desc->max_msgs); in ti_sci_get_one_xfer()
336 set_bit(bit_pos, minfo->xfer_alloc_table); in ti_sci_get_one_xfer()
337 spin_unlock_irqrestore(&minfo->xfer_lock, flags); in ti_sci_get_one_xfer()
341 * fit in hdr.seq - NOTE: this improves access latencies in ti_sci_get_one_xfer()
348 xfer = &minfo->xfer_block[xfer_id]; in ti_sci_get_one_xfer()
350 hdr = (struct ti_sci_msg_hdr *)xfer->tx_message.buf; in ti_sci_get_one_xfer()
351 xfer->tx_message.len = tx_message_size; in ti_sci_get_one_xfer()
352 xfer->rx_len = (u8)rx_message_size; in ti_sci_get_one_xfer()
354 reinit_completion(&xfer->done); in ti_sci_get_one_xfer()
356 hdr->seq = xfer_id; in ti_sci_get_one_xfer()
357 hdr->type = msg_type; in ti_sci_get_one_xfer()
358 hdr->host = info->host_id; in ti_sci_get_one_xfer()
359 hdr->flags = msg_flags; in ti_sci_get_one_xfer()
365 * ti_sci_put_one_xfer() - Release a message
378 hdr = (struct ti_sci_msg_hdr *)xfer->tx_message.buf; in ti_sci_put_one_xfer()
379 xfer_id = hdr->seq; in ti_sci_put_one_xfer()
386 spin_lock_irqsave(&minfo->xfer_lock, flags); in ti_sci_put_one_xfer()
387 clear_bit(xfer_id, minfo->xfer_alloc_table); in ti_sci_put_one_xfer()
388 spin_unlock_irqrestore(&minfo->xfer_lock, flags); in ti_sci_put_one_xfer()
391 up(&minfo->sem_xfer_count); in ti_sci_put_one_xfer()
395 * ti_sci_do_xfer() - Do one transfer
399 * Return: -ETIMEDOUT in case of no response, if transmit error,
408 struct device *dev = info->dev; in ti_sci_do_xfer()
410 ret = mbox_send_message(info->chan_tx, &xfer->tx_message); in ti_sci_do_xfer()
417 timeout = msecs_to_jiffies(info->desc->max_rx_timeout_ms); in ti_sci_do_xfer()
418 if (!wait_for_completion_timeout(&xfer->done, timeout)) { in ti_sci_do_xfer()
421 ret = -ETIMEDOUT; in ti_sci_do_xfer()
429 mbox_client_txdone(info->chan_tx, ret); in ti_sci_do_xfer()
435 * ti_sci_cmd_get_revision() - command to get the revision of the SCI entity
444 struct device *dev = info->dev; in ti_sci_cmd_get_revision()
445 struct ti_sci_handle *handle = &info->handle; in ti_sci_cmd_get_revision()
446 struct ti_sci_version_info *ver = &handle->version; in ti_sci_cmd_get_revision()
461 rev_info = (struct ti_sci_msg_resp_version *)xfer->xfer_buf; in ti_sci_cmd_get_revision()
469 ver->abi_major = rev_info->abi_major; in ti_sci_cmd_get_revision()
470 ver->abi_minor = rev_info->abi_minor; in ti_sci_cmd_get_revision()
471 ver->firmware_revision = rev_info->firmware_revision; in ti_sci_cmd_get_revision()
472 strncpy(ver->firmware_description, rev_info->firmware_description, in ti_sci_cmd_get_revision()
473 sizeof(ver->firmware_description)); in ti_sci_cmd_get_revision()
476 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_get_revision()
481 * ti_sci_is_response_ack() - Generic ACK/NACK message checkup
490 return hdr->flags & TI_SCI_FLAG_RESP_GENERIC_ACK ? true : false; in ti_sci_is_response_ack()
494 * ti_sci_set_device_state() - Set device state helper
515 return -EINVAL; in ti_sci_set_device_state()
518 dev = info->dev; in ti_sci_set_device_state()
528 req = (struct ti_sci_msg_req_set_device_state *)xfer->xfer_buf; in ti_sci_set_device_state()
529 req->id = id; in ti_sci_set_device_state()
530 req->state = state; in ti_sci_set_device_state()
538 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_set_device_state()
540 ret = ti_sci_is_response_ack(resp) ? 0 : -ENODEV; in ti_sci_set_device_state()
543 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_set_device_state()
549 * ti_sci_get_device_state() - Get device state helper
573 return -EINVAL; in ti_sci_get_device_state()
576 return -EINVAL; in ti_sci_get_device_state()
579 dev = info->dev; in ti_sci_get_device_state()
589 req = (struct ti_sci_msg_req_get_device_state *)xfer->xfer_buf; in ti_sci_get_device_state()
590 req->id = id; in ti_sci_get_device_state()
598 resp = (struct ti_sci_msg_resp_get_device_state *)xfer->xfer_buf; in ti_sci_get_device_state()
600 ret = -ENODEV; in ti_sci_get_device_state()
605 *clcnt = resp->context_loss_count; in ti_sci_get_device_state()
607 *resets = resp->resets; in ti_sci_get_device_state()
609 *p_state = resp->programmed_state; in ti_sci_get_device_state()
611 *c_state = resp->current_state; in ti_sci_get_device_state()
613 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_get_device_state()
619 * ti_sci_cmd_get_device() - command to request for device managed by TISCI
624 * Request for the device - NOTE: the client MUST maintain integrity of
637 * ti_sci_cmd_get_device_exclusive() - command to request for device managed by
643 * Request for the device - NOTE: the client MUST maintain integrity of
658 * ti_sci_cmd_idle_device() - Command to idle a device managed by TISCI
662 * Request for the device - NOTE: the client MUST maintain integrity of
675 * ti_sci_cmd_idle_device_exclusive() - Command to idle a device managed by
681 * Request for the device - NOTE: the client MUST maintain integrity of
696 * ti_sci_cmd_put_device() - command to release a device managed by TISCI
700 * Request for the device - NOTE: the client MUST maintain integrity of
713 * ti_sci_cmd_dev_is_valid() - Is the device valid
729 * ti_sci_cmd_dev_get_clcnt() - Get context loss counter
743 * ti_sci_cmd_dev_is_idle() - Check if the device is requested to be idle
757 return -EINVAL; in ti_sci_cmd_dev_is_idle()
769 * ti_sci_cmd_dev_is_stop() - Check if the device is requested to be stopped
784 return -EINVAL; in ti_sci_cmd_dev_is_stop()
800 * ti_sci_cmd_dev_is_on() - Check if the device is requested to be ON
815 return -EINVAL; in ti_sci_cmd_dev_is_on()
831 * ti_sci_cmd_dev_is_trans() - Check if the device is currently transitioning
845 return -EINVAL; in ti_sci_cmd_dev_is_trans()
857 * ti_sci_cmd_set_device_resets() - command to set resets for device managed
878 return -EINVAL; in ti_sci_cmd_set_device_resets()
881 dev = info->dev; in ti_sci_cmd_set_device_resets()
891 req = (struct ti_sci_msg_req_set_device_resets *)xfer->xfer_buf; in ti_sci_cmd_set_device_resets()
892 req->id = id; in ti_sci_cmd_set_device_resets()
893 req->resets = reset_state; in ti_sci_cmd_set_device_resets()
901 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_cmd_set_device_resets()
903 ret = ti_sci_is_response_ack(resp) ? 0 : -ENODEV; in ti_sci_cmd_set_device_resets()
906 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_set_device_resets()
912 * ti_sci_cmd_get_device_resets() - Get reset state for device managed
928 * ti_sci_set_clock_state() - Set clock state helper
953 return -EINVAL; in ti_sci_set_clock_state()
956 dev = info->dev; in ti_sci_set_clock_state()
966 req = (struct ti_sci_msg_req_set_clock_state *)xfer->xfer_buf; in ti_sci_set_clock_state()
967 req->dev_id = dev_id; in ti_sci_set_clock_state()
969 req->clk_id = clk_id; in ti_sci_set_clock_state()
971 req->clk_id = 255; in ti_sci_set_clock_state()
972 req->clk_id_32 = clk_id; in ti_sci_set_clock_state()
974 req->request_state = state; in ti_sci_set_clock_state()
982 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_set_clock_state()
984 ret = ti_sci_is_response_ack(resp) ? 0 : -ENODEV; in ti_sci_set_clock_state()
987 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_set_clock_state()
993 * ti_sci_cmd_get_clock_state() - Get clock state helper
1018 return -EINVAL; in ti_sci_cmd_get_clock_state()
1021 return -EINVAL; in ti_sci_cmd_get_clock_state()
1024 dev = info->dev; in ti_sci_cmd_get_clock_state()
1034 req = (struct ti_sci_msg_req_get_clock_state *)xfer->xfer_buf; in ti_sci_cmd_get_clock_state()
1035 req->dev_id = dev_id; in ti_sci_cmd_get_clock_state()
1037 req->clk_id = clk_id; in ti_sci_cmd_get_clock_state()
1039 req->clk_id = 255; in ti_sci_cmd_get_clock_state()
1040 req->clk_id_32 = clk_id; in ti_sci_cmd_get_clock_state()
1049 resp = (struct ti_sci_msg_resp_get_clock_state *)xfer->xfer_buf; in ti_sci_cmd_get_clock_state()
1052 ret = -ENODEV; in ti_sci_cmd_get_clock_state()
1057 *programmed_state = resp->programmed_state; in ti_sci_cmd_get_clock_state()
1059 *current_state = resp->current_state; in ti_sci_cmd_get_clock_state()
1062 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_get_clock_state()
1068 * ti_sci_cmd_get_clock() - Get control of a clock from TI SCI
1076 * @enable_input_term: 'true' if input termination is desired, else 'false'
1095 * ti_sci_cmd_idle_clock() - Idle a clock which is in our control
1115 * ti_sci_cmd_put_clock() - Release a clock from our control back to TISCI
1135 * ti_sci_cmd_clk_is_auto() - Is the clock being auto managed
1152 return -EINVAL; in ti_sci_cmd_clk_is_auto()
1163 * ti_sci_cmd_clk_is_on() - Is the clock ON
1181 return -EINVAL; in ti_sci_cmd_clk_is_on()
1196 * ti_sci_cmd_clk_is_off() - Is the clock OFF
1214 return -EINVAL; in ti_sci_cmd_clk_is_off()
1229 * ti_sci_cmd_clk_set_parent() - Set the clock source of a specific device clock
1252 return -EINVAL; in ti_sci_cmd_clk_set_parent()
1255 dev = info->dev; in ti_sci_cmd_clk_set_parent()
1265 req = (struct ti_sci_msg_req_set_clock_parent *)xfer->xfer_buf; in ti_sci_cmd_clk_set_parent()
1266 req->dev_id = dev_id; in ti_sci_cmd_clk_set_parent()
1268 req->clk_id = clk_id; in ti_sci_cmd_clk_set_parent()
1270 req->clk_id = 255; in ti_sci_cmd_clk_set_parent()
1271 req->clk_id_32 = clk_id; in ti_sci_cmd_clk_set_parent()
1274 req->parent_id = parent_id; in ti_sci_cmd_clk_set_parent()
1276 req->parent_id = 255; in ti_sci_cmd_clk_set_parent()
1277 req->parent_id_32 = parent_id; in ti_sci_cmd_clk_set_parent()
1286 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_cmd_clk_set_parent()
1288 ret = ti_sci_is_response_ack(resp) ? 0 : -ENODEV; in ti_sci_cmd_clk_set_parent()
1291 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_clk_set_parent()
1297 * ti_sci_cmd_clk_get_parent() - Get current parent clock source
1320 return -EINVAL; in ti_sci_cmd_clk_get_parent()
1323 dev = info->dev; in ti_sci_cmd_clk_get_parent()
1333 req = (struct ti_sci_msg_req_get_clock_parent *)xfer->xfer_buf; in ti_sci_cmd_clk_get_parent()
1334 req->dev_id = dev_id; in ti_sci_cmd_clk_get_parent()
1336 req->clk_id = clk_id; in ti_sci_cmd_clk_get_parent()
1338 req->clk_id = 255; in ti_sci_cmd_clk_get_parent()
1339 req->clk_id_32 = clk_id; in ti_sci_cmd_clk_get_parent()
1348 resp = (struct ti_sci_msg_resp_get_clock_parent *)xfer->xfer_buf; in ti_sci_cmd_clk_get_parent()
1351 ret = -ENODEV; in ti_sci_cmd_clk_get_parent()
1353 if (resp->parent_id < 255) in ti_sci_cmd_clk_get_parent()
1354 *parent_id = resp->parent_id; in ti_sci_cmd_clk_get_parent()
1356 *parent_id = resp->parent_id_32; in ti_sci_cmd_clk_get_parent()
1360 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_clk_get_parent()
1366 * ti_sci_cmd_clk_get_num_parents() - Get num parents of the current clk source
1390 return -EINVAL; in ti_sci_cmd_clk_get_num_parents()
1393 dev = info->dev; in ti_sci_cmd_clk_get_num_parents()
1403 req = (struct ti_sci_msg_req_get_clock_num_parents *)xfer->xfer_buf; in ti_sci_cmd_clk_get_num_parents()
1404 req->dev_id = dev_id; in ti_sci_cmd_clk_get_num_parents()
1406 req->clk_id = clk_id; in ti_sci_cmd_clk_get_num_parents()
1408 req->clk_id = 255; in ti_sci_cmd_clk_get_num_parents()
1409 req->clk_id_32 = clk_id; in ti_sci_cmd_clk_get_num_parents()
1418 resp = (struct ti_sci_msg_resp_get_clock_num_parents *)xfer->xfer_buf; in ti_sci_cmd_clk_get_num_parents()
1421 ret = -ENODEV; in ti_sci_cmd_clk_get_num_parents()
1423 if (resp->num_parents < 255) in ti_sci_cmd_clk_get_num_parents()
1424 *num_parents = resp->num_parents; in ti_sci_cmd_clk_get_num_parents()
1426 *num_parents = resp->num_parents_32; in ti_sci_cmd_clk_get_num_parents()
1430 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_clk_get_num_parents()
1436 * ti_sci_cmd_clk_get_match_freq() - Find a good match for frequency
1469 return -EINVAL; in ti_sci_cmd_clk_get_match_freq()
1472 dev = info->dev; in ti_sci_cmd_clk_get_match_freq()
1482 req = (struct ti_sci_msg_req_query_clock_freq *)xfer->xfer_buf; in ti_sci_cmd_clk_get_match_freq()
1483 req->dev_id = dev_id; in ti_sci_cmd_clk_get_match_freq()
1485 req->clk_id = clk_id; in ti_sci_cmd_clk_get_match_freq()
1487 req->clk_id = 255; in ti_sci_cmd_clk_get_match_freq()
1488 req->clk_id_32 = clk_id; in ti_sci_cmd_clk_get_match_freq()
1490 req->min_freq_hz = min_freq; in ti_sci_cmd_clk_get_match_freq()
1491 req->target_freq_hz = target_freq; in ti_sci_cmd_clk_get_match_freq()
1492 req->max_freq_hz = max_freq; in ti_sci_cmd_clk_get_match_freq()
1500 resp = (struct ti_sci_msg_resp_query_clock_freq *)xfer->xfer_buf; in ti_sci_cmd_clk_get_match_freq()
1503 ret = -ENODEV; in ti_sci_cmd_clk_get_match_freq()
1505 *match_freq = resp->freq_hz; in ti_sci_cmd_clk_get_match_freq()
1508 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_clk_get_match_freq()
1514 * ti_sci_cmd_clk_set_freq() - Set a frequency for clock
1545 return -EINVAL; in ti_sci_cmd_clk_set_freq()
1548 dev = info->dev; in ti_sci_cmd_clk_set_freq()
1558 req = (struct ti_sci_msg_req_set_clock_freq *)xfer->xfer_buf; in ti_sci_cmd_clk_set_freq()
1559 req->dev_id = dev_id; in ti_sci_cmd_clk_set_freq()
1561 req->clk_id = clk_id; in ti_sci_cmd_clk_set_freq()
1563 req->clk_id = 255; in ti_sci_cmd_clk_set_freq()
1564 req->clk_id_32 = clk_id; in ti_sci_cmd_clk_set_freq()
1566 req->min_freq_hz = min_freq; in ti_sci_cmd_clk_set_freq()
1567 req->target_freq_hz = target_freq; in ti_sci_cmd_clk_set_freq()
1568 req->max_freq_hz = max_freq; in ti_sci_cmd_clk_set_freq()
1576 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_cmd_clk_set_freq()
1578 ret = ti_sci_is_response_ack(resp) ? 0 : -ENODEV; in ti_sci_cmd_clk_set_freq()
1581 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_clk_set_freq()
1587 * ti_sci_cmd_clk_get_freq() - Get current frequency
1610 return -EINVAL; in ti_sci_cmd_clk_get_freq()
1613 dev = info->dev; in ti_sci_cmd_clk_get_freq()
1623 req = (struct ti_sci_msg_req_get_clock_freq *)xfer->xfer_buf; in ti_sci_cmd_clk_get_freq()
1624 req->dev_id = dev_id; in ti_sci_cmd_clk_get_freq()
1626 req->clk_id = clk_id; in ti_sci_cmd_clk_get_freq()
1628 req->clk_id = 255; in ti_sci_cmd_clk_get_freq()
1629 req->clk_id_32 = clk_id; in ti_sci_cmd_clk_get_freq()
1638 resp = (struct ti_sci_msg_resp_get_clock_freq *)xfer->xfer_buf; in ti_sci_cmd_clk_get_freq()
1641 ret = -ENODEV; in ti_sci_cmd_clk_get_freq()
1643 *freq = resp->freq_hz; in ti_sci_cmd_clk_get_freq()
1646 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_clk_get_freq()
1663 return -EINVAL; in ti_sci_cmd_core_reboot()
1666 dev = info->dev; in ti_sci_cmd_core_reboot()
1676 req = (struct ti_sci_msg_req_reboot *)xfer->xfer_buf; in ti_sci_cmd_core_reboot()
1684 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_cmd_core_reboot()
1687 ret = -ENODEV; in ti_sci_cmd_core_reboot()
1692 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_core_reboot()
1698 * ti_sci_get_resource_range - Helper to get a range of resources assigned
1725 return -EINVAL; in ti_sci_get_resource_range()
1728 dev = info->dev; in ti_sci_get_resource_range()
1739 req = (struct ti_sci_msg_req_get_resource_range *)xfer->xfer_buf; in ti_sci_get_resource_range()
1740 req->secondary_host = s_host; in ti_sci_get_resource_range()
1741 req->type = dev_id & MSG_RM_RESOURCE_TYPE_MASK; in ti_sci_get_resource_range()
1742 req->subtype = subtype & MSG_RM_RESOURCE_SUBTYPE_MASK; in ti_sci_get_resource_range()
1750 resp = (struct ti_sci_msg_resp_get_resource_range *)xfer->xfer_buf; in ti_sci_get_resource_range()
1753 ret = -ENODEV; in ti_sci_get_resource_range()
1754 } else if (!resp->range_start && !resp->range_num) { in ti_sci_get_resource_range()
1755 ret = -ENODEV; in ti_sci_get_resource_range()
1757 *range_start = resp->range_start; in ti_sci_get_resource_range()
1758 *range_num = resp->range_num; in ti_sci_get_resource_range()
1762 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_get_resource_range()
1768 * ti_sci_cmd_get_resource_range - Get a range of resources assigned to host
1789 * ti_sci_cmd_get_resource_range_from_shost - Get a range of resources
1811 * ti_sci_manage_irq() - Helper api to configure/release the irq route between
1845 return -EINVAL; in ti_sci_manage_irq()
1848 dev = info->dev; in ti_sci_manage_irq()
1857 req = (struct ti_sci_msg_req_manage_irq *)xfer->xfer_buf; in ti_sci_manage_irq()
1858 req->valid_params = valid_params; in ti_sci_manage_irq()
1859 req->src_id = src_id; in ti_sci_manage_irq()
1860 req->src_index = src_index; in ti_sci_manage_irq()
1861 req->dst_id = dst_id; in ti_sci_manage_irq()
1862 req->dst_host_irq = dst_host_irq; in ti_sci_manage_irq()
1863 req->ia_id = ia_id; in ti_sci_manage_irq()
1864 req->vint = vint; in ti_sci_manage_irq()
1865 req->global_event = global_event; in ti_sci_manage_irq()
1866 req->vint_status_bit = vint_status_bit; in ti_sci_manage_irq()
1867 req->secondary_host = s_host; in ti_sci_manage_irq()
1875 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_manage_irq()
1877 ret = ti_sci_is_response_ack(resp) ? 0 : -ENODEV; in ti_sci_manage_irq()
1880 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_manage_irq()
1886 * ti_sci_set_irq() - Helper api to configure the irq route between the
1920 * ti_sci_free_irq() - Helper api to free the irq route between the
1954 * ti_sci_cmd_set_irq() - Configure a host irq route between the requested
1976 * ti_sci_cmd_set_event_map() - Configure an event based irq route between the
2002 * ti_sci_cmd_free_irq() - Free a host irq route between the between the
2024 * ti_sci_cmd_free_event_map() - Free an event map between the requested source
2050 * ti_sci_cmd_ring_config() - configure RA ring
2081 return -EINVAL; in ti_sci_cmd_ring_config()
2084 dev = info->dev; in ti_sci_cmd_ring_config()
2094 req = (struct ti_sci_msg_rm_ring_cfg_req *)xfer->xfer_buf; in ti_sci_cmd_ring_config()
2095 req->valid_params = valid_params; in ti_sci_cmd_ring_config()
2096 req->nav_id = nav_id; in ti_sci_cmd_ring_config()
2097 req->index = index; in ti_sci_cmd_ring_config()
2098 req->addr_lo = addr_lo; in ti_sci_cmd_ring_config()
2099 req->addr_hi = addr_hi; in ti_sci_cmd_ring_config()
2100 req->count = count; in ti_sci_cmd_ring_config()
2101 req->mode = mode; in ti_sci_cmd_ring_config()
2102 req->size = size; in ti_sci_cmd_ring_config()
2103 req->order_id = order_id; in ti_sci_cmd_ring_config()
2111 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_cmd_ring_config()
2112 ret = ti_sci_is_response_ack(resp) ? 0 : -ENODEV; in ti_sci_cmd_ring_config()
2115 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_ring_config()
2121 * ti_sci_cmd_ring_get_config() - get RA ring configuration
2150 return -EINVAL; in ti_sci_cmd_ring_get_config()
2153 dev = info->dev; in ti_sci_cmd_ring_get_config()
2164 req = (struct ti_sci_msg_rm_ring_get_cfg_req *)xfer->xfer_buf; in ti_sci_cmd_ring_get_config()
2165 req->nav_id = nav_id; in ti_sci_cmd_ring_get_config()
2166 req->index = index; in ti_sci_cmd_ring_get_config()
2174 resp = (struct ti_sci_msg_rm_ring_get_cfg_resp *)xfer->xfer_buf; in ti_sci_cmd_ring_get_config()
2177 ret = -ENODEV; in ti_sci_cmd_ring_get_config()
2180 *mode = resp->mode; in ti_sci_cmd_ring_get_config()
2182 *addr_lo = resp->addr_lo; in ti_sci_cmd_ring_get_config()
2184 *addr_hi = resp->addr_hi; in ti_sci_cmd_ring_get_config()
2186 *count = resp->count; in ti_sci_cmd_ring_get_config()
2188 *size = resp->size; in ti_sci_cmd_ring_get_config()
2190 *order_id = resp->order_id; in ti_sci_cmd_ring_get_config()
2194 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_ring_get_config()
2200 * ti_sci_cmd_rm_psil_pair() - Pair PSI-L source to destination thread
2204 * @src_thread: Source PSI-L thread ID
2205 * @dst_thread: Destination PSI-L thread ID
2222 return -EINVAL; in ti_sci_cmd_rm_psil_pair()
2225 dev = info->dev; in ti_sci_cmd_rm_psil_pair()
2235 req = (struct ti_sci_msg_psil_pair *)xfer->xfer_buf; in ti_sci_cmd_rm_psil_pair()
2236 req->nav_id = nav_id; in ti_sci_cmd_rm_psil_pair()
2237 req->src_thread = src_thread; in ti_sci_cmd_rm_psil_pair()
2238 req->dst_thread = dst_thread; in ti_sci_cmd_rm_psil_pair()
2246 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_cmd_rm_psil_pair()
2247 ret = ti_sci_is_response_ack(resp) ? 0 : -EINVAL; in ti_sci_cmd_rm_psil_pair()
2250 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_rm_psil_pair()
2256 * ti_sci_cmd_rm_psil_unpair() - Unpair PSI-L source from destination thread
2260 * @src_thread: Source PSI-L thread ID
2261 * @dst_thread: Destination PSI-L thread ID
2278 return -EINVAL; in ti_sci_cmd_rm_psil_unpair()
2281 dev = info->dev; in ti_sci_cmd_rm_psil_unpair()
2291 req = (struct ti_sci_msg_psil_unpair *)xfer->xfer_buf; in ti_sci_cmd_rm_psil_unpair()
2292 req->nav_id = nav_id; in ti_sci_cmd_rm_psil_unpair()
2293 req->src_thread = src_thread; in ti_sci_cmd_rm_psil_unpair()
2294 req->dst_thread = dst_thread; in ti_sci_cmd_rm_psil_unpair()
2302 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_cmd_rm_psil_unpair()
2303 ret = ti_sci_is_response_ack(resp) ? 0 : -EINVAL; in ti_sci_cmd_rm_psil_unpair()
2306 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_rm_psil_unpair()
2312 * ti_sci_cmd_rm_udmap_tx_ch_cfg() - Configure a UDMAP TX channel
2314 * @params: Pointer to ti_sci_msg_rm_udmap_tx_ch_cfg TX channel config
2333 return -EINVAL; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2336 dev = info->dev; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2346 req = (struct ti_sci_msg_rm_udmap_tx_ch_cfg_req *)xfer->xfer_buf; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2347 req->valid_params = params->valid_params; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2348 req->nav_id = params->nav_id; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2349 req->index = params->index; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2350 req->tx_pause_on_err = params->tx_pause_on_err; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2351 req->tx_filt_einfo = params->tx_filt_einfo; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2352 req->tx_filt_pswords = params->tx_filt_pswords; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2353 req->tx_atype = params->tx_atype; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2354 req->tx_chan_type = params->tx_chan_type; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2355 req->tx_supr_tdpkt = params->tx_supr_tdpkt; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2356 req->tx_fetch_size = params->tx_fetch_size; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2357 req->tx_credit_count = params->tx_credit_count; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2358 req->txcq_qnum = params->txcq_qnum; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2359 req->tx_priority = params->tx_priority; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2360 req->tx_qos = params->tx_qos; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2361 req->tx_orderid = params->tx_orderid; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2362 req->fdepth = params->fdepth; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2363 req->tx_sched_priority = params->tx_sched_priority; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2364 req->tx_burst_size = params->tx_burst_size; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2372 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2373 ret = ti_sci_is_response_ack(resp) ? 0 : -EINVAL; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2376 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2377 dev_dbg(dev, "TX_CH_CFG: chn %u ret:%u\n", params->index, ret); in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2382 * ti_sci_cmd_rm_udmap_rx_ch_cfg() - Configure a UDMAP RX channel
2403 return -EINVAL; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2406 dev = info->dev; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2416 req = (struct ti_sci_msg_rm_udmap_rx_ch_cfg_req *)xfer->xfer_buf; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2417 req->valid_params = params->valid_params; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2418 req->nav_id = params->nav_id; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2419 req->index = params->index; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2420 req->rx_fetch_size = params->rx_fetch_size; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2421 req->rxcq_qnum = params->rxcq_qnum; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2422 req->rx_priority = params->rx_priority; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2423 req->rx_qos = params->rx_qos; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2424 req->rx_orderid = params->rx_orderid; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2425 req->rx_sched_priority = params->rx_sched_priority; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2426 req->flowid_start = params->flowid_start; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2427 req->flowid_cnt = params->flowid_cnt; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2428 req->rx_pause_on_err = params->rx_pause_on_err; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2429 req->rx_atype = params->rx_atype; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2430 req->rx_chan_type = params->rx_chan_type; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2431 req->rx_ignore_short = params->rx_ignore_short; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2432 req->rx_ignore_long = params->rx_ignore_long; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2433 req->rx_burst_size = params->rx_burst_size; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2441 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2442 ret = ti_sci_is_response_ack(resp) ? 0 : -EINVAL; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2445 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2446 dev_dbg(dev, "RX_CH_CFG: chn %u ret:%d\n", params->index, ret); in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2451 * ti_sci_cmd_rm_udmap_rx_flow_cfg() - Configure UDMAP RX FLOW
2472 return -EINVAL; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2475 dev = info->dev; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2485 req = (struct ti_sci_msg_rm_udmap_flow_cfg_req *)xfer->xfer_buf; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2486 req->valid_params = params->valid_params; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2487 req->nav_id = params->nav_id; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2488 req->flow_index = params->flow_index; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2489 req->rx_einfo_present = params->rx_einfo_present; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2490 req->rx_psinfo_present = params->rx_psinfo_present; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2491 req->rx_error_handling = params->rx_error_handling; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2492 req->rx_desc_type = params->rx_desc_type; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2493 req->rx_sop_offset = params->rx_sop_offset; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2494 req->rx_dest_qnum = params->rx_dest_qnum; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2495 req->rx_src_tag_hi = params->rx_src_tag_hi; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2496 req->rx_src_tag_lo = params->rx_src_tag_lo; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2497 req->rx_dest_tag_hi = params->rx_dest_tag_hi; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2498 req->rx_dest_tag_lo = params->rx_dest_tag_lo; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2499 req->rx_src_tag_hi_sel = params->rx_src_tag_hi_sel; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2500 req->rx_src_tag_lo_sel = params->rx_src_tag_lo_sel; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2501 req->rx_dest_tag_hi_sel = params->rx_dest_tag_hi_sel; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2502 req->rx_dest_tag_lo_sel = params->rx_dest_tag_lo_sel; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2503 req->rx_fdq0_sz0_qnum = params->rx_fdq0_sz0_qnum; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2504 req->rx_fdq1_qnum = params->rx_fdq1_qnum; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2505 req->rx_fdq2_qnum = params->rx_fdq2_qnum; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2506 req->rx_fdq3_qnum = params->rx_fdq3_qnum; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2507 req->rx_ps_location = params->rx_ps_location; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2515 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2516 ret = ti_sci_is_response_ack(resp) ? 0 : -EINVAL; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2519 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2520 dev_dbg(info->dev, "RX_FL_CFG: %u ret:%d\n", params->flow_index, ret); in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2525 * ti_sci_cmd_proc_request() - Command to request a physical processor control
2542 return -EINVAL; in ti_sci_cmd_proc_request()
2547 dev = info->dev; in ti_sci_cmd_proc_request()
2557 req = (struct ti_sci_msg_req_proc_request *)xfer->xfer_buf; in ti_sci_cmd_proc_request()
2558 req->processor_id = proc_id; in ti_sci_cmd_proc_request()
2566 resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf; in ti_sci_cmd_proc_request()
2568 ret = ti_sci_is_response_ack(resp) ? 0 : -ENODEV; in ti_sci_cmd_proc_request()
2571 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_proc_request()
2577 * ti_sci_cmd_proc_release() - Command to release a physical processor control
2594 return -EINVAL; in ti_sci_cmd_proc_release()
2599 dev = info->dev; in ti_sci_cmd_proc_release()
2609 req = (struct ti_sci_msg_req_proc_release *)xfer->xfer_buf; in ti_sci_cmd_proc_release()
2610 req->processor_id = proc_id; in ti_sci_cmd_proc_release()
2618 resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf; in ti_sci_cmd_proc_release()
2620 ret = ti_sci_is_response_ack(resp) ? 0 : -ENODEV; in ti_sci_cmd_proc_release()
2623 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_proc_release()
2629 * ti_sci_cmd_proc_handover() - Command to handover a physical processor
2649 return -EINVAL; in ti_sci_cmd_proc_handover()
2654 dev = info->dev; in ti_sci_cmd_proc_handover()
2664 req = (struct ti_sci_msg_req_proc_handover *)xfer->xfer_buf; in ti_sci_cmd_proc_handover()
2665 req->processor_id = proc_id; in ti_sci_cmd_proc_handover()
2666 req->host_id = host_id; in ti_sci_cmd_proc_handover()
2674 resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf; in ti_sci_cmd_proc_handover()
2676 ret = ti_sci_is_response_ack(resp) ? 0 : -ENODEV; in ti_sci_cmd_proc_handover()
2679 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_proc_handover()
2685 * ti_sci_cmd_proc_set_config() - Command to set the processor boot
2707 return -EINVAL; in ti_sci_cmd_proc_set_config()
2712 dev = info->dev; in ti_sci_cmd_proc_set_config()
2722 req = (struct ti_sci_msg_req_set_config *)xfer->xfer_buf; in ti_sci_cmd_proc_set_config()
2723 req->processor_id = proc_id; in ti_sci_cmd_proc_set_config()
2724 req->bootvector_low = bootvector & TI_SCI_ADDR_LOW_MASK; in ti_sci_cmd_proc_set_config()
2725 req->bootvector_high = (bootvector & TI_SCI_ADDR_HIGH_MASK) >> in ti_sci_cmd_proc_set_config()
2727 req->config_flags_set = config_flags_set; in ti_sci_cmd_proc_set_config()
2728 req->config_flags_clear = config_flags_clear; in ti_sci_cmd_proc_set_config()
2736 resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf; in ti_sci_cmd_proc_set_config()
2738 ret = ti_sci_is_response_ack(resp) ? 0 : -ENODEV; in ti_sci_cmd_proc_set_config()
2741 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_proc_set_config()
2747 * ti_sci_cmd_proc_set_control() - Command to set the processor boot
2768 return -EINVAL; in ti_sci_cmd_proc_set_control()
2773 dev = info->dev; in ti_sci_cmd_proc_set_control()
2783 req = (struct ti_sci_msg_req_set_ctrl *)xfer->xfer_buf; in ti_sci_cmd_proc_set_control()
2784 req->processor_id = proc_id; in ti_sci_cmd_proc_set_control()
2785 req->control_flags_set = control_flags_set; in ti_sci_cmd_proc_set_control()
2786 req->control_flags_clear = control_flags_clear; in ti_sci_cmd_proc_set_control()
2794 resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf; in ti_sci_cmd_proc_set_control()
2796 ret = ti_sci_is_response_ack(resp) ? 0 : -ENODEV; in ti_sci_cmd_proc_set_control()
2799 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_proc_set_control()
2805 * ti_sci_cmd_get_boot_status() - Command to get the processor boot status
2823 return -EINVAL; in ti_sci_cmd_proc_get_status()
2828 dev = info->dev; in ti_sci_cmd_proc_get_status()
2838 req = (struct ti_sci_msg_req_get_status *)xfer->xfer_buf; in ti_sci_cmd_proc_get_status()
2839 req->processor_id = proc_id; in ti_sci_cmd_proc_get_status()
2847 resp = (struct ti_sci_msg_resp_get_status *)xfer->tx_message.buf; in ti_sci_cmd_proc_get_status()
2850 ret = -ENODEV; in ti_sci_cmd_proc_get_status()
2852 *bv = (resp->bootvector_low & TI_SCI_ADDR_LOW_MASK) | in ti_sci_cmd_proc_get_status()
2853 (((u64)resp->bootvector_high << TI_SCI_ADDR_HIGH_SHIFT) & in ti_sci_cmd_proc_get_status()
2855 *cfg_flags = resp->config_flags; in ti_sci_cmd_proc_get_status()
2856 *ctrl_flags = resp->control_flags; in ti_sci_cmd_proc_get_status()
2857 *sts_flags = resp->status_flags; in ti_sci_cmd_proc_get_status()
2861 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_proc_get_status()
2867 * ti_sci_setup_ops() - Setup the operations structures
2872 struct ti_sci_ops *ops = &info->handle.ops; in ti_sci_setup_ops()
2873 struct ti_sci_core_ops *core_ops = &ops->core_ops; in ti_sci_setup_ops()
2874 struct ti_sci_dev_ops *dops = &ops->dev_ops; in ti_sci_setup_ops()
2875 struct ti_sci_clk_ops *cops = &ops->clk_ops; in ti_sci_setup_ops()
2876 struct ti_sci_rm_core_ops *rm_core_ops = &ops->rm_core_ops; in ti_sci_setup_ops()
2877 struct ti_sci_rm_irq_ops *iops = &ops->rm_irq_ops; in ti_sci_setup_ops()
2878 struct ti_sci_rm_ringacc_ops *rops = &ops->rm_ring_ops; in ti_sci_setup_ops()
2879 struct ti_sci_rm_psil_ops *psilops = &ops->rm_psil_ops; in ti_sci_setup_ops()
2880 struct ti_sci_rm_udmap_ops *udmap_ops = &ops->rm_udmap_ops; in ti_sci_setup_ops()
2881 struct ti_sci_proc_ops *pops = &ops->proc_ops; in ti_sci_setup_ops()
2883 core_ops->reboot_device = ti_sci_cmd_core_reboot; in ti_sci_setup_ops()
2885 dops->get_device = ti_sci_cmd_get_device; in ti_sci_setup_ops()
2886 dops->get_device_exclusive = ti_sci_cmd_get_device_exclusive; in ti_sci_setup_ops()
2887 dops->idle_device = ti_sci_cmd_idle_device; in ti_sci_setup_ops()
2888 dops->idle_device_exclusive = ti_sci_cmd_idle_device_exclusive; in ti_sci_setup_ops()
2889 dops->put_device = ti_sci_cmd_put_device; in ti_sci_setup_ops()
2891 dops->is_valid = ti_sci_cmd_dev_is_valid; in ti_sci_setup_ops()
2892 dops->get_context_loss_count = ti_sci_cmd_dev_get_clcnt; in ti_sci_setup_ops()
2893 dops->is_idle = ti_sci_cmd_dev_is_idle; in ti_sci_setup_ops()
2894 dops->is_stop = ti_sci_cmd_dev_is_stop; in ti_sci_setup_ops()
2895 dops->is_on = ti_sci_cmd_dev_is_on; in ti_sci_setup_ops()
2896 dops->is_transitioning = ti_sci_cmd_dev_is_trans; in ti_sci_setup_ops()
2897 dops->set_device_resets = ti_sci_cmd_set_device_resets; in ti_sci_setup_ops()
2898 dops->get_device_resets = ti_sci_cmd_get_device_resets; in ti_sci_setup_ops()
2900 cops->get_clock = ti_sci_cmd_get_clock; in ti_sci_setup_ops()
2901 cops->idle_clock = ti_sci_cmd_idle_clock; in ti_sci_setup_ops()
2902 cops->put_clock = ti_sci_cmd_put_clock; in ti_sci_setup_ops()
2903 cops->is_auto = ti_sci_cmd_clk_is_auto; in ti_sci_setup_ops()
2904 cops->is_on = ti_sci_cmd_clk_is_on; in ti_sci_setup_ops()
2905 cops->is_off = ti_sci_cmd_clk_is_off; in ti_sci_setup_ops()
2907 cops->set_parent = ti_sci_cmd_clk_set_parent; in ti_sci_setup_ops()
2908 cops->get_parent = ti_sci_cmd_clk_get_parent; in ti_sci_setup_ops()
2909 cops->get_num_parents = ti_sci_cmd_clk_get_num_parents; in ti_sci_setup_ops()
2911 cops->get_best_match_freq = ti_sci_cmd_clk_get_match_freq; in ti_sci_setup_ops()
2912 cops->set_freq = ti_sci_cmd_clk_set_freq; in ti_sci_setup_ops()
2913 cops->get_freq = ti_sci_cmd_clk_get_freq; in ti_sci_setup_ops()
2915 rm_core_ops->get_range = ti_sci_cmd_get_resource_range; in ti_sci_setup_ops()
2916 rm_core_ops->get_range_from_shost = in ti_sci_setup_ops()
2919 iops->set_irq = ti_sci_cmd_set_irq; in ti_sci_setup_ops()
2920 iops->set_event_map = ti_sci_cmd_set_event_map; in ti_sci_setup_ops()
2921 iops->free_irq = ti_sci_cmd_free_irq; in ti_sci_setup_ops()
2922 iops->free_event_map = ti_sci_cmd_free_event_map; in ti_sci_setup_ops()
2924 rops->config = ti_sci_cmd_ring_config; in ti_sci_setup_ops()
2925 rops->get_config = ti_sci_cmd_ring_get_config; in ti_sci_setup_ops()
2927 psilops->pair = ti_sci_cmd_rm_psil_pair; in ti_sci_setup_ops()
2928 psilops->unpair = ti_sci_cmd_rm_psil_unpair; in ti_sci_setup_ops()
2930 udmap_ops->tx_ch_cfg = ti_sci_cmd_rm_udmap_tx_ch_cfg; in ti_sci_setup_ops()
2931 udmap_ops->rx_ch_cfg = ti_sci_cmd_rm_udmap_rx_ch_cfg; in ti_sci_setup_ops()
2932 udmap_ops->rx_flow_cfg = ti_sci_cmd_rm_udmap_rx_flow_cfg; in ti_sci_setup_ops()
2934 pops->request = ti_sci_cmd_proc_request; in ti_sci_setup_ops()
2935 pops->release = ti_sci_cmd_proc_release; in ti_sci_setup_ops()
2936 pops->handover = ti_sci_cmd_proc_handover; in ti_sci_setup_ops()
2937 pops->set_config = ti_sci_cmd_proc_set_config; in ti_sci_setup_ops()
2938 pops->set_control = ti_sci_cmd_proc_set_control; in ti_sci_setup_ops()
2939 pops->get_status = ti_sci_cmd_proc_get_status; in ti_sci_setup_ops()
2943 * ti_sci_get_handle() - Get the TI SCI handle for a device
2950 * -EPROBE_DEFER if the instance is not ready
2951 * -ENODEV if the required node handler is missing
2952 * -EINVAL if invalid conditions are encountered.
2963 return ERR_PTR(-EINVAL); in ti_sci_get_handle()
2965 ti_sci_np = of_get_parent(dev->of_node); in ti_sci_get_handle()
2968 return ERR_PTR(-EINVAL); in ti_sci_get_handle()
2974 if (ti_sci_np == info->dev->of_node) { in ti_sci_get_handle()
2975 handle = &info->handle; in ti_sci_get_handle()
2976 info->users++; in ti_sci_get_handle()
2984 return ERR_PTR(-EPROBE_DEFER); in ti_sci_get_handle()
2991 * ti_sci_put_handle() - Release the handle acquired by ti_sci_get_handle
3000 * if null was passed, it returns -EINVAL;
3009 return -EINVAL; in ti_sci_put_handle()
3013 if (!WARN_ON(!info->users)) in ti_sci_put_handle()
3014 info->users--; in ti_sci_put_handle()
3033 * devm_ti_sci_get_handle() - Managed get handle
3050 return ERR_PTR(-ENOMEM); in devm_ti_sci_get_handle()
3065 * ti_sci_get_by_phandle() - Get the TI SCI handle using DT phandle
3073 * -EPROBE_DEFER if the instance is not ready
3074 * -ENODEV if the required node handler is missing
3075 * -EINVAL if invalid conditions are encountered.
3087 return ERR_PTR(-EINVAL); in ti_sci_get_by_phandle()
3092 return ERR_PTR(-ENODEV); in ti_sci_get_by_phandle()
3097 if (ti_sci_np == info->dev->of_node) { in ti_sci_get_by_phandle()
3098 handle = &info->handle; in ti_sci_get_by_phandle()
3099 info->users++; in ti_sci_get_by_phandle()
3107 return ERR_PTR(-EPROBE_DEFER); in ti_sci_get_by_phandle()
3114 * devm_ti_sci_get_by_phandle() - Managed get handle using phandle
3133 return ERR_PTR(-ENOMEM); in devm_ti_sci_get_by_phandle()
3148 * ti_sci_get_free_resource() - Get a free resource from TISCI resource.
3158 raw_spin_lock_irqsave(&res->lock, flags); in ti_sci_get_free_resource()
3159 for (set = 0; set < res->sets; set++) { in ti_sci_get_free_resource()
3160 free_bit = find_first_zero_bit(res->desc[set].res_map, in ti_sci_get_free_resource()
3161 res->desc[set].num); in ti_sci_get_free_resource()
3162 if (free_bit != res->desc[set].num) { in ti_sci_get_free_resource()
3163 set_bit(free_bit, res->desc[set].res_map); in ti_sci_get_free_resource()
3164 raw_spin_unlock_irqrestore(&res->lock, flags); in ti_sci_get_free_resource()
3165 return res->desc[set].start + free_bit; in ti_sci_get_free_resource()
3168 raw_spin_unlock_irqrestore(&res->lock, flags); in ti_sci_get_free_resource()
3175 * ti_sci_release_resource() - Release a resource from TISCI resource.
3184 raw_spin_lock_irqsave(&res->lock, flags); in ti_sci_release_resource()
3185 for (set = 0; set < res->sets; set++) { in ti_sci_release_resource()
3186 if (res->desc[set].start <= id && in ti_sci_release_resource()
3187 (res->desc[set].num + res->desc[set].start) > id) in ti_sci_release_resource()
3188 clear_bit(id - res->desc[set].start, in ti_sci_release_resource()
3189 res->desc[set].res_map); in ti_sci_release_resource()
3191 raw_spin_unlock_irqrestore(&res->lock, flags); in ti_sci_release_resource()
3196 * ti_sci_get_num_resources() - Get the number of resources in TISCI resource
3205 for (set = 0; set < res->sets; set++) in ti_sci_get_num_resources()
3206 count += res->desc[set].num; in ti_sci_get_num_resources()
3213 * devm_ti_sci_get_resource_sets() - Get a TISCI resources assigned to a device
3234 return ERR_PTR(-ENOMEM); in devm_ti_sci_get_resource_sets()
3236 res->sets = sets; in devm_ti_sci_get_resource_sets()
3237 res->desc = devm_kcalloc(dev, res->sets, sizeof(*res->desc), in devm_ti_sci_get_resource_sets()
3239 if (!res->desc) in devm_ti_sci_get_resource_sets()
3240 return ERR_PTR(-ENOMEM); in devm_ti_sci_get_resource_sets()
3242 for (i = 0; i < res->sets; i++) { in devm_ti_sci_get_resource_sets()
3243 ret = handle->ops.rm_core_ops.get_range(handle, dev_id, in devm_ti_sci_get_resource_sets()
3245 &res->desc[i].start, in devm_ti_sci_get_resource_sets()
3246 &res->desc[i].num); in devm_ti_sci_get_resource_sets()
3250 res->desc[i].start = 0; in devm_ti_sci_get_resource_sets()
3251 res->desc[i].num = 0; in devm_ti_sci_get_resource_sets()
3256 dev_id, sub_types[i], res->desc[i].start, in devm_ti_sci_get_resource_sets()
3257 res->desc[i].num); in devm_ti_sci_get_resource_sets()
3260 res->desc[i].res_map = in devm_ti_sci_get_resource_sets()
3261 devm_kzalloc(dev, BITS_TO_LONGS(res->desc[i].num) * in devm_ti_sci_get_resource_sets()
3262 sizeof(*res->desc[i].res_map), GFP_KERNEL); in devm_ti_sci_get_resource_sets()
3263 if (!res->desc[i].res_map) in devm_ti_sci_get_resource_sets()
3264 return ERR_PTR(-ENOMEM); in devm_ti_sci_get_resource_sets()
3266 raw_spin_lock_init(&res->lock); in devm_ti_sci_get_resource_sets()
3271 return ERR_PTR(-EINVAL); in devm_ti_sci_get_resource_sets()
3275 * devm_ti_sci_get_of_resource() - Get a TISCI resource assigned to a device
3301 return ERR_PTR(-ENOMEM); in devm_ti_sci_get_of_resource()
3313 * devm_ti_sci_get_resource() - Get a resource range assigned to the device
3334 const struct ti_sci_handle *handle = &info->handle; in tisci_reboot_handler()
3363 {.compatible = "ti,k2g-sci", .data = &ti_sci_pmmc_k2g_desc},
3364 {.compatible = "ti,am654-sci", .data = &ti_sci_pmmc_am654_desc},
3371 struct device *dev = &pdev->dev; in ti_sci_probe()
3378 int ret = -EINVAL; in ti_sci_probe()
3386 return -EINVAL; in ti_sci_probe()
3388 desc = of_id->data; in ti_sci_probe()
3392 return -ENOMEM; in ti_sci_probe()
3394 info->dev = dev; in ti_sci_probe()
3395 info->desc = desc; in ti_sci_probe()
3396 ret = of_property_read_u32(dev->of_node, "ti,host-id", &h_id); in ti_sci_probe()
3399 info->host_id = info->desc->default_host_id; in ti_sci_probe()
3403 info->host_id = info->desc->default_host_id; in ti_sci_probe()
3405 info->host_id = h_id; in ti_sci_probe()
3409 reboot = of_property_read_bool(dev->of_node, in ti_sci_probe()
3410 "ti,system-reboot-controller"); in ti_sci_probe()
3411 INIT_LIST_HEAD(&info->node); in ti_sci_probe()
3412 minfo = &info->minfo; in ti_sci_probe()
3415 * Pre-allocate messages in ti_sci_probe()
3417 * if we have data description bug, force a fix.. in ti_sci_probe()
3419 if (WARN_ON(desc->max_msgs >= in ti_sci_probe()
3420 1 << 8 * sizeof(((struct ti_sci_msg_hdr *)0)->seq))) in ti_sci_probe()
3421 return -EINVAL; in ti_sci_probe()
3423 minfo->xfer_block = devm_kcalloc(dev, in ti_sci_probe()
3424 desc->max_msgs, in ti_sci_probe()
3425 sizeof(*minfo->xfer_block), in ti_sci_probe()
3427 if (!minfo->xfer_block) in ti_sci_probe()
3428 return -ENOMEM; in ti_sci_probe()
3430 minfo->xfer_alloc_table = devm_kcalloc(dev, in ti_sci_probe()
3431 BITS_TO_LONGS(desc->max_msgs), in ti_sci_probe()
3434 if (!minfo->xfer_alloc_table) in ti_sci_probe()
3435 return -ENOMEM; in ti_sci_probe()
3436 bitmap_zero(minfo->xfer_alloc_table, desc->max_msgs); in ti_sci_probe()
3438 /* Pre-initialize the buffer pointer to pre-allocated buffers */ in ti_sci_probe()
3439 for (i = 0, xfer = minfo->xfer_block; i < desc->max_msgs; i++, xfer++) { in ti_sci_probe()
3440 xfer->xfer_buf = devm_kcalloc(dev, 1, desc->max_msg_size, in ti_sci_probe()
3442 if (!xfer->xfer_buf) in ti_sci_probe()
3443 return -ENOMEM; in ti_sci_probe()
3445 xfer->tx_message.buf = xfer->xfer_buf; in ti_sci_probe()
3446 init_completion(&xfer->done); in ti_sci_probe()
3455 cl = &info->cl; in ti_sci_probe()
3456 cl->dev = dev; in ti_sci_probe()
3457 cl->tx_block = false; in ti_sci_probe()
3458 cl->rx_callback = ti_sci_rx_callback; in ti_sci_probe()
3459 cl->knows_txdone = true; in ti_sci_probe()
3461 spin_lock_init(&minfo->xfer_lock); in ti_sci_probe()
3462 sema_init(&minfo->sem_xfer_count, desc->max_msgs); in ti_sci_probe()
3464 info->chan_rx = mbox_request_channel_byname(cl, "rx"); in ti_sci_probe()
3465 if (IS_ERR(info->chan_rx)) { in ti_sci_probe()
3466 ret = PTR_ERR(info->chan_rx); in ti_sci_probe()
3470 info->chan_tx = mbox_request_channel_byname(cl, "tx"); in ti_sci_probe()
3471 if (IS_ERR(info->chan_tx)) { in ti_sci_probe()
3472 ret = PTR_ERR(info->chan_tx); in ti_sci_probe()
3484 info->nb.notifier_call = tisci_reboot_handler; in ti_sci_probe()
3485 info->nb.priority = 128; in ti_sci_probe()
3487 ret = register_restart_handler(&info->nb); in ti_sci_probe()
3495 info->handle.version.abi_major, info->handle.version.abi_minor, in ti_sci_probe()
3496 info->handle.version.firmware_revision, in ti_sci_probe()
3497 info->handle.version.firmware_description); in ti_sci_probe()
3500 list_add_tail(&info->node, &ti_sci_list); in ti_sci_probe()
3503 return of_platform_populate(dev->of_node, NULL, NULL, dev); in ti_sci_probe()
3505 if (!IS_ERR(info->chan_tx)) in ti_sci_probe()
3506 mbox_free_channel(info->chan_tx); in ti_sci_probe()
3507 if (!IS_ERR(info->chan_rx)) in ti_sci_probe()
3508 mbox_free_channel(info->chan_rx); in ti_sci_probe()
3509 debugfs_remove(info->d); in ti_sci_probe()
3516 struct device *dev = &pdev->dev; in ti_sci_remove()
3523 if (info->nb.notifier_call) in ti_sci_remove()
3524 unregister_restart_handler(&info->nb); in ti_sci_remove()
3527 if (info->users) in ti_sci_remove()
3528 ret = -EBUSY; in ti_sci_remove()
3530 list_del(&info->node); in ti_sci_remove()
3537 mbox_free_channel(info->chan_tx); in ti_sci_remove()
3538 mbox_free_channel(info->chan_rx); in ti_sci_remove()
3548 .name = "ti-sci",
3557 MODULE_ALIAS("platform:ti-sci");