1 // SPDX-License-Identifier: BSD-3-Clause
3 * Texas Instruments System Control Interface (TISCI) Protocol
5 * Communication protocol with TI SCI hardware
6 * The system works in a message response protocol
7 * See: http://processors.wiki.ti.com/index.php/TISCI for details
9 * Copyright (C) 2015-2016 Texas Instruments Incorporated - http://www.ti.com/
15 /* Generic Messages */
16 #define TI_SCI_MSG_ENABLE_WDT 0x0000
17 #define TI_SCI_MSG_WAKE_RESET 0x0001
18 #define TI_SCI_MSG_VERSION 0x0002
19 #define TI_SCI_MSG_WAKE_REASON 0x0003
20 #define TI_SCI_MSG_GOODBYE 0x0004
21 #define TI_SCI_MSG_SYS_RESET 0x0005
24 #define TI_SCI_MSG_SET_DEVICE_STATE 0x0200
25 #define TI_SCI_MSG_GET_DEVICE_STATE 0x0201
26 #define TI_SCI_MSG_SET_DEVICE_RESETS 0x0202
29 #define TI_SCI_MSG_SET_CLOCK_STATE 0x0100
30 #define TI_SCI_MSG_GET_CLOCK_STATE 0x0101
31 #define TI_SCI_MSG_SET_CLOCK_PARENT 0x0102
32 #define TI_SCI_MSG_GET_CLOCK_PARENT 0x0103
33 #define TI_SCI_MSG_GET_NUM_CLOCK_PARENTS 0x0104
34 #define TI_SCI_MSG_SET_CLOCK_FREQ 0x010c
35 #define TI_SCI_MSG_QUERY_CLOCK_FREQ 0x010d
36 #define TI_SCI_MSG_GET_CLOCK_FREQ 0x010e
39 * struct ti_sci_msg_hdr - Generic Message Header for All messages and responses
40 * @type: Type of messages: One of TI_SCI_MSG* values
41 * @host: Host of the message
42 * @seq: Message identifier indicating a transfer sequence
43 * @flags: Flag for the message
45 struct ti_sci_msg_hdr
{
49 #define TI_SCI_MSG_FLAG(val) (1 << (val))
50 #define TI_SCI_FLAG_REQ_GENERIC_NORESPONSE 0x0
51 #define TI_SCI_FLAG_REQ_ACK_ON_RECEIVED TI_SCI_MSG_FLAG(0)
52 #define TI_SCI_FLAG_REQ_ACK_ON_PROCESSED TI_SCI_MSG_FLAG(1)
53 #define TI_SCI_FLAG_RESP_GENERIC_NACK 0x0
54 #define TI_SCI_FLAG_RESP_GENERIC_ACK TI_SCI_MSG_FLAG(1)
55 /* Additional Flags */
60 * struct ti_sci_msg_resp_version - Response for a message
61 * @hdr: Generic header
62 * @firmware_description: String describing the firmware
63 * @firmware_revision: Firmware revision
64 * @abi_major: Major version of the ABI that firmware supports
65 * @abi_minor: Minor version of the ABI that firmware supports
67 * In general, ABI version changes follow the rule that minor version increments
68 * are backward compatible. Major revision changes in ABI may not be
69 * backward compatible.
71 * Response to a generic message with message type TI_SCI_MSG_VERSION
73 struct ti_sci_msg_resp_version
{
74 struct ti_sci_msg_hdr hdr
;
75 char firmware_description
[32];
76 u16 firmware_revision
;
82 * struct ti_sci_msg_req_reboot - Reboot the SoC
83 * @hdr: Generic Header
85 * Request type is TI_SCI_MSG_SYS_RESET, responded with a generic
88 struct ti_sci_msg_req_reboot
{
89 struct ti_sci_msg_hdr hdr
;
93 * struct ti_sci_msg_req_set_device_state - Set the desired state of the device
94 * @hdr: Generic header
95 * @id: Indicates which device to modify
96 * @reserved: Reserved space in message, must be 0 for backward compatibility
97 * @state: The desired state of the device.
99 * Certain flags can also be set to alter the device state:
100 * + MSG_FLAG_DEVICE_WAKE_ENABLED - Configure the device to be a wake source.
101 * The meaning of this flag will vary slightly from device to device and from
102 * SoC to SoC but it generally allows the device to wake the SoC out of deep
104 * + MSG_FLAG_DEVICE_RESET_ISO - Enable reset isolation for this device.
105 * + MSG_FLAG_DEVICE_EXCLUSIVE - Claim this device exclusively. When passed
106 * with STATE_RETENTION or STATE_ON, it will claim the device exclusively.
107 * If another host already has this device set to STATE_RETENTION or STATE_ON,
108 * the message will fail. Once successful, other hosts attempting to set
109 * STATE_RETENTION or STATE_ON will fail.
111 * Request type is TI_SCI_MSG_SET_DEVICE_STATE, responded with a generic
114 struct ti_sci_msg_req_set_device_state
{
115 /* Additional hdr->flags options */
116 #define MSG_FLAG_DEVICE_WAKE_ENABLED TI_SCI_MSG_FLAG(8)
117 #define MSG_FLAG_DEVICE_RESET_ISO TI_SCI_MSG_FLAG(9)
118 #define MSG_FLAG_DEVICE_EXCLUSIVE TI_SCI_MSG_FLAG(10)
119 struct ti_sci_msg_hdr hdr
;
123 #define MSG_DEVICE_SW_STATE_AUTO_OFF 0
124 #define MSG_DEVICE_SW_STATE_RETENTION 1
125 #define MSG_DEVICE_SW_STATE_ON 2
130 * struct ti_sci_msg_req_get_device_state - Request to get device.
131 * @hdr: Generic header
132 * @id: Device Identifier
134 * Request type is TI_SCI_MSG_GET_DEVICE_STATE, responded device state
137 struct ti_sci_msg_req_get_device_state
{
138 struct ti_sci_msg_hdr hdr
;
143 * struct ti_sci_msg_resp_get_device_state - Response to get device request.
144 * @hdr: Generic header
145 * @context_loss_count: Indicates how many times the device has lost context. A
146 * driver can use this monotonic counter to determine if the device has
147 * lost context since the last time this message was exchanged.
148 * @resets: Programmed state of the reset lines.
149 * @programmed_state: The state as programmed by set_device.
150 * - Uses the MSG_DEVICE_SW_* macros
151 * @current_state: The actual state of the hardware.
153 * Response to request TI_SCI_MSG_GET_DEVICE_STATE.
155 struct ti_sci_msg_resp_get_device_state
{
156 struct ti_sci_msg_hdr hdr
;
157 u32 context_loss_count
;
160 #define MSG_DEVICE_HW_STATE_OFF 0
161 #define MSG_DEVICE_HW_STATE_ON 1
162 #define MSG_DEVICE_HW_STATE_TRANS 2
167 * struct ti_sci_msg_req_set_device_resets - Set the desired resets
168 * configuration of the device
169 * @hdr: Generic header
170 * @id: Indicates which device to modify
171 * @resets: A bit field of resets for the device. The meaning, behavior,
172 * and usage of the reset flags are device specific. 0 for a bit
173 * indicates releasing the reset represented by that bit while 1
174 * indicates keeping it held.
176 * Request type is TI_SCI_MSG_SET_DEVICE_RESETS, responded with a generic
179 struct ti_sci_msg_req_set_device_resets
{
180 struct ti_sci_msg_hdr hdr
;
186 * struct ti_sci_msg_req_set_clock_state - Request to setup a Clock state
187 * @hdr: Generic Header, Certain flags can be set specific to the clocks:
188 * MSG_FLAG_CLOCK_ALLOW_SSC: Allow this clock to be modified
189 * via spread spectrum clocking.
190 * MSG_FLAG_CLOCK_ALLOW_FREQ_CHANGE: Allow this clock's
191 * frequency to be changed while it is running so long as it
192 * is within the min/max limits.
193 * MSG_FLAG_CLOCK_INPUT_TERM: Enable input termination, this
194 * is only applicable to clock inputs on the SoC pseudo-device.
195 * @dev_id: Device identifier this request is for
196 * @clk_id: Clock identifier for the device for this request.
197 * Each device has it's own set of clock inputs. This indexes
198 * which clock input to modify.
199 * @request_state: Request the state for the clock to be set to.
200 * MSG_CLOCK_SW_STATE_UNREQ: The IP does not require this clock,
201 * it can be disabled, regardless of the state of the device
202 * MSG_CLOCK_SW_STATE_AUTO: Allow the System Controller to
203 * automatically manage the state of this clock. If the device
204 * is enabled, then the clock is enabled. If the device is set
205 * to off or retention, then the clock is internally set as not
206 * being required by the device.(default)
207 * MSG_CLOCK_SW_STATE_REQ: Configure the clock to be enabled,
208 * regardless of the state of the device.
210 * Normally, all required clocks are managed by TISCI entity, this is used
211 * only for specific control *IF* required. Auto managed state is
212 * MSG_CLOCK_SW_STATE_AUTO, in other states, TISCI entity assume remote
213 * will explicitly control.
215 * Request type is TI_SCI_MSG_SET_CLOCK_STATE, response is a generic
216 * ACK or NACK message.
218 struct ti_sci_msg_req_set_clock_state
{
219 /* Additional hdr->flags options */
220 #define MSG_FLAG_CLOCK_ALLOW_SSC TI_SCI_MSG_FLAG(8)
221 #define MSG_FLAG_CLOCK_ALLOW_FREQ_CHANGE TI_SCI_MSG_FLAG(9)
222 #define MSG_FLAG_CLOCK_INPUT_TERM TI_SCI_MSG_FLAG(10)
223 struct ti_sci_msg_hdr hdr
;
226 #define MSG_CLOCK_SW_STATE_UNREQ 0
227 #define MSG_CLOCK_SW_STATE_AUTO 1
228 #define MSG_CLOCK_SW_STATE_REQ 2
233 * struct ti_sci_msg_req_get_clock_state - Request for clock state
234 * @hdr: Generic Header
235 * @dev_id: Device identifier this request is for
236 * @clk_id: Clock identifier for the device for this request.
237 * Each device has it's own set of clock inputs. This indexes
238 * which clock input to get state of.
240 * Request type is TI_SCI_MSG_GET_CLOCK_STATE, response is state
243 struct ti_sci_msg_req_get_clock_state
{
244 struct ti_sci_msg_hdr hdr
;
250 * struct ti_sci_msg_resp_get_clock_state - Response to get clock state
251 * @hdr: Generic Header
252 * @programmed_state: Any programmed state of the clock. This is one of
253 * MSG_CLOCK_SW_STATE* values.
254 * @current_state: Current state of the clock. This is one of:
255 * MSG_CLOCK_HW_STATE_NOT_READY: Clock is not ready
256 * MSG_CLOCK_HW_STATE_READY: Clock is ready
258 * Response to TI_SCI_MSG_GET_CLOCK_STATE.
260 struct ti_sci_msg_resp_get_clock_state
{
261 struct ti_sci_msg_hdr hdr
;
263 #define MSG_CLOCK_HW_STATE_NOT_READY 0
264 #define MSG_CLOCK_HW_STATE_READY 1
269 * struct ti_sci_msg_req_set_clock_parent - Set the clock parent
270 * @hdr: Generic Header
271 * @dev_id: Device identifier this request is for
272 * @clk_id: Clock identifier for the device for this request.
273 * Each device has it's own set of clock inputs. This indexes
274 * which clock input to modify.
275 * @parent_id: The new clock parent is selectable by an index via this
278 * Request type is TI_SCI_MSG_SET_CLOCK_PARENT, response is generic
279 * ACK / NACK message.
281 struct ti_sci_msg_req_set_clock_parent
{
282 struct ti_sci_msg_hdr hdr
;
289 * struct ti_sci_msg_req_get_clock_parent - Get the clock parent
290 * @hdr: Generic Header
291 * @dev_id: Device identifier this request is for
292 * @clk_id: Clock identifier for the device for this request.
293 * Each device has it's own set of clock inputs. This indexes
294 * which clock input to get the parent for.
296 * Request type is TI_SCI_MSG_GET_CLOCK_PARENT, response is parent information
298 struct ti_sci_msg_req_get_clock_parent
{
299 struct ti_sci_msg_hdr hdr
;
305 * struct ti_sci_msg_resp_get_clock_parent - Response with clock parent
306 * @hdr: Generic Header
307 * @parent_id: The current clock parent
309 * Response to TI_SCI_MSG_GET_CLOCK_PARENT.
311 struct ti_sci_msg_resp_get_clock_parent
{
312 struct ti_sci_msg_hdr hdr
;
317 * struct ti_sci_msg_req_get_clock_num_parents - Request to get clock parents
318 * @hdr: Generic header
319 * @dev_id: Device identifier this request is for
320 * @clk_id: Clock identifier for the device for this request.
322 * This request provides information about how many clock parent options
323 * are available for a given clock to a device. This is typically used
326 * Request type is TI_SCI_MSG_GET_NUM_CLOCK_PARENTS, response is appropriate
327 * message, or NACK in case of inability to satisfy request.
329 struct ti_sci_msg_req_get_clock_num_parents
{
330 struct ti_sci_msg_hdr hdr
;
336 * struct ti_sci_msg_resp_get_clock_num_parents - Response for get clk parents
337 * @hdr: Generic header
338 * @num_parents: Number of clock parents
340 * Response to TI_SCI_MSG_GET_NUM_CLOCK_PARENTS
342 struct ti_sci_msg_resp_get_clock_num_parents
{
343 struct ti_sci_msg_hdr hdr
;
348 * struct ti_sci_msg_req_query_clock_freq - Request to query a frequency
349 * @hdr: Generic Header
350 * @dev_id: Device identifier this request is for
351 * @min_freq_hz: The minimum allowable frequency in Hz. This is the minimum
352 * allowable programmed frequency and does not account for clock
353 * tolerances and jitter.
354 * @target_freq_hz: The target clock frequency. A frequency will be found
355 * as close to this target frequency as possible.
356 * @max_freq_hz: The maximum allowable frequency in Hz. This is the maximum
357 * allowable programmed frequency and does not account for clock
358 * tolerances and jitter.
359 * @clk_id: Clock identifier for the device for this request.
361 * NOTE: Normally clock frequency management is automatically done by TISCI
362 * entity. In case of specific requests, TISCI evaluates capability to achieve
363 * requested frequency within provided range and responds with
366 * Request type is TI_SCI_MSG_QUERY_CLOCK_FREQ, response is appropriate message,
367 * or NACK in case of inability to satisfy request.
369 struct ti_sci_msg_req_query_clock_freq
{
370 struct ti_sci_msg_hdr hdr
;
379 * struct ti_sci_msg_resp_query_clock_freq - Response to a clock frequency query
380 * @hdr: Generic Header
381 * @freq_hz: Frequency that is the best match in Hz.
383 * Response to request type TI_SCI_MSG_QUERY_CLOCK_FREQ. NOTE: if the request
384 * cannot be satisfied, the message will be of type NACK.
386 struct ti_sci_msg_resp_query_clock_freq
{
387 struct ti_sci_msg_hdr hdr
;
392 * struct ti_sci_msg_req_set_clock_freq - Request to setup a clock frequency
393 * @hdr: Generic Header
394 * @dev_id: Device identifier this request is for
395 * @min_freq_hz: The minimum allowable frequency in Hz. This is the minimum
396 * allowable programmed frequency and does not account for clock
397 * tolerances and jitter.
398 * @target_freq_hz: The target clock frequency. The clock will be programmed
399 * at a rate as close to this target frequency as possible.
400 * @max_freq_hz: The maximum allowable frequency in Hz. This is the maximum
401 * allowable programmed frequency and does not account for clock
402 * tolerances and jitter.
403 * @clk_id: Clock identifier for the device for this request.
405 * NOTE: Normally clock frequency management is automatically done by TISCI
406 * entity. In case of specific requests, TISCI evaluates capability to achieve
407 * requested range and responds with success/failure message.
409 * This sets the desired frequency for a clock within an allowable
410 * range. This message will fail on an enabled clock unless
411 * MSG_FLAG_CLOCK_ALLOW_FREQ_CHANGE is set for the clock. Additionally,
412 * if other clocks have their frequency modified due to this message,
413 * they also must have the MSG_FLAG_CLOCK_ALLOW_FREQ_CHANGE or be disabled.
415 * Calling set frequency on a clock input to the SoC pseudo-device will
416 * inform the PMMC of that clock's frequency. Setting a frequency of
417 * zero will indicate the clock is disabled.
419 * Calling set frequency on clock outputs from the SoC pseudo-device will
420 * function similarly to setting the clock frequency on a device.
422 * Request type is TI_SCI_MSG_SET_CLOCK_FREQ, response is a generic ACK/NACK
425 struct ti_sci_msg_req_set_clock_freq
{
426 struct ti_sci_msg_hdr hdr
;
435 * struct ti_sci_msg_req_get_clock_freq - Request to get the clock frequency
436 * @hdr: Generic Header
437 * @dev_id: Device identifier this request is for
438 * @clk_id: Clock identifier for the device for this request.
440 * NOTE: Normally clock frequency management is automatically done by TISCI
441 * entity. In some cases, clock frequencies are configured by host.
443 * Request type is TI_SCI_MSG_GET_CLOCK_FREQ, responded with clock frequency
444 * that the clock is currently at.
446 struct ti_sci_msg_req_get_clock_freq
{
447 struct ti_sci_msg_hdr hdr
;
453 * struct ti_sci_msg_resp_get_clock_freq - Response of clock frequency request
454 * @hdr: Generic Header
455 * @freq_hz: Frequency that the clock is currently on, in Hz.
457 * Response to request type TI_SCI_MSG_GET_CLOCK_FREQ.
459 struct ti_sci_msg_resp_get_clock_freq
{
460 struct ti_sci_msg_hdr hdr
;
464 #endif /* __TI_SCI_H */