cros_ec_commands.h 67 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350
  1. /*
  2. * Host communication command constants for ChromeOS EC
  3. *
  4. * Copyright (C) 2012 Google, Inc
  5. *
  6. * This software is licensed under the terms of the GNU General Public
  7. * License version 2, as published by the Free Software Foundation, and
  8. * may be copied, distributed, and modified under those terms.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * The ChromeOS EC multi function device is used to mux all the requests
  16. * to the EC device for its multiple features: keyboard controller,
  17. * battery charging and regulator control, firmware update.
  18. *
  19. * NOTE: This file is copied verbatim from the ChromeOS EC Open Source
  20. * project in an attempt to make future updates easy to make.
  21. */
  22. #ifndef __CROS_EC_COMMANDS_H
  23. #define __CROS_EC_COMMANDS_H
  24. /*
  25. * Current version of this protocol
  26. *
  27. * TODO(crosbug.com/p/11223): This is effectively useless; protocol is
  28. * determined in other ways. Remove this once the kernel code no longer
  29. * depends on it.
  30. */
  31. #define EC_PROTO_VERSION 0x00000002
  32. /* Command version mask */
  33. #define EC_VER_MASK(version) (1UL << (version))
  34. /* I/O addresses for ACPI commands */
  35. #define EC_LPC_ADDR_ACPI_DATA 0x62
  36. #define EC_LPC_ADDR_ACPI_CMD 0x66
  37. /* I/O addresses for host command */
  38. #define EC_LPC_ADDR_HOST_DATA 0x200
  39. #define EC_LPC_ADDR_HOST_CMD 0x204
  40. /* I/O addresses for host command args and params */
  41. /* Protocol version 2 */
  42. #define EC_LPC_ADDR_HOST_ARGS 0x800 /* And 0x801, 0x802, 0x803 */
  43. #define EC_LPC_ADDR_HOST_PARAM 0x804 /* For version 2 params; size is
  44. * EC_PROTO2_MAX_PARAM_SIZE */
  45. /* Protocol version 3 */
  46. #define EC_LPC_ADDR_HOST_PACKET 0x800 /* Offset of version 3 packet */
  47. #define EC_LPC_HOST_PACKET_SIZE 0x100 /* Max size of version 3 packet */
  48. /* The actual block is 0x800-0x8ff, but some BIOSes think it's 0x880-0x8ff
  49. * and they tell the kernel that so we have to think of it as two parts. */
  50. #define EC_HOST_CMD_REGION0 0x800
  51. #define EC_HOST_CMD_REGION1 0x880
  52. #define EC_HOST_CMD_REGION_SIZE 0x80
  53. /* EC command register bit functions */
  54. #define EC_LPC_CMDR_DATA (1 << 0) /* Data ready for host to read */
  55. #define EC_LPC_CMDR_PENDING (1 << 1) /* Write pending to EC */
  56. #define EC_LPC_CMDR_BUSY (1 << 2) /* EC is busy processing a command */
  57. #define EC_LPC_CMDR_CMD (1 << 3) /* Last host write was a command */
  58. #define EC_LPC_CMDR_ACPI_BRST (1 << 4) /* Burst mode (not used) */
  59. #define EC_LPC_CMDR_SCI (1 << 5) /* SCI event is pending */
  60. #define EC_LPC_CMDR_SMI (1 << 6) /* SMI event is pending */
  61. #define EC_LPC_ADDR_MEMMAP 0x900
  62. #define EC_MEMMAP_SIZE 255 /* ACPI IO buffer max is 255 bytes */
  63. #define EC_MEMMAP_TEXT_MAX 8 /* Size of a string in the memory map */
  64. /* The offset address of each type of data in mapped memory. */
  65. #define EC_MEMMAP_TEMP_SENSOR 0x00 /* Temp sensors 0x00 - 0x0f */
  66. #define EC_MEMMAP_FAN 0x10 /* Fan speeds 0x10 - 0x17 */
  67. #define EC_MEMMAP_TEMP_SENSOR_B 0x18 /* More temp sensors 0x18 - 0x1f */
  68. #define EC_MEMMAP_ID 0x20 /* 0x20 == 'E', 0x21 == 'C' */
  69. #define EC_MEMMAP_ID_VERSION 0x22 /* Version of data in 0x20 - 0x2f */
  70. #define EC_MEMMAP_THERMAL_VERSION 0x23 /* Version of data in 0x00 - 0x1f */
  71. #define EC_MEMMAP_BATTERY_VERSION 0x24 /* Version of data in 0x40 - 0x7f */
  72. #define EC_MEMMAP_SWITCHES_VERSION 0x25 /* Version of data in 0x30 - 0x33 */
  73. #define EC_MEMMAP_EVENTS_VERSION 0x26 /* Version of data in 0x34 - 0x3f */
  74. #define EC_MEMMAP_HOST_CMD_FLAGS 0x27 /* Host cmd interface flags (8 bits) */
  75. /* Unused 0x28 - 0x2f */
  76. #define EC_MEMMAP_SWITCHES 0x30 /* 8 bits */
  77. /* Unused 0x31 - 0x33 */
  78. #define EC_MEMMAP_HOST_EVENTS 0x34 /* 32 bits */
  79. /* Reserve 0x38 - 0x3f for additional host event-related stuff */
  80. /* Battery values are all 32 bits */
  81. #define EC_MEMMAP_BATT_VOLT 0x40 /* Battery Present Voltage */
  82. #define EC_MEMMAP_BATT_RATE 0x44 /* Battery Present Rate */
  83. #define EC_MEMMAP_BATT_CAP 0x48 /* Battery Remaining Capacity */
  84. #define EC_MEMMAP_BATT_FLAG 0x4c /* Battery State, defined below */
  85. #define EC_MEMMAP_BATT_DCAP 0x50 /* Battery Design Capacity */
  86. #define EC_MEMMAP_BATT_DVLT 0x54 /* Battery Design Voltage */
  87. #define EC_MEMMAP_BATT_LFCC 0x58 /* Battery Last Full Charge Capacity */
  88. #define EC_MEMMAP_BATT_CCNT 0x5c /* Battery Cycle Count */
  89. /* Strings are all 8 bytes (EC_MEMMAP_TEXT_MAX) */
  90. #define EC_MEMMAP_BATT_MFGR 0x60 /* Battery Manufacturer String */
  91. #define EC_MEMMAP_BATT_MODEL 0x68 /* Battery Model Number String */
  92. #define EC_MEMMAP_BATT_SERIAL 0x70 /* Battery Serial Number String */
  93. #define EC_MEMMAP_BATT_TYPE 0x78 /* Battery Type String */
  94. #define EC_MEMMAP_ALS 0x80 /* ALS readings in lux (2 X 16 bits) */
  95. /* Unused 0x84 - 0x8f */
  96. #define EC_MEMMAP_ACC_STATUS 0x90 /* Accelerometer status (8 bits )*/
  97. /* Unused 0x91 */
  98. #define EC_MEMMAP_ACC_DATA 0x92 /* Accelerometer data 0x92 - 0x9f */
  99. #define EC_MEMMAP_GYRO_DATA 0xa0 /* Gyroscope data 0xa0 - 0xa5 */
  100. /* Unused 0xa6 - 0xfe (remember, 0xff is NOT part of the memmap region) */
  101. /* Define the format of the accelerometer mapped memory status byte. */
  102. #define EC_MEMMAP_ACC_STATUS_SAMPLE_ID_MASK 0x0f
  103. #define EC_MEMMAP_ACC_STATUS_BUSY_BIT (1 << 4)
  104. #define EC_MEMMAP_ACC_STATUS_PRESENCE_BIT (1 << 7)
  105. /* Number of temp sensors at EC_MEMMAP_TEMP_SENSOR */
  106. #define EC_TEMP_SENSOR_ENTRIES 16
  107. /*
  108. * Number of temp sensors at EC_MEMMAP_TEMP_SENSOR_B.
  109. *
  110. * Valid only if EC_MEMMAP_THERMAL_VERSION returns >= 2.
  111. */
  112. #define EC_TEMP_SENSOR_B_ENTRIES 8
  113. /* Special values for mapped temperature sensors */
  114. #define EC_TEMP_SENSOR_NOT_PRESENT 0xff
  115. #define EC_TEMP_SENSOR_ERROR 0xfe
  116. #define EC_TEMP_SENSOR_NOT_POWERED 0xfd
  117. #define EC_TEMP_SENSOR_NOT_CALIBRATED 0xfc
  118. /*
  119. * The offset of temperature value stored in mapped memory. This allows
  120. * reporting a temperature range of 200K to 454K = -73C to 181C.
  121. */
  122. #define EC_TEMP_SENSOR_OFFSET 200
  123. /*
  124. * Number of ALS readings at EC_MEMMAP_ALS
  125. */
  126. #define EC_ALS_ENTRIES 2
  127. /*
  128. * The default value a temperature sensor will return when it is present but
  129. * has not been read this boot. This is a reasonable number to avoid
  130. * triggering alarms on the host.
  131. */
  132. #define EC_TEMP_SENSOR_DEFAULT (296 - EC_TEMP_SENSOR_OFFSET)
  133. #define EC_FAN_SPEED_ENTRIES 4 /* Number of fans at EC_MEMMAP_FAN */
  134. #define EC_FAN_SPEED_NOT_PRESENT 0xffff /* Entry not present */
  135. #define EC_FAN_SPEED_STALLED 0xfffe /* Fan stalled */
  136. /* Battery bit flags at EC_MEMMAP_BATT_FLAG. */
  137. #define EC_BATT_FLAG_AC_PRESENT 0x01
  138. #define EC_BATT_FLAG_BATT_PRESENT 0x02
  139. #define EC_BATT_FLAG_DISCHARGING 0x04
  140. #define EC_BATT_FLAG_CHARGING 0x08
  141. #define EC_BATT_FLAG_LEVEL_CRITICAL 0x10
  142. /* Switch flags at EC_MEMMAP_SWITCHES */
  143. #define EC_SWITCH_LID_OPEN 0x01
  144. #define EC_SWITCH_POWER_BUTTON_PRESSED 0x02
  145. #define EC_SWITCH_WRITE_PROTECT_DISABLED 0x04
  146. /* Was recovery requested via keyboard; now unused. */
  147. #define EC_SWITCH_IGNORE1 0x08
  148. /* Recovery requested via dedicated signal (from servo board) */
  149. #define EC_SWITCH_DEDICATED_RECOVERY 0x10
  150. /* Was fake developer mode switch; now unused. Remove in next refactor. */
  151. #define EC_SWITCH_IGNORE0 0x20
  152. /* Host command interface flags */
  153. /* Host command interface supports LPC args (LPC interface only) */
  154. #define EC_HOST_CMD_FLAG_LPC_ARGS_SUPPORTED 0x01
  155. /* Host command interface supports version 3 protocol */
  156. #define EC_HOST_CMD_FLAG_VERSION_3 0x02
  157. /* Wireless switch flags */
  158. #define EC_WIRELESS_SWITCH_ALL ~0x00 /* All flags */
  159. #define EC_WIRELESS_SWITCH_WLAN 0x01 /* WLAN radio */
  160. #define EC_WIRELESS_SWITCH_BLUETOOTH 0x02 /* Bluetooth radio */
  161. #define EC_WIRELESS_SWITCH_WWAN 0x04 /* WWAN power */
  162. #define EC_WIRELESS_SWITCH_WLAN_POWER 0x08 /* WLAN power */
  163. /*
  164. * This header file is used in coreboot both in C and ACPI code. The ACPI code
  165. * is pre-processed to handle constants but the ASL compiler is unable to
  166. * handle actual C code so keep it separate.
  167. */
  168. #ifndef __ACPI__
  169. /*
  170. * Define __packed if someone hasn't beat us to it. Linux kernel style
  171. * checking prefers __packed over __attribute__((packed)).
  172. */
  173. #ifndef __packed
  174. #define __packed __attribute__((packed))
  175. #endif
  176. /* LPC command status byte masks */
  177. /* EC has written a byte in the data register and host hasn't read it yet */
  178. #define EC_LPC_STATUS_TO_HOST 0x01
  179. /* Host has written a command/data byte and the EC hasn't read it yet */
  180. #define EC_LPC_STATUS_FROM_HOST 0x02
  181. /* EC is processing a command */
  182. #define EC_LPC_STATUS_PROCESSING 0x04
  183. /* Last write to EC was a command, not data */
  184. #define EC_LPC_STATUS_LAST_CMD 0x08
  185. /* EC is in burst mode. Unsupported by Chrome EC, so this bit is never set */
  186. #define EC_LPC_STATUS_BURST_MODE 0x10
  187. /* SCI event is pending (requesting SCI query) */
  188. #define EC_LPC_STATUS_SCI_PENDING 0x20
  189. /* SMI event is pending (requesting SMI query) */
  190. #define EC_LPC_STATUS_SMI_PENDING 0x40
  191. /* (reserved) */
  192. #define EC_LPC_STATUS_RESERVED 0x80
  193. /*
  194. * EC is busy. This covers both the EC processing a command, and the host has
  195. * written a new command but the EC hasn't picked it up yet.
  196. */
  197. #define EC_LPC_STATUS_BUSY_MASK \
  198. (EC_LPC_STATUS_FROM_HOST | EC_LPC_STATUS_PROCESSING)
  199. /* Host command response codes */
  200. enum ec_status {
  201. EC_RES_SUCCESS = 0,
  202. EC_RES_INVALID_COMMAND = 1,
  203. EC_RES_ERROR = 2,
  204. EC_RES_INVALID_PARAM = 3,
  205. EC_RES_ACCESS_DENIED = 4,
  206. EC_RES_INVALID_RESPONSE = 5,
  207. EC_RES_INVALID_VERSION = 6,
  208. EC_RES_INVALID_CHECKSUM = 7,
  209. EC_RES_IN_PROGRESS = 8, /* Accepted, command in progress */
  210. EC_RES_UNAVAILABLE = 9, /* No response available */
  211. EC_RES_TIMEOUT = 10, /* We got a timeout */
  212. EC_RES_OVERFLOW = 11, /* Table / data overflow */
  213. EC_RES_INVALID_HEADER = 12, /* Header contains invalid data */
  214. EC_RES_REQUEST_TRUNCATED = 13, /* Didn't get the entire request */
  215. EC_RES_RESPONSE_TOO_BIG = 14 /* Response was too big to handle */
  216. };
  217. /*
  218. * Host event codes. Note these are 1-based, not 0-based, because ACPI query
  219. * EC command uses code 0 to mean "no event pending". We explicitly specify
  220. * each value in the enum listing so they won't change if we delete/insert an
  221. * item or rearrange the list (it needs to be stable across platforms, not
  222. * just within a single compiled instance).
  223. */
  224. enum host_event_code {
  225. EC_HOST_EVENT_LID_CLOSED = 1,
  226. EC_HOST_EVENT_LID_OPEN = 2,
  227. EC_HOST_EVENT_POWER_BUTTON = 3,
  228. EC_HOST_EVENT_AC_CONNECTED = 4,
  229. EC_HOST_EVENT_AC_DISCONNECTED = 5,
  230. EC_HOST_EVENT_BATTERY_LOW = 6,
  231. EC_HOST_EVENT_BATTERY_CRITICAL = 7,
  232. EC_HOST_EVENT_BATTERY = 8,
  233. EC_HOST_EVENT_THERMAL_THRESHOLD = 9,
  234. EC_HOST_EVENT_THERMAL_OVERLOAD = 10,
  235. EC_HOST_EVENT_THERMAL = 11,
  236. EC_HOST_EVENT_USB_CHARGER = 12,
  237. EC_HOST_EVENT_KEY_PRESSED = 13,
  238. /*
  239. * EC has finished initializing the host interface. The host can check
  240. * for this event following sending a EC_CMD_REBOOT_EC command to
  241. * determine when the EC is ready to accept subsequent commands.
  242. */
  243. EC_HOST_EVENT_INTERFACE_READY = 14,
  244. /* Keyboard recovery combo has been pressed */
  245. EC_HOST_EVENT_KEYBOARD_RECOVERY = 15,
  246. /* Shutdown due to thermal overload */
  247. EC_HOST_EVENT_THERMAL_SHUTDOWN = 16,
  248. /* Shutdown due to battery level too low */
  249. EC_HOST_EVENT_BATTERY_SHUTDOWN = 17,
  250. /* Suggest that the AP throttle itself */
  251. EC_HOST_EVENT_THROTTLE_START = 18,
  252. /* Suggest that the AP resume normal speed */
  253. EC_HOST_EVENT_THROTTLE_STOP = 19,
  254. /* Hang detect logic detected a hang and host event timeout expired */
  255. EC_HOST_EVENT_HANG_DETECT = 20,
  256. /* Hang detect logic detected a hang and warm rebooted the AP */
  257. EC_HOST_EVENT_HANG_REBOOT = 21,
  258. /*
  259. * The high bit of the event mask is not used as a host event code. If
  260. * it reads back as set, then the entire event mask should be
  261. * considered invalid by the host. This can happen when reading the
  262. * raw event status via EC_MEMMAP_HOST_EVENTS but the LPC interface is
  263. * not initialized on the EC, or improperly configured on the host.
  264. */
  265. EC_HOST_EVENT_INVALID = 32
  266. };
  267. /* Host event mask */
  268. #define EC_HOST_EVENT_MASK(event_code) (1UL << ((event_code) - 1))
  269. /* Arguments at EC_LPC_ADDR_HOST_ARGS */
  270. struct ec_lpc_host_args {
  271. uint8_t flags;
  272. uint8_t command_version;
  273. uint8_t data_size;
  274. /*
  275. * Checksum; sum of command + flags + command_version + data_size +
  276. * all params/response data bytes.
  277. */
  278. uint8_t checksum;
  279. } __packed;
  280. /* Flags for ec_lpc_host_args.flags */
  281. /*
  282. * Args are from host. Data area at EC_LPC_ADDR_HOST_PARAM contains command
  283. * params.
  284. *
  285. * If EC gets a command and this flag is not set, this is an old-style command.
  286. * Command version is 0 and params from host are at EC_LPC_ADDR_OLD_PARAM with
  287. * unknown length. EC must respond with an old-style response (that is,
  288. * withouth setting EC_HOST_ARGS_FLAG_TO_HOST).
  289. */
  290. #define EC_HOST_ARGS_FLAG_FROM_HOST 0x01
  291. /*
  292. * Args are from EC. Data area at EC_LPC_ADDR_HOST_PARAM contains response.
  293. *
  294. * If EC responds to a command and this flag is not set, this is an old-style
  295. * response. Command version is 0 and response data from EC is at
  296. * EC_LPC_ADDR_OLD_PARAM with unknown length.
  297. */
  298. #define EC_HOST_ARGS_FLAG_TO_HOST 0x02
  299. /*****************************************************************************/
  300. /*
  301. * Byte codes returned by EC over SPI interface.
  302. *
  303. * These can be used by the AP to debug the EC interface, and to determine
  304. * when the EC is not in a state where it will ever get around to responding
  305. * to the AP.
  306. *
  307. * Example of sequence of bytes read from EC for a current good transfer:
  308. * 1. - - AP asserts chip select (CS#)
  309. * 2. EC_SPI_OLD_READY - AP sends first byte(s) of request
  310. * 3. - - EC starts handling CS# interrupt
  311. * 4. EC_SPI_RECEIVING - AP sends remaining byte(s) of request
  312. * 5. EC_SPI_PROCESSING - EC starts processing request; AP is clocking in
  313. * bytes looking for EC_SPI_FRAME_START
  314. * 6. - - EC finishes processing and sets up response
  315. * 7. EC_SPI_FRAME_START - AP reads frame byte
  316. * 8. (response packet) - AP reads response packet
  317. * 9. EC_SPI_PAST_END - Any additional bytes read by AP
  318. * 10 - - AP deasserts chip select
  319. * 11 - - EC processes CS# interrupt and sets up DMA for
  320. * next request
  321. *
  322. * If the AP is waiting for EC_SPI_FRAME_START and sees any value other than
  323. * the following byte values:
  324. * EC_SPI_OLD_READY
  325. * EC_SPI_RX_READY
  326. * EC_SPI_RECEIVING
  327. * EC_SPI_PROCESSING
  328. *
  329. * Then the EC found an error in the request, or was not ready for the request
  330. * and lost data. The AP should give up waiting for EC_SPI_FRAME_START,
  331. * because the EC is unable to tell when the AP is done sending its request.
  332. */
  333. /*
  334. * Framing byte which precedes a response packet from the EC. After sending a
  335. * request, the AP will clock in bytes until it sees the framing byte, then
  336. * clock in the response packet.
  337. */
  338. #define EC_SPI_FRAME_START 0xec
  339. /*
  340. * Padding bytes which are clocked out after the end of a response packet.
  341. */
  342. #define EC_SPI_PAST_END 0xed
  343. /*
  344. * EC is ready to receive, and has ignored the byte sent by the AP. EC expects
  345. * that the AP will send a valid packet header (starting with
  346. * EC_COMMAND_PROTOCOL_3) in the next 32 bytes.
  347. */
  348. #define EC_SPI_RX_READY 0xf8
  349. /*
  350. * EC has started receiving the request from the AP, but hasn't started
  351. * processing it yet.
  352. */
  353. #define EC_SPI_RECEIVING 0xf9
  354. /* EC has received the entire request from the AP and is processing it. */
  355. #define EC_SPI_PROCESSING 0xfa
  356. /*
  357. * EC received bad data from the AP, such as a packet header with an invalid
  358. * length. EC will ignore all data until chip select deasserts.
  359. */
  360. #define EC_SPI_RX_BAD_DATA 0xfb
  361. /*
  362. * EC received data from the AP before it was ready. That is, the AP asserted
  363. * chip select and started clocking data before the EC was ready to receive it.
  364. * EC will ignore all data until chip select deasserts.
  365. */
  366. #define EC_SPI_NOT_READY 0xfc
  367. /*
  368. * EC was ready to receive a request from the AP. EC has treated the byte sent
  369. * by the AP as part of a request packet, or (for old-style ECs) is processing
  370. * a fully received packet but is not ready to respond yet.
  371. */
  372. #define EC_SPI_OLD_READY 0xfd
  373. /*****************************************************************************/
  374. /*
  375. * Protocol version 2 for I2C and SPI send a request this way:
  376. *
  377. * 0 EC_CMD_VERSION0 + (command version)
  378. * 1 Command number
  379. * 2 Length of params = N
  380. * 3..N+2 Params, if any
  381. * N+3 8-bit checksum of bytes 0..N+2
  382. *
  383. * The corresponding response is:
  384. *
  385. * 0 Result code (EC_RES_*)
  386. * 1 Length of params = M
  387. * 2..M+1 Params, if any
  388. * M+2 8-bit checksum of bytes 0..M+1
  389. */
  390. #define EC_PROTO2_REQUEST_HEADER_BYTES 3
  391. #define EC_PROTO2_REQUEST_TRAILER_BYTES 1
  392. #define EC_PROTO2_REQUEST_OVERHEAD (EC_PROTO2_REQUEST_HEADER_BYTES + \
  393. EC_PROTO2_REQUEST_TRAILER_BYTES)
  394. #define EC_PROTO2_RESPONSE_HEADER_BYTES 2
  395. #define EC_PROTO2_RESPONSE_TRAILER_BYTES 1
  396. #define EC_PROTO2_RESPONSE_OVERHEAD (EC_PROTO2_RESPONSE_HEADER_BYTES + \
  397. EC_PROTO2_RESPONSE_TRAILER_BYTES)
  398. /* Parameter length was limited by the LPC interface */
  399. #define EC_PROTO2_MAX_PARAM_SIZE 0xfc
  400. /* Maximum request and response packet sizes for protocol version 2 */
  401. #define EC_PROTO2_MAX_REQUEST_SIZE (EC_PROTO2_REQUEST_OVERHEAD + \
  402. EC_PROTO2_MAX_PARAM_SIZE)
  403. #define EC_PROTO2_MAX_RESPONSE_SIZE (EC_PROTO2_RESPONSE_OVERHEAD + \
  404. EC_PROTO2_MAX_PARAM_SIZE)
  405. /*****************************************************************************/
  406. /*
  407. * Value written to legacy command port / prefix byte to indicate protocol
  408. * 3+ structs are being used. Usage is bus-dependent.
  409. */
  410. #define EC_COMMAND_PROTOCOL_3 0xda
  411. #define EC_HOST_REQUEST_VERSION 3
  412. /* Version 3 request from host */
  413. struct ec_host_request {
  414. /* Struct version (=3)
  415. *
  416. * EC will return EC_RES_INVALID_HEADER if it receives a header with a
  417. * version it doesn't know how to parse.
  418. */
  419. uint8_t struct_version;
  420. /*
  421. * Checksum of request and data; sum of all bytes including checksum
  422. * should total to 0.
  423. */
  424. uint8_t checksum;
  425. /* Command code */
  426. uint16_t command;
  427. /* Command version */
  428. uint8_t command_version;
  429. /* Unused byte in current protocol version; set to 0 */
  430. uint8_t reserved;
  431. /* Length of data which follows this header */
  432. uint16_t data_len;
  433. } __packed;
  434. #define EC_HOST_RESPONSE_VERSION 3
  435. /* Version 3 response from EC */
  436. struct ec_host_response {
  437. /* Struct version (=3) */
  438. uint8_t struct_version;
  439. /*
  440. * Checksum of response and data; sum of all bytes including checksum
  441. * should total to 0.
  442. */
  443. uint8_t checksum;
  444. /* Result code (EC_RES_*) */
  445. uint16_t result;
  446. /* Length of data which follows this header */
  447. uint16_t data_len;
  448. /* Unused bytes in current protocol version; set to 0 */
  449. uint16_t reserved;
  450. } __packed;
  451. /*****************************************************************************/
  452. /*
  453. * Notes on commands:
  454. *
  455. * Each command is an 8-byte command value. Commands which take params or
  456. * return response data specify structs for that data. If no struct is
  457. * specified, the command does not input or output data, respectively.
  458. * Parameter/response length is implicit in the structs. Some underlying
  459. * communication protocols (I2C, SPI) may add length or checksum headers, but
  460. * those are implementation-dependent and not defined here.
  461. */
  462. /*****************************************************************************/
  463. /* General / test commands */
  464. /*
  465. * Get protocol version, used to deal with non-backward compatible protocol
  466. * changes.
  467. */
  468. #define EC_CMD_PROTO_VERSION 0x00
  469. struct ec_response_proto_version {
  470. uint32_t version;
  471. } __packed;
  472. /*
  473. * Hello. This is a simple command to test the EC is responsive to
  474. * commands.
  475. */
  476. #define EC_CMD_HELLO 0x01
  477. struct ec_params_hello {
  478. uint32_t in_data; /* Pass anything here */
  479. } __packed;
  480. struct ec_response_hello {
  481. uint32_t out_data; /* Output will be in_data + 0x01020304 */
  482. } __packed;
  483. /* Get version number */
  484. #define EC_CMD_GET_VERSION 0x02
  485. enum ec_current_image {
  486. EC_IMAGE_UNKNOWN = 0,
  487. EC_IMAGE_RO,
  488. EC_IMAGE_RW
  489. };
  490. struct ec_response_get_version {
  491. /* Null-terminated version strings for RO, RW */
  492. char version_string_ro[32];
  493. char version_string_rw[32];
  494. char reserved[32]; /* Was previously RW-B string */
  495. uint32_t current_image; /* One of ec_current_image */
  496. } __packed;
  497. /* Read test */
  498. #define EC_CMD_READ_TEST 0x03
  499. struct ec_params_read_test {
  500. uint32_t offset; /* Starting value for read buffer */
  501. uint32_t size; /* Size to read in bytes */
  502. } __packed;
  503. struct ec_response_read_test {
  504. uint32_t data[32];
  505. } __packed;
  506. /*
  507. * Get build information
  508. *
  509. * Response is null-terminated string.
  510. */
  511. #define EC_CMD_GET_BUILD_INFO 0x04
  512. /* Get chip info */
  513. #define EC_CMD_GET_CHIP_INFO 0x05
  514. struct ec_response_get_chip_info {
  515. /* Null-terminated strings */
  516. char vendor[32];
  517. char name[32];
  518. char revision[32]; /* Mask version */
  519. } __packed;
  520. /* Get board HW version */
  521. #define EC_CMD_GET_BOARD_VERSION 0x06
  522. struct ec_response_board_version {
  523. uint16_t board_version; /* A monotonously incrementing number. */
  524. } __packed;
  525. /*
  526. * Read memory-mapped data.
  527. *
  528. * This is an alternate interface to memory-mapped data for bus protocols
  529. * which don't support direct-mapped memory - I2C, SPI, etc.
  530. *
  531. * Response is params.size bytes of data.
  532. */
  533. #define EC_CMD_READ_MEMMAP 0x07
  534. struct ec_params_read_memmap {
  535. uint8_t offset; /* Offset in memmap (EC_MEMMAP_*) */
  536. uint8_t size; /* Size to read in bytes */
  537. } __packed;
  538. /* Read versions supported for a command */
  539. #define EC_CMD_GET_CMD_VERSIONS 0x08
  540. struct ec_params_get_cmd_versions {
  541. uint8_t cmd; /* Command to check */
  542. } __packed;
  543. struct ec_response_get_cmd_versions {
  544. /*
  545. * Mask of supported versions; use EC_VER_MASK() to compare with a
  546. * desired version.
  547. */
  548. uint32_t version_mask;
  549. } __packed;
  550. /*
  551. * Check EC communcations status (busy). This is needed on i2c/spi but not
  552. * on lpc since it has its own out-of-band busy indicator.
  553. *
  554. * lpc must read the status from the command register. Attempting this on
  555. * lpc will overwrite the args/parameter space and corrupt its data.
  556. */
  557. #define EC_CMD_GET_COMMS_STATUS 0x09
  558. /* Avoid using ec_status which is for return values */
  559. enum ec_comms_status {
  560. EC_COMMS_STATUS_PROCESSING = 1 << 0, /* Processing cmd */
  561. };
  562. struct ec_response_get_comms_status {
  563. uint32_t flags; /* Mask of enum ec_comms_status */
  564. } __packed;
  565. /* Fake a variety of responses, purely for testing purposes. */
  566. #define EC_CMD_TEST_PROTOCOL 0x0a
  567. /* Tell the EC what to send back to us. */
  568. struct ec_params_test_protocol {
  569. uint32_t ec_result;
  570. uint32_t ret_len;
  571. uint8_t buf[32];
  572. } __packed;
  573. /* Here it comes... */
  574. struct ec_response_test_protocol {
  575. uint8_t buf[32];
  576. } __packed;
  577. /* Get prococol information */
  578. #define EC_CMD_GET_PROTOCOL_INFO 0x0b
  579. /* Flags for ec_response_get_protocol_info.flags */
  580. /* EC_RES_IN_PROGRESS may be returned if a command is slow */
  581. #define EC_PROTOCOL_INFO_IN_PROGRESS_SUPPORTED (1 << 0)
  582. struct ec_response_get_protocol_info {
  583. /* Fields which exist if at least protocol version 3 supported */
  584. /* Bitmask of protocol versions supported (1 << n means version n)*/
  585. uint32_t protocol_versions;
  586. /* Maximum request packet size, in bytes */
  587. uint16_t max_request_packet_size;
  588. /* Maximum response packet size, in bytes */
  589. uint16_t max_response_packet_size;
  590. /* Flags; see EC_PROTOCOL_INFO_* */
  591. uint32_t flags;
  592. } __packed;
  593. /*****************************************************************************/
  594. /* Get/Set miscellaneous values */
  595. /* The upper byte of .flags tells what to do (nothing means "get") */
  596. #define EC_GSV_SET 0x80000000
  597. /* The lower three bytes of .flags identifies the parameter, if that has
  598. meaning for an individual command. */
  599. #define EC_GSV_PARAM_MASK 0x00ffffff
  600. struct ec_params_get_set_value {
  601. uint32_t flags;
  602. uint32_t value;
  603. } __packed;
  604. struct ec_response_get_set_value {
  605. uint32_t flags;
  606. uint32_t value;
  607. } __packed;
  608. /* More than one command can use these structs to get/set paramters. */
  609. #define EC_CMD_GSV_PAUSE_IN_S5 0x0c
  610. /*****************************************************************************/
  611. /* Flash commands */
  612. /* Get flash info */
  613. #define EC_CMD_FLASH_INFO 0x10
  614. /* Version 0 returns these fields */
  615. struct ec_response_flash_info {
  616. /* Usable flash size, in bytes */
  617. uint32_t flash_size;
  618. /*
  619. * Write block size. Write offset and size must be a multiple
  620. * of this.
  621. */
  622. uint32_t write_block_size;
  623. /*
  624. * Erase block size. Erase offset and size must be a multiple
  625. * of this.
  626. */
  627. uint32_t erase_block_size;
  628. /*
  629. * Protection block size. Protection offset and size must be a
  630. * multiple of this.
  631. */
  632. uint32_t protect_block_size;
  633. } __packed;
  634. /* Flags for version 1+ flash info command */
  635. /* EC flash erases bits to 0 instead of 1 */
  636. #define EC_FLASH_INFO_ERASE_TO_0 (1 << 0)
  637. /*
  638. * Version 1 returns the same initial fields as version 0, with additional
  639. * fields following.
  640. *
  641. * gcc anonymous structs don't seem to get along with the __packed directive;
  642. * if they did we'd define the version 0 struct as a sub-struct of this one.
  643. */
  644. struct ec_response_flash_info_1 {
  645. /* Version 0 fields; see above for description */
  646. uint32_t flash_size;
  647. uint32_t write_block_size;
  648. uint32_t erase_block_size;
  649. uint32_t protect_block_size;
  650. /* Version 1 adds these fields: */
  651. /*
  652. * Ideal write size in bytes. Writes will be fastest if size is
  653. * exactly this and offset is a multiple of this. For example, an EC
  654. * may have a write buffer which can do half-page operations if data is
  655. * aligned, and a slower word-at-a-time write mode.
  656. */
  657. uint32_t write_ideal_size;
  658. /* Flags; see EC_FLASH_INFO_* */
  659. uint32_t flags;
  660. } __packed;
  661. /*
  662. * Read flash
  663. *
  664. * Response is params.size bytes of data.
  665. */
  666. #define EC_CMD_FLASH_READ 0x11
  667. struct ec_params_flash_read {
  668. uint32_t offset; /* Byte offset to read */
  669. uint32_t size; /* Size to read in bytes */
  670. } __packed;
  671. /* Write flash */
  672. #define EC_CMD_FLASH_WRITE 0x12
  673. #define EC_VER_FLASH_WRITE 1
  674. /* Version 0 of the flash command supported only 64 bytes of data */
  675. #define EC_FLASH_WRITE_VER0_SIZE 64
  676. struct ec_params_flash_write {
  677. uint32_t offset; /* Byte offset to write */
  678. uint32_t size; /* Size to write in bytes */
  679. /* Followed by data to write */
  680. } __packed;
  681. /* Erase flash */
  682. #define EC_CMD_FLASH_ERASE 0x13
  683. struct ec_params_flash_erase {
  684. uint32_t offset; /* Byte offset to erase */
  685. uint32_t size; /* Size to erase in bytes */
  686. } __packed;
  687. /*
  688. * Get/set flash protection.
  689. *
  690. * If mask!=0, sets/clear the requested bits of flags. Depending on the
  691. * firmware write protect GPIO, not all flags will take effect immediately;
  692. * some flags require a subsequent hard reset to take effect. Check the
  693. * returned flags bits to see what actually happened.
  694. *
  695. * If mask=0, simply returns the current flags state.
  696. */
  697. #define EC_CMD_FLASH_PROTECT 0x15
  698. #define EC_VER_FLASH_PROTECT 1 /* Command version 1 */
  699. /* Flags for flash protection */
  700. /* RO flash code protected when the EC boots */
  701. #define EC_FLASH_PROTECT_RO_AT_BOOT (1 << 0)
  702. /*
  703. * RO flash code protected now. If this bit is set, at-boot status cannot
  704. * be changed.
  705. */
  706. #define EC_FLASH_PROTECT_RO_NOW (1 << 1)
  707. /* Entire flash code protected now, until reboot. */
  708. #define EC_FLASH_PROTECT_ALL_NOW (1 << 2)
  709. /* Flash write protect GPIO is asserted now */
  710. #define EC_FLASH_PROTECT_GPIO_ASSERTED (1 << 3)
  711. /* Error - at least one bank of flash is stuck locked, and cannot be unlocked */
  712. #define EC_FLASH_PROTECT_ERROR_STUCK (1 << 4)
  713. /*
  714. * Error - flash protection is in inconsistent state. At least one bank of
  715. * flash which should be protected is not protected. Usually fixed by
  716. * re-requesting the desired flags, or by a hard reset if that fails.
  717. */
  718. #define EC_FLASH_PROTECT_ERROR_INCONSISTENT (1 << 5)
  719. /* Entile flash code protected when the EC boots */
  720. #define EC_FLASH_PROTECT_ALL_AT_BOOT (1 << 6)
  721. struct ec_params_flash_protect {
  722. uint32_t mask; /* Bits in flags to apply */
  723. uint32_t flags; /* New flags to apply */
  724. } __packed;
  725. struct ec_response_flash_protect {
  726. /* Current value of flash protect flags */
  727. uint32_t flags;
  728. /*
  729. * Flags which are valid on this platform. This allows the caller
  730. * to distinguish between flags which aren't set vs. flags which can't
  731. * be set on this platform.
  732. */
  733. uint32_t valid_flags;
  734. /* Flags which can be changed given the current protection state */
  735. uint32_t writable_flags;
  736. } __packed;
  737. /*
  738. * Note: commands 0x14 - 0x19 version 0 were old commands to get/set flash
  739. * write protect. These commands may be reused with version > 0.
  740. */
  741. /* Get the region offset/size */
  742. #define EC_CMD_FLASH_REGION_INFO 0x16
  743. #define EC_VER_FLASH_REGION_INFO 1
  744. enum ec_flash_region {
  745. /* Region which holds read-only EC image */
  746. EC_FLASH_REGION_RO = 0,
  747. /* Region which holds rewritable EC image */
  748. EC_FLASH_REGION_RW,
  749. /*
  750. * Region which should be write-protected in the factory (a superset of
  751. * EC_FLASH_REGION_RO)
  752. */
  753. EC_FLASH_REGION_WP_RO,
  754. /* Number of regions */
  755. EC_FLASH_REGION_COUNT,
  756. };
  757. struct ec_params_flash_region_info {
  758. uint32_t region; /* enum ec_flash_region */
  759. } __packed;
  760. struct ec_response_flash_region_info {
  761. uint32_t offset;
  762. uint32_t size;
  763. } __packed;
  764. /* Read/write VbNvContext */
  765. #define EC_CMD_VBNV_CONTEXT 0x17
  766. #define EC_VER_VBNV_CONTEXT 1
  767. #define EC_VBNV_BLOCK_SIZE 16
  768. enum ec_vbnvcontext_op {
  769. EC_VBNV_CONTEXT_OP_READ,
  770. EC_VBNV_CONTEXT_OP_WRITE,
  771. };
  772. struct ec_params_vbnvcontext {
  773. uint32_t op;
  774. uint8_t block[EC_VBNV_BLOCK_SIZE];
  775. } __packed;
  776. struct ec_response_vbnvcontext {
  777. uint8_t block[EC_VBNV_BLOCK_SIZE];
  778. } __packed;
  779. /*****************************************************************************/
  780. /* PWM commands */
  781. /* Get fan target RPM */
  782. #define EC_CMD_PWM_GET_FAN_TARGET_RPM 0x20
  783. struct ec_response_pwm_get_fan_rpm {
  784. uint32_t rpm;
  785. } __packed;
  786. /* Set target fan RPM */
  787. #define EC_CMD_PWM_SET_FAN_TARGET_RPM 0x21
  788. struct ec_params_pwm_set_fan_target_rpm {
  789. uint32_t rpm;
  790. } __packed;
  791. /* Get keyboard backlight */
  792. #define EC_CMD_PWM_GET_KEYBOARD_BACKLIGHT 0x22
  793. struct ec_response_pwm_get_keyboard_backlight {
  794. uint8_t percent;
  795. uint8_t enabled;
  796. } __packed;
  797. /* Set keyboard backlight */
  798. #define EC_CMD_PWM_SET_KEYBOARD_BACKLIGHT 0x23
  799. struct ec_params_pwm_set_keyboard_backlight {
  800. uint8_t percent;
  801. } __packed;
  802. /* Set target fan PWM duty cycle */
  803. #define EC_CMD_PWM_SET_FAN_DUTY 0x24
  804. struct ec_params_pwm_set_fan_duty {
  805. uint32_t percent;
  806. } __packed;
  807. /*****************************************************************************/
  808. /*
  809. * Lightbar commands. This looks worse than it is. Since we only use one HOST
  810. * command to say "talk to the lightbar", we put the "and tell it to do X" part
  811. * into a subcommand. We'll make separate structs for subcommands with
  812. * different input args, so that we know how much to expect.
  813. */
  814. #define EC_CMD_LIGHTBAR_CMD 0x28
  815. struct rgb_s {
  816. uint8_t r, g, b;
  817. };
  818. #define LB_BATTERY_LEVELS 4
  819. /* List of tweakable parameters. NOTE: It's __packed so it can be sent in a
  820. * host command, but the alignment is the same regardless. Keep it that way.
  821. */
  822. struct lightbar_params {
  823. /* Timing */
  824. int32_t google_ramp_up;
  825. int32_t google_ramp_down;
  826. int32_t s3s0_ramp_up;
  827. int32_t s0_tick_delay[2]; /* AC=0/1 */
  828. int32_t s0a_tick_delay[2]; /* AC=0/1 */
  829. int32_t s0s3_ramp_down;
  830. int32_t s3_sleep_for;
  831. int32_t s3_ramp_up;
  832. int32_t s3_ramp_down;
  833. /* Oscillation */
  834. uint8_t new_s0;
  835. uint8_t osc_min[2]; /* AC=0/1 */
  836. uint8_t osc_max[2]; /* AC=0/1 */
  837. uint8_t w_ofs[2]; /* AC=0/1 */
  838. /* Brightness limits based on the backlight and AC. */
  839. uint8_t bright_bl_off_fixed[2]; /* AC=0/1 */
  840. uint8_t bright_bl_on_min[2]; /* AC=0/1 */
  841. uint8_t bright_bl_on_max[2]; /* AC=0/1 */
  842. /* Battery level thresholds */
  843. uint8_t battery_threshold[LB_BATTERY_LEVELS - 1];
  844. /* Map [AC][battery_level] to color index */
  845. uint8_t s0_idx[2][LB_BATTERY_LEVELS]; /* AP is running */
  846. uint8_t s3_idx[2][LB_BATTERY_LEVELS]; /* AP is sleeping */
  847. /* Color palette */
  848. struct rgb_s color[8]; /* 0-3 are Google colors */
  849. } __packed;
  850. struct ec_params_lightbar {
  851. uint8_t cmd; /* Command (see enum lightbar_command) */
  852. union {
  853. struct {
  854. /* no args */
  855. } dump, off, on, init, get_seq, get_params, version;
  856. struct num {
  857. uint8_t num;
  858. } brightness, seq, demo;
  859. struct reg {
  860. uint8_t ctrl, reg, value;
  861. } reg;
  862. struct rgb {
  863. uint8_t led, red, green, blue;
  864. } rgb;
  865. struct lightbar_params set_params;
  866. };
  867. } __packed;
  868. struct ec_response_lightbar {
  869. union {
  870. struct dump {
  871. struct {
  872. uint8_t reg;
  873. uint8_t ic0;
  874. uint8_t ic1;
  875. } vals[23];
  876. } dump;
  877. struct get_seq {
  878. uint8_t num;
  879. } get_seq;
  880. struct lightbar_params get_params;
  881. struct version {
  882. uint32_t num;
  883. uint32_t flags;
  884. } version;
  885. struct {
  886. /* no return params */
  887. } off, on, init, brightness, seq, reg, rgb, demo, set_params;
  888. };
  889. } __packed;
  890. /* Lightbar commands */
  891. enum lightbar_command {
  892. LIGHTBAR_CMD_DUMP = 0,
  893. LIGHTBAR_CMD_OFF = 1,
  894. LIGHTBAR_CMD_ON = 2,
  895. LIGHTBAR_CMD_INIT = 3,
  896. LIGHTBAR_CMD_BRIGHTNESS = 4,
  897. LIGHTBAR_CMD_SEQ = 5,
  898. LIGHTBAR_CMD_REG = 6,
  899. LIGHTBAR_CMD_RGB = 7,
  900. LIGHTBAR_CMD_GET_SEQ = 8,
  901. LIGHTBAR_CMD_DEMO = 9,
  902. LIGHTBAR_CMD_GET_PARAMS = 10,
  903. LIGHTBAR_CMD_SET_PARAMS = 11,
  904. LIGHTBAR_CMD_VERSION = 12,
  905. LIGHTBAR_NUM_CMDS
  906. };
  907. /*****************************************************************************/
  908. /* LED control commands */
  909. #define EC_CMD_LED_CONTROL 0x29
  910. enum ec_led_id {
  911. /* LED to indicate battery state of charge */
  912. EC_LED_ID_BATTERY_LED = 0,
  913. /*
  914. * LED to indicate system power state (on or in suspend).
  915. * May be on power button or on C-panel.
  916. */
  917. EC_LED_ID_POWER_LED,
  918. /* LED on power adapter or its plug */
  919. EC_LED_ID_ADAPTER_LED,
  920. EC_LED_ID_COUNT
  921. };
  922. /* LED control flags */
  923. #define EC_LED_FLAGS_QUERY (1 << 0) /* Query LED capability only */
  924. #define EC_LED_FLAGS_AUTO (1 << 1) /* Switch LED back to automatic control */
  925. enum ec_led_colors {
  926. EC_LED_COLOR_RED = 0,
  927. EC_LED_COLOR_GREEN,
  928. EC_LED_COLOR_BLUE,
  929. EC_LED_COLOR_YELLOW,
  930. EC_LED_COLOR_WHITE,
  931. EC_LED_COLOR_COUNT
  932. };
  933. struct ec_params_led_control {
  934. uint8_t led_id; /* Which LED to control */
  935. uint8_t flags; /* Control flags */
  936. uint8_t brightness[EC_LED_COLOR_COUNT];
  937. } __packed;
  938. struct ec_response_led_control {
  939. /*
  940. * Available brightness value range.
  941. *
  942. * Range 0 means color channel not present.
  943. * Range 1 means on/off control.
  944. * Other values means the LED is control by PWM.
  945. */
  946. uint8_t brightness_range[EC_LED_COLOR_COUNT];
  947. } __packed;
  948. /*****************************************************************************/
  949. /* Verified boot commands */
  950. /*
  951. * Note: command code 0x29 version 0 was VBOOT_CMD in Link EVT; it may be
  952. * reused for other purposes with version > 0.
  953. */
  954. /* Verified boot hash command */
  955. #define EC_CMD_VBOOT_HASH 0x2A
  956. struct ec_params_vboot_hash {
  957. uint8_t cmd; /* enum ec_vboot_hash_cmd */
  958. uint8_t hash_type; /* enum ec_vboot_hash_type */
  959. uint8_t nonce_size; /* Nonce size; may be 0 */
  960. uint8_t reserved0; /* Reserved; set 0 */
  961. uint32_t offset; /* Offset in flash to hash */
  962. uint32_t size; /* Number of bytes to hash */
  963. uint8_t nonce_data[64]; /* Nonce data; ignored if nonce_size=0 */
  964. } __packed;
  965. struct ec_response_vboot_hash {
  966. uint8_t status; /* enum ec_vboot_hash_status */
  967. uint8_t hash_type; /* enum ec_vboot_hash_type */
  968. uint8_t digest_size; /* Size of hash digest in bytes */
  969. uint8_t reserved0; /* Ignore; will be 0 */
  970. uint32_t offset; /* Offset in flash which was hashed */
  971. uint32_t size; /* Number of bytes hashed */
  972. uint8_t hash_digest[64]; /* Hash digest data */
  973. } __packed;
  974. enum ec_vboot_hash_cmd {
  975. EC_VBOOT_HASH_GET = 0, /* Get current hash status */
  976. EC_VBOOT_HASH_ABORT = 1, /* Abort calculating current hash */
  977. EC_VBOOT_HASH_START = 2, /* Start computing a new hash */
  978. EC_VBOOT_HASH_RECALC = 3, /* Synchronously compute a new hash */
  979. };
  980. enum ec_vboot_hash_type {
  981. EC_VBOOT_HASH_TYPE_SHA256 = 0, /* SHA-256 */
  982. };
  983. enum ec_vboot_hash_status {
  984. EC_VBOOT_HASH_STATUS_NONE = 0, /* No hash (not started, or aborted) */
  985. EC_VBOOT_HASH_STATUS_DONE = 1, /* Finished computing a hash */
  986. EC_VBOOT_HASH_STATUS_BUSY = 2, /* Busy computing a hash */
  987. };
  988. /*
  989. * Special values for offset for EC_VBOOT_HASH_START and EC_VBOOT_HASH_RECALC.
  990. * If one of these is specified, the EC will automatically update offset and
  991. * size to the correct values for the specified image (RO or RW).
  992. */
  993. #define EC_VBOOT_HASH_OFFSET_RO 0xfffffffe
  994. #define EC_VBOOT_HASH_OFFSET_RW 0xfffffffd
  995. /*****************************************************************************/
  996. /*
  997. * Motion sense commands. We'll make separate structs for sub-commands with
  998. * different input args, so that we know how much to expect.
  999. */
  1000. #define EC_CMD_MOTION_SENSE_CMD 0x2B
  1001. /* Motion sense commands */
  1002. enum motionsense_command {
  1003. /*
  1004. * Dump command returns all motion sensor data including motion sense
  1005. * module flags and individual sensor flags.
  1006. */
  1007. MOTIONSENSE_CMD_DUMP = 0,
  1008. /*
  1009. * Info command returns data describing the details of a given sensor,
  1010. * including enum motionsensor_type, enum motionsensor_location, and
  1011. * enum motionsensor_chip.
  1012. */
  1013. MOTIONSENSE_CMD_INFO = 1,
  1014. /*
  1015. * EC Rate command is a setter/getter command for the EC sampling rate
  1016. * of all motion sensors in milliseconds.
  1017. */
  1018. MOTIONSENSE_CMD_EC_RATE = 2,
  1019. /*
  1020. * Sensor ODR command is a setter/getter command for the output data
  1021. * rate of a specific motion sensor in millihertz.
  1022. */
  1023. MOTIONSENSE_CMD_SENSOR_ODR = 3,
  1024. /*
  1025. * Sensor range command is a setter/getter command for the range of
  1026. * a specified motion sensor in +/-G's or +/- deg/s.
  1027. */
  1028. MOTIONSENSE_CMD_SENSOR_RANGE = 4,
  1029. /*
  1030. * Setter/getter command for the keyboard wake angle. When the lid
  1031. * angle is greater than this value, keyboard wake is disabled in S3,
  1032. * and when the lid angle goes less than this value, keyboard wake is
  1033. * enabled. Note, the lid angle measurement is an approximate,
  1034. * un-calibrated value, hence the wake angle isn't exact.
  1035. */
  1036. MOTIONSENSE_CMD_KB_WAKE_ANGLE = 5,
  1037. /* Number of motionsense sub-commands. */
  1038. MOTIONSENSE_NUM_CMDS
  1039. };
  1040. enum motionsensor_id {
  1041. EC_MOTION_SENSOR_ACCEL_BASE = 0,
  1042. EC_MOTION_SENSOR_ACCEL_LID = 1,
  1043. EC_MOTION_SENSOR_GYRO = 2,
  1044. /*
  1045. * Note, if more sensors are added and this count changes, the padding
  1046. * in ec_response_motion_sense dump command must be modified.
  1047. */
  1048. EC_MOTION_SENSOR_COUNT = 3
  1049. };
  1050. /* List of motion sensor types. */
  1051. enum motionsensor_type {
  1052. MOTIONSENSE_TYPE_ACCEL = 0,
  1053. MOTIONSENSE_TYPE_GYRO = 1,
  1054. };
  1055. /* List of motion sensor locations. */
  1056. enum motionsensor_location {
  1057. MOTIONSENSE_LOC_BASE = 0,
  1058. MOTIONSENSE_LOC_LID = 1,
  1059. };
  1060. /* List of motion sensor chips. */
  1061. enum motionsensor_chip {
  1062. MOTIONSENSE_CHIP_KXCJ9 = 0,
  1063. };
  1064. /* Module flag masks used for the dump sub-command. */
  1065. #define MOTIONSENSE_MODULE_FLAG_ACTIVE (1<<0)
  1066. /* Sensor flag masks used for the dump sub-command. */
  1067. #define MOTIONSENSE_SENSOR_FLAG_PRESENT (1<<0)
  1068. /*
  1069. * Send this value for the data element to only perform a read. If you
  1070. * send any other value, the EC will interpret it as data to set and will
  1071. * return the actual value set.
  1072. */
  1073. #define EC_MOTION_SENSE_NO_VALUE -1
  1074. struct ec_params_motion_sense {
  1075. uint8_t cmd;
  1076. union {
  1077. /* Used for MOTIONSENSE_CMD_DUMP. */
  1078. struct {
  1079. /* no args */
  1080. } dump;
  1081. /*
  1082. * Used for MOTIONSENSE_CMD_EC_RATE and
  1083. * MOTIONSENSE_CMD_KB_WAKE_ANGLE.
  1084. */
  1085. struct {
  1086. /* Data to set or EC_MOTION_SENSE_NO_VALUE to read. */
  1087. int16_t data;
  1088. } ec_rate, kb_wake_angle;
  1089. /* Used for MOTIONSENSE_CMD_INFO. */
  1090. struct {
  1091. /* Should be element of enum motionsensor_id. */
  1092. uint8_t sensor_num;
  1093. } info;
  1094. /*
  1095. * Used for MOTIONSENSE_CMD_SENSOR_ODR and
  1096. * MOTIONSENSE_CMD_SENSOR_RANGE.
  1097. */
  1098. struct {
  1099. /* Should be element of enum motionsensor_id. */
  1100. uint8_t sensor_num;
  1101. /* Rounding flag, true for round-up, false for down. */
  1102. uint8_t roundup;
  1103. uint16_t reserved;
  1104. /* Data to set or EC_MOTION_SENSE_NO_VALUE to read. */
  1105. int32_t data;
  1106. } sensor_odr, sensor_range;
  1107. };
  1108. } __packed;
  1109. struct ec_response_motion_sense {
  1110. union {
  1111. /* Used for MOTIONSENSE_CMD_DUMP. */
  1112. struct {
  1113. /* Flags representing the motion sensor module. */
  1114. uint8_t module_flags;
  1115. /* Flags for each sensor in enum motionsensor_id. */
  1116. uint8_t sensor_flags[EC_MOTION_SENSOR_COUNT];
  1117. /* Array of all sensor data. Each sensor is 3-axis. */
  1118. int16_t data[3*EC_MOTION_SENSOR_COUNT];
  1119. } dump;
  1120. /* Used for MOTIONSENSE_CMD_INFO. */
  1121. struct {
  1122. /* Should be element of enum motionsensor_type. */
  1123. uint8_t type;
  1124. /* Should be element of enum motionsensor_location. */
  1125. uint8_t location;
  1126. /* Should be element of enum motionsensor_chip. */
  1127. uint8_t chip;
  1128. } info;
  1129. /*
  1130. * Used for MOTIONSENSE_CMD_EC_RATE, MOTIONSENSE_CMD_SENSOR_ODR,
  1131. * MOTIONSENSE_CMD_SENSOR_RANGE, and
  1132. * MOTIONSENSE_CMD_KB_WAKE_ANGLE.
  1133. */
  1134. struct {
  1135. /* Current value of the parameter queried. */
  1136. int32_t ret;
  1137. } ec_rate, sensor_odr, sensor_range, kb_wake_angle;
  1138. };
  1139. } __packed;
  1140. /*****************************************************************************/
  1141. /* USB charging control commands */
  1142. /* Set USB port charging mode */
  1143. #define EC_CMD_USB_CHARGE_SET_MODE 0x30
  1144. struct ec_params_usb_charge_set_mode {
  1145. uint8_t usb_port_id;
  1146. uint8_t mode;
  1147. } __packed;
  1148. /*****************************************************************************/
  1149. /* Persistent storage for host */
  1150. /* Maximum bytes that can be read/written in a single command */
  1151. #define EC_PSTORE_SIZE_MAX 64
  1152. /* Get persistent storage info */
  1153. #define EC_CMD_PSTORE_INFO 0x40
  1154. struct ec_response_pstore_info {
  1155. /* Persistent storage size, in bytes */
  1156. uint32_t pstore_size;
  1157. /* Access size; read/write offset and size must be a multiple of this */
  1158. uint32_t access_size;
  1159. } __packed;
  1160. /*
  1161. * Read persistent storage
  1162. *
  1163. * Response is params.size bytes of data.
  1164. */
  1165. #define EC_CMD_PSTORE_READ 0x41
  1166. struct ec_params_pstore_read {
  1167. uint32_t offset; /* Byte offset to read */
  1168. uint32_t size; /* Size to read in bytes */
  1169. } __packed;
  1170. /* Write persistent storage */
  1171. #define EC_CMD_PSTORE_WRITE 0x42
  1172. struct ec_params_pstore_write {
  1173. uint32_t offset; /* Byte offset to write */
  1174. uint32_t size; /* Size to write in bytes */
  1175. uint8_t data[EC_PSTORE_SIZE_MAX];
  1176. } __packed;
  1177. /*****************************************************************************/
  1178. /* Real-time clock */
  1179. /* RTC params and response structures */
  1180. struct ec_params_rtc {
  1181. uint32_t time;
  1182. } __packed;
  1183. struct ec_response_rtc {
  1184. uint32_t time;
  1185. } __packed;
  1186. /* These use ec_response_rtc */
  1187. #define EC_CMD_RTC_GET_VALUE 0x44
  1188. #define EC_CMD_RTC_GET_ALARM 0x45
  1189. /* These all use ec_params_rtc */
  1190. #define EC_CMD_RTC_SET_VALUE 0x46
  1191. #define EC_CMD_RTC_SET_ALARM 0x47
  1192. /*****************************************************************************/
  1193. /* Port80 log access */
  1194. /* Get last port80 code from previous boot */
  1195. #define EC_CMD_PORT80_LAST_BOOT 0x48
  1196. struct ec_response_port80_last_boot {
  1197. uint16_t code;
  1198. } __packed;
  1199. /*****************************************************************************/
  1200. /* Thermal engine commands. Note that there are two implementations. We'll
  1201. * reuse the command number, but the data and behavior is incompatible.
  1202. * Version 0 is what originally shipped on Link.
  1203. * Version 1 separates the CPU thermal limits from the fan control.
  1204. */
  1205. #define EC_CMD_THERMAL_SET_THRESHOLD 0x50
  1206. #define EC_CMD_THERMAL_GET_THRESHOLD 0x51
  1207. /* The version 0 structs are opaque. You have to know what they are for
  1208. * the get/set commands to make any sense.
  1209. */
  1210. /* Version 0 - set */
  1211. struct ec_params_thermal_set_threshold {
  1212. uint8_t sensor_type;
  1213. uint8_t threshold_id;
  1214. uint16_t value;
  1215. } __packed;
  1216. /* Version 0 - get */
  1217. struct ec_params_thermal_get_threshold {
  1218. uint8_t sensor_type;
  1219. uint8_t threshold_id;
  1220. } __packed;
  1221. struct ec_response_thermal_get_threshold {
  1222. uint16_t value;
  1223. } __packed;
  1224. /* The version 1 structs are visible. */
  1225. enum ec_temp_thresholds {
  1226. EC_TEMP_THRESH_WARN = 0,
  1227. EC_TEMP_THRESH_HIGH,
  1228. EC_TEMP_THRESH_HALT,
  1229. EC_TEMP_THRESH_COUNT
  1230. };
  1231. /* Thermal configuration for one temperature sensor. Temps are in degrees K.
  1232. * Zero values will be silently ignored by the thermal task.
  1233. */
  1234. struct ec_thermal_config {
  1235. uint32_t temp_host[EC_TEMP_THRESH_COUNT]; /* levels of hotness */
  1236. uint32_t temp_fan_off; /* no active cooling needed */
  1237. uint32_t temp_fan_max; /* max active cooling needed */
  1238. } __packed;
  1239. /* Version 1 - get config for one sensor. */
  1240. struct ec_params_thermal_get_threshold_v1 {
  1241. uint32_t sensor_num;
  1242. } __packed;
  1243. /* This returns a struct ec_thermal_config */
  1244. /* Version 1 - set config for one sensor.
  1245. * Use read-modify-write for best results! */
  1246. struct ec_params_thermal_set_threshold_v1 {
  1247. uint32_t sensor_num;
  1248. struct ec_thermal_config cfg;
  1249. } __packed;
  1250. /* This returns no data */
  1251. /****************************************************************************/
  1252. /* Toggle automatic fan control */
  1253. #define EC_CMD_THERMAL_AUTO_FAN_CTRL 0x52
  1254. /* Get TMP006 calibration data */
  1255. #define EC_CMD_TMP006_GET_CALIBRATION 0x53
  1256. struct ec_params_tmp006_get_calibration {
  1257. uint8_t index;
  1258. } __packed;
  1259. struct ec_response_tmp006_get_calibration {
  1260. float s0;
  1261. float b0;
  1262. float b1;
  1263. float b2;
  1264. } __packed;
  1265. /* Set TMP006 calibration data */
  1266. #define EC_CMD_TMP006_SET_CALIBRATION 0x54
  1267. struct ec_params_tmp006_set_calibration {
  1268. uint8_t index;
  1269. uint8_t reserved[3]; /* Reserved; set 0 */
  1270. float s0;
  1271. float b0;
  1272. float b1;
  1273. float b2;
  1274. } __packed;
  1275. /* Read raw TMP006 data */
  1276. #define EC_CMD_TMP006_GET_RAW 0x55
  1277. struct ec_params_tmp006_get_raw {
  1278. uint8_t index;
  1279. } __packed;
  1280. struct ec_response_tmp006_get_raw {
  1281. int32_t t; /* In 1/100 K */
  1282. int32_t v; /* In nV */
  1283. };
  1284. /*****************************************************************************/
  1285. /* MKBP - Matrix KeyBoard Protocol */
  1286. /*
  1287. * Read key state
  1288. *
  1289. * Returns raw data for keyboard cols; see ec_response_mkbp_info.cols for
  1290. * expected response size.
  1291. */
  1292. #define EC_CMD_MKBP_STATE 0x60
  1293. /* Provide information about the matrix : number of rows and columns */
  1294. #define EC_CMD_MKBP_INFO 0x61
  1295. struct ec_response_mkbp_info {
  1296. uint32_t rows;
  1297. uint32_t cols;
  1298. uint8_t switches;
  1299. } __packed;
  1300. /* Simulate key press */
  1301. #define EC_CMD_MKBP_SIMULATE_KEY 0x62
  1302. struct ec_params_mkbp_simulate_key {
  1303. uint8_t col;
  1304. uint8_t row;
  1305. uint8_t pressed;
  1306. } __packed;
  1307. /* Configure keyboard scanning */
  1308. #define EC_CMD_MKBP_SET_CONFIG 0x64
  1309. #define EC_CMD_MKBP_GET_CONFIG 0x65
  1310. /* flags */
  1311. enum mkbp_config_flags {
  1312. EC_MKBP_FLAGS_ENABLE = 1, /* Enable keyboard scanning */
  1313. };
  1314. enum mkbp_config_valid {
  1315. EC_MKBP_VALID_SCAN_PERIOD = 1 << 0,
  1316. EC_MKBP_VALID_POLL_TIMEOUT = 1 << 1,
  1317. EC_MKBP_VALID_MIN_POST_SCAN_DELAY = 1 << 3,
  1318. EC_MKBP_VALID_OUTPUT_SETTLE = 1 << 4,
  1319. EC_MKBP_VALID_DEBOUNCE_DOWN = 1 << 5,
  1320. EC_MKBP_VALID_DEBOUNCE_UP = 1 << 6,
  1321. EC_MKBP_VALID_FIFO_MAX_DEPTH = 1 << 7,
  1322. };
  1323. /* Configuration for our key scanning algorithm */
  1324. struct ec_mkbp_config {
  1325. uint32_t valid_mask; /* valid fields */
  1326. uint8_t flags; /* some flags (enum mkbp_config_flags) */
  1327. uint8_t valid_flags; /* which flags are valid */
  1328. uint16_t scan_period_us; /* period between start of scans */
  1329. /* revert to interrupt mode after no activity for this long */
  1330. uint32_t poll_timeout_us;
  1331. /*
  1332. * minimum post-scan relax time. Once we finish a scan we check
  1333. * the time until we are due to start the next one. If this time is
  1334. * shorter this field, we use this instead.
  1335. */
  1336. uint16_t min_post_scan_delay_us;
  1337. /* delay between setting up output and waiting for it to settle */
  1338. uint16_t output_settle_us;
  1339. uint16_t debounce_down_us; /* time for debounce on key down */
  1340. uint16_t debounce_up_us; /* time for debounce on key up */
  1341. /* maximum depth to allow for fifo (0 = no keyscan output) */
  1342. uint8_t fifo_max_depth;
  1343. } __packed;
  1344. struct ec_params_mkbp_set_config {
  1345. struct ec_mkbp_config config;
  1346. } __packed;
  1347. struct ec_response_mkbp_get_config {
  1348. struct ec_mkbp_config config;
  1349. } __packed;
  1350. /* Run the key scan emulation */
  1351. #define EC_CMD_KEYSCAN_SEQ_CTRL 0x66
  1352. enum ec_keyscan_seq_cmd {
  1353. EC_KEYSCAN_SEQ_STATUS = 0, /* Get status information */
  1354. EC_KEYSCAN_SEQ_CLEAR = 1, /* Clear sequence */
  1355. EC_KEYSCAN_SEQ_ADD = 2, /* Add item to sequence */
  1356. EC_KEYSCAN_SEQ_START = 3, /* Start running sequence */
  1357. EC_KEYSCAN_SEQ_COLLECT = 4, /* Collect sequence summary data */
  1358. };
  1359. enum ec_collect_flags {
  1360. /*
  1361. * Indicates this scan was processed by the EC. Due to timing, some
  1362. * scans may be skipped.
  1363. */
  1364. EC_KEYSCAN_SEQ_FLAG_DONE = 1 << 0,
  1365. };
  1366. struct ec_collect_item {
  1367. uint8_t flags; /* some flags (enum ec_collect_flags) */
  1368. };
  1369. struct ec_params_keyscan_seq_ctrl {
  1370. uint8_t cmd; /* Command to send (enum ec_keyscan_seq_cmd) */
  1371. union {
  1372. struct {
  1373. uint8_t active; /* still active */
  1374. uint8_t num_items; /* number of items */
  1375. /* Current item being presented */
  1376. uint8_t cur_item;
  1377. } status;
  1378. struct {
  1379. /*
  1380. * Absolute time for this scan, measured from the
  1381. * start of the sequence.
  1382. */
  1383. uint32_t time_us;
  1384. uint8_t scan[0]; /* keyscan data */
  1385. } add;
  1386. struct {
  1387. uint8_t start_item; /* First item to return */
  1388. uint8_t num_items; /* Number of items to return */
  1389. } collect;
  1390. };
  1391. } __packed;
  1392. struct ec_result_keyscan_seq_ctrl {
  1393. union {
  1394. struct {
  1395. uint8_t num_items; /* Number of items */
  1396. /* Data for each item */
  1397. struct ec_collect_item item[0];
  1398. } collect;
  1399. };
  1400. } __packed;
  1401. /*****************************************************************************/
  1402. /* Temperature sensor commands */
  1403. /* Read temperature sensor info */
  1404. #define EC_CMD_TEMP_SENSOR_GET_INFO 0x70
  1405. struct ec_params_temp_sensor_get_info {
  1406. uint8_t id;
  1407. } __packed;
  1408. struct ec_response_temp_sensor_get_info {
  1409. char sensor_name[32];
  1410. uint8_t sensor_type;
  1411. } __packed;
  1412. /*****************************************************************************/
  1413. /*
  1414. * Note: host commands 0x80 - 0x87 are reserved to avoid conflict with ACPI
  1415. * commands accidentally sent to the wrong interface. See the ACPI section
  1416. * below.
  1417. */
  1418. /*****************************************************************************/
  1419. /* Host event commands */
  1420. /*
  1421. * Host event mask params and response structures, shared by all of the host
  1422. * event commands below.
  1423. */
  1424. struct ec_params_host_event_mask {
  1425. uint32_t mask;
  1426. } __packed;
  1427. struct ec_response_host_event_mask {
  1428. uint32_t mask;
  1429. } __packed;
  1430. /* These all use ec_response_host_event_mask */
  1431. #define EC_CMD_HOST_EVENT_GET_B 0x87
  1432. #define EC_CMD_HOST_EVENT_GET_SMI_MASK 0x88
  1433. #define EC_CMD_HOST_EVENT_GET_SCI_MASK 0x89
  1434. #define EC_CMD_HOST_EVENT_GET_WAKE_MASK 0x8d
  1435. /* These all use ec_params_host_event_mask */
  1436. #define EC_CMD_HOST_EVENT_SET_SMI_MASK 0x8a
  1437. #define EC_CMD_HOST_EVENT_SET_SCI_MASK 0x8b
  1438. #define EC_CMD_HOST_EVENT_CLEAR 0x8c
  1439. #define EC_CMD_HOST_EVENT_SET_WAKE_MASK 0x8e
  1440. #define EC_CMD_HOST_EVENT_CLEAR_B 0x8f
  1441. /*****************************************************************************/
  1442. /* Switch commands */
  1443. /* Enable/disable LCD backlight */
  1444. #define EC_CMD_SWITCH_ENABLE_BKLIGHT 0x90
  1445. struct ec_params_switch_enable_backlight {
  1446. uint8_t enabled;
  1447. } __packed;
  1448. /* Enable/disable WLAN/Bluetooth */
  1449. #define EC_CMD_SWITCH_ENABLE_WIRELESS 0x91
  1450. #define EC_VER_SWITCH_ENABLE_WIRELESS 1
  1451. /* Version 0 params; no response */
  1452. struct ec_params_switch_enable_wireless_v0 {
  1453. uint8_t enabled;
  1454. } __packed;
  1455. /* Version 1 params */
  1456. struct ec_params_switch_enable_wireless_v1 {
  1457. /* Flags to enable now */
  1458. uint8_t now_flags;
  1459. /* Which flags to copy from now_flags */
  1460. uint8_t now_mask;
  1461. /*
  1462. * Flags to leave enabled in S3, if they're on at the S0->S3
  1463. * transition. (Other flags will be disabled by the S0->S3
  1464. * transition.)
  1465. */
  1466. uint8_t suspend_flags;
  1467. /* Which flags to copy from suspend_flags */
  1468. uint8_t suspend_mask;
  1469. } __packed;
  1470. /* Version 1 response */
  1471. struct ec_response_switch_enable_wireless_v1 {
  1472. /* Flags to enable now */
  1473. uint8_t now_flags;
  1474. /* Flags to leave enabled in S3 */
  1475. uint8_t suspend_flags;
  1476. } __packed;
  1477. /*****************************************************************************/
  1478. /* GPIO commands. Only available on EC if write protect has been disabled. */
  1479. /* Set GPIO output value */
  1480. #define EC_CMD_GPIO_SET 0x92
  1481. struct ec_params_gpio_set {
  1482. char name[32];
  1483. uint8_t val;
  1484. } __packed;
  1485. /* Get GPIO value */
  1486. #define EC_CMD_GPIO_GET 0x93
  1487. struct ec_params_gpio_get {
  1488. char name[32];
  1489. } __packed;
  1490. struct ec_response_gpio_get {
  1491. uint8_t val;
  1492. } __packed;
  1493. /*****************************************************************************/
  1494. /* I2C commands. Only available when flash write protect is unlocked. */
  1495. /*
  1496. * TODO(crosbug.com/p/23570): These commands are deprecated, and will be
  1497. * removed soon. Use EC_CMD_I2C_XFER instead.
  1498. */
  1499. /* Read I2C bus */
  1500. #define EC_CMD_I2C_READ 0x94
  1501. struct ec_params_i2c_read {
  1502. uint16_t addr; /* 8-bit address (7-bit shifted << 1) */
  1503. uint8_t read_size; /* Either 8 or 16. */
  1504. uint8_t port;
  1505. uint8_t offset;
  1506. } __packed;
  1507. struct ec_response_i2c_read {
  1508. uint16_t data;
  1509. } __packed;
  1510. /* Write I2C bus */
  1511. #define EC_CMD_I2C_WRITE 0x95
  1512. struct ec_params_i2c_write {
  1513. uint16_t data;
  1514. uint16_t addr; /* 8-bit address (7-bit shifted << 1) */
  1515. uint8_t write_size; /* Either 8 or 16. */
  1516. uint8_t port;
  1517. uint8_t offset;
  1518. } __packed;
  1519. /*****************************************************************************/
  1520. /* Charge state commands. Only available when flash write protect unlocked. */
  1521. /* Force charge state machine to stop charging the battery or force it to
  1522. * discharge the battery.
  1523. */
  1524. #define EC_CMD_CHARGE_CONTROL 0x96
  1525. #define EC_VER_CHARGE_CONTROL 1
  1526. enum ec_charge_control_mode {
  1527. CHARGE_CONTROL_NORMAL = 0,
  1528. CHARGE_CONTROL_IDLE,
  1529. CHARGE_CONTROL_DISCHARGE,
  1530. };
  1531. struct ec_params_charge_control {
  1532. uint32_t mode; /* enum charge_control_mode */
  1533. } __packed;
  1534. /*****************************************************************************/
  1535. /* Console commands. Only available when flash write protect is unlocked. */
  1536. /* Snapshot console output buffer for use by EC_CMD_CONSOLE_READ. */
  1537. #define EC_CMD_CONSOLE_SNAPSHOT 0x97
  1538. /*
  1539. * Read next chunk of data from saved snapshot.
  1540. *
  1541. * Response is null-terminated string. Empty string, if there is no more
  1542. * remaining output.
  1543. */
  1544. #define EC_CMD_CONSOLE_READ 0x98
  1545. /*****************************************************************************/
  1546. /*
  1547. * Cut off battery power output if the battery supports.
  1548. *
  1549. * For unsupported battery, just don't implement this command and lets EC
  1550. * return EC_RES_INVALID_COMMAND.
  1551. */
  1552. #define EC_CMD_BATTERY_CUT_OFF 0x99
  1553. /*****************************************************************************/
  1554. /* USB port mux control. */
  1555. /*
  1556. * Switch USB mux or return to automatic switching.
  1557. */
  1558. #define EC_CMD_USB_MUX 0x9a
  1559. struct ec_params_usb_mux {
  1560. uint8_t mux;
  1561. } __packed;
  1562. /*****************************************************************************/
  1563. /* LDOs / FETs control. */
  1564. enum ec_ldo_state {
  1565. EC_LDO_STATE_OFF = 0, /* the LDO / FET is shut down */
  1566. EC_LDO_STATE_ON = 1, /* the LDO / FET is ON / providing power */
  1567. };
  1568. /*
  1569. * Switch on/off a LDO.
  1570. */
  1571. #define EC_CMD_LDO_SET 0x9b
  1572. struct ec_params_ldo_set {
  1573. uint8_t index;
  1574. uint8_t state;
  1575. } __packed;
  1576. /*
  1577. * Get LDO state.
  1578. */
  1579. #define EC_CMD_LDO_GET 0x9c
  1580. struct ec_params_ldo_get {
  1581. uint8_t index;
  1582. } __packed;
  1583. struct ec_response_ldo_get {
  1584. uint8_t state;
  1585. } __packed;
  1586. /*****************************************************************************/
  1587. /* Power info. */
  1588. /*
  1589. * Get power info.
  1590. */
  1591. #define EC_CMD_POWER_INFO 0x9d
  1592. struct ec_response_power_info {
  1593. uint32_t usb_dev_type;
  1594. uint16_t voltage_ac;
  1595. uint16_t voltage_system;
  1596. uint16_t current_system;
  1597. uint16_t usb_current_limit;
  1598. } __packed;
  1599. /*****************************************************************************/
  1600. /* I2C passthru command */
  1601. #define EC_CMD_I2C_PASSTHRU 0x9e
  1602. /* Read data; if not present, message is a write */
  1603. #define EC_I2C_FLAG_READ (1 << 15)
  1604. /* Mask for address */
  1605. #define EC_I2C_ADDR_MASK 0x3ff
  1606. #define EC_I2C_STATUS_NAK (1 << 0) /* Transfer was not acknowledged */
  1607. #define EC_I2C_STATUS_TIMEOUT (1 << 1) /* Timeout during transfer */
  1608. /* Any error */
  1609. #define EC_I2C_STATUS_ERROR (EC_I2C_STATUS_NAK | EC_I2C_STATUS_TIMEOUT)
  1610. struct ec_params_i2c_passthru_msg {
  1611. uint16_t addr_flags; /* I2C slave address (7 or 10 bits) and flags */
  1612. uint16_t len; /* Number of bytes to read or write */
  1613. } __packed;
  1614. struct ec_params_i2c_passthru {
  1615. uint8_t port; /* I2C port number */
  1616. uint8_t num_msgs; /* Number of messages */
  1617. struct ec_params_i2c_passthru_msg msg[];
  1618. /* Data to write for all messages is concatenated here */
  1619. } __packed;
  1620. struct ec_response_i2c_passthru {
  1621. uint8_t i2c_status; /* Status flags (EC_I2C_STATUS_...) */
  1622. uint8_t num_msgs; /* Number of messages processed */
  1623. uint8_t data[]; /* Data read by messages concatenated here */
  1624. } __packed;
  1625. /*****************************************************************************/
  1626. /* Power button hang detect */
  1627. #define EC_CMD_HANG_DETECT 0x9f
  1628. /* Reasons to start hang detection timer */
  1629. /* Power button pressed */
  1630. #define EC_HANG_START_ON_POWER_PRESS (1 << 0)
  1631. /* Lid closed */
  1632. #define EC_HANG_START_ON_LID_CLOSE (1 << 1)
  1633. /* Lid opened */
  1634. #define EC_HANG_START_ON_LID_OPEN (1 << 2)
  1635. /* Start of AP S3->S0 transition (booting or resuming from suspend) */
  1636. #define EC_HANG_START_ON_RESUME (1 << 3)
  1637. /* Reasons to cancel hang detection */
  1638. /* Power button released */
  1639. #define EC_HANG_STOP_ON_POWER_RELEASE (1 << 8)
  1640. /* Any host command from AP received */
  1641. #define EC_HANG_STOP_ON_HOST_COMMAND (1 << 9)
  1642. /* Stop on end of AP S0->S3 transition (suspending or shutting down) */
  1643. #define EC_HANG_STOP_ON_SUSPEND (1 << 10)
  1644. /*
  1645. * If this flag is set, all the other fields are ignored, and the hang detect
  1646. * timer is started. This provides the AP a way to start the hang timer
  1647. * without reconfiguring any of the other hang detect settings. Note that
  1648. * you must previously have configured the timeouts.
  1649. */
  1650. #define EC_HANG_START_NOW (1 << 30)
  1651. /*
  1652. * If this flag is set, all the other fields are ignored (including
  1653. * EC_HANG_START_NOW). This provides the AP a way to stop the hang timer
  1654. * without reconfiguring any of the other hang detect settings.
  1655. */
  1656. #define EC_HANG_STOP_NOW (1 << 31)
  1657. struct ec_params_hang_detect {
  1658. /* Flags; see EC_HANG_* */
  1659. uint32_t flags;
  1660. /* Timeout in msec before generating host event, if enabled */
  1661. uint16_t host_event_timeout_msec;
  1662. /* Timeout in msec before generating warm reboot, if enabled */
  1663. uint16_t warm_reboot_timeout_msec;
  1664. } __packed;
  1665. /*****************************************************************************/
  1666. /* Commands for battery charging */
  1667. /*
  1668. * This is the single catch-all host command to exchange data regarding the
  1669. * charge state machine (v2 and up).
  1670. */
  1671. #define EC_CMD_CHARGE_STATE 0xa0
  1672. /* Subcommands for this host command */
  1673. enum charge_state_command {
  1674. CHARGE_STATE_CMD_GET_STATE,
  1675. CHARGE_STATE_CMD_GET_PARAM,
  1676. CHARGE_STATE_CMD_SET_PARAM,
  1677. CHARGE_STATE_NUM_CMDS
  1678. };
  1679. /*
  1680. * Known param numbers are defined here. Ranges are reserved for board-specific
  1681. * params, which are handled by the particular implementations.
  1682. */
  1683. enum charge_state_params {
  1684. CS_PARAM_CHG_VOLTAGE, /* charger voltage limit */
  1685. CS_PARAM_CHG_CURRENT, /* charger current limit */
  1686. CS_PARAM_CHG_INPUT_CURRENT, /* charger input current limit */
  1687. CS_PARAM_CHG_STATUS, /* charger-specific status */
  1688. CS_PARAM_CHG_OPTION, /* charger-specific options */
  1689. /* How many so far? */
  1690. CS_NUM_BASE_PARAMS,
  1691. /* Range for CONFIG_CHARGER_PROFILE_OVERRIDE params */
  1692. CS_PARAM_CUSTOM_PROFILE_MIN = 0x10000,
  1693. CS_PARAM_CUSTOM_PROFILE_MAX = 0x1ffff,
  1694. /* Other custom param ranges go here... */
  1695. };
  1696. struct ec_params_charge_state {
  1697. uint8_t cmd; /* enum charge_state_command */
  1698. union {
  1699. struct {
  1700. /* no args */
  1701. } get_state;
  1702. struct {
  1703. uint32_t param; /* enum charge_state_param */
  1704. } get_param;
  1705. struct {
  1706. uint32_t param; /* param to set */
  1707. uint32_t value; /* value to set */
  1708. } set_param;
  1709. };
  1710. } __packed;
  1711. struct ec_response_charge_state {
  1712. union {
  1713. struct {
  1714. int ac;
  1715. int chg_voltage;
  1716. int chg_current;
  1717. int chg_input_current;
  1718. int batt_state_of_charge;
  1719. } get_state;
  1720. struct {
  1721. uint32_t value;
  1722. } get_param;
  1723. struct {
  1724. /* no return values */
  1725. } set_param;
  1726. };
  1727. } __packed;
  1728. /*
  1729. * Set maximum battery charging current.
  1730. */
  1731. #define EC_CMD_CHARGE_CURRENT_LIMIT 0xa1
  1732. struct ec_params_current_limit {
  1733. uint32_t limit; /* in mA */
  1734. } __packed;
  1735. /*
  1736. * Set maximum external power current.
  1737. */
  1738. #define EC_CMD_EXT_POWER_CURRENT_LIMIT 0xa2
  1739. struct ec_params_ext_power_current_limit {
  1740. uint32_t limit; /* in mA */
  1741. } __packed;
  1742. /*****************************************************************************/
  1743. /* Smart battery pass-through */
  1744. /* Get / Set 16-bit smart battery registers */
  1745. #define EC_CMD_SB_READ_WORD 0xb0
  1746. #define EC_CMD_SB_WRITE_WORD 0xb1
  1747. /* Get / Set string smart battery parameters
  1748. * formatted as SMBUS "block".
  1749. */
  1750. #define EC_CMD_SB_READ_BLOCK 0xb2
  1751. #define EC_CMD_SB_WRITE_BLOCK 0xb3
  1752. struct ec_params_sb_rd {
  1753. uint8_t reg;
  1754. } __packed;
  1755. struct ec_response_sb_rd_word {
  1756. uint16_t value;
  1757. } __packed;
  1758. struct ec_params_sb_wr_word {
  1759. uint8_t reg;
  1760. uint16_t value;
  1761. } __packed;
  1762. struct ec_response_sb_rd_block {
  1763. uint8_t data[32];
  1764. } __packed;
  1765. struct ec_params_sb_wr_block {
  1766. uint8_t reg;
  1767. uint16_t data[32];
  1768. } __packed;
  1769. /*****************************************************************************/
  1770. /* System commands */
  1771. /*
  1772. * TODO(crosbug.com/p/23747): This is a confusing name, since it doesn't
  1773. * necessarily reboot the EC. Rename to "image" or something similar?
  1774. */
  1775. #define EC_CMD_REBOOT_EC 0xd2
  1776. /* Command */
  1777. enum ec_reboot_cmd {
  1778. EC_REBOOT_CANCEL = 0, /* Cancel a pending reboot */
  1779. EC_REBOOT_JUMP_RO = 1, /* Jump to RO without rebooting */
  1780. EC_REBOOT_JUMP_RW = 2, /* Jump to RW without rebooting */
  1781. /* (command 3 was jump to RW-B) */
  1782. EC_REBOOT_COLD = 4, /* Cold-reboot */
  1783. EC_REBOOT_DISABLE_JUMP = 5, /* Disable jump until next reboot */
  1784. EC_REBOOT_HIBERNATE = 6 /* Hibernate EC */
  1785. };
  1786. /* Flags for ec_params_reboot_ec.reboot_flags */
  1787. #define EC_REBOOT_FLAG_RESERVED0 (1 << 0) /* Was recovery request */
  1788. #define EC_REBOOT_FLAG_ON_AP_SHUTDOWN (1 << 1) /* Reboot after AP shutdown */
  1789. struct ec_params_reboot_ec {
  1790. uint8_t cmd; /* enum ec_reboot_cmd */
  1791. uint8_t flags; /* See EC_REBOOT_FLAG_* */
  1792. } __packed;
  1793. /*
  1794. * Get information on last EC panic.
  1795. *
  1796. * Returns variable-length platform-dependent panic information. See panic.h
  1797. * for details.
  1798. */
  1799. #define EC_CMD_GET_PANIC_INFO 0xd3
  1800. /*****************************************************************************/
  1801. /*
  1802. * ACPI commands
  1803. *
  1804. * These are valid ONLY on the ACPI command/data port.
  1805. */
  1806. /*
  1807. * ACPI Read Embedded Controller
  1808. *
  1809. * This reads from ACPI memory space on the EC (EC_ACPI_MEM_*).
  1810. *
  1811. * Use the following sequence:
  1812. *
  1813. * - Write EC_CMD_ACPI_READ to EC_LPC_ADDR_ACPI_CMD
  1814. * - Wait for EC_LPC_CMDR_PENDING bit to clear
  1815. * - Write address to EC_LPC_ADDR_ACPI_DATA
  1816. * - Wait for EC_LPC_CMDR_DATA bit to set
  1817. * - Read value from EC_LPC_ADDR_ACPI_DATA
  1818. */
  1819. #define EC_CMD_ACPI_READ 0x80
  1820. /*
  1821. * ACPI Write Embedded Controller
  1822. *
  1823. * This reads from ACPI memory space on the EC (EC_ACPI_MEM_*).
  1824. *
  1825. * Use the following sequence:
  1826. *
  1827. * - Write EC_CMD_ACPI_WRITE to EC_LPC_ADDR_ACPI_CMD
  1828. * - Wait for EC_LPC_CMDR_PENDING bit to clear
  1829. * - Write address to EC_LPC_ADDR_ACPI_DATA
  1830. * - Wait for EC_LPC_CMDR_PENDING bit to clear
  1831. * - Write value to EC_LPC_ADDR_ACPI_DATA
  1832. */
  1833. #define EC_CMD_ACPI_WRITE 0x81
  1834. /*
  1835. * ACPI Query Embedded Controller
  1836. *
  1837. * This clears the lowest-order bit in the currently pending host events, and
  1838. * sets the result code to the 1-based index of the bit (event 0x00000001 = 1,
  1839. * event 0x80000000 = 32), or 0 if no event was pending.
  1840. */
  1841. #define EC_CMD_ACPI_QUERY_EVENT 0x84
  1842. /* Valid addresses in ACPI memory space, for read/write commands */
  1843. /* Memory space version; set to EC_ACPI_MEM_VERSION_CURRENT */
  1844. #define EC_ACPI_MEM_VERSION 0x00
  1845. /*
  1846. * Test location; writing value here updates test compliment byte to (0xff -
  1847. * value).
  1848. */
  1849. #define EC_ACPI_MEM_TEST 0x01
  1850. /* Test compliment; writes here are ignored. */
  1851. #define EC_ACPI_MEM_TEST_COMPLIMENT 0x02
  1852. /* Keyboard backlight brightness percent (0 - 100) */
  1853. #define EC_ACPI_MEM_KEYBOARD_BACKLIGHT 0x03
  1854. /* DPTF Target Fan Duty (0-100, 0xff for auto/none) */
  1855. #define EC_ACPI_MEM_FAN_DUTY 0x04
  1856. /*
  1857. * DPTF temp thresholds. Any of the EC's temp sensors can have up to two
  1858. * independent thresholds attached to them. The current value of the ID
  1859. * register determines which sensor is affected by the THRESHOLD and COMMIT
  1860. * registers. The THRESHOLD register uses the same EC_TEMP_SENSOR_OFFSET scheme
  1861. * as the memory-mapped sensors. The COMMIT register applies those settings.
  1862. *
  1863. * The spec does not mandate any way to read back the threshold settings
  1864. * themselves, but when a threshold is crossed the AP needs a way to determine
  1865. * which sensor(s) are responsible. Each reading of the ID register clears and
  1866. * returns one sensor ID that has crossed one of its threshold (in either
  1867. * direction) since the last read. A value of 0xFF means "no new thresholds
  1868. * have tripped". Setting or enabling the thresholds for a sensor will clear
  1869. * the unread event count for that sensor.
  1870. */
  1871. #define EC_ACPI_MEM_TEMP_ID 0x05
  1872. #define EC_ACPI_MEM_TEMP_THRESHOLD 0x06
  1873. #define EC_ACPI_MEM_TEMP_COMMIT 0x07
  1874. /*
  1875. * Here are the bits for the COMMIT register:
  1876. * bit 0 selects the threshold index for the chosen sensor (0/1)
  1877. * bit 1 enables/disables the selected threshold (0 = off, 1 = on)
  1878. * Each write to the commit register affects one threshold.
  1879. */
  1880. #define EC_ACPI_MEM_TEMP_COMMIT_SELECT_MASK (1 << 0)
  1881. #define EC_ACPI_MEM_TEMP_COMMIT_ENABLE_MASK (1 << 1)
  1882. /*
  1883. * Example:
  1884. *
  1885. * Set the thresholds for sensor 2 to 50 C and 60 C:
  1886. * write 2 to [0x05] -- select temp sensor 2
  1887. * write 0x7b to [0x06] -- C_TO_K(50) - EC_TEMP_SENSOR_OFFSET
  1888. * write 0x2 to [0x07] -- enable threshold 0 with this value
  1889. * write 0x85 to [0x06] -- C_TO_K(60) - EC_TEMP_SENSOR_OFFSET
  1890. * write 0x3 to [0x07] -- enable threshold 1 with this value
  1891. *
  1892. * Disable the 60 C threshold, leaving the 50 C threshold unchanged:
  1893. * write 2 to [0x05] -- select temp sensor 2
  1894. * write 0x1 to [0x07] -- disable threshold 1
  1895. */
  1896. /* DPTF battery charging current limit */
  1897. #define EC_ACPI_MEM_CHARGING_LIMIT 0x08
  1898. /* Charging limit is specified in 64 mA steps */
  1899. #define EC_ACPI_MEM_CHARGING_LIMIT_STEP_MA 64
  1900. /* Value to disable DPTF battery charging limit */
  1901. #define EC_ACPI_MEM_CHARGING_LIMIT_DISABLED 0xff
  1902. /* Current version of ACPI memory address space */
  1903. #define EC_ACPI_MEM_VERSION_CURRENT 1
  1904. /*****************************************************************************/
  1905. /*
  1906. * Special commands
  1907. *
  1908. * These do not follow the normal rules for commands. See each command for
  1909. * details.
  1910. */
  1911. /*
  1912. * Reboot NOW
  1913. *
  1914. * This command will work even when the EC LPC interface is busy, because the
  1915. * reboot command is processed at interrupt level. Note that when the EC
  1916. * reboots, the host will reboot too, so there is no response to this command.
  1917. *
  1918. * Use EC_CMD_REBOOT_EC to reboot the EC more politely.
  1919. */
  1920. #define EC_CMD_REBOOT 0xd1 /* Think "die" */
  1921. /*
  1922. * Resend last response (not supported on LPC).
  1923. *
  1924. * Returns EC_RES_UNAVAILABLE if there is no response available - for example,
  1925. * there was no previous command, or the previous command's response was too
  1926. * big to save.
  1927. */
  1928. #define EC_CMD_RESEND_RESPONSE 0xdb
  1929. /*
  1930. * This header byte on a command indicate version 0. Any header byte less
  1931. * than this means that we are talking to an old EC which doesn't support
  1932. * versioning. In that case, we assume version 0.
  1933. *
  1934. * Header bytes greater than this indicate a later version. For example,
  1935. * EC_CMD_VERSION0 + 1 means we are using version 1.
  1936. *
  1937. * The old EC interface must not use commands 0xdc or higher.
  1938. */
  1939. #define EC_CMD_VERSION0 0xdc
  1940. #endif /* !__ACPI__ */
  1941. /*****************************************************************************/
  1942. /*
  1943. * Deprecated constants. These constants have been renamed for clarity. The
  1944. * meaning and size has not changed. Programs that use the old names should
  1945. * switch to the new names soon, as the old names may not be carried forward
  1946. * forever.
  1947. */
  1948. #define EC_HOST_PARAM_SIZE EC_PROTO2_MAX_PARAM_SIZE
  1949. #define EC_LPC_ADDR_OLD_PARAM EC_HOST_CMD_REGION1
  1950. #define EC_OLD_PARAM_SIZE EC_HOST_CMD_REGION_SIZE
  1951. #endif /* __CROS_EC_COMMANDS_H */