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_board_config - Board configuration message
100 * @hdr: Generic Header
101 * @boardcfgp_low: Lower 32 bit of the pointer pointing to the board
103 * @boardcfgp_high: Upper 32 bit of the pointer pointing to the board
105 * @boardcfg_size: Size of board configuration data object
106 * Request type is TI_SCI_MSG_BOARD_CONFIG, responded with a generic
109 struct ti_sci_msg_board_config {
110 struct ti_sci_msg_hdr hdr;
117 * struct ti_sci_msg_req_set_device_state - Set the desired state of the device
118 * @hdr: Generic header
119 * @id: Indicates which device to modify
120 * @reserved: Reserved space in message, must be 0 for backward compatibility
121 * @state: The desired state of the device.
123 * Certain flags can also be set to alter the device state:
124 * + MSG_FLAG_DEVICE_WAKE_ENABLED - Configure the device to be a wake source.
125 * The meaning of this flag will vary slightly from device to device and from
126 * SoC to SoC but it generally allows the device to wake the SoC out of deep
128 * + MSG_FLAG_DEVICE_RESET_ISO - Enable reset isolation for this device.
129 * + MSG_FLAG_DEVICE_EXCLUSIVE - Claim this device exclusively. When passed
130 * with STATE_RETENTION or STATE_ON, it will claim the device exclusively.
131 * If another host already has this device set to STATE_RETENTION or STATE_ON,
132 * the message will fail. Once successful, other hosts attempting to set
133 * STATE_RETENTION or STATE_ON will fail.
135 * Request type is TI_SCI_MSG_SET_DEVICE_STATE, responded with a generic
138 struct ti_sci_msg_req_set_device_state {
139 /* Additional hdr->flags options */
140 #define MSG_FLAG_DEVICE_WAKE_ENABLED TI_SCI_MSG_FLAG(8)
141 #define MSG_FLAG_DEVICE_RESET_ISO TI_SCI_MSG_FLAG(9)
142 #define MSG_FLAG_DEVICE_EXCLUSIVE TI_SCI_MSG_FLAG(10)
143 struct ti_sci_msg_hdr hdr;
147 #define MSG_DEVICE_SW_STATE_AUTO_OFF 0
148 #define MSG_DEVICE_SW_STATE_RETENTION 1
149 #define MSG_DEVICE_SW_STATE_ON 2
154 * struct ti_sci_msg_req_get_device_state - Request to get device.
155 * @hdr: Generic header
156 * @id: Device Identifier
158 * Request type is TI_SCI_MSG_GET_DEVICE_STATE, responded device state
161 struct ti_sci_msg_req_get_device_state {
162 struct ti_sci_msg_hdr hdr;
167 * struct ti_sci_msg_resp_get_device_state - Response to get device request.
168 * @hdr: Generic header
169 * @context_loss_count: Indicates how many times the device has lost context. A
170 * driver can use this monotonic counter to determine if the device has
171 * lost context since the last time this message was exchanged.
172 * @resets: Programmed state of the reset lines.
173 * @programmed_state: The state as programmed by set_device.
174 * - Uses the MSG_DEVICE_SW_* macros
175 * @current_state: The actual state of the hardware.
177 * Response to request TI_SCI_MSG_GET_DEVICE_STATE.
179 struct ti_sci_msg_resp_get_device_state {
180 struct ti_sci_msg_hdr hdr;
181 u32 context_loss_count;
184 #define MSG_DEVICE_HW_STATE_OFF 0
185 #define MSG_DEVICE_HW_STATE_ON 1
186 #define MSG_DEVICE_HW_STATE_TRANS 2
191 * struct ti_sci_msg_req_set_device_resets - Set the desired resets
192 * configuration of the device
193 * @hdr: Generic header
194 * @id: Indicates which device to modify
195 * @resets: A bit field of resets for the device. The meaning, behavior,
196 * and usage of the reset flags are device specific. 0 for a bit
197 * indicates releasing the reset represented by that bit while 1
198 * indicates keeping it held.
200 * Request type is TI_SCI_MSG_SET_DEVICE_RESETS, responded with a generic
203 struct ti_sci_msg_req_set_device_resets {
204 struct ti_sci_msg_hdr hdr;
210 * struct ti_sci_msg_req_set_clock_state - Request to setup a Clock state
211 * @hdr: Generic Header, Certain flags can be set specific to the clocks:
212 * MSG_FLAG_CLOCK_ALLOW_SSC: Allow this clock to be modified
213 * via spread spectrum clocking.
214 * MSG_FLAG_CLOCK_ALLOW_FREQ_CHANGE: Allow this clock's
215 * frequency to be changed while it is running so long as it
216 * is within the min/max limits.
217 * MSG_FLAG_CLOCK_INPUT_TERM: Enable input termination, this
218 * is only applicable to clock inputs on the SoC pseudo-device.
219 * @dev_id: Device identifier this request is for
220 * @clk_id: Clock identifier for the device for this request.
221 * Each device has it's own set of clock inputs. This indexes
222 * which clock input to modify.
223 * @request_state: Request the state for the clock to be set to.
224 * MSG_CLOCK_SW_STATE_UNREQ: The IP does not require this clock,
225 * it can be disabled, regardless of the state of the device
226 * MSG_CLOCK_SW_STATE_AUTO: Allow the System Controller to
227 * automatically manage the state of this clock. If the device
228 * is enabled, then the clock is enabled. If the device is set
229 * to off or retention, then the clock is internally set as not
230 * being required by the device.(default)
231 * MSG_CLOCK_SW_STATE_REQ: Configure the clock to be enabled,
232 * regardless of the state of the device.
234 * Normally, all required clocks are managed by TISCI entity, this is used
235 * only for specific control *IF* required. Auto managed state is
236 * MSG_CLOCK_SW_STATE_AUTO, in other states, TISCI entity assume remote
237 * will explicitly control.
239 * Request type is TI_SCI_MSG_SET_CLOCK_STATE, response is a generic
240 * ACK or NACK message.
242 struct ti_sci_msg_req_set_clock_state {
243 /* Additional hdr->flags options */
244 #define MSG_FLAG_CLOCK_ALLOW_SSC TI_SCI_MSG_FLAG(8)
245 #define MSG_FLAG_CLOCK_ALLOW_FREQ_CHANGE TI_SCI_MSG_FLAG(9)
246 #define MSG_FLAG_CLOCK_INPUT_TERM TI_SCI_MSG_FLAG(10)
247 struct ti_sci_msg_hdr hdr;
250 #define MSG_CLOCK_SW_STATE_UNREQ 0
251 #define MSG_CLOCK_SW_STATE_AUTO 1
252 #define MSG_CLOCK_SW_STATE_REQ 2
257 * struct ti_sci_msg_req_get_clock_state - Request for clock state
258 * @hdr: Generic Header
259 * @dev_id: Device identifier this request is for
260 * @clk_id: Clock identifier for the device for this request.
261 * Each device has it's own set of clock inputs. This indexes
262 * which clock input to get state of.
264 * Request type is TI_SCI_MSG_GET_CLOCK_STATE, response is state
267 struct ti_sci_msg_req_get_clock_state {
268 struct ti_sci_msg_hdr hdr;
274 * struct ti_sci_msg_resp_get_clock_state - Response to get clock state
275 * @hdr: Generic Header
276 * @programmed_state: Any programmed state of the clock. This is one of
277 * MSG_CLOCK_SW_STATE* values.
278 * @current_state: Current state of the clock. This is one of:
279 * MSG_CLOCK_HW_STATE_NOT_READY: Clock is not ready
280 * MSG_CLOCK_HW_STATE_READY: Clock is ready
282 * Response to TI_SCI_MSG_GET_CLOCK_STATE.
284 struct ti_sci_msg_resp_get_clock_state {
285 struct ti_sci_msg_hdr hdr;
287 #define MSG_CLOCK_HW_STATE_NOT_READY 0
288 #define MSG_CLOCK_HW_STATE_READY 1
293 * struct ti_sci_msg_req_set_clock_parent - Set the clock parent
294 * @hdr: Generic Header
295 * @dev_id: Device identifier this request is for
296 * @clk_id: Clock identifier for the device for this request.
297 * Each device has it's own set of clock inputs. This indexes
298 * which clock input to modify.
299 * @parent_id: The new clock parent is selectable by an index via this
302 * Request type is TI_SCI_MSG_SET_CLOCK_PARENT, response is generic
303 * ACK / NACK message.
305 struct ti_sci_msg_req_set_clock_parent {
306 struct ti_sci_msg_hdr hdr;
313 * struct ti_sci_msg_req_get_clock_parent - Get the clock parent
314 * @hdr: Generic Header
315 * @dev_id: Device identifier this request is for
316 * @clk_id: Clock identifier for the device for this request.
317 * Each device has it's own set of clock inputs. This indexes
318 * which clock input to get the parent for.
320 * Request type is TI_SCI_MSG_GET_CLOCK_PARENT, response is parent information
322 struct ti_sci_msg_req_get_clock_parent {
323 struct ti_sci_msg_hdr hdr;
329 * struct ti_sci_msg_resp_get_clock_parent - Response with clock parent
330 * @hdr: Generic Header
331 * @parent_id: The current clock parent
333 * Response to TI_SCI_MSG_GET_CLOCK_PARENT.
335 struct ti_sci_msg_resp_get_clock_parent {
336 struct ti_sci_msg_hdr hdr;
341 * struct ti_sci_msg_req_get_clock_num_parents - Request to get clock parents
342 * @hdr: Generic header
343 * @dev_id: Device identifier this request is for
344 * @clk_id: Clock identifier for the device for this request.
346 * This request provides information about how many clock parent options
347 * are available for a given clock to a device. This is typically used
350 * Request type is TI_SCI_MSG_GET_NUM_CLOCK_PARENTS, response is appropriate
351 * message, or NACK in case of inability to satisfy request.
353 struct ti_sci_msg_req_get_clock_num_parents {
354 struct ti_sci_msg_hdr hdr;
360 * struct ti_sci_msg_resp_get_clock_num_parents - Response for get clk parents
361 * @hdr: Generic header
362 * @num_parents: Number of clock parents
364 * Response to TI_SCI_MSG_GET_NUM_CLOCK_PARENTS
366 struct ti_sci_msg_resp_get_clock_num_parents {
367 struct ti_sci_msg_hdr hdr;
372 * struct ti_sci_msg_req_query_clock_freq - Request to query a frequency
373 * @hdr: Generic Header
374 * @dev_id: Device identifier this request is for
375 * @min_freq_hz: The minimum allowable frequency in Hz. This is the minimum
376 * allowable programmed frequency and does not account for clock
377 * tolerances and jitter.
378 * @target_freq_hz: The target clock frequency. A frequency will be found
379 * as close to this target frequency as possible.
380 * @max_freq_hz: The maximum allowable frequency in Hz. This is the maximum
381 * allowable programmed frequency and does not account for clock
382 * tolerances and jitter.
383 * @clk_id: Clock identifier for the device for this request.
385 * NOTE: Normally clock frequency management is automatically done by TISCI
386 * entity. In case of specific requests, TISCI evaluates capability to achieve
387 * requested frequency within provided range and responds with
390 * Request type is TI_SCI_MSG_QUERY_CLOCK_FREQ, response is appropriate message,
391 * or NACK in case of inability to satisfy request.
393 struct ti_sci_msg_req_query_clock_freq {
394 struct ti_sci_msg_hdr hdr;
403 * struct ti_sci_msg_resp_query_clock_freq - Response to a clock frequency query
404 * @hdr: Generic Header
405 * @freq_hz: Frequency that is the best match in Hz.
407 * Response to request type TI_SCI_MSG_QUERY_CLOCK_FREQ. NOTE: if the request
408 * cannot be satisfied, the message will be of type NACK.
410 struct ti_sci_msg_resp_query_clock_freq {
411 struct ti_sci_msg_hdr hdr;
416 * struct ti_sci_msg_req_set_clock_freq - Request to setup a clock frequency
417 * @hdr: Generic Header
418 * @dev_id: Device identifier this request is for
419 * @min_freq_hz: The minimum allowable frequency in Hz. This is the minimum
420 * allowable programmed frequency and does not account for clock
421 * tolerances and jitter.
422 * @target_freq_hz: The target clock frequency. The clock will be programmed
423 * at a rate as close to this target frequency as possible.
424 * @max_freq_hz: The maximum allowable frequency in Hz. This is the maximum
425 * allowable programmed frequency and does not account for clock
426 * tolerances and jitter.
427 * @clk_id: Clock identifier for the device for this request.
429 * NOTE: Normally clock frequency management is automatically done by TISCI
430 * entity. In case of specific requests, TISCI evaluates capability to achieve
431 * requested range and responds with success/failure message.
433 * This sets the desired frequency for a clock within an allowable
434 * range. This message will fail on an enabled clock unless
435 * MSG_FLAG_CLOCK_ALLOW_FREQ_CHANGE is set for the clock. Additionally,
436 * if other clocks have their frequency modified due to this message,
437 * they also must have the MSG_FLAG_CLOCK_ALLOW_FREQ_CHANGE or be disabled.
439 * Calling set frequency on a clock input to the SoC pseudo-device will
440 * inform the PMMC of that clock's frequency. Setting a frequency of
441 * zero will indicate the clock is disabled.
443 * Calling set frequency on clock outputs from the SoC pseudo-device will
444 * function similarly to setting the clock frequency on a device.
446 * Request type is TI_SCI_MSG_SET_CLOCK_FREQ, response is a generic ACK/NACK
449 struct ti_sci_msg_req_set_clock_freq {
450 struct ti_sci_msg_hdr hdr;
459 * struct ti_sci_msg_req_get_clock_freq - Request to get the clock frequency
460 * @hdr: Generic Header
461 * @dev_id: Device identifier this request is for
462 * @clk_id: Clock identifier for the device for this request.
464 * NOTE: Normally clock frequency management is automatically done by TISCI
465 * entity. In some cases, clock frequencies are configured by host.
467 * Request type is TI_SCI_MSG_GET_CLOCK_FREQ, responded with clock frequency
468 * that the clock is currently at.
470 struct ti_sci_msg_req_get_clock_freq {
471 struct ti_sci_msg_hdr hdr;
477 * struct ti_sci_msg_resp_get_clock_freq - Response of clock frequency request
478 * @hdr: Generic Header
479 * @freq_hz: Frequency that the clock is currently on, in Hz.
481 * Response to request type TI_SCI_MSG_GET_CLOCK_FREQ.
483 struct ti_sci_msg_resp_get_clock_freq {
484 struct ti_sci_msg_hdr hdr;
488 #endif /* __TI_SCI_H */