]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - k3conf/k3conf.git/blob - include/tisci_protocol.h
soc: am65x: Add processors info
[k3conf/k3conf.git] / include / tisci_protocol.h
1 /*
2  * TISCI Protocol header file.
3  *
4  * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/
5  *      Lokesh Vutla <lokeshvutla@ti.com>
6  *
7  *  Redistribution and use in source and binary forms, with or without
8  *  modification, are permitted provided that the following conditions
9  *  are met:
10  *
11  *    Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  *
14  *    Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the
17  *    distribution.
18  *
19  *    Neither the name of Texas Instruments Incorporated nor the names of
20  *    its contributors may be used to endorse or promote products derived
21  *    from this software without specific prior written permission.
22  *
23  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26  *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27  *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28  *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29  *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30  *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31  *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32  *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33  *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34  */
36 #ifndef __TISCI_P_H
37 #define __TISCI_P_H
39 #include <stdint.h>
40 #include <sec_proxy.h>
42 #define TI_SCI_MSG_VERSION              0x0002
43 /* Device requests */
44 #define TI_SCI_MSG_SET_DEVICE_STATE     0x0200
45 #define TI_SCI_MSG_GET_DEVICE_STATE     0x0201
46 /* Clock requests */
47 #define TI_SCI_MSG_SET_CLOCK_STATE      0x0100
48 #define TI_SCI_MSG_GET_CLOCK_STATE      0x0101
49 #define TI_SCI_MSG_SET_CLOCK_FREQ       0x010c
50 #define TI_SCI_MSG_QUERY_CLOCK_FREQ     0x010d
51 #define TI_SCI_MSG_GET_CLOCK_FREQ       0x010e
53 #define TI_SCI_MSG_FLAG(val)                    (1 << (val))
54 #define TI_SCI_FLAG_REQ_GENERIC_NORESPONSE      0x0
55 #define TI_SCI_FLAG_REQ_ACK_ON_RECEIVED         TI_SCI_MSG_FLAG(0)
56 #define TI_SCI_FLAG_REQ_ACK_ON_PROCESSED        TI_SCI_MSG_FLAG(1)
57 #define TI_SCI_FLAG_RESP_GENERIC_NACK           0x0
58 #define TI_SCI_FLAG_RESP_GENERIC_ACK            TI_SCI_MSG_FLAG(1)
60 struct ti_sci_msg_hdr {
61         uint16_t type;
62         uint8_t host;
63         uint8_t seq;
64         uint32_t flags;
65 } __attribute__ ((__packed__));
67 struct ti_sci_msg_resp_version {
68         struct ti_sci_msg_hdr hdr;
69         char firmware_description[32];
70         uint16_t version;
71         uint8_t abi_major;
72         uint8_t abi_minor;
73 } __attribute__ ((__packed__));
75 struct ti_sci_secure_msg_hdr {
76         uint16_t checksum;
77         uint16_t reserved;
78 } __attribute__ ((__packed__));
80 struct ti_sci_msg_req_set_device_state {
81         /* Additional hdr->flags options */
82 #define MSG_FLAG_DEVICE_WAKE_ENABLED    TI_SCI_MSG_FLAG(8)
83 #define MSG_FLAG_DEVICE_RESET_ISO       TI_SCI_MSG_FLAG(9)
84 #define MSG_FLAG_DEVICE_EXCLUSIVE       TI_SCI_MSG_FLAG(10)
85         struct ti_sci_msg_hdr hdr;
86         uint32_t id;
87         uint32_t reserved;
88 #define MSG_DEVICE_SW_STATE_AUTO_OFF    0
89 #define MSG_DEVICE_SW_STATE_RETENTION   1
90 #define MSG_DEVICE_SW_STATE_ON          2
91         uint8_t state;
92 } __attribute__ ((__packed__));
94 struct ti_sci_msg_req_get_device_state {
95         struct ti_sci_msg_hdr hdr;
96         uint32_t id;
97 } __attribute__ ((__packed__));
99 struct ti_sci_msg_resp_get_device_state {
100         struct ti_sci_msg_hdr hdr;
101         uint32_t context_loss_count;
102         uint32_t resets;
103         uint8_t programmed_state;
104 #define MSG_DEVICE_HW_STATE_OFF         0
105 #define MSG_DEVICE_HW_STATE_ON          1
106 #define MSG_DEVICE_HW_STATE_TRANS       2
107 #define MAX_DEVICE_HW_STATES            3
108         uint8_t current_state;
109 } __attribute__ ((__packed__));
111 struct ti_sci_msg_req_set_clock_state {
112         /* Additional hdr->flags options */
113 #define MSG_FLAG_CLOCK_ALLOW_SSC                TI_SCI_MSG_FLAG(8)
114 #define MSG_FLAG_CLOCK_ALLOW_FREQ_CHANGE        TI_SCI_MSG_FLAG(9)
115 #define MSG_FLAG_CLOCK_INPUT_TERM               TI_SCI_MSG_FLAG(10)
116         struct ti_sci_msg_hdr hdr;
117         uint32_t dev_id;
118         uint8_t clk_id;
119 #define MSG_CLOCK_SW_STATE_UNREQ        0
120 #define MSG_CLOCK_SW_STATE_AUTO         1
121 #define MSG_CLOCK_SW_STATE_REQ          2
122         uint8_t request_state;
123         uint32_t clk_id_32;
124 } __attribute__ ((__packed__));
126 struct ti_sci_msg_req_get_clock_state {
127         struct ti_sci_msg_hdr hdr;
128         uint32_t dev_id;
129         uint8_t clk_id;
130         uint32_t clk_id_32;
131 } __attribute__ ((__packed__));
133 struct ti_sci_msg_resp_get_clock_state {
134         struct ti_sci_msg_hdr hdr;
135         uint8_t programmed_state;
136 #define MSG_CLOCK_HW_STATE_NOT_READY    0
137 #define MSG_CLOCK_HW_STATE_READY        1
138 #define MAX_CLOCK_HW_STATES             2
139         uint8_t current_state;
140 } __attribute__ ((__packed__));
142 struct ti_sci_msg_req_query_clock_freq {
143         struct ti_sci_msg_hdr hdr;
144         uint32_t dev_id;
145         uint64_t min_freq_hz;
146         uint64_t target_freq_hz;
147         uint64_t max_freq_hz;
148         uint8_t clk_id;
149         uint32_t clk_id_32;
150 } __attribute__ ((__packed__));
152 struct ti_sci_msg_resp_query_clock_freq {
153         struct ti_sci_msg_hdr hdr;
154         uint64_t freq_hz;
155 } __attribute__ ((__packed__));
157 struct ti_sci_msg_req_set_clock_freq {
158         struct ti_sci_msg_hdr hdr;
159         uint32_t dev_id;
160         uint64_t min_freq_hz;
161         uint64_t target_freq_hz;
162         uint64_t max_freq_hz;
163         uint8_t clk_id;
164         uint32_t clk_id_32;
165 } __attribute__ ((__packed__));
167 struct ti_sci_msg_req_get_clock_freq {
168         struct ti_sci_msg_hdr hdr;
169         uint32_t dev_id;
170         uint8_t clk_id;
171         uint32_t clk_id_32;
172 } __attribute__ ((__packed__));
174 struct ti_sci_msg_resp_get_clock_freq {
175         struct ti_sci_msg_hdr hdr;
176         uint64_t freq_hz;
177 } __attribute__ ((__packed__));
179 void ti_sci_setup_header(struct ti_sci_msg_hdr *hdr, uint16_t type,
180                          uint32_t flags);
181 int ti_sci_xfer_msg(struct k3_sec_proxy_msg *msg);
183 static inline uint8_t ti_sci_is_response_ack(uint8_t *resp)
185         struct ti_sci_msg_hdr *hdr = (struct ti_sci_msg_hdr *)resp;
187         return hdr->flags & TI_SCI_FLAG_RESP_GENERIC_ACK ? 1 : 0;
190 #endif