ti_sci.h 17 KB

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