• Home
  • Raw
  • Download

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

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>
27 /* List of all TI SCI devices active in system */
33 * struct ti_sci_xfer - Structure representing a message flow
37 * Since we work with request-ACK protocol, we can
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
84 * @dev: Device pointer
91 * @handle: Instance of TI SCI handle to send to clients.
97 * @host_id: Host ID
101 struct device *dev; member
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
155 * @info: Pointer to SCI entity information
162 struct device *dev = &pdev->dev; in ti_sci_debugfs_create() local
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()
179 info->debug_buffer[info->debug_region_size] = 0; in ti_sci_debugfs_create()
182 dev_name(dev)); in ti_sci_debugfs_create()
183 info->d = debugfs_create_file(debug_name, 0444, NULL, info, 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()
188 dev_dbg(dev, "Debug region => %p, size = %zu bytes, resource: %pr\n", in ti_sci_debugfs_create()
189 info->debug_region, info->debug_region_size, res); in ti_sci_debugfs_create()
194 static inline int ti_sci_debugfs_create(struct platform_device *dev, in ti_sci_debugfs_create() argument
200 static inline void ti_sci_debugfs_destroy(struct platform_device *dev, in ti_sci_debugfs_destroy() argument
207 * ti_sci_dump_header_dbg() - Helper to dump a message header.
208 * @dev: Device pointer corresponding to the SCI entity
211 static inline void ti_sci_dump_header_dbg(struct device *dev, in ti_sci_dump_header_dbg() argument
214 dev_dbg(dev, "MSGHDR:type=0x%04x host=0x%02x seq=0x%02x flags=0x%08x\n", in ti_sci_dump_header_dbg()
215 hdr->type, hdr->host, hdr->seq, hdr->flags); in ti_sci_dump_header_dbg()
219 * ti_sci_rx_callback() - mailbox client callback for receive messages
232 struct device *dev = info->dev; in ti_sci_rx_callback() local
233 struct ti_sci_xfers_info *minfo = &info->minfo; in ti_sci_rx_callback()
235 struct ti_sci_msg_hdr *hdr = (struct ti_sci_msg_hdr *)mbox_msg->buf; in ti_sci_rx_callback()
239 xfer_id = hdr->seq; in ti_sci_rx_callback()
245 if (!test_bit(xfer_id, minfo->xfer_alloc_table)) { in ti_sci_rx_callback()
246 dev_err(dev, "Message for %d is not expected!\n", xfer_id); in ti_sci_rx_callback()
250 xfer = &minfo->xfer_block[xfer_id]; in ti_sci_rx_callback()
253 if (mbox_msg->len > info->desc->max_msg_size) { in ti_sci_rx_callback()
254 dev_err(dev, "Unable to handle %zu xfer(max %d)\n", in ti_sci_rx_callback()
255 mbox_msg->len, info->desc->max_msg_size); in ti_sci_rx_callback()
256 ti_sci_dump_header_dbg(dev, hdr); in ti_sci_rx_callback()
259 if (mbox_msg->len < xfer->rx_len) { in ti_sci_rx_callback()
260 dev_err(dev, "Recv xfer %zu < expected %d length\n", in ti_sci_rx_callback()
261 mbox_msg->len, xfer->rx_len); in ti_sci_rx_callback()
262 ti_sci_dump_header_dbg(dev, hdr); in ti_sci_rx_callback()
266 ti_sci_dump_header_dbg(dev, hdr); in ti_sci_rx_callback()
268 memcpy(xfer->xfer_buf, mbox_msg->buf, xfer->rx_len); in ti_sci_rx_callback()
269 complete(&xfer->done); in ti_sci_rx_callback()
273 * ti_sci_get_one_xfer() - Allocate one message
274 * @info: Pointer to SCI entity information
284 * for the SCI entity. Further, this also holds a spinlock to maintain integrity
294 struct ti_sci_xfers_info *minfo = &info->minfo; in ti_sci_get_one_xfer()
304 if (rx_message_size > info->desc->max_msg_size || in ti_sci_get_one_xfer()
305 tx_message_size > info->desc->max_msg_size || in ti_sci_get_one_xfer()
307 return ERR_PTR(-ERANGE); in ti_sci_get_one_xfer()
314 timeout = msecs_to_jiffies(info->desc->max_rx_timeout_ms) * 5; in ti_sci_get_one_xfer()
315 ret = down_timeout(&minfo->sem_xfer_count, timeout); in ti_sci_get_one_xfer()
320 spin_lock_irqsave(&minfo->xfer_lock, flags); in ti_sci_get_one_xfer()
321 bit_pos = find_first_zero_bit(minfo->xfer_alloc_table, in ti_sci_get_one_xfer()
322 info->desc->max_msgs); in ti_sci_get_one_xfer()
323 set_bit(bit_pos, minfo->xfer_alloc_table); in ti_sci_get_one_xfer()
324 spin_unlock_irqrestore(&minfo->xfer_lock, flags); in ti_sci_get_one_xfer()
328 * fit in hdr.seq - NOTE: this improves access latencies in ti_sci_get_one_xfer()
335 xfer = &minfo->xfer_block[xfer_id]; in ti_sci_get_one_xfer()
337 hdr = (struct ti_sci_msg_hdr *)xfer->tx_message.buf; in ti_sci_get_one_xfer()
338 xfer->tx_message.len = tx_message_size; in ti_sci_get_one_xfer()
339 xfer->rx_len = (u8)rx_message_size; in ti_sci_get_one_xfer()
341 reinit_completion(&xfer->done); in ti_sci_get_one_xfer()
343 hdr->seq = xfer_id; in ti_sci_get_one_xfer()
344 hdr->type = msg_type; in ti_sci_get_one_xfer()
345 hdr->host = info->host_id; in ti_sci_get_one_xfer()
346 hdr->flags = msg_flags; in ti_sci_get_one_xfer()
352 * ti_sci_put_one_xfer() - Release a message
365 hdr = (struct ti_sci_msg_hdr *)xfer->tx_message.buf; in ti_sci_put_one_xfer()
366 xfer_id = hdr->seq; in ti_sci_put_one_xfer()
373 spin_lock_irqsave(&minfo->xfer_lock, flags); in ti_sci_put_one_xfer()
374 clear_bit(xfer_id, minfo->xfer_alloc_table); in ti_sci_put_one_xfer()
375 spin_unlock_irqrestore(&minfo->xfer_lock, flags); in ti_sci_put_one_xfer()
378 up(&minfo->sem_xfer_count); in ti_sci_put_one_xfer()
382 * ti_sci_do_xfer() - Do one transfer
383 * @info: Pointer to SCI entity information
386 * Return: -ETIMEDOUT in case of no response, if transmit error,
395 struct device *dev = info->dev; in ti_sci_do_xfer() local
397 ret = mbox_send_message(info->chan_tx, &xfer->tx_message); in ti_sci_do_xfer()
404 timeout = msecs_to_jiffies(info->desc->max_rx_timeout_ms); in ti_sci_do_xfer()
405 if (!wait_for_completion_timeout(&xfer->done, timeout)) { in ti_sci_do_xfer()
406 dev_err(dev, "Mbox timedout in resp(caller: %pS)\n", in ti_sci_do_xfer()
408 ret = -ETIMEDOUT; in ti_sci_do_xfer()
416 mbox_client_txdone(info->chan_tx, ret); in ti_sci_do_xfer()
422 * ti_sci_cmd_get_revision() - command to get the revision of the SCI entity
423 * @info: Pointer to SCI entity information
425 * Updates the SCI information in the internal data structure.
431 struct device *dev = info->dev; in ti_sci_cmd_get_revision() local
432 struct ti_sci_handle *handle = &info->handle; in ti_sci_cmd_get_revision()
433 struct ti_sci_version_info *ver = &handle->version; in ti_sci_cmd_get_revision()
444 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_cmd_get_revision()
448 rev_info = (struct ti_sci_msg_resp_version *)xfer->xfer_buf; in ti_sci_cmd_get_revision()
452 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_cmd_get_revision()
456 ver->abi_major = rev_info->abi_major; in ti_sci_cmd_get_revision()
457 ver->abi_minor = rev_info->abi_minor; in ti_sci_cmd_get_revision()
458 ver->firmware_revision = rev_info->firmware_revision; in ti_sci_cmd_get_revision()
459 strncpy(ver->firmware_description, rev_info->firmware_description, in ti_sci_cmd_get_revision()
460 sizeof(ver->firmware_description)); in ti_sci_cmd_get_revision()
463 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_get_revision()
468 * ti_sci_is_response_ack() - Generic ACK/NACK message checkup
477 return hdr->flags & TI_SCI_FLAG_RESP_GENERIC_ACK ? true : false; in ti_sci_is_response_ack()
481 * ti_sci_set_device_state() - Set device state helper
482 * @handle: pointer to TI SCI handle
483 * @id: Device identifier
490 u32 id, u32 flags, u8 state) in ti_sci_set_device_state() argument
496 struct device *dev; in ti_sci_set_device_state() local
502 return -EINVAL; in ti_sci_set_device_state()
505 dev = info->dev; in ti_sci_set_device_state()
512 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_set_device_state()
515 req = (struct ti_sci_msg_req_set_device_state *)xfer->xfer_buf; in ti_sci_set_device_state()
516 req->id = id; in ti_sci_set_device_state()
517 req->state = state; in ti_sci_set_device_state()
521 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_set_device_state()
525 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_set_device_state()
527 ret = ti_sci_is_response_ack(resp) ? 0 : -ENODEV; in ti_sci_set_device_state()
530 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_set_device_state()
536 * ti_sci_get_device_state() - Get device state helper
538 * @id: Device Identifier
547 u32 id, u32 *clcnt, u32 *resets, in ti_sci_get_device_state() argument
554 struct device *dev; in ti_sci_get_device_state() local
560 return -EINVAL; in ti_sci_get_device_state()
563 return -EINVAL; in ti_sci_get_device_state()
566 dev = info->dev; in ti_sci_get_device_state()
573 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_get_device_state()
576 req = (struct ti_sci_msg_req_get_device_state *)xfer->xfer_buf; in ti_sci_get_device_state()
577 req->id = id; in ti_sci_get_device_state()
581 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_get_device_state()
585 resp = (struct ti_sci_msg_resp_get_device_state *)xfer->xfer_buf; in ti_sci_get_device_state()
587 ret = -ENODEV; in ti_sci_get_device_state()
592 *clcnt = resp->context_loss_count; in ti_sci_get_device_state()
594 *resets = resp->resets; in ti_sci_get_device_state()
596 *p_state = resp->programmed_state; in ti_sci_get_device_state()
598 *c_state = resp->current_state; in ti_sci_get_device_state()
600 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_get_device_state()
606 * ti_sci_cmd_get_device() - command to request for device managed by TISCI
609 * @id: Device Identifier
611 * Request for the device - NOTE: the client MUST maintain integrity of
617 static int ti_sci_cmd_get_device(const struct ti_sci_handle *handle, u32 id) in ti_sci_cmd_get_device() argument
619 return ti_sci_set_device_state(handle, id, 0, in ti_sci_cmd_get_device()
624 * ti_sci_cmd_get_device_exclusive() - command to request for device managed by
628 * @id: Device Identifier
630 * Request for the device - NOTE: the client MUST maintain integrity of
637 u32 id) in ti_sci_cmd_get_device_exclusive() argument
639 return ti_sci_set_device_state(handle, id, in ti_sci_cmd_get_device_exclusive()
645 * ti_sci_cmd_idle_device() - Command to idle a device managed by TISCI
647 * @id: Device Identifier
649 * Request for the device - NOTE: the client MUST maintain integrity of
655 static int ti_sci_cmd_idle_device(const struct ti_sci_handle *handle, u32 id) in ti_sci_cmd_idle_device() argument
657 return ti_sci_set_device_state(handle, id, 0, in ti_sci_cmd_idle_device()
662 * ti_sci_cmd_idle_device_exclusive() - Command to idle a device managed by
666 * @id: Device Identifier
668 * Request for the device - NOTE: the client MUST maintain integrity of
675 u32 id) in ti_sci_cmd_idle_device_exclusive() argument
677 return ti_sci_set_device_state(handle, id, in ti_sci_cmd_idle_device_exclusive()
683 * ti_sci_cmd_put_device() - command to release a device managed by TISCI
685 * @id: Device Identifier
687 * Request for the device - NOTE: the client MUST maintain integrity of
693 static int ti_sci_cmd_put_device(const struct ti_sci_handle *handle, u32 id) in ti_sci_cmd_put_device() argument
695 return ti_sci_set_device_state(handle, id, in ti_sci_cmd_put_device()
700 * ti_sci_cmd_dev_is_valid() - Is the device valid
702 * @id: Device Identifier
704 * Return: 0 if all went fine and the device ID is valid, else return
707 static int ti_sci_cmd_dev_is_valid(const struct ti_sci_handle *handle, u32 id) in ti_sci_cmd_dev_is_valid() argument
711 /* check the device state which will also tell us if the ID is valid */ in ti_sci_cmd_dev_is_valid()
712 return ti_sci_get_device_state(handle, id, NULL, NULL, NULL, &unused); in ti_sci_cmd_dev_is_valid()
716 * ti_sci_cmd_dev_get_clcnt() - Get context loss counter
718 * @id: Device Identifier
723 static int ti_sci_cmd_dev_get_clcnt(const struct ti_sci_handle *handle, u32 id, in ti_sci_cmd_dev_get_clcnt() argument
726 return ti_sci_get_device_state(handle, id, count, NULL, NULL, NULL); in ti_sci_cmd_dev_get_clcnt()
730 * ti_sci_cmd_dev_is_idle() - Check if the device is requested to be idle
732 * @id: Device Identifier
737 static int ti_sci_cmd_dev_is_idle(const struct ti_sci_handle *handle, u32 id, in ti_sci_cmd_dev_is_idle() argument
744 return -EINVAL; in ti_sci_cmd_dev_is_idle()
746 ret = ti_sci_get_device_state(handle, id, NULL, NULL, &state, NULL); in ti_sci_cmd_dev_is_idle()
756 * ti_sci_cmd_dev_is_stop() - Check if the device is requested to be stopped
758 * @id: Device Identifier
764 static int ti_sci_cmd_dev_is_stop(const struct ti_sci_handle *handle, u32 id, in ti_sci_cmd_dev_is_stop() argument
771 return -EINVAL; in ti_sci_cmd_dev_is_stop()
774 ti_sci_get_device_state(handle, id, NULL, NULL, &p_state, &c_state); in ti_sci_cmd_dev_is_stop()
787 * ti_sci_cmd_dev_is_on() - Check if the device is requested to be ON
789 * @id: Device Identifier
795 static int ti_sci_cmd_dev_is_on(const struct ti_sci_handle *handle, u32 id, in ti_sci_cmd_dev_is_on() argument
802 return -EINVAL; in ti_sci_cmd_dev_is_on()
805 ti_sci_get_device_state(handle, id, NULL, NULL, &p_state, &c_state); in ti_sci_cmd_dev_is_on()
818 * ti_sci_cmd_dev_is_trans() - Check if the device is currently transitioning
820 * @id: Device Identifier
825 static int ti_sci_cmd_dev_is_trans(const struct ti_sci_handle *handle, u32 id, in ti_sci_cmd_dev_is_trans() argument
832 return -EINVAL; in ti_sci_cmd_dev_is_trans()
834 ret = ti_sci_get_device_state(handle, id, NULL, NULL, NULL, &state); in ti_sci_cmd_dev_is_trans()
844 * ti_sci_cmd_set_device_resets() - command to set resets for device managed
847 * @id: Device Identifier
853 u32 id, u32 reset_state) in ti_sci_cmd_set_device_resets() argument
859 struct device *dev; in ti_sci_cmd_set_device_resets() local
865 return -EINVAL; in ti_sci_cmd_set_device_resets()
868 dev = info->dev; in ti_sci_cmd_set_device_resets()
875 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_cmd_set_device_resets()
878 req = (struct ti_sci_msg_req_set_device_resets *)xfer->xfer_buf; in ti_sci_cmd_set_device_resets()
879 req->id = id; in ti_sci_cmd_set_device_resets()
880 req->resets = reset_state; in ti_sci_cmd_set_device_resets()
884 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_cmd_set_device_resets()
888 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_cmd_set_device_resets()
890 ret = ti_sci_is_response_ack(resp) ? 0 : -ENODEV; in ti_sci_cmd_set_device_resets()
893 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_set_device_resets()
899 * ti_sci_cmd_get_device_resets() - Get reset state for device managed
902 * @id: Device Identifier
908 u32 id, u32 *reset_state) in ti_sci_cmd_get_device_resets() argument
910 return ti_sci_get_device_state(handle, id, NULL, reset_state, NULL, in ti_sci_cmd_get_device_resets()
915 * ti_sci_set_clock_state() - Set clock state helper
916 * @handle: pointer to TI SCI handle
934 struct device *dev; in ti_sci_set_clock_state() local
940 return -EINVAL; in ti_sci_set_clock_state()
943 dev = info->dev; in ti_sci_set_clock_state()
950 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_set_clock_state()
953 req = (struct ti_sci_msg_req_set_clock_state *)xfer->xfer_buf; in ti_sci_set_clock_state()
954 req->dev_id = dev_id; in ti_sci_set_clock_state()
956 req->clk_id = clk_id; in ti_sci_set_clock_state()
958 req->clk_id = 255; in ti_sci_set_clock_state()
959 req->clk_id_32 = clk_id; in ti_sci_set_clock_state()
961 req->request_state = state; in ti_sci_set_clock_state()
965 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_set_clock_state()
969 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_set_clock_state()
971 ret = ti_sci_is_response_ack(resp) ? 0 : -ENODEV; in ti_sci_set_clock_state()
974 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_set_clock_state()
980 * ti_sci_cmd_get_clock_state() - Get clock state helper
981 * @handle: pointer to TI SCI handle
999 struct device *dev; in ti_sci_cmd_get_clock_state() local
1005 return -EINVAL; in ti_sci_cmd_get_clock_state()
1008 return -EINVAL; in ti_sci_cmd_get_clock_state()
1011 dev = info->dev; in ti_sci_cmd_get_clock_state()
1018 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_cmd_get_clock_state()
1021 req = (struct ti_sci_msg_req_get_clock_state *)xfer->xfer_buf; in ti_sci_cmd_get_clock_state()
1022 req->dev_id = dev_id; in ti_sci_cmd_get_clock_state()
1024 req->clk_id = clk_id; in ti_sci_cmd_get_clock_state()
1026 req->clk_id = 255; in ti_sci_cmd_get_clock_state()
1027 req->clk_id_32 = clk_id; in ti_sci_cmd_get_clock_state()
1032 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_cmd_get_clock_state()
1036 resp = (struct ti_sci_msg_resp_get_clock_state *)xfer->xfer_buf; in ti_sci_cmd_get_clock_state()
1039 ret = -ENODEV; in ti_sci_cmd_get_clock_state()
1044 *programmed_state = resp->programmed_state; in ti_sci_cmd_get_clock_state()
1046 *current_state = resp->current_state; in ti_sci_cmd_get_clock_state()
1049 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_get_clock_state()
1055 * ti_sci_cmd_get_clock() - Get control of a clock from TI SCI
1056 * @handle: pointer to TI SCI handle
1082 * ti_sci_cmd_idle_clock() - Idle a clock which is in our control
1083 * @handle: pointer to TI SCI handle
1102 * ti_sci_cmd_put_clock() - Release a clock from our control back to TISCI
1103 * @handle: pointer to TI SCI handle
1122 * ti_sci_cmd_clk_is_auto() - Is the clock being auto managed
1123 * @handle: pointer to TI SCI handle
1139 return -EINVAL; in ti_sci_cmd_clk_is_auto()
1150 * ti_sci_cmd_clk_is_on() - Is the clock ON
1151 * @handle: pointer to TI SCI handle
1168 return -EINVAL; in ti_sci_cmd_clk_is_on()
1183 * ti_sci_cmd_clk_is_off() - Is the clock OFF
1184 * @handle: pointer to TI SCI handle
1201 return -EINVAL; in ti_sci_cmd_clk_is_off()
1216 * ti_sci_cmd_clk_set_parent() - Set the clock source of a specific device clock
1217 * @handle: pointer to TI SCI handle
1233 struct device *dev; in ti_sci_cmd_clk_set_parent() local
1239 return -EINVAL; in ti_sci_cmd_clk_set_parent()
1242 dev = info->dev; in ti_sci_cmd_clk_set_parent()
1249 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_cmd_clk_set_parent()
1252 req = (struct ti_sci_msg_req_set_clock_parent *)xfer->xfer_buf; in ti_sci_cmd_clk_set_parent()
1253 req->dev_id = dev_id; in ti_sci_cmd_clk_set_parent()
1255 req->clk_id = clk_id; in ti_sci_cmd_clk_set_parent()
1257 req->clk_id = 255; in ti_sci_cmd_clk_set_parent()
1258 req->clk_id_32 = clk_id; in ti_sci_cmd_clk_set_parent()
1261 req->parent_id = parent_id; in ti_sci_cmd_clk_set_parent()
1263 req->parent_id = 255; in ti_sci_cmd_clk_set_parent()
1264 req->parent_id_32 = parent_id; in ti_sci_cmd_clk_set_parent()
1269 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_cmd_clk_set_parent()
1273 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_cmd_clk_set_parent()
1275 ret = ti_sci_is_response_ack(resp) ? 0 : -ENODEV; in ti_sci_cmd_clk_set_parent()
1278 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_clk_set_parent()
1284 * ti_sci_cmd_clk_get_parent() - Get current parent clock source
1285 * @handle: pointer to TI SCI handle
1301 struct device *dev; in ti_sci_cmd_clk_get_parent() local
1307 return -EINVAL; in ti_sci_cmd_clk_get_parent()
1310 dev = info->dev; in ti_sci_cmd_clk_get_parent()
1317 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_cmd_clk_get_parent()
1320 req = (struct ti_sci_msg_req_get_clock_parent *)xfer->xfer_buf; in ti_sci_cmd_clk_get_parent()
1321 req->dev_id = dev_id; in ti_sci_cmd_clk_get_parent()
1323 req->clk_id = clk_id; in ti_sci_cmd_clk_get_parent()
1325 req->clk_id = 255; in ti_sci_cmd_clk_get_parent()
1326 req->clk_id_32 = clk_id; in ti_sci_cmd_clk_get_parent()
1331 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_cmd_clk_get_parent()
1335 resp = (struct ti_sci_msg_resp_get_clock_parent *)xfer->xfer_buf; in ti_sci_cmd_clk_get_parent()
1338 ret = -ENODEV; in ti_sci_cmd_clk_get_parent()
1340 if (resp->parent_id < 255) in ti_sci_cmd_clk_get_parent()
1341 *parent_id = resp->parent_id; in ti_sci_cmd_clk_get_parent()
1343 *parent_id = resp->parent_id_32; in ti_sci_cmd_clk_get_parent()
1347 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_clk_get_parent()
1353 * ti_sci_cmd_clk_get_num_parents() - Get num parents of the current clk source
1354 * @handle: pointer to TI SCI handle
1371 struct device *dev; in ti_sci_cmd_clk_get_num_parents() local
1377 return -EINVAL; in ti_sci_cmd_clk_get_num_parents()
1380 dev = info->dev; in ti_sci_cmd_clk_get_num_parents()
1387 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_cmd_clk_get_num_parents()
1390 req = (struct ti_sci_msg_req_get_clock_num_parents *)xfer->xfer_buf; in ti_sci_cmd_clk_get_num_parents()
1391 req->dev_id = dev_id; in ti_sci_cmd_clk_get_num_parents()
1393 req->clk_id = clk_id; in ti_sci_cmd_clk_get_num_parents()
1395 req->clk_id = 255; in ti_sci_cmd_clk_get_num_parents()
1396 req->clk_id_32 = clk_id; in ti_sci_cmd_clk_get_num_parents()
1401 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_cmd_clk_get_num_parents()
1405 resp = (struct ti_sci_msg_resp_get_clock_num_parents *)xfer->xfer_buf; in ti_sci_cmd_clk_get_num_parents()
1408 ret = -ENODEV; in ti_sci_cmd_clk_get_num_parents()
1410 if (resp->num_parents < 255) in ti_sci_cmd_clk_get_num_parents()
1411 *num_parents = resp->num_parents; in ti_sci_cmd_clk_get_num_parents()
1413 *num_parents = resp->num_parents_32; in ti_sci_cmd_clk_get_num_parents()
1417 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_clk_get_num_parents()
1423 * ti_sci_cmd_clk_get_match_freq() - Find a good match for frequency
1424 * @handle: pointer to TI SCI handle
1450 struct device *dev; in ti_sci_cmd_clk_get_match_freq() local
1456 return -EINVAL; in ti_sci_cmd_clk_get_match_freq()
1459 dev = info->dev; in ti_sci_cmd_clk_get_match_freq()
1466 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_cmd_clk_get_match_freq()
1469 req = (struct ti_sci_msg_req_query_clock_freq *)xfer->xfer_buf; in ti_sci_cmd_clk_get_match_freq()
1470 req->dev_id = dev_id; in ti_sci_cmd_clk_get_match_freq()
1472 req->clk_id = clk_id; in ti_sci_cmd_clk_get_match_freq()
1474 req->clk_id = 255; in ti_sci_cmd_clk_get_match_freq()
1475 req->clk_id_32 = clk_id; in ti_sci_cmd_clk_get_match_freq()
1477 req->min_freq_hz = min_freq; in ti_sci_cmd_clk_get_match_freq()
1478 req->target_freq_hz = target_freq; in ti_sci_cmd_clk_get_match_freq()
1479 req->max_freq_hz = max_freq; in ti_sci_cmd_clk_get_match_freq()
1483 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_cmd_clk_get_match_freq()
1487 resp = (struct ti_sci_msg_resp_query_clock_freq *)xfer->xfer_buf; in ti_sci_cmd_clk_get_match_freq()
1490 ret = -ENODEV; in ti_sci_cmd_clk_get_match_freq()
1492 *match_freq = resp->freq_hz; in ti_sci_cmd_clk_get_match_freq()
1495 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_clk_get_match_freq()
1501 * ti_sci_cmd_clk_set_freq() - Set a frequency for clock
1502 * @handle: pointer to TI SCI handle
1526 struct device *dev; in ti_sci_cmd_clk_set_freq() local
1532 return -EINVAL; in ti_sci_cmd_clk_set_freq()
1535 dev = info->dev; in ti_sci_cmd_clk_set_freq()
1542 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_cmd_clk_set_freq()
1545 req = (struct ti_sci_msg_req_set_clock_freq *)xfer->xfer_buf; in ti_sci_cmd_clk_set_freq()
1546 req->dev_id = dev_id; in ti_sci_cmd_clk_set_freq()
1548 req->clk_id = clk_id; in ti_sci_cmd_clk_set_freq()
1550 req->clk_id = 255; in ti_sci_cmd_clk_set_freq()
1551 req->clk_id_32 = clk_id; in ti_sci_cmd_clk_set_freq()
1553 req->min_freq_hz = min_freq; in ti_sci_cmd_clk_set_freq()
1554 req->target_freq_hz = target_freq; in ti_sci_cmd_clk_set_freq()
1555 req->max_freq_hz = max_freq; in ti_sci_cmd_clk_set_freq()
1559 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_cmd_clk_set_freq()
1563 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_cmd_clk_set_freq()
1565 ret = ti_sci_is_response_ack(resp) ? 0 : -ENODEV; in ti_sci_cmd_clk_set_freq()
1568 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_clk_set_freq()
1574 * ti_sci_cmd_clk_get_freq() - Get current frequency
1575 * @handle: pointer to TI SCI handle
1591 struct device *dev; in ti_sci_cmd_clk_get_freq() local
1597 return -EINVAL; in ti_sci_cmd_clk_get_freq()
1600 dev = info->dev; in ti_sci_cmd_clk_get_freq()
1607 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_cmd_clk_get_freq()
1610 req = (struct ti_sci_msg_req_get_clock_freq *)xfer->xfer_buf; in ti_sci_cmd_clk_get_freq()
1611 req->dev_id = dev_id; in ti_sci_cmd_clk_get_freq()
1613 req->clk_id = clk_id; in ti_sci_cmd_clk_get_freq()
1615 req->clk_id = 255; in ti_sci_cmd_clk_get_freq()
1616 req->clk_id_32 = clk_id; in ti_sci_cmd_clk_get_freq()
1621 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_cmd_clk_get_freq()
1625 resp = (struct ti_sci_msg_resp_get_clock_freq *)xfer->xfer_buf; in ti_sci_cmd_clk_get_freq()
1628 ret = -ENODEV; in ti_sci_cmd_clk_get_freq()
1630 *freq = resp->freq_hz; in ti_sci_cmd_clk_get_freq()
1633 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_clk_get_freq()
1644 struct device *dev; in ti_sci_cmd_core_reboot() local
1650 return -EINVAL; in ti_sci_cmd_core_reboot()
1653 dev = info->dev; in ti_sci_cmd_core_reboot()
1660 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_cmd_core_reboot()
1663 req = (struct ti_sci_msg_req_reboot *)xfer->xfer_buf; in ti_sci_cmd_core_reboot()
1667 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_cmd_core_reboot()
1671 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_cmd_core_reboot()
1674 ret = -ENODEV; in ti_sci_cmd_core_reboot()
1679 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_core_reboot()
1685 * ti_sci_get_resource_range - Helper to get a range of resources assigned
1689 * @dev_id: TISCI device ID.
1692 * @s_host: Host processor ID to which the resources are allocated
1706 struct device *dev; in ti_sci_get_resource_range() local
1712 return -EINVAL; in ti_sci_get_resource_range()
1715 dev = info->dev; in ti_sci_get_resource_range()
1722 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_get_resource_range()
1726 req = (struct ti_sci_msg_req_get_resource_range *)xfer->xfer_buf; in ti_sci_get_resource_range()
1727 req->secondary_host = s_host; in ti_sci_get_resource_range()
1728 req->type = dev_id & MSG_RM_RESOURCE_TYPE_MASK; in ti_sci_get_resource_range()
1729 req->subtype = subtype & MSG_RM_RESOURCE_SUBTYPE_MASK; in ti_sci_get_resource_range()
1733 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_get_resource_range()
1737 resp = (struct ti_sci_msg_resp_get_resource_range *)xfer->xfer_buf; in ti_sci_get_resource_range()
1740 ret = -ENODEV; in ti_sci_get_resource_range()
1741 } else if (!resp->range_start && !resp->range_num) { in ti_sci_get_resource_range()
1742 ret = -ENODEV; in ti_sci_get_resource_range()
1744 *range_start = resp->range_start; in ti_sci_get_resource_range()
1745 *range_num = resp->range_num; in ti_sci_get_resource_range()
1749 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_get_resource_range()
1755 * ti_sci_cmd_get_resource_range - Get a range of resources assigned to host
1756 * that is same as ti sci interface host.
1758 * @dev_id: TISCI device ID.
1776 * ti_sci_cmd_get_resource_range_from_shost - Get a range of resources
1779 * @dev_id: TISCI device ID.
1782 * @s_host: Host processor ID to which the resources are allocated
1798 * ti_sci_manage_irq() - Helper api to configure/release the irq route between
1802 * @src_id: Device ID of the IRQ source
1804 * @dst_id: Device ID of the IRQ destination
1806 * @ia_id: Device ID of the IA, if the IRQ flows through this IA
1810 * @s_host: Secondary host ID to which the irq/event is being
1826 struct device *dev; in ti_sci_manage_irq() local
1832 return -EINVAL; in ti_sci_manage_irq()
1835 dev = info->dev; in ti_sci_manage_irq()
1841 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_manage_irq()
1844 req = (struct ti_sci_msg_req_manage_irq *)xfer->xfer_buf; in ti_sci_manage_irq()
1845 req->valid_params = valid_params; in ti_sci_manage_irq()
1846 req->src_id = src_id; in ti_sci_manage_irq()
1847 req->src_index = src_index; in ti_sci_manage_irq()
1848 req->dst_id = dst_id; in ti_sci_manage_irq()
1849 req->dst_host_irq = dst_host_irq; in ti_sci_manage_irq()
1850 req->ia_id = ia_id; in ti_sci_manage_irq()
1851 req->vint = vint; in ti_sci_manage_irq()
1852 req->global_event = global_event; in ti_sci_manage_irq()
1853 req->vint_status_bit = vint_status_bit; in ti_sci_manage_irq()
1854 req->secondary_host = s_host; in ti_sci_manage_irq()
1858 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_manage_irq()
1862 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_manage_irq()
1864 ret = ti_sci_is_response_ack(resp) ? 0 : -ENODEV; in ti_sci_manage_irq()
1867 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_manage_irq()
1873 * ti_sci_set_irq() - Helper api to configure the irq route between the
1877 * @src_id: Device ID of the IRQ source
1879 * @dst_id: Device ID of the IRQ destination
1881 * @ia_id: Device ID of the IA, if the IRQ flows through this IA
1885 * @s_host: Secondary host ID to which the irq/event is being
1907 * ti_sci_free_irq() - Helper api to free the irq route between the
1911 * @src_id: Device ID of the IRQ source
1913 * @dst_id: Device ID of the IRQ destination
1915 * @ia_id: Device ID of the IA, if the IRQ flows through this IA
1919 * @s_host: Secondary host ID to which the irq/event is being
1941 * ti_sci_cmd_set_irq() - Configure a host irq route between the requested
1944 * @src_id: Device ID of the IRQ source
1946 * @dst_id: Device ID of the IRQ destination
1963 * ti_sci_cmd_set_event_map() - Configure an event based irq route between the
1966 * @src_id: Device ID of the IRQ source
1968 * @ia_id: Device ID of the IA, if the IRQ flows through this IA
1989 * ti_sci_cmd_free_irq() - Free a host irq route between the between the
1992 * @src_id: Device ID of the IRQ source
1994 * @dst_id: Device ID of the IRQ destination
2011 * ti_sci_cmd_free_event_map() - Free an event map between the requested source
2014 * @src_id: Device ID of the IRQ source
2016 * @ia_id: Device ID of the IA, if the IRQ flows through this IA
2037 * ti_sci_cmd_ring_config() - configure RA ring
2038 * @handle: Pointer to TI SCI handle.
2041 * @nav_id: Device ID of Navigator Subsystem from which the ring is
2049 * @order_id: Specifies the ring's bus order ID
2064 struct device *dev; in ti_sci_cmd_ring_config() local
2068 return -EINVAL; in ti_sci_cmd_ring_config()
2071 dev = info->dev; in ti_sci_cmd_ring_config()
2078 dev_err(dev, "RM_RA:Message config failed(%d)\n", ret); in ti_sci_cmd_ring_config()
2081 req = (struct ti_sci_msg_rm_ring_cfg_req *)xfer->xfer_buf; in ti_sci_cmd_ring_config()
2082 req->valid_params = valid_params; in ti_sci_cmd_ring_config()
2083 req->nav_id = nav_id; in ti_sci_cmd_ring_config()
2084 req->index = index; in ti_sci_cmd_ring_config()
2085 req->addr_lo = addr_lo; in ti_sci_cmd_ring_config()
2086 req->addr_hi = addr_hi; in ti_sci_cmd_ring_config()
2087 req->count = count; in ti_sci_cmd_ring_config()
2088 req->mode = mode; in ti_sci_cmd_ring_config()
2089 req->size = size; in ti_sci_cmd_ring_config()
2090 req->order_id = order_id; in ti_sci_cmd_ring_config()
2094 dev_err(dev, "RM_RA:Mbox config send fail %d\n", ret); in ti_sci_cmd_ring_config()
2098 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_cmd_ring_config()
2099 ret = ti_sci_is_response_ack(resp) ? 0 : -ENODEV; in ti_sci_cmd_ring_config()
2102 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_ring_config()
2103 dev_dbg(dev, "RM_RA:config ring %u ret:%d\n", index, ret); in ti_sci_cmd_ring_config()
2108 * ti_sci_cmd_ring_get_config() - get RA ring configuration
2109 * @handle: Pointer to TI SCI handle.
2110 * @nav_id: Device ID of Navigator Subsystem from which the ring is
2118 * @order_id: Returns ring's bus order ID
2133 struct device *dev; in ti_sci_cmd_ring_get_config() local
2137 return -EINVAL; in ti_sci_cmd_ring_get_config()
2140 dev = info->dev; in ti_sci_cmd_ring_get_config()
2147 dev_err(dev, in ti_sci_cmd_ring_get_config()
2151 req = (struct ti_sci_msg_rm_ring_get_cfg_req *)xfer->xfer_buf; in ti_sci_cmd_ring_get_config()
2152 req->nav_id = nav_id; in ti_sci_cmd_ring_get_config()
2153 req->index = index; in ti_sci_cmd_ring_get_config()
2157 dev_err(dev, "RM_RA:Mbox get config send fail %d\n", ret); in ti_sci_cmd_ring_get_config()
2161 resp = (struct ti_sci_msg_rm_ring_get_cfg_resp *)xfer->xfer_buf; in ti_sci_cmd_ring_get_config()
2164 ret = -ENODEV; in ti_sci_cmd_ring_get_config()
2167 *mode = resp->mode; in ti_sci_cmd_ring_get_config()
2169 *addr_lo = resp->addr_lo; in ti_sci_cmd_ring_get_config()
2171 *addr_hi = resp->addr_hi; in ti_sci_cmd_ring_get_config()
2173 *count = resp->count; in ti_sci_cmd_ring_get_config()
2175 *size = resp->size; in ti_sci_cmd_ring_get_config()
2177 *order_id = resp->order_id; in ti_sci_cmd_ring_get_config()
2181 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_ring_get_config()
2182 dev_dbg(dev, "RM_RA:get config ring %u ret:%d\n", index, ret); in ti_sci_cmd_ring_get_config()
2187 * ti_sci_cmd_rm_psil_pair() - Pair PSI-L source to destination thread
2188 * @handle: Pointer to TI SCI handle.
2189 * @nav_id: Device ID of Navigator Subsystem which should be used for
2191 * @src_thread: Source PSI-L thread ID
2192 * @dst_thread: Destination PSI-L thread ID
2203 struct device *dev; in ti_sci_cmd_rm_psil_pair() local
2209 return -EINVAL; in ti_sci_cmd_rm_psil_pair()
2212 dev = info->dev; in ti_sci_cmd_rm_psil_pair()
2219 dev_err(dev, "RM_PSIL:Message reconfig failed(%d)\n", ret); in ti_sci_cmd_rm_psil_pair()
2222 req = (struct ti_sci_msg_psil_pair *)xfer->xfer_buf; in ti_sci_cmd_rm_psil_pair()
2223 req->nav_id = nav_id; in ti_sci_cmd_rm_psil_pair()
2224 req->src_thread = src_thread; in ti_sci_cmd_rm_psil_pair()
2225 req->dst_thread = dst_thread; in ti_sci_cmd_rm_psil_pair()
2229 dev_err(dev, "RM_PSIL:Mbox send fail %d\n", ret); in ti_sci_cmd_rm_psil_pair()
2233 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_cmd_rm_psil_pair()
2234 ret = ti_sci_is_response_ack(resp) ? 0 : -EINVAL; in ti_sci_cmd_rm_psil_pair()
2237 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_rm_psil_pair()
2243 * ti_sci_cmd_rm_psil_unpair() - Unpair PSI-L source from destination thread
2244 * @handle: Pointer to TI SCI handle.
2245 * @nav_id: Device ID of Navigator Subsystem which should be used for
2247 * @src_thread: Source PSI-L thread ID
2248 * @dst_thread: Destination PSI-L thread ID
2259 struct device *dev; in ti_sci_cmd_rm_psil_unpair() local
2265 return -EINVAL; in ti_sci_cmd_rm_psil_unpair()
2268 dev = info->dev; in ti_sci_cmd_rm_psil_unpair()
2275 dev_err(dev, "RM_PSIL:Message reconfig failed(%d)\n", ret); in ti_sci_cmd_rm_psil_unpair()
2278 req = (struct ti_sci_msg_psil_unpair *)xfer->xfer_buf; in ti_sci_cmd_rm_psil_unpair()
2279 req->nav_id = nav_id; in ti_sci_cmd_rm_psil_unpair()
2280 req->src_thread = src_thread; in ti_sci_cmd_rm_psil_unpair()
2281 req->dst_thread = dst_thread; in ti_sci_cmd_rm_psil_unpair()
2285 dev_err(dev, "RM_PSIL:Mbox send fail %d\n", ret); in ti_sci_cmd_rm_psil_unpair()
2289 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_cmd_rm_psil_unpair()
2290 ret = ti_sci_is_response_ack(resp) ? 0 : -EINVAL; in ti_sci_cmd_rm_psil_unpair()
2293 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_rm_psil_unpair()
2299 * ti_sci_cmd_rm_udmap_tx_ch_cfg() - Configure a UDMAP TX channel
2300 * @handle: Pointer to TI SCI handle.
2316 struct device *dev; in ti_sci_cmd_rm_udmap_tx_ch_cfg() local
2320 return -EINVAL; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2323 dev = info->dev; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2330 dev_err(dev, "Message TX_CH_CFG alloc failed(%d)\n", ret); in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2333 req = (struct ti_sci_msg_rm_udmap_tx_ch_cfg_req *)xfer->xfer_buf; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2334 req->valid_params = params->valid_params; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2335 req->nav_id = params->nav_id; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2336 req->index = params->index; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2337 req->tx_pause_on_err = params->tx_pause_on_err; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2338 req->tx_filt_einfo = params->tx_filt_einfo; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2339 req->tx_filt_pswords = params->tx_filt_pswords; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2340 req->tx_atype = params->tx_atype; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2341 req->tx_chan_type = params->tx_chan_type; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2342 req->tx_supr_tdpkt = params->tx_supr_tdpkt; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2343 req->tx_fetch_size = params->tx_fetch_size; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2344 req->tx_credit_count = params->tx_credit_count; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2345 req->txcq_qnum = params->txcq_qnum; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2346 req->tx_priority = params->tx_priority; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2347 req->tx_qos = params->tx_qos; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2348 req->tx_orderid = params->tx_orderid; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2349 req->fdepth = params->fdepth; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2350 req->tx_sched_priority = params->tx_sched_priority; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2351 req->tx_burst_size = params->tx_burst_size; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2355 dev_err(dev, "Mbox send TX_CH_CFG fail %d\n", ret); in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2359 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2360 ret = ti_sci_is_response_ack(resp) ? 0 : -EINVAL; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2363 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2364 dev_dbg(dev, "TX_CH_CFG: chn %u ret:%u\n", params->index, ret); in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2369 * ti_sci_cmd_rm_udmap_rx_ch_cfg() - Configure a UDMAP RX channel
2370 * @handle: Pointer to TI SCI handle.
2386 struct device *dev; in ti_sci_cmd_rm_udmap_rx_ch_cfg() local
2390 return -EINVAL; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2393 dev = info->dev; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2400 dev_err(dev, "Message RX_CH_CFG alloc failed(%d)\n", ret); in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2403 req = (struct ti_sci_msg_rm_udmap_rx_ch_cfg_req *)xfer->xfer_buf; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2404 req->valid_params = params->valid_params; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2405 req->nav_id = params->nav_id; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2406 req->index = params->index; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2407 req->rx_fetch_size = params->rx_fetch_size; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2408 req->rxcq_qnum = params->rxcq_qnum; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2409 req->rx_priority = params->rx_priority; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2410 req->rx_qos = params->rx_qos; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2411 req->rx_orderid = params->rx_orderid; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2412 req->rx_sched_priority = params->rx_sched_priority; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2413 req->flowid_start = params->flowid_start; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2414 req->flowid_cnt = params->flowid_cnt; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2415 req->rx_pause_on_err = params->rx_pause_on_err; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2416 req->rx_atype = params->rx_atype; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2417 req->rx_chan_type = params->rx_chan_type; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2418 req->rx_ignore_short = params->rx_ignore_short; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2419 req->rx_ignore_long = params->rx_ignore_long; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2420 req->rx_burst_size = params->rx_burst_size; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2424 dev_err(dev, "Mbox send RX_CH_CFG fail %d\n", ret); in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2428 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2429 ret = ti_sci_is_response_ack(resp) ? 0 : -EINVAL; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2432 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2433 dev_dbg(dev, "RX_CH_CFG: chn %u ret:%d\n", params->index, ret); in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2438 * ti_sci_cmd_rm_udmap_rx_flow_cfg() - Configure UDMAP RX FLOW
2439 * @handle: Pointer to TI SCI handle.
2455 struct device *dev; in ti_sci_cmd_rm_udmap_rx_flow_cfg() local
2459 return -EINVAL; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2462 dev = info->dev; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2469 dev_err(dev, "RX_FL_CFG: Message alloc failed(%d)\n", ret); in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2472 req = (struct ti_sci_msg_rm_udmap_flow_cfg_req *)xfer->xfer_buf; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2473 req->valid_params = params->valid_params; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2474 req->nav_id = params->nav_id; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2475 req->flow_index = params->flow_index; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2476 req->rx_einfo_present = params->rx_einfo_present; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2477 req->rx_psinfo_present = params->rx_psinfo_present; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2478 req->rx_error_handling = params->rx_error_handling; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2479 req->rx_desc_type = params->rx_desc_type; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2480 req->rx_sop_offset = params->rx_sop_offset; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2481 req->rx_dest_qnum = params->rx_dest_qnum; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2482 req->rx_src_tag_hi = params->rx_src_tag_hi; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2483 req->rx_src_tag_lo = params->rx_src_tag_lo; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2484 req->rx_dest_tag_hi = params->rx_dest_tag_hi; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2485 req->rx_dest_tag_lo = params->rx_dest_tag_lo; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2486 req->rx_src_tag_hi_sel = params->rx_src_tag_hi_sel; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2487 req->rx_src_tag_lo_sel = params->rx_src_tag_lo_sel; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2488 req->rx_dest_tag_hi_sel = params->rx_dest_tag_hi_sel; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2489 req->rx_dest_tag_lo_sel = params->rx_dest_tag_lo_sel; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2490 req->rx_fdq0_sz0_qnum = params->rx_fdq0_sz0_qnum; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2491 req->rx_fdq1_qnum = params->rx_fdq1_qnum; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2492 req->rx_fdq2_qnum = params->rx_fdq2_qnum; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2493 req->rx_fdq3_qnum = params->rx_fdq3_qnum; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2494 req->rx_ps_location = params->rx_ps_location; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2498 dev_err(dev, "RX_FL_CFG: Mbox send fail %d\n", ret); in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2502 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2503 ret = ti_sci_is_response_ack(resp) ? 0 : -EINVAL; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2506 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2507 dev_dbg(info->dev, "RX_FL_CFG: %u ret:%d\n", params->flow_index, ret); in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2512 * ti_sci_cmd_proc_request() - Command to request a physical processor control
2513 * @handle: Pointer to TI SCI handle
2514 * @proc_id: Processor ID this request is for
2525 struct device *dev; in ti_sci_cmd_proc_request() local
2529 return -EINVAL; in ti_sci_cmd_proc_request()
2534 dev = info->dev; in ti_sci_cmd_proc_request()
2541 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_cmd_proc_request()
2544 req = (struct ti_sci_msg_req_proc_request *)xfer->xfer_buf; in ti_sci_cmd_proc_request()
2545 req->processor_id = proc_id; in ti_sci_cmd_proc_request()
2549 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_cmd_proc_request()
2553 resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf; in ti_sci_cmd_proc_request()
2555 ret = ti_sci_is_response_ack(resp) ? 0 : -ENODEV; in ti_sci_cmd_proc_request()
2558 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_proc_request()
2564 * ti_sci_cmd_proc_release() - Command to release a physical processor control
2565 * @handle: Pointer to TI SCI handle
2566 * @proc_id: Processor ID this request is for
2577 struct device *dev; in ti_sci_cmd_proc_release() local
2581 return -EINVAL; in ti_sci_cmd_proc_release()
2586 dev = info->dev; in ti_sci_cmd_proc_release()
2593 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_cmd_proc_release()
2596 req = (struct ti_sci_msg_req_proc_release *)xfer->xfer_buf; in ti_sci_cmd_proc_release()
2597 req->processor_id = proc_id; in ti_sci_cmd_proc_release()
2601 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_cmd_proc_release()
2605 resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf; in ti_sci_cmd_proc_release()
2607 ret = ti_sci_is_response_ack(resp) ? 0 : -ENODEV; in ti_sci_cmd_proc_release()
2610 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_proc_release()
2616 * ti_sci_cmd_proc_handover() - Command to handover a physical processor
2619 * @handle: Pointer to TI SCI handle
2620 * @proc_id: Processor ID this request is for
2621 * @host_id: Host ID to get the control of the processor
2632 struct device *dev; in ti_sci_cmd_proc_handover() local
2636 return -EINVAL; in ti_sci_cmd_proc_handover()
2641 dev = info->dev; in ti_sci_cmd_proc_handover()
2648 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_cmd_proc_handover()
2651 req = (struct ti_sci_msg_req_proc_handover *)xfer->xfer_buf; in ti_sci_cmd_proc_handover()
2652 req->processor_id = proc_id; in ti_sci_cmd_proc_handover()
2653 req->host_id = host_id; in ti_sci_cmd_proc_handover()
2657 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_cmd_proc_handover()
2661 resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf; in ti_sci_cmd_proc_handover()
2663 ret = ti_sci_is_response_ack(resp) ? 0 : -ENODEV; in ti_sci_cmd_proc_handover()
2666 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_proc_handover()
2672 * ti_sci_cmd_proc_set_config() - Command to set the processor boot
2674 * @handle: Pointer to TI SCI handle
2675 * @proc_id: Processor ID this request is for
2690 struct device *dev; in ti_sci_cmd_proc_set_config() local
2694 return -EINVAL; in ti_sci_cmd_proc_set_config()
2699 dev = info->dev; in ti_sci_cmd_proc_set_config()
2706 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_cmd_proc_set_config()
2709 req = (struct ti_sci_msg_req_set_config *)xfer->xfer_buf; in ti_sci_cmd_proc_set_config()
2710 req->processor_id = proc_id; in ti_sci_cmd_proc_set_config()
2711 req->bootvector_low = bootvector & TI_SCI_ADDR_LOW_MASK; in ti_sci_cmd_proc_set_config()
2712 req->bootvector_high = (bootvector & TI_SCI_ADDR_HIGH_MASK) >> in ti_sci_cmd_proc_set_config()
2714 req->config_flags_set = config_flags_set; in ti_sci_cmd_proc_set_config()
2715 req->config_flags_clear = config_flags_clear; in ti_sci_cmd_proc_set_config()
2719 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_cmd_proc_set_config()
2723 resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf; in ti_sci_cmd_proc_set_config()
2725 ret = ti_sci_is_response_ack(resp) ? 0 : -ENODEV; in ti_sci_cmd_proc_set_config()
2728 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_proc_set_config()
2734 * ti_sci_cmd_proc_set_control() - Command to set the processor boot
2736 * @handle: Pointer to TI SCI handle
2737 * @proc_id: Processor ID this request is for
2751 struct device *dev; in ti_sci_cmd_proc_set_control() local
2755 return -EINVAL; in ti_sci_cmd_proc_set_control()
2760 dev = info->dev; in ti_sci_cmd_proc_set_control()
2767 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_cmd_proc_set_control()
2770 req = (struct ti_sci_msg_req_set_ctrl *)xfer->xfer_buf; in ti_sci_cmd_proc_set_control()
2771 req->processor_id = proc_id; in ti_sci_cmd_proc_set_control()
2772 req->control_flags_set = control_flags_set; in ti_sci_cmd_proc_set_control()
2773 req->control_flags_clear = control_flags_clear; in ti_sci_cmd_proc_set_control()
2777 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_cmd_proc_set_control()
2781 resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf; in ti_sci_cmd_proc_set_control()
2783 ret = ti_sci_is_response_ack(resp) ? 0 : -ENODEV; in ti_sci_cmd_proc_set_control()
2786 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_proc_set_control()
2792 * ti_sci_cmd_get_boot_status() - Command to get the processor boot status
2793 * @handle: Pointer to TI SCI handle
2794 * @proc_id: Processor ID this request is for
2806 struct device *dev; in ti_sci_cmd_proc_get_status() local
2810 return -EINVAL; in ti_sci_cmd_proc_get_status()
2815 dev = info->dev; in ti_sci_cmd_proc_get_status()
2822 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_cmd_proc_get_status()
2825 req = (struct ti_sci_msg_req_get_status *)xfer->xfer_buf; in ti_sci_cmd_proc_get_status()
2826 req->processor_id = proc_id; in ti_sci_cmd_proc_get_status()
2830 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_cmd_proc_get_status()
2834 resp = (struct ti_sci_msg_resp_get_status *)xfer->tx_message.buf; in ti_sci_cmd_proc_get_status()
2837 ret = -ENODEV; in ti_sci_cmd_proc_get_status()
2839 *bv = (resp->bootvector_low & TI_SCI_ADDR_LOW_MASK) | in ti_sci_cmd_proc_get_status()
2840 (((u64)resp->bootvector_high << TI_SCI_ADDR_HIGH_SHIFT) & in ti_sci_cmd_proc_get_status()
2842 *cfg_flags = resp->config_flags; in ti_sci_cmd_proc_get_status()
2843 *ctrl_flags = resp->control_flags; in ti_sci_cmd_proc_get_status()
2844 *sts_flags = resp->status_flags; in ti_sci_cmd_proc_get_status()
2848 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_proc_get_status()
2854 * ti_sci_setup_ops() - Setup the operations structures
2859 struct ti_sci_ops *ops = &info->handle.ops; in ti_sci_setup_ops()
2860 struct ti_sci_core_ops *core_ops = &ops->core_ops; in ti_sci_setup_ops()
2861 struct ti_sci_dev_ops *dops = &ops->dev_ops; in ti_sci_setup_ops()
2862 struct ti_sci_clk_ops *cops = &ops->clk_ops; in ti_sci_setup_ops()
2863 struct ti_sci_rm_core_ops *rm_core_ops = &ops->rm_core_ops; in ti_sci_setup_ops()
2864 struct ti_sci_rm_irq_ops *iops = &ops->rm_irq_ops; in ti_sci_setup_ops()
2865 struct ti_sci_rm_ringacc_ops *rops = &ops->rm_ring_ops; in ti_sci_setup_ops()
2866 struct ti_sci_rm_psil_ops *psilops = &ops->rm_psil_ops; in ti_sci_setup_ops()
2867 struct ti_sci_rm_udmap_ops *udmap_ops = &ops->rm_udmap_ops; in ti_sci_setup_ops()
2868 struct ti_sci_proc_ops *pops = &ops->proc_ops; in ti_sci_setup_ops()
2870 core_ops->reboot_device = ti_sci_cmd_core_reboot; in ti_sci_setup_ops()
2872 dops->get_device = ti_sci_cmd_get_device; in ti_sci_setup_ops()
2873 dops->get_device_exclusive = ti_sci_cmd_get_device_exclusive; in ti_sci_setup_ops()
2874 dops->idle_device = ti_sci_cmd_idle_device; in ti_sci_setup_ops()
2875 dops->idle_device_exclusive = ti_sci_cmd_idle_device_exclusive; in ti_sci_setup_ops()
2876 dops->put_device = ti_sci_cmd_put_device; in ti_sci_setup_ops()
2878 dops->is_valid = ti_sci_cmd_dev_is_valid; in ti_sci_setup_ops()
2879 dops->get_context_loss_count = ti_sci_cmd_dev_get_clcnt; in ti_sci_setup_ops()
2880 dops->is_idle = ti_sci_cmd_dev_is_idle; in ti_sci_setup_ops()
2881 dops->is_stop = ti_sci_cmd_dev_is_stop; in ti_sci_setup_ops()
2882 dops->is_on = ti_sci_cmd_dev_is_on; in ti_sci_setup_ops()
2883 dops->is_transitioning = ti_sci_cmd_dev_is_trans; in ti_sci_setup_ops()
2884 dops->set_device_resets = ti_sci_cmd_set_device_resets; in ti_sci_setup_ops()
2885 dops->get_device_resets = ti_sci_cmd_get_device_resets; in ti_sci_setup_ops()
2887 cops->get_clock = ti_sci_cmd_get_clock; in ti_sci_setup_ops()
2888 cops->idle_clock = ti_sci_cmd_idle_clock; in ti_sci_setup_ops()
2889 cops->put_clock = ti_sci_cmd_put_clock; in ti_sci_setup_ops()
2890 cops->is_auto = ti_sci_cmd_clk_is_auto; in ti_sci_setup_ops()
2891 cops->is_on = ti_sci_cmd_clk_is_on; in ti_sci_setup_ops()
2892 cops->is_off = ti_sci_cmd_clk_is_off; in ti_sci_setup_ops()
2894 cops->set_parent = ti_sci_cmd_clk_set_parent; in ti_sci_setup_ops()
2895 cops->get_parent = ti_sci_cmd_clk_get_parent; in ti_sci_setup_ops()
2896 cops->get_num_parents = ti_sci_cmd_clk_get_num_parents; in ti_sci_setup_ops()
2898 cops->get_best_match_freq = ti_sci_cmd_clk_get_match_freq; in ti_sci_setup_ops()
2899 cops->set_freq = ti_sci_cmd_clk_set_freq; in ti_sci_setup_ops()
2900 cops->get_freq = ti_sci_cmd_clk_get_freq; in ti_sci_setup_ops()
2902 rm_core_ops->get_range = ti_sci_cmd_get_resource_range; in ti_sci_setup_ops()
2903 rm_core_ops->get_range_from_shost = in ti_sci_setup_ops()
2906 iops->set_irq = ti_sci_cmd_set_irq; in ti_sci_setup_ops()
2907 iops->set_event_map = ti_sci_cmd_set_event_map; in ti_sci_setup_ops()
2908 iops->free_irq = ti_sci_cmd_free_irq; in ti_sci_setup_ops()
2909 iops->free_event_map = ti_sci_cmd_free_event_map; in ti_sci_setup_ops()
2911 rops->config = ti_sci_cmd_ring_config; in ti_sci_setup_ops()
2912 rops->get_config = ti_sci_cmd_ring_get_config; in ti_sci_setup_ops()
2914 psilops->pair = ti_sci_cmd_rm_psil_pair; in ti_sci_setup_ops()
2915 psilops->unpair = ti_sci_cmd_rm_psil_unpair; in ti_sci_setup_ops()
2917 udmap_ops->tx_ch_cfg = ti_sci_cmd_rm_udmap_tx_ch_cfg; in ti_sci_setup_ops()
2918 udmap_ops->rx_ch_cfg = ti_sci_cmd_rm_udmap_rx_ch_cfg; in ti_sci_setup_ops()
2919 udmap_ops->rx_flow_cfg = ti_sci_cmd_rm_udmap_rx_flow_cfg; in ti_sci_setup_ops()
2921 pops->request = ti_sci_cmd_proc_request; in ti_sci_setup_ops()
2922 pops->release = ti_sci_cmd_proc_release; in ti_sci_setup_ops()
2923 pops->handover = ti_sci_cmd_proc_handover; in ti_sci_setup_ops()
2924 pops->set_config = ti_sci_cmd_proc_set_config; in ti_sci_setup_ops()
2925 pops->set_control = ti_sci_cmd_proc_set_control; in ti_sci_setup_ops()
2926 pops->get_status = ti_sci_cmd_proc_get_status; in ti_sci_setup_ops()
2930 * ti_sci_get_handle() - Get the TI SCI handle for a device
2931 * @dev: Pointer to device for which we want SCI handle
2934 * and is expected to be maintained by caller of TI SCI protocol library.
2937 * -EPROBE_DEFER if the instance is not ready
2938 * -ENODEV if the required node handler is missing
2939 * -EINVAL if invalid conditions are encountered.
2941 const struct ti_sci_handle *ti_sci_get_handle(struct device *dev) in ti_sci_get_handle() argument
2948 if (!dev) { in ti_sci_get_handle()
2950 return ERR_PTR(-EINVAL); in ti_sci_get_handle()
2952 ti_sci_np = of_get_parent(dev->of_node); in ti_sci_get_handle()
2954 dev_err(dev, "No OF information\n"); in ti_sci_get_handle()
2955 return ERR_PTR(-EINVAL); in ti_sci_get_handle()
2961 if (ti_sci_np == info->dev->of_node) { in ti_sci_get_handle()
2962 handle = &info->handle; in ti_sci_get_handle()
2963 info->users++; in ti_sci_get_handle()
2971 return ERR_PTR(-EPROBE_DEFER); in ti_sci_get_handle()
2978 * ti_sci_put_handle() - Release the handle acquired by ti_sci_get_handle
2982 * and is expected to be maintained by caller of TI SCI protocol library.
2987 * if null was passed, it returns -EINVAL;
2996 return -EINVAL; in ti_sci_put_handle()
3000 if (!WARN_ON(!info->users)) in ti_sci_put_handle()
3001 info->users--; in ti_sci_put_handle()
3008 static void devm_ti_sci_release(struct device *dev, void *res) in devm_ti_sci_release() argument
3016 dev_err(dev, "failed to put handle %d\n", ret); in devm_ti_sci_release()
3020 * devm_ti_sci_get_handle() - Managed get handle
3021 * @dev: device for which we want SCI handle for.
3026 * and is expected to be maintained by caller of TI SCI protocol library.
3030 const struct ti_sci_handle *devm_ti_sci_get_handle(struct device *dev) in devm_ti_sci_get_handle() argument
3037 return ERR_PTR(-ENOMEM); in devm_ti_sci_get_handle()
3038 handle = ti_sci_get_handle(dev); in devm_ti_sci_get_handle()
3042 devres_add(dev, ptr); in devm_ti_sci_get_handle()
3052 * ti_sci_get_by_phandle() - Get the TI SCI handle using DT phandle
3057 * and is expected to be maintained by caller of TI SCI protocol library.
3060 * -EPROBE_DEFER if the instance is not ready
3061 * -ENODEV if the required node handler is missing
3062 * -EINVAL if invalid conditions are encountered.
3074 return ERR_PTR(-EINVAL); in ti_sci_get_by_phandle()
3079 return ERR_PTR(-ENODEV); in ti_sci_get_by_phandle()
3084 if (ti_sci_np == info->dev->of_node) { in ti_sci_get_by_phandle()
3085 handle = &info->handle; in ti_sci_get_by_phandle()
3086 info->users++; in ti_sci_get_by_phandle()
3094 return ERR_PTR(-EPROBE_DEFER); in ti_sci_get_by_phandle()
3101 * devm_ti_sci_get_by_phandle() - Managed get handle using phandle
3102 * @dev: Device pointer requesting TISCI handle
3108 * and is expected to be maintained by caller of TI SCI protocol library.
3112 const struct ti_sci_handle *devm_ti_sci_get_by_phandle(struct device *dev, in devm_ti_sci_get_by_phandle() argument
3120 return ERR_PTR(-ENOMEM); in devm_ti_sci_get_by_phandle()
3121 handle = ti_sci_get_by_phandle(dev_of_node(dev), property); in devm_ti_sci_get_by_phandle()
3125 devres_add(dev, ptr); in devm_ti_sci_get_by_phandle()
3135 * ti_sci_get_free_resource() - Get a free resource from TISCI resource.
3145 raw_spin_lock_irqsave(&res->lock, flags); in ti_sci_get_free_resource()
3146 for (set = 0; set < res->sets; set++) { in ti_sci_get_free_resource()
3147 free_bit = find_first_zero_bit(res->desc[set].res_map, in ti_sci_get_free_resource()
3148 res->desc[set].num); in ti_sci_get_free_resource()
3149 if (free_bit != res->desc[set].num) { in ti_sci_get_free_resource()
3150 set_bit(free_bit, res->desc[set].res_map); in ti_sci_get_free_resource()
3151 raw_spin_unlock_irqrestore(&res->lock, flags); in ti_sci_get_free_resource()
3152 return res->desc[set].start + free_bit; in ti_sci_get_free_resource()
3155 raw_spin_unlock_irqrestore(&res->lock, flags); in ti_sci_get_free_resource()
3162 * ti_sci_release_resource() - Release a resource from TISCI resource.
3164 * @id: Resource id to be released.
3166 void ti_sci_release_resource(struct ti_sci_resource *res, u16 id) in ti_sci_release_resource() argument
3171 raw_spin_lock_irqsave(&res->lock, flags); in ti_sci_release_resource()
3172 for (set = 0; set < res->sets; set++) { in ti_sci_release_resource()
3173 if (res->desc[set].start <= id && in ti_sci_release_resource()
3174 (res->desc[set].num + res->desc[set].start) > id) in ti_sci_release_resource()
3175 clear_bit(id - res->desc[set].start, in ti_sci_release_resource()
3176 res->desc[set].res_map); in ti_sci_release_resource()
3178 raw_spin_unlock_irqrestore(&res->lock, flags); in ti_sci_release_resource()
3183 * ti_sci_get_num_resources() - Get the number of resources in TISCI resource
3192 for (set = 0; set < res->sets; set++) in ti_sci_get_num_resources()
3193 count += res->desc[set].num; in ti_sci_get_num_resources()
3200 * devm_ti_sci_get_resource_sets() - Get a TISCI resources assigned to a device
3202 * @dev: Device pointer to which the resource is assigned
3203 * @dev_id: TISCI device id to which the resource is assigned
3212 struct device *dev, u32 dev_id, u32 *sub_types, in devm_ti_sci_get_resource_sets() argument
3219 res = devm_kzalloc(dev, sizeof(*res), GFP_KERNEL); in devm_ti_sci_get_resource_sets()
3221 return ERR_PTR(-ENOMEM); in devm_ti_sci_get_resource_sets()
3223 res->sets = sets; in devm_ti_sci_get_resource_sets()
3224 res->desc = devm_kcalloc(dev, res->sets, sizeof(*res->desc), in devm_ti_sci_get_resource_sets()
3226 if (!res->desc) in devm_ti_sci_get_resource_sets()
3227 return ERR_PTR(-ENOMEM); in devm_ti_sci_get_resource_sets()
3229 for (i = 0; i < res->sets; i++) { in devm_ti_sci_get_resource_sets()
3230 ret = handle->ops.rm_core_ops.get_range(handle, dev_id, in devm_ti_sci_get_resource_sets()
3232 &res->desc[i].start, in devm_ti_sci_get_resource_sets()
3233 &res->desc[i].num); in devm_ti_sci_get_resource_sets()
3235 dev_dbg(dev, "dev = %d subtype %d not allocated for this host\n", in devm_ti_sci_get_resource_sets()
3237 res->desc[i].start = 0; in devm_ti_sci_get_resource_sets()
3238 res->desc[i].num = 0; in devm_ti_sci_get_resource_sets()
3242 dev_dbg(dev, "dev = %d, subtype = %d, start = %d, num = %d\n", in devm_ti_sci_get_resource_sets()
3243 dev_id, sub_types[i], res->desc[i].start, in devm_ti_sci_get_resource_sets()
3244 res->desc[i].num); in devm_ti_sci_get_resource_sets()
3247 res->desc[i].res_map = in devm_ti_sci_get_resource_sets()
3248 devm_kzalloc(dev, BITS_TO_LONGS(res->desc[i].num) * in devm_ti_sci_get_resource_sets()
3249 sizeof(*res->desc[i].res_map), GFP_KERNEL); in devm_ti_sci_get_resource_sets()
3250 if (!res->desc[i].res_map) in devm_ti_sci_get_resource_sets()
3251 return ERR_PTR(-ENOMEM); in devm_ti_sci_get_resource_sets()
3253 raw_spin_lock_init(&res->lock); in devm_ti_sci_get_resource_sets()
3258 return ERR_PTR(-EINVAL); in devm_ti_sci_get_resource_sets()
3262 * devm_ti_sci_get_of_resource() - Get a TISCI resource assigned to a device
3264 * @dev: Device pointer to which the resource is assigned
3265 * @dev_id: TISCI device id to which the resource is assigned
3273 struct device *dev, u32 dev_id, char *of_prop) in devm_ti_sci_get_of_resource() argument
3279 sets = of_property_count_elems_of_size(dev_of_node(dev), of_prop, in devm_ti_sci_get_of_resource()
3282 dev_err(dev, "%s resource type ids not available\n", of_prop); in devm_ti_sci_get_of_resource()
3288 return ERR_PTR(-ENOMEM); in devm_ti_sci_get_of_resource()
3290 of_property_read_u32_array(dev_of_node(dev), of_prop, sub_types, sets); in devm_ti_sci_get_of_resource()
3291 res = devm_ti_sci_get_resource_sets(handle, dev, dev_id, sub_types, in devm_ti_sci_get_of_resource()
3300 * devm_ti_sci_get_resource() - Get a resource range assigned to the device
3302 * @dev: Device pointer to which the resource is assigned
3303 * @dev_id: TISCI device id to which the resource is assigned
3310 devm_ti_sci_get_resource(const struct ti_sci_handle *handle, struct device *dev, in devm_ti_sci_get_resource() argument
3313 return devm_ti_sci_get_resource_sets(handle, dev, dev_id, &sub_type, 1); in devm_ti_sci_get_resource()
3321 const struct ti_sci_handle *handle = &info->handle; in tisci_reboot_handler()
3350 {.compatible = "ti,k2g-sci", .data = &ti_sci_pmmc_k2g_desc},
3351 {.compatible = "ti,am654-sci", .data = &ti_sci_pmmc_am654_desc},
3358 struct device *dev = &pdev->dev; in ti_sci_probe() local
3365 int ret = -EINVAL; in ti_sci_probe()
3370 of_id = of_match_device(ti_sci_of_match, dev); in ti_sci_probe()
3372 dev_err(dev, "OF data missing\n"); in ti_sci_probe()
3373 return -EINVAL; in ti_sci_probe()
3375 desc = of_id->data; in ti_sci_probe()
3377 info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL); in ti_sci_probe()
3379 return -ENOMEM; in ti_sci_probe()
3381 info->dev = dev; in ti_sci_probe()
3382 info->desc = desc; in ti_sci_probe()
3383 ret = of_property_read_u32(dev->of_node, "ti,host-id", &h_id); in ti_sci_probe()
3386 info->host_id = info->desc->default_host_id; in ti_sci_probe()
3389 dev_warn(dev, "Host ID 0 is reserved for firmware\n"); in ti_sci_probe()
3390 info->host_id = info->desc->default_host_id; in ti_sci_probe()
3392 info->host_id = h_id; in ti_sci_probe()
3396 reboot = of_property_read_bool(dev->of_node, in ti_sci_probe()
3397 "ti,system-reboot-controller"); in ti_sci_probe()
3398 INIT_LIST_HEAD(&info->node); in ti_sci_probe()
3399 minfo = &info->minfo; in ti_sci_probe()
3402 * Pre-allocate messages in ti_sci_probe()
3406 if (WARN_ON(desc->max_msgs >= in ti_sci_probe()
3407 1 << 8 * sizeof(((struct ti_sci_msg_hdr *)0)->seq))) in ti_sci_probe()
3408 return -EINVAL; in ti_sci_probe()
3410 minfo->xfer_block = devm_kcalloc(dev, in ti_sci_probe()
3411 desc->max_msgs, in ti_sci_probe()
3412 sizeof(*minfo->xfer_block), in ti_sci_probe()
3414 if (!minfo->xfer_block) in ti_sci_probe()
3415 return -ENOMEM; in ti_sci_probe()
3417 minfo->xfer_alloc_table = devm_kcalloc(dev, in ti_sci_probe()
3418 BITS_TO_LONGS(desc->max_msgs), in ti_sci_probe()
3421 if (!minfo->xfer_alloc_table) in ti_sci_probe()
3422 return -ENOMEM; in ti_sci_probe()
3423 bitmap_zero(minfo->xfer_alloc_table, desc->max_msgs); in ti_sci_probe()
3425 /* Pre-initialize the buffer pointer to pre-allocated buffers */ in ti_sci_probe()
3426 for (i = 0, xfer = minfo->xfer_block; i < desc->max_msgs; i++, xfer++) { in ti_sci_probe()
3427 xfer->xfer_buf = devm_kcalloc(dev, 1, desc->max_msg_size, in ti_sci_probe()
3429 if (!xfer->xfer_buf) in ti_sci_probe()
3430 return -ENOMEM; in ti_sci_probe()
3432 xfer->tx_message.buf = xfer->xfer_buf; in ti_sci_probe()
3433 init_completion(&xfer->done); in ti_sci_probe()
3438 dev_warn(dev, "Failed to create debug file\n"); in ti_sci_probe()
3442 cl = &info->cl; in ti_sci_probe()
3443 cl->dev = dev; in ti_sci_probe()
3444 cl->tx_block = false; in ti_sci_probe()
3445 cl->rx_callback = ti_sci_rx_callback; in ti_sci_probe()
3446 cl->knows_txdone = true; in ti_sci_probe()
3448 spin_lock_init(&minfo->xfer_lock); in ti_sci_probe()
3449 sema_init(&minfo->sem_xfer_count, desc->max_msgs); in ti_sci_probe()
3451 info->chan_rx = mbox_request_channel_byname(cl, "rx"); in ti_sci_probe()
3452 if (IS_ERR(info->chan_rx)) { in ti_sci_probe()
3453 ret = PTR_ERR(info->chan_rx); in ti_sci_probe()
3457 info->chan_tx = mbox_request_channel_byname(cl, "tx"); in ti_sci_probe()
3458 if (IS_ERR(info->chan_tx)) { in ti_sci_probe()
3459 ret = PTR_ERR(info->chan_tx); in ti_sci_probe()
3464 dev_err(dev, "Unable to communicate with TISCI(%d)\n", ret); in ti_sci_probe()
3471 info->nb.notifier_call = tisci_reboot_handler; in ti_sci_probe()
3472 info->nb.priority = 128; in ti_sci_probe()
3474 ret = register_restart_handler(&info->nb); in ti_sci_probe()
3476 dev_err(dev, "reboot registration fail(%d)\n", ret); in ti_sci_probe()
3481 dev_info(dev, "ABI: %d.%d (firmware rev 0x%04x '%s')\n", in ti_sci_probe()
3482 info->handle.version.abi_major, info->handle.version.abi_minor, in ti_sci_probe()
3483 info->handle.version.firmware_revision, in ti_sci_probe()
3484 info->handle.version.firmware_description); in ti_sci_probe()
3487 list_add_tail(&info->node, &ti_sci_list); in ti_sci_probe()
3490 return of_platform_populate(dev->of_node, NULL, NULL, dev); in ti_sci_probe()
3492 if (!IS_ERR(info->chan_tx)) in ti_sci_probe()
3493 mbox_free_channel(info->chan_tx); in ti_sci_probe()
3494 if (!IS_ERR(info->chan_rx)) in ti_sci_probe()
3495 mbox_free_channel(info->chan_rx); in ti_sci_probe()
3496 debugfs_remove(info->d); in ti_sci_probe()
3503 .name = "ti-sci",
3511 MODULE_DESCRIPTION("TI System Control Interface(SCI) driver");
3513 MODULE_ALIAS("platform:ti-sci");