ti_sci.h 16 KB

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