ti_sci.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499
  1. /* 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. #ifndef __TI_SCI_H
  14. #define __TI_SCI_H
  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
  22. #define TI_SCI_MSG_BOARD_CONFIG 0x000b
  23. #define TI_SCI_MSG_BOARD_CONFIG_RM 0x000c
  24. #define TI_SCI_MSG_BOARD_CONFIG_SECURITY 0x000d
  25. #define TI_SCI_MSG_BOARD_CONFIG_PM 0x000e
  26. /* Device requests */
  27. #define TI_SCI_MSG_SET_DEVICE_STATE 0x0200
  28. #define TI_SCI_MSG_GET_DEVICE_STATE 0x0201
  29. #define TI_SCI_MSG_SET_DEVICE_RESETS 0x0202
  30. /* Clock requests */
  31. #define TI_SCI_MSG_SET_CLOCK_STATE 0x0100
  32. #define TI_SCI_MSG_GET_CLOCK_STATE 0x0101
  33. #define TI_SCI_MSG_SET_CLOCK_PARENT 0x0102
  34. #define TI_SCI_MSG_GET_CLOCK_PARENT 0x0103
  35. #define TI_SCI_MSG_GET_NUM_CLOCK_PARENTS 0x0104
  36. #define TI_SCI_MSG_SET_CLOCK_FREQ 0x010c
  37. #define TI_SCI_MSG_QUERY_CLOCK_FREQ 0x010d
  38. #define TI_SCI_MSG_GET_CLOCK_FREQ 0x010e
  39. /**
  40. * struct ti_sci_msg_hdr - Generic Message Header for All messages and responses
  41. * @type: Type of messages: One of TI_SCI_MSG* values
  42. * @host: Host of the message
  43. * @seq: Message identifier indicating a transfer sequence
  44. * @flags: Flag for the message
  45. */
  46. struct ti_sci_msg_hdr {
  47. u16 type;
  48. u8 host;
  49. u8 seq;
  50. #define TI_SCI_MSG_FLAG(val) (1 << (val))
  51. #define TI_SCI_FLAG_REQ_GENERIC_NORESPONSE 0x0
  52. #define TI_SCI_FLAG_REQ_ACK_ON_RECEIVED TI_SCI_MSG_FLAG(0)
  53. #define TI_SCI_FLAG_REQ_ACK_ON_PROCESSED TI_SCI_MSG_FLAG(1)
  54. #define TI_SCI_FLAG_RESP_GENERIC_NACK 0x0
  55. #define TI_SCI_FLAG_RESP_GENERIC_ACK TI_SCI_MSG_FLAG(1)
  56. /* Additional Flags */
  57. u32 flags;
  58. } __packed;
  59. /**
  60. * struct ti_sci_secure_msg_hdr - Header that prefixes all TISCI messages sent
  61. * via secure transport.
  62. * @checksum: crc16 checksum for the entire message
  63. * @reserved: Reserved for future use.
  64. */
  65. struct ti_sci_secure_msg_hdr {
  66. u16 checksum;
  67. u16 reserved;
  68. } __packed;
  69. /**
  70. * struct ti_sci_msg_resp_version - Response for a message
  71. * @hdr: Generic header
  72. * @firmware_description: String describing the firmware
  73. * @firmware_revision: Firmware revision
  74. * @abi_major: Major version of the ABI that firmware supports
  75. * @abi_minor: Minor version of the ABI that firmware supports
  76. *
  77. * In general, ABI version changes follow the rule that minor version increments
  78. * are backward compatible. Major revision changes in ABI may not be
  79. * backward compatible.
  80. *
  81. * Response to a generic message with message type TI_SCI_MSG_VERSION
  82. */
  83. struct ti_sci_msg_resp_version {
  84. struct ti_sci_msg_hdr hdr;
  85. char firmware_description[32];
  86. u16 firmware_revision;
  87. u8 abi_major;
  88. u8 abi_minor;
  89. } __packed;
  90. /**
  91. * struct ti_sci_msg_req_reboot - Reboot the SoC
  92. * @hdr: Generic Header
  93. *
  94. * Request type is TI_SCI_MSG_SYS_RESET, responded with a generic
  95. * ACK/NACK message.
  96. */
  97. struct ti_sci_msg_req_reboot {
  98. struct ti_sci_msg_hdr hdr;
  99. } __packed;
  100. /**
  101. * struct ti_sci_msg_board_config - Board configuration message
  102. * @hdr: Generic Header
  103. * @boardcfgp_low: Lower 32 bit of the pointer pointing to the board
  104. * configuration data
  105. * @boardcfgp_high: Upper 32 bit of the pointer pointing to the board
  106. * configuration data
  107. * @boardcfg_size: Size of board configuration data object
  108. * Request type is TI_SCI_MSG_BOARD_CONFIG, responded with a generic
  109. * ACK/NACK message.
  110. */
  111. struct ti_sci_msg_board_config {
  112. struct ti_sci_msg_hdr hdr;
  113. u32 boardcfgp_low;
  114. u32 boardcfgp_high;
  115. u16 boardcfg_size;
  116. } __packed;
  117. /**
  118. * struct ti_sci_msg_req_set_device_state - Set the desired state of the device
  119. * @hdr: Generic header
  120. * @id: Indicates which device to modify
  121. * @reserved: Reserved space in message, must be 0 for backward compatibility
  122. * @state: The desired state of the device.
  123. *
  124. * Certain flags can also be set to alter the device state:
  125. * + MSG_FLAG_DEVICE_WAKE_ENABLED - Configure the device to be a wake source.
  126. * The meaning of this flag will vary slightly from device to device and from
  127. * SoC to SoC but it generally allows the device to wake the SoC out of deep
  128. * suspend states.
  129. * + MSG_FLAG_DEVICE_RESET_ISO - Enable reset isolation for this device.
  130. * + MSG_FLAG_DEVICE_EXCLUSIVE - Claim this device exclusively. When passed
  131. * with STATE_RETENTION or STATE_ON, it will claim the device exclusively.
  132. * If another host already has this device set to STATE_RETENTION or STATE_ON,
  133. * the message will fail. Once successful, other hosts attempting to set
  134. * STATE_RETENTION or STATE_ON will fail.
  135. *
  136. * Request type is TI_SCI_MSG_SET_DEVICE_STATE, responded with a generic
  137. * ACK/NACK message.
  138. */
  139. struct ti_sci_msg_req_set_device_state {
  140. /* Additional hdr->flags options */
  141. #define MSG_FLAG_DEVICE_WAKE_ENABLED TI_SCI_MSG_FLAG(8)
  142. #define MSG_FLAG_DEVICE_RESET_ISO TI_SCI_MSG_FLAG(9)
  143. #define MSG_FLAG_DEVICE_EXCLUSIVE TI_SCI_MSG_FLAG(10)
  144. struct ti_sci_msg_hdr hdr;
  145. u32 id;
  146. u32 reserved;
  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
  150. u8 state;
  151. } __packed;
  152. /**
  153. * struct ti_sci_msg_req_get_device_state - Request to get device.
  154. * @hdr: Generic header
  155. * @id: Device Identifier
  156. *
  157. * Request type is TI_SCI_MSG_GET_DEVICE_STATE, responded device state
  158. * information
  159. */
  160. struct ti_sci_msg_req_get_device_state {
  161. struct ti_sci_msg_hdr hdr;
  162. u32 id;
  163. } __packed;
  164. /**
  165. * struct ti_sci_msg_resp_get_device_state - Response to get device request.
  166. * @hdr: Generic header
  167. * @context_loss_count: Indicates how many times the device has lost context. A
  168. * driver can use this monotonic counter to determine if the device has
  169. * lost context since the last time this message was exchanged.
  170. * @resets: Programmed state of the reset lines.
  171. * @programmed_state: The state as programmed by set_device.
  172. * - Uses the MSG_DEVICE_SW_* macros
  173. * @current_state: The actual state of the hardware.
  174. *
  175. * Response to request TI_SCI_MSG_GET_DEVICE_STATE.
  176. */
  177. struct ti_sci_msg_resp_get_device_state {
  178. struct ti_sci_msg_hdr hdr;
  179. u32 context_loss_count;
  180. u32 resets;
  181. u8 programmed_state;
  182. #define MSG_DEVICE_HW_STATE_OFF 0
  183. #define MSG_DEVICE_HW_STATE_ON 1
  184. #define MSG_DEVICE_HW_STATE_TRANS 2
  185. u8 current_state;
  186. } __packed;
  187. /**
  188. * struct ti_sci_msg_req_set_device_resets - Set the desired resets
  189. * configuration of the device
  190. * @hdr: Generic header
  191. * @id: Indicates which device to modify
  192. * @resets: A bit field of resets for the device. The meaning, behavior,
  193. * and usage of the reset flags are device specific. 0 for a bit
  194. * indicates releasing the reset represented by that bit while 1
  195. * indicates keeping it held.
  196. *
  197. * Request type is TI_SCI_MSG_SET_DEVICE_RESETS, responded with a generic
  198. * ACK/NACK message.
  199. */
  200. struct ti_sci_msg_req_set_device_resets {
  201. struct ti_sci_msg_hdr hdr;
  202. u32 id;
  203. u32 resets;
  204. } __packed;
  205. /**
  206. * struct ti_sci_msg_req_set_clock_state - Request to setup a Clock state
  207. * @hdr: Generic Header, Certain flags can be set specific to the clocks:
  208. * MSG_FLAG_CLOCK_ALLOW_SSC: Allow this clock to be modified
  209. * via spread spectrum clocking.
  210. * MSG_FLAG_CLOCK_ALLOW_FREQ_CHANGE: Allow this clock's
  211. * frequency to be changed while it is running so long as it
  212. * is within the min/max limits.
  213. * MSG_FLAG_CLOCK_INPUT_TERM: Enable input termination, this
  214. * is only applicable to clock inputs on the SoC pseudo-device.
  215. * @dev_id: Device identifier this request is for
  216. * @clk_id: Clock identifier for the device for this request.
  217. * Each device has it's own set of clock inputs. This indexes
  218. * which clock input to modify.
  219. * @request_state: Request the state for the clock to be set to.
  220. * MSG_CLOCK_SW_STATE_UNREQ: The IP does not require this clock,
  221. * it can be disabled, regardless of the state of the device
  222. * MSG_CLOCK_SW_STATE_AUTO: Allow the System Controller to
  223. * automatically manage the state of this clock. If the device
  224. * is enabled, then the clock is enabled. If the device is set
  225. * to off or retention, then the clock is internally set as not
  226. * being required by the device.(default)
  227. * MSG_CLOCK_SW_STATE_REQ: Configure the clock to be enabled,
  228. * regardless of the state of the device.
  229. *
  230. * Normally, all required clocks are managed by TISCI entity, this is used
  231. * only for specific control *IF* required. Auto managed state is
  232. * MSG_CLOCK_SW_STATE_AUTO, in other states, TISCI entity assume remote
  233. * will explicitly control.
  234. *
  235. * Request type is TI_SCI_MSG_SET_CLOCK_STATE, response is a generic
  236. * ACK or NACK message.
  237. */
  238. struct ti_sci_msg_req_set_clock_state {
  239. /* Additional hdr->flags options */
  240. #define MSG_FLAG_CLOCK_ALLOW_SSC TI_SCI_MSG_FLAG(8)
  241. #define MSG_FLAG_CLOCK_ALLOW_FREQ_CHANGE TI_SCI_MSG_FLAG(9)
  242. #define MSG_FLAG_CLOCK_INPUT_TERM TI_SCI_MSG_FLAG(10)
  243. struct ti_sci_msg_hdr hdr;
  244. u32 dev_id;
  245. u8 clk_id;
  246. #define MSG_CLOCK_SW_STATE_UNREQ 0
  247. #define MSG_CLOCK_SW_STATE_AUTO 1
  248. #define MSG_CLOCK_SW_STATE_REQ 2
  249. u8 request_state;
  250. } __packed;
  251. /**
  252. * struct ti_sci_msg_req_get_clock_state - Request for clock state
  253. * @hdr: Generic Header
  254. * @dev_id: Device identifier this request is for
  255. * @clk_id: Clock identifier for the device for this request.
  256. * Each device has it's own set of clock inputs. This indexes
  257. * which clock input to get state of.
  258. *
  259. * Request type is TI_SCI_MSG_GET_CLOCK_STATE, response is state
  260. * of the clock
  261. */
  262. struct ti_sci_msg_req_get_clock_state {
  263. struct ti_sci_msg_hdr hdr;
  264. u32 dev_id;
  265. u8 clk_id;
  266. } __packed;
  267. /**
  268. * struct ti_sci_msg_resp_get_clock_state - Response to get clock state
  269. * @hdr: Generic Header
  270. * @programmed_state: Any programmed state of the clock. This is one of
  271. * MSG_CLOCK_SW_STATE* values.
  272. * @current_state: Current state of the clock. This is one of:
  273. * MSG_CLOCK_HW_STATE_NOT_READY: Clock is not ready
  274. * MSG_CLOCK_HW_STATE_READY: Clock is ready
  275. *
  276. * Response to TI_SCI_MSG_GET_CLOCK_STATE.
  277. */
  278. struct ti_sci_msg_resp_get_clock_state {
  279. struct ti_sci_msg_hdr hdr;
  280. u8 programmed_state;
  281. #define MSG_CLOCK_HW_STATE_NOT_READY 0
  282. #define MSG_CLOCK_HW_STATE_READY 1
  283. u8 current_state;
  284. } __packed;
  285. /**
  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.
  292. * @parent_id: The new clock parent is selectable by an index via this
  293. * parameter.
  294. *
  295. * Request type is TI_SCI_MSG_SET_CLOCK_PARENT, response is generic
  296. * ACK / NACK message.
  297. */
  298. struct ti_sci_msg_req_set_clock_parent {
  299. struct ti_sci_msg_hdr hdr;
  300. u32 dev_id;
  301. u8 clk_id;
  302. u8 parent_id;
  303. } __packed;
  304. /**
  305. * struct ti_sci_msg_req_get_clock_parent - Get the clock parent
  306. * @hdr: Generic Header
  307. * @dev_id: Device identifier this request is for
  308. * @clk_id: Clock identifier for the device for this request.
  309. * Each device has it's own set of clock inputs. This indexes
  310. * which clock input to get the parent for.
  311. *
  312. * Request type is TI_SCI_MSG_GET_CLOCK_PARENT, response is parent information
  313. */
  314. struct ti_sci_msg_req_get_clock_parent {
  315. struct ti_sci_msg_hdr hdr;
  316. u32 dev_id;
  317. u8 clk_id;
  318. } __packed;
  319. /**
  320. * struct ti_sci_msg_resp_get_clock_parent - Response with clock parent
  321. * @hdr: Generic Header
  322. * @parent_id: The current clock parent
  323. *
  324. * Response to TI_SCI_MSG_GET_CLOCK_PARENT.
  325. */
  326. struct ti_sci_msg_resp_get_clock_parent {
  327. struct ti_sci_msg_hdr hdr;
  328. u8 parent_id;
  329. } __packed;
  330. /**
  331. * struct ti_sci_msg_req_get_clock_num_parents - Request to get clock parents
  332. * @hdr: Generic header
  333. * @dev_id: Device identifier this request is for
  334. * @clk_id: Clock identifier for the device for this request.
  335. *
  336. * This request provides information about how many clock parent options
  337. * are available for a given clock to a device. This is typically used
  338. * for input clocks.
  339. *
  340. * Request type is TI_SCI_MSG_GET_NUM_CLOCK_PARENTS, response is appropriate
  341. * message, or NACK in case of inability to satisfy request.
  342. */
  343. struct ti_sci_msg_req_get_clock_num_parents {
  344. struct ti_sci_msg_hdr hdr;
  345. u32 dev_id;
  346. u8 clk_id;
  347. } __packed;
  348. /**
  349. * struct ti_sci_msg_resp_get_clock_num_parents - Response for get clk parents
  350. * @hdr: Generic header
  351. * @num_parents: Number of clock parents
  352. *
  353. * Response to TI_SCI_MSG_GET_NUM_CLOCK_PARENTS
  354. */
  355. struct ti_sci_msg_resp_get_clock_num_parents {
  356. struct ti_sci_msg_hdr hdr;
  357. u8 num_parents;
  358. } __packed;
  359. /**
  360. * struct ti_sci_msg_req_query_clock_freq - Request to query a frequency
  361. * @hdr: Generic Header
  362. * @dev_id: Device identifier this request is for
  363. * @min_freq_hz: The minimum allowable frequency in Hz. This is the minimum
  364. * allowable programmed frequency and does not account for clock
  365. * tolerances and jitter.
  366. * @target_freq_hz: The target clock frequency. A frequency will be found
  367. * as close to this target frequency as possible.
  368. * @max_freq_hz: The maximum allowable frequency in Hz. This is the maximum
  369. * allowable programmed frequency and does not account for clock
  370. * tolerances and jitter.
  371. * @clk_id: Clock identifier for the device for this request.
  372. *
  373. * NOTE: Normally clock frequency management is automatically done by TISCI
  374. * entity. In case of specific requests, TISCI evaluates capability to achieve
  375. * requested frequency within provided range and responds with
  376. * result message.
  377. *
  378. * Request type is TI_SCI_MSG_QUERY_CLOCK_FREQ, response is appropriate message,
  379. * or NACK in case of inability to satisfy request.
  380. */
  381. struct ti_sci_msg_req_query_clock_freq {
  382. struct ti_sci_msg_hdr hdr;
  383. u32 dev_id;
  384. u64 min_freq_hz;
  385. u64 target_freq_hz;
  386. u64 max_freq_hz;
  387. u8 clk_id;
  388. } __packed;
  389. /**
  390. * struct ti_sci_msg_resp_query_clock_freq - Response to a clock frequency query
  391. * @hdr: Generic Header
  392. * @freq_hz: Frequency that is the best match in Hz.
  393. *
  394. * Response to request type TI_SCI_MSG_QUERY_CLOCK_FREQ. NOTE: if the request
  395. * cannot be satisfied, the message will be of type NACK.
  396. */
  397. struct ti_sci_msg_resp_query_clock_freq {
  398. struct ti_sci_msg_hdr hdr;
  399. u64 freq_hz;
  400. } __packed;
  401. /**
  402. * struct ti_sci_msg_req_set_clock_freq - Request to setup a clock frequency
  403. * @hdr: Generic Header
  404. * @dev_id: Device identifier this request is for
  405. * @min_freq_hz: The minimum allowable frequency in Hz. This is the minimum
  406. * allowable programmed frequency and does not account for clock
  407. * tolerances and jitter.
  408. * @target_freq_hz: The target clock frequency. The clock will be programmed
  409. * at a rate as close to this target frequency as possible.
  410. * @max_freq_hz: The maximum allowable frequency in Hz. This is the maximum
  411. * allowable programmed frequency and does not account for clock
  412. * tolerances and jitter.
  413. * @clk_id: Clock identifier for the device for this request.
  414. *
  415. * NOTE: Normally clock frequency management is automatically done by TISCI
  416. * entity. In case of specific requests, TISCI evaluates capability to achieve
  417. * requested range and responds with success/failure message.
  418. *
  419. * This sets the desired frequency for a clock within an allowable
  420. * range. This message will fail on an enabled clock unless
  421. * MSG_FLAG_CLOCK_ALLOW_FREQ_CHANGE is set for the clock. Additionally,
  422. * if other clocks have their frequency modified due to this message,
  423. * they also must have the MSG_FLAG_CLOCK_ALLOW_FREQ_CHANGE or be disabled.
  424. *
  425. * Calling set frequency on a clock input to the SoC pseudo-device will
  426. * inform the PMMC of that clock's frequency. Setting a frequency of
  427. * zero will indicate the clock is disabled.
  428. *
  429. * Calling set frequency on clock outputs from the SoC pseudo-device will
  430. * function similarly to setting the clock frequency on a device.
  431. *
  432. * Request type is TI_SCI_MSG_SET_CLOCK_FREQ, response is a generic ACK/NACK
  433. * message.
  434. */
  435. struct ti_sci_msg_req_set_clock_freq {
  436. struct ti_sci_msg_hdr hdr;
  437. u32 dev_id;
  438. u64 min_freq_hz;
  439. u64 target_freq_hz;
  440. u64 max_freq_hz;
  441. u8 clk_id;
  442. } __packed;
  443. /**
  444. * struct ti_sci_msg_req_get_clock_freq - Request to get the clock frequency
  445. * @hdr: Generic Header
  446. * @dev_id: Device identifier this request is for
  447. * @clk_id: Clock identifier for the device for this request.
  448. *
  449. * NOTE: Normally clock frequency management is automatically done by TISCI
  450. * entity. In some cases, clock frequencies are configured by host.
  451. *
  452. * Request type is TI_SCI_MSG_GET_CLOCK_FREQ, responded with clock frequency
  453. * that the clock is currently at.
  454. */
  455. struct ti_sci_msg_req_get_clock_freq {
  456. struct ti_sci_msg_hdr hdr;
  457. u32 dev_id;
  458. u8 clk_id;
  459. } __packed;
  460. /**
  461. * struct ti_sci_msg_resp_get_clock_freq - Response of clock frequency request
  462. * @hdr: Generic Header
  463. * @freq_hz: Frequency that the clock is currently on, in Hz.
  464. *
  465. * Response to request type TI_SCI_MSG_GET_CLOCK_FREQ.
  466. */
  467. struct ti_sci_msg_resp_get_clock_freq {
  468. struct ti_sci_msg_hdr hdr;
  469. u64 freq_hz;
  470. } __packed;
  471. #endif /* __TI_SCI_H */