bpmp_abi.h 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (c) 2014-2016, NVIDIA CORPORATION.
  4. */
  5. #ifndef _ABI_BPMP_ABI_H_
  6. #define _ABI_BPMP_ABI_H_
  7. #ifdef LK
  8. #include <stdint.h>
  9. #endif
  10. #ifndef __ABI_PACKED
  11. #define __ABI_PACKED __attribute__((packed))
  12. #endif
  13. #ifdef NO_GCC_EXTENSIONS
  14. #define EMPTY char empty;
  15. #define EMPTY_ARRAY 1
  16. #else
  17. #define EMPTY
  18. #define EMPTY_ARRAY 0
  19. #endif
  20. #ifndef __UNION_ANON
  21. #define __UNION_ANON
  22. #endif
  23. /**
  24. * @file
  25. */
  26. /**
  27. * @defgroup MRQ MRQ Messages
  28. * @brief Messages sent to/from BPMP via IPC
  29. * @{
  30. * @defgroup MRQ_Format Message Format
  31. * @defgroup MRQ_Codes Message Request (MRQ) Codes
  32. * @defgroup MRQ_Payloads Message Payloads
  33. * @defgroup Error_Codes Error Codes
  34. * @}
  35. */
  36. /**
  37. * @addtogroup MRQ_Format Message Format
  38. * @{
  39. * The CPU requests the BPMP to perform a particular service by
  40. * sending it an IVC frame containing a single MRQ message. An MRQ
  41. * message consists of a @ref mrq_request followed by a payload whose
  42. * format depends on mrq_request::mrq.
  43. *
  44. * The BPMP processes the data and replies with an IVC frame (on the
  45. * same IVC channel) containing and MRQ response. An MRQ response
  46. * consists of a @ref mrq_response followed by a payload whose format
  47. * depends on the associated mrq_request::mrq.
  48. *
  49. * A well-defined subset of the MRQ messages that the CPU sends to the
  50. * BPMP can lead to BPMP eventually sending an MRQ message to the
  51. * CPU. For example, when the CPU uses an #MRQ_THERMAL message to set
  52. * a thermal trip point, the BPMP may eventually send a single
  53. * #MRQ_THERMAL message of its own to the CPU indicating that the trip
  54. * point has been crossed.
  55. * @}
  56. */
  57. /**
  58. * @ingroup MRQ_Format
  59. * @brief header for an MRQ message
  60. *
  61. * Provides the MRQ number for the MRQ message: #mrq. The remainder of
  62. * the MRQ message is a payload (immediately following the
  63. * mrq_request) whose format depends on mrq.
  64. *
  65. * @todo document the flags
  66. */
  67. struct mrq_request {
  68. /** @brief MRQ number of the request */
  69. uint32_t mrq;
  70. /** @brief flags for the request */
  71. uint32_t flags;
  72. } __ABI_PACKED;
  73. /**
  74. * @ingroup MRQ_Format
  75. * @brief header for an MRQ response
  76. *
  77. * Provides an error code for the associated MRQ message. The
  78. * remainder of the MRQ response is a payload (immediately following
  79. * the mrq_response) whose format depends on the associated
  80. * mrq_request::mrq
  81. *
  82. * @todo document the flags
  83. */
  84. struct mrq_response {
  85. /** @brief error code for the MRQ request itself */
  86. int32_t err;
  87. /** @brief flags for the response */
  88. uint32_t flags;
  89. } __ABI_PACKED;
  90. /**
  91. * @ingroup MRQ_Format
  92. * Minimum needed size for an IPC message buffer
  93. */
  94. #define MSG_MIN_SZ 128
  95. /**
  96. * @ingroup MRQ_Format
  97. * Minimum size guaranteed for data in an IPC message buffer
  98. */
  99. #define MSG_DATA_MIN_SZ 120
  100. /**
  101. * @ingroup MRQ_Codes
  102. * @name Legal MRQ codes
  103. * These are the legal values for mrq_request::mrq
  104. * @{
  105. */
  106. #define MRQ_PING 0
  107. #define MRQ_QUERY_TAG 1
  108. #define MRQ_MODULE_LOAD 4
  109. #define MRQ_MODULE_UNLOAD 5
  110. #define MRQ_TRACE_MODIFY 7
  111. #define MRQ_WRITE_TRACE 8
  112. #define MRQ_THREADED_PING 9
  113. #define MRQ_MODULE_MAIL 11
  114. #define MRQ_DEBUGFS 19
  115. #define MRQ_RESET 20
  116. #define MRQ_I2C 21
  117. #define MRQ_CLK 22
  118. #define MRQ_QUERY_ABI 23
  119. #define MRQ_PG_READ_STATE 25
  120. #define MRQ_PG_UPDATE_STATE 26
  121. #define MRQ_THERMAL 27
  122. #define MRQ_CPU_VHINT 28
  123. #define MRQ_ABI_RATCHET 29
  124. #define MRQ_EMC_DVFS_LATENCY 31
  125. #define MRQ_TRACE_ITER 64
  126. /** @} */
  127. /**
  128. * @ingroup MRQ_Codes
  129. * @brief Maximum MRQ code to be sent by CPU software to
  130. * BPMP. Subject to change in future
  131. */
  132. #define MAX_CPU_MRQ_ID 64
  133. /**
  134. * @addtogroup MRQ_Payloads Message Payloads
  135. * @{
  136. * @defgroup Ping
  137. * @defgroup Query_Tag Query Tag
  138. * @defgroup Module Loadable Modules
  139. * @defgroup Trace
  140. * @defgroup Debugfs
  141. * @defgroup Reset
  142. * @defgroup I2C
  143. * @defgroup Clocks
  144. * @defgroup ABI_info ABI Info
  145. * @defgroup MC_Flush MC Flush
  146. * @defgroup Powergating
  147. * @defgroup Thermal
  148. * @defgroup Vhint CPU Voltage hint
  149. * @defgroup MRQ_Deprecated Deprecated MRQ messages
  150. * @defgroup EMC
  151. * @}
  152. */
  153. /**
  154. * @ingroup MRQ_Codes
  155. * @def MRQ_PING
  156. * @brief A simple ping
  157. *
  158. * * Platforms: All
  159. * * Initiators: Any
  160. * * Targets: Any
  161. * * Request Payload: @ref mrq_ping_request
  162. * * Response Payload: @ref mrq_ping_response
  163. *
  164. * @ingroup MRQ_Codes
  165. * @def MRQ_THREADED_PING
  166. * @brief A deeper ping
  167. *
  168. * * Platforms: All
  169. * * Initiators: Any
  170. * * Targets: BPMP
  171. * * Request Payload: @ref mrq_ping_request
  172. * * Response Payload: @ref mrq_ping_response
  173. *
  174. * Behavior is equivalent to a simple #MRQ_PING except that BPMP
  175. * responds from a thread context (providing a slightly more robust
  176. * sign of life).
  177. *
  178. */
  179. /**
  180. * @ingroup Ping
  181. * @brief request with #MRQ_PING
  182. *
  183. * Used by the sender of an #MRQ_PING message to request a pong from
  184. * recipient. The response from the recipient is computed based on
  185. * #challenge.
  186. */
  187. struct mrq_ping_request {
  188. /** @brief arbitrarily chosen value */
  189. uint32_t challenge;
  190. } __ABI_PACKED;
  191. /**
  192. * @ingroup Ping
  193. * @brief response to #MRQ_PING
  194. *
  195. * Sent in response to an #MRQ_PING message. #reply should be the
  196. * mrq_ping_request challenge left shifted by 1 with the carry-bit
  197. * dropped.
  198. *
  199. */
  200. struct mrq_ping_response {
  201. /** @brief response to the MRQ_PING challege */
  202. uint32_t reply;
  203. } __ABI_PACKED;
  204. /**
  205. * @ingroup MRQ_Codes
  206. * @def MRQ_QUERY_TAG
  207. * @brief Query BPMP firmware's tag (i.e. version information)
  208. *
  209. * * Platforms: All
  210. * * Initiators: CCPLEX
  211. * * Targets: BPMP
  212. * * Request Payload: @ref mrq_query_tag_request
  213. * * Response Payload: N/A
  214. *
  215. */
  216. /**
  217. * @ingroup Query_Tag
  218. * @brief request with #MRQ_QUERY_TAG
  219. *
  220. * Used by #MRQ_QUERY_TAG call to ask BPMP to fill in the memory
  221. * pointed by #addr with BPMP firmware header.
  222. *
  223. * The sender is reponsible for ensuring that #addr is mapped in to
  224. * the recipient's address map.
  225. */
  226. struct mrq_query_tag_request {
  227. /** @brief base address to store the firmware header */
  228. uint32_t addr;
  229. } __ABI_PACKED;
  230. /**
  231. * @ingroup MRQ_Codes
  232. * @def MRQ_MODULE_LOAD
  233. * @brief dynamically load a BPMP code module
  234. *
  235. * * Platforms: All
  236. * * Initiators: CCPLEX
  237. * * Targets: BPMP
  238. * * Request Payload: @ref mrq_module_load_request
  239. * * Response Payload: @ref mrq_module_load_response
  240. *
  241. * @note This MRQ is disabled on production systems
  242. *
  243. */
  244. /**
  245. * @ingroup Module
  246. * @brief request with #MRQ_MODULE_LOAD
  247. *
  248. * Used by #MRQ_MODULE_LOAD calls to ask the recipient to dynamically
  249. * load the code located at #phys_addr and having size #size
  250. * bytes. #phys_addr is treated as a void pointer.
  251. *
  252. * The recipient copies the code from #phys_addr to locally allocated
  253. * memory prior to responding to this message.
  254. *
  255. * @todo document the module header format
  256. *
  257. * The sender is responsible for ensuring that the code is mapped in
  258. * the recipient's address map.
  259. *
  260. */
  261. struct mrq_module_load_request {
  262. /** @brief base address of the code to load. Treated as (void *) */
  263. uint32_t phys_addr; /* (void *) */
  264. /** @brief size in bytes of code to load */
  265. uint32_t size;
  266. } __ABI_PACKED;
  267. /**
  268. * @ingroup Module
  269. * @brief response to #MRQ_MODULE_LOAD
  270. *
  271. * @todo document mrq_response::err
  272. */
  273. struct mrq_module_load_response {
  274. /** @brief handle to the loaded module */
  275. uint32_t base;
  276. } __ABI_PACKED;
  277. /**
  278. * @ingroup MRQ_Codes
  279. * @def MRQ_MODULE_UNLOAD
  280. * @brief unload a previously loaded code module
  281. *
  282. * * Platforms: All
  283. * * Initiators: CCPLEX
  284. * * Targets: BPMP
  285. * * Request Payload: @ref mrq_module_unload_request
  286. * * Response Payload: N/A
  287. *
  288. * @note This MRQ is disabled on production systems
  289. */
  290. /**
  291. * @ingroup Module
  292. * @brief request with #MRQ_MODULE_UNLOAD
  293. *
  294. * Used by #MRQ_MODULE_UNLOAD calls to request that a previously loaded
  295. * module be unloaded.
  296. */
  297. struct mrq_module_unload_request {
  298. /** @brief handle of the module to unload */
  299. uint32_t base;
  300. } __ABI_PACKED;
  301. /**
  302. * @ingroup MRQ_Codes
  303. * @def MRQ_TRACE_MODIFY
  304. * @brief modify the set of enabled trace events
  305. *
  306. * * Platforms: All
  307. * * Initiators: CCPLEX
  308. * * Targets: BPMP
  309. * * Request Payload: @ref mrq_trace_modify_request
  310. * * Response Payload: @ref mrq_trace_modify_response
  311. *
  312. * @note This MRQ is disabled on production systems
  313. */
  314. /**
  315. * @ingroup Trace
  316. * @brief request with #MRQ_TRACE_MODIFY
  317. *
  318. * Used by %MRQ_TRACE_MODIFY calls to enable or disable specify trace
  319. * events. #set takes precedence for any bit set in both #set and
  320. * #clr.
  321. */
  322. struct mrq_trace_modify_request {
  323. /** @brief bit mask of trace events to disable */
  324. uint32_t clr;
  325. /** @brief bit mask of trace events to enable */
  326. uint32_t set;
  327. } __ABI_PACKED;
  328. /**
  329. * @ingroup Trace
  330. * @brief response to #MRQ_TRACE_MODIFY
  331. *
  332. * Sent in repsonse to an #MRQ_TRACE_MODIFY message. #mask reflects the
  333. * state of which events are enabled after the recipient acted on the
  334. * message.
  335. *
  336. */
  337. struct mrq_trace_modify_response {
  338. /** @brief bit mask of trace event enable states */
  339. uint32_t mask;
  340. } __ABI_PACKED;
  341. /**
  342. * @ingroup MRQ_Codes
  343. * @def MRQ_WRITE_TRACE
  344. * @brief Write trace data to a buffer
  345. *
  346. * * Platforms: All
  347. * * Initiators: CCPLEX
  348. * * Targets: BPMP
  349. * * Request Payload: @ref mrq_write_trace_request
  350. * * Response Payload: @ref mrq_write_trace_response
  351. *
  352. * mrq_response::err depends on the @ref mrq_write_trace_request field
  353. * values. err is -#BPMP_EINVAL if size is zero or area is NULL or
  354. * area is in an illegal range. A positive value for err indicates the
  355. * number of bytes written to area.
  356. *
  357. * @note This MRQ is disabled on production systems
  358. */
  359. /**
  360. * @ingroup Trace
  361. * @brief request with #MRQ_WRITE_TRACE
  362. *
  363. * Used by MRQ_WRITE_TRACE calls to ask the recipient to copy trace
  364. * data from the recipient's local buffer to the output buffer. #area
  365. * is treated as a byte-aligned pointer in the recipient's address
  366. * space.
  367. *
  368. * The sender is responsible for ensuring that the output
  369. * buffer is mapped in the recipient's address map. The recipient is
  370. * responsible for protecting its own code and data from accidental
  371. * overwrites.
  372. */
  373. struct mrq_write_trace_request {
  374. /** @brief base address of output buffer */
  375. uint32_t area;
  376. /** @brief size in bytes of the output buffer */
  377. uint32_t size;
  378. } __ABI_PACKED;
  379. /**
  380. * @ingroup Trace
  381. * @brief response to #MRQ_WRITE_TRACE
  382. *
  383. * Once this response is sent, the respondent will not access the
  384. * output buffer further.
  385. */
  386. struct mrq_write_trace_response {
  387. /**
  388. * @brief flag whether more data remains in local buffer
  389. *
  390. * Value is 1 if the entire local trace buffer has been
  391. * drained to the outputbuffer. Value is 0 otherwise.
  392. */
  393. uint32_t eof;
  394. } __ABI_PACKED;
  395. /** @private */
  396. struct mrq_threaded_ping_request {
  397. uint32_t challenge;
  398. } __ABI_PACKED;
  399. /** @private */
  400. struct mrq_threaded_ping_response {
  401. uint32_t reply;
  402. } __ABI_PACKED;
  403. /**
  404. * @ingroup MRQ_Codes
  405. * @def MRQ_MODULE_MAIL
  406. * @brief send a message to a loadable module
  407. *
  408. * * Platforms: All
  409. * * Initiators: Any
  410. * * Targets: BPMP
  411. * * Request Payload: @ref mrq_module_mail_request
  412. * * Response Payload: @ref mrq_module_mail_response
  413. *
  414. * @note This MRQ is disabled on production systems
  415. */
  416. /**
  417. * @ingroup Module
  418. * @brief request with #MRQ_MODULE_MAIL
  419. */
  420. struct mrq_module_mail_request {
  421. /** @brief handle to the previously loaded module */
  422. uint32_t base;
  423. /** @brief module-specific mail payload
  424. *
  425. * The length of data[ ] is unknown to the BPMP core firmware
  426. * but it is limited to the size of an IPC message.
  427. */
  428. uint8_t data[EMPTY_ARRAY];
  429. } __ABI_PACKED;
  430. /**
  431. * @ingroup Module
  432. * @brief response to #MRQ_MODULE_MAIL
  433. */
  434. struct mrq_module_mail_response {
  435. /** @brief module-specific mail payload
  436. *
  437. * The length of data[ ] is unknown to the BPMP core firmware
  438. * but it is limited to the size of an IPC message.
  439. */
  440. uint8_t data[EMPTY_ARRAY];
  441. } __ABI_PACKED;
  442. /**
  443. * @ingroup MRQ_Codes
  444. * @def MRQ_DEBUGFS
  445. * @brief Interact with BPMP's debugfs file nodes
  446. *
  447. * * Platforms: T186
  448. * * Initiators: Any
  449. * * Targets: BPMP
  450. * * Request Payload: @ref mrq_debugfs_request
  451. * * Response Payload: @ref mrq_debugfs_response
  452. */
  453. /**
  454. * @addtogroup Debugfs
  455. * @{
  456. *
  457. * The BPMP firmware implements a pseudo-filesystem called
  458. * debugfs. Any driver within the firmware may register with debugfs
  459. * to expose an arbitrary set of "files" in the filesystem. When
  460. * software on the CPU writes to a debugfs file, debugfs passes the
  461. * written data to a callback provided by the driver. When software on
  462. * the CPU reads a debugfs file, debugfs queries the driver for the
  463. * data to return to the CPU. The intention of the debugfs filesystem
  464. * is to provide information useful for debugging the system at
  465. * runtime.
  466. *
  467. * @note The files exposed via debugfs are not part of the
  468. * BPMP firmware's ABI. debugfs files may be added or removed in any
  469. * given version of the firmware. Typically the semantics of a debugfs
  470. * file are consistent from version to version but even that is not
  471. * guaranteed.
  472. *
  473. * @}
  474. */
  475. /** @ingroup Debugfs */
  476. enum mrq_debugfs_commands {
  477. CMD_DEBUGFS_READ = 1,
  478. CMD_DEBUGFS_WRITE = 2,
  479. CMD_DEBUGFS_DUMPDIR = 3,
  480. CMD_DEBUGFS_MAX
  481. };
  482. /**
  483. * @ingroup Debugfs
  484. * @brief parameters for CMD_DEBUGFS_READ/WRITE command
  485. */
  486. struct cmd_debugfs_fileop_request {
  487. /** @brief physical address pointing at filename */
  488. uint32_t fnameaddr;
  489. /** @brief length in bytes of filename buffer */
  490. uint32_t fnamelen;
  491. /** @brief physical address pointing to data buffer */
  492. uint32_t dataaddr;
  493. /** @brief length in bytes of data buffer */
  494. uint32_t datalen;
  495. } __ABI_PACKED;
  496. /**
  497. * @ingroup Debugfs
  498. * @brief parameters for CMD_DEBUGFS_READ/WRITE command
  499. */
  500. struct cmd_debugfs_dumpdir_request {
  501. /** @brief physical address pointing to data buffer */
  502. uint32_t dataaddr;
  503. /** @brief length in bytes of data buffer */
  504. uint32_t datalen;
  505. } __ABI_PACKED;
  506. /**
  507. * @ingroup Debugfs
  508. * @brief response data for CMD_DEBUGFS_READ/WRITE command
  509. */
  510. struct cmd_debugfs_fileop_response {
  511. /** @brief always 0 */
  512. uint32_t reserved;
  513. /** @brief number of bytes read from or written to data buffer */
  514. uint32_t nbytes;
  515. } __ABI_PACKED;
  516. /**
  517. * @ingroup Debugfs
  518. * @brief response data for CMD_DEBUGFS_DUMPDIR command
  519. */
  520. struct cmd_debugfs_dumpdir_response {
  521. /** @brief always 0 */
  522. uint32_t reserved;
  523. /** @brief number of bytes read from or written to data buffer */
  524. uint32_t nbytes;
  525. } __ABI_PACKED;
  526. /**
  527. * @ingroup Debugfs
  528. * @brief request with #MRQ_DEBUGFS.
  529. *
  530. * The sender of an MRQ_DEBUGFS message uses #cmd to specify a debugfs
  531. * command to execute. Legal commands are the values of @ref
  532. * mrq_debugfs_commands. Each command requires a specific additional
  533. * payload of data.
  534. *
  535. * |command |payload|
  536. * |-------------------|-------|
  537. * |CMD_DEBUGFS_READ |fop |
  538. * |CMD_DEBUGFS_WRITE |fop |
  539. * |CMD_DEBUGFS_DUMPDIR|dumpdir|
  540. */
  541. struct mrq_debugfs_request {
  542. uint32_t cmd;
  543. union {
  544. struct cmd_debugfs_fileop_request fop;
  545. struct cmd_debugfs_dumpdir_request dumpdir;
  546. } __UNION_ANON;
  547. } __ABI_PACKED;
  548. /**
  549. * @ingroup Debugfs
  550. */
  551. struct mrq_debugfs_response {
  552. /** @brief always 0 */
  553. int32_t reserved;
  554. union {
  555. /** @brief response data for CMD_DEBUGFS_READ OR
  556. * CMD_DEBUGFS_WRITE command
  557. */
  558. struct cmd_debugfs_fileop_response fop;
  559. /** @brief response data for CMD_DEBUGFS_DUMPDIR command */
  560. struct cmd_debugfs_dumpdir_response dumpdir;
  561. } __UNION_ANON;
  562. } __ABI_PACKED;
  563. /**
  564. * @addtogroup Debugfs
  565. * @{
  566. */
  567. #define DEBUGFS_S_ISDIR (1 << 9)
  568. #define DEBUGFS_S_IRUSR (1 << 8)
  569. #define DEBUGFS_S_IWUSR (1 << 7)
  570. /** @} */
  571. /**
  572. * @ingroup MRQ_Codes
  573. * @def MRQ_RESET
  574. * @brief reset an IP block
  575. *
  576. * * Platforms: T186
  577. * * Initiators: Any
  578. * * Targets: BPMP
  579. * * Request Payload: @ref mrq_reset_request
  580. * * Response Payload: N/A
  581. */
  582. /**
  583. * @ingroup Reset
  584. */
  585. enum mrq_reset_commands {
  586. CMD_RESET_ASSERT = 1,
  587. CMD_RESET_DEASSERT = 2,
  588. CMD_RESET_MODULE = 3,
  589. CMD_RESET_MAX, /* not part of ABI and subject to change */
  590. };
  591. /**
  592. * @ingroup Reset
  593. * @brief request with MRQ_RESET
  594. *
  595. * Used by the sender of an #MRQ_RESET message to request BPMP to
  596. * assert or or deassert a given reset line.
  597. */
  598. struct mrq_reset_request {
  599. /** @brief reset action to perform (@enum mrq_reset_commands) */
  600. uint32_t cmd;
  601. /** @brief id of the reset to affected */
  602. uint32_t reset_id;
  603. } __ABI_PACKED;
  604. /**
  605. * @ingroup MRQ_Codes
  606. * @def MRQ_I2C
  607. * @brief issue an i2c transaction
  608. *
  609. * * Platforms: T186
  610. * * Initiators: Any
  611. * * Targets: BPMP
  612. * * Request Payload: @ref mrq_i2c_request
  613. * * Response Payload: @ref mrq_i2c_response
  614. */
  615. /**
  616. * @addtogroup I2C
  617. * @{
  618. */
  619. #define TEGRA_I2C_IPC_MAX_IN_BUF_SIZE (MSG_DATA_MIN_SZ - 12)
  620. #define TEGRA_I2C_IPC_MAX_OUT_BUF_SIZE (MSG_DATA_MIN_SZ - 4)
  621. /** @} */
  622. /**
  623. * @ingroup I2C
  624. * @name Serial I2C flags
  625. * Use these flags with serial_i2c_request::flags
  626. * @{
  627. */
  628. #define SERIALI2C_TEN 0x0010
  629. #define SERIALI2C_RD 0x0001
  630. #define SERIALI2C_STOP 0x8000
  631. #define SERIALI2C_NOSTART 0x4000
  632. #define SERIALI2C_REV_DIR_ADDR 0x2000
  633. #define SERIALI2C_IGNORE_NAK 0x1000
  634. #define SERIALI2C_NO_RD_ACK 0x0800
  635. #define SERIALI2C_RECV_LEN 0x0400
  636. /** @} */
  637. /** @ingroup I2C */
  638. enum {
  639. CMD_I2C_XFER = 1
  640. };
  641. /**
  642. * @ingroup I2C
  643. * @brief serializable i2c request
  644. *
  645. * Instances of this structure are packed (little-endian) into
  646. * cmd_i2c_xfer_request::data_buf. Each instance represents a single
  647. * transaction (or a portion of a transaction with repeated starts) on
  648. * an i2c bus.
  649. *
  650. * Because these structures are packed, some instances are likely to
  651. * be misaligned. Additionally because #data is variable length, it is
  652. * not possible to iterate through a serialized list of these
  653. * structures without inspecting #len in each instance. It may be
  654. * easier to serialize or deserialize cmd_i2c_xfer_request::data_buf
  655. * manually rather than using this structure definition.
  656. */
  657. struct serial_i2c_request {
  658. /** @brief I2C slave address */
  659. uint16_t addr;
  660. /** @brief bitmask of SERIALI2C_ flags */
  661. uint16_t flags;
  662. /** @brief length of I2C transaction in bytes */
  663. uint16_t len;
  664. /** @brief for write transactions only, #len bytes of data */
  665. uint8_t data[];
  666. } __ABI_PACKED;
  667. /**
  668. * @ingroup I2C
  669. * @brief trigger one or more i2c transactions
  670. */
  671. struct cmd_i2c_xfer_request {
  672. /** @brief valid bus number from mach-t186/i2c-t186.h*/
  673. uint32_t bus_id;
  674. /** @brief count of valid bytes in #data_buf*/
  675. uint32_t data_size;
  676. /** @brief serialized packed instances of @ref serial_i2c_request*/
  677. uint8_t data_buf[TEGRA_I2C_IPC_MAX_IN_BUF_SIZE];
  678. } __ABI_PACKED;
  679. /**
  680. * @ingroup I2C
  681. * @brief container for data read from the i2c bus
  682. *
  683. * Processing an cmd_i2c_xfer_request::data_buf causes BPMP to execute
  684. * zero or more I2C reads. The data read from the bus is serialized
  685. * into #data_buf.
  686. */
  687. struct cmd_i2c_xfer_response {
  688. /** @brief count of valid bytes in #data_buf*/
  689. uint32_t data_size;
  690. /** @brief i2c read data */
  691. uint8_t data_buf[TEGRA_I2C_IPC_MAX_OUT_BUF_SIZE];
  692. } __ABI_PACKED;
  693. /**
  694. * @ingroup I2C
  695. * @brief request with #MRQ_I2C
  696. */
  697. struct mrq_i2c_request {
  698. /** @brief always CMD_I2C_XFER (i.e. 1) */
  699. uint32_t cmd;
  700. /** @brief parameters of the transfer request */
  701. struct cmd_i2c_xfer_request xfer;
  702. } __ABI_PACKED;
  703. /**
  704. * @ingroup I2C
  705. * @brief response to #MRQ_I2C
  706. */
  707. struct mrq_i2c_response {
  708. struct cmd_i2c_xfer_response xfer;
  709. } __ABI_PACKED;
  710. /**
  711. * @ingroup MRQ_Codes
  712. * @def MRQ_CLK
  713. *
  714. * * Platforms: T186
  715. * * Initiators: Any
  716. * * Targets: BPMP
  717. * * Request Payload: @ref mrq_clk_request
  718. * * Response Payload: @ref mrq_clk_response
  719. * @addtogroup Clocks
  720. * @{
  721. */
  722. /**
  723. * @name MRQ_CLK sub-commands
  724. * @{
  725. */
  726. enum {
  727. CMD_CLK_GET_RATE = 1,
  728. CMD_CLK_SET_RATE = 2,
  729. CMD_CLK_ROUND_RATE = 3,
  730. CMD_CLK_GET_PARENT = 4,
  731. CMD_CLK_SET_PARENT = 5,
  732. CMD_CLK_IS_ENABLED = 6,
  733. CMD_CLK_ENABLE = 7,
  734. CMD_CLK_DISABLE = 8,
  735. CMD_CLK_GET_ALL_INFO = 14,
  736. CMD_CLK_GET_MAX_CLK_ID = 15,
  737. CMD_CLK_MAX,
  738. };
  739. /** @} */
  740. #define MRQ_CLK_NAME_MAXLEN 40
  741. #define MRQ_CLK_MAX_PARENTS 16
  742. /** @private */
  743. struct cmd_clk_get_rate_request {
  744. EMPTY
  745. } __ABI_PACKED;
  746. struct cmd_clk_get_rate_response {
  747. int64_t rate;
  748. } __ABI_PACKED;
  749. struct cmd_clk_set_rate_request {
  750. int32_t unused;
  751. int64_t rate;
  752. } __ABI_PACKED;
  753. struct cmd_clk_set_rate_response {
  754. int64_t rate;
  755. } __ABI_PACKED;
  756. struct cmd_clk_round_rate_request {
  757. int32_t unused;
  758. int64_t rate;
  759. } __ABI_PACKED;
  760. struct cmd_clk_round_rate_response {
  761. int64_t rate;
  762. } __ABI_PACKED;
  763. /** @private */
  764. struct cmd_clk_get_parent_request {
  765. EMPTY
  766. } __ABI_PACKED;
  767. struct cmd_clk_get_parent_response {
  768. uint32_t parent_id;
  769. } __ABI_PACKED;
  770. struct cmd_clk_set_parent_request {
  771. uint32_t parent_id;
  772. } __ABI_PACKED;
  773. struct cmd_clk_set_parent_response {
  774. uint32_t parent_id;
  775. } __ABI_PACKED;
  776. /** @private */
  777. struct cmd_clk_is_enabled_request {
  778. EMPTY
  779. } __ABI_PACKED;
  780. struct cmd_clk_is_enabled_response {
  781. int32_t state;
  782. } __ABI_PACKED;
  783. /** @private */
  784. struct cmd_clk_enable_request {
  785. EMPTY
  786. } __ABI_PACKED;
  787. /** @private */
  788. struct cmd_clk_enable_response {
  789. EMPTY
  790. } __ABI_PACKED;
  791. /** @private */
  792. struct cmd_clk_disable_request {
  793. EMPTY
  794. } __ABI_PACKED;
  795. /** @private */
  796. struct cmd_clk_disable_response {
  797. EMPTY
  798. } __ABI_PACKED;
  799. /** @private */
  800. struct cmd_clk_get_all_info_request {
  801. EMPTY
  802. } __ABI_PACKED;
  803. struct cmd_clk_get_all_info_response {
  804. uint32_t flags;
  805. uint32_t parent;
  806. uint32_t parents[MRQ_CLK_MAX_PARENTS];
  807. uint8_t num_parents;
  808. uint8_t name[MRQ_CLK_NAME_MAXLEN];
  809. } __ABI_PACKED;
  810. /** @private */
  811. struct cmd_clk_get_max_clk_id_request {
  812. EMPTY
  813. } __ABI_PACKED;
  814. struct cmd_clk_get_max_clk_id_response {
  815. uint32_t max_id;
  816. } __ABI_PACKED;
  817. /** @} */
  818. /**
  819. * @ingroup Clocks
  820. * @brief request with #MRQ_CLK
  821. *
  822. * Used by the sender of an #MRQ_CLK message to control clocks. The
  823. * clk_request is split into several sub-commands. Some sub-commands
  824. * require no additional data. Others have a sub-command specific
  825. * payload
  826. *
  827. * |sub-command |payload |
  828. * |----------------------------|-----------------------|
  829. * |CMD_CLK_GET_RATE |- |
  830. * |CMD_CLK_SET_RATE |clk_set_rate |
  831. * |CMD_CLK_ROUND_RATE |clk_round_rate |
  832. * |CMD_CLK_GET_PARENT |- |
  833. * |CMD_CLK_SET_PARENT |clk_set_parent |
  834. * |CMD_CLK_IS_ENABLED |- |
  835. * |CMD_CLK_ENABLE |- |
  836. * |CMD_CLK_DISABLE |- |
  837. * |CMD_CLK_GET_ALL_INFO |- |
  838. * |CMD_CLK_GET_MAX_CLK_ID |- |
  839. *
  840. */
  841. struct mrq_clk_request {
  842. /** @brief sub-command and clock id concatenated to 32-bit word.
  843. * - bits[31..24] is the sub-cmd.
  844. * - bits[23..0] is the clock id
  845. */
  846. uint32_t cmd_and_id;
  847. union {
  848. /** @private */
  849. struct cmd_clk_get_rate_request clk_get_rate;
  850. struct cmd_clk_set_rate_request clk_set_rate;
  851. struct cmd_clk_round_rate_request clk_round_rate;
  852. /** @private */
  853. struct cmd_clk_get_parent_request clk_get_parent;
  854. struct cmd_clk_set_parent_request clk_set_parent;
  855. /** @private */
  856. struct cmd_clk_enable_request clk_enable;
  857. /** @private */
  858. struct cmd_clk_disable_request clk_disable;
  859. /** @private */
  860. struct cmd_clk_is_enabled_request clk_is_enabled;
  861. /** @private */
  862. struct cmd_clk_get_all_info_request clk_get_all_info;
  863. /** @private */
  864. struct cmd_clk_get_max_clk_id_request clk_get_max_clk_id;
  865. } __UNION_ANON;
  866. } __ABI_PACKED;
  867. /**
  868. * @ingroup Clocks
  869. * @brief response to MRQ_CLK
  870. *
  871. * Each sub-command supported by @ref mrq_clk_request may return
  872. * sub-command-specific data. Some do and some do not as indicated in
  873. * the following table
  874. *
  875. * |sub-command |payload |
  876. * |----------------------------|------------------------|
  877. * |CMD_CLK_GET_RATE |clk_get_rate |
  878. * |CMD_CLK_SET_RATE |clk_set_rate |
  879. * |CMD_CLK_ROUND_RATE |clk_round_rate |
  880. * |CMD_CLK_GET_PARENT |clk_get_parent |
  881. * |CMD_CLK_SET_PARENT |clk_set_parent |
  882. * |CMD_CLK_IS_ENABLED |clk_is_enabled |
  883. * |CMD_CLK_ENABLE |- |
  884. * |CMD_CLK_DISABLE |- |
  885. * |CMD_CLK_GET_ALL_INFO |clk_get_all_info |
  886. * |CMD_CLK_GET_MAX_CLK_ID |clk_get_max_id |
  887. *
  888. */
  889. struct mrq_clk_response {
  890. union {
  891. struct cmd_clk_get_rate_response clk_get_rate;
  892. struct cmd_clk_set_rate_response clk_set_rate;
  893. struct cmd_clk_round_rate_response clk_round_rate;
  894. struct cmd_clk_get_parent_response clk_get_parent;
  895. struct cmd_clk_set_parent_response clk_set_parent;
  896. /** @private */
  897. struct cmd_clk_enable_response clk_enable;
  898. /** @private */
  899. struct cmd_clk_disable_response clk_disable;
  900. struct cmd_clk_is_enabled_response clk_is_enabled;
  901. struct cmd_clk_get_all_info_response clk_get_all_info;
  902. struct cmd_clk_get_max_clk_id_response clk_get_max_clk_id;
  903. } __UNION_ANON;
  904. } __ABI_PACKED;
  905. /**
  906. * @ingroup MRQ_Codes
  907. * @def MRQ_QUERY_ABI
  908. * @brief check if an MRQ is implemented
  909. *
  910. * * Platforms: All
  911. * * Initiators: Any
  912. * * Targets: Any
  913. * * Request Payload: @ref mrq_query_abi_request
  914. * * Response Payload: @ref mrq_query_abi_response
  915. */
  916. /**
  917. * @ingroup ABI_info
  918. * @brief request with MRQ_QUERY_ABI
  919. *
  920. * Used by #MRQ_QUERY_ABI call to check if MRQ code #mrq is supported
  921. * by the recipient.
  922. */
  923. struct mrq_query_abi_request {
  924. /** @brief MRQ code to query */
  925. uint32_t mrq;
  926. } __ABI_PACKED;
  927. /**
  928. * @ingroup ABI_info
  929. * @brief response to MRQ_QUERY_ABI
  930. */
  931. struct mrq_query_abi_response {
  932. /** @brief 0 if queried MRQ is supported. Else, -#BPMP_ENODEV */
  933. int32_t status;
  934. } __ABI_PACKED;
  935. /**
  936. * @ingroup MRQ_Codes
  937. * @def MRQ_PG_READ_STATE
  938. * @brief read the power-gating state of a partition
  939. *
  940. * * Platforms: T186
  941. * * Initiators: Any
  942. * * Targets: BPMP
  943. * * Request Payload: @ref mrq_pg_read_state_request
  944. * * Response Payload: @ref mrq_pg_read_state_response
  945. * @addtogroup Powergating
  946. * @{
  947. */
  948. /**
  949. * @brief request with #MRQ_PG_READ_STATE
  950. *
  951. * Used by MRQ_PG_READ_STATE call to read the current state of a
  952. * partition.
  953. */
  954. struct mrq_pg_read_state_request {
  955. /** @brief ID of partition */
  956. uint32_t partition_id;
  957. } __ABI_PACKED;
  958. /**
  959. * @brief response to MRQ_PG_READ_STATE
  960. * @todo define possible errors.
  961. */
  962. struct mrq_pg_read_state_response {
  963. /** @brief read as don't care */
  964. uint32_t sram_state;
  965. /** @brief state of power partition
  966. * * 0 : off
  967. * * 1 : on
  968. */
  969. uint32_t logic_state;
  970. } __ABI_PACKED;
  971. /** @} */
  972. /**
  973. * @ingroup MRQ_Codes
  974. * @def MRQ_PG_UPDATE_STATE
  975. * @brief modify the power-gating state of a partition
  976. *
  977. * * Platforms: T186
  978. * * Initiators: Any
  979. * * Targets: BPMP
  980. * * Request Payload: @ref mrq_pg_update_state_request
  981. * * Response Payload: N/A
  982. * @addtogroup Powergating
  983. * @{
  984. */
  985. /**
  986. * @brief request with mrq_pg_update_state_request
  987. *
  988. * Used by #MRQ_PG_UPDATE_STATE call to request BPMP to change the
  989. * state of a power partition #partition_id.
  990. */
  991. struct mrq_pg_update_state_request {
  992. /** @brief ID of partition */
  993. uint32_t partition_id;
  994. /** @brief secondary control of power partition
  995. * @details Ignored by many versions of the BPMP
  996. * firmware. For maximum compatibility, set the value
  997. * according to @logic_state
  998. * * 0x1: power ON partition (@ref logic_state == 0x3)
  999. * * 0x3: power OFF partition (@ref logic_state == 0x1)
  1000. */
  1001. uint32_t sram_state;
  1002. /** @brief controls state of power partition, legal values are
  1003. * * 0x1 : power OFF partition
  1004. * * 0x3 : power ON partition
  1005. */
  1006. uint32_t logic_state;
  1007. /** @brief change state of clocks of the power partition, legal values
  1008. * * 0x0 : do not change clock state
  1009. * * 0x1 : disable partition clocks (only applicable when
  1010. * @ref logic_state == 0x1)
  1011. * * 0x3 : enable partition clocks (only applicable when
  1012. * @ref logic_state == 0x3)
  1013. */
  1014. uint32_t clock_state;
  1015. } __ABI_PACKED;
  1016. /** @} */
  1017. /**
  1018. * @ingroup MRQ_Codes
  1019. * @def MRQ_THERMAL
  1020. * @brief interact with BPMP thermal framework
  1021. *
  1022. * * Platforms: T186
  1023. * * Initiators: Any
  1024. * * Targets: Any
  1025. * * Request Payload: TODO
  1026. * * Response Payload: TODO
  1027. *
  1028. * @addtogroup Thermal
  1029. *
  1030. * The BPMP firmware includes a thermal framework. Drivers within the
  1031. * bpmp firmware register with the framework to provide thermal
  1032. * zones. Each thermal zone corresponds to an entity whose temperature
  1033. * can be measured. The framework also has a notion of trip points. A
  1034. * trip point consists of a thermal zone id, a temperature, and a
  1035. * callback routine. The framework invokes the callback when the zone
  1036. * hits the indicated temperature. The BPMP firmware uses this thermal
  1037. * framework interally to implement various temperature-dependent
  1038. * functions.
  1039. *
  1040. * Software on the CPU can use #MRQ_THERMAL (with payload @ref
  1041. * mrq_thermal_host_to_bpmp_request) to interact with the BPMP thermal
  1042. * framework. The CPU must It can query the number of supported zones,
  1043. * query zone temperatures, and set trip points.
  1044. *
  1045. * When a trip point set by the CPU gets crossed, BPMP firmware issues
  1046. * an IPC to the CPU having mrq_request::mrq = #MRQ_THERMAL and a
  1047. * payload of @ref mrq_thermal_bpmp_to_host_request.
  1048. * @{
  1049. */
  1050. enum mrq_thermal_host_to_bpmp_cmd {
  1051. /**
  1052. * @brief Check whether the BPMP driver supports the specified
  1053. * request type.
  1054. *
  1055. * Host needs to supply request parameters.
  1056. *
  1057. * mrq_response::err is 0 if the specified request is
  1058. * supported and -#BPMP_ENODEV otherwise.
  1059. */
  1060. CMD_THERMAL_QUERY_ABI = 0,
  1061. /**
  1062. * @brief Get the current temperature of the specified zone.
  1063. *
  1064. * Host needs to supply request parameters.
  1065. *
  1066. * mrq_response::err is
  1067. * * 0: Temperature query succeeded.
  1068. * * -#BPMP_EINVAL: Invalid request parameters.
  1069. * * -#BPMP_ENOENT: No driver registered for thermal zone..
  1070. * * -#BPMP_EFAULT: Problem reading temperature measurement.
  1071. */
  1072. CMD_THERMAL_GET_TEMP = 1,
  1073. /**
  1074. * @brief Enable or disable and set the lower and upper
  1075. * thermal limits for a thermal trip point. Each zone has
  1076. * one trip point.
  1077. *
  1078. * Host needs to supply request parameters. Once the
  1079. * temperature hits a trip point, the BPMP will send a message
  1080. * to the CPU having MRQ=MRQ_THERMAL and
  1081. * type=CMD_THERMAL_HOST_TRIP_REACHED
  1082. *
  1083. * mrq_response::err is
  1084. * * 0: Trip successfully set.
  1085. * * -#BPMP_EINVAL: Invalid request parameters.
  1086. * * -#BPMP_ENOENT: No driver registered for thermal zone.
  1087. * * -#BPMP_EFAULT: Problem setting trip point.
  1088. */
  1089. CMD_THERMAL_SET_TRIP = 2,
  1090. /**
  1091. * @brief Get the number of supported thermal zones.
  1092. *
  1093. * No request parameters required.
  1094. *
  1095. * mrq_response::err is always 0, indicating success.
  1096. */
  1097. CMD_THERMAL_GET_NUM_ZONES = 3,
  1098. /** @brief: number of supported host-to-bpmp commands. May
  1099. * increase in future
  1100. */
  1101. CMD_THERMAL_HOST_TO_BPMP_NUM
  1102. };
  1103. enum mrq_thermal_bpmp_to_host_cmd {
  1104. /**
  1105. * @brief Indication that the temperature for a zone has
  1106. * exceeded the range indicated in the thermal trip point
  1107. * for the zone.
  1108. *
  1109. * BPMP needs to supply request parameters. Host only needs to
  1110. * acknowledge.
  1111. */
  1112. CMD_THERMAL_HOST_TRIP_REACHED = 100,
  1113. /** @brief: number of supported bpmp-to-host commands. May
  1114. * increase in future
  1115. */
  1116. CMD_THERMAL_BPMP_TO_HOST_NUM
  1117. };
  1118. /*
  1119. * Host->BPMP request data for request type CMD_THERMAL_QUERY_ABI
  1120. *
  1121. * zone: Request type for which to check existence.
  1122. */
  1123. struct cmd_thermal_query_abi_request {
  1124. uint32_t type;
  1125. } __ABI_PACKED;
  1126. /*
  1127. * Host->BPMP request data for request type CMD_THERMAL_GET_TEMP
  1128. *
  1129. * zone: Number of thermal zone.
  1130. */
  1131. struct cmd_thermal_get_temp_request {
  1132. uint32_t zone;
  1133. } __ABI_PACKED;
  1134. /*
  1135. * BPMP->Host reply data for request CMD_THERMAL_GET_TEMP
  1136. *
  1137. * error: 0 if request succeeded.
  1138. * -BPMP_EINVAL if request parameters were invalid.
  1139. * -BPMP_ENOENT if no driver was registered for the specified thermal zone.
  1140. * -BPMP_EFAULT for other thermal zone driver errors.
  1141. * temp: Current temperature in millicelsius.
  1142. */
  1143. struct cmd_thermal_get_temp_response {
  1144. int32_t temp;
  1145. } __ABI_PACKED;
  1146. /*
  1147. * Host->BPMP request data for request type CMD_THERMAL_SET_TRIP
  1148. *
  1149. * zone: Number of thermal zone.
  1150. * low: Temperature of lower trip point in millicelsius
  1151. * high: Temperature of upper trip point in millicelsius
  1152. * enabled: 1 to enable trip point, 0 to disable trip point
  1153. */
  1154. struct cmd_thermal_set_trip_request {
  1155. uint32_t zone;
  1156. int32_t low;
  1157. int32_t high;
  1158. uint32_t enabled;
  1159. } __ABI_PACKED;
  1160. /*
  1161. * BPMP->Host request data for request type CMD_THERMAL_HOST_TRIP_REACHED
  1162. *
  1163. * zone: Number of thermal zone where trip point was reached.
  1164. */
  1165. struct cmd_thermal_host_trip_reached_request {
  1166. uint32_t zone;
  1167. } __ABI_PACKED;
  1168. /*
  1169. * BPMP->Host reply data for request type CMD_THERMAL_GET_NUM_ZONES
  1170. *
  1171. * num: Number of supported thermal zones. The thermal zones are indexed
  1172. * starting from zero.
  1173. */
  1174. struct cmd_thermal_get_num_zones_response {
  1175. uint32_t num;
  1176. } __ABI_PACKED;
  1177. /*
  1178. * Host->BPMP request data.
  1179. *
  1180. * Reply type is union mrq_thermal_bpmp_to_host_response.
  1181. *
  1182. * type: Type of request. Values listed in enum mrq_thermal_type.
  1183. * data: Request type specific parameters.
  1184. */
  1185. struct mrq_thermal_host_to_bpmp_request {
  1186. uint32_t type;
  1187. union {
  1188. struct cmd_thermal_query_abi_request query_abi;
  1189. struct cmd_thermal_get_temp_request get_temp;
  1190. struct cmd_thermal_set_trip_request set_trip;
  1191. } __UNION_ANON;
  1192. } __ABI_PACKED;
  1193. /*
  1194. * BPMP->Host request data.
  1195. *
  1196. * type: Type of request. Values listed in enum mrq_thermal_type.
  1197. * data: Request type specific parameters.
  1198. */
  1199. struct mrq_thermal_bpmp_to_host_request {
  1200. uint32_t type;
  1201. union {
  1202. struct cmd_thermal_host_trip_reached_request host_trip_reached;
  1203. } __UNION_ANON;
  1204. } __ABI_PACKED;
  1205. /*
  1206. * Data in reply to a Host->BPMP request.
  1207. */
  1208. union mrq_thermal_bpmp_to_host_response {
  1209. struct cmd_thermal_get_temp_response get_temp;
  1210. struct cmd_thermal_get_num_zones_response get_num_zones;
  1211. } __ABI_PACKED;
  1212. /** @} */
  1213. /**
  1214. * @ingroup MRQ_Codes
  1215. * @def MRQ_CPU_VHINT
  1216. * @brief Query CPU voltage hint data
  1217. *
  1218. * * Platforms: T186
  1219. * * Initiators: CCPLEX
  1220. * * Targets: BPMP
  1221. * * Request Payload: @ref mrq_cpu_vhint_request
  1222. * * Response Payload: N/A
  1223. *
  1224. * @addtogroup Vhint CPU Voltage hint
  1225. * @{
  1226. */
  1227. /**
  1228. * @brief request with #MRQ_CPU_VHINT
  1229. *
  1230. * Used by #MRQ_CPU_VHINT call by CCPLEX to retrieve voltage hint data
  1231. * from BPMP to memory space pointed by #addr. CCPLEX is responsible
  1232. * to allocate sizeof(cpu_vhint_data) sized block of memory and
  1233. * appropriately map it for BPMP before sending the request.
  1234. */
  1235. struct mrq_cpu_vhint_request {
  1236. /** @brief IOVA address for the #cpu_vhint_data */
  1237. uint32_t addr; /* struct cpu_vhint_data * */
  1238. /** @brief ID of the cluster whose data is requested */
  1239. uint32_t cluster_id; /* enum cluster_id */
  1240. } __ABI_PACKED;
  1241. /**
  1242. * @brief description of the CPU v/f relation
  1243. *
  1244. * Used by #MRQ_CPU_VHINT call to carry data pointed by #addr of
  1245. * struct mrq_cpu_vhint_request
  1246. */
  1247. struct cpu_vhint_data {
  1248. uint32_t ref_clk_hz; /**< reference frequency in Hz */
  1249. uint16_t pdiv; /**< post divider value */
  1250. uint16_t mdiv; /**< input divider value */
  1251. uint16_t ndiv_max; /**< fMAX expressed with max NDIV value */
  1252. /** table of ndiv values as a function of vINDEX (voltage index) */
  1253. uint16_t ndiv[80];
  1254. /** minimum allowed NDIV value */
  1255. uint16_t ndiv_min;
  1256. /** minimum allowed voltage hint value (as in vINDEX) */
  1257. uint16_t vfloor;
  1258. /** maximum allowed voltage hint value (as in vINDEX) */
  1259. uint16_t vceil;
  1260. /** post-multiplier for vindex value */
  1261. uint16_t vindex_mult;
  1262. /** post-divider for vindex value */
  1263. uint16_t vindex_div;
  1264. /** reserved for future use */
  1265. uint16_t reserved[328];
  1266. } __ABI_PACKED;
  1267. /** @} */
  1268. /**
  1269. * @ingroup MRQ_Codes
  1270. * @def MRQ_ABI_RATCHET
  1271. * @brief ABI ratchet value query
  1272. *
  1273. * * Platforms: T186
  1274. * * Initiators: Any
  1275. * * Targets: BPMP
  1276. * * Request Payload: @ref mrq_abi_ratchet_request
  1277. * * Response Payload: @ref mrq_abi_ratchet_response
  1278. * @addtogroup ABI_info
  1279. * @{
  1280. */
  1281. /**
  1282. * @brief an ABI compatibility mechanism
  1283. *
  1284. * BPMP_ABI_RATCHET_VALUE may increase for various reasons in a future
  1285. * revision of this header file.
  1286. * 1. That future revision deprecates some MRQ
  1287. * 2. That future revision introduces a breaking change to an existing
  1288. * MRQ or
  1289. * 3. A bug is discovered in an existing implementation of the BPMP-FW
  1290. * (or possibly one of its clients) which warrants deprecating that
  1291. * implementation.
  1292. */
  1293. #define BPMP_ABI_RATCHET_VALUE 3
  1294. /**
  1295. * @brief request with #MRQ_ABI_RATCHET.
  1296. *
  1297. * #ratchet should be #BPMP_ABI_RATCHET_VALUE from the ABI header
  1298. * against which the requester was compiled.
  1299. *
  1300. * If ratchet is less than BPMP's #BPMP_ABI_RATCHET_VALUE, BPMP may
  1301. * reply with mrq_response::err = -#BPMP_ERANGE to indicate that
  1302. * BPMP-FW cannot interoperate correctly with the requester. Requester
  1303. * should cease further communication with BPMP.
  1304. *
  1305. * Otherwise, err shall be 0.
  1306. */
  1307. struct mrq_abi_ratchet_request {
  1308. /** @brief requester's ratchet value */
  1309. uint16_t ratchet;
  1310. };
  1311. /**
  1312. * @brief response to #MRQ_ABI_RATCHET
  1313. *
  1314. * #ratchet shall be #BPMP_ABI_RATCHET_VALUE from the ABI header
  1315. * against which BPMP firwmare was compiled.
  1316. *
  1317. * If #ratchet is less than the requester's #BPMP_ABI_RATCHET_VALUE,
  1318. * the requster must either interoperate with BPMP according to an ABI
  1319. * header version with BPMP_ABI_RATCHET_VALUE = ratchet or cease
  1320. * communication with BPMP.
  1321. *
  1322. * If mrq_response::err is 0 and ratchet is greater than or equal to the
  1323. * requester's BPMP_ABI_RATCHET_VALUE, the requester should continue
  1324. * normal operation.
  1325. */
  1326. struct mrq_abi_ratchet_response {
  1327. /** @brief BPMP's ratchet value */
  1328. uint16_t ratchet;
  1329. };
  1330. /** @} */
  1331. /**
  1332. * @ingroup MRQ_Codes
  1333. * @def MRQ_EMC_DVFS_LATENCY
  1334. * @brief query frequency dependent EMC DVFS latency
  1335. *
  1336. * * Platforms: T186
  1337. * * Initiators: CCPLEX
  1338. * * Targets: BPMP
  1339. * * Request Payload: N/A
  1340. * * Response Payload: @ref mrq_emc_dvfs_latency_response
  1341. * @addtogroup EMC
  1342. * @{
  1343. */
  1344. /**
  1345. * @brief used by @ref mrq_emc_dvfs_latency_response
  1346. */
  1347. struct emc_dvfs_latency {
  1348. /** @brief EMC frequency in kHz */
  1349. uint32_t freq;
  1350. /** @brief EMC DVFS latency in nanoseconds */
  1351. uint32_t latency;
  1352. } __ABI_PACKED;
  1353. #define EMC_DVFS_LATENCY_MAX_SIZE 14
  1354. /**
  1355. * @brief response to #MRQ_EMC_DVFS_LATENCY
  1356. */
  1357. struct mrq_emc_dvfs_latency_response {
  1358. /** @brief the number valid entries in #pairs */
  1359. uint32_t num_pairs;
  1360. /** @brief EMC <frequency, latency> information */
  1361. struct emc_dvfs_latency pairs[EMC_DVFS_LATENCY_MAX_SIZE];
  1362. } __ABI_PACKED;
  1363. /** @} */
  1364. /**
  1365. * @ingroup MRQ_Codes
  1366. * @def MRQ_TRACE_ITER
  1367. * @brief manage the trace iterator
  1368. *
  1369. * * Platforms: All
  1370. * * Initiators: CCPLEX
  1371. * * Targets: BPMP
  1372. * * Request Payload: N/A
  1373. * * Response Payload: @ref mrq_trace_iter_request
  1374. * @addtogroup Trace
  1375. * @{
  1376. */
  1377. enum {
  1378. /** @brief (re)start the tracing now. Ignore older events */
  1379. TRACE_ITER_INIT = 0,
  1380. /** @brief clobber all events in the trace buffer */
  1381. TRACE_ITER_CLEAN = 1
  1382. };
  1383. /**
  1384. * @brief request with #MRQ_TRACE_ITER
  1385. */
  1386. struct mrq_trace_iter_request {
  1387. /** @brief TRACE_ITER_INIT or TRACE_ITER_CLEAN */
  1388. uint32_t cmd;
  1389. } __ABI_PACKED;
  1390. /** @} */
  1391. /*
  1392. * 4. Enumerations
  1393. */
  1394. /*
  1395. * 4.1 CPU enumerations
  1396. *
  1397. * See <mach-t186/system-t186.h>
  1398. *
  1399. * 4.2 CPU Cluster enumerations
  1400. *
  1401. * See <mach-t186/system-t186.h>
  1402. *
  1403. * 4.3 System low power state enumerations
  1404. *
  1405. * See <mach-t186/system-t186.h>
  1406. */
  1407. /*
  1408. * 4.4 Clock enumerations
  1409. *
  1410. * For clock enumerations, see <mach-t186/clk-t186.h>
  1411. */
  1412. /*
  1413. * 4.5 Reset enumerations
  1414. *
  1415. * For reset enumerations, see <mach-t186/reset-t186.h>
  1416. */
  1417. /*
  1418. * 4.6 Thermal sensor enumerations
  1419. *
  1420. * For thermal sensor enumerations, see <mach-t186/thermal-t186.h>
  1421. */
  1422. /**
  1423. * @defgroup Error_Codes
  1424. * Negative values for mrq_response::err generally indicate some
  1425. * error. The ABI defines the following error codes. Negating these
  1426. * defines is an exercise left to the user.
  1427. * @{
  1428. */
  1429. /** @brief No such file or directory */
  1430. #define BPMP_ENOENT 2
  1431. /** @brief No MRQ handler */
  1432. #define BPMP_ENOHANDLER 3
  1433. /** @brief I/O error */
  1434. #define BPMP_EIO 5
  1435. /** @brief Bad sub-MRQ command */
  1436. #define BPMP_EBADCMD 6
  1437. /** @brief Not enough memory */
  1438. #define BPMP_ENOMEM 12
  1439. /** @brief Permission denied */
  1440. #define BPMP_EACCES 13
  1441. /** @brief Bad address */
  1442. #define BPMP_EFAULT 14
  1443. /** @brief No such device */
  1444. #define BPMP_ENODEV 19
  1445. /** @brief Argument is a directory */
  1446. #define BPMP_EISDIR 21
  1447. /** @brief Invalid argument */
  1448. #define BPMP_EINVAL 22
  1449. /** @brief Timeout during operation */
  1450. #define BPMP_ETIMEDOUT 23
  1451. /** @brief Out of range */
  1452. #define BPMP_ERANGE 34
  1453. /** @} */
  1454. /** @} */
  1455. #endif