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

1 // SPDX-License-Identifier: GPL-2.0
5 * Copyright (C) 2015-2025 Texas Instruments Incorporated - https://www.ti.com/
27 #include <linux/soc/ti/ti-msgmgr.h>
35 /* List of all TI SCI devices active in system */
41 * struct ti_sci_xfer - Structure representing a message flow
45 * Since we work with request-ACK protocol, we can
58 * struct ti_sci_xfers_info - Structure to manage transfer information
76 * struct ti_sci_desc - Description of SoC integration
91 * struct ti_sci_info - Structure representing a TI SCI instance
92 * @dev: Device pointer
98 * @handle: Instance of TI SCI handle to send to clients.
104 * @host_id: Host ID
109 struct device *dev; member
133 * ti_sci_debug_show() - Helper to dump the debug log
141 struct ti_sci_info *info = s->private; in ti_sci_debug_show()
143 memcpy_fromio(info->debug_buffer, info->debug_region, in ti_sci_debug_show()
144 info->debug_region_size); in ti_sci_debug_show()
149 * in the buffer as is - we expect the messages to be self explanatory. in ti_sci_debug_show()
151 seq_puts(s, info->debug_buffer); in ti_sci_debug_show()
159 * ti_sci_debugfs_create() - Create log debug file
161 * @info: Pointer to SCI entity information
168 struct device *dev = &pdev->dev; in ti_sci_debugfs_create() local
175 info->debug_region = devm_ioremap_resource(dev, res); in ti_sci_debugfs_create()
176 if (IS_ERR(info->debug_region)) in ti_sci_debugfs_create()
178 info->debug_region_size = resource_size(res); in ti_sci_debugfs_create()
180 info->debug_buffer = devm_kcalloc(dev, info->debug_region_size + 1, in ti_sci_debugfs_create()
182 if (!info->debug_buffer) in ti_sci_debugfs_create()
183 return -ENOMEM; in ti_sci_debugfs_create()
185 info->debug_buffer[info->debug_region_size] = 0; in ti_sci_debugfs_create()
188 dev_name(dev)); in ti_sci_debugfs_create()
189 info->d = debugfs_create_file(debug_name, 0444, NULL, info, in ti_sci_debugfs_create()
191 if (IS_ERR(info->d)) in ti_sci_debugfs_create()
192 return PTR_ERR(info->d); in ti_sci_debugfs_create()
194 dev_dbg(dev, "Debug region => %p, size = %zu bytes, resource: %pr\n", in ti_sci_debugfs_create()
195 info->debug_region, info->debug_region_size, res); in ti_sci_debugfs_create()
200 static inline int ti_sci_debugfs_create(struct platform_device *dev, in ti_sci_debugfs_create() argument
206 static inline void ti_sci_debugfs_destroy(struct platform_device *dev, in ti_sci_debugfs_destroy() argument
213 * ti_sci_dump_header_dbg() - Helper to dump a message header.
214 * @dev: Device pointer corresponding to the SCI entity
217 static inline void ti_sci_dump_header_dbg(struct device *dev, in ti_sci_dump_header_dbg() argument
220 dev_dbg(dev, "MSGHDR:type=0x%04x host=0x%02x seq=0x%02x flags=0x%08x\n", in ti_sci_dump_header_dbg()
221 hdr->type, hdr->host, hdr->seq, hdr->flags); in ti_sci_dump_header_dbg()
225 * ti_sci_rx_callback() - mailbox client callback for receive messages
238 struct device *dev = info->dev; in ti_sci_rx_callback() local
239 struct ti_sci_xfers_info *minfo = &info->minfo; in ti_sci_rx_callback()
241 struct ti_sci_msg_hdr *hdr = (struct ti_sci_msg_hdr *)mbox_msg->buf; in ti_sci_rx_callback()
245 xfer_id = hdr->seq; in ti_sci_rx_callback()
251 if (!test_bit(xfer_id, minfo->xfer_alloc_table)) { in ti_sci_rx_callback()
252 dev_err(dev, "Message for %d is not expected!\n", xfer_id); in ti_sci_rx_callback()
256 xfer = &minfo->xfer_block[xfer_id]; in ti_sci_rx_callback()
259 if (mbox_msg->len > info->desc->max_msg_size) { in ti_sci_rx_callback()
260 dev_err(dev, "Unable to handle %zu xfer(max %d)\n", in ti_sci_rx_callback()
261 mbox_msg->len, info->desc->max_msg_size); in ti_sci_rx_callback()
262 ti_sci_dump_header_dbg(dev, hdr); in ti_sci_rx_callback()
265 if (mbox_msg->len < xfer->rx_len) { in ti_sci_rx_callback()
266 dev_err(dev, "Recv xfer %zu < expected %d length\n", in ti_sci_rx_callback()
267 mbox_msg->len, xfer->rx_len); in ti_sci_rx_callback()
268 ti_sci_dump_header_dbg(dev, hdr); in ti_sci_rx_callback()
272 ti_sci_dump_header_dbg(dev, hdr); in ti_sci_rx_callback()
274 memcpy(xfer->xfer_buf, mbox_msg->buf, xfer->rx_len); in ti_sci_rx_callback()
275 complete(&xfer->done); in ti_sci_rx_callback()
279 * ti_sci_get_one_xfer() - Allocate one message
280 * @info: Pointer to SCI entity information
290 * for the SCI entity. Further, this also holds a spinlock to maintain integrity
300 struct ti_sci_xfers_info *minfo = &info->minfo; in ti_sci_get_one_xfer()
310 if (rx_message_size > info->desc->max_msg_size || in ti_sci_get_one_xfer()
311 tx_message_size > info->desc->max_msg_size || in ti_sci_get_one_xfer()
313 return ERR_PTR(-ERANGE); in ti_sci_get_one_xfer()
320 timeout = msecs_to_jiffies(info->desc->max_rx_timeout_ms) * 5; in ti_sci_get_one_xfer()
321 ret = down_timeout(&minfo->sem_xfer_count, timeout); in ti_sci_get_one_xfer()
326 spin_lock_irqsave(&minfo->xfer_lock, flags); in ti_sci_get_one_xfer()
327 bit_pos = find_first_zero_bit(minfo->xfer_alloc_table, in ti_sci_get_one_xfer()
328 info->desc->max_msgs); in ti_sci_get_one_xfer()
329 set_bit(bit_pos, minfo->xfer_alloc_table); in ti_sci_get_one_xfer()
330 spin_unlock_irqrestore(&minfo->xfer_lock, flags); in ti_sci_get_one_xfer()
334 * fit in hdr.seq - NOTE: this improves access latencies in ti_sci_get_one_xfer()
341 xfer = &minfo->xfer_block[xfer_id]; in ti_sci_get_one_xfer()
343 hdr = (struct ti_sci_msg_hdr *)xfer->tx_message.buf; in ti_sci_get_one_xfer()
344 xfer->tx_message.len = tx_message_size; in ti_sci_get_one_xfer()
345 xfer->tx_message.chan_rx = info->chan_rx; in ti_sci_get_one_xfer()
346 xfer->tx_message.timeout_rx_ms = info->desc->max_rx_timeout_ms; in ti_sci_get_one_xfer()
347 xfer->rx_len = (u8)rx_message_size; in ti_sci_get_one_xfer()
349 reinit_completion(&xfer->done); in ti_sci_get_one_xfer()
351 hdr->seq = xfer_id; in ti_sci_get_one_xfer()
352 hdr->type = msg_type; in ti_sci_get_one_xfer()
353 hdr->host = info->host_id; in ti_sci_get_one_xfer()
354 hdr->flags = msg_flags; in ti_sci_get_one_xfer()
360 * ti_sci_put_one_xfer() - Release a message
373 hdr = (struct ti_sci_msg_hdr *)xfer->tx_message.buf; in ti_sci_put_one_xfer()
374 xfer_id = hdr->seq; in ti_sci_put_one_xfer()
381 spin_lock_irqsave(&minfo->xfer_lock, flags); in ti_sci_put_one_xfer()
382 clear_bit(xfer_id, minfo->xfer_alloc_table); in ti_sci_put_one_xfer()
383 spin_unlock_irqrestore(&minfo->xfer_lock, flags); in ti_sci_put_one_xfer()
386 up(&minfo->sem_xfer_count); in ti_sci_put_one_xfer()
390 * ti_sci_do_xfer() - Do one transfer
391 * @info: Pointer to SCI entity information
394 * Return: -ETIMEDOUT in case of no response, if transmit error,
401 struct ti_sci_msg_hdr *hdr = (struct ti_sci_msg_hdr *)xfer->tx_message.buf; in ti_sci_do_xfer()
402 bool response_expected = !!(hdr->flags & (TI_SCI_FLAG_REQ_ACK_ON_PROCESSED | in ti_sci_do_xfer()
406 struct device *dev = info->dev; in ti_sci_do_xfer() local
409 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()
419 ret = -ETIMEDOUT; in ti_sci_do_xfer()
427 info->desc->max_rx_timeout_ms * 1000, in ti_sci_do_xfer()
428 false, &xfer->done); in ti_sci_do_xfer()
431 if (ret == -ETIMEDOUT) in ti_sci_do_xfer()
432 dev_err(dev, "Mbox timedout in resp(caller: %pS)\n", in ti_sci_do_xfer()
441 mbox_client_txdone(info->chan_tx, ret); in ti_sci_do_xfer()
447 * ti_sci_cmd_get_revision() - command to get the revision of the SCI entity
448 * @info: Pointer to SCI entity information
450 * Updates the SCI information in the internal data structure.
456 struct device *dev = info->dev; in ti_sci_cmd_get_revision() local
457 struct ti_sci_handle *handle = &info->handle; in ti_sci_cmd_get_revision()
458 struct ti_sci_version_info *ver = &handle->version; in ti_sci_cmd_get_revision()
469 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_cmd_get_revision()
473 rev_info = (struct ti_sci_msg_resp_version *)xfer->xfer_buf; in ti_sci_cmd_get_revision()
477 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_cmd_get_revision()
481 ver->abi_major = rev_info->abi_major; in ti_sci_cmd_get_revision()
482 ver->abi_minor = rev_info->abi_minor; in ti_sci_cmd_get_revision()
483 ver->firmware_revision = rev_info->firmware_revision; in ti_sci_cmd_get_revision()
484 strscpy(ver->firmware_description, rev_info->firmware_description, in ti_sci_cmd_get_revision()
485 sizeof(ver->firmware_description)); in ti_sci_cmd_get_revision()
488 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_get_revision()
493 * ti_sci_is_response_ack() - Generic ACK/NACK message checkup
502 return hdr->flags & TI_SCI_FLAG_RESP_GENERIC_ACK ? true : false; in ti_sci_is_response_ack()
506 * ti_sci_set_device_state() - Set device state helper
507 * @handle: pointer to TI SCI handle
508 * @id: Device identifier
515 u32 id, u32 flags, u8 state) in ti_sci_set_device_state() argument
521 struct device *dev; in ti_sci_set_device_state() local
527 return -EINVAL; in ti_sci_set_device_state()
530 dev = info->dev; in ti_sci_set_device_state()
537 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_set_device_state()
540 req = (struct ti_sci_msg_req_set_device_state *)xfer->xfer_buf; in ti_sci_set_device_state()
541 req->id = id; in ti_sci_set_device_state()
542 req->state = state; in ti_sci_set_device_state()
546 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_set_device_state()
550 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_set_device_state()
552 ret = ti_sci_is_response_ack(resp) ? 0 : -ENODEV; in ti_sci_set_device_state()
555 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_set_device_state()
561 * ti_sci_get_device_state() - Get device state helper
563 * @id: Device Identifier
572 u32 id, u32 *clcnt, u32 *resets, in ti_sci_get_device_state() argument
579 struct device *dev; in ti_sci_get_device_state() local
585 return -EINVAL; in ti_sci_get_device_state()
588 return -EINVAL; in ti_sci_get_device_state()
591 dev = info->dev; in ti_sci_get_device_state()
598 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_get_device_state()
601 req = (struct ti_sci_msg_req_get_device_state *)xfer->xfer_buf; in ti_sci_get_device_state()
602 req->id = id; in ti_sci_get_device_state()
606 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_get_device_state()
610 resp = (struct ti_sci_msg_resp_get_device_state *)xfer->xfer_buf; in ti_sci_get_device_state()
612 ret = -ENODEV; in ti_sci_get_device_state()
617 *clcnt = resp->context_loss_count; in ti_sci_get_device_state()
619 *resets = resp->resets; in ti_sci_get_device_state()
621 *p_state = resp->programmed_state; in ti_sci_get_device_state()
623 *c_state = resp->current_state; in ti_sci_get_device_state()
625 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_get_device_state()
631 * ti_sci_cmd_get_device() - command to request for device managed by TISCI
634 * @id: Device Identifier
636 * Request for the device - NOTE: the client MUST maintain integrity of
642 static int ti_sci_cmd_get_device(const struct ti_sci_handle *handle, u32 id) in ti_sci_cmd_get_device() argument
644 return ti_sci_set_device_state(handle, id, 0, in ti_sci_cmd_get_device()
649 * ti_sci_cmd_get_device_exclusive() - command to request for device managed by
653 * @id: Device Identifier
655 * Request for the device - NOTE: the client MUST maintain integrity of
662 u32 id) in ti_sci_cmd_get_device_exclusive() argument
664 return ti_sci_set_device_state(handle, id, in ti_sci_cmd_get_device_exclusive()
670 * ti_sci_cmd_idle_device() - Command to idle a device managed by TISCI
672 * @id: Device Identifier
674 * Request for the device - NOTE: the client MUST maintain integrity of
680 static int ti_sci_cmd_idle_device(const struct ti_sci_handle *handle, u32 id) in ti_sci_cmd_idle_device() argument
682 return ti_sci_set_device_state(handle, id, 0, in ti_sci_cmd_idle_device()
687 * ti_sci_cmd_idle_device_exclusive() - Command to idle a device managed by
691 * @id: Device Identifier
693 * Request for the device - NOTE: the client MUST maintain integrity of
700 u32 id) in ti_sci_cmd_idle_device_exclusive() argument
702 return ti_sci_set_device_state(handle, id, in ti_sci_cmd_idle_device_exclusive()
708 * ti_sci_cmd_put_device() - command to release a device managed by TISCI
710 * @id: Device Identifier
712 * Request for the device - NOTE: the client MUST maintain integrity of
718 static int ti_sci_cmd_put_device(const struct ti_sci_handle *handle, u32 id) in ti_sci_cmd_put_device() argument
720 return ti_sci_set_device_state(handle, id, in ti_sci_cmd_put_device()
725 * ti_sci_cmd_dev_is_valid() - Is the device valid
727 * @id: Device Identifier
729 * Return: 0 if all went fine and the device ID is valid, else return
732 static int ti_sci_cmd_dev_is_valid(const struct ti_sci_handle *handle, u32 id) in ti_sci_cmd_dev_is_valid() argument
736 /* check the device state which will also tell us if the ID is valid */ in ti_sci_cmd_dev_is_valid()
737 return ti_sci_get_device_state(handle, id, NULL, NULL, NULL, &unused); in ti_sci_cmd_dev_is_valid()
741 * ti_sci_cmd_dev_get_clcnt() - Get context loss counter
743 * @id: Device Identifier
748 static int ti_sci_cmd_dev_get_clcnt(const struct ti_sci_handle *handle, u32 id, in ti_sci_cmd_dev_get_clcnt() argument
751 return ti_sci_get_device_state(handle, id, count, NULL, NULL, NULL); in ti_sci_cmd_dev_get_clcnt()
755 * ti_sci_cmd_dev_is_idle() - Check if the device is requested to be idle
757 * @id: Device Identifier
762 static int ti_sci_cmd_dev_is_idle(const struct ti_sci_handle *handle, u32 id, in ti_sci_cmd_dev_is_idle() argument
769 return -EINVAL; in ti_sci_cmd_dev_is_idle()
771 ret = ti_sci_get_device_state(handle, id, NULL, NULL, &state, NULL); in ti_sci_cmd_dev_is_idle()
781 * ti_sci_cmd_dev_is_stop() - Check if the device is requested to be stopped
783 * @id: Device Identifier
789 static int ti_sci_cmd_dev_is_stop(const struct ti_sci_handle *handle, u32 id, in ti_sci_cmd_dev_is_stop() argument
796 return -EINVAL; in ti_sci_cmd_dev_is_stop()
799 ti_sci_get_device_state(handle, id, NULL, NULL, &p_state, &c_state); in ti_sci_cmd_dev_is_stop()
812 * ti_sci_cmd_dev_is_on() - Check if the device is requested to be ON
814 * @id: Device Identifier
820 static int ti_sci_cmd_dev_is_on(const struct ti_sci_handle *handle, u32 id, in ti_sci_cmd_dev_is_on() argument
827 return -EINVAL; in ti_sci_cmd_dev_is_on()
830 ti_sci_get_device_state(handle, id, NULL, NULL, &p_state, &c_state); in ti_sci_cmd_dev_is_on()
843 * ti_sci_cmd_dev_is_trans() - Check if the device is currently transitioning
845 * @id: Device Identifier
850 static int ti_sci_cmd_dev_is_trans(const struct ti_sci_handle *handle, u32 id, in ti_sci_cmd_dev_is_trans() argument
857 return -EINVAL; in ti_sci_cmd_dev_is_trans()
859 ret = ti_sci_get_device_state(handle, id, NULL, NULL, NULL, &state); in ti_sci_cmd_dev_is_trans()
869 * ti_sci_cmd_set_device_resets() - command to set resets for device managed
872 * @id: Device Identifier
878 u32 id, u32 reset_state) in ti_sci_cmd_set_device_resets() argument
884 struct device *dev; in ti_sci_cmd_set_device_resets() local
890 return -EINVAL; in ti_sci_cmd_set_device_resets()
893 dev = info->dev; in ti_sci_cmd_set_device_resets()
900 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_cmd_set_device_resets()
903 req = (struct ti_sci_msg_req_set_device_resets *)xfer->xfer_buf; in ti_sci_cmd_set_device_resets()
904 req->id = id; in ti_sci_cmd_set_device_resets()
905 req->resets = reset_state; in ti_sci_cmd_set_device_resets()
909 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_cmd_set_device_resets()
913 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_cmd_set_device_resets()
915 ret = ti_sci_is_response_ack(resp) ? 0 : -ENODEV; in ti_sci_cmd_set_device_resets()
918 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_set_device_resets()
924 * ti_sci_cmd_get_device_resets() - Get reset state for device managed
927 * @id: Device Identifier
933 u32 id, u32 *reset_state) in ti_sci_cmd_get_device_resets() argument
935 return ti_sci_get_device_state(handle, id, NULL, reset_state, NULL, in ti_sci_cmd_get_device_resets()
940 * ti_sci_set_clock_state() - Set clock state helper
941 * @handle: pointer to TI SCI handle
959 struct device *dev; in ti_sci_set_clock_state() local
965 return -EINVAL; in ti_sci_set_clock_state()
968 dev = info->dev; in ti_sci_set_clock_state()
975 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_set_clock_state()
978 req = (struct ti_sci_msg_req_set_clock_state *)xfer->xfer_buf; in ti_sci_set_clock_state()
979 req->dev_id = dev_id; in ti_sci_set_clock_state()
981 req->clk_id = clk_id; in ti_sci_set_clock_state()
983 req->clk_id = 255; in ti_sci_set_clock_state()
984 req->clk_id_32 = clk_id; in ti_sci_set_clock_state()
986 req->request_state = state; in ti_sci_set_clock_state()
990 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_set_clock_state()
994 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_set_clock_state()
996 ret = ti_sci_is_response_ack(resp) ? 0 : -ENODEV; in ti_sci_set_clock_state()
999 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_set_clock_state()
1005 * ti_sci_cmd_get_clock_state() - Get clock state helper
1006 * @handle: pointer to TI SCI handle
1024 struct device *dev; in ti_sci_cmd_get_clock_state() local
1030 return -EINVAL; in ti_sci_cmd_get_clock_state()
1033 return -EINVAL; in ti_sci_cmd_get_clock_state()
1036 dev = info->dev; in ti_sci_cmd_get_clock_state()
1043 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_cmd_get_clock_state()
1046 req = (struct ti_sci_msg_req_get_clock_state *)xfer->xfer_buf; in ti_sci_cmd_get_clock_state()
1047 req->dev_id = dev_id; in ti_sci_cmd_get_clock_state()
1049 req->clk_id = clk_id; in ti_sci_cmd_get_clock_state()
1051 req->clk_id = 255; in ti_sci_cmd_get_clock_state()
1052 req->clk_id_32 = clk_id; in ti_sci_cmd_get_clock_state()
1057 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_cmd_get_clock_state()
1061 resp = (struct ti_sci_msg_resp_get_clock_state *)xfer->xfer_buf; in ti_sci_cmd_get_clock_state()
1064 ret = -ENODEV; in ti_sci_cmd_get_clock_state()
1069 *programmed_state = resp->programmed_state; in ti_sci_cmd_get_clock_state()
1071 *current_state = resp->current_state; in ti_sci_cmd_get_clock_state()
1074 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_get_clock_state()
1080 * ti_sci_cmd_get_clock() - Get control of a clock from TI SCI
1081 * @handle: pointer to TI SCI handle
1107 * ti_sci_cmd_idle_clock() - Idle a clock which is in our control
1108 * @handle: pointer to TI SCI handle
1127 * ti_sci_cmd_put_clock() - Release a clock from our control back to TISCI
1128 * @handle: pointer to TI SCI handle
1147 * ti_sci_cmd_clk_is_auto() - Is the clock being auto managed
1148 * @handle: pointer to TI SCI handle
1164 return -EINVAL; in ti_sci_cmd_clk_is_auto()
1175 * ti_sci_cmd_clk_is_on() - Is the clock ON
1176 * @handle: pointer to TI SCI handle
1193 return -EINVAL; in ti_sci_cmd_clk_is_on()
1208 * ti_sci_cmd_clk_is_off() - Is the clock OFF
1209 * @handle: pointer to TI SCI handle
1226 return -EINVAL; in ti_sci_cmd_clk_is_off()
1241 * ti_sci_cmd_clk_set_parent() - Set the clock source of a specific device clock
1242 * @handle: pointer to TI SCI handle
1258 struct device *dev; in ti_sci_cmd_clk_set_parent() local
1264 return -EINVAL; in ti_sci_cmd_clk_set_parent()
1267 dev = info->dev; in ti_sci_cmd_clk_set_parent()
1274 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_cmd_clk_set_parent()
1277 req = (struct ti_sci_msg_req_set_clock_parent *)xfer->xfer_buf; in ti_sci_cmd_clk_set_parent()
1278 req->dev_id = dev_id; in ti_sci_cmd_clk_set_parent()
1280 req->clk_id = clk_id; in ti_sci_cmd_clk_set_parent()
1282 req->clk_id = 255; in ti_sci_cmd_clk_set_parent()
1283 req->clk_id_32 = clk_id; in ti_sci_cmd_clk_set_parent()
1286 req->parent_id = parent_id; in ti_sci_cmd_clk_set_parent()
1288 req->parent_id = 255; in ti_sci_cmd_clk_set_parent()
1289 req->parent_id_32 = parent_id; in ti_sci_cmd_clk_set_parent()
1294 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_cmd_clk_set_parent()
1298 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_cmd_clk_set_parent()
1300 ret = ti_sci_is_response_ack(resp) ? 0 : -ENODEV; in ti_sci_cmd_clk_set_parent()
1303 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_clk_set_parent()
1309 * ti_sci_cmd_clk_get_parent() - Get current parent clock source
1310 * @handle: pointer to TI SCI handle
1326 struct device *dev; in ti_sci_cmd_clk_get_parent() local
1332 return -EINVAL; in ti_sci_cmd_clk_get_parent()
1335 dev = info->dev; in ti_sci_cmd_clk_get_parent()
1342 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_cmd_clk_get_parent()
1345 req = (struct ti_sci_msg_req_get_clock_parent *)xfer->xfer_buf; in ti_sci_cmd_clk_get_parent()
1346 req->dev_id = dev_id; in ti_sci_cmd_clk_get_parent()
1348 req->clk_id = clk_id; in ti_sci_cmd_clk_get_parent()
1350 req->clk_id = 255; in ti_sci_cmd_clk_get_parent()
1351 req->clk_id_32 = clk_id; in ti_sci_cmd_clk_get_parent()
1356 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_cmd_clk_get_parent()
1360 resp = (struct ti_sci_msg_resp_get_clock_parent *)xfer->xfer_buf; in ti_sci_cmd_clk_get_parent()
1363 ret = -ENODEV; in ti_sci_cmd_clk_get_parent()
1365 if (resp->parent_id < 255) in ti_sci_cmd_clk_get_parent()
1366 *parent_id = resp->parent_id; in ti_sci_cmd_clk_get_parent()
1368 *parent_id = resp->parent_id_32; in ti_sci_cmd_clk_get_parent()
1372 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_clk_get_parent()
1378 * ti_sci_cmd_clk_get_num_parents() - Get num parents of the current clk source
1379 * @handle: pointer to TI SCI handle
1396 struct device *dev; in ti_sci_cmd_clk_get_num_parents() local
1402 return -EINVAL; in ti_sci_cmd_clk_get_num_parents()
1405 dev = info->dev; in ti_sci_cmd_clk_get_num_parents()
1412 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_cmd_clk_get_num_parents()
1415 req = (struct ti_sci_msg_req_get_clock_num_parents *)xfer->xfer_buf; in ti_sci_cmd_clk_get_num_parents()
1416 req->dev_id = dev_id; in ti_sci_cmd_clk_get_num_parents()
1418 req->clk_id = clk_id; in ti_sci_cmd_clk_get_num_parents()
1420 req->clk_id = 255; in ti_sci_cmd_clk_get_num_parents()
1421 req->clk_id_32 = clk_id; in ti_sci_cmd_clk_get_num_parents()
1426 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_cmd_clk_get_num_parents()
1430 resp = (struct ti_sci_msg_resp_get_clock_num_parents *)xfer->xfer_buf; in ti_sci_cmd_clk_get_num_parents()
1433 ret = -ENODEV; in ti_sci_cmd_clk_get_num_parents()
1435 if (resp->num_parents < 255) in ti_sci_cmd_clk_get_num_parents()
1436 *num_parents = resp->num_parents; in ti_sci_cmd_clk_get_num_parents()
1438 *num_parents = resp->num_parents_32; in ti_sci_cmd_clk_get_num_parents()
1442 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_clk_get_num_parents()
1448 * ti_sci_cmd_clk_get_match_freq() - Find a good match for frequency
1449 * @handle: pointer to TI SCI handle
1475 struct device *dev; in ti_sci_cmd_clk_get_match_freq() local
1481 return -EINVAL; in ti_sci_cmd_clk_get_match_freq()
1484 dev = info->dev; in ti_sci_cmd_clk_get_match_freq()
1491 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_cmd_clk_get_match_freq()
1494 req = (struct ti_sci_msg_req_query_clock_freq *)xfer->xfer_buf; in ti_sci_cmd_clk_get_match_freq()
1495 req->dev_id = dev_id; in ti_sci_cmd_clk_get_match_freq()
1497 req->clk_id = clk_id; in ti_sci_cmd_clk_get_match_freq()
1499 req->clk_id = 255; in ti_sci_cmd_clk_get_match_freq()
1500 req->clk_id_32 = clk_id; in ti_sci_cmd_clk_get_match_freq()
1502 req->min_freq_hz = min_freq; in ti_sci_cmd_clk_get_match_freq()
1503 req->target_freq_hz = target_freq; in ti_sci_cmd_clk_get_match_freq()
1504 req->max_freq_hz = max_freq; in ti_sci_cmd_clk_get_match_freq()
1508 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_cmd_clk_get_match_freq()
1512 resp = (struct ti_sci_msg_resp_query_clock_freq *)xfer->xfer_buf; in ti_sci_cmd_clk_get_match_freq()
1515 ret = -ENODEV; in ti_sci_cmd_clk_get_match_freq()
1517 *match_freq = resp->freq_hz; in ti_sci_cmd_clk_get_match_freq()
1520 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_clk_get_match_freq()
1526 * ti_sci_cmd_clk_set_freq() - Set a frequency for clock
1527 * @handle: pointer to TI SCI handle
1551 struct device *dev; in ti_sci_cmd_clk_set_freq() local
1557 return -EINVAL; in ti_sci_cmd_clk_set_freq()
1560 dev = info->dev; in ti_sci_cmd_clk_set_freq()
1567 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_cmd_clk_set_freq()
1570 req = (struct ti_sci_msg_req_set_clock_freq *)xfer->xfer_buf; in ti_sci_cmd_clk_set_freq()
1571 req->dev_id = dev_id; in ti_sci_cmd_clk_set_freq()
1573 req->clk_id = clk_id; in ti_sci_cmd_clk_set_freq()
1575 req->clk_id = 255; in ti_sci_cmd_clk_set_freq()
1576 req->clk_id_32 = clk_id; in ti_sci_cmd_clk_set_freq()
1578 req->min_freq_hz = min_freq; in ti_sci_cmd_clk_set_freq()
1579 req->target_freq_hz = target_freq; in ti_sci_cmd_clk_set_freq()
1580 req->max_freq_hz = max_freq; in ti_sci_cmd_clk_set_freq()
1584 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_cmd_clk_set_freq()
1588 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_cmd_clk_set_freq()
1590 ret = ti_sci_is_response_ack(resp) ? 0 : -ENODEV; in ti_sci_cmd_clk_set_freq()
1593 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_clk_set_freq()
1599 * ti_sci_cmd_clk_get_freq() - Get current frequency
1600 * @handle: pointer to TI SCI handle
1616 struct device *dev; in ti_sci_cmd_clk_get_freq() local
1622 return -EINVAL; in ti_sci_cmd_clk_get_freq()
1625 dev = info->dev; in ti_sci_cmd_clk_get_freq()
1632 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_cmd_clk_get_freq()
1635 req = (struct ti_sci_msg_req_get_clock_freq *)xfer->xfer_buf; in ti_sci_cmd_clk_get_freq()
1636 req->dev_id = dev_id; in ti_sci_cmd_clk_get_freq()
1638 req->clk_id = clk_id; in ti_sci_cmd_clk_get_freq()
1640 req->clk_id = 255; in ti_sci_cmd_clk_get_freq()
1641 req->clk_id_32 = clk_id; in ti_sci_cmd_clk_get_freq()
1646 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_cmd_clk_get_freq()
1650 resp = (struct ti_sci_msg_resp_get_clock_freq *)xfer->xfer_buf; in ti_sci_cmd_clk_get_freq()
1653 ret = -ENODEV; in ti_sci_cmd_clk_get_freq()
1655 *freq = resp->freq_hz; in ti_sci_cmd_clk_get_freq()
1658 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_clk_get_freq()
1664 * ti_sci_cmd_prepare_sleep() - Prepare system for system suspend
1665 * @handle: pointer to TI SCI handle
1683 struct device *dev; in ti_sci_cmd_prepare_sleep() local
1689 return -EINVAL; in ti_sci_cmd_prepare_sleep()
1692 dev = info->dev; in ti_sci_cmd_prepare_sleep()
1699 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_cmd_prepare_sleep()
1703 req = (struct ti_sci_msg_req_prepare_sleep *)xfer->xfer_buf; in ti_sci_cmd_prepare_sleep()
1704 req->mode = mode; in ti_sci_cmd_prepare_sleep()
1705 req->ctx_lo = ctx_lo; in ti_sci_cmd_prepare_sleep()
1706 req->ctx_hi = ctx_hi; in ti_sci_cmd_prepare_sleep()
1707 req->debug_flags = debug_flags; in ti_sci_cmd_prepare_sleep()
1711 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_cmd_prepare_sleep()
1716 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_cmd_prepare_sleep()
1718 dev_err(dev, "Failed to prepare sleep\n"); in ti_sci_cmd_prepare_sleep()
1719 ret = -ENODEV; in ti_sci_cmd_prepare_sleep()
1724 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_prepare_sleep()
1730 * ti_sci_msg_cmd_query_fw_caps() - Get the FW/SoC capabilities
1731 * @handle: Pointer to TI SCI handle
1736 * -ENODEV being returned.
1746 struct device *dev; in ti_sci_msg_cmd_query_fw_caps() local
1752 return -EINVAL; in ti_sci_msg_cmd_query_fw_caps()
1755 dev = info->dev; in ti_sci_msg_cmd_query_fw_caps()
1763 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_msg_cmd_query_fw_caps()
1769 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_msg_cmd_query_fw_caps()
1773 resp = (struct ti_sci_msg_resp_query_fw_caps *)xfer->xfer_buf; in ti_sci_msg_cmd_query_fw_caps()
1776 dev_err(dev, "Failed to get capabilities\n"); in ti_sci_msg_cmd_query_fw_caps()
1777 ret = -ENODEV; in ti_sci_msg_cmd_query_fw_caps()
1782 *fw_caps = resp->fw_caps; in ti_sci_msg_cmd_query_fw_caps()
1785 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_msg_cmd_query_fw_caps()
1791 * ti_sci_cmd_set_io_isolation() - Enable IO isolation in LPM
1792 * @handle: Pointer to TI SCI handle
1804 struct device *dev; in ti_sci_cmd_set_io_isolation() local
1810 return -EINVAL; in ti_sci_cmd_set_io_isolation()
1813 dev = info->dev; in ti_sci_cmd_set_io_isolation()
1820 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_cmd_set_io_isolation()
1823 req = (struct ti_sci_msg_req_set_io_isolation *)xfer->xfer_buf; in ti_sci_cmd_set_io_isolation()
1824 req->state = state; in ti_sci_cmd_set_io_isolation()
1828 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_cmd_set_io_isolation()
1832 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_cmd_set_io_isolation()
1835 dev_err(dev, "Failed to set IO isolation\n"); in ti_sci_cmd_set_io_isolation()
1836 ret = -ENODEV; in ti_sci_cmd_set_io_isolation()
1840 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_set_io_isolation()
1846 * ti_sci_msg_cmd_lpm_wake_reason() - Get the wakeup source from LPM
1847 * @handle: Pointer to TI SCI handle
1861 struct device *dev; in ti_sci_msg_cmd_lpm_wake_reason() local
1867 return -EINVAL; in ti_sci_msg_cmd_lpm_wake_reason()
1870 dev = info->dev; in ti_sci_msg_cmd_lpm_wake_reason()
1878 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_msg_cmd_lpm_wake_reason()
1884 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_msg_cmd_lpm_wake_reason()
1888 resp = (struct ti_sci_msg_resp_lpm_wake_reason *)xfer->xfer_buf; in ti_sci_msg_cmd_lpm_wake_reason()
1891 dev_err(dev, "Failed to get wake reason\n"); in ti_sci_msg_cmd_lpm_wake_reason()
1892 ret = -ENODEV; in ti_sci_msg_cmd_lpm_wake_reason()
1897 *source = resp->wake_source; in ti_sci_msg_cmd_lpm_wake_reason()
1899 *timestamp = resp->wake_timestamp; in ti_sci_msg_cmd_lpm_wake_reason()
1901 *pin = resp->wake_pin; in ti_sci_msg_cmd_lpm_wake_reason()
1903 *mode = resp->mode; in ti_sci_msg_cmd_lpm_wake_reason()
1906 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_msg_cmd_lpm_wake_reason()
1912 * ti_sci_cmd_set_device_constraint() - Set LPM constraint on behalf of a device
1913 * @handle: pointer to TI SCI handle
1914 * @id: Device identifier
1920 u32 id, u8 state) in ti_sci_cmd_set_device_constraint() argument
1926 struct device *dev; in ti_sci_cmd_set_device_constraint() local
1932 return -EINVAL; in ti_sci_cmd_set_device_constraint()
1935 dev = info->dev; in ti_sci_cmd_set_device_constraint()
1942 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_cmd_set_device_constraint()
1945 req = (struct ti_sci_msg_req_lpm_set_device_constraint *)xfer->xfer_buf; in ti_sci_cmd_set_device_constraint()
1946 req->id = id; in ti_sci_cmd_set_device_constraint()
1947 req->state = state; in ti_sci_cmd_set_device_constraint()
1951 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_cmd_set_device_constraint()
1955 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_cmd_set_device_constraint()
1958 dev_err(dev, "Failed to set device constraint\n"); in ti_sci_cmd_set_device_constraint()
1959 ret = -ENODEV; in ti_sci_cmd_set_device_constraint()
1963 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_set_device_constraint()
1969 * ti_sci_cmd_set_latency_constraint() - Set LPM resume latency constraint
1970 * @handle: pointer to TI SCI handle
1983 struct device *dev; in ti_sci_cmd_set_latency_constraint() local
1989 return -EINVAL; in ti_sci_cmd_set_latency_constraint()
1992 dev = info->dev; in ti_sci_cmd_set_latency_constraint()
1999 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_cmd_set_latency_constraint()
2002 req = (struct ti_sci_msg_req_lpm_set_latency_constraint *)xfer->xfer_buf; in ti_sci_cmd_set_latency_constraint()
2003 req->latency = latency; in ti_sci_cmd_set_latency_constraint()
2004 req->state = state; in ti_sci_cmd_set_latency_constraint()
2008 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_cmd_set_latency_constraint()
2012 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_cmd_set_latency_constraint()
2015 dev_err(dev, "Failed to set device constraint\n"); in ti_sci_cmd_set_latency_constraint()
2016 ret = -ENODEV; in ti_sci_cmd_set_latency_constraint()
2020 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_set_latency_constraint()
2026 * ti_sci_cmd_lpm_abort() - Abort entry to LPM by clearing selection of LPM to enter
2027 * @dev: Device pointer corresponding to the SCI entity
2031 static int ti_sci_cmd_lpm_abort(struct device *dev) in ti_sci_cmd_lpm_abort() argument
2033 struct ti_sci_info *info = dev_get_drvdata(dev); in ti_sci_cmd_lpm_abort()
2044 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_cmd_lpm_abort()
2047 req = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_cmd_lpm_abort()
2051 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_cmd_lpm_abort()
2055 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_cmd_lpm_abort()
2058 ret = -ENODEV; in ti_sci_cmd_lpm_abort()
2061 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_lpm_abort()
2072 struct device *dev; in ti_sci_cmd_core_reboot() local
2078 return -EINVAL; in ti_sci_cmd_core_reboot()
2081 dev = info->dev; in ti_sci_cmd_core_reboot()
2088 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_cmd_core_reboot()
2091 req = (struct ti_sci_msg_req_reboot *)xfer->xfer_buf; in ti_sci_cmd_core_reboot()
2095 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_cmd_core_reboot()
2099 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_cmd_core_reboot()
2102 ret = -ENODEV; in ti_sci_cmd_core_reboot()
2107 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_core_reboot()
2113 * ti_sci_get_resource_range - Helper to get a range of resources assigned
2117 * @dev_id: TISCI device ID.
2120 * @s_host: Host processor ID to which the resources are allocated
2134 struct device *dev; in ti_sci_get_resource_range() local
2140 return -EINVAL; in ti_sci_get_resource_range()
2143 dev = info->dev; in ti_sci_get_resource_range()
2150 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_get_resource_range()
2154 req = (struct ti_sci_msg_req_get_resource_range *)xfer->xfer_buf; in ti_sci_get_resource_range()
2155 req->secondary_host = s_host; in ti_sci_get_resource_range()
2156 req->type = dev_id & MSG_RM_RESOURCE_TYPE_MASK; in ti_sci_get_resource_range()
2157 req->subtype = subtype & MSG_RM_RESOURCE_SUBTYPE_MASK; in ti_sci_get_resource_range()
2161 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_get_resource_range()
2165 resp = (struct ti_sci_msg_resp_get_resource_range *)xfer->xfer_buf; in ti_sci_get_resource_range()
2168 ret = -ENODEV; in ti_sci_get_resource_range()
2169 } else if (!resp->range_num && !resp->range_num_sec) { in ti_sci_get_resource_range()
2171 ret = -ENODEV; in ti_sci_get_resource_range()
2173 desc->start = resp->range_start; in ti_sci_get_resource_range()
2174 desc->num = resp->range_num; in ti_sci_get_resource_range()
2175 desc->start_sec = resp->range_start_sec; in ti_sci_get_resource_range()
2176 desc->num_sec = resp->range_num_sec; in ti_sci_get_resource_range()
2180 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_get_resource_range()
2186 * ti_sci_cmd_get_resource_range - Get a range of resources assigned to host
2187 * that is same as ti sci interface host.
2189 * @dev_id: TISCI device ID.
2207 * ti_sci_cmd_get_resource_range_from_shost - Get a range of resources
2210 * @dev_id: TISCI device ID.
2213 * @s_host: Host processor ID to which the resources are allocated
2228 * ti_sci_manage_irq() - Helper api to configure/release the irq route between
2232 * @src_id: Device ID of the IRQ source
2234 * @dst_id: Device ID of the IRQ destination
2236 * @ia_id: Device ID of the IA, if the IRQ flows through this IA
2240 * @s_host: Secondary host ID to which the irq/event is being
2256 struct device *dev; in ti_sci_manage_irq() local
2262 return -EINVAL; in ti_sci_manage_irq()
2265 dev = info->dev; in ti_sci_manage_irq()
2271 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_manage_irq()
2274 req = (struct ti_sci_msg_req_manage_irq *)xfer->xfer_buf; in ti_sci_manage_irq()
2275 req->valid_params = valid_params; in ti_sci_manage_irq()
2276 req->src_id = src_id; in ti_sci_manage_irq()
2277 req->src_index = src_index; in ti_sci_manage_irq()
2278 req->dst_id = dst_id; in ti_sci_manage_irq()
2279 req->dst_host_irq = dst_host_irq; in ti_sci_manage_irq()
2280 req->ia_id = ia_id; in ti_sci_manage_irq()
2281 req->vint = vint; in ti_sci_manage_irq()
2282 req->global_event = global_event; in ti_sci_manage_irq()
2283 req->vint_status_bit = vint_status_bit; in ti_sci_manage_irq()
2284 req->secondary_host = s_host; in ti_sci_manage_irq()
2288 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_manage_irq()
2292 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_manage_irq()
2294 ret = ti_sci_is_response_ack(resp) ? 0 : -ENODEV; in ti_sci_manage_irq()
2297 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_manage_irq()
2303 * ti_sci_set_irq() - Helper api to configure the irq route between the
2307 * @src_id: Device ID of the IRQ source
2309 * @dst_id: Device ID of the IRQ destination
2311 * @ia_id: Device ID of the IA, if the IRQ flows through this IA
2315 * @s_host: Secondary host ID to which the irq/event is being
2337 * ti_sci_free_irq() - Helper api to free the irq route between the
2341 * @src_id: Device ID of the IRQ source
2343 * @dst_id: Device ID of the IRQ destination
2345 * @ia_id: Device ID of the IA, if the IRQ flows through this IA
2349 * @s_host: Secondary host ID to which the irq/event is being
2371 * ti_sci_cmd_set_irq() - Configure a host irq route between the requested
2374 * @src_id: Device ID of the IRQ source
2376 * @dst_id: Device ID of the IRQ destination
2391 * ti_sci_cmd_set_event_map() - Configure an event based irq route between the
2394 * @src_id: Device ID of the IRQ source
2396 * @ia_id: Device ID of the IA, if the IRQ flows through this IA
2417 * ti_sci_cmd_free_irq() - Free a host irq route between the between the
2420 * @src_id: Device ID of the IRQ source
2422 * @dst_id: Device ID of the IRQ destination
2437 * ti_sci_cmd_free_event_map() - Free an event map between the requested source
2440 * @src_id: Device ID of the IRQ source
2442 * @ia_id: Device ID of the IA, if the IRQ flows through this IA
2463 * ti_sci_cmd_rm_ring_cfg() - Configure a NAVSS ring
2464 * @handle: Pointer to TI SCI handle.
2479 struct device *dev; in ti_sci_cmd_rm_ring_cfg() local
2483 return -EINVAL; in ti_sci_cmd_rm_ring_cfg()
2486 dev = info->dev; in ti_sci_cmd_rm_ring_cfg()
2493 dev_err(dev, "RM_RA:Message config failed(%d)\n", ret); in ti_sci_cmd_rm_ring_cfg()
2496 req = (struct ti_sci_msg_rm_ring_cfg_req *)xfer->xfer_buf; in ti_sci_cmd_rm_ring_cfg()
2497 req->valid_params = params->valid_params; in ti_sci_cmd_rm_ring_cfg()
2498 req->nav_id = params->nav_id; in ti_sci_cmd_rm_ring_cfg()
2499 req->index = params->index; in ti_sci_cmd_rm_ring_cfg()
2500 req->addr_lo = params->addr_lo; in ti_sci_cmd_rm_ring_cfg()
2501 req->addr_hi = params->addr_hi; in ti_sci_cmd_rm_ring_cfg()
2502 req->count = params->count; in ti_sci_cmd_rm_ring_cfg()
2503 req->mode = params->mode; in ti_sci_cmd_rm_ring_cfg()
2504 req->size = params->size; in ti_sci_cmd_rm_ring_cfg()
2505 req->order_id = params->order_id; in ti_sci_cmd_rm_ring_cfg()
2506 req->virtid = params->virtid; in ti_sci_cmd_rm_ring_cfg()
2507 req->asel = params->asel; in ti_sci_cmd_rm_ring_cfg()
2511 dev_err(dev, "RM_RA:Mbox config send fail %d\n", ret); in ti_sci_cmd_rm_ring_cfg()
2515 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_cmd_rm_ring_cfg()
2516 ret = ti_sci_is_response_ack(resp) ? 0 : -EINVAL; in ti_sci_cmd_rm_ring_cfg()
2519 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_rm_ring_cfg()
2520 dev_dbg(dev, "RM_RA:config ring %u ret:%d\n", params->index, ret); in ti_sci_cmd_rm_ring_cfg()
2525 * ti_sci_cmd_rm_psil_pair() - Pair PSI-L source to destination thread
2526 * @handle: Pointer to TI SCI handle.
2527 * @nav_id: Device ID of Navigator Subsystem which should be used for
2529 * @src_thread: Source PSI-L thread ID
2530 * @dst_thread: Destination PSI-L thread ID
2541 struct device *dev; in ti_sci_cmd_rm_psil_pair() local
2547 return -EINVAL; in ti_sci_cmd_rm_psil_pair()
2550 dev = info->dev; in ti_sci_cmd_rm_psil_pair()
2557 dev_err(dev, "RM_PSIL:Message reconfig failed(%d)\n", ret); in ti_sci_cmd_rm_psil_pair()
2560 req = (struct ti_sci_msg_psil_pair *)xfer->xfer_buf; in ti_sci_cmd_rm_psil_pair()
2561 req->nav_id = nav_id; in ti_sci_cmd_rm_psil_pair()
2562 req->src_thread = src_thread; in ti_sci_cmd_rm_psil_pair()
2563 req->dst_thread = dst_thread; in ti_sci_cmd_rm_psil_pair()
2567 dev_err(dev, "RM_PSIL:Mbox send fail %d\n", ret); in ti_sci_cmd_rm_psil_pair()
2571 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_cmd_rm_psil_pair()
2572 ret = ti_sci_is_response_ack(resp) ? 0 : -EINVAL; in ti_sci_cmd_rm_psil_pair()
2575 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_rm_psil_pair()
2581 * ti_sci_cmd_rm_psil_unpair() - Unpair PSI-L source from destination thread
2582 * @handle: Pointer to TI SCI handle.
2583 * @nav_id: Device ID of Navigator Subsystem which should be used for
2585 * @src_thread: Source PSI-L thread ID
2586 * @dst_thread: Destination PSI-L thread ID
2597 struct device *dev; in ti_sci_cmd_rm_psil_unpair() local
2603 return -EINVAL; in ti_sci_cmd_rm_psil_unpair()
2606 dev = info->dev; in ti_sci_cmd_rm_psil_unpair()
2613 dev_err(dev, "RM_PSIL:Message reconfig failed(%d)\n", ret); in ti_sci_cmd_rm_psil_unpair()
2616 req = (struct ti_sci_msg_psil_unpair *)xfer->xfer_buf; in ti_sci_cmd_rm_psil_unpair()
2617 req->nav_id = nav_id; in ti_sci_cmd_rm_psil_unpair()
2618 req->src_thread = src_thread; in ti_sci_cmd_rm_psil_unpair()
2619 req->dst_thread = dst_thread; in ti_sci_cmd_rm_psil_unpair()
2623 dev_err(dev, "RM_PSIL:Mbox send fail %d\n", ret); in ti_sci_cmd_rm_psil_unpair()
2627 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_cmd_rm_psil_unpair()
2628 ret = ti_sci_is_response_ack(resp) ? 0 : -EINVAL; in ti_sci_cmd_rm_psil_unpair()
2631 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_rm_psil_unpair()
2637 * ti_sci_cmd_rm_udmap_tx_ch_cfg() - Configure a UDMAP TX channel
2638 * @handle: Pointer to TI SCI handle.
2654 struct device *dev; in ti_sci_cmd_rm_udmap_tx_ch_cfg() local
2658 return -EINVAL; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2661 dev = info->dev; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2668 dev_err(dev, "Message TX_CH_CFG alloc failed(%d)\n", ret); in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2671 req = (struct ti_sci_msg_rm_udmap_tx_ch_cfg_req *)xfer->xfer_buf; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2672 req->valid_params = params->valid_params; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2673 req->nav_id = params->nav_id; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2674 req->index = params->index; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2675 req->tx_pause_on_err = params->tx_pause_on_err; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2676 req->tx_filt_einfo = params->tx_filt_einfo; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2677 req->tx_filt_pswords = params->tx_filt_pswords; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2678 req->tx_atype = params->tx_atype; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2679 req->tx_chan_type = params->tx_chan_type; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2680 req->tx_supr_tdpkt = params->tx_supr_tdpkt; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2681 req->tx_fetch_size = params->tx_fetch_size; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2682 req->tx_credit_count = params->tx_credit_count; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2683 req->txcq_qnum = params->txcq_qnum; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2684 req->tx_priority = params->tx_priority; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2685 req->tx_qos = params->tx_qos; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2686 req->tx_orderid = params->tx_orderid; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2687 req->fdepth = params->fdepth; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2688 req->tx_sched_priority = params->tx_sched_priority; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2689 req->tx_burst_size = params->tx_burst_size; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2690 req->tx_tdtype = params->tx_tdtype; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2691 req->extended_ch_type = params->extended_ch_type; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2695 dev_err(dev, "Mbox send TX_CH_CFG fail %d\n", ret); in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2699 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2700 ret = ti_sci_is_response_ack(resp) ? 0 : -EINVAL; in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2703 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2704 dev_dbg(dev, "TX_CH_CFG: chn %u ret:%u\n", params->index, ret); in ti_sci_cmd_rm_udmap_tx_ch_cfg()
2709 * ti_sci_cmd_rm_udmap_rx_ch_cfg() - Configure a UDMAP RX channel
2710 * @handle: Pointer to TI SCI handle.
2726 struct device *dev; in ti_sci_cmd_rm_udmap_rx_ch_cfg() local
2730 return -EINVAL; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2733 dev = info->dev; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2740 dev_err(dev, "Message RX_CH_CFG alloc failed(%d)\n", ret); in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2743 req = (struct ti_sci_msg_rm_udmap_rx_ch_cfg_req *)xfer->xfer_buf; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2744 req->valid_params = params->valid_params; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2745 req->nav_id = params->nav_id; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2746 req->index = params->index; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2747 req->rx_fetch_size = params->rx_fetch_size; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2748 req->rxcq_qnum = params->rxcq_qnum; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2749 req->rx_priority = params->rx_priority; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2750 req->rx_qos = params->rx_qos; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2751 req->rx_orderid = params->rx_orderid; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2752 req->rx_sched_priority = params->rx_sched_priority; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2753 req->flowid_start = params->flowid_start; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2754 req->flowid_cnt = params->flowid_cnt; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2755 req->rx_pause_on_err = params->rx_pause_on_err; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2756 req->rx_atype = params->rx_atype; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2757 req->rx_chan_type = params->rx_chan_type; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2758 req->rx_ignore_short = params->rx_ignore_short; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2759 req->rx_ignore_long = params->rx_ignore_long; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2760 req->rx_burst_size = params->rx_burst_size; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2764 dev_err(dev, "Mbox send RX_CH_CFG fail %d\n", ret); in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2768 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2769 ret = ti_sci_is_response_ack(resp) ? 0 : -EINVAL; in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2772 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2773 dev_dbg(dev, "RX_CH_CFG: chn %u ret:%d\n", params->index, ret); in ti_sci_cmd_rm_udmap_rx_ch_cfg()
2778 * ti_sci_cmd_rm_udmap_rx_flow_cfg() - Configure UDMAP RX FLOW
2779 * @handle: Pointer to TI SCI handle.
2795 struct device *dev; in ti_sci_cmd_rm_udmap_rx_flow_cfg() local
2799 return -EINVAL; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2802 dev = info->dev; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2809 dev_err(dev, "RX_FL_CFG: Message alloc failed(%d)\n", ret); in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2812 req = (struct ti_sci_msg_rm_udmap_flow_cfg_req *)xfer->xfer_buf; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2813 req->valid_params = params->valid_params; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2814 req->nav_id = params->nav_id; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2815 req->flow_index = params->flow_index; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2816 req->rx_einfo_present = params->rx_einfo_present; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2817 req->rx_psinfo_present = params->rx_psinfo_present; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2818 req->rx_error_handling = params->rx_error_handling; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2819 req->rx_desc_type = params->rx_desc_type; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2820 req->rx_sop_offset = params->rx_sop_offset; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2821 req->rx_dest_qnum = params->rx_dest_qnum; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2822 req->rx_src_tag_hi = params->rx_src_tag_hi; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2823 req->rx_src_tag_lo = params->rx_src_tag_lo; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2824 req->rx_dest_tag_hi = params->rx_dest_tag_hi; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2825 req->rx_dest_tag_lo = params->rx_dest_tag_lo; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2826 req->rx_src_tag_hi_sel = params->rx_src_tag_hi_sel; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2827 req->rx_src_tag_lo_sel = params->rx_src_tag_lo_sel; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2828 req->rx_dest_tag_hi_sel = params->rx_dest_tag_hi_sel; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2829 req->rx_dest_tag_lo_sel = params->rx_dest_tag_lo_sel; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2830 req->rx_fdq0_sz0_qnum = params->rx_fdq0_sz0_qnum; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2831 req->rx_fdq1_qnum = params->rx_fdq1_qnum; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2832 req->rx_fdq2_qnum = params->rx_fdq2_qnum; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2833 req->rx_fdq3_qnum = params->rx_fdq3_qnum; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2834 req->rx_ps_location = params->rx_ps_location; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2838 dev_err(dev, "RX_FL_CFG: Mbox send fail %d\n", ret); in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2842 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2843 ret = ti_sci_is_response_ack(resp) ? 0 : -EINVAL; in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2846 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2847 dev_dbg(info->dev, "RX_FL_CFG: %u ret:%d\n", params->flow_index, ret); in ti_sci_cmd_rm_udmap_rx_flow_cfg()
2852 * ti_sci_cmd_proc_request() - Command to request a physical processor control
2853 * @handle: Pointer to TI SCI handle
2854 * @proc_id: Processor ID this request is for
2865 struct device *dev; in ti_sci_cmd_proc_request() local
2869 return -EINVAL; in ti_sci_cmd_proc_request()
2874 dev = info->dev; in ti_sci_cmd_proc_request()
2881 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_cmd_proc_request()
2884 req = (struct ti_sci_msg_req_proc_request *)xfer->xfer_buf; in ti_sci_cmd_proc_request()
2885 req->processor_id = proc_id; in ti_sci_cmd_proc_request()
2889 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_cmd_proc_request()
2893 resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf; in ti_sci_cmd_proc_request()
2895 ret = ti_sci_is_response_ack(resp) ? 0 : -ENODEV; in ti_sci_cmd_proc_request()
2898 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_proc_request()
2904 * ti_sci_cmd_proc_release() - Command to release a physical processor control
2905 * @handle: Pointer to TI SCI handle
2906 * @proc_id: Processor ID this request is for
2917 struct device *dev; in ti_sci_cmd_proc_release() local
2921 return -EINVAL; in ti_sci_cmd_proc_release()
2926 dev = info->dev; in ti_sci_cmd_proc_release()
2933 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_cmd_proc_release()
2936 req = (struct ti_sci_msg_req_proc_release *)xfer->xfer_buf; in ti_sci_cmd_proc_release()
2937 req->processor_id = proc_id; in ti_sci_cmd_proc_release()
2941 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_cmd_proc_release()
2945 resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf; in ti_sci_cmd_proc_release()
2947 ret = ti_sci_is_response_ack(resp) ? 0 : -ENODEV; in ti_sci_cmd_proc_release()
2950 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_proc_release()
2956 * ti_sci_cmd_proc_handover() - Command to handover a physical processor
2959 * @handle: Pointer to TI SCI handle
2960 * @proc_id: Processor ID this request is for
2961 * @host_id: Host ID to get the control of the processor
2972 struct device *dev; in ti_sci_cmd_proc_handover() local
2976 return -EINVAL; in ti_sci_cmd_proc_handover()
2981 dev = info->dev; in ti_sci_cmd_proc_handover()
2988 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_cmd_proc_handover()
2991 req = (struct ti_sci_msg_req_proc_handover *)xfer->xfer_buf; in ti_sci_cmd_proc_handover()
2992 req->processor_id = proc_id; in ti_sci_cmd_proc_handover()
2993 req->host_id = host_id; in ti_sci_cmd_proc_handover()
2997 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_cmd_proc_handover()
3001 resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf; in ti_sci_cmd_proc_handover()
3003 ret = ti_sci_is_response_ack(resp) ? 0 : -ENODEV; in ti_sci_cmd_proc_handover()
3006 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_proc_handover()
3012 * ti_sci_cmd_proc_set_config() - Command to set the processor boot
3014 * @handle: Pointer to TI SCI handle
3015 * @proc_id: Processor ID this request is for
3031 struct device *dev; in ti_sci_cmd_proc_set_config() local
3035 return -EINVAL; in ti_sci_cmd_proc_set_config()
3040 dev = info->dev; in ti_sci_cmd_proc_set_config()
3047 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_cmd_proc_set_config()
3050 req = (struct ti_sci_msg_req_set_config *)xfer->xfer_buf; in ti_sci_cmd_proc_set_config()
3051 req->processor_id = proc_id; in ti_sci_cmd_proc_set_config()
3052 req->bootvector_low = bootvector & TI_SCI_ADDR_LOW_MASK; in ti_sci_cmd_proc_set_config()
3053 req->bootvector_high = (bootvector & TI_SCI_ADDR_HIGH_MASK) >> in ti_sci_cmd_proc_set_config()
3055 req->config_flags_set = config_flags_set; in ti_sci_cmd_proc_set_config()
3056 req->config_flags_clear = config_flags_clear; in ti_sci_cmd_proc_set_config()
3060 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_cmd_proc_set_config()
3064 resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf; in ti_sci_cmd_proc_set_config()
3066 ret = ti_sci_is_response_ack(resp) ? 0 : -ENODEV; in ti_sci_cmd_proc_set_config()
3069 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_proc_set_config()
3075 * ti_sci_cmd_proc_set_control() - Command to set the processor boot
3077 * @handle: Pointer to TI SCI handle
3078 * @proc_id: Processor ID this request is for
3092 struct device *dev; in ti_sci_cmd_proc_set_control() local
3096 return -EINVAL; in ti_sci_cmd_proc_set_control()
3101 dev = info->dev; in ti_sci_cmd_proc_set_control()
3108 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_cmd_proc_set_control()
3111 req = (struct ti_sci_msg_req_set_ctrl *)xfer->xfer_buf; in ti_sci_cmd_proc_set_control()
3112 req->processor_id = proc_id; in ti_sci_cmd_proc_set_control()
3113 req->control_flags_set = control_flags_set; in ti_sci_cmd_proc_set_control()
3114 req->control_flags_clear = control_flags_clear; in ti_sci_cmd_proc_set_control()
3118 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_cmd_proc_set_control()
3122 resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf; in ti_sci_cmd_proc_set_control()
3124 ret = ti_sci_is_response_ack(resp) ? 0 : -ENODEV; in ti_sci_cmd_proc_set_control()
3127 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_proc_set_control()
3133 * ti_sci_cmd_proc_get_status() - Command to get the processor boot status
3134 * @handle: Pointer to TI SCI handle
3135 * @proc_id: Processor ID this request is for
3151 struct device *dev; in ti_sci_cmd_proc_get_status() local
3155 return -EINVAL; in ti_sci_cmd_proc_get_status()
3160 dev = info->dev; in ti_sci_cmd_proc_get_status()
3167 dev_err(dev, "Message alloc failed(%d)\n", ret); in ti_sci_cmd_proc_get_status()
3170 req = (struct ti_sci_msg_req_get_status *)xfer->xfer_buf; in ti_sci_cmd_proc_get_status()
3171 req->processor_id = proc_id; in ti_sci_cmd_proc_get_status()
3175 dev_err(dev, "Mbox send fail %d\n", ret); in ti_sci_cmd_proc_get_status()
3179 resp = (struct ti_sci_msg_resp_get_status *)xfer->tx_message.buf; in ti_sci_cmd_proc_get_status()
3182 ret = -ENODEV; in ti_sci_cmd_proc_get_status()
3184 *bv = (resp->bootvector_low & TI_SCI_ADDR_LOW_MASK) | in ti_sci_cmd_proc_get_status()
3185 (((u64)resp->bootvector_high << TI_SCI_ADDR_HIGH_SHIFT) & in ti_sci_cmd_proc_get_status()
3187 *cfg_flags = resp->config_flags; in ti_sci_cmd_proc_get_status()
3188 *ctrl_flags = resp->control_flags; in ti_sci_cmd_proc_get_status()
3189 *sts_flags = resp->status_flags; in ti_sci_cmd_proc_get_status()
3193 ti_sci_put_one_xfer(&info->minfo, xfer); in ti_sci_cmd_proc_get_status()
3199 * ti_sci_setup_ops() - Setup the operations structures
3204 struct ti_sci_ops *ops = &info->handle.ops; in ti_sci_setup_ops()
3205 struct ti_sci_core_ops *core_ops = &ops->core_ops; in ti_sci_setup_ops()
3206 struct ti_sci_dev_ops *dops = &ops->dev_ops; in ti_sci_setup_ops()
3207 struct ti_sci_clk_ops *cops = &ops->clk_ops; in ti_sci_setup_ops()
3208 struct ti_sci_pm_ops *pmops = &ops->pm_ops; in ti_sci_setup_ops()
3209 struct ti_sci_rm_core_ops *rm_core_ops = &ops->rm_core_ops; in ti_sci_setup_ops()
3210 struct ti_sci_rm_irq_ops *iops = &ops->rm_irq_ops; in ti_sci_setup_ops()
3211 struct ti_sci_rm_ringacc_ops *rops = &ops->rm_ring_ops; in ti_sci_setup_ops()
3212 struct ti_sci_rm_psil_ops *psilops = &ops->rm_psil_ops; in ti_sci_setup_ops()
3213 struct ti_sci_rm_udmap_ops *udmap_ops = &ops->rm_udmap_ops; in ti_sci_setup_ops()
3214 struct ti_sci_proc_ops *pops = &ops->proc_ops; in ti_sci_setup_ops()
3216 core_ops->reboot_device = ti_sci_cmd_core_reboot; in ti_sci_setup_ops()
3218 dops->get_device = ti_sci_cmd_get_device; in ti_sci_setup_ops()
3219 dops->get_device_exclusive = ti_sci_cmd_get_device_exclusive; in ti_sci_setup_ops()
3220 dops->idle_device = ti_sci_cmd_idle_device; in ti_sci_setup_ops()
3221 dops->idle_device_exclusive = ti_sci_cmd_idle_device_exclusive; in ti_sci_setup_ops()
3222 dops->put_device = ti_sci_cmd_put_device; in ti_sci_setup_ops()
3224 dops->is_valid = ti_sci_cmd_dev_is_valid; in ti_sci_setup_ops()
3225 dops->get_context_loss_count = ti_sci_cmd_dev_get_clcnt; in ti_sci_setup_ops()
3226 dops->is_idle = ti_sci_cmd_dev_is_idle; in ti_sci_setup_ops()
3227 dops->is_stop = ti_sci_cmd_dev_is_stop; in ti_sci_setup_ops()
3228 dops->is_on = ti_sci_cmd_dev_is_on; in ti_sci_setup_ops()
3229 dops->is_transitioning = ti_sci_cmd_dev_is_trans; in ti_sci_setup_ops()
3230 dops->set_device_resets = ti_sci_cmd_set_device_resets; in ti_sci_setup_ops()
3231 dops->get_device_resets = ti_sci_cmd_get_device_resets; in ti_sci_setup_ops()
3233 cops->get_clock = ti_sci_cmd_get_clock; in ti_sci_setup_ops()
3234 cops->idle_clock = ti_sci_cmd_idle_clock; in ti_sci_setup_ops()
3235 cops->put_clock = ti_sci_cmd_put_clock; in ti_sci_setup_ops()
3236 cops->is_auto = ti_sci_cmd_clk_is_auto; in ti_sci_setup_ops()
3237 cops->is_on = ti_sci_cmd_clk_is_on; in ti_sci_setup_ops()
3238 cops->is_off = ti_sci_cmd_clk_is_off; in ti_sci_setup_ops()
3240 cops->set_parent = ti_sci_cmd_clk_set_parent; in ti_sci_setup_ops()
3241 cops->get_parent = ti_sci_cmd_clk_get_parent; in ti_sci_setup_ops()
3242 cops->get_num_parents = ti_sci_cmd_clk_get_num_parents; in ti_sci_setup_ops()
3244 cops->get_best_match_freq = ti_sci_cmd_clk_get_match_freq; in ti_sci_setup_ops()
3245 cops->set_freq = ti_sci_cmd_clk_set_freq; in ti_sci_setup_ops()
3246 cops->get_freq = ti_sci_cmd_clk_get_freq; in ti_sci_setup_ops()
3248 if (info->fw_caps & MSG_FLAG_CAPS_LPM_DM_MANAGED) { in ti_sci_setup_ops()
3250 pmops->lpm_wake_reason = ti_sci_msg_cmd_lpm_wake_reason; in ti_sci_setup_ops()
3251 pmops->set_device_constraint = ti_sci_cmd_set_device_constraint; in ti_sci_setup_ops()
3252 pmops->set_latency_constraint = ti_sci_cmd_set_latency_constraint; in ti_sci_setup_ops()
3255 rm_core_ops->get_range = ti_sci_cmd_get_resource_range; in ti_sci_setup_ops()
3256 rm_core_ops->get_range_from_shost = in ti_sci_setup_ops()
3259 iops->set_irq = ti_sci_cmd_set_irq; in ti_sci_setup_ops()
3260 iops->set_event_map = ti_sci_cmd_set_event_map; in ti_sci_setup_ops()
3261 iops->free_irq = ti_sci_cmd_free_irq; in ti_sci_setup_ops()
3262 iops->free_event_map = ti_sci_cmd_free_event_map; in ti_sci_setup_ops()
3264 rops->set_cfg = ti_sci_cmd_rm_ring_cfg; in ti_sci_setup_ops()
3266 psilops->pair = ti_sci_cmd_rm_psil_pair; in ti_sci_setup_ops()
3267 psilops->unpair = ti_sci_cmd_rm_psil_unpair; in ti_sci_setup_ops()
3269 udmap_ops->tx_ch_cfg = ti_sci_cmd_rm_udmap_tx_ch_cfg; in ti_sci_setup_ops()
3270 udmap_ops->rx_ch_cfg = ti_sci_cmd_rm_udmap_rx_ch_cfg; in ti_sci_setup_ops()
3271 udmap_ops->rx_flow_cfg = ti_sci_cmd_rm_udmap_rx_flow_cfg; in ti_sci_setup_ops()
3273 pops->request = ti_sci_cmd_proc_request; in ti_sci_setup_ops()
3274 pops->release = ti_sci_cmd_proc_release; in ti_sci_setup_ops()
3275 pops->handover = ti_sci_cmd_proc_handover; in ti_sci_setup_ops()
3276 pops->set_config = ti_sci_cmd_proc_set_config; in ti_sci_setup_ops()
3277 pops->set_control = ti_sci_cmd_proc_set_control; in ti_sci_setup_ops()
3278 pops->get_status = ti_sci_cmd_proc_get_status; in ti_sci_setup_ops()
3282 * ti_sci_get_handle() - Get the TI SCI handle for a device
3283 * @dev: Pointer to device for which we want SCI handle
3286 * and is expected to be maintained by caller of TI SCI protocol library.
3289 * -EPROBE_DEFER if the instance is not ready
3290 * -ENODEV if the required node handler is missing
3291 * -EINVAL if invalid conditions are encountered.
3293 const struct ti_sci_handle *ti_sci_get_handle(struct device *dev) in ti_sci_get_handle() argument
3299 if (!dev) { in ti_sci_get_handle()
3301 return ERR_PTR(-EINVAL); in ti_sci_get_handle()
3303 ti_sci_np = of_get_parent(dev->of_node); in ti_sci_get_handle()
3305 dev_err(dev, "No OF information\n"); in ti_sci_get_handle()
3306 return ERR_PTR(-EINVAL); in ti_sci_get_handle()
3311 if (ti_sci_np == info->dev->of_node) { in ti_sci_get_handle()
3312 handle = &info->handle; in ti_sci_get_handle()
3313 info->users++; in ti_sci_get_handle()
3321 return ERR_PTR(-EPROBE_DEFER); in ti_sci_get_handle()
3328 * ti_sci_put_handle() - Release the handle acquired by ti_sci_get_handle
3332 * and is expected to be maintained by caller of TI SCI protocol library.
3337 * if null was passed, it returns -EINVAL;
3346 return -EINVAL; in ti_sci_put_handle()
3350 if (!WARN_ON(!info->users)) in ti_sci_put_handle()
3351 info->users--; in ti_sci_put_handle()
3358 static void devm_ti_sci_release(struct device *dev, void *res) in devm_ti_sci_release() argument
3366 dev_err(dev, "failed to put handle %d\n", ret); in devm_ti_sci_release()
3370 * devm_ti_sci_get_handle() - Managed get handle
3371 * @dev: device for which we want SCI handle for.
3376 * and is expected to be maintained by caller of TI SCI protocol library.
3380 const struct ti_sci_handle *devm_ti_sci_get_handle(struct device *dev) in devm_ti_sci_get_handle() argument
3387 return ERR_PTR(-ENOMEM); in devm_ti_sci_get_handle()
3388 handle = ti_sci_get_handle(dev); in devm_ti_sci_get_handle()
3392 devres_add(dev, ptr); in devm_ti_sci_get_handle()
3402 * ti_sci_get_by_phandle() - Get the TI SCI handle using DT phandle
3407 * and is expected to be maintained by caller of TI SCI protocol library.
3410 * -EPROBE_DEFER if the instance is not ready
3411 * -ENODEV if the required node handler is missing
3412 * -EINVAL if invalid conditions are encountered.
3423 return ERR_PTR(-EINVAL); in ti_sci_get_by_phandle()
3428 return ERR_PTR(-ENODEV); in ti_sci_get_by_phandle()
3432 if (ti_sci_np == info->dev->of_node) { in ti_sci_get_by_phandle()
3433 handle = &info->handle; in ti_sci_get_by_phandle()
3434 info->users++; in ti_sci_get_by_phandle()
3442 return ERR_PTR(-EPROBE_DEFER); in ti_sci_get_by_phandle()
3449 * devm_ti_sci_get_by_phandle() - Managed get handle using phandle
3450 * @dev: Device pointer requesting TISCI handle
3456 * and is expected to be maintained by caller of TI SCI protocol library.
3460 const struct ti_sci_handle *devm_ti_sci_get_by_phandle(struct device *dev, in devm_ti_sci_get_by_phandle() argument
3468 return ERR_PTR(-ENOMEM); in devm_ti_sci_get_by_phandle()
3469 handle = ti_sci_get_by_phandle(dev_of_node(dev), property); in devm_ti_sci_get_by_phandle()
3473 devres_add(dev, ptr); in devm_ti_sci_get_by_phandle()
3483 * ti_sci_get_free_resource() - Get a free resource from TISCI resource.
3493 raw_spin_lock_irqsave(&res->lock, flags); in ti_sci_get_free_resource()
3494 for (set = 0; set < res->sets; set++) { in ti_sci_get_free_resource()
3495 struct ti_sci_resource_desc *desc = &res->desc[set]; in ti_sci_get_free_resource()
3496 int res_count = desc->num + desc->num_sec; in ti_sci_get_free_resource()
3498 free_bit = find_first_zero_bit(desc->res_map, res_count); in ti_sci_get_free_resource()
3500 __set_bit(free_bit, desc->res_map); in ti_sci_get_free_resource()
3501 raw_spin_unlock_irqrestore(&res->lock, flags); in ti_sci_get_free_resource()
3503 if (desc->num && free_bit < desc->num) in ti_sci_get_free_resource()
3504 return desc->start + free_bit; in ti_sci_get_free_resource()
3506 return desc->start_sec + free_bit; in ti_sci_get_free_resource()
3509 raw_spin_unlock_irqrestore(&res->lock, flags); in ti_sci_get_free_resource()
3516 * ti_sci_release_resource() - Release a resource from TISCI resource.
3518 * @id: Resource id to be released.
3520 void ti_sci_release_resource(struct ti_sci_resource *res, u16 id) in ti_sci_release_resource() argument
3525 raw_spin_lock_irqsave(&res->lock, flags); in ti_sci_release_resource()
3526 for (set = 0; set < res->sets; set++) { in ti_sci_release_resource()
3527 struct ti_sci_resource_desc *desc = &res->desc[set]; in ti_sci_release_resource()
3529 if (desc->num && desc->start <= id && in ti_sci_release_resource()
3530 (desc->start + desc->num) > id) in ti_sci_release_resource()
3531 __clear_bit(id - desc->start, desc->res_map); in ti_sci_release_resource()
3532 else if (desc->num_sec && desc->start_sec <= id && in ti_sci_release_resource()
3533 (desc->start_sec + desc->num_sec) > id) in ti_sci_release_resource()
3534 __clear_bit(id - desc->start_sec, desc->res_map); in ti_sci_release_resource()
3536 raw_spin_unlock_irqrestore(&res->lock, flags); in ti_sci_release_resource()
3541 * ti_sci_get_num_resources() - Get the number of resources in TISCI resource
3550 for (set = 0; set < res->sets; set++) in ti_sci_get_num_resources()
3551 count += res->desc[set].num + res->desc[set].num_sec; in ti_sci_get_num_resources()
3558 * devm_ti_sci_get_resource_sets() - Get a TISCI resources assigned to a device
3560 * @dev: Device pointer to which the resource is assigned
3561 * @dev_id: TISCI device id to which the resource is assigned
3570 struct device *dev, u32 dev_id, u32 *sub_types, in devm_ti_sci_get_resource_sets() argument
3577 res = devm_kzalloc(dev, sizeof(*res), GFP_KERNEL); in devm_ti_sci_get_resource_sets()
3579 return ERR_PTR(-ENOMEM); in devm_ti_sci_get_resource_sets()
3581 res->sets = sets; in devm_ti_sci_get_resource_sets()
3582 res->desc = devm_kcalloc(dev, res->sets, sizeof(*res->desc), in devm_ti_sci_get_resource_sets()
3584 if (!res->desc) in devm_ti_sci_get_resource_sets()
3585 return ERR_PTR(-ENOMEM); in devm_ti_sci_get_resource_sets()
3587 for (i = 0; i < res->sets; i++) { in devm_ti_sci_get_resource_sets()
3588 ret = handle->ops.rm_core_ops.get_range(handle, dev_id, in devm_ti_sci_get_resource_sets()
3590 &res->desc[i]); in devm_ti_sci_get_resource_sets()
3592 dev_dbg(dev, "dev = %d subtype %d not allocated for this host\n", in devm_ti_sci_get_resource_sets()
3594 memset(&res->desc[i], 0, sizeof(res->desc[i])); in devm_ti_sci_get_resource_sets()
3598 dev_dbg(dev, "dev/sub_type: %d/%d, start/num: %d/%d | %d/%d\n", in devm_ti_sci_get_resource_sets()
3599 dev_id, sub_types[i], res->desc[i].start, in devm_ti_sci_get_resource_sets()
3600 res->desc[i].num, res->desc[i].start_sec, in devm_ti_sci_get_resource_sets()
3601 res->desc[i].num_sec); in devm_ti_sci_get_resource_sets()
3604 res_count = res->desc[i].num + res->desc[i].num_sec; in devm_ti_sci_get_resource_sets()
3605 res->desc[i].res_map = devm_bitmap_zalloc(dev, res_count, in devm_ti_sci_get_resource_sets()
3607 if (!res->desc[i].res_map) in devm_ti_sci_get_resource_sets()
3608 return ERR_PTR(-ENOMEM); in devm_ti_sci_get_resource_sets()
3610 raw_spin_lock_init(&res->lock); in devm_ti_sci_get_resource_sets()
3615 return ERR_PTR(-EINVAL); in devm_ti_sci_get_resource_sets()
3619 * devm_ti_sci_get_of_resource() - Get a TISCI resource assigned to a device
3621 * @dev: Device pointer to which the resource is assigned
3622 * @dev_id: TISCI device id to which the resource is assigned
3630 struct device *dev, u32 dev_id, char *of_prop) in devm_ti_sci_get_of_resource() argument
3636 sets = of_property_count_elems_of_size(dev_of_node(dev), of_prop, in devm_ti_sci_get_of_resource()
3639 dev_err(dev, "%s resource type ids not available\n", of_prop); in devm_ti_sci_get_of_resource()
3645 return ERR_PTR(-ENOMEM); in devm_ti_sci_get_of_resource()
3647 of_property_read_u32_array(dev_of_node(dev), of_prop, sub_types, sets); in devm_ti_sci_get_of_resource()
3648 res = devm_ti_sci_get_resource_sets(handle, dev, dev_id, sub_types, in devm_ti_sci_get_of_resource()
3657 * devm_ti_sci_get_resource() - Get a resource range assigned to the device
3659 * @dev: Device pointer to which the resource is assigned
3660 * @dev_id: TISCI device id to which the resource is assigned
3667 devm_ti_sci_get_resource(const struct ti_sci_handle *handle, struct device *dev, in devm_ti_sci_get_resource() argument
3670 return devm_ti_sci_get_resource_sets(handle, dev, dev_id, &sub_type, 1); in devm_ti_sci_get_resource()
3675 * Iterate all device nodes that have a wakeup-source property and check if one
3676 * of the possible phandles points to a Partial-IO system state. If it
3684 for_each_node_with_property(wakeup_node, "wakeup-source") { in ti_sci_partial_io_wakeup_enabled()
3688 of_for_each_phandle(&it, err, wakeup_node, "wakeup-source", NULL, 0) { in ti_sci_partial_io_wakeup_enabled()
3693 * Continue if idle-state-name is not off-wake. Return in ti_sci_partial_io_wakeup_enabled()
3695 * off-wake is present. in ti_sci_partial_io_wakeup_enabled()
3697 if (of_property_match_string(it.node, "idle-state-name", "off-wake")) in ti_sci_partial_io_wakeup_enabled()
3704 may_wakeup = device_may_wakeup(&pdev->dev); in ti_sci_partial_io_wakeup_enabled()
3705 put_device(&pdev->dev); in ti_sci_partial_io_wakeup_enabled()
3708 dev_dbg(info->dev, "%pOF identified as wakeup source for Partial-IO\n", in ti_sci_partial_io_wakeup_enabled()
3722 struct ti_sci_info *info = data->cb_data; in ti_sci_sys_off_handler()
3723 const struct ti_sci_handle *handle = &info->handle; in ti_sci_sys_off_handler()
3730 dev_info(info->dev, "Entering Partial-IO because a powered wakeup-enabled device was found.\n"); in ti_sci_sys_off_handler()
3734 dev_err(info->dev, in ti_sci_sys_off_handler()
3735 "Failed to enter Partial-IO %pe, trying to do an emergency restart\n", in ti_sci_sys_off_handler()
3748 struct ti_sci_info *info = data->cb_data; in tisci_reboot_handler()
3749 const struct ti_sci_handle *handle = &info->handle; in tisci_reboot_handler()
3765 if (info->fw_caps & MSG_FLAG_CAPS_LPM_DM_MANAGED) { in ti_sci_prepare_system_suspend()
3770 return ti_sci_cmd_prepare_sleep(&info->handle, in ti_sci_prepare_system_suspend()
3775 dev_err(info->dev, "Suspend to memory is not supported by the firmware\n"); in ti_sci_prepare_system_suspend()
3776 return -EOPNOTSUPP; in ti_sci_prepare_system_suspend()
3788 static int ti_sci_suspend(struct device *dev) in ti_sci_suspend() argument
3790 struct ti_sci_info *info = dev_get_drvdata(dev); in ti_sci_suspend()
3796 if (info->fw_caps & MSG_FLAG_CAPS_LPM_DM_MANAGED) { in ti_sci_suspend()
3813 ret = ti_sci_cmd_set_latency_constraint(&info->handle, in ti_sci_suspend()
3828 static int ti_sci_suspend_noirq(struct device *dev) in ti_sci_suspend_noirq() argument
3830 struct ti_sci_info *info = dev_get_drvdata(dev); in ti_sci_suspend_noirq()
3833 if (info->fw_caps & MSG_FLAG_CAPS_IO_ISOLATION) { in ti_sci_suspend_noirq()
3834 ret = ti_sci_cmd_set_io_isolation(&info->handle, TISCI_MSG_VALUE_IO_ENABLE); in ti_sci_suspend_noirq()
3842 static int ti_sci_resume_noirq(struct device *dev) in ti_sci_resume_noirq() argument
3844 struct ti_sci_info *info = dev_get_drvdata(dev); in ti_sci_resume_noirq()
3851 if (info->fw_caps & MSG_FLAG_CAPS_IO_ISOLATION) { in ti_sci_resume_noirq()
3852 ret = ti_sci_cmd_set_io_isolation(&info->handle, TISCI_MSG_VALUE_IO_DISABLE); in ti_sci_resume_noirq()
3857 ret = ti_sci_msg_cmd_lpm_wake_reason(&info->handle, &source, &time, &pin, &mode); in ti_sci_resume_noirq()
3860 dev_info(dev, "ti_sci: wakeup source:0x%x, pin:0x%x, mode:0x%x\n", in ti_sci_resume_noirq()
3866 static void ti_sci_pm_complete(struct device *dev) in ti_sci_pm_complete() argument
3868 struct ti_sci_info *info = dev_get_drvdata(dev); in ti_sci_pm_complete()
3870 if (info->fw_caps & MSG_FLAG_CAPS_LPM_ABORT) { in ti_sci_pm_complete()
3871 if (ti_sci_cmd_lpm_abort(dev)) in ti_sci_pm_complete()
3872 dev_err(dev, "LPM clear selection failed.\n"); in ti_sci_pm_complete()
3904 {.compatible = "ti,k2g-sci", .data = &ti_sci_pmmc_k2g_desc},
3905 {.compatible = "ti,am654-sci", .data = &ti_sci_pmmc_am654_desc},
3912 struct device *dev = &pdev->dev; in ti_sci_probe() local
3918 int ret = -EINVAL; in ti_sci_probe()
3922 desc = device_get_match_data(dev); in ti_sci_probe()
3924 info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL); in ti_sci_probe()
3926 return -ENOMEM; in ti_sci_probe()
3928 info->dev = dev; in ti_sci_probe()
3929 info->desc = desc; in ti_sci_probe()
3930 ret = of_property_read_u32(dev->of_node, "ti,host-id", &h_id); in ti_sci_probe()
3933 info->host_id = info->desc->default_host_id; in ti_sci_probe()
3936 dev_warn(dev, "Host ID 0 is reserved for firmware\n"); in ti_sci_probe()
3937 info->host_id = info->desc->default_host_id; in ti_sci_probe()
3939 info->host_id = h_id; in ti_sci_probe()
3943 INIT_LIST_HEAD(&info->node); in ti_sci_probe()
3944 minfo = &info->minfo; in ti_sci_probe()
3947 * Pre-allocate messages in ti_sci_probe()
3951 if (WARN_ON(desc->max_msgs >= in ti_sci_probe()
3952 1 << 8 * sizeof(((struct ti_sci_msg_hdr *)0)->seq))) in ti_sci_probe()
3953 return -EINVAL; in ti_sci_probe()
3955 minfo->xfer_block = devm_kcalloc(dev, in ti_sci_probe()
3956 desc->max_msgs, in ti_sci_probe()
3957 sizeof(*minfo->xfer_block), in ti_sci_probe()
3959 if (!minfo->xfer_block) in ti_sci_probe()
3960 return -ENOMEM; in ti_sci_probe()
3962 minfo->xfer_alloc_table = devm_bitmap_zalloc(dev, in ti_sci_probe()
3963 desc->max_msgs, in ti_sci_probe()
3965 if (!minfo->xfer_alloc_table) in ti_sci_probe()
3966 return -ENOMEM; in ti_sci_probe()
3968 /* Pre-initialize the buffer pointer to pre-allocated buffers */ in ti_sci_probe()
3969 for (i = 0, xfer = minfo->xfer_block; i < desc->max_msgs; i++, xfer++) { in ti_sci_probe()
3970 xfer->xfer_buf = devm_kcalloc(dev, 1, desc->max_msg_size, in ti_sci_probe()
3972 if (!xfer->xfer_buf) in ti_sci_probe()
3973 return -ENOMEM; in ti_sci_probe()
3975 xfer->tx_message.buf = xfer->xfer_buf; in ti_sci_probe()
3976 init_completion(&xfer->done); in ti_sci_probe()
3981 dev_warn(dev, "Failed to create debug file\n"); in ti_sci_probe()
3985 cl = &info->cl; in ti_sci_probe()
3986 cl->dev = dev; in ti_sci_probe()
3987 cl->tx_block = false; in ti_sci_probe()
3988 cl->rx_callback = ti_sci_rx_callback; in ti_sci_probe()
3989 cl->knows_txdone = true; in ti_sci_probe()
3991 spin_lock_init(&minfo->xfer_lock); in ti_sci_probe()
3992 sema_init(&minfo->sem_xfer_count, desc->max_msgs); in ti_sci_probe()
3994 info->chan_rx = mbox_request_channel_byname(cl, "rx"); in ti_sci_probe()
3995 if (IS_ERR(info->chan_rx)) { in ti_sci_probe()
3996 ret = PTR_ERR(info->chan_rx); in ti_sci_probe()
4000 info->chan_tx = mbox_request_channel_byname(cl, "tx"); in ti_sci_probe()
4001 if (IS_ERR(info->chan_tx)) { in ti_sci_probe()
4002 ret = PTR_ERR(info->chan_tx); in ti_sci_probe()
4007 dev_err(dev, "Unable to communicate with TISCI(%d)\n", ret); in ti_sci_probe()
4011 ti_sci_msg_cmd_query_fw_caps(&info->handle, &info->fw_caps); in ti_sci_probe()
4012 dev_dbg(dev, "Detected firmware capabilities: %s%s%s%s%s\n", in ti_sci_probe()
4013 info->fw_caps & MSG_FLAG_CAPS_GENERIC ? "Generic" : "", in ti_sci_probe()
4014 info->fw_caps & MSG_FLAG_CAPS_LPM_PARTIAL_IO ? " Partial-IO" : "", in ti_sci_probe()
4015 info->fw_caps & MSG_FLAG_CAPS_LPM_DM_MANAGED ? " DM-Managed" : "", in ti_sci_probe()
4016 info->fw_caps & MSG_FLAG_CAPS_LPM_ABORT ? " LPM-Abort" : "", in ti_sci_probe()
4017 info->fw_caps & MSG_FLAG_CAPS_IO_ISOLATION ? " IO-Isolation" : "" in ti_sci_probe()
4022 ret = devm_register_restart_handler(dev, tisci_reboot_handler, info); in ti_sci_probe()
4024 dev_err(dev, "reboot registration fail(%d)\n", ret); in ti_sci_probe()
4028 if (info->fw_caps & MSG_FLAG_CAPS_LPM_PARTIAL_IO) { in ti_sci_probe()
4029 ret = devm_register_sys_off_handler(dev, in ti_sci_probe()
4035 dev_err(dev, "Failed to register sys_off_handler %pe\n", in ti_sci_probe()
4041 dev_info(dev, "ABI: %d.%d (firmware rev 0x%04x '%s')\n", in ti_sci_probe()
4042 info->handle.version.abi_major, info->handle.version.abi_minor, in ti_sci_probe()
4043 info->handle.version.firmware_revision, in ti_sci_probe()
4044 info->handle.version.firmware_description); in ti_sci_probe()
4047 list_add_tail(&info->node, &ti_sci_list); in ti_sci_probe()
4050 ret = of_platform_populate(dev->of_node, NULL, NULL, dev); in ti_sci_probe()
4052 dev_err(dev, "platform_populate failed %pe\n", ERR_PTR(ret)); in ti_sci_probe()
4058 if (!IS_ERR(info->chan_tx)) in ti_sci_probe()
4059 mbox_free_channel(info->chan_tx); in ti_sci_probe()
4060 if (!IS_ERR(info->chan_rx)) in ti_sci_probe()
4061 mbox_free_channel(info->chan_rx); in ti_sci_probe()
4062 debugfs_remove(info->d); in ti_sci_probe()
4069 .name = "ti-sci",
4078 MODULE_DESCRIPTION("TI System Control Interface(SCI) driver");
4080 MODULE_ALIAS("platform:ti-sci");