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) 2018 Texas Instruments Incorporated - http://www.ti.com/
10 * Based on drivers/firmware/ti_sci.h from Linux.
17 /* Generic Messages */
18 #define TI_SCI_MSG_ENABLE_WDT 0x0000
19 #define TI_SCI_MSG_WAKE_RESET 0x0001
20 #define TI_SCI_MSG_VERSION 0x0002
21 #define TI_SCI_MSG_WAKE_REASON 0x0003
22 #define TI_SCI_MSG_GOODBYE 0x0004
23 #define TI_SCI_MSG_SYS_RESET 0x0005
24 #define TI_SCI_MSG_BOARD_CONFIG 0x000b
25 #define TI_SCI_MSG_BOARD_CONFIG_RM 0x000c
26 #define TI_SCI_MSG_BOARD_CONFIG_SECURITY 0x000d
27 #define TI_SCI_MSG_BOARD_CONFIG_PM 0x000e
30 #define TI_SCI_MSG_SET_DEVICE_STATE 0x0200
31 #define TI_SCI_MSG_GET_DEVICE_STATE 0x0201
32 #define TI_SCI_MSG_SET_DEVICE_RESETS 0x0202
35 #define TI_SCI_MSG_SET_CLOCK_STATE 0x0100
36 #define TI_SCI_MSG_GET_CLOCK_STATE 0x0101
37 #define TI_SCI_MSG_SET_CLOCK_PARENT 0x0102
38 #define TI_SCI_MSG_GET_CLOCK_PARENT 0x0103
39 #define TI_SCI_MSG_GET_NUM_CLOCK_PARENTS 0x0104
40 #define TI_SCI_MSG_SET_CLOCK_FREQ 0x010c
41 #define TI_SCI_MSG_QUERY_CLOCK_FREQ 0x010d
42 #define TI_SCI_MSG_GET_CLOCK_FREQ 0x010e
45 * struct ti_sci_msg_hdr - Generic Message Header for All messages and responses
46 * @type: Type of messages: One of TI_SCI_MSG* values
47 * @host: Host of the message
48 * @seq: Message identifier indicating a transfer sequence
49 * @flags: Flag for the message
51 struct ti_sci_msg_hdr {
55 #define TI_SCI_MSG_FLAG(val) (1 << (val))
56 #define TI_SCI_FLAG_REQ_GENERIC_NORESPONSE 0x0
57 #define TI_SCI_FLAG_REQ_ACK_ON_RECEIVED TI_SCI_MSG_FLAG(0)
58 #define TI_SCI_FLAG_REQ_ACK_ON_PROCESSED TI_SCI_MSG_FLAG(1)
59 #define TI_SCI_FLAG_RESP_GENERIC_NACK 0x0
60 #define TI_SCI_FLAG_RESP_GENERIC_ACK TI_SCI_MSG_FLAG(1)
61 /* Additional Flags */
66 * struct ti_sci_secure_msg_hdr - Header that prefixes all TISCI messages sent
67 * via secure transport.
68 * @checksum: crc16 checksum for the entire message
69 * @reserved: Reserved for future use.
71 struct ti_sci_secure_msg_hdr {
77 * struct ti_sci_msg_resp_version - Response for a message
78 * @hdr: Generic header
79 * @firmware_description: String describing the firmware
80 * @firmware_revision: Firmware revision
81 * @abi_major: Major version of the ABI that firmware supports
82 * @abi_minor: Minor version of the ABI that firmware supports
84 * In general, ABI version changes follow the rule that minor version increments
85 * are backward compatible. Major revision changes in ABI may not be
86 * backward compatible.
88 * Response to a generic message with message type TI_SCI_MSG_VERSION
90 struct ti_sci_msg_resp_version {
91 struct ti_sci_msg_hdr hdr;
92 char firmware_description[32];
93 u16 firmware_revision;
99 * struct ti_sci_msg_req_reboot - Reboot the SoC
100 * @hdr: Generic Header
102 * Request type is TI_SCI_MSG_SYS_RESET, responded with a generic
105 struct ti_sci_msg_req_reboot {
106 struct ti_sci_msg_hdr hdr;
110 * struct ti_sci_msg_board_config - Board configuration message
111 * @hdr: Generic Header
112 * @boardcfgp_low: Lower 32 bit of the pointer pointing to the board
114 * @boardcfgp_high: Upper 32 bit of the pointer pointing to the board
116 * @boardcfg_size: Size of board configuration data object
117 * Request type is TI_SCI_MSG_BOARD_CONFIG, responded with a generic
120 struct ti_sci_msg_board_config {
121 struct ti_sci_msg_hdr hdr;
128 * struct ti_sci_msg_req_set_device_state - Set the desired state of the device
129 * @hdr: Generic header
130 * @id: Indicates which device to modify
131 * @reserved: Reserved space in message, must be 0 for backward compatibility
132 * @state: The desired state of the device.
134 * Certain flags can also be set to alter the device state:
135 * + MSG_FLAG_DEVICE_WAKE_ENABLED - Configure the device to be a wake source.
136 * The meaning of this flag will vary slightly from device to device and from
137 * SoC to SoC but it generally allows the device to wake the SoC out of deep
139 * + MSG_FLAG_DEVICE_RESET_ISO - Enable reset isolation for this device.
140 * + MSG_FLAG_DEVICE_EXCLUSIVE - Claim this device exclusively. When passed
141 * with STATE_RETENTION or STATE_ON, it will claim the device exclusively.
142 * If another host already has this device set to STATE_RETENTION or STATE_ON,
143 * the message will fail. Once successful, other hosts attempting to set
144 * STATE_RETENTION or STATE_ON will fail.
146 * Request type is TI_SCI_MSG_SET_DEVICE_STATE, responded with a generic
149 struct ti_sci_msg_req_set_device_state {
150 /* Additional hdr->flags options */
151 #define MSG_FLAG_DEVICE_WAKE_ENABLED TI_SCI_MSG_FLAG(8)
152 #define MSG_FLAG_DEVICE_RESET_ISO TI_SCI_MSG_FLAG(9)
153 #define MSG_FLAG_DEVICE_EXCLUSIVE TI_SCI_MSG_FLAG(10)
154 struct ti_sci_msg_hdr hdr;
158 #define MSG_DEVICE_SW_STATE_AUTO_OFF 0
159 #define MSG_DEVICE_SW_STATE_RETENTION 1
160 #define MSG_DEVICE_SW_STATE_ON 2
165 * struct ti_sci_msg_req_get_device_state - Request to get device.
166 * @hdr: Generic header
167 * @id: Device Identifier
169 * Request type is TI_SCI_MSG_GET_DEVICE_STATE, responded device state
172 struct ti_sci_msg_req_get_device_state {
173 struct ti_sci_msg_hdr hdr;
178 * struct ti_sci_msg_resp_get_device_state - Response to get device request.
179 * @hdr: Generic header
180 * @context_loss_count: Indicates how many times the device has lost context. A
181 * driver can use this monotonic counter to determine if the device has
182 * lost context since the last time this message was exchanged.
183 * @resets: Programmed state of the reset lines.
184 * @programmed_state: The state as programmed by set_device.
185 * - Uses the MSG_DEVICE_SW_* macros
186 * @current_state: The actual state of the hardware.
188 * Response to request TI_SCI_MSG_GET_DEVICE_STATE.
190 struct ti_sci_msg_resp_get_device_state {
191 struct ti_sci_msg_hdr hdr;
192 u32 context_loss_count;
195 #define MSG_DEVICE_HW_STATE_OFF 0
196 #define MSG_DEVICE_HW_STATE_ON 1
197 #define MSG_DEVICE_HW_STATE_TRANS 2
202 * struct ti_sci_msg_req_set_device_resets - Set the desired resets
203 * configuration of the device
204 * @hdr: Generic header
205 * @id: Indicates which device to modify
206 * @resets: A bit field of resets for the device. The meaning, behavior,
207 * and usage of the reset flags are device specific. 0 for a bit
208 * indicates releasing the reset represented by that bit while 1
209 * indicates keeping it held.
211 * Request type is TI_SCI_MSG_SET_DEVICE_RESETS, responded with a generic
214 struct ti_sci_msg_req_set_device_resets {
215 struct ti_sci_msg_hdr hdr;
221 * struct ti_sci_msg_req_set_clock_state - Request to setup a Clock state
222 * @hdr: Generic Header, Certain flags can be set specific to the clocks:
223 * MSG_FLAG_CLOCK_ALLOW_SSC: Allow this clock to be modified
224 * via spread spectrum clocking.
225 * MSG_FLAG_CLOCK_ALLOW_FREQ_CHANGE: Allow this clock's
226 * frequency to be changed while it is running so long as it
227 * is within the min/max limits.
228 * MSG_FLAG_CLOCK_INPUT_TERM: Enable input termination, this
229 * is only applicable to clock inputs on the SoC pseudo-device.
230 * @dev_id: Device identifier this request is for
231 * @clk_id: Clock identifier for the device for this request.
232 * Each device has it's own set of clock inputs. This indexes
233 * which clock input to modify.
234 * @request_state: Request the state for the clock to be set to.
235 * MSG_CLOCK_SW_STATE_UNREQ: The IP does not require this clock,
236 * it can be disabled, regardless of the state of the device
237 * MSG_CLOCK_SW_STATE_AUTO: Allow the System Controller to
238 * automatically manage the state of this clock. If the device
239 * is enabled, then the clock is enabled. If the device is set
240 * to off or retention, then the clock is internally set as not
241 * being required by the device.(default)
242 * MSG_CLOCK_SW_STATE_REQ: Configure the clock to be enabled,
243 * regardless of the state of the device.
245 * Normally, all required clocks are managed by TISCI entity, this is used
246 * only for specific control *IF* required. Auto managed state is
247 * MSG_CLOCK_SW_STATE_AUTO, in other states, TISCI entity assume remote
248 * will explicitly control.
250 * Request type is TI_SCI_MSG_SET_CLOCK_STATE, response is a generic
251 * ACK or NACK message.
253 struct ti_sci_msg_req_set_clock_state {
254 /* Additional hdr->flags options */
255 #define MSG_FLAG_CLOCK_ALLOW_SSC TI_SCI_MSG_FLAG(8)
256 #define MSG_FLAG_CLOCK_ALLOW_FREQ_CHANGE TI_SCI_MSG_FLAG(9)
257 #define MSG_FLAG_CLOCK_INPUT_TERM TI_SCI_MSG_FLAG(10)
258 struct ti_sci_msg_hdr hdr;
261 #define MSG_CLOCK_SW_STATE_UNREQ 0
262 #define MSG_CLOCK_SW_STATE_AUTO 1
263 #define MSG_CLOCK_SW_STATE_REQ 2
268 * struct ti_sci_msg_req_get_clock_state - Request for clock state
269 * @hdr: Generic Header
270 * @dev_id: Device identifier this request is for
271 * @clk_id: Clock identifier for the device for this request.
272 * Each device has it's own set of clock inputs. This indexes
273 * which clock input to get state of.
275 * Request type is TI_SCI_MSG_GET_CLOCK_STATE, response is state
278 struct ti_sci_msg_req_get_clock_state {
279 struct ti_sci_msg_hdr hdr;
285 * struct ti_sci_msg_resp_get_clock_state - Response to get clock state
286 * @hdr: Generic Header
287 * @programmed_state: Any programmed state of the clock. This is one of
288 * MSG_CLOCK_SW_STATE* values.
289 * @current_state: Current state of the clock. This is one of:
290 * MSG_CLOCK_HW_STATE_NOT_READY: Clock is not ready
291 * MSG_CLOCK_HW_STATE_READY: Clock is ready
293 * Response to TI_SCI_MSG_GET_CLOCK_STATE.
295 struct ti_sci_msg_resp_get_clock_state {
296 struct ti_sci_msg_hdr hdr;
298 #define MSG_CLOCK_HW_STATE_NOT_READY 0
299 #define MSG_CLOCK_HW_STATE_READY 1
304 * struct ti_sci_msg_req_set_clock_parent - Set the clock parent
305 * @hdr: Generic Header
306 * @dev_id: Device identifier this request is for
307 * @clk_id: Clock identifier for the device for this request.
308 * Each device has it's own set of clock inputs. This indexes
309 * which clock input to modify.
310 * @parent_id: The new clock parent is selectable by an index via this
313 * Request type is TI_SCI_MSG_SET_CLOCK_PARENT, response is generic
314 * ACK / NACK message.
316 struct ti_sci_msg_req_set_clock_parent {
317 struct ti_sci_msg_hdr hdr;
324 * struct ti_sci_msg_req_get_clock_parent - Get the clock parent
325 * @hdr: Generic Header
326 * @dev_id: Device identifier this request is for
327 * @clk_id: Clock identifier for the device for this request.
328 * Each device has it's own set of clock inputs. This indexes
329 * which clock input to get the parent for.
331 * Request type is TI_SCI_MSG_GET_CLOCK_PARENT, response is parent information
333 struct ti_sci_msg_req_get_clock_parent {
334 struct ti_sci_msg_hdr hdr;
340 * struct ti_sci_msg_resp_get_clock_parent - Response with clock parent
341 * @hdr: Generic Header
342 * @parent_id: The current clock parent
344 * Response to TI_SCI_MSG_GET_CLOCK_PARENT.
346 struct ti_sci_msg_resp_get_clock_parent {
347 struct ti_sci_msg_hdr hdr;
352 * struct ti_sci_msg_req_get_clock_num_parents - Request to get clock parents
353 * @hdr: Generic header
354 * @dev_id: Device identifier this request is for
355 * @clk_id: Clock identifier for the device for this request.
357 * This request provides information about how many clock parent options
358 * are available for a given clock to a device. This is typically used
361 * Request type is TI_SCI_MSG_GET_NUM_CLOCK_PARENTS, response is appropriate
362 * message, or NACK in case of inability to satisfy request.
364 struct ti_sci_msg_req_get_clock_num_parents {
365 struct ti_sci_msg_hdr hdr;
371 * struct ti_sci_msg_resp_get_clock_num_parents - Response for get clk parents
372 * @hdr: Generic header
373 * @num_parents: Number of clock parents
375 * Response to TI_SCI_MSG_GET_NUM_CLOCK_PARENTS
377 struct ti_sci_msg_resp_get_clock_num_parents {
378 struct ti_sci_msg_hdr hdr;
383 * struct ti_sci_msg_req_query_clock_freq - Request to query a frequency
384 * @hdr: Generic Header
385 * @dev_id: Device identifier this request is for
386 * @min_freq_hz: The minimum allowable frequency in Hz. This is the minimum
387 * allowable programmed frequency and does not account for clock
388 * tolerances and jitter.
389 * @target_freq_hz: The target clock frequency. A frequency will be found
390 * as close to this target frequency as possible.
391 * @max_freq_hz: The maximum allowable frequency in Hz. This is the maximum
392 * allowable programmed frequency and does not account for clock
393 * tolerances and jitter.
394 * @clk_id: Clock identifier for the device for this request.
396 * NOTE: Normally clock frequency management is automatically done by TISCI
397 * entity. In case of specific requests, TISCI evaluates capability to achieve
398 * requested frequency within provided range and responds with
401 * Request type is TI_SCI_MSG_QUERY_CLOCK_FREQ, response is appropriate message,
402 * or NACK in case of inability to satisfy request.
404 struct ti_sci_msg_req_query_clock_freq {
405 struct ti_sci_msg_hdr hdr;
414 * struct ti_sci_msg_resp_query_clock_freq - Response to a clock frequency query
415 * @hdr: Generic Header
416 * @freq_hz: Frequency that is the best match in Hz.
418 * Response to request type TI_SCI_MSG_QUERY_CLOCK_FREQ. NOTE: if the request
419 * cannot be satisfied, the message will be of type NACK.
421 struct ti_sci_msg_resp_query_clock_freq {
422 struct ti_sci_msg_hdr hdr;
427 * struct ti_sci_msg_req_set_clock_freq - Request to setup a clock frequency
428 * @hdr: Generic Header
429 * @dev_id: Device identifier this request is for
430 * @min_freq_hz: The minimum allowable frequency in Hz. This is the minimum
431 * allowable programmed frequency and does not account for clock
432 * tolerances and jitter.
433 * @target_freq_hz: The target clock frequency. The clock will be programmed
434 * at a rate as close to this target frequency as possible.
435 * @max_freq_hz: The maximum allowable frequency in Hz. This is the maximum
436 * allowable programmed frequency and does not account for clock
437 * tolerances and jitter.
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 case of specific requests, TISCI evaluates capability to achieve
442 * requested range and responds with success/failure message.
444 * This sets the desired frequency for a clock within an allowable
445 * range. This message will fail on an enabled clock unless
446 * MSG_FLAG_CLOCK_ALLOW_FREQ_CHANGE is set for the clock. Additionally,
447 * if other clocks have their frequency modified due to this message,
448 * they also must have the MSG_FLAG_CLOCK_ALLOW_FREQ_CHANGE or be disabled.
450 * Calling set frequency on a clock input to the SoC pseudo-device will
451 * inform the PMMC of that clock's frequency. Setting a frequency of
452 * zero will indicate the clock is disabled.
454 * Calling set frequency on clock outputs from the SoC pseudo-device will
455 * function similarly to setting the clock frequency on a device.
457 * Request type is TI_SCI_MSG_SET_CLOCK_FREQ, response is a generic ACK/NACK
460 struct ti_sci_msg_req_set_clock_freq {
461 struct ti_sci_msg_hdr hdr;
470 * struct ti_sci_msg_req_get_clock_freq - Request to get the clock frequency
471 * @hdr: Generic Header
472 * @dev_id: Device identifier this request is for
473 * @clk_id: Clock identifier for the device for this request.
475 * NOTE: Normally clock frequency management is automatically done by TISCI
476 * entity. In some cases, clock frequencies are configured by host.
478 * Request type is TI_SCI_MSG_GET_CLOCK_FREQ, responded with clock frequency
479 * that the clock is currently at.
481 struct ti_sci_msg_req_get_clock_freq {
482 struct ti_sci_msg_hdr hdr;
488 * struct ti_sci_msg_resp_get_clock_freq - Response of clock frequency request
489 * @hdr: Generic Header
490 * @freq_hz: Frequency that the clock is currently on, in Hz.
492 * Response to request type TI_SCI_MSG_GET_CLOCK_FREQ.
494 struct ti_sci_msg_resp_get_clock_freq {
495 struct ti_sci_msg_hdr hdr;
499 #endif /* __TI_SCI_H */