aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNishanth Menon <nm@ti.com>2016-10-18 19:08:35 -0400
committerTero Kristo <t-kristo@ti.com>2016-10-27 05:09:11 -0400
commit9e7d756da7a5b0cc756d1f512f3eaf261834180a (patch)
tree94cd5d3a94ec8890813623a9b0d6a2620f3fa99a
parentaa276781a64a5f15ecc21e920960c5b1f84e5fee (diff)
firmware: ti_sci: Add support for Device control
Texas Instrument's System Control Interface (TI-SCI) Message Protocol is used in Texas Instrument's System on Chip (SoC) such as those in keystone family K2G SoC to communicate between various compute processors with a central system controller entity. TI-SCI message protocol provides support for management of various hardware entitites within the SoC. Add support driver to allow communication with system controller entity within the SoC using the mailbox client. We introduce the fundamental device management capability support to the driver protocol as part of this change. [d-gerlach@ti.com: Contributed device reset handling] Signed-off-by: Dave Gerlach <d-gerlach@ti.com> Signed-off-by: Nishanth Menon <nm@ti.com> Signed-off-by: Tero Kristo <t-kristo@ti.com>
-rw-r--r--drivers/firmware/ti_sci.c433
-rw-r--r--drivers/firmware/ti_sci.h98
-rw-r--r--include/linux/soc/ti/ti_sci_protocol.h91
3 files changed, 622 insertions, 0 deletions
diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c
index 5e99d7c18276..c7b25ccf6f07 100644
--- a/drivers/firmware/ti_sci.c
+++ b/drivers/firmware/ti_sci.c
@@ -495,6 +495,437 @@ fail:
495} 495}
496 496
497/** 497/**
498 * ti_sci_is_response_ack() - Generic ACK/NACK message checkup
499 * @r: pointer to response buffer
500 *
501 * Return: true if the response was an ACK, else returns false.
502 */
503static inline bool ti_sci_is_response_ack(void *r)
504{
505 struct ti_sci_msg_hdr *hdr = r;
506
507 return hdr->flags & TI_SCI_FLAG_RESP_GENERIC_ACK ? true : false;
508}
509
510/**
511 * ti_sci_set_device_state() - Set device state helper
512 * @handle: pointer to TI SCI handle
513 * @id: Device identifier
514 * @flags: flags to setup for the device
515 * @state: State to move the device to
516 *
517 * Return: 0 if all went well, else returns appropriate error value.
518 */
519static int ti_sci_set_device_state(const struct ti_sci_handle *handle,
520 u32 id, u32 flags, u8 state)
521{
522 struct ti_sci_info *info;
523 struct ti_sci_msg_req_set_device_state *req;
524 struct ti_sci_msg_hdr *resp;
525 struct ti_sci_xfer *xfer;
526 struct device *dev;
527 int ret = 0;
528
529 if (IS_ERR(handle))
530 return PTR_ERR(handle);
531 if (!handle)
532 return -EINVAL;
533
534 info = handle_to_ti_sci_info(handle);
535 dev = info->dev;
536
537 xfer = ti_sci_get_one_xfer(info, TI_SCI_MSG_SET_DEVICE_STATE,
538 flags | TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
539 sizeof(*req), sizeof(*resp));
540 if (IS_ERR(xfer)) {
541 ret = PTR_ERR(xfer);
542 dev_err(dev, "Message alloc failed(%d)\n", ret);
543 return ret;
544 }
545 req = (struct ti_sci_msg_req_set_device_state *)xfer->xfer_buf;
546 req->id = id;
547 req->state = state;
548
549 ret = ti_sci_do_xfer(info, xfer);
550 if (ret) {
551 dev_err(dev, "Mbox send fail %d\n", ret);
552 goto fail;
553 }
554
555 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf;
556
557 ret = ti_sci_is_response_ack(resp) ? 0 : -ENODEV;
558
559fail:
560 ti_sci_put_one_xfer(&info->minfo, xfer);
561
562 return ret;
563}
564
565/**
566 * ti_sci_get_device_state() - Get device state helper
567 * @handle: Handle to the device
568 * @id: Device Identifier
569 * @clcnt: Pointer to Context Loss Count
570 * @resets: pointer to resets
571 * @p_state: pointer to p_state
572 * @c_state: pointer to c_state
573 *
574 * Return: 0 if all went fine, else return appropriate error.
575 */
576static int ti_sci_get_device_state(const struct ti_sci_handle *handle,
577 u32 id, u32 *clcnt, u32 *resets,
578 u8 *p_state, u8 *c_state)
579{
580 struct ti_sci_info *info;
581 struct ti_sci_msg_req_get_device_state *req;
582 struct ti_sci_msg_resp_get_device_state *resp;
583 struct ti_sci_xfer *xfer;
584 struct device *dev;
585 int ret = 0;
586
587 if (IS_ERR(handle))
588 return PTR_ERR(handle);
589 if (!handle)
590 return -EINVAL;
591
592 if (!clcnt && !resets && !p_state && !c_state)
593 return -EINVAL;
594
595 info = handle_to_ti_sci_info(handle);
596 dev = info->dev;
597
598 /* Response is expected, so need of any flags */
599 xfer = ti_sci_get_one_xfer(info, TI_SCI_MSG_GET_DEVICE_STATE,
600 0, sizeof(*req), sizeof(*resp));
601 if (IS_ERR(xfer)) {
602 ret = PTR_ERR(xfer);
603 dev_err(dev, "Message alloc failed(%d)\n", ret);
604 return ret;
605 }
606 req = (struct ti_sci_msg_req_get_device_state *)xfer->xfer_buf;
607 req->id = id;
608
609 ret = ti_sci_do_xfer(info, xfer);
610 if (ret) {
611 dev_err(dev, "Mbox send fail %d\n", ret);
612 goto fail;
613 }
614
615 resp = (struct ti_sci_msg_resp_get_device_state *)xfer->xfer_buf;
616 if (!ti_sci_is_response_ack(resp)) {
617 ret = -ENODEV;
618 goto fail;
619 }
620
621 if (clcnt)
622 *clcnt = resp->context_loss_count;
623 if (resets)
624 *resets = resp->resets;
625 if (p_state)
626 *p_state = resp->programmed_state;
627 if (c_state)
628 *c_state = resp->current_state;
629fail:
630 ti_sci_put_one_xfer(&info->minfo, xfer);
631
632 return ret;
633}
634
635/**
636 * ti_sci_cmd_get_device() - command to request for device managed by TISCI
637 * @handle: Pointer to TISCI handle as retrieved by *ti_sci_get_handle
638 * @id: Device Identifier
639 *
640 * Request for the device - NOTE: the client MUST maintain integrity of
641 * usage count by balancing get_device with put_device. No refcounting is
642 * managed by driver for that purpose.
643 *
644 * NOTE: The request is for exclusive access for the processor.
645 *
646 * Return: 0 if all went fine, else return appropriate error.
647 */
648static int ti_sci_cmd_get_device(const struct ti_sci_handle *handle, u32 id)
649{
650 return ti_sci_set_device_state(handle, id,
651 MSG_FLAG_DEVICE_EXCLUSIVE,
652 MSG_DEVICE_SW_STATE_ON);
653}
654
655/**
656 * ti_sci_cmd_idle_device() - Command to idle a device managed by TISCI
657 * @handle: Pointer to TISCI handle as retrieved by *ti_sci_get_handle
658 * @id: Device Identifier
659 *
660 * Request for the device - NOTE: the client MUST maintain integrity of
661 * usage count by balancing get_device with put_device. No refcounting is
662 * managed by driver for that purpose.
663 *
664 * Return: 0 if all went fine, else return appropriate error.
665 */
666static int ti_sci_cmd_idle_device(const struct ti_sci_handle *handle, u32 id)
667{
668 return ti_sci_set_device_state(handle, id,
669 MSG_FLAG_DEVICE_EXCLUSIVE,
670 MSG_DEVICE_SW_STATE_RETENTION);
671}
672
673/**
674 * ti_sci_cmd_put_device() - command to release a device managed by TISCI
675 * @handle: Pointer to TISCI handle as retrieved by *ti_sci_get_handle
676 * @id: Device Identifier
677 *
678 * Request for the device - NOTE: the client MUST maintain integrity of
679 * usage count by balancing get_device with put_device. No refcounting is
680 * managed by driver for that purpose.
681 *
682 * Return: 0 if all went fine, else return appropriate error.
683 */
684static int ti_sci_cmd_put_device(const struct ti_sci_handle *handle, u32 id)
685{
686 return ti_sci_set_device_state(handle, id,
687 0, MSG_DEVICE_SW_STATE_AUTO_OFF);
688}
689
690/**
691 * ti_sci_cmd_dev_is_valid() - Is the device valid
692 * @handle: Pointer to TISCI handle as retrieved by *ti_sci_get_handle
693 * @id: Device Identifier
694 *
695 * Return: 0 if all went fine and the device ID is valid, else return
696 * appropriate error.
697 */
698static int ti_sci_cmd_dev_is_valid(const struct ti_sci_handle *handle, u32 id)
699{
700 u8 unused;
701
702 /* check the device state which will also tell us if the ID is valid */
703 return ti_sci_get_device_state(handle, id, NULL, NULL, NULL, &unused);
704}
705
706/**
707 * ti_sci_cmd_dev_get_clcnt() - Get context loss counter
708 * @handle: Pointer to TISCI handle
709 * @id: Device Identifier
710 * @count: Pointer to Context Loss counter to populate
711 *
712 * Return: 0 if all went fine, else return appropriate error.
713 */
714static int ti_sci_cmd_dev_get_clcnt(const struct ti_sci_handle *handle, u32 id,
715 u32 *count)
716{
717 return ti_sci_get_device_state(handle, id, count, NULL, NULL, NULL);
718}
719
720/**
721 * ti_sci_cmd_dev_is_idle() - Check if the device is requested to be idle
722 * @handle: Pointer to TISCI handle
723 * @id: Device Identifier
724 * @r_state: true if requested to be idle
725 *
726 * Return: 0 if all went fine, else return appropriate error.
727 */
728static int ti_sci_cmd_dev_is_idle(const struct ti_sci_handle *handle, u32 id,
729 bool *r_state)
730{
731 int ret;
732 u8 state;
733
734 if (!r_state)
735 return -EINVAL;
736
737 ret = ti_sci_get_device_state(handle, id, NULL, NULL, &state, NULL);
738 if (ret)
739 return ret;
740
741 *r_state = (state == MSG_DEVICE_SW_STATE_RETENTION);
742
743 return 0;
744}
745
746/**
747 * ti_sci_cmd_dev_is_stop() - Check if the device is requested to be stopped
748 * @handle: Pointer to TISCI handle
749 * @id: Device Identifier
750 * @r_state: true if requested to be stopped
751 * @curr_state: true if currently stopped.
752 *
753 * Return: 0 if all went fine, else return appropriate error.
754 */
755static int ti_sci_cmd_dev_is_stop(const struct ti_sci_handle *handle, u32 id,
756 bool *r_state, bool *curr_state)
757{
758 int ret;
759 u8 p_state, c_state;
760
761 if (!r_state && !curr_state)
762 return -EINVAL;
763
764 ret =
765 ti_sci_get_device_state(handle, id, NULL, NULL, &p_state, &c_state);
766 if (ret)
767 return ret;
768
769 if (r_state)
770 *r_state = (p_state == MSG_DEVICE_SW_STATE_AUTO_OFF);
771 if (curr_state)
772 *curr_state = (c_state == MSG_DEVICE_HW_STATE_OFF);
773
774 return 0;
775}
776
777/**
778 * ti_sci_cmd_dev_is_on() - Check if the device is requested to be ON
779 * @handle: Pointer to TISCI handle
780 * @id: Device Identifier
781 * @r_state: true if requested to be ON
782 * @curr_state: true if currently ON and active
783 *
784 * Return: 0 if all went fine, else return appropriate error.
785 */
786static int ti_sci_cmd_dev_is_on(const struct ti_sci_handle *handle, u32 id,
787 bool *r_state, bool *curr_state)
788{
789 int ret;
790 u8 p_state, c_state;
791
792 if (!r_state && !curr_state)
793 return -EINVAL;
794
795 ret =
796 ti_sci_get_device_state(handle, id, NULL, NULL, &p_state, &c_state);
797 if (ret)
798 return ret;
799
800 if (r_state)
801 *r_state = (p_state == MSG_DEVICE_SW_STATE_ON);
802 if (curr_state)
803 *curr_state = (c_state == MSG_DEVICE_HW_STATE_ON);
804
805 return 0;
806}
807
808/**
809 * ti_sci_cmd_dev_is_trans() - Check if the device is currently transitioning
810 * @handle: Pointer to TISCI handle
811 * @id: Device Identifier
812 * @curr_state: true if currently transitioning.
813 *
814 * Return: 0 if all went fine, else return appropriate error.
815 */
816static int ti_sci_cmd_dev_is_trans(const struct ti_sci_handle *handle, u32 id,
817 bool *curr_state)
818{
819 int ret;
820 u8 state;
821
822 if (!curr_state)
823 return -EINVAL;
824
825 ret = ti_sci_get_device_state(handle, id, NULL, NULL, NULL, &state);
826 if (ret)
827 return ret;
828
829 *curr_state = (state == MSG_DEVICE_HW_STATE_TRANS);
830
831 return 0;
832}
833
834/**
835 * ti_sci_cmd_set_device_resets() - command to set resets for device managed
836 * by TISCI
837 * @handle: Pointer to TISCI handle as retrieved by *ti_sci_get_handle
838 * @id: Device Identifier
839 * @reset_state: Device specific reset bit field
840 *
841 * Return: 0 if all went fine, else return appropriate error.
842 */
843static int ti_sci_cmd_set_device_resets(const struct ti_sci_handle *handle,
844 u32 id, u32 reset_state)
845{
846 struct ti_sci_info *info;
847 struct ti_sci_msg_req_set_device_resets *req;
848 struct ti_sci_msg_hdr *resp;
849 struct ti_sci_xfer *xfer;
850 struct device *dev;
851 int ret = 0;
852
853 if (IS_ERR(handle))
854 return PTR_ERR(handle);
855 if (!handle)
856 return -EINVAL;
857
858 info = handle_to_ti_sci_info(handle);
859 dev = info->dev;
860
861 xfer = ti_sci_get_one_xfer(info, TI_SCI_MSG_SET_DEVICE_RESETS,
862 TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
863 sizeof(*req), sizeof(*resp));
864 if (IS_ERR(xfer)) {
865 ret = PTR_ERR(xfer);
866 dev_err(dev, "Message alloc failed(%d)\n", ret);
867 return ret;
868 }
869 req = (struct ti_sci_msg_req_set_device_resets *)xfer->xfer_buf;
870 req->id = id;
871 req->resets = reset_state;
872
873 ret = ti_sci_do_xfer(info, xfer);
874 if (ret) {
875 dev_err(dev, "Mbox send fail %d\n", ret);
876 goto fail;
877 }
878
879 resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf;
880
881 ret = ti_sci_is_response_ack(resp) ? 0 : -ENODEV;
882
883fail:
884 ti_sci_put_one_xfer(&info->minfo, xfer);
885
886 return ret;
887}
888
889/**
890 * ti_sci_cmd_get_device_resets() - Get reset state for device managed
891 * by TISCI
892 * @handle: Pointer to TISCI handle
893 * @id: Device Identifier
894 * @reset_state: Pointer to reset state to populate
895 *
896 * Return: 0 if all went fine, else return appropriate error.
897 */
898static int ti_sci_cmd_get_device_resets(const struct ti_sci_handle *handle,
899 u32 id, u32 *reset_state)
900{
901 return ti_sci_get_device_state(handle, id, NULL, reset_state, NULL,
902 NULL);
903}
904
905/*
906 * ti_sci_setup_ops() - Setup the operations structures
907 * @info: pointer to TISCI pointer
908 */
909static void ti_sci_setup_ops(struct ti_sci_info *info)
910{
911 struct ti_sci_ops *ops = &info->handle.ops;
912 struct ti_sci_dev_ops *dops = &ops->dev_ops;
913
914 dops->get_device = ti_sci_cmd_get_device;
915 dops->idle_device = ti_sci_cmd_idle_device;
916 dops->put_device = ti_sci_cmd_put_device;
917
918 dops->is_valid = ti_sci_cmd_dev_is_valid;
919 dops->get_context_loss_count = ti_sci_cmd_dev_get_clcnt;
920 dops->is_idle = ti_sci_cmd_dev_is_idle;
921 dops->is_stop = ti_sci_cmd_dev_is_stop;
922 dops->is_on = ti_sci_cmd_dev_is_on;
923 dops->is_transitioning = ti_sci_cmd_dev_is_trans;
924 dops->set_device_resets = ti_sci_cmd_set_device_resets;
925 dops->get_device_resets = ti_sci_cmd_get_device_resets;
926}
927
928/**
498 * ti_sci_get_handle() - Get the TI SCI handle for a device 929 * ti_sci_get_handle() - Get the TI SCI handle for a device
499 * @dev: Pointer to device for which we want SCI handle 930 * @dev: Pointer to device for which we want SCI handle
500 * 931 *
@@ -727,6 +1158,8 @@ static int ti_sci_probe(struct platform_device *pdev)
727 goto out; 1158 goto out;
728 } 1159 }
729 1160
1161 ti_sci_setup_ops(info);
1162
730 dev_info(dev, "ABI: %d.%d (firmware rev 0x%04x '%s')\n", 1163 dev_info(dev, "ABI: %d.%d (firmware rev 0x%04x '%s')\n",
731 info->handle.version.abi_major, info->handle.version.abi_minor, 1164 info->handle.version.abi_major, info->handle.version.abi_minor,
732 info->handle.version.firmware_revision, 1165 info->handle.version.firmware_revision,
diff --git a/drivers/firmware/ti_sci.h b/drivers/firmware/ti_sci.h
index e9dc53f26e0e..29ce0532a7ca 100644
--- a/drivers/firmware/ti_sci.h
+++ b/drivers/firmware/ti_sci.h
@@ -47,6 +47,11 @@
47#define TI_SCI_MSG_WAKE_REASON 0x0003 47#define TI_SCI_MSG_WAKE_REASON 0x0003
48#define TI_SCI_MSG_GOODBYE 0x0004 48#define TI_SCI_MSG_GOODBYE 0x0004
49 49
50/* Device requests */
51#define TI_SCI_MSG_SET_DEVICE_STATE 0x0200
52#define TI_SCI_MSG_GET_DEVICE_STATE 0x0201
53#define TI_SCI_MSG_SET_DEVICE_RESETS 0x0202
54
50/** 55/**
51 * struct ti_sci_msg_hdr - Generic Message Header for All messages and responses 56 * struct ti_sci_msg_hdr - Generic Message Header for All messages and responses
52 * @type: Type of messages: One of TI_SCI_MSG* values 57 * @type: Type of messages: One of TI_SCI_MSG* values
@@ -90,4 +95,97 @@ struct ti_sci_msg_resp_version {
90 u8 abi_minor; 95 u8 abi_minor;
91} __packed; 96} __packed;
92 97
98/**
99 * struct ti_sci_msg_req_set_device_state - Set the desired state of the device
100 * @hdr: Generic header
101 * @id: Indicates which device to modify
102 * @reserved: Reserved space in message, must be 0 for backward compatibility
103 * @state: The desired state of the device.
104 *
105 * Certain flags can also be set to alter the device state:
106 * + MSG_FLAG_DEVICE_WAKE_ENABLED - Configure the device to be a wake source.
107 * The meaning of this flag will vary slightly from device to device and from
108 * SoC to SoC but it generally allows the device to wake the SoC out of deep
109 * suspend states.
110 * + MSG_FLAG_DEVICE_RESET_ISO - Enable reset isolation for this device.
111 * + MSG_FLAG_DEVICE_EXCLUSIVE - Claim this device exclusively. When passed
112 * with STATE_RETENTION or STATE_ON, it will claim the device exclusively.
113 * If another host already has this device set to STATE_RETENTION or STATE_ON,
114 * the message will fail. Once successful, other hosts attempting to set
115 * STATE_RETENTION or STATE_ON will fail.
116 *
117 * Request type is TI_SCI_MSG_SET_DEVICE_STATE, responded with a generic
118 * ACK/NACK message.
119 */
120struct ti_sci_msg_req_set_device_state {
121 /* Additional hdr->flags options */
122#define MSG_FLAG_DEVICE_WAKE_ENABLED TI_SCI_MSG_FLAG(8)
123#define MSG_FLAG_DEVICE_RESET_ISO TI_SCI_MSG_FLAG(9)
124#define MSG_FLAG_DEVICE_EXCLUSIVE TI_SCI_MSG_FLAG(10)
125 struct ti_sci_msg_hdr hdr;
126 u32 id;
127 u32 reserved;
128
129#define MSG_DEVICE_SW_STATE_AUTO_OFF 0
130#define MSG_DEVICE_SW_STATE_RETENTION 1
131#define MSG_DEVICE_SW_STATE_ON 2
132 u8 state;
133} __packed;
134
135/**
136 * struct ti_sci_msg_req_get_device_state - Request to get device.
137 * @hdr: Generic header
138 * @id: Device Identifier
139 *
140 * Request type is TI_SCI_MSG_GET_DEVICE_STATE, responded device state
141 * information
142 */
143struct ti_sci_msg_req_get_device_state {
144 struct ti_sci_msg_hdr hdr;
145 u32 id;
146} __packed;
147
148/**
149 * struct ti_sci_msg_resp_get_device_state - Response to get device request.
150 * @hdr: Generic header
151 * @context_loss_count: Indicates how many times the device has lost context. A
152 * driver can use this monotonic counter to determine if the device has
153 * lost context since the last time this message was exchanged.
154 * @resets: Programmed state of the reset lines.
155 * @programmed_state: The state as programmed by set_device.
156 * - Uses the MSG_DEVICE_SW_* macros
157 * @current_state: The actual state of the hardware.
158 *
159 * Response to request TI_SCI_MSG_GET_DEVICE_STATE.
160 */
161struct ti_sci_msg_resp_get_device_state {
162 struct ti_sci_msg_hdr hdr;
163 u32 context_loss_count;
164 u32 resets;
165 u8 programmed_state;
166#define MSG_DEVICE_HW_STATE_OFF 0
167#define MSG_DEVICE_HW_STATE_ON 1
168#define MSG_DEVICE_HW_STATE_TRANS 2
169 u8 current_state;
170} __packed;
171
172/**
173 * struct ti_sci_msg_req_set_device_resets - Set the desired resets
174 * configuration of the device
175 * @hdr: Generic header
176 * @id: Indicates which device to modify
177 * @resets: A bit field of resets for the device. The meaning, behavior,
178 * and usage of the reset flags are device specific. 0 for a bit
179 * indicates releasing the reset represented by that bit while 1
180 * indicates keeping it held.
181 *
182 * Request type is TI_SCI_MSG_SET_DEVICE_RESETS, responded with a generic
183 * ACK/NACK message.
184 */
185struct ti_sci_msg_req_set_device_resets {
186 struct ti_sci_msg_hdr hdr;
187 u32 id;
188 u32 resets;
189} __packed;
190
93#endif /* __TI_SCI_H */ 191#endif /* __TI_SCI_H */
diff --git a/include/linux/soc/ti/ti_sci_protocol.h b/include/linux/soc/ti/ti_sci_protocol.h
index e73483fd5327..87fa73851471 100644
--- a/include/linux/soc/ti/ti_sci_protocol.h
+++ b/include/linux/soc/ti/ti_sci_protocol.h
@@ -33,12 +33,103 @@ struct ti_sci_version_info {
33 char firmware_description[32]; 33 char firmware_description[32];
34}; 34};
35 35
36struct ti_sci_handle;
37
38/**
39 * struct ti_sci_dev_ops - Device control operations
40 * @get_device: Command to request for device managed by TISCI
41 * Returns 0 for successful exclusive request, else returns
42 * corresponding error message.
43 * @idle_device: Command to idle a device managed by TISCI
44 * Returns 0 for successful exclusive request, else returns
45 * corresponding error message.
46 * @put_device: Command to release a device managed by TISCI
47 * Returns 0 for successful release, else returns corresponding
48 * error message.
49 * @is_valid: Check if the device ID is a valid ID.
50 * Returns 0 if the ID is valid, else returns corresponding error.
51 * @get_context_loss_count: Command to retrieve context loss counter - this
52 * increments every time the device looses context. Overflow
53 * is possible.
54 * - count: pointer to u32 which will retrieve counter
55 * Returns 0 for successful information request and count has
56 * proper data, else returns corresponding error message.
57 * @is_idle: Reports back about device idle state
58 * - req_state: Returns requested idle state
59 * Returns 0 for successful information request and req_state and
60 * current_state has proper data, else returns corresponding error
61 * message.
62 * @is_stop: Reports back about device stop state
63 * - req_state: Returns requested stop state
64 * - current_state: Returns current stop state
65 * Returns 0 for successful information request and req_state and
66 * current_state has proper data, else returns corresponding error
67 * message.
68 * @is_on: Reports back about device ON(or active) state
69 * - req_state: Returns requested ON state
70 * - current_state: Returns current ON state
71 * Returns 0 for successful information request and req_state and
72 * current_state has proper data, else returns corresponding error
73 * message.
74 * @is_transitioning: Reports back if the device is in the middle of transition
75 * of state.
76 * -current_state: Returns 'true' if currently transitioning.
77 * @set_device_resets: Command to configure resets for device managed by TISCI.
78 * -reset_state: Device specific reset bit field
79 * Returns 0 for successful request, else returns
80 * corresponding error message.
81 * @get_device_resets: Command to read state of resets for device managed
82 * by TISCI.
83 * -reset_state: pointer to u32 which will retrieve resets
84 * Returns 0 for successful request, else returns
85 * corresponding error message.
86 *
87 * NOTE: for all these functions, the following parameters are generic in
88 * nature:
89 * -handle: Pointer to TISCI handle as retrieved by *ti_sci_get_handle
90 * -id: Device Identifier
91 *
92 * Request for the device - NOTE: the client MUST maintain integrity of
93 * usage count by balancing get_device with put_device. No refcounting is
94 * managed by driver for that purpose.
95 */
96struct ti_sci_dev_ops {
97 int (*get_device)(const struct ti_sci_handle *handle, u32 id);
98 int (*idle_device)(const struct ti_sci_handle *handle, u32 id);
99 int (*put_device)(const struct ti_sci_handle *handle, u32 id);
100 int (*is_valid)(const struct ti_sci_handle *handle, u32 id);
101 int (*get_context_loss_count)(const struct ti_sci_handle *handle,
102 u32 id, u32 *count);
103 int (*is_idle)(const struct ti_sci_handle *handle, u32 id,
104 bool *requested_state);
105 int (*is_stop)(const struct ti_sci_handle *handle, u32 id,
106 bool *req_state, bool *current_state);
107 int (*is_on)(const struct ti_sci_handle *handle, u32 id,
108 bool *req_state, bool *current_state);
109 int (*is_transitioning)(const struct ti_sci_handle *handle, u32 id,
110 bool *current_state);
111 int (*set_device_resets)(const struct ti_sci_handle *handle, u32 id,
112 u32 reset_state);
113 int (*get_device_resets)(const struct ti_sci_handle *handle, u32 id,
114 u32 *reset_state);
115};
116
117/**
118 * struct ti_sci_ops - Function support for TI SCI
119 * @dev_ops: Device specific operations
120 */
121struct ti_sci_ops {
122 struct ti_sci_dev_ops dev_ops;
123};
124
36/** 125/**
37 * struct ti_sci_handle - Handle returned to TI SCI clients for usage. 126 * struct ti_sci_handle - Handle returned to TI SCI clients for usage.
38 * @version: structure containing version information 127 * @version: structure containing version information
128 * @ops: operations that are made available to TI SCI clients
39 */ 129 */
40struct ti_sci_handle { 130struct ti_sci_handle {
41 struct ti_sci_version_info version; 131 struct ti_sci_version_info version;
132 struct ti_sci_ops ops;
42}; 133};
43 134
44#if IS_ENABLED(CONFIG_TI_SCI_PROTOCOL) 135#if IS_ENABLED(CONFIG_TI_SCI_PROTOCOL)