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
38 /* Resource Management Requests */
39 #define TI_SCI_MSG_GET_RESOURCE_RANGE 0x1500
42 #define TI_SCI_MSG_SET_IRQ 0x1000
43 #define TI_SCI_MSG_FREE_IRQ 0x1001
46 * struct ti_sci_msg_hdr - Generic Message Header for All messages and responses
47 * @type: Type of messages: One of TI_SCI_MSG* values
48 * @host: Host of the message
49 * @seq: Message identifier indicating a transfer sequence
50 * @flags: Flag for the message
52 struct ti_sci_msg_hdr {
56 #define TI_SCI_MSG_FLAG(val) (1 << (val))
57 #define TI_SCI_FLAG_REQ_GENERIC_NORESPONSE 0x0
58 #define TI_SCI_FLAG_REQ_ACK_ON_RECEIVED TI_SCI_MSG_FLAG(0)
59 #define TI_SCI_FLAG_REQ_ACK_ON_PROCESSED TI_SCI_MSG_FLAG(1)
60 #define TI_SCI_FLAG_RESP_GENERIC_NACK 0x0
61 #define TI_SCI_FLAG_RESP_GENERIC_ACK TI_SCI_MSG_FLAG(1)
62 /* Additional Flags */
67 * struct ti_sci_msg_resp_version - Response for a message
68 * @hdr: Generic header
69 * @firmware_description: String describing the firmware
70 * @firmware_revision: Firmware revision
71 * @abi_major: Major version of the ABI that firmware supports
72 * @abi_minor: Minor version of the ABI that firmware supports
74 * In general, ABI version changes follow the rule that minor version increments
75 * are backward compatible. Major revision changes in ABI may not be
76 * backward compatible.
78 * Response to a generic message with message type TI_SCI_MSG_VERSION
80 struct ti_sci_msg_resp_version {
81 struct ti_sci_msg_hdr hdr;
82 char firmware_description[32];
83 u16 firmware_revision;
89 * struct ti_sci_msg_req_reboot - Reboot the SoC
90 * @hdr: Generic Header
92 * Request type is TI_SCI_MSG_SYS_RESET, responded with a generic
95 struct ti_sci_msg_req_reboot {
96 struct ti_sci_msg_hdr hdr;
100 * struct ti_sci_msg_req_set_device_state - Set the desired state of the device
101 * @hdr: Generic header
102 * @id: Indicates which device to modify
103 * @reserved: Reserved space in message, must be 0 for backward compatibility
104 * @state: The desired state of the device.
106 * Certain flags can also be set to alter the device state:
107 * + MSG_FLAG_DEVICE_WAKE_ENABLED - Configure the device to be a wake source.
108 * The meaning of this flag will vary slightly from device to device and from
109 * SoC to SoC but it generally allows the device to wake the SoC out of deep
111 * + MSG_FLAG_DEVICE_RESET_ISO - Enable reset isolation for this device.
112 * + MSG_FLAG_DEVICE_EXCLUSIVE - Claim this device exclusively. When passed
113 * with STATE_RETENTION or STATE_ON, it will claim the device exclusively.
114 * If another host already has this device set to STATE_RETENTION or STATE_ON,
115 * the message will fail. Once successful, other hosts attempting to set
116 * STATE_RETENTION or STATE_ON will fail.
118 * Request type is TI_SCI_MSG_SET_DEVICE_STATE, responded with a generic
121 struct ti_sci_msg_req_set_device_state {
122 /* Additional hdr->flags options */
123 #define MSG_FLAG_DEVICE_WAKE_ENABLED TI_SCI_MSG_FLAG(8)
124 #define MSG_FLAG_DEVICE_RESET_ISO TI_SCI_MSG_FLAG(9)
125 #define MSG_FLAG_DEVICE_EXCLUSIVE TI_SCI_MSG_FLAG(10)
126 struct ti_sci_msg_hdr hdr;
130 #define MSG_DEVICE_SW_STATE_AUTO_OFF 0
131 #define MSG_DEVICE_SW_STATE_RETENTION 1
132 #define MSG_DEVICE_SW_STATE_ON 2
137 * struct ti_sci_msg_req_get_device_state - Request to get device.
138 * @hdr: Generic header
139 * @id: Device Identifier
141 * Request type is TI_SCI_MSG_GET_DEVICE_STATE, responded device state
144 struct ti_sci_msg_req_get_device_state {
145 struct ti_sci_msg_hdr hdr;
150 * struct ti_sci_msg_resp_get_device_state - Response to get device request.
151 * @hdr: Generic header
152 * @context_loss_count: Indicates how many times the device has lost context. A
153 * driver can use this monotonic counter to determine if the device has
154 * lost context since the last time this message was exchanged.
155 * @resets: Programmed state of the reset lines.
156 * @programmed_state: The state as programmed by set_device.
157 * - Uses the MSG_DEVICE_SW_* macros
158 * @current_state: The actual state of the hardware.
160 * Response to request TI_SCI_MSG_GET_DEVICE_STATE.
162 struct ti_sci_msg_resp_get_device_state {
163 struct ti_sci_msg_hdr hdr;
164 u32 context_loss_count;
167 #define MSG_DEVICE_HW_STATE_OFF 0
168 #define MSG_DEVICE_HW_STATE_ON 1
169 #define MSG_DEVICE_HW_STATE_TRANS 2
174 * struct ti_sci_msg_req_set_device_resets - Set the desired resets
175 * configuration of the device
176 * @hdr: Generic header
177 * @id: Indicates which device to modify
178 * @resets: A bit field of resets for the device. The meaning, behavior,
179 * and usage of the reset flags are device specific. 0 for a bit
180 * indicates releasing the reset represented by that bit while 1
181 * indicates keeping it held.
183 * Request type is TI_SCI_MSG_SET_DEVICE_RESETS, responded with a generic
186 struct ti_sci_msg_req_set_device_resets {
187 struct ti_sci_msg_hdr hdr;
193 * struct ti_sci_msg_req_set_clock_state - Request to setup a Clock state
194 * @hdr: Generic Header, Certain flags can be set specific to the clocks:
195 * MSG_FLAG_CLOCK_ALLOW_SSC: Allow this clock to be modified
196 * via spread spectrum clocking.
197 * MSG_FLAG_CLOCK_ALLOW_FREQ_CHANGE: Allow this clock's
198 * frequency to be changed while it is running so long as it
199 * is within the min/max limits.
200 * MSG_FLAG_CLOCK_INPUT_TERM: Enable input termination, this
201 * is only applicable to clock inputs on the SoC pseudo-device.
202 * @dev_id: Device identifier this request is for
203 * @clk_id: Clock identifier for the device for this request.
204 * Each device has it's own set of clock inputs. This indexes
205 * which clock input to modify.
206 * @request_state: Request the state for the clock to be set to.
207 * MSG_CLOCK_SW_STATE_UNREQ: The IP does not require this clock,
208 * it can be disabled, regardless of the state of the device
209 * MSG_CLOCK_SW_STATE_AUTO: Allow the System Controller to
210 * automatically manage the state of this clock. If the device
211 * is enabled, then the clock is enabled. If the device is set
212 * to off or retention, then the clock is internally set as not
213 * being required by the device.(default)
214 * MSG_CLOCK_SW_STATE_REQ: Configure the clock to be enabled,
215 * regardless of the state of the device.
217 * Normally, all required clocks are managed by TISCI entity, this is used
218 * only for specific control *IF* required. Auto managed state is
219 * MSG_CLOCK_SW_STATE_AUTO, in other states, TISCI entity assume remote
220 * will explicitly control.
222 * Request type is TI_SCI_MSG_SET_CLOCK_STATE, response is a generic
223 * ACK or NACK message.
225 struct ti_sci_msg_req_set_clock_state {
226 /* Additional hdr->flags options */
227 #define MSG_FLAG_CLOCK_ALLOW_SSC TI_SCI_MSG_FLAG(8)
228 #define MSG_FLAG_CLOCK_ALLOW_FREQ_CHANGE TI_SCI_MSG_FLAG(9)
229 #define MSG_FLAG_CLOCK_INPUT_TERM TI_SCI_MSG_FLAG(10)
230 struct ti_sci_msg_hdr hdr;
233 #define MSG_CLOCK_SW_STATE_UNREQ 0
234 #define MSG_CLOCK_SW_STATE_AUTO 1
235 #define MSG_CLOCK_SW_STATE_REQ 2
240 * struct ti_sci_msg_req_get_clock_state - Request for clock state
241 * @hdr: Generic Header
242 * @dev_id: Device identifier this request is for
243 * @clk_id: Clock identifier for the device for this request.
244 * Each device has it's own set of clock inputs. This indexes
245 * which clock input to get state of.
247 * Request type is TI_SCI_MSG_GET_CLOCK_STATE, response is state
250 struct ti_sci_msg_req_get_clock_state {
251 struct ti_sci_msg_hdr hdr;
257 * struct ti_sci_msg_resp_get_clock_state - Response to get clock state
258 * @hdr: Generic Header
259 * @programmed_state: Any programmed state of the clock. This is one of
260 * MSG_CLOCK_SW_STATE* values.
261 * @current_state: Current state of the clock. This is one of:
262 * MSG_CLOCK_HW_STATE_NOT_READY: Clock is not ready
263 * MSG_CLOCK_HW_STATE_READY: Clock is ready
265 * Response to TI_SCI_MSG_GET_CLOCK_STATE.
267 struct ti_sci_msg_resp_get_clock_state {
268 struct ti_sci_msg_hdr hdr;
270 #define MSG_CLOCK_HW_STATE_NOT_READY 0
271 #define MSG_CLOCK_HW_STATE_READY 1
276 * struct ti_sci_msg_req_set_clock_parent - Set the clock parent
277 * @hdr: Generic Header
278 * @dev_id: Device identifier this request is for
279 * @clk_id: Clock identifier for the device for this request.
280 * Each device has it's own set of clock inputs. This indexes
281 * which clock input to modify.
282 * @parent_id: The new clock parent is selectable by an index via this
285 * Request type is TI_SCI_MSG_SET_CLOCK_PARENT, response is generic
286 * ACK / NACK message.
288 struct ti_sci_msg_req_set_clock_parent {
289 struct ti_sci_msg_hdr hdr;
296 * struct ti_sci_msg_req_get_clock_parent - Get the clock parent
297 * @hdr: Generic Header
298 * @dev_id: Device identifier this request is for
299 * @clk_id: Clock identifier for the device for this request.
300 * Each device has it's own set of clock inputs. This indexes
301 * which clock input to get the parent for.
303 * Request type is TI_SCI_MSG_GET_CLOCK_PARENT, response is parent information
305 struct ti_sci_msg_req_get_clock_parent {
306 struct ti_sci_msg_hdr hdr;
312 * struct ti_sci_msg_resp_get_clock_parent - Response with clock parent
313 * @hdr: Generic Header
314 * @parent_id: The current clock parent
316 * Response to TI_SCI_MSG_GET_CLOCK_PARENT.
318 struct ti_sci_msg_resp_get_clock_parent {
319 struct ti_sci_msg_hdr hdr;
324 * struct ti_sci_msg_req_get_clock_num_parents - Request to get clock parents
325 * @hdr: Generic header
326 * @dev_id: Device identifier this request is for
327 * @clk_id: Clock identifier for the device for this request.
329 * This request provides information about how many clock parent options
330 * are available for a given clock to a device. This is typically used
333 * Request type is TI_SCI_MSG_GET_NUM_CLOCK_PARENTS, response is appropriate
334 * message, or NACK in case of inability to satisfy request.
336 struct ti_sci_msg_req_get_clock_num_parents {
337 struct ti_sci_msg_hdr hdr;
343 * struct ti_sci_msg_resp_get_clock_num_parents - Response for get clk parents
344 * @hdr: Generic header
345 * @num_parents: Number of clock parents
347 * Response to TI_SCI_MSG_GET_NUM_CLOCK_PARENTS
349 struct ti_sci_msg_resp_get_clock_num_parents {
350 struct ti_sci_msg_hdr hdr;
355 * struct ti_sci_msg_req_query_clock_freq - Request to query a frequency
356 * @hdr: Generic Header
357 * @dev_id: Device identifier this request is for
358 * @min_freq_hz: The minimum allowable frequency in Hz. This is the minimum
359 * allowable programmed frequency and does not account for clock
360 * tolerances and jitter.
361 * @target_freq_hz: The target clock frequency. A frequency will be found
362 * as close to this target frequency as possible.
363 * @max_freq_hz: The maximum allowable frequency in Hz. This is the maximum
364 * allowable programmed frequency and does not account for clock
365 * tolerances and jitter.
366 * @clk_id: Clock identifier for the device for this request.
368 * NOTE: Normally clock frequency management is automatically done by TISCI
369 * entity. In case of specific requests, TISCI evaluates capability to achieve
370 * requested frequency within provided range and responds with
373 * Request type is TI_SCI_MSG_QUERY_CLOCK_FREQ, response is appropriate message,
374 * or NACK in case of inability to satisfy request.
376 struct ti_sci_msg_req_query_clock_freq {
377 struct ti_sci_msg_hdr hdr;
386 * struct ti_sci_msg_resp_query_clock_freq - Response to a clock frequency query
387 * @hdr: Generic Header
388 * @freq_hz: Frequency that is the best match in Hz.
390 * Response to request type TI_SCI_MSG_QUERY_CLOCK_FREQ. NOTE: if the request
391 * cannot be satisfied, the message will be of type NACK.
393 struct ti_sci_msg_resp_query_clock_freq {
394 struct ti_sci_msg_hdr hdr;
399 * struct ti_sci_msg_req_set_clock_freq - Request to setup a clock frequency
400 * @hdr: Generic Header
401 * @dev_id: Device identifier this request is for
402 * @min_freq_hz: The minimum allowable frequency in Hz. This is the minimum
403 * allowable programmed frequency and does not account for clock
404 * tolerances and jitter.
405 * @target_freq_hz: The target clock frequency. The clock will be programmed
406 * at a rate as close to this target frequency as possible.
407 * @max_freq_hz: The maximum allowable frequency in Hz. This is the maximum
408 * allowable programmed frequency and does not account for clock
409 * tolerances and jitter.
410 * @clk_id: Clock identifier for the device for this request.
412 * NOTE: Normally clock frequency management is automatically done by TISCI
413 * entity. In case of specific requests, TISCI evaluates capability to achieve
414 * requested range and responds with success/failure message.
416 * This sets the desired frequency for a clock within an allowable
417 * range. This message will fail on an enabled clock unless
418 * MSG_FLAG_CLOCK_ALLOW_FREQ_CHANGE is set for the clock. Additionally,
419 * if other clocks have their frequency modified due to this message,
420 * they also must have the MSG_FLAG_CLOCK_ALLOW_FREQ_CHANGE or be disabled.
422 * Calling set frequency on a clock input to the SoC pseudo-device will
423 * inform the PMMC of that clock's frequency. Setting a frequency of
424 * zero will indicate the clock is disabled.
426 * Calling set frequency on clock outputs from the SoC pseudo-device will
427 * function similarly to setting the clock frequency on a device.
429 * Request type is TI_SCI_MSG_SET_CLOCK_FREQ, response is a generic ACK/NACK
432 struct ti_sci_msg_req_set_clock_freq {
433 struct ti_sci_msg_hdr hdr;
442 * struct ti_sci_msg_req_get_clock_freq - Request to get the clock frequency
443 * @hdr: Generic Header
444 * @dev_id: Device identifier this request is for
445 * @clk_id: Clock identifier for the device for this request.
447 * NOTE: Normally clock frequency management is automatically done by TISCI
448 * entity. In some cases, clock frequencies are configured by host.
450 * Request type is TI_SCI_MSG_GET_CLOCK_FREQ, responded with clock frequency
451 * that the clock is currently at.
453 struct ti_sci_msg_req_get_clock_freq {
454 struct ti_sci_msg_hdr hdr;
460 * struct ti_sci_msg_resp_get_clock_freq - Response of clock frequency request
461 * @hdr: Generic Header
462 * @freq_hz: Frequency that the clock is currently on, in Hz.
464 * Response to request type TI_SCI_MSG_GET_CLOCK_FREQ.
466 struct ti_sci_msg_resp_get_clock_freq {
467 struct ti_sci_msg_hdr hdr;
471 #define TI_SCI_IRQ_SECONDARY_HOST_INVALID 0xff
474 * struct ti_sci_msg_req_get_resource_range - Request to get a host's assigned
475 * range of resources.
476 * @hdr: Generic Header
477 * @type: Unique resource assignment type
478 * @subtype: Resource assignment subtype within the resource type.
479 * @secondary_host: Host processing entity to which the resources are
480 * allocated. This is required only when the destination
481 * host id id different from ti sci interface host id,
482 * else TI_SCI_IRQ_SECONDARY_HOST_INVALID can be passed.
484 * Request type is TI_SCI_MSG_GET_RESOURCE_RANGE. Responded with requested
485 * resource range which is of type TI_SCI_MSG_GET_RESOURCE_RANGE.
487 struct ti_sci_msg_req_get_resource_range {
488 struct ti_sci_msg_hdr hdr;
489 #define MSG_RM_RESOURCE_TYPE_MASK GENMASK(9, 0)
490 #define MSG_RM_RESOURCE_SUBTYPE_MASK GENMASK(5, 0)
497 * struct ti_sci_msg_resp_get_resource_range - Response to resource get range.
498 * @hdr: Generic Header
499 * @range_start: Start index of the resource range.
500 * @range_num: Number of resources in the range.
502 * Response to request TI_SCI_MSG_GET_RESOURCE_RANGE.
504 struct ti_sci_msg_resp_get_resource_range {
505 struct ti_sci_msg_hdr hdr;
511 * struct ti_sci_msg_req_manage_irq - Request to configure/release the route
512 * between the dev and the host.
513 * @hdr: Generic Header
514 * @valid_params: Bit fields defining the validity of interrupt source
515 * parameters. If a bit is not set, then corresponding
516 * field is not valid and will not be used for route set.
517 * Bit field definitions:
518 * 0 - Valid bit for @dst_id
519 * 1 - Valid bit for @dst_host_irq
520 * 2 - Valid bit for @ia_id
521 * 3 - Valid bit for @vint
522 * 4 - Valid bit for @global_event
523 * 5 - Valid bit for @vint_status_bit_index
524 * 31 - Valid bit for @secondary_host
525 * @src_id: IRQ source peripheral ID.
526 * @src_index: IRQ source index within the peripheral
527 * @dst_id: IRQ Destination ID. Based on the architecture it can be
528 * IRQ controller or host processor ID.
529 * @dst_host_irq: IRQ number of the destination host IRQ controller
530 * @ia_id: Device ID of the interrupt aggregator in which the
532 * @vint: Virtual interrupt number if the interrupt route
533 * is through an interrupt aggregator.
534 * @global_event: Global event that is to be mapped to interrupt
535 * aggregator virtual interrupt status bit.
536 * @vint_status_bit: Virtual interrupt status bit if the interrupt route
537 * utilizes an interrupt aggregator status bit.
538 * @secondary_host: Host ID of the IRQ destination computing entity. This is
539 * required only when destination host id is different
540 * from ti sci interface host id.
542 * Request type is TI_SCI_MSG_SET/RELEASE_IRQ.
543 * Response is generic ACK / NACK message.
545 struct ti_sci_msg_req_manage_irq {
546 struct ti_sci_msg_hdr hdr;
547 #define MSG_FLAG_DST_ID_VALID TI_SCI_MSG_FLAG(0)
548 #define MSG_FLAG_DST_HOST_IRQ_VALID TI_SCI_MSG_FLAG(1)
549 #define MSG_FLAG_IA_ID_VALID TI_SCI_MSG_FLAG(2)
550 #define MSG_FLAG_VINT_VALID TI_SCI_MSG_FLAG(3)
551 #define MSG_FLAG_GLB_EVNT_VALID TI_SCI_MSG_FLAG(4)
552 #define MSG_FLAG_VINT_STS_BIT_VALID TI_SCI_MSG_FLAG(5)
553 #define MSG_FLAG_SHOST_VALID TI_SCI_MSG_FLAG(31)
566 #endif /* __TI_SCI_H */