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. Set to 255 if clock ID is
206 * greater than or equal to 255.
207 * @request_state: Request the state for the clock to be set to.
208 * MSG_CLOCK_SW_STATE_UNREQ: The IP does not require this clock,
209 * it can be disabled, regardless of the state of the device
210 * MSG_CLOCK_SW_STATE_AUTO: Allow the System Controller to
211 * automatically manage the state of this clock. If the device
212 * is enabled, then the clock is enabled. If the device is set
213 * to off or retention, then the clock is internally set as not
214 * being required by the device.(default)
215 * MSG_CLOCK_SW_STATE_REQ: Configure the clock to be enabled,
216 * regardless of the state of the device.
217 * @clk_id_32: Clock identifier for the device for this request.
218 * Only to be used if the clock ID is greater than or equal to
221 * Normally, all required clocks are managed by TISCI entity, this is used
222 * only for specific control *IF* required. Auto managed state is
223 * MSG_CLOCK_SW_STATE_AUTO, in other states, TISCI entity assume remote
224 * will explicitly control.
226 * Request type is TI_SCI_MSG_SET_CLOCK_STATE, response is a generic
227 * ACK or NACK message.
229 struct ti_sci_msg_req_set_clock_state {
230 /* Additional hdr->flags options */
231 #define MSG_FLAG_CLOCK_ALLOW_SSC TI_SCI_MSG_FLAG(8)
232 #define MSG_FLAG_CLOCK_ALLOW_FREQ_CHANGE TI_SCI_MSG_FLAG(9)
233 #define MSG_FLAG_CLOCK_INPUT_TERM TI_SCI_MSG_FLAG(10)
234 struct ti_sci_msg_hdr hdr;
237 #define MSG_CLOCK_SW_STATE_UNREQ 0
238 #define MSG_CLOCK_SW_STATE_AUTO 1
239 #define MSG_CLOCK_SW_STATE_REQ 2
245 * struct ti_sci_msg_req_get_clock_state - Request for clock state
246 * @hdr: Generic Header
247 * @dev_id: Device identifier this request is for
248 * @clk_id: Clock identifier for the device for this request.
249 * Each device has it's own set of clock inputs. This indexes
250 * which clock input to get state of. Set to 255 if the clock
251 * ID is greater than or equal to 255.
252 * @clk_id_32: Clock identifier for the device for the request.
253 * Only to be used if the clock ID is greater than or equal to
256 * Request type is TI_SCI_MSG_GET_CLOCK_STATE, response is state
259 struct ti_sci_msg_req_get_clock_state {
260 struct ti_sci_msg_hdr hdr;
267 * struct ti_sci_msg_resp_get_clock_state - Response to get clock state
268 * @hdr: Generic Header
269 * @programmed_state: Any programmed state of the clock. This is one of
270 * MSG_CLOCK_SW_STATE* values.
271 * @current_state: Current state of the clock. This is one of:
272 * MSG_CLOCK_HW_STATE_NOT_READY: Clock is not ready
273 * MSG_CLOCK_HW_STATE_READY: Clock is ready
275 * Response to TI_SCI_MSG_GET_CLOCK_STATE.
277 struct ti_sci_msg_resp_get_clock_state {
278 struct ti_sci_msg_hdr hdr;
280 #define MSG_CLOCK_HW_STATE_NOT_READY 0
281 #define MSG_CLOCK_HW_STATE_READY 1
286 * struct ti_sci_msg_req_set_clock_parent - Set the clock parent
287 * @hdr: Generic Header
288 * @dev_id: Device identifier this request is for
289 * @clk_id: Clock identifier for the device for this request.
290 * Each device has it's own set of clock inputs. This indexes
291 * which clock input to modify. Set to 255 if clock ID is
292 * greater than or equal to 255.
293 * @parent_id: The new clock parent is selectable by an index via this
294 * parameter. Set to 255 if clock ID is greater than or
296 * @clk_id_32: Clock identifier if @clk_id field is 255.
297 * @parent_id_32: Parent identifier if @parent_id is 255.
299 * Request type is TI_SCI_MSG_SET_CLOCK_PARENT, response is generic
300 * ACK / NACK message.
302 struct ti_sci_msg_req_set_clock_parent {
303 struct ti_sci_msg_hdr hdr;
312 * struct ti_sci_msg_req_get_clock_parent - Get the clock parent
313 * @hdr: Generic Header
314 * @dev_id: Device identifier this request is for
315 * @clk_id: Clock identifier for the device for this request.
316 * Each device has it's own set of clock inputs. This indexes
317 * which clock input to get the parent for. If this field
318 * contains 255, the actual clock identifier is stored in
320 * @clk_id_32: Clock identifier if the @clk_id field contains 255.
322 * Request type is TI_SCI_MSG_GET_CLOCK_PARENT, response is parent information
324 struct ti_sci_msg_req_get_clock_parent {
325 struct ti_sci_msg_hdr hdr;
332 * struct ti_sci_msg_resp_get_clock_parent - Response with clock parent
333 * @hdr: Generic Header
334 * @parent_id: The current clock parent. If set to 255, the current parent
335 * ID can be found from the @parent_id_32 field.
336 * @parent_id_32: Current clock parent if @parent_id field is set to
339 * Response to TI_SCI_MSG_GET_CLOCK_PARENT.
341 struct ti_sci_msg_resp_get_clock_parent {
342 struct ti_sci_msg_hdr hdr;
348 * struct ti_sci_msg_req_get_clock_num_parents - Request to get clock parents
349 * @hdr: Generic header
350 * @dev_id: Device identifier this request is for
351 * @clk_id: Clock identifier for the device for this request. Set to
352 * 255 if clock ID is greater than or equal to 255.
353 * @clk_id_32: Clock identifier if the @clk_id field contains 255.
355 * This request provides information about how many clock parent options
356 * are available for a given clock to a device. This is typically used
359 * Request type is TI_SCI_MSG_GET_NUM_CLOCK_PARENTS, response is appropriate
360 * message, or NACK in case of inability to satisfy request.
362 struct ti_sci_msg_req_get_clock_num_parents {
363 struct ti_sci_msg_hdr hdr;
370 * struct ti_sci_msg_resp_get_clock_num_parents - Response for get clk parents
371 * @hdr: Generic header
372 * @num_parents: Number of clock parents. If set to 255, the actual
373 * number of parents is stored into @num_parents_32
375 * @num_parents_32: Number of clock parents if @num_parents field is
378 * Response to TI_SCI_MSG_GET_NUM_CLOCK_PARENTS
380 struct ti_sci_msg_resp_get_clock_num_parents {
381 struct ti_sci_msg_hdr hdr;
387 * struct ti_sci_msg_req_query_clock_freq - Request to query a frequency
388 * @hdr: Generic Header
389 * @dev_id: Device identifier this request is for
390 * @min_freq_hz: The minimum allowable frequency in Hz. This is the minimum
391 * allowable programmed frequency and does not account for clock
392 * tolerances and jitter.
393 * @target_freq_hz: The target clock frequency. A frequency will be found
394 * as close to this target frequency as possible.
395 * @max_freq_hz: The maximum allowable frequency in Hz. This is the maximum
396 * allowable programmed frequency and does not account for clock
397 * tolerances and jitter.
398 * @clk_id: Clock identifier for the device for this request. Set to
399 * 255 if clock identifier is greater than or equal to 255.
400 * @clk_id_32: Clock identifier if @clk_id is set to 255.
402 * NOTE: Normally clock frequency management is automatically done by TISCI
403 * entity. In case of specific requests, TISCI evaluates capability to achieve
404 * requested frequency within provided range and responds with
407 * Request type is TI_SCI_MSG_QUERY_CLOCK_FREQ, response is appropriate message,
408 * or NACK in case of inability to satisfy request.
410 struct ti_sci_msg_req_query_clock_freq {
411 struct ti_sci_msg_hdr hdr;
421 * struct ti_sci_msg_resp_query_clock_freq - Response to a clock frequency query
422 * @hdr: Generic Header
423 * @freq_hz: Frequency that is the best match in Hz.
425 * Response to request type TI_SCI_MSG_QUERY_CLOCK_FREQ. NOTE: if the request
426 * cannot be satisfied, the message will be of type NACK.
428 struct ti_sci_msg_resp_query_clock_freq {
429 struct ti_sci_msg_hdr hdr;
434 * struct ti_sci_msg_req_set_clock_freq - Request to setup a clock frequency
435 * @hdr: Generic Header
436 * @dev_id: Device identifier this request is for
437 * @min_freq_hz: The minimum allowable frequency in Hz. This is the minimum
438 * allowable programmed frequency and does not account for clock
439 * tolerances and jitter.
440 * @target_freq_hz: The target clock frequency. The clock will be programmed
441 * at a rate as close to this target frequency as possible.
442 * @max_freq_hz: The maximum allowable frequency in Hz. This is the maximum
443 * allowable programmed frequency and does not account for clock
444 * tolerances and jitter.
445 * @clk_id: Clock identifier for the device for this request. Set to
446 * 255 if clock ID is greater than or equal to 255.
447 * @clk_id_32: Clock identifier if @clk_id field is set to 255.
449 * NOTE: Normally clock frequency management is automatically done by TISCI
450 * entity. In case of specific requests, TISCI evaluates capability to achieve
451 * requested range and responds with success/failure message.
453 * This sets the desired frequency for a clock within an allowable
454 * range. This message will fail on an enabled clock unless
455 * MSG_FLAG_CLOCK_ALLOW_FREQ_CHANGE is set for the clock. Additionally,
456 * if other clocks have their frequency modified due to this message,
457 * they also must have the MSG_FLAG_CLOCK_ALLOW_FREQ_CHANGE or be disabled.
459 * Calling set frequency on a clock input to the SoC pseudo-device will
460 * inform the PMMC of that clock's frequency. Setting a frequency of
461 * zero will indicate the clock is disabled.
463 * Calling set frequency on clock outputs from the SoC pseudo-device will
464 * function similarly to setting the clock frequency on a device.
466 * Request type is TI_SCI_MSG_SET_CLOCK_FREQ, response is a generic ACK/NACK
469 struct ti_sci_msg_req_set_clock_freq {
470 struct ti_sci_msg_hdr hdr;
480 * struct ti_sci_msg_req_get_clock_freq - Request to get the clock frequency
481 * @hdr: Generic Header
482 * @dev_id: Device identifier this request is for
483 * @clk_id: Clock identifier for the device for this request. Set to
484 * 255 if clock ID is greater than or equal to 255.
485 * @clk_id_32: Clock identifier if @clk_id field is set to 255.
487 * NOTE: Normally clock frequency management is automatically done by TISCI
488 * entity. In some cases, clock frequencies are configured by host.
490 * Request type is TI_SCI_MSG_GET_CLOCK_FREQ, responded with clock frequency
491 * that the clock is currently at.
493 struct ti_sci_msg_req_get_clock_freq {
494 struct ti_sci_msg_hdr hdr;
501 * struct ti_sci_msg_resp_get_clock_freq - Response of clock frequency request
502 * @hdr: Generic Header
503 * @freq_hz: Frequency that the clock is currently on, in Hz.
505 * Response to request type TI_SCI_MSG_GET_CLOCK_FREQ.
507 struct ti_sci_msg_resp_get_clock_freq {
508 struct ti_sci_msg_hdr hdr;
512 #define TI_SCI_IRQ_SECONDARY_HOST_INVALID 0xff
515 * struct ti_sci_msg_req_get_resource_range - Request to get a host's assigned
516 * range of resources.
517 * @hdr: Generic Header
518 * @type: Unique resource assignment type
519 * @subtype: Resource assignment subtype within the resource type.
520 * @secondary_host: Host processing entity to which the resources are
521 * allocated. This is required only when the destination
522 * host id id different from ti sci interface host id,
523 * else TI_SCI_IRQ_SECONDARY_HOST_INVALID can be passed.
525 * Request type is TI_SCI_MSG_GET_RESOURCE_RANGE. Responded with requested
526 * resource range which is of type TI_SCI_MSG_GET_RESOURCE_RANGE.
528 struct ti_sci_msg_req_get_resource_range {
529 struct ti_sci_msg_hdr hdr;
530 #define MSG_RM_RESOURCE_TYPE_MASK GENMASK(9, 0)
531 #define MSG_RM_RESOURCE_SUBTYPE_MASK GENMASK(5, 0)
538 * struct ti_sci_msg_resp_get_resource_range - Response to resource get range.
539 * @hdr: Generic Header
540 * @range_start: Start index of the resource range.
541 * @range_num: Number of resources in the range.
543 * Response to request TI_SCI_MSG_GET_RESOURCE_RANGE.
545 struct ti_sci_msg_resp_get_resource_range {
546 struct ti_sci_msg_hdr hdr;
552 * struct ti_sci_msg_req_manage_irq - Request to configure/release the route
553 * between the dev and the host.
554 * @hdr: Generic Header
555 * @valid_params: Bit fields defining the validity of interrupt source
556 * parameters. If a bit is not set, then corresponding
557 * field is not valid and will not be used for route set.
558 * Bit field definitions:
559 * 0 - Valid bit for @dst_id
560 * 1 - Valid bit for @dst_host_irq
561 * 2 - Valid bit for @ia_id
562 * 3 - Valid bit for @vint
563 * 4 - Valid bit for @global_event
564 * 5 - Valid bit for @vint_status_bit_index
565 * 31 - Valid bit for @secondary_host
566 * @src_id: IRQ source peripheral ID.
567 * @src_index: IRQ source index within the peripheral
568 * @dst_id: IRQ Destination ID. Based on the architecture it can be
569 * IRQ controller or host processor ID.
570 * @dst_host_irq: IRQ number of the destination host IRQ controller
571 * @ia_id: Device ID of the interrupt aggregator in which the
573 * @vint: Virtual interrupt number if the interrupt route
574 * is through an interrupt aggregator.
575 * @global_event: Global event that is to be mapped to interrupt
576 * aggregator virtual interrupt status bit.
577 * @vint_status_bit: Virtual interrupt status bit if the interrupt route
578 * utilizes an interrupt aggregator status bit.
579 * @secondary_host: Host ID of the IRQ destination computing entity. This is
580 * required only when destination host id is different
581 * from ti sci interface host id.
583 * Request type is TI_SCI_MSG_SET/RELEASE_IRQ.
584 * Response is generic ACK / NACK message.
586 struct ti_sci_msg_req_manage_irq {
587 struct ti_sci_msg_hdr hdr;
588 #define MSG_FLAG_DST_ID_VALID TI_SCI_MSG_FLAG(0)
589 #define MSG_FLAG_DST_HOST_IRQ_VALID TI_SCI_MSG_FLAG(1)
590 #define MSG_FLAG_IA_ID_VALID TI_SCI_MSG_FLAG(2)
591 #define MSG_FLAG_VINT_VALID TI_SCI_MSG_FLAG(3)
592 #define MSG_FLAG_GLB_EVNT_VALID TI_SCI_MSG_FLAG(4)
593 #define MSG_FLAG_VINT_STS_BIT_VALID TI_SCI_MSG_FLAG(5)
594 #define MSG_FLAG_SHOST_VALID TI_SCI_MSG_FLAG(31)
607 #endif /* __TI_SCI_H */