greybus_protocols.h 59 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178
  1. /* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) */
  2. /*
  3. * Copyright(c) 2014 - 2015 Google Inc. All rights reserved.
  4. * Copyright(c) 2014 - 2015 Linaro Ltd. All rights reserved.
  5. */
  6. #ifndef __GREYBUS_PROTOCOLS_H
  7. #define __GREYBUS_PROTOCOLS_H
  8. #include <linux/types.h>
  9. /* Fixed IDs for control/svc protocols */
  10. /* SVC switch-port device ids */
  11. #define GB_SVC_DEVICE_ID_SVC 0
  12. #define GB_SVC_DEVICE_ID_AP 1
  13. #define GB_SVC_DEVICE_ID_MIN 2
  14. #define GB_SVC_DEVICE_ID_MAX 31
  15. #define GB_SVC_CPORT_ID 0
  16. #define GB_CONTROL_BUNDLE_ID 0
  17. #define GB_CONTROL_CPORT_ID 0
  18. /*
  19. * All operation messages (both requests and responses) begin with
  20. * a header that encodes the size of the message (header included).
  21. * This header also contains a unique identifier, that associates a
  22. * response message with its operation. The header contains an
  23. * operation type field, whose interpretation is dependent on what
  24. * type of protocol is used over the connection. The high bit
  25. * (0x80) of the operation type field is used to indicate whether
  26. * the message is a request (clear) or a response (set).
  27. *
  28. * Response messages include an additional result byte, which
  29. * communicates the result of the corresponding request. A zero
  30. * result value means the operation completed successfully. Any
  31. * other value indicates an error; in this case, the payload of the
  32. * response message (if any) is ignored. The result byte must be
  33. * zero in the header for a request message.
  34. *
  35. * The wire format for all numeric fields in the header is little
  36. * endian. Any operation-specific data begins immediately after the
  37. * header.
  38. */
  39. struct gb_operation_msg_hdr {
  40. __le16 size; /* Size in bytes of header + payload */
  41. __le16 operation_id; /* Operation unique id */
  42. __u8 type; /* E.g GB_I2C_TYPE_* or GB_GPIO_TYPE_* */
  43. __u8 result; /* Result of request (in responses only) */
  44. __u8 pad[2]; /* must be zero (ignore when read) */
  45. } __packed;
  46. /* Generic request types */
  47. #define GB_REQUEST_TYPE_CPORT_SHUTDOWN 0x00
  48. #define GB_REQUEST_TYPE_INVALID 0x7f
  49. struct gb_cport_shutdown_request {
  50. __u8 phase;
  51. } __packed;
  52. /* Control Protocol */
  53. /* Greybus control request types */
  54. #define GB_CONTROL_TYPE_VERSION 0x01
  55. #define GB_CONTROL_TYPE_PROBE_AP 0x02
  56. #define GB_CONTROL_TYPE_GET_MANIFEST_SIZE 0x03
  57. #define GB_CONTROL_TYPE_GET_MANIFEST 0x04
  58. #define GB_CONTROL_TYPE_CONNECTED 0x05
  59. #define GB_CONTROL_TYPE_DISCONNECTED 0x06
  60. #define GB_CONTROL_TYPE_TIMESYNC_ENABLE 0x07
  61. #define GB_CONTROL_TYPE_TIMESYNC_DISABLE 0x08
  62. #define GB_CONTROL_TYPE_TIMESYNC_AUTHORITATIVE 0x09
  63. /* Unused 0x0a */
  64. #define GB_CONTROL_TYPE_BUNDLE_VERSION 0x0b
  65. #define GB_CONTROL_TYPE_DISCONNECTING 0x0c
  66. #define GB_CONTROL_TYPE_TIMESYNC_GET_LAST_EVENT 0x0d
  67. #define GB_CONTROL_TYPE_MODE_SWITCH 0x0e
  68. #define GB_CONTROL_TYPE_BUNDLE_SUSPEND 0x0f
  69. #define GB_CONTROL_TYPE_BUNDLE_RESUME 0x10
  70. #define GB_CONTROL_TYPE_BUNDLE_DEACTIVATE 0x11
  71. #define GB_CONTROL_TYPE_BUNDLE_ACTIVATE 0x12
  72. #define GB_CONTROL_TYPE_INTF_SUSPEND_PREPARE 0x13
  73. #define GB_CONTROL_TYPE_INTF_DEACTIVATE_PREPARE 0x14
  74. #define GB_CONTROL_TYPE_INTF_HIBERNATE_ABORT 0x15
  75. struct gb_control_version_request {
  76. __u8 major;
  77. __u8 minor;
  78. } __packed;
  79. struct gb_control_version_response {
  80. __u8 major;
  81. __u8 minor;
  82. } __packed;
  83. struct gb_control_bundle_version_request {
  84. __u8 bundle_id;
  85. } __packed;
  86. struct gb_control_bundle_version_response {
  87. __u8 major;
  88. __u8 minor;
  89. } __packed;
  90. /* Control protocol manifest get size request has no payload*/
  91. struct gb_control_get_manifest_size_response {
  92. __le16 size;
  93. } __packed;
  94. /* Control protocol manifest get request has no payload */
  95. struct gb_control_get_manifest_response {
  96. __u8 data[0];
  97. } __packed;
  98. /* Control protocol [dis]connected request */
  99. struct gb_control_connected_request {
  100. __le16 cport_id;
  101. } __packed;
  102. struct gb_control_disconnecting_request {
  103. __le16 cport_id;
  104. } __packed;
  105. /* disconnecting response has no payload */
  106. struct gb_control_disconnected_request {
  107. __le16 cport_id;
  108. } __packed;
  109. /* Control protocol [dis]connected response has no payload */
  110. /*
  111. * All Bundle power management operations use the same request and response
  112. * layout and status codes.
  113. */
  114. #define GB_CONTROL_BUNDLE_PM_OK 0x00
  115. #define GB_CONTROL_BUNDLE_PM_INVAL 0x01
  116. #define GB_CONTROL_BUNDLE_PM_BUSY 0x02
  117. #define GB_CONTROL_BUNDLE_PM_FAIL 0x03
  118. #define GB_CONTROL_BUNDLE_PM_NA 0x04
  119. struct gb_control_bundle_pm_request {
  120. __u8 bundle_id;
  121. } __packed;
  122. struct gb_control_bundle_pm_response {
  123. __u8 status;
  124. } __packed;
  125. /*
  126. * Interface Suspend Prepare and Deactivate Prepare operations use the same
  127. * response layout and error codes. Define a single response structure and reuse
  128. * it. Both operations have no payload.
  129. */
  130. #define GB_CONTROL_INTF_PM_OK 0x00
  131. #define GB_CONTROL_INTF_PM_BUSY 0x01
  132. #define GB_CONTROL_INTF_PM_NA 0x02
  133. struct gb_control_intf_pm_response {
  134. __u8 status;
  135. } __packed;
  136. /* APBridge protocol */
  137. /* request APB1 log */
  138. #define GB_APB_REQUEST_LOG 0x02
  139. /* request to map a cport to bulk in and bulk out endpoints */
  140. #define GB_APB_REQUEST_EP_MAPPING 0x03
  141. /* request to get the number of cports available */
  142. #define GB_APB_REQUEST_CPORT_COUNT 0x04
  143. /* request to reset a cport state */
  144. #define GB_APB_REQUEST_RESET_CPORT 0x05
  145. /* request to time the latency of messages on a given cport */
  146. #define GB_APB_REQUEST_LATENCY_TAG_EN 0x06
  147. #define GB_APB_REQUEST_LATENCY_TAG_DIS 0x07
  148. /* request to control the CSI transmitter */
  149. #define GB_APB_REQUEST_CSI_TX_CONTROL 0x08
  150. /* request to control audio streaming */
  151. #define GB_APB_REQUEST_AUDIO_CONTROL 0x09
  152. /* TimeSync requests */
  153. #define GB_APB_REQUEST_TIMESYNC_ENABLE 0x0d
  154. #define GB_APB_REQUEST_TIMESYNC_DISABLE 0x0e
  155. #define GB_APB_REQUEST_TIMESYNC_AUTHORITATIVE 0x0f
  156. #define GB_APB_REQUEST_TIMESYNC_GET_LAST_EVENT 0x10
  157. /* requests to set Greybus CPort flags */
  158. #define GB_APB_REQUEST_CPORT_FLAGS 0x11
  159. /* ARPC request */
  160. #define GB_APB_REQUEST_ARPC_RUN 0x12
  161. struct gb_apb_request_cport_flags {
  162. __le32 flags;
  163. #define GB_APB_CPORT_FLAG_CONTROL 0x01
  164. #define GB_APB_CPORT_FLAG_HIGH_PRIO 0x02
  165. } __packed;
  166. /* Firmware Download Protocol */
  167. /* Request Types */
  168. #define GB_FW_DOWNLOAD_TYPE_FIND_FIRMWARE 0x01
  169. #define GB_FW_DOWNLOAD_TYPE_FETCH_FIRMWARE 0x02
  170. #define GB_FW_DOWNLOAD_TYPE_RELEASE_FIRMWARE 0x03
  171. #define GB_FIRMWARE_TAG_MAX_SIZE 10
  172. /* firmware download find firmware request/response */
  173. struct gb_fw_download_find_firmware_request {
  174. __u8 firmware_tag[GB_FIRMWARE_TAG_MAX_SIZE];
  175. } __packed;
  176. struct gb_fw_download_find_firmware_response {
  177. __u8 firmware_id;
  178. __le32 size;
  179. } __packed;
  180. /* firmware download fetch firmware request/response */
  181. struct gb_fw_download_fetch_firmware_request {
  182. __u8 firmware_id;
  183. __le32 offset;
  184. __le32 size;
  185. } __packed;
  186. struct gb_fw_download_fetch_firmware_response {
  187. __u8 data[0];
  188. } __packed;
  189. /* firmware download release firmware request */
  190. struct gb_fw_download_release_firmware_request {
  191. __u8 firmware_id;
  192. } __packed;
  193. /* firmware download release firmware response has no payload */
  194. /* Firmware Management Protocol */
  195. /* Request Types */
  196. #define GB_FW_MGMT_TYPE_INTERFACE_FW_VERSION 0x01
  197. #define GB_FW_MGMT_TYPE_LOAD_AND_VALIDATE_FW 0x02
  198. #define GB_FW_MGMT_TYPE_LOADED_FW 0x03
  199. #define GB_FW_MGMT_TYPE_BACKEND_FW_VERSION 0x04
  200. #define GB_FW_MGMT_TYPE_BACKEND_FW_UPDATE 0x05
  201. #define GB_FW_MGMT_TYPE_BACKEND_FW_UPDATED 0x06
  202. #define GB_FW_LOAD_METHOD_UNIPRO 0x01
  203. #define GB_FW_LOAD_METHOD_INTERNAL 0x02
  204. #define GB_FW_LOAD_STATUS_FAILED 0x00
  205. #define GB_FW_LOAD_STATUS_UNVALIDATED 0x01
  206. #define GB_FW_LOAD_STATUS_VALIDATED 0x02
  207. #define GB_FW_LOAD_STATUS_VALIDATION_FAILED 0x03
  208. #define GB_FW_BACKEND_FW_STATUS_SUCCESS 0x01
  209. #define GB_FW_BACKEND_FW_STATUS_FAIL_FIND 0x02
  210. #define GB_FW_BACKEND_FW_STATUS_FAIL_FETCH 0x03
  211. #define GB_FW_BACKEND_FW_STATUS_FAIL_WRITE 0x04
  212. #define GB_FW_BACKEND_FW_STATUS_INT 0x05
  213. #define GB_FW_BACKEND_FW_STATUS_RETRY 0x06
  214. #define GB_FW_BACKEND_FW_STATUS_NOT_SUPPORTED 0x07
  215. #define GB_FW_BACKEND_VERSION_STATUS_SUCCESS 0x01
  216. #define GB_FW_BACKEND_VERSION_STATUS_NOT_AVAILABLE 0x02
  217. #define GB_FW_BACKEND_VERSION_STATUS_NOT_SUPPORTED 0x03
  218. #define GB_FW_BACKEND_VERSION_STATUS_RETRY 0x04
  219. #define GB_FW_BACKEND_VERSION_STATUS_FAIL_INT 0x05
  220. /* firmware management interface firmware version request has no payload */
  221. struct gb_fw_mgmt_interface_fw_version_response {
  222. __u8 firmware_tag[GB_FIRMWARE_TAG_MAX_SIZE];
  223. __le16 major;
  224. __le16 minor;
  225. } __packed;
  226. /* firmware management load and validate firmware request/response */
  227. struct gb_fw_mgmt_load_and_validate_fw_request {
  228. __u8 request_id;
  229. __u8 load_method;
  230. __u8 firmware_tag[GB_FIRMWARE_TAG_MAX_SIZE];
  231. } __packed;
  232. /* firmware management load and validate firmware response has no payload*/
  233. /* firmware management loaded firmware request */
  234. struct gb_fw_mgmt_loaded_fw_request {
  235. __u8 request_id;
  236. __u8 status;
  237. __le16 major;
  238. __le16 minor;
  239. } __packed;
  240. /* firmware management loaded firmware response has no payload */
  241. /* firmware management backend firmware version request/response */
  242. struct gb_fw_mgmt_backend_fw_version_request {
  243. __u8 firmware_tag[GB_FIRMWARE_TAG_MAX_SIZE];
  244. } __packed;
  245. struct gb_fw_mgmt_backend_fw_version_response {
  246. __le16 major;
  247. __le16 minor;
  248. __u8 status;
  249. } __packed;
  250. /* firmware management backend firmware update request */
  251. struct gb_fw_mgmt_backend_fw_update_request {
  252. __u8 request_id;
  253. __u8 firmware_tag[GB_FIRMWARE_TAG_MAX_SIZE];
  254. } __packed;
  255. /* firmware management backend firmware update response has no payload */
  256. /* firmware management backend firmware updated request */
  257. struct gb_fw_mgmt_backend_fw_updated_request {
  258. __u8 request_id;
  259. __u8 status;
  260. } __packed;
  261. /* firmware management backend firmware updated response has no payload */
  262. /* Component Authentication Protocol (CAP) */
  263. /* Request Types */
  264. #define GB_CAP_TYPE_GET_ENDPOINT_UID 0x01
  265. #define GB_CAP_TYPE_GET_IMS_CERTIFICATE 0x02
  266. #define GB_CAP_TYPE_AUTHENTICATE 0x03
  267. /* CAP get endpoint uid request has no payload */
  268. struct gb_cap_get_endpoint_uid_response {
  269. __u8 uid[8];
  270. } __packed;
  271. /* CAP get endpoint ims certificate request/response */
  272. struct gb_cap_get_ims_certificate_request {
  273. __le32 certificate_class;
  274. __le32 certificate_id;
  275. } __packed;
  276. struct gb_cap_get_ims_certificate_response {
  277. __u8 result_code;
  278. __u8 certificate[];
  279. } __packed;
  280. /* CAP authenticate request/response */
  281. struct gb_cap_authenticate_request {
  282. __le32 auth_type;
  283. __u8 uid[8];
  284. __u8 challenge[32];
  285. } __packed;
  286. struct gb_cap_authenticate_response {
  287. __u8 result_code;
  288. __u8 response[64];
  289. __u8 signature[];
  290. } __packed;
  291. /* Bootrom Protocol */
  292. /* Version of the Greybus bootrom protocol we support */
  293. #define GB_BOOTROM_VERSION_MAJOR 0x00
  294. #define GB_BOOTROM_VERSION_MINOR 0x01
  295. /* Greybus bootrom request types */
  296. #define GB_BOOTROM_TYPE_VERSION 0x01
  297. #define GB_BOOTROM_TYPE_FIRMWARE_SIZE 0x02
  298. #define GB_BOOTROM_TYPE_GET_FIRMWARE 0x03
  299. #define GB_BOOTROM_TYPE_READY_TO_BOOT 0x04
  300. #define GB_BOOTROM_TYPE_AP_READY 0x05 /* Request with no-payload */
  301. #define GB_BOOTROM_TYPE_GET_VID_PID 0x06 /* Request with no-payload */
  302. /* Greybus bootrom boot stages */
  303. #define GB_BOOTROM_BOOT_STAGE_ONE 0x01 /* Reserved for the boot ROM */
  304. #define GB_BOOTROM_BOOT_STAGE_TWO 0x02 /* Bootrom package to be loaded by the boot ROM */
  305. #define GB_BOOTROM_BOOT_STAGE_THREE 0x03 /* Module personality package loaded by Stage 2 firmware */
  306. /* Greybus bootrom ready to boot status */
  307. #define GB_BOOTROM_BOOT_STATUS_INVALID 0x00 /* Firmware blob could not be validated */
  308. #define GB_BOOTROM_BOOT_STATUS_INSECURE 0x01 /* Firmware blob is valid but insecure */
  309. #define GB_BOOTROM_BOOT_STATUS_SECURE 0x02 /* Firmware blob is valid and secure */
  310. /* Max bootrom data fetch size in bytes */
  311. #define GB_BOOTROM_FETCH_MAX 2000
  312. struct gb_bootrom_version_request {
  313. __u8 major;
  314. __u8 minor;
  315. } __packed;
  316. struct gb_bootrom_version_response {
  317. __u8 major;
  318. __u8 minor;
  319. } __packed;
  320. /* Bootrom protocol firmware size request/response */
  321. struct gb_bootrom_firmware_size_request {
  322. __u8 stage;
  323. } __packed;
  324. struct gb_bootrom_firmware_size_response {
  325. __le32 size;
  326. } __packed;
  327. /* Bootrom protocol get firmware request/response */
  328. struct gb_bootrom_get_firmware_request {
  329. __le32 offset;
  330. __le32 size;
  331. } __packed;
  332. struct gb_bootrom_get_firmware_response {
  333. __u8 data[0];
  334. } __packed;
  335. /* Bootrom protocol Ready to boot request */
  336. struct gb_bootrom_ready_to_boot_request {
  337. __u8 status;
  338. } __packed;
  339. /* Bootrom protocol Ready to boot response has no payload */
  340. /* Bootrom protocol get VID/PID request has no payload */
  341. struct gb_bootrom_get_vid_pid_response {
  342. __le32 vendor_id;
  343. __le32 product_id;
  344. } __packed;
  345. /* Power Supply */
  346. /* Greybus power supply request types */
  347. #define GB_POWER_SUPPLY_TYPE_GET_SUPPLIES 0x02
  348. #define GB_POWER_SUPPLY_TYPE_GET_DESCRIPTION 0x03
  349. #define GB_POWER_SUPPLY_TYPE_GET_PROP_DESCRIPTORS 0x04
  350. #define GB_POWER_SUPPLY_TYPE_GET_PROPERTY 0x05
  351. #define GB_POWER_SUPPLY_TYPE_SET_PROPERTY 0x06
  352. #define GB_POWER_SUPPLY_TYPE_EVENT 0x07
  353. /* Greybus power supply battery technologies types */
  354. #define GB_POWER_SUPPLY_TECH_UNKNOWN 0x0000
  355. #define GB_POWER_SUPPLY_TECH_NiMH 0x0001
  356. #define GB_POWER_SUPPLY_TECH_LION 0x0002
  357. #define GB_POWER_SUPPLY_TECH_LIPO 0x0003
  358. #define GB_POWER_SUPPLY_TECH_LiFe 0x0004
  359. #define GB_POWER_SUPPLY_TECH_NiCd 0x0005
  360. #define GB_POWER_SUPPLY_TECH_LiMn 0x0006
  361. /* Greybus power supply types */
  362. #define GB_POWER_SUPPLY_UNKNOWN_TYPE 0x0000
  363. #define GB_POWER_SUPPLY_BATTERY_TYPE 0x0001
  364. #define GB_POWER_SUPPLY_UPS_TYPE 0x0002
  365. #define GB_POWER_SUPPLY_MAINS_TYPE 0x0003
  366. #define GB_POWER_SUPPLY_USB_TYPE 0x0004
  367. #define GB_POWER_SUPPLY_USB_DCP_TYPE 0x0005
  368. #define GB_POWER_SUPPLY_USB_CDP_TYPE 0x0006
  369. #define GB_POWER_SUPPLY_USB_ACA_TYPE 0x0007
  370. /* Greybus power supply health values */
  371. #define GB_POWER_SUPPLY_HEALTH_UNKNOWN 0x0000
  372. #define GB_POWER_SUPPLY_HEALTH_GOOD 0x0001
  373. #define GB_POWER_SUPPLY_HEALTH_OVERHEAT 0x0002
  374. #define GB_POWER_SUPPLY_HEALTH_DEAD 0x0003
  375. #define GB_POWER_SUPPLY_HEALTH_OVERVOLTAGE 0x0004
  376. #define GB_POWER_SUPPLY_HEALTH_UNSPEC_FAILURE 0x0005
  377. #define GB_POWER_SUPPLY_HEALTH_COLD 0x0006
  378. #define GB_POWER_SUPPLY_HEALTH_WATCHDOG_TIMER_EXPIRE 0x0007
  379. #define GB_POWER_SUPPLY_HEALTH_SAFETY_TIMER_EXPIRE 0x0008
  380. /* Greybus power supply status values */
  381. #define GB_POWER_SUPPLY_STATUS_UNKNOWN 0x0000
  382. #define GB_POWER_SUPPLY_STATUS_CHARGING 0x0001
  383. #define GB_POWER_SUPPLY_STATUS_DISCHARGING 0x0002
  384. #define GB_POWER_SUPPLY_STATUS_NOT_CHARGING 0x0003
  385. #define GB_POWER_SUPPLY_STATUS_FULL 0x0004
  386. /* Greybus power supply capacity level values */
  387. #define GB_POWER_SUPPLY_CAPACITY_LEVEL_UNKNOWN 0x0000
  388. #define GB_POWER_SUPPLY_CAPACITY_LEVEL_CRITICAL 0x0001
  389. #define GB_POWER_SUPPLY_CAPACITY_LEVEL_LOW 0x0002
  390. #define GB_POWER_SUPPLY_CAPACITY_LEVEL_NORMAL 0x0003
  391. #define GB_POWER_SUPPLY_CAPACITY_LEVEL_HIGH 0x0004
  392. #define GB_POWER_SUPPLY_CAPACITY_LEVEL_FULL 0x0005
  393. /* Greybus power supply scope values */
  394. #define GB_POWER_SUPPLY_SCOPE_UNKNOWN 0x0000
  395. #define GB_POWER_SUPPLY_SCOPE_SYSTEM 0x0001
  396. #define GB_POWER_SUPPLY_SCOPE_DEVICE 0x0002
  397. struct gb_power_supply_get_supplies_response {
  398. __u8 supplies_count;
  399. } __packed;
  400. struct gb_power_supply_get_description_request {
  401. __u8 psy_id;
  402. } __packed;
  403. struct gb_power_supply_get_description_response {
  404. __u8 manufacturer[32];
  405. __u8 model[32];
  406. __u8 serial_number[32];
  407. __le16 type;
  408. __u8 properties_count;
  409. } __packed;
  410. struct gb_power_supply_props_desc {
  411. __u8 property;
  412. #define GB_POWER_SUPPLY_PROP_STATUS 0x00
  413. #define GB_POWER_SUPPLY_PROP_CHARGE_TYPE 0x01
  414. #define GB_POWER_SUPPLY_PROP_HEALTH 0x02
  415. #define GB_POWER_SUPPLY_PROP_PRESENT 0x03
  416. #define GB_POWER_SUPPLY_PROP_ONLINE 0x04
  417. #define GB_POWER_SUPPLY_PROP_AUTHENTIC 0x05
  418. #define GB_POWER_SUPPLY_PROP_TECHNOLOGY 0x06
  419. #define GB_POWER_SUPPLY_PROP_CYCLE_COUNT 0x07
  420. #define GB_POWER_SUPPLY_PROP_VOLTAGE_MAX 0x08
  421. #define GB_POWER_SUPPLY_PROP_VOLTAGE_MIN 0x09
  422. #define GB_POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN 0x0A
  423. #define GB_POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN 0x0B
  424. #define GB_POWER_SUPPLY_PROP_VOLTAGE_NOW 0x0C
  425. #define GB_POWER_SUPPLY_PROP_VOLTAGE_AVG 0x0D
  426. #define GB_POWER_SUPPLY_PROP_VOLTAGE_OCV 0x0E
  427. #define GB_POWER_SUPPLY_PROP_VOLTAGE_BOOT 0x0F
  428. #define GB_POWER_SUPPLY_PROP_CURRENT_MAX 0x10
  429. #define GB_POWER_SUPPLY_PROP_CURRENT_NOW 0x11
  430. #define GB_POWER_SUPPLY_PROP_CURRENT_AVG 0x12
  431. #define GB_POWER_SUPPLY_PROP_CURRENT_BOOT 0x13
  432. #define GB_POWER_SUPPLY_PROP_POWER_NOW 0x14
  433. #define GB_POWER_SUPPLY_PROP_POWER_AVG 0x15
  434. #define GB_POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN 0x16
  435. #define GB_POWER_SUPPLY_PROP_CHARGE_EMPTY_DESIGN 0x17
  436. #define GB_POWER_SUPPLY_PROP_CHARGE_FULL 0x18
  437. #define GB_POWER_SUPPLY_PROP_CHARGE_EMPTY 0x19
  438. #define GB_POWER_SUPPLY_PROP_CHARGE_NOW 0x1A
  439. #define GB_POWER_SUPPLY_PROP_CHARGE_AVG 0x1B
  440. #define GB_POWER_SUPPLY_PROP_CHARGE_COUNTER 0x1C
  441. #define GB_POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT 0x1D
  442. #define GB_POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX 0x1E
  443. #define GB_POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE 0x1F
  444. #define GB_POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX 0x20
  445. #define GB_POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT 0x21
  446. #define GB_POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT_MAX 0x22
  447. #define GB_POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT 0x23
  448. #define GB_POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN 0x24
  449. #define GB_POWER_SUPPLY_PROP_ENERGY_EMPTY_DESIGN 0x25
  450. #define GB_POWER_SUPPLY_PROP_ENERGY_FULL 0x26
  451. #define GB_POWER_SUPPLY_PROP_ENERGY_EMPTY 0x27
  452. #define GB_POWER_SUPPLY_PROP_ENERGY_NOW 0x28
  453. #define GB_POWER_SUPPLY_PROP_ENERGY_AVG 0x29
  454. #define GB_POWER_SUPPLY_PROP_CAPACITY 0x2A
  455. #define GB_POWER_SUPPLY_PROP_CAPACITY_ALERT_MIN 0x2B
  456. #define GB_POWER_SUPPLY_PROP_CAPACITY_ALERT_MAX 0x2C
  457. #define GB_POWER_SUPPLY_PROP_CAPACITY_LEVEL 0x2D
  458. #define GB_POWER_SUPPLY_PROP_TEMP 0x2E
  459. #define GB_POWER_SUPPLY_PROP_TEMP_MAX 0x2F
  460. #define GB_POWER_SUPPLY_PROP_TEMP_MIN 0x30
  461. #define GB_POWER_SUPPLY_PROP_TEMP_ALERT_MIN 0x31
  462. #define GB_POWER_SUPPLY_PROP_TEMP_ALERT_MAX 0x32
  463. #define GB_POWER_SUPPLY_PROP_TEMP_AMBIENT 0x33
  464. #define GB_POWER_SUPPLY_PROP_TEMP_AMBIENT_ALERT_MIN 0x34
  465. #define GB_POWER_SUPPLY_PROP_TEMP_AMBIENT_ALERT_MAX 0x35
  466. #define GB_POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW 0x36
  467. #define GB_POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG 0x37
  468. #define GB_POWER_SUPPLY_PROP_TIME_TO_FULL_NOW 0x38
  469. #define GB_POWER_SUPPLY_PROP_TIME_TO_FULL_AVG 0x39
  470. #define GB_POWER_SUPPLY_PROP_TYPE 0x3A
  471. #define GB_POWER_SUPPLY_PROP_SCOPE 0x3B
  472. #define GB_POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT 0x3C
  473. #define GB_POWER_SUPPLY_PROP_CALIBRATE 0x3D
  474. __u8 is_writeable;
  475. } __packed;
  476. struct gb_power_supply_get_property_descriptors_request {
  477. __u8 psy_id;
  478. } __packed;
  479. struct gb_power_supply_get_property_descriptors_response {
  480. __u8 properties_count;
  481. struct gb_power_supply_props_desc props[];
  482. } __packed;
  483. struct gb_power_supply_get_property_request {
  484. __u8 psy_id;
  485. __u8 property;
  486. } __packed;
  487. struct gb_power_supply_get_property_response {
  488. __le32 prop_val;
  489. };
  490. struct gb_power_supply_set_property_request {
  491. __u8 psy_id;
  492. __u8 property;
  493. __le32 prop_val;
  494. } __packed;
  495. struct gb_power_supply_event_request {
  496. __u8 psy_id;
  497. __u8 event;
  498. #define GB_POWER_SUPPLY_UPDATE 0x01
  499. } __packed;
  500. /* HID */
  501. /* Greybus HID operation types */
  502. #define GB_HID_TYPE_GET_DESC 0x02
  503. #define GB_HID_TYPE_GET_REPORT_DESC 0x03
  504. #define GB_HID_TYPE_PWR_ON 0x04
  505. #define GB_HID_TYPE_PWR_OFF 0x05
  506. #define GB_HID_TYPE_GET_REPORT 0x06
  507. #define GB_HID_TYPE_SET_REPORT 0x07
  508. #define GB_HID_TYPE_IRQ_EVENT 0x08
  509. /* Report type */
  510. #define GB_HID_INPUT_REPORT 0
  511. #define GB_HID_OUTPUT_REPORT 1
  512. #define GB_HID_FEATURE_REPORT 2
  513. /* Different request/response structures */
  514. /* HID get descriptor response */
  515. struct gb_hid_desc_response {
  516. __u8 bLength;
  517. __le16 wReportDescLength;
  518. __le16 bcdHID;
  519. __le16 wProductID;
  520. __le16 wVendorID;
  521. __u8 bCountryCode;
  522. } __packed;
  523. /* HID get report request/response */
  524. struct gb_hid_get_report_request {
  525. __u8 report_type;
  526. __u8 report_id;
  527. } __packed;
  528. /* HID set report request */
  529. struct gb_hid_set_report_request {
  530. __u8 report_type;
  531. __u8 report_id;
  532. __u8 report[];
  533. } __packed;
  534. /* HID input report request, via interrupt pipe */
  535. struct gb_hid_input_report_request {
  536. __u8 report[0];
  537. } __packed;
  538. /* I2C */
  539. /* Greybus i2c request types */
  540. #define GB_I2C_TYPE_FUNCTIONALITY 0x02
  541. #define GB_I2C_TYPE_TRANSFER 0x05
  542. /* functionality request has no payload */
  543. struct gb_i2c_functionality_response {
  544. __le32 functionality;
  545. } __packed;
  546. /*
  547. * Outgoing data immediately follows the op count and ops array.
  548. * The data for each write (master -> slave) op in the array is sent
  549. * in order, with no (e.g. pad) bytes separating them.
  550. *
  551. * Short reads cause the entire transfer request to fail So response
  552. * payload consists only of bytes read, and the number of bytes is
  553. * exactly what was specified in the corresponding op. Like
  554. * outgoing data, the incoming data is in order and contiguous.
  555. */
  556. struct gb_i2c_transfer_op {
  557. __le16 addr;
  558. __le16 flags;
  559. __le16 size;
  560. } __packed;
  561. struct gb_i2c_transfer_request {
  562. __le16 op_count;
  563. struct gb_i2c_transfer_op ops[]; /* op_count of these */
  564. } __packed;
  565. struct gb_i2c_transfer_response {
  566. __u8 data[0]; /* inbound data */
  567. } __packed;
  568. /* GPIO */
  569. /* Greybus GPIO request types */
  570. #define GB_GPIO_TYPE_LINE_COUNT 0x02
  571. #define GB_GPIO_TYPE_ACTIVATE 0x03
  572. #define GB_GPIO_TYPE_DEACTIVATE 0x04
  573. #define GB_GPIO_TYPE_GET_DIRECTION 0x05
  574. #define GB_GPIO_TYPE_DIRECTION_IN 0x06
  575. #define GB_GPIO_TYPE_DIRECTION_OUT 0x07
  576. #define GB_GPIO_TYPE_GET_VALUE 0x08
  577. #define GB_GPIO_TYPE_SET_VALUE 0x09
  578. #define GB_GPIO_TYPE_SET_DEBOUNCE 0x0a
  579. #define GB_GPIO_TYPE_IRQ_TYPE 0x0b
  580. #define GB_GPIO_TYPE_IRQ_MASK 0x0c
  581. #define GB_GPIO_TYPE_IRQ_UNMASK 0x0d
  582. #define GB_GPIO_TYPE_IRQ_EVENT 0x0e
  583. #define GB_GPIO_IRQ_TYPE_NONE 0x00
  584. #define GB_GPIO_IRQ_TYPE_EDGE_RISING 0x01
  585. #define GB_GPIO_IRQ_TYPE_EDGE_FALLING 0x02
  586. #define GB_GPIO_IRQ_TYPE_EDGE_BOTH 0x03
  587. #define GB_GPIO_IRQ_TYPE_LEVEL_HIGH 0x04
  588. #define GB_GPIO_IRQ_TYPE_LEVEL_LOW 0x08
  589. /* line count request has no payload */
  590. struct gb_gpio_line_count_response {
  591. __u8 count;
  592. } __packed;
  593. struct gb_gpio_activate_request {
  594. __u8 which;
  595. } __packed;
  596. /* activate response has no payload */
  597. struct gb_gpio_deactivate_request {
  598. __u8 which;
  599. } __packed;
  600. /* deactivate response has no payload */
  601. struct gb_gpio_get_direction_request {
  602. __u8 which;
  603. } __packed;
  604. struct gb_gpio_get_direction_response {
  605. __u8 direction;
  606. } __packed;
  607. struct gb_gpio_direction_in_request {
  608. __u8 which;
  609. } __packed;
  610. /* direction in response has no payload */
  611. struct gb_gpio_direction_out_request {
  612. __u8 which;
  613. __u8 value;
  614. } __packed;
  615. /* direction out response has no payload */
  616. struct gb_gpio_get_value_request {
  617. __u8 which;
  618. } __packed;
  619. struct gb_gpio_get_value_response {
  620. __u8 value;
  621. } __packed;
  622. struct gb_gpio_set_value_request {
  623. __u8 which;
  624. __u8 value;
  625. } __packed;
  626. /* set value response has no payload */
  627. struct gb_gpio_set_debounce_request {
  628. __u8 which;
  629. __le16 usec;
  630. } __packed;
  631. /* debounce response has no payload */
  632. struct gb_gpio_irq_type_request {
  633. __u8 which;
  634. __u8 type;
  635. } __packed;
  636. /* irq type response has no payload */
  637. struct gb_gpio_irq_mask_request {
  638. __u8 which;
  639. } __packed;
  640. /* irq mask response has no payload */
  641. struct gb_gpio_irq_unmask_request {
  642. __u8 which;
  643. } __packed;
  644. /* irq unmask response has no payload */
  645. /* irq event requests originate on another module and are handled on the AP */
  646. struct gb_gpio_irq_event_request {
  647. __u8 which;
  648. } __packed;
  649. /* irq event has no response */
  650. /* PWM */
  651. /* Greybus PWM operation types */
  652. #define GB_PWM_TYPE_PWM_COUNT 0x02
  653. #define GB_PWM_TYPE_ACTIVATE 0x03
  654. #define GB_PWM_TYPE_DEACTIVATE 0x04
  655. #define GB_PWM_TYPE_CONFIG 0x05
  656. #define GB_PWM_TYPE_POLARITY 0x06
  657. #define GB_PWM_TYPE_ENABLE 0x07
  658. #define GB_PWM_TYPE_DISABLE 0x08
  659. /* pwm count request has no payload */
  660. struct gb_pwm_count_response {
  661. __u8 count;
  662. } __packed;
  663. struct gb_pwm_activate_request {
  664. __u8 which;
  665. } __packed;
  666. struct gb_pwm_deactivate_request {
  667. __u8 which;
  668. } __packed;
  669. struct gb_pwm_config_request {
  670. __u8 which;
  671. __le32 duty;
  672. __le32 period;
  673. } __packed;
  674. struct gb_pwm_polarity_request {
  675. __u8 which;
  676. __u8 polarity;
  677. } __packed;
  678. struct gb_pwm_enable_request {
  679. __u8 which;
  680. } __packed;
  681. struct gb_pwm_disable_request {
  682. __u8 which;
  683. } __packed;
  684. /* SPI */
  685. /* Should match up with modes in linux/spi/spi.h */
  686. #define GB_SPI_MODE_CPHA 0x01 /* clock phase */
  687. #define GB_SPI_MODE_CPOL 0x02 /* clock polarity */
  688. #define GB_SPI_MODE_MODE_0 (0 | 0) /* (original MicroWire) */
  689. #define GB_SPI_MODE_MODE_1 (0 | GB_SPI_MODE_CPHA)
  690. #define GB_SPI_MODE_MODE_2 (GB_SPI_MODE_CPOL | 0)
  691. #define GB_SPI_MODE_MODE_3 (GB_SPI_MODE_CPOL | GB_SPI_MODE_CPHA)
  692. #define GB_SPI_MODE_CS_HIGH 0x04 /* chipselect active high? */
  693. #define GB_SPI_MODE_LSB_FIRST 0x08 /* per-word bits-on-wire */
  694. #define GB_SPI_MODE_3WIRE 0x10 /* SI/SO signals shared */
  695. #define GB_SPI_MODE_LOOP 0x20 /* loopback mode */
  696. #define GB_SPI_MODE_NO_CS 0x40 /* 1 dev/bus, no chipselect */
  697. #define GB_SPI_MODE_READY 0x80 /* slave pulls low to pause */
  698. /* Should match up with flags in linux/spi/spi.h */
  699. #define GB_SPI_FLAG_HALF_DUPLEX BIT(0) /* can't do full duplex */
  700. #define GB_SPI_FLAG_NO_RX BIT(1) /* can't do buffer read */
  701. #define GB_SPI_FLAG_NO_TX BIT(2) /* can't do buffer write */
  702. /* Greybus spi operation types */
  703. #define GB_SPI_TYPE_MASTER_CONFIG 0x02
  704. #define GB_SPI_TYPE_DEVICE_CONFIG 0x03
  705. #define GB_SPI_TYPE_TRANSFER 0x04
  706. /* mode request has no payload */
  707. struct gb_spi_master_config_response {
  708. __le32 bits_per_word_mask;
  709. __le32 min_speed_hz;
  710. __le32 max_speed_hz;
  711. __le16 mode;
  712. __le16 flags;
  713. __u8 num_chipselect;
  714. } __packed;
  715. struct gb_spi_device_config_request {
  716. __u8 chip_select;
  717. } __packed;
  718. struct gb_spi_device_config_response {
  719. __le16 mode;
  720. __u8 bits_per_word;
  721. __le32 max_speed_hz;
  722. __u8 device_type;
  723. #define GB_SPI_SPI_DEV 0x00
  724. #define GB_SPI_SPI_NOR 0x01
  725. #define GB_SPI_SPI_MODALIAS 0x02
  726. __u8 name[32];
  727. } __packed;
  728. /**
  729. * struct gb_spi_transfer - a read/write buffer pair
  730. * @speed_hz: Select a speed other than the device default for this transfer. If
  731. * 0 the default (from @spi_device) is used.
  732. * @len: size of rx and tx buffers (in bytes)
  733. * @delay_usecs: microseconds to delay after this transfer before (optionally)
  734. * changing the chipselect status, then starting the next transfer or
  735. * completing this spi_message.
  736. * @cs_change: affects chipselect after this transfer completes
  737. * @bits_per_word: select a bits_per_word other than the device default for this
  738. * transfer. If 0 the default (from @spi_device) is used.
  739. */
  740. struct gb_spi_transfer {
  741. __le32 speed_hz;
  742. __le32 len;
  743. __le16 delay_usecs;
  744. __u8 cs_change;
  745. __u8 bits_per_word;
  746. __u8 xfer_flags;
  747. #define GB_SPI_XFER_READ 0x01
  748. #define GB_SPI_XFER_WRITE 0x02
  749. #define GB_SPI_XFER_INPROGRESS 0x04
  750. } __packed;
  751. struct gb_spi_transfer_request {
  752. __u8 chip_select; /* of the spi device */
  753. __u8 mode; /* of the spi device */
  754. __le16 count;
  755. struct gb_spi_transfer transfers[]; /* count of these */
  756. } __packed;
  757. struct gb_spi_transfer_response {
  758. __u8 data[0]; /* inbound data */
  759. } __packed;
  760. /* Version of the Greybus SVC protocol we support */
  761. #define GB_SVC_VERSION_MAJOR 0x00
  762. #define GB_SVC_VERSION_MINOR 0x01
  763. /* Greybus SVC request types */
  764. #define GB_SVC_TYPE_PROTOCOL_VERSION 0x01
  765. #define GB_SVC_TYPE_SVC_HELLO 0x02
  766. #define GB_SVC_TYPE_INTF_DEVICE_ID 0x03
  767. #define GB_SVC_TYPE_INTF_RESET 0x06
  768. #define GB_SVC_TYPE_CONN_CREATE 0x07
  769. #define GB_SVC_TYPE_CONN_DESTROY 0x08
  770. #define GB_SVC_TYPE_DME_PEER_GET 0x09
  771. #define GB_SVC_TYPE_DME_PEER_SET 0x0a
  772. #define GB_SVC_TYPE_ROUTE_CREATE 0x0b
  773. #define GB_SVC_TYPE_ROUTE_DESTROY 0x0c
  774. #define GB_SVC_TYPE_TIMESYNC_ENABLE 0x0d
  775. #define GB_SVC_TYPE_TIMESYNC_DISABLE 0x0e
  776. #define GB_SVC_TYPE_TIMESYNC_AUTHORITATIVE 0x0f
  777. #define GB_SVC_TYPE_INTF_SET_PWRM 0x10
  778. #define GB_SVC_TYPE_INTF_EJECT 0x11
  779. #define GB_SVC_TYPE_PING 0x13
  780. #define GB_SVC_TYPE_PWRMON_RAIL_COUNT_GET 0x14
  781. #define GB_SVC_TYPE_PWRMON_RAIL_NAMES_GET 0x15
  782. #define GB_SVC_TYPE_PWRMON_SAMPLE_GET 0x16
  783. #define GB_SVC_TYPE_PWRMON_INTF_SAMPLE_GET 0x17
  784. #define GB_SVC_TYPE_TIMESYNC_WAKE_PINS_ACQUIRE 0x18
  785. #define GB_SVC_TYPE_TIMESYNC_WAKE_PINS_RELEASE 0x19
  786. #define GB_SVC_TYPE_TIMESYNC_PING 0x1a
  787. #define GB_SVC_TYPE_MODULE_INSERTED 0x1f
  788. #define GB_SVC_TYPE_MODULE_REMOVED 0x20
  789. #define GB_SVC_TYPE_INTF_VSYS_ENABLE 0x21
  790. #define GB_SVC_TYPE_INTF_VSYS_DISABLE 0x22
  791. #define GB_SVC_TYPE_INTF_REFCLK_ENABLE 0x23
  792. #define GB_SVC_TYPE_INTF_REFCLK_DISABLE 0x24
  793. #define GB_SVC_TYPE_INTF_UNIPRO_ENABLE 0x25
  794. #define GB_SVC_TYPE_INTF_UNIPRO_DISABLE 0x26
  795. #define GB_SVC_TYPE_INTF_ACTIVATE 0x27
  796. #define GB_SVC_TYPE_INTF_RESUME 0x28
  797. #define GB_SVC_TYPE_INTF_MAILBOX_EVENT 0x29
  798. #define GB_SVC_TYPE_INTF_OOPS 0x2a
  799. /* Greybus SVC protocol status values */
  800. #define GB_SVC_OP_SUCCESS 0x00
  801. #define GB_SVC_OP_UNKNOWN_ERROR 0x01
  802. #define GB_SVC_INTF_NOT_DETECTED 0x02
  803. #define GB_SVC_INTF_NO_UPRO_LINK 0x03
  804. #define GB_SVC_INTF_UPRO_NOT_DOWN 0x04
  805. #define GB_SVC_INTF_UPRO_NOT_HIBERNATED 0x05
  806. #define GB_SVC_INTF_NO_V_SYS 0x06
  807. #define GB_SVC_INTF_V_CHG 0x07
  808. #define GB_SVC_INTF_WAKE_BUSY 0x08
  809. #define GB_SVC_INTF_NO_REFCLK 0x09
  810. #define GB_SVC_INTF_RELEASING 0x0a
  811. #define GB_SVC_INTF_NO_ORDER 0x0b
  812. #define GB_SVC_INTF_MBOX_SET 0x0c
  813. #define GB_SVC_INTF_BAD_MBOX 0x0d
  814. #define GB_SVC_INTF_OP_TIMEOUT 0x0e
  815. #define GB_SVC_PWRMON_OP_NOT_PRESENT 0x0f
  816. struct gb_svc_version_request {
  817. __u8 major;
  818. __u8 minor;
  819. } __packed;
  820. struct gb_svc_version_response {
  821. __u8 major;
  822. __u8 minor;
  823. } __packed;
  824. /* SVC protocol hello request */
  825. struct gb_svc_hello_request {
  826. __le16 endo_id;
  827. __u8 interface_id;
  828. } __packed;
  829. /* hello response has no payload */
  830. struct gb_svc_intf_device_id_request {
  831. __u8 intf_id;
  832. __u8 device_id;
  833. } __packed;
  834. /* device id response has no payload */
  835. struct gb_svc_intf_reset_request {
  836. __u8 intf_id;
  837. } __packed;
  838. /* interface reset response has no payload */
  839. struct gb_svc_intf_eject_request {
  840. __u8 intf_id;
  841. } __packed;
  842. /* interface eject response has no payload */
  843. struct gb_svc_conn_create_request {
  844. __u8 intf1_id;
  845. __le16 cport1_id;
  846. __u8 intf2_id;
  847. __le16 cport2_id;
  848. __u8 tc;
  849. __u8 flags;
  850. } __packed;
  851. /* connection create response has no payload */
  852. struct gb_svc_conn_destroy_request {
  853. __u8 intf1_id;
  854. __le16 cport1_id;
  855. __u8 intf2_id;
  856. __le16 cport2_id;
  857. } __packed;
  858. /* connection destroy response has no payload */
  859. struct gb_svc_dme_peer_get_request {
  860. __u8 intf_id;
  861. __le16 attr;
  862. __le16 selector;
  863. } __packed;
  864. struct gb_svc_dme_peer_get_response {
  865. __le16 result_code;
  866. __le32 attr_value;
  867. } __packed;
  868. struct gb_svc_dme_peer_set_request {
  869. __u8 intf_id;
  870. __le16 attr;
  871. __le16 selector;
  872. __le32 value;
  873. } __packed;
  874. struct gb_svc_dme_peer_set_response {
  875. __le16 result_code;
  876. } __packed;
  877. /* Greybus init-status values, currently retrieved using DME peer gets. */
  878. #define GB_INIT_SPI_BOOT_STARTED 0x02
  879. #define GB_INIT_TRUSTED_SPI_BOOT_FINISHED 0x03
  880. #define GB_INIT_UNTRUSTED_SPI_BOOT_FINISHED 0x04
  881. #define GB_INIT_BOOTROM_UNIPRO_BOOT_STARTED 0x06
  882. #define GB_INIT_BOOTROM_FALLBACK_UNIPRO_BOOT_STARTED 0x09
  883. #define GB_INIT_S2_LOADER_BOOT_STARTED 0x0D
  884. struct gb_svc_route_create_request {
  885. __u8 intf1_id;
  886. __u8 dev1_id;
  887. __u8 intf2_id;
  888. __u8 dev2_id;
  889. } __packed;
  890. /* route create response has no payload */
  891. struct gb_svc_route_destroy_request {
  892. __u8 intf1_id;
  893. __u8 intf2_id;
  894. } __packed;
  895. /* route destroy response has no payload */
  896. /* used for svc_intf_vsys_{enable,disable} */
  897. struct gb_svc_intf_vsys_request {
  898. __u8 intf_id;
  899. } __packed;
  900. struct gb_svc_intf_vsys_response {
  901. __u8 result_code;
  902. #define GB_SVC_INTF_VSYS_OK 0x00
  903. /* 0x01 is reserved */
  904. #define GB_SVC_INTF_VSYS_FAIL 0x02
  905. } __packed;
  906. /* used for svc_intf_refclk_{enable,disable} */
  907. struct gb_svc_intf_refclk_request {
  908. __u8 intf_id;
  909. } __packed;
  910. struct gb_svc_intf_refclk_response {
  911. __u8 result_code;
  912. #define GB_SVC_INTF_REFCLK_OK 0x00
  913. /* 0x01 is reserved */
  914. #define GB_SVC_INTF_REFCLK_FAIL 0x02
  915. } __packed;
  916. /* used for svc_intf_unipro_{enable,disable} */
  917. struct gb_svc_intf_unipro_request {
  918. __u8 intf_id;
  919. } __packed;
  920. struct gb_svc_intf_unipro_response {
  921. __u8 result_code;
  922. #define GB_SVC_INTF_UNIPRO_OK 0x00
  923. /* 0x01 is reserved */
  924. #define GB_SVC_INTF_UNIPRO_FAIL 0x02
  925. #define GB_SVC_INTF_UNIPRO_NOT_OFF 0x03
  926. } __packed;
  927. #define GB_SVC_UNIPRO_FAST_MODE 0x01
  928. #define GB_SVC_UNIPRO_SLOW_MODE 0x02
  929. #define GB_SVC_UNIPRO_FAST_AUTO_MODE 0x04
  930. #define GB_SVC_UNIPRO_SLOW_AUTO_MODE 0x05
  931. #define GB_SVC_UNIPRO_MODE_UNCHANGED 0x07
  932. #define GB_SVC_UNIPRO_HIBERNATE_MODE 0x11
  933. #define GB_SVC_UNIPRO_OFF_MODE 0x12
  934. #define GB_SVC_SMALL_AMPLITUDE 0x01
  935. #define GB_SVC_LARGE_AMPLITUDE 0x02
  936. #define GB_SVC_NO_DE_EMPHASIS 0x00
  937. #define GB_SVC_SMALL_DE_EMPHASIS 0x01
  938. #define GB_SVC_LARGE_DE_EMPHASIS 0x02
  939. #define GB_SVC_PWRM_RXTERMINATION 0x01
  940. #define GB_SVC_PWRM_TXTERMINATION 0x02
  941. #define GB_SVC_PWRM_LINE_RESET 0x04
  942. #define GB_SVC_PWRM_SCRAMBLING 0x20
  943. #define GB_SVC_PWRM_QUIRK_HSSER 0x00000001
  944. #define GB_SVC_UNIPRO_HS_SERIES_A 0x01
  945. #define GB_SVC_UNIPRO_HS_SERIES_B 0x02
  946. #define GB_SVC_SETPWRM_PWR_OK 0x00
  947. #define GB_SVC_SETPWRM_PWR_LOCAL 0x01
  948. #define GB_SVC_SETPWRM_PWR_REMOTE 0x02
  949. #define GB_SVC_SETPWRM_PWR_BUSY 0x03
  950. #define GB_SVC_SETPWRM_PWR_ERROR_CAP 0x04
  951. #define GB_SVC_SETPWRM_PWR_FATAL_ERROR 0x05
  952. struct gb_svc_l2_timer_cfg {
  953. __le16 tsb_fc0_protection_timeout;
  954. __le16 tsb_tc0_replay_timeout;
  955. __le16 tsb_afc0_req_timeout;
  956. __le16 tsb_fc1_protection_timeout;
  957. __le16 tsb_tc1_replay_timeout;
  958. __le16 tsb_afc1_req_timeout;
  959. __le16 reserved_for_tc2[3];
  960. __le16 reserved_for_tc3[3];
  961. } __packed;
  962. struct gb_svc_intf_set_pwrm_request {
  963. __u8 intf_id;
  964. __u8 hs_series;
  965. __u8 tx_mode;
  966. __u8 tx_gear;
  967. __u8 tx_nlanes;
  968. __u8 tx_amplitude;
  969. __u8 tx_hs_equalizer;
  970. __u8 rx_mode;
  971. __u8 rx_gear;
  972. __u8 rx_nlanes;
  973. __u8 flags;
  974. __le32 quirks;
  975. struct gb_svc_l2_timer_cfg local_l2timerdata, remote_l2timerdata;
  976. } __packed;
  977. struct gb_svc_intf_set_pwrm_response {
  978. __u8 result_code;
  979. } __packed;
  980. struct gb_svc_key_event_request {
  981. __le16 key_code;
  982. #define GB_KEYCODE_ARA 0x00
  983. __u8 key_event;
  984. #define GB_SVC_KEY_RELEASED 0x00
  985. #define GB_SVC_KEY_PRESSED 0x01
  986. } __packed;
  987. #define GB_SVC_PWRMON_MAX_RAIL_COUNT 254
  988. struct gb_svc_pwrmon_rail_count_get_response {
  989. __u8 rail_count;
  990. } __packed;
  991. #define GB_SVC_PWRMON_RAIL_NAME_BUFSIZE 32
  992. struct gb_svc_pwrmon_rail_names_get_response {
  993. __u8 status;
  994. __u8 name[][GB_SVC_PWRMON_RAIL_NAME_BUFSIZE];
  995. } __packed;
  996. #define GB_SVC_PWRMON_TYPE_CURR 0x01
  997. #define GB_SVC_PWRMON_TYPE_VOL 0x02
  998. #define GB_SVC_PWRMON_TYPE_PWR 0x03
  999. #define GB_SVC_PWRMON_GET_SAMPLE_OK 0x00
  1000. #define GB_SVC_PWRMON_GET_SAMPLE_INVAL 0x01
  1001. #define GB_SVC_PWRMON_GET_SAMPLE_NOSUPP 0x02
  1002. #define GB_SVC_PWRMON_GET_SAMPLE_HWERR 0x03
  1003. struct gb_svc_pwrmon_sample_get_request {
  1004. __u8 rail_id;
  1005. __u8 measurement_type;
  1006. } __packed;
  1007. struct gb_svc_pwrmon_sample_get_response {
  1008. __u8 result;
  1009. __le32 measurement;
  1010. } __packed;
  1011. struct gb_svc_pwrmon_intf_sample_get_request {
  1012. __u8 intf_id;
  1013. __u8 measurement_type;
  1014. } __packed;
  1015. struct gb_svc_pwrmon_intf_sample_get_response {
  1016. __u8 result;
  1017. __le32 measurement;
  1018. } __packed;
  1019. #define GB_SVC_MODULE_INSERTED_FLAG_NO_PRIMARY 0x0001
  1020. struct gb_svc_module_inserted_request {
  1021. __u8 primary_intf_id;
  1022. __u8 intf_count;
  1023. __le16 flags;
  1024. } __packed;
  1025. /* module_inserted response has no payload */
  1026. struct gb_svc_module_removed_request {
  1027. __u8 primary_intf_id;
  1028. } __packed;
  1029. /* module_removed response has no payload */
  1030. struct gb_svc_intf_activate_request {
  1031. __u8 intf_id;
  1032. } __packed;
  1033. #define GB_SVC_INTF_TYPE_UNKNOWN 0x00
  1034. #define GB_SVC_INTF_TYPE_DUMMY 0x01
  1035. #define GB_SVC_INTF_TYPE_UNIPRO 0x02
  1036. #define GB_SVC_INTF_TYPE_GREYBUS 0x03
  1037. struct gb_svc_intf_activate_response {
  1038. __u8 status;
  1039. __u8 intf_type;
  1040. } __packed;
  1041. struct gb_svc_intf_resume_request {
  1042. __u8 intf_id;
  1043. } __packed;
  1044. struct gb_svc_intf_resume_response {
  1045. __u8 status;
  1046. } __packed;
  1047. #define GB_SVC_INTF_MAILBOX_NONE 0x00
  1048. #define GB_SVC_INTF_MAILBOX_AP 0x01
  1049. #define GB_SVC_INTF_MAILBOX_GREYBUS 0x02
  1050. struct gb_svc_intf_mailbox_event_request {
  1051. __u8 intf_id;
  1052. __le16 result_code;
  1053. __le32 mailbox;
  1054. } __packed;
  1055. /* intf_mailbox_event response has no payload */
  1056. struct gb_svc_intf_oops_request {
  1057. __u8 intf_id;
  1058. __u8 reason;
  1059. } __packed;
  1060. /* intf_oops response has no payload */
  1061. /* RAW */
  1062. /* Greybus raw request types */
  1063. #define GB_RAW_TYPE_SEND 0x02
  1064. struct gb_raw_send_request {
  1065. __le32 len;
  1066. __u8 data[];
  1067. } __packed;
  1068. /* UART */
  1069. /* Greybus UART operation types */
  1070. #define GB_UART_TYPE_SEND_DATA 0x02
  1071. #define GB_UART_TYPE_RECEIVE_DATA 0x03 /* Unsolicited data */
  1072. #define GB_UART_TYPE_SET_LINE_CODING 0x04
  1073. #define GB_UART_TYPE_SET_CONTROL_LINE_STATE 0x05
  1074. #define GB_UART_TYPE_SEND_BREAK 0x06
  1075. #define GB_UART_TYPE_SERIAL_STATE 0x07 /* Unsolicited data */
  1076. #define GB_UART_TYPE_RECEIVE_CREDITS 0x08
  1077. #define GB_UART_TYPE_FLUSH_FIFOS 0x09
  1078. /* Represents data from AP -> Module */
  1079. struct gb_uart_send_data_request {
  1080. __le16 size;
  1081. __u8 data[];
  1082. } __packed;
  1083. /* recv-data-request flags */
  1084. #define GB_UART_RECV_FLAG_FRAMING 0x01 /* Framing error */
  1085. #define GB_UART_RECV_FLAG_PARITY 0x02 /* Parity error */
  1086. #define GB_UART_RECV_FLAG_OVERRUN 0x04 /* Overrun error */
  1087. #define GB_UART_RECV_FLAG_BREAK 0x08 /* Break */
  1088. /* Represents data from Module -> AP */
  1089. struct gb_uart_recv_data_request {
  1090. __le16 size;
  1091. __u8 flags;
  1092. __u8 data[];
  1093. } __packed;
  1094. struct gb_uart_receive_credits_request {
  1095. __le16 count;
  1096. } __packed;
  1097. struct gb_uart_set_line_coding_request {
  1098. __le32 rate;
  1099. __u8 format;
  1100. #define GB_SERIAL_1_STOP_BITS 0
  1101. #define GB_SERIAL_1_5_STOP_BITS 1
  1102. #define GB_SERIAL_2_STOP_BITS 2
  1103. __u8 parity;
  1104. #define GB_SERIAL_NO_PARITY 0
  1105. #define GB_SERIAL_ODD_PARITY 1
  1106. #define GB_SERIAL_EVEN_PARITY 2
  1107. #define GB_SERIAL_MARK_PARITY 3
  1108. #define GB_SERIAL_SPACE_PARITY 4
  1109. __u8 data_bits;
  1110. __u8 flow_control;
  1111. #define GB_SERIAL_AUTO_RTSCTS_EN 0x1
  1112. } __packed;
  1113. /* output control lines */
  1114. #define GB_UART_CTRL_DTR 0x01
  1115. #define GB_UART_CTRL_RTS 0x02
  1116. struct gb_uart_set_control_line_state_request {
  1117. __u8 control;
  1118. } __packed;
  1119. struct gb_uart_set_break_request {
  1120. __u8 state;
  1121. } __packed;
  1122. /* input control lines and line errors */
  1123. #define GB_UART_CTRL_DCD 0x01
  1124. #define GB_UART_CTRL_DSR 0x02
  1125. #define GB_UART_CTRL_RI 0x04
  1126. struct gb_uart_serial_state_request {
  1127. __u8 control;
  1128. } __packed;
  1129. struct gb_uart_serial_flush_request {
  1130. __u8 flags;
  1131. #define GB_SERIAL_FLAG_FLUSH_TRANSMITTER 0x01
  1132. #define GB_SERIAL_FLAG_FLUSH_RECEIVER 0x02
  1133. } __packed;
  1134. /* Loopback */
  1135. /* Greybus loopback request types */
  1136. #define GB_LOOPBACK_TYPE_PING 0x02
  1137. #define GB_LOOPBACK_TYPE_TRANSFER 0x03
  1138. #define GB_LOOPBACK_TYPE_SINK 0x04
  1139. /*
  1140. * Loopback request/response header format should be identical
  1141. * to simplify bandwidth and data movement analysis.
  1142. */
  1143. struct gb_loopback_transfer_request {
  1144. __le32 len;
  1145. __le32 reserved0;
  1146. __le32 reserved1;
  1147. __u8 data[];
  1148. } __packed;
  1149. struct gb_loopback_transfer_response {
  1150. __le32 len;
  1151. __le32 reserved0;
  1152. __le32 reserved1;
  1153. __u8 data[];
  1154. } __packed;
  1155. /* SDIO */
  1156. /* Greybus SDIO operation types */
  1157. #define GB_SDIO_TYPE_GET_CAPABILITIES 0x02
  1158. #define GB_SDIO_TYPE_SET_IOS 0x03
  1159. #define GB_SDIO_TYPE_COMMAND 0x04
  1160. #define GB_SDIO_TYPE_TRANSFER 0x05
  1161. #define GB_SDIO_TYPE_EVENT 0x06
  1162. /* get caps response: request has no payload */
  1163. struct gb_sdio_get_caps_response {
  1164. __le32 caps;
  1165. #define GB_SDIO_CAP_NONREMOVABLE 0x00000001
  1166. #define GB_SDIO_CAP_4_BIT_DATA 0x00000002
  1167. #define GB_SDIO_CAP_8_BIT_DATA 0x00000004
  1168. #define GB_SDIO_CAP_MMC_HS 0x00000008
  1169. #define GB_SDIO_CAP_SD_HS 0x00000010
  1170. #define GB_SDIO_CAP_ERASE 0x00000020
  1171. #define GB_SDIO_CAP_1_2V_DDR 0x00000040
  1172. #define GB_SDIO_CAP_1_8V_DDR 0x00000080
  1173. #define GB_SDIO_CAP_POWER_OFF_CARD 0x00000100
  1174. #define GB_SDIO_CAP_UHS_SDR12 0x00000200
  1175. #define GB_SDIO_CAP_UHS_SDR25 0x00000400
  1176. #define GB_SDIO_CAP_UHS_SDR50 0x00000800
  1177. #define GB_SDIO_CAP_UHS_SDR104 0x00001000
  1178. #define GB_SDIO_CAP_UHS_DDR50 0x00002000
  1179. #define GB_SDIO_CAP_DRIVER_TYPE_A 0x00004000
  1180. #define GB_SDIO_CAP_DRIVER_TYPE_C 0x00008000
  1181. #define GB_SDIO_CAP_DRIVER_TYPE_D 0x00010000
  1182. #define GB_SDIO_CAP_HS200_1_2V 0x00020000
  1183. #define GB_SDIO_CAP_HS200_1_8V 0x00040000
  1184. #define GB_SDIO_CAP_HS400_1_2V 0x00080000
  1185. #define GB_SDIO_CAP_HS400_1_8V 0x00100000
  1186. /* see possible values below at vdd */
  1187. __le32 ocr;
  1188. __le32 f_min;
  1189. __le32 f_max;
  1190. __le16 max_blk_count;
  1191. __le16 max_blk_size;
  1192. } __packed;
  1193. /* set ios request: response has no payload */
  1194. struct gb_sdio_set_ios_request {
  1195. __le32 clock;
  1196. __le32 vdd;
  1197. #define GB_SDIO_VDD_165_195 0x00000001
  1198. #define GB_SDIO_VDD_20_21 0x00000002
  1199. #define GB_SDIO_VDD_21_22 0x00000004
  1200. #define GB_SDIO_VDD_22_23 0x00000008
  1201. #define GB_SDIO_VDD_23_24 0x00000010
  1202. #define GB_SDIO_VDD_24_25 0x00000020
  1203. #define GB_SDIO_VDD_25_26 0x00000040
  1204. #define GB_SDIO_VDD_26_27 0x00000080
  1205. #define GB_SDIO_VDD_27_28 0x00000100
  1206. #define GB_SDIO_VDD_28_29 0x00000200
  1207. #define GB_SDIO_VDD_29_30 0x00000400
  1208. #define GB_SDIO_VDD_30_31 0x00000800
  1209. #define GB_SDIO_VDD_31_32 0x00001000
  1210. #define GB_SDIO_VDD_32_33 0x00002000
  1211. #define GB_SDIO_VDD_33_34 0x00004000
  1212. #define GB_SDIO_VDD_34_35 0x00008000
  1213. #define GB_SDIO_VDD_35_36 0x00010000
  1214. __u8 bus_mode;
  1215. #define GB_SDIO_BUSMODE_OPENDRAIN 0x00
  1216. #define GB_SDIO_BUSMODE_PUSHPULL 0x01
  1217. __u8 power_mode;
  1218. #define GB_SDIO_POWER_OFF 0x00
  1219. #define GB_SDIO_POWER_UP 0x01
  1220. #define GB_SDIO_POWER_ON 0x02
  1221. #define GB_SDIO_POWER_UNDEFINED 0x03
  1222. __u8 bus_width;
  1223. #define GB_SDIO_BUS_WIDTH_1 0x00
  1224. #define GB_SDIO_BUS_WIDTH_4 0x02
  1225. #define GB_SDIO_BUS_WIDTH_8 0x03
  1226. __u8 timing;
  1227. #define GB_SDIO_TIMING_LEGACY 0x00
  1228. #define GB_SDIO_TIMING_MMC_HS 0x01
  1229. #define GB_SDIO_TIMING_SD_HS 0x02
  1230. #define GB_SDIO_TIMING_UHS_SDR12 0x03
  1231. #define GB_SDIO_TIMING_UHS_SDR25 0x04
  1232. #define GB_SDIO_TIMING_UHS_SDR50 0x05
  1233. #define GB_SDIO_TIMING_UHS_SDR104 0x06
  1234. #define GB_SDIO_TIMING_UHS_DDR50 0x07
  1235. #define GB_SDIO_TIMING_MMC_DDR52 0x08
  1236. #define GB_SDIO_TIMING_MMC_HS200 0x09
  1237. #define GB_SDIO_TIMING_MMC_HS400 0x0A
  1238. __u8 signal_voltage;
  1239. #define GB_SDIO_SIGNAL_VOLTAGE_330 0x00
  1240. #define GB_SDIO_SIGNAL_VOLTAGE_180 0x01
  1241. #define GB_SDIO_SIGNAL_VOLTAGE_120 0x02
  1242. __u8 drv_type;
  1243. #define GB_SDIO_SET_DRIVER_TYPE_B 0x00
  1244. #define GB_SDIO_SET_DRIVER_TYPE_A 0x01
  1245. #define GB_SDIO_SET_DRIVER_TYPE_C 0x02
  1246. #define GB_SDIO_SET_DRIVER_TYPE_D 0x03
  1247. } __packed;
  1248. /* command request */
  1249. struct gb_sdio_command_request {
  1250. __u8 cmd;
  1251. __u8 cmd_flags;
  1252. #define GB_SDIO_RSP_NONE 0x00
  1253. #define GB_SDIO_RSP_PRESENT 0x01
  1254. #define GB_SDIO_RSP_136 0x02
  1255. #define GB_SDIO_RSP_CRC 0x04
  1256. #define GB_SDIO_RSP_BUSY 0x08
  1257. #define GB_SDIO_RSP_OPCODE 0x10
  1258. __u8 cmd_type;
  1259. #define GB_SDIO_CMD_AC 0x00
  1260. #define GB_SDIO_CMD_ADTC 0x01
  1261. #define GB_SDIO_CMD_BC 0x02
  1262. #define GB_SDIO_CMD_BCR 0x03
  1263. __le32 cmd_arg;
  1264. __le16 data_blocks;
  1265. __le16 data_blksz;
  1266. } __packed;
  1267. struct gb_sdio_command_response {
  1268. __le32 resp[4];
  1269. } __packed;
  1270. /* transfer request */
  1271. struct gb_sdio_transfer_request {
  1272. __u8 data_flags;
  1273. #define GB_SDIO_DATA_WRITE 0x01
  1274. #define GB_SDIO_DATA_READ 0x02
  1275. #define GB_SDIO_DATA_STREAM 0x04
  1276. __le16 data_blocks;
  1277. __le16 data_blksz;
  1278. __u8 data[];
  1279. } __packed;
  1280. struct gb_sdio_transfer_response {
  1281. __le16 data_blocks;
  1282. __le16 data_blksz;
  1283. __u8 data[];
  1284. } __packed;
  1285. /* event request: generated by module and is defined as unidirectional */
  1286. struct gb_sdio_event_request {
  1287. __u8 event;
  1288. #define GB_SDIO_CARD_INSERTED 0x01
  1289. #define GB_SDIO_CARD_REMOVED 0x02
  1290. #define GB_SDIO_WP 0x04
  1291. } __packed;
  1292. /* Camera */
  1293. /* Greybus Camera request types */
  1294. #define GB_CAMERA_TYPE_CAPABILITIES 0x02
  1295. #define GB_CAMERA_TYPE_CONFIGURE_STREAMS 0x03
  1296. #define GB_CAMERA_TYPE_CAPTURE 0x04
  1297. #define GB_CAMERA_TYPE_FLUSH 0x05
  1298. #define GB_CAMERA_TYPE_METADATA 0x06
  1299. #define GB_CAMERA_MAX_STREAMS 4
  1300. #define GB_CAMERA_MAX_SETTINGS_SIZE 8192
  1301. /* Greybus Camera Configure Streams request payload */
  1302. struct gb_camera_stream_config_request {
  1303. __le16 width;
  1304. __le16 height;
  1305. __le16 format;
  1306. __le16 padding;
  1307. } __packed;
  1308. struct gb_camera_configure_streams_request {
  1309. __u8 num_streams;
  1310. __u8 flags;
  1311. #define GB_CAMERA_CONFIGURE_STREAMS_TEST_ONLY 0x01
  1312. __le16 padding;
  1313. struct gb_camera_stream_config_request config[];
  1314. } __packed;
  1315. /* Greybus Camera Configure Streams response payload */
  1316. struct gb_camera_stream_config_response {
  1317. __le16 width;
  1318. __le16 height;
  1319. __le16 format;
  1320. __u8 virtual_channel;
  1321. __u8 data_type[2];
  1322. __le16 max_pkt_size;
  1323. __u8 padding;
  1324. __le32 max_size;
  1325. } __packed;
  1326. struct gb_camera_configure_streams_response {
  1327. __u8 num_streams;
  1328. #define GB_CAMERA_CONFIGURE_STREAMS_ADJUSTED 0x01
  1329. __u8 flags;
  1330. __u8 padding[2];
  1331. __le32 data_rate;
  1332. struct gb_camera_stream_config_response config[];
  1333. };
  1334. /* Greybus Camera Capture request payload - response has no payload */
  1335. struct gb_camera_capture_request {
  1336. __le32 request_id;
  1337. __u8 streams;
  1338. __u8 padding;
  1339. __le16 num_frames;
  1340. __u8 settings[];
  1341. } __packed;
  1342. /* Greybus Camera Flush response payload - request has no payload */
  1343. struct gb_camera_flush_response {
  1344. __le32 request_id;
  1345. } __packed;
  1346. /* Greybus Camera Metadata request payload - operation has no response */
  1347. struct gb_camera_metadata_request {
  1348. __le32 request_id;
  1349. __le16 frame_number;
  1350. __u8 stream;
  1351. __u8 padding;
  1352. __u8 metadata[];
  1353. } __packed;
  1354. /* Lights */
  1355. /* Greybus Lights request types */
  1356. #define GB_LIGHTS_TYPE_GET_LIGHTS 0x02
  1357. #define GB_LIGHTS_TYPE_GET_LIGHT_CONFIG 0x03
  1358. #define GB_LIGHTS_TYPE_GET_CHANNEL_CONFIG 0x04
  1359. #define GB_LIGHTS_TYPE_GET_CHANNEL_FLASH_CONFIG 0x05
  1360. #define GB_LIGHTS_TYPE_SET_BRIGHTNESS 0x06
  1361. #define GB_LIGHTS_TYPE_SET_BLINK 0x07
  1362. #define GB_LIGHTS_TYPE_SET_COLOR 0x08
  1363. #define GB_LIGHTS_TYPE_SET_FADE 0x09
  1364. #define GB_LIGHTS_TYPE_EVENT 0x0A
  1365. #define GB_LIGHTS_TYPE_SET_FLASH_INTENSITY 0x0B
  1366. #define GB_LIGHTS_TYPE_SET_FLASH_STROBE 0x0C
  1367. #define GB_LIGHTS_TYPE_SET_FLASH_TIMEOUT 0x0D
  1368. #define GB_LIGHTS_TYPE_GET_FLASH_FAULT 0x0E
  1369. /* Greybus Light modes */
  1370. /*
  1371. * if you add any specific mode below, update also the
  1372. * GB_CHANNEL_MODE_DEFINED_RANGE value accordingly
  1373. */
  1374. #define GB_CHANNEL_MODE_NONE 0x00000000
  1375. #define GB_CHANNEL_MODE_BATTERY 0x00000001
  1376. #define GB_CHANNEL_MODE_POWER 0x00000002
  1377. #define GB_CHANNEL_MODE_WIRELESS 0x00000004
  1378. #define GB_CHANNEL_MODE_BLUETOOTH 0x00000008
  1379. #define GB_CHANNEL_MODE_KEYBOARD 0x00000010
  1380. #define GB_CHANNEL_MODE_BUTTONS 0x00000020
  1381. #define GB_CHANNEL_MODE_NOTIFICATION 0x00000040
  1382. #define GB_CHANNEL_MODE_ATTENTION 0x00000080
  1383. #define GB_CHANNEL_MODE_FLASH 0x00000100
  1384. #define GB_CHANNEL_MODE_TORCH 0x00000200
  1385. #define GB_CHANNEL_MODE_INDICATOR 0x00000400
  1386. /* Lights Mode valid bit values */
  1387. #define GB_CHANNEL_MODE_DEFINED_RANGE 0x000004FF
  1388. #define GB_CHANNEL_MODE_VENDOR_RANGE 0x00F00000
  1389. /* Greybus Light Channels Flags */
  1390. #define GB_LIGHT_CHANNEL_MULTICOLOR 0x00000001
  1391. #define GB_LIGHT_CHANNEL_FADER 0x00000002
  1392. #define GB_LIGHT_CHANNEL_BLINK 0x00000004
  1393. /* get count of lights in module */
  1394. struct gb_lights_get_lights_response {
  1395. __u8 lights_count;
  1396. } __packed;
  1397. /* light config request payload */
  1398. struct gb_lights_get_light_config_request {
  1399. __u8 id;
  1400. } __packed;
  1401. /* light config response payload */
  1402. struct gb_lights_get_light_config_response {
  1403. __u8 channel_count;
  1404. __u8 name[32];
  1405. } __packed;
  1406. /* channel config request payload */
  1407. struct gb_lights_get_channel_config_request {
  1408. __u8 light_id;
  1409. __u8 channel_id;
  1410. } __packed;
  1411. /* channel flash config request payload */
  1412. struct gb_lights_get_channel_flash_config_request {
  1413. __u8 light_id;
  1414. __u8 channel_id;
  1415. } __packed;
  1416. /* channel config response payload */
  1417. struct gb_lights_get_channel_config_response {
  1418. __u8 max_brightness;
  1419. __le32 flags;
  1420. __le32 color;
  1421. __u8 color_name[32];
  1422. __le32 mode;
  1423. __u8 mode_name[32];
  1424. } __packed;
  1425. /* channel flash config response payload */
  1426. struct gb_lights_get_channel_flash_config_response {
  1427. __le32 intensity_min_uA;
  1428. __le32 intensity_max_uA;
  1429. __le32 intensity_step_uA;
  1430. __le32 timeout_min_us;
  1431. __le32 timeout_max_us;
  1432. __le32 timeout_step_us;
  1433. } __packed;
  1434. /* blink request payload: response have no payload */
  1435. struct gb_lights_blink_request {
  1436. __u8 light_id;
  1437. __u8 channel_id;
  1438. __le16 time_on_ms;
  1439. __le16 time_off_ms;
  1440. } __packed;
  1441. /* set brightness request payload: response have no payload */
  1442. struct gb_lights_set_brightness_request {
  1443. __u8 light_id;
  1444. __u8 channel_id;
  1445. __u8 brightness;
  1446. } __packed;
  1447. /* set color request payload: response have no payload */
  1448. struct gb_lights_set_color_request {
  1449. __u8 light_id;
  1450. __u8 channel_id;
  1451. __le32 color;
  1452. } __packed;
  1453. /* set fade request payload: response have no payload */
  1454. struct gb_lights_set_fade_request {
  1455. __u8 light_id;
  1456. __u8 channel_id;
  1457. __u8 fade_in;
  1458. __u8 fade_out;
  1459. } __packed;
  1460. /* event request: generated by module */
  1461. struct gb_lights_event_request {
  1462. __u8 light_id;
  1463. __u8 event;
  1464. #define GB_LIGHTS_LIGHT_CONFIG 0x01
  1465. } __packed;
  1466. /* set flash intensity request payload: response have no payload */
  1467. struct gb_lights_set_flash_intensity_request {
  1468. __u8 light_id;
  1469. __u8 channel_id;
  1470. __le32 intensity_uA;
  1471. } __packed;
  1472. /* set flash strobe state request payload: response have no payload */
  1473. struct gb_lights_set_flash_strobe_request {
  1474. __u8 light_id;
  1475. __u8 channel_id;
  1476. __u8 state;
  1477. } __packed;
  1478. /* set flash timeout request payload: response have no payload */
  1479. struct gb_lights_set_flash_timeout_request {
  1480. __u8 light_id;
  1481. __u8 channel_id;
  1482. __le32 timeout_us;
  1483. } __packed;
  1484. /* get flash fault request payload */
  1485. struct gb_lights_get_flash_fault_request {
  1486. __u8 light_id;
  1487. __u8 channel_id;
  1488. } __packed;
  1489. /* get flash fault response payload */
  1490. struct gb_lights_get_flash_fault_response {
  1491. __le32 fault;
  1492. #define GB_LIGHTS_FLASH_FAULT_OVER_VOLTAGE 0x00000000
  1493. #define GB_LIGHTS_FLASH_FAULT_TIMEOUT 0x00000001
  1494. #define GB_LIGHTS_FLASH_FAULT_OVER_TEMPERATURE 0x00000002
  1495. #define GB_LIGHTS_FLASH_FAULT_SHORT_CIRCUIT 0x00000004
  1496. #define GB_LIGHTS_FLASH_FAULT_OVER_CURRENT 0x00000008
  1497. #define GB_LIGHTS_FLASH_FAULT_INDICATOR 0x00000010
  1498. #define GB_LIGHTS_FLASH_FAULT_UNDER_VOLTAGE 0x00000020
  1499. #define GB_LIGHTS_FLASH_FAULT_INPUT_VOLTAGE 0x00000040
  1500. #define GB_LIGHTS_FLASH_FAULT_LED_OVER_TEMPERATURE 0x00000080
  1501. } __packed;
  1502. /* Audio */
  1503. #define GB_AUDIO_TYPE_GET_TOPOLOGY_SIZE 0x02
  1504. #define GB_AUDIO_TYPE_GET_TOPOLOGY 0x03
  1505. #define GB_AUDIO_TYPE_GET_CONTROL 0x04
  1506. #define GB_AUDIO_TYPE_SET_CONTROL 0x05
  1507. #define GB_AUDIO_TYPE_ENABLE_WIDGET 0x06
  1508. #define GB_AUDIO_TYPE_DISABLE_WIDGET 0x07
  1509. #define GB_AUDIO_TYPE_GET_PCM 0x08
  1510. #define GB_AUDIO_TYPE_SET_PCM 0x09
  1511. #define GB_AUDIO_TYPE_SET_TX_DATA_SIZE 0x0a
  1512. /* 0x0b unused */
  1513. #define GB_AUDIO_TYPE_ACTIVATE_TX 0x0c
  1514. #define GB_AUDIO_TYPE_DEACTIVATE_TX 0x0d
  1515. #define GB_AUDIO_TYPE_SET_RX_DATA_SIZE 0x0e
  1516. /* 0x0f unused */
  1517. #define GB_AUDIO_TYPE_ACTIVATE_RX 0x10
  1518. #define GB_AUDIO_TYPE_DEACTIVATE_RX 0x11
  1519. #define GB_AUDIO_TYPE_JACK_EVENT 0x12
  1520. #define GB_AUDIO_TYPE_BUTTON_EVENT 0x13
  1521. #define GB_AUDIO_TYPE_STREAMING_EVENT 0x14
  1522. #define GB_AUDIO_TYPE_SEND_DATA 0x15
  1523. /* Module must be able to buffer 10ms of audio data, minimum */
  1524. #define GB_AUDIO_SAMPLE_BUFFER_MIN_US 10000
  1525. #define GB_AUDIO_PCM_NAME_MAX 32
  1526. #define AUDIO_DAI_NAME_MAX 32
  1527. #define AUDIO_CONTROL_NAME_MAX 32
  1528. #define AUDIO_CTL_ELEM_NAME_MAX 44
  1529. #define AUDIO_ENUM_NAME_MAX 64
  1530. #define AUDIO_WIDGET_NAME_MAX 32
  1531. /* See SNDRV_PCM_FMTBIT_* in Linux source */
  1532. #define GB_AUDIO_PCM_FMT_S8 BIT(0)
  1533. #define GB_AUDIO_PCM_FMT_U8 BIT(1)
  1534. #define GB_AUDIO_PCM_FMT_S16_LE BIT(2)
  1535. #define GB_AUDIO_PCM_FMT_S16_BE BIT(3)
  1536. #define GB_AUDIO_PCM_FMT_U16_LE BIT(4)
  1537. #define GB_AUDIO_PCM_FMT_U16_BE BIT(5)
  1538. #define GB_AUDIO_PCM_FMT_S24_LE BIT(6)
  1539. #define GB_AUDIO_PCM_FMT_S24_BE BIT(7)
  1540. #define GB_AUDIO_PCM_FMT_U24_LE BIT(8)
  1541. #define GB_AUDIO_PCM_FMT_U24_BE BIT(9)
  1542. #define GB_AUDIO_PCM_FMT_S32_LE BIT(10)
  1543. #define GB_AUDIO_PCM_FMT_S32_BE BIT(11)
  1544. #define GB_AUDIO_PCM_FMT_U32_LE BIT(12)
  1545. #define GB_AUDIO_PCM_FMT_U32_BE BIT(13)
  1546. /* See SNDRV_PCM_RATE_* in Linux source */
  1547. #define GB_AUDIO_PCM_RATE_5512 BIT(0)
  1548. #define GB_AUDIO_PCM_RATE_8000 BIT(1)
  1549. #define GB_AUDIO_PCM_RATE_11025 BIT(2)
  1550. #define GB_AUDIO_PCM_RATE_16000 BIT(3)
  1551. #define GB_AUDIO_PCM_RATE_22050 BIT(4)
  1552. #define GB_AUDIO_PCM_RATE_32000 BIT(5)
  1553. #define GB_AUDIO_PCM_RATE_44100 BIT(6)
  1554. #define GB_AUDIO_PCM_RATE_48000 BIT(7)
  1555. #define GB_AUDIO_PCM_RATE_64000 BIT(8)
  1556. #define GB_AUDIO_PCM_RATE_88200 BIT(9)
  1557. #define GB_AUDIO_PCM_RATE_96000 BIT(10)
  1558. #define GB_AUDIO_PCM_RATE_176400 BIT(11)
  1559. #define GB_AUDIO_PCM_RATE_192000 BIT(12)
  1560. #define GB_AUDIO_STREAM_TYPE_CAPTURE 0x1
  1561. #define GB_AUDIO_STREAM_TYPE_PLAYBACK 0x2
  1562. #define GB_AUDIO_CTL_ELEM_ACCESS_READ BIT(0)
  1563. #define GB_AUDIO_CTL_ELEM_ACCESS_WRITE BIT(1)
  1564. /* See SNDRV_CTL_ELEM_TYPE_* in Linux source */
  1565. #define GB_AUDIO_CTL_ELEM_TYPE_BOOLEAN 0x01
  1566. #define GB_AUDIO_CTL_ELEM_TYPE_INTEGER 0x02
  1567. #define GB_AUDIO_CTL_ELEM_TYPE_ENUMERATED 0x03
  1568. #define GB_AUDIO_CTL_ELEM_TYPE_INTEGER64 0x06
  1569. /* See SNDRV_CTL_ELEM_IFACE_* in Linux source */
  1570. #define GB_AUDIO_CTL_ELEM_IFACE_CARD 0x00
  1571. #define GB_AUDIO_CTL_ELEM_IFACE_HWDEP 0x01
  1572. #define GB_AUDIO_CTL_ELEM_IFACE_MIXER 0x02
  1573. #define GB_AUDIO_CTL_ELEM_IFACE_PCM 0x03
  1574. #define GB_AUDIO_CTL_ELEM_IFACE_RAWMIDI 0x04
  1575. #define GB_AUDIO_CTL_ELEM_IFACE_TIMER 0x05
  1576. #define GB_AUDIO_CTL_ELEM_IFACE_SEQUENCER 0x06
  1577. /* SNDRV_CTL_ELEM_ACCESS_* in Linux source */
  1578. #define GB_AUDIO_ACCESS_READ BIT(0)
  1579. #define GB_AUDIO_ACCESS_WRITE BIT(1)
  1580. #define GB_AUDIO_ACCESS_VOLATILE BIT(2)
  1581. #define GB_AUDIO_ACCESS_TIMESTAMP BIT(3)
  1582. #define GB_AUDIO_ACCESS_TLV_READ BIT(4)
  1583. #define GB_AUDIO_ACCESS_TLV_WRITE BIT(5)
  1584. #define GB_AUDIO_ACCESS_TLV_COMMAND BIT(6)
  1585. #define GB_AUDIO_ACCESS_INACTIVE BIT(7)
  1586. #define GB_AUDIO_ACCESS_LOCK BIT(8)
  1587. #define GB_AUDIO_ACCESS_OWNER BIT(9)
  1588. /* enum snd_soc_dapm_type */
  1589. #define GB_AUDIO_WIDGET_TYPE_INPUT 0x0
  1590. #define GB_AUDIO_WIDGET_TYPE_OUTPUT 0x1
  1591. #define GB_AUDIO_WIDGET_TYPE_MUX 0x2
  1592. #define GB_AUDIO_WIDGET_TYPE_VIRT_MUX 0x3
  1593. #define GB_AUDIO_WIDGET_TYPE_VALUE_MUX 0x4
  1594. #define GB_AUDIO_WIDGET_TYPE_MIXER 0x5
  1595. #define GB_AUDIO_WIDGET_TYPE_MIXER_NAMED_CTL 0x6
  1596. #define GB_AUDIO_WIDGET_TYPE_PGA 0x7
  1597. #define GB_AUDIO_WIDGET_TYPE_OUT_DRV 0x8
  1598. #define GB_AUDIO_WIDGET_TYPE_ADC 0x9
  1599. #define GB_AUDIO_WIDGET_TYPE_DAC 0xa
  1600. #define GB_AUDIO_WIDGET_TYPE_MICBIAS 0xb
  1601. #define GB_AUDIO_WIDGET_TYPE_MIC 0xc
  1602. #define GB_AUDIO_WIDGET_TYPE_HP 0xd
  1603. #define GB_AUDIO_WIDGET_TYPE_SPK 0xe
  1604. #define GB_AUDIO_WIDGET_TYPE_LINE 0xf
  1605. #define GB_AUDIO_WIDGET_TYPE_SWITCH 0x10
  1606. #define GB_AUDIO_WIDGET_TYPE_VMID 0x11
  1607. #define GB_AUDIO_WIDGET_TYPE_PRE 0x12
  1608. #define GB_AUDIO_WIDGET_TYPE_POST 0x13
  1609. #define GB_AUDIO_WIDGET_TYPE_SUPPLY 0x14
  1610. #define GB_AUDIO_WIDGET_TYPE_REGULATOR_SUPPLY 0x15
  1611. #define GB_AUDIO_WIDGET_TYPE_CLOCK_SUPPLY 0x16
  1612. #define GB_AUDIO_WIDGET_TYPE_AIF_IN 0x17
  1613. #define GB_AUDIO_WIDGET_TYPE_AIF_OUT 0x18
  1614. #define GB_AUDIO_WIDGET_TYPE_SIGGEN 0x19
  1615. #define GB_AUDIO_WIDGET_TYPE_DAI_IN 0x1a
  1616. #define GB_AUDIO_WIDGET_TYPE_DAI_OUT 0x1b
  1617. #define GB_AUDIO_WIDGET_TYPE_DAI_LINK 0x1c
  1618. #define GB_AUDIO_WIDGET_STATE_DISABLED 0x01
  1619. #define GB_AUDIO_WIDGET_STATE_ENAABLED 0x02
  1620. #define GB_AUDIO_JACK_EVENT_INSERTION 0x1
  1621. #define GB_AUDIO_JACK_EVENT_REMOVAL 0x2
  1622. #define GB_AUDIO_BUTTON_EVENT_PRESS 0x1
  1623. #define GB_AUDIO_BUTTON_EVENT_RELEASE 0x2
  1624. #define GB_AUDIO_STREAMING_EVENT_UNSPECIFIED 0x1
  1625. #define GB_AUDIO_STREAMING_EVENT_HALT 0x2
  1626. #define GB_AUDIO_STREAMING_EVENT_INTERNAL_ERROR 0x3
  1627. #define GB_AUDIO_STREAMING_EVENT_PROTOCOL_ERROR 0x4
  1628. #define GB_AUDIO_STREAMING_EVENT_FAILURE 0x5
  1629. #define GB_AUDIO_STREAMING_EVENT_UNDERRUN 0x6
  1630. #define GB_AUDIO_STREAMING_EVENT_OVERRUN 0x7
  1631. #define GB_AUDIO_STREAMING_EVENT_CLOCKING 0x8
  1632. #define GB_AUDIO_STREAMING_EVENT_DATA_LEN 0x9
  1633. #define GB_AUDIO_INVALID_INDEX 0xff
  1634. /* enum snd_jack_types */
  1635. #define GB_AUDIO_JACK_HEADPHONE 0x0000001
  1636. #define GB_AUDIO_JACK_MICROPHONE 0x0000002
  1637. #define GB_AUDIO_JACK_HEADSET (GB_AUDIO_JACK_HEADPHONE | \
  1638. GB_AUDIO_JACK_MICROPHONE)
  1639. #define GB_AUDIO_JACK_LINEOUT 0x0000004
  1640. #define GB_AUDIO_JACK_MECHANICAL 0x0000008
  1641. #define GB_AUDIO_JACK_VIDEOOUT 0x0000010
  1642. #define GB_AUDIO_JACK_AVOUT (GB_AUDIO_JACK_LINEOUT | \
  1643. GB_AUDIO_JACK_VIDEOOUT)
  1644. #define GB_AUDIO_JACK_LINEIN 0x0000020
  1645. #define GB_AUDIO_JACK_OC_HPHL 0x0000040
  1646. #define GB_AUDIO_JACK_OC_HPHR 0x0000080
  1647. #define GB_AUDIO_JACK_MICROPHONE2 0x0000200
  1648. #define GB_AUDIO_JACK_ANC_HEADPHONE (GB_AUDIO_JACK_HEADPHONE | \
  1649. GB_AUDIO_JACK_MICROPHONE | \
  1650. GB_AUDIO_JACK_MICROPHONE2)
  1651. /* Kept separate from switches to facilitate implementation */
  1652. #define GB_AUDIO_JACK_BTN_0 0x4000000
  1653. #define GB_AUDIO_JACK_BTN_1 0x2000000
  1654. #define GB_AUDIO_JACK_BTN_2 0x1000000
  1655. #define GB_AUDIO_JACK_BTN_3 0x0800000
  1656. struct gb_audio_pcm {
  1657. __u8 stream_name[GB_AUDIO_PCM_NAME_MAX];
  1658. __le32 formats; /* GB_AUDIO_PCM_FMT_* */
  1659. __le32 rates; /* GB_AUDIO_PCM_RATE_* */
  1660. __u8 chan_min;
  1661. __u8 chan_max;
  1662. __u8 sig_bits; /* number of bits of content */
  1663. } __packed;
  1664. struct gb_audio_dai {
  1665. __u8 name[AUDIO_DAI_NAME_MAX];
  1666. __le16 data_cport;
  1667. struct gb_audio_pcm capture;
  1668. struct gb_audio_pcm playback;
  1669. } __packed;
  1670. struct gb_audio_integer {
  1671. __le32 min;
  1672. __le32 max;
  1673. __le32 step;
  1674. } __packed;
  1675. struct gb_audio_integer64 {
  1676. __le64 min;
  1677. __le64 max;
  1678. __le64 step;
  1679. } __packed;
  1680. struct gb_audio_enumerated {
  1681. __le32 items;
  1682. __le16 names_length;
  1683. __u8 names[];
  1684. } __packed;
  1685. struct gb_audio_ctl_elem_info { /* See snd_ctl_elem_info in Linux source */
  1686. __u8 type; /* GB_AUDIO_CTL_ELEM_TYPE_* */
  1687. __le16 dimen[4];
  1688. union {
  1689. struct gb_audio_integer integer;
  1690. struct gb_audio_integer64 integer64;
  1691. struct gb_audio_enumerated enumerated;
  1692. } value;
  1693. } __packed;
  1694. struct gb_audio_ctl_elem_value { /* See snd_ctl_elem_value in Linux source */
  1695. __le64 timestamp; /* XXX needed? */
  1696. union {
  1697. __le32 integer_value[2]; /* consider CTL_DOUBLE_xxx */
  1698. __le64 integer64_value[2];
  1699. __le32 enumerated_item[2];
  1700. } value;
  1701. } __packed;
  1702. struct gb_audio_control {
  1703. __u8 name[AUDIO_CONTROL_NAME_MAX];
  1704. __u8 id; /* 0-63 */
  1705. __u8 iface; /* GB_AUDIO_IFACE_* */
  1706. __le16 data_cport;
  1707. __le32 access; /* GB_AUDIO_ACCESS_* */
  1708. __u8 count; /* count of same elements */
  1709. __u8 count_values; /* count of values, max=2 for CTL_DOUBLE_xxx */
  1710. struct gb_audio_ctl_elem_info info;
  1711. } __packed;
  1712. struct gb_audio_widget {
  1713. __u8 name[AUDIO_WIDGET_NAME_MAX];
  1714. __u8 sname[AUDIO_WIDGET_NAME_MAX];
  1715. __u8 id;
  1716. __u8 type; /* GB_AUDIO_WIDGET_TYPE_* */
  1717. __u8 state; /* GB_AUDIO_WIDGET_STATE_* */
  1718. __u8 ncontrols;
  1719. struct gb_audio_control ctl[]; /* 'ncontrols' entries */
  1720. } __packed;
  1721. struct gb_audio_route {
  1722. __u8 source_id; /* widget id */
  1723. __u8 destination_id; /* widget id */
  1724. __u8 control_id; /* 0-63 */
  1725. __u8 index; /* Selection within the control */
  1726. } __packed;
  1727. struct gb_audio_topology {
  1728. __u8 num_dais;
  1729. __u8 num_controls;
  1730. __u8 num_widgets;
  1731. __u8 num_routes;
  1732. __le32 size_dais;
  1733. __le32 size_controls;
  1734. __le32 size_widgets;
  1735. __le32 size_routes;
  1736. __le32 jack_type;
  1737. /*
  1738. * struct gb_audio_dai dai[num_dais];
  1739. * struct gb_audio_control controls[num_controls];
  1740. * struct gb_audio_widget widgets[num_widgets];
  1741. * struct gb_audio_route routes[num_routes];
  1742. */
  1743. __u8 data[];
  1744. } __packed;
  1745. struct gb_audio_get_topology_size_response {
  1746. __le16 size;
  1747. } __packed;
  1748. struct gb_audio_get_topology_response {
  1749. struct gb_audio_topology topology;
  1750. } __packed;
  1751. struct gb_audio_get_control_request {
  1752. __u8 control_id;
  1753. __u8 index;
  1754. } __packed;
  1755. struct gb_audio_get_control_response {
  1756. struct gb_audio_ctl_elem_value value;
  1757. } __packed;
  1758. struct gb_audio_set_control_request {
  1759. __u8 control_id;
  1760. __u8 index;
  1761. struct gb_audio_ctl_elem_value value;
  1762. } __packed;
  1763. struct gb_audio_enable_widget_request {
  1764. __u8 widget_id;
  1765. } __packed;
  1766. struct gb_audio_disable_widget_request {
  1767. __u8 widget_id;
  1768. } __packed;
  1769. struct gb_audio_get_pcm_request {
  1770. __le16 data_cport;
  1771. } __packed;
  1772. struct gb_audio_get_pcm_response {
  1773. __le32 format;
  1774. __le32 rate;
  1775. __u8 channels;
  1776. __u8 sig_bits;
  1777. } __packed;
  1778. struct gb_audio_set_pcm_request {
  1779. __le16 data_cport;
  1780. __le32 format;
  1781. __le32 rate;
  1782. __u8 channels;
  1783. __u8 sig_bits;
  1784. } __packed;
  1785. struct gb_audio_set_tx_data_size_request {
  1786. __le16 data_cport;
  1787. __le16 size;
  1788. } __packed;
  1789. struct gb_audio_activate_tx_request {
  1790. __le16 data_cport;
  1791. } __packed;
  1792. struct gb_audio_deactivate_tx_request {
  1793. __le16 data_cport;
  1794. } __packed;
  1795. struct gb_audio_set_rx_data_size_request {
  1796. __le16 data_cport;
  1797. __le16 size;
  1798. } __packed;
  1799. struct gb_audio_activate_rx_request {
  1800. __le16 data_cport;
  1801. } __packed;
  1802. struct gb_audio_deactivate_rx_request {
  1803. __le16 data_cport;
  1804. } __packed;
  1805. struct gb_audio_jack_event_request {
  1806. __u8 widget_id;
  1807. __u8 jack_attribute;
  1808. __u8 event;
  1809. } __packed;
  1810. struct gb_audio_button_event_request {
  1811. __u8 widget_id;
  1812. __u8 button_id;
  1813. __u8 event;
  1814. } __packed;
  1815. struct gb_audio_streaming_event_request {
  1816. __le16 data_cport;
  1817. __u8 event;
  1818. } __packed;
  1819. struct gb_audio_send_data_request {
  1820. __le64 timestamp;
  1821. __u8 data[];
  1822. } __packed;
  1823. /* Log */
  1824. /* operations */
  1825. #define GB_LOG_TYPE_SEND_LOG 0x02
  1826. /* length */
  1827. #define GB_LOG_MAX_LEN 1024
  1828. struct gb_log_send_log_request {
  1829. __le16 len;
  1830. __u8 msg[];
  1831. } __packed;
  1832. #endif /* __GREYBUS_PROTOCOLS_H */