blob: 2fc9063ff52e8993261682040df1c0620504338b [file] [log] [blame]
Lokesh Vutla32cd2512018-08-27 15:57:32 +05301/* SPDX-License-Identifier: BSD-3-Clause */
2/*
3 * Texas Instruments System Control Interface (TISCI) Protocol
4 *
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
8 *
9 * Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/
10 * Based on drivers/firmware/ti_sci.h from Linux.
11 *
12 */
13
14#ifndef __TI_SCI_H
15#define __TI_SCI_H
16
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
Andreas Dannenbergdcfc52a2018-08-27 15:57:33 +053025#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
Lokesh Vutla32cd2512018-08-27 15:57:32 +053028
Andreas Dannenberg7bc33042018-08-27 15:57:34 +053029/* Device requests */
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
33
Lokesh Vutla9b871812018-08-27 15:57:35 +053034/* Clock requests */
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
43
Lokesh Vutla32cd2512018-08-27 15:57:32 +053044/**
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
50 */
51struct ti_sci_msg_hdr {
52 u16 type;
53 u8 host;
54 u8 seq;
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 */
62 u32 flags;
63} __packed;
64
65/**
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.
70 */
71struct ti_sci_secure_msg_hdr {
72 u16 checksum;
73 u16 reserved;
74} __packed;
75
76/**
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
83 *
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.
87 *
88 * Response to a generic message with message type TI_SCI_MSG_VERSION
89 */
90struct ti_sci_msg_resp_version {
91 struct ti_sci_msg_hdr hdr;
92 char firmware_description[32];
93 u16 firmware_revision;
94 u8 abi_major;
95 u8 abi_minor;
96} __packed;
97
Andreas Dannenbergdcfc52a2018-08-27 15:57:33 +053098/**
Andreas Dannenbergf369b0f2018-08-27 15:57:36 +053099 * struct ti_sci_msg_req_reboot - Reboot the SoC
100 * @hdr: Generic Header
101 *
102 * Request type is TI_SCI_MSG_SYS_RESET, responded with a generic
103 * ACK/NACK message.
104 */
105struct ti_sci_msg_req_reboot {
106 struct ti_sci_msg_hdr hdr;
107} __packed;
108
109/**
Andreas Dannenbergdcfc52a2018-08-27 15:57:33 +0530110 * 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
113 * configuration data
114 * @boardcfgp_high: Upper 32 bit of the pointer pointing to the board
115 * configuration data
116 * @boardcfg_size: Size of board configuration data object
117 * Request type is TI_SCI_MSG_BOARD_CONFIG, responded with a generic
118 * ACK/NACK message.
119 */
120struct ti_sci_msg_board_config {
121 struct ti_sci_msg_hdr hdr;
122 u32 boardcfgp_low;
123 u32 boardcfgp_high;
124 u16 boardcfg_size;
125} __packed;
126
Andreas Dannenberg7bc33042018-08-27 15:57:34 +0530127/**
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.
133 *
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
138 * suspend states.
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.
145 *
146 * Request type is TI_SCI_MSG_SET_DEVICE_STATE, responded with a generic
147 * ACK/NACK message.
148 */
149struct 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;
155 u32 id;
156 u32 reserved;
157
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
161 u8 state;
162} __packed;
163
164/**
165 * struct ti_sci_msg_req_get_device_state - Request to get device.
166 * @hdr: Generic header
167 * @id: Device Identifier
168 *
169 * Request type is TI_SCI_MSG_GET_DEVICE_STATE, responded device state
170 * information
171 */
172struct ti_sci_msg_req_get_device_state {
173 struct ti_sci_msg_hdr hdr;
174 u32 id;
175} __packed;
176
177/**
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.
187 *
188 * Response to request TI_SCI_MSG_GET_DEVICE_STATE.
189 */
190struct ti_sci_msg_resp_get_device_state {
191 struct ti_sci_msg_hdr hdr;
192 u32 context_loss_count;
193 u32 resets;
194 u8 programmed_state;
195#define MSG_DEVICE_HW_STATE_OFF 0
196#define MSG_DEVICE_HW_STATE_ON 1
197#define MSG_DEVICE_HW_STATE_TRANS 2
198 u8 current_state;
199} __packed;
200
201/**
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.
210 *
211 * Request type is TI_SCI_MSG_SET_DEVICE_RESETS, responded with a generic
212 * ACK/NACK message.
213 */
214struct ti_sci_msg_req_set_device_resets {
215 struct ti_sci_msg_hdr hdr;
216 u32 id;
217 u32 resets;
218} __packed;
219
Lokesh Vutla9b871812018-08-27 15:57:35 +0530220/**
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.
244 *
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.
249 *
250 * Request type is TI_SCI_MSG_SET_CLOCK_STATE, response is a generic
251 * ACK or NACK message.
252 */
253struct 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;
259 u32 dev_id;
260 u8 clk_id;
261#define MSG_CLOCK_SW_STATE_UNREQ 0
262#define MSG_CLOCK_SW_STATE_AUTO 1
263#define MSG_CLOCK_SW_STATE_REQ 2
264 u8 request_state;
265} __packed;
266
267/**
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.
274 *
275 * Request type is TI_SCI_MSG_GET_CLOCK_STATE, response is state
276 * of the clock
277 */
278struct ti_sci_msg_req_get_clock_state {
279 struct ti_sci_msg_hdr hdr;
280 u32 dev_id;
281 u8 clk_id;
282} __packed;
283
284/**
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
292 *
293 * Response to TI_SCI_MSG_GET_CLOCK_STATE.
294 */
295struct ti_sci_msg_resp_get_clock_state {
296 struct ti_sci_msg_hdr hdr;
297 u8 programmed_state;
298#define MSG_CLOCK_HW_STATE_NOT_READY 0
299#define MSG_CLOCK_HW_STATE_READY 1
300 u8 current_state;
301} __packed;
302
303/**
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
311 * parameter.
312 *
313 * Request type is TI_SCI_MSG_SET_CLOCK_PARENT, response is generic
314 * ACK / NACK message.
315 */
316struct ti_sci_msg_req_set_clock_parent {
317 struct ti_sci_msg_hdr hdr;
318 u32 dev_id;
319 u8 clk_id;
320 u8 parent_id;
321} __packed;
322
323/**
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.
330 *
331 * Request type is TI_SCI_MSG_GET_CLOCK_PARENT, response is parent information
332 */
333struct ti_sci_msg_req_get_clock_parent {
334 struct ti_sci_msg_hdr hdr;
335 u32 dev_id;
336 u8 clk_id;
337} __packed;
338
339/**
340 * struct ti_sci_msg_resp_get_clock_parent - Response with clock parent
341 * @hdr: Generic Header
342 * @parent_id: The current clock parent
343 *
344 * Response to TI_SCI_MSG_GET_CLOCK_PARENT.
345 */
346struct ti_sci_msg_resp_get_clock_parent {
347 struct ti_sci_msg_hdr hdr;
348 u8 parent_id;
349} __packed;
350
351/**
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.
356 *
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
359 * for input clocks.
360 *
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.
363 */
364struct ti_sci_msg_req_get_clock_num_parents {
365 struct ti_sci_msg_hdr hdr;
366 u32 dev_id;
367 u8 clk_id;
368} __packed;
369
370/**
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
374 *
375 * Response to TI_SCI_MSG_GET_NUM_CLOCK_PARENTS
376 */
377struct ti_sci_msg_resp_get_clock_num_parents {
378 struct ti_sci_msg_hdr hdr;
379 u8 num_parents;
380} __packed;
381
382/**
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.
395 *
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
399 * result message.
400 *
401 * Request type is TI_SCI_MSG_QUERY_CLOCK_FREQ, response is appropriate message,
402 * or NACK in case of inability to satisfy request.
403 */
404struct ti_sci_msg_req_query_clock_freq {
405 struct ti_sci_msg_hdr hdr;
406 u32 dev_id;
407 u64 min_freq_hz;
408 u64 target_freq_hz;
409 u64 max_freq_hz;
410 u8 clk_id;
411} __packed;
412
413/**
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.
417 *
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.
420 */
421struct ti_sci_msg_resp_query_clock_freq {
422 struct ti_sci_msg_hdr hdr;
423 u64 freq_hz;
424} __packed;
425
426/**
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.
439 *
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.
443 *
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.
449 *
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.
453 *
454 * Calling set frequency on clock outputs from the SoC pseudo-device will
455 * function similarly to setting the clock frequency on a device.
456 *
457 * Request type is TI_SCI_MSG_SET_CLOCK_FREQ, response is a generic ACK/NACK
458 * message.
459 */
460struct ti_sci_msg_req_set_clock_freq {
461 struct ti_sci_msg_hdr hdr;
462 u32 dev_id;
463 u64 min_freq_hz;
464 u64 target_freq_hz;
465 u64 max_freq_hz;
466 u8 clk_id;
467} __packed;
468
469/**
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.
474 *
475 * NOTE: Normally clock frequency management is automatically done by TISCI
476 * entity. In some cases, clock frequencies are configured by host.
477 *
478 * Request type is TI_SCI_MSG_GET_CLOCK_FREQ, responded with clock frequency
479 * that the clock is currently at.
480 */
481struct ti_sci_msg_req_get_clock_freq {
482 struct ti_sci_msg_hdr hdr;
483 u32 dev_id;
484 u8 clk_id;
485} __packed;
486
487/**
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.
491 *
492 * Response to request type TI_SCI_MSG_GET_CLOCK_FREQ.
493 */
494struct ti_sci_msg_resp_get_clock_freq {
495 struct ti_sci_msg_hdr hdr;
496 u64 freq_hz;
497} __packed;
498
Lokesh Vutla32cd2512018-08-27 15:57:32 +0530499#endif /* __TI_SCI_H */