bpmp-abi.h 40 KB

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