bpmp_abi.h 40 KB

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