cros_ec_commands.h 82 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906
  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 16-bit 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. /* List the features supported by the firmware */
  612. #define EC_CMD_GET_FEATURES 0x0d
  613. /* Supported features */
  614. enum ec_feature_code {
  615. /*
  616. * This image contains a limited set of features. Another image
  617. * in RW partition may support more features.
  618. */
  619. EC_FEATURE_LIMITED = 0,
  620. /*
  621. * Commands for probing/reading/writing/erasing the flash in the
  622. * EC are present.
  623. */
  624. EC_FEATURE_FLASH = 1,
  625. /*
  626. * Can control the fan speed directly.
  627. */
  628. EC_FEATURE_PWM_FAN = 2,
  629. /*
  630. * Can control the intensity of the keyboard backlight.
  631. */
  632. EC_FEATURE_PWM_KEYB = 3,
  633. /*
  634. * Support Google lightbar, introduced on Pixel.
  635. */
  636. EC_FEATURE_LIGHTBAR = 4,
  637. /* Control of LEDs */
  638. EC_FEATURE_LED = 5,
  639. /* Exposes an interface to control gyro and sensors.
  640. * The host goes through the EC to access these sensors.
  641. * In addition, the EC may provide composite sensors, like lid angle.
  642. */
  643. EC_FEATURE_MOTION_SENSE = 6,
  644. /* The keyboard is controlled by the EC */
  645. EC_FEATURE_KEYB = 7,
  646. /* The AP can use part of the EC flash as persistent storage. */
  647. EC_FEATURE_PSTORE = 8,
  648. /* The EC monitors BIOS port 80h, and can return POST codes. */
  649. EC_FEATURE_PORT80 = 9,
  650. /*
  651. * Thermal management: include TMP specific commands.
  652. * Higher level than direct fan control.
  653. */
  654. EC_FEATURE_THERMAL = 10,
  655. /* Can switch the screen backlight on/off */
  656. EC_FEATURE_BKLIGHT_SWITCH = 11,
  657. /* Can switch the wifi module on/off */
  658. EC_FEATURE_WIFI_SWITCH = 12,
  659. /* Monitor host events, through for example SMI or SCI */
  660. EC_FEATURE_HOST_EVENTS = 13,
  661. /* The EC exposes GPIO commands to control/monitor connected devices. */
  662. EC_FEATURE_GPIO = 14,
  663. /* The EC can send i2c messages to downstream devices. */
  664. EC_FEATURE_I2C = 15,
  665. /* Command to control charger are included */
  666. EC_FEATURE_CHARGER = 16,
  667. /* Simple battery support. */
  668. EC_FEATURE_BATTERY = 17,
  669. /*
  670. * Support Smart battery protocol
  671. * (Common Smart Battery System Interface Specification)
  672. */
  673. EC_FEATURE_SMART_BATTERY = 18,
  674. /* EC can dectect when the host hangs. */
  675. EC_FEATURE_HANG_DETECT = 19,
  676. /* Report power information, for pit only */
  677. EC_FEATURE_PMU = 20,
  678. /* Another Cros EC device is present downstream of this one */
  679. EC_FEATURE_SUB_MCU = 21,
  680. /* Support USB Power delivery (PD) commands */
  681. EC_FEATURE_USB_PD = 22,
  682. /* Control USB multiplexer, for audio through USB port for instance. */
  683. EC_FEATURE_USB_MUX = 23,
  684. /* Motion Sensor code has an internal software FIFO */
  685. EC_FEATURE_MOTION_SENSE_FIFO = 24,
  686. };
  687. #define EC_FEATURE_MASK_0(event_code) (1UL << (event_code % 32))
  688. #define EC_FEATURE_MASK_1(event_code) (1UL << (event_code - 32))
  689. struct ec_response_get_features {
  690. uint32_t flags[2];
  691. } __packed;
  692. /*****************************************************************************/
  693. /* Flash commands */
  694. /* Get flash info */
  695. #define EC_CMD_FLASH_INFO 0x10
  696. /* Version 0 returns these fields */
  697. struct ec_response_flash_info {
  698. /* Usable flash size, in bytes */
  699. uint32_t flash_size;
  700. /*
  701. * Write block size. Write offset and size must be a multiple
  702. * of this.
  703. */
  704. uint32_t write_block_size;
  705. /*
  706. * Erase block size. Erase offset and size must be a multiple
  707. * of this.
  708. */
  709. uint32_t erase_block_size;
  710. /*
  711. * Protection block size. Protection offset and size must be a
  712. * multiple of this.
  713. */
  714. uint32_t protect_block_size;
  715. } __packed;
  716. /* Flags for version 1+ flash info command */
  717. /* EC flash erases bits to 0 instead of 1 */
  718. #define EC_FLASH_INFO_ERASE_TO_0 (1 << 0)
  719. /*
  720. * Version 1 returns the same initial fields as version 0, with additional
  721. * fields following.
  722. *
  723. * gcc anonymous structs don't seem to get along with the __packed directive;
  724. * if they did we'd define the version 0 struct as a sub-struct of this one.
  725. */
  726. struct ec_response_flash_info_1 {
  727. /* Version 0 fields; see above for description */
  728. uint32_t flash_size;
  729. uint32_t write_block_size;
  730. uint32_t erase_block_size;
  731. uint32_t protect_block_size;
  732. /* Version 1 adds these fields: */
  733. /*
  734. * Ideal write size in bytes. Writes will be fastest if size is
  735. * exactly this and offset is a multiple of this. For example, an EC
  736. * may have a write buffer which can do half-page operations if data is
  737. * aligned, and a slower word-at-a-time write mode.
  738. */
  739. uint32_t write_ideal_size;
  740. /* Flags; see EC_FLASH_INFO_* */
  741. uint32_t flags;
  742. } __packed;
  743. /*
  744. * Read flash
  745. *
  746. * Response is params.size bytes of data.
  747. */
  748. #define EC_CMD_FLASH_READ 0x11
  749. struct ec_params_flash_read {
  750. uint32_t offset; /* Byte offset to read */
  751. uint32_t size; /* Size to read in bytes */
  752. } __packed;
  753. /* Write flash */
  754. #define EC_CMD_FLASH_WRITE 0x12
  755. #define EC_VER_FLASH_WRITE 1
  756. /* Version 0 of the flash command supported only 64 bytes of data */
  757. #define EC_FLASH_WRITE_VER0_SIZE 64
  758. struct ec_params_flash_write {
  759. uint32_t offset; /* Byte offset to write */
  760. uint32_t size; /* Size to write in bytes */
  761. /* Followed by data to write */
  762. } __packed;
  763. /* Erase flash */
  764. #define EC_CMD_FLASH_ERASE 0x13
  765. struct ec_params_flash_erase {
  766. uint32_t offset; /* Byte offset to erase */
  767. uint32_t size; /* Size to erase in bytes */
  768. } __packed;
  769. /*
  770. * Get/set flash protection.
  771. *
  772. * If mask!=0, sets/clear the requested bits of flags. Depending on the
  773. * firmware write protect GPIO, not all flags will take effect immediately;
  774. * some flags require a subsequent hard reset to take effect. Check the
  775. * returned flags bits to see what actually happened.
  776. *
  777. * If mask=0, simply returns the current flags state.
  778. */
  779. #define EC_CMD_FLASH_PROTECT 0x15
  780. #define EC_VER_FLASH_PROTECT 1 /* Command version 1 */
  781. /* Flags for flash protection */
  782. /* RO flash code protected when the EC boots */
  783. #define EC_FLASH_PROTECT_RO_AT_BOOT (1 << 0)
  784. /*
  785. * RO flash code protected now. If this bit is set, at-boot status cannot
  786. * be changed.
  787. */
  788. #define EC_FLASH_PROTECT_RO_NOW (1 << 1)
  789. /* Entire flash code protected now, until reboot. */
  790. #define EC_FLASH_PROTECT_ALL_NOW (1 << 2)
  791. /* Flash write protect GPIO is asserted now */
  792. #define EC_FLASH_PROTECT_GPIO_ASSERTED (1 << 3)
  793. /* Error - at least one bank of flash is stuck locked, and cannot be unlocked */
  794. #define EC_FLASH_PROTECT_ERROR_STUCK (1 << 4)
  795. /*
  796. * Error - flash protection is in inconsistent state. At least one bank of
  797. * flash which should be protected is not protected. Usually fixed by
  798. * re-requesting the desired flags, or by a hard reset if that fails.
  799. */
  800. #define EC_FLASH_PROTECT_ERROR_INCONSISTENT (1 << 5)
  801. /* Entile flash code protected when the EC boots */
  802. #define EC_FLASH_PROTECT_ALL_AT_BOOT (1 << 6)
  803. struct ec_params_flash_protect {
  804. uint32_t mask; /* Bits in flags to apply */
  805. uint32_t flags; /* New flags to apply */
  806. } __packed;
  807. struct ec_response_flash_protect {
  808. /* Current value of flash protect flags */
  809. uint32_t flags;
  810. /*
  811. * Flags which are valid on this platform. This allows the caller
  812. * to distinguish between flags which aren't set vs. flags which can't
  813. * be set on this platform.
  814. */
  815. uint32_t valid_flags;
  816. /* Flags which can be changed given the current protection state */
  817. uint32_t writable_flags;
  818. } __packed;
  819. /*
  820. * Note: commands 0x14 - 0x19 version 0 were old commands to get/set flash
  821. * write protect. These commands may be reused with version > 0.
  822. */
  823. /* Get the region offset/size */
  824. #define EC_CMD_FLASH_REGION_INFO 0x16
  825. #define EC_VER_FLASH_REGION_INFO 1
  826. enum ec_flash_region {
  827. /* Region which holds read-only EC image */
  828. EC_FLASH_REGION_RO = 0,
  829. /* Region which holds rewritable EC image */
  830. EC_FLASH_REGION_RW,
  831. /*
  832. * Region which should be write-protected in the factory (a superset of
  833. * EC_FLASH_REGION_RO)
  834. */
  835. EC_FLASH_REGION_WP_RO,
  836. /* Number of regions */
  837. EC_FLASH_REGION_COUNT,
  838. };
  839. struct ec_params_flash_region_info {
  840. uint32_t region; /* enum ec_flash_region */
  841. } __packed;
  842. struct ec_response_flash_region_info {
  843. uint32_t offset;
  844. uint32_t size;
  845. } __packed;
  846. /* Read/write VbNvContext */
  847. #define EC_CMD_VBNV_CONTEXT 0x17
  848. #define EC_VER_VBNV_CONTEXT 1
  849. #define EC_VBNV_BLOCK_SIZE 16
  850. enum ec_vbnvcontext_op {
  851. EC_VBNV_CONTEXT_OP_READ,
  852. EC_VBNV_CONTEXT_OP_WRITE,
  853. };
  854. struct ec_params_vbnvcontext {
  855. uint32_t op;
  856. uint8_t block[EC_VBNV_BLOCK_SIZE];
  857. } __packed;
  858. struct ec_response_vbnvcontext {
  859. uint8_t block[EC_VBNV_BLOCK_SIZE];
  860. } __packed;
  861. /*****************************************************************************/
  862. /* PWM commands */
  863. /* Get fan target RPM */
  864. #define EC_CMD_PWM_GET_FAN_TARGET_RPM 0x20
  865. struct ec_response_pwm_get_fan_rpm {
  866. uint32_t rpm;
  867. } __packed;
  868. /* Set target fan RPM */
  869. #define EC_CMD_PWM_SET_FAN_TARGET_RPM 0x21
  870. struct ec_params_pwm_set_fan_target_rpm {
  871. uint32_t rpm;
  872. } __packed;
  873. /* Get keyboard backlight */
  874. #define EC_CMD_PWM_GET_KEYBOARD_BACKLIGHT 0x22
  875. struct ec_response_pwm_get_keyboard_backlight {
  876. uint8_t percent;
  877. uint8_t enabled;
  878. } __packed;
  879. /* Set keyboard backlight */
  880. #define EC_CMD_PWM_SET_KEYBOARD_BACKLIGHT 0x23
  881. struct ec_params_pwm_set_keyboard_backlight {
  882. uint8_t percent;
  883. } __packed;
  884. /* Set target fan PWM duty cycle */
  885. #define EC_CMD_PWM_SET_FAN_DUTY 0x24
  886. struct ec_params_pwm_set_fan_duty {
  887. uint32_t percent;
  888. } __packed;
  889. #define EC_CMD_PWM_SET_DUTY 0x25
  890. /* 16 bit duty cycle, 0xffff = 100% */
  891. #define EC_PWM_MAX_DUTY 0xffff
  892. enum ec_pwm_type {
  893. /* All types, indexed by board-specific enum pwm_channel */
  894. EC_PWM_TYPE_GENERIC = 0,
  895. /* Keyboard backlight */
  896. EC_PWM_TYPE_KB_LIGHT,
  897. /* Display backlight */
  898. EC_PWM_TYPE_DISPLAY_LIGHT,
  899. EC_PWM_TYPE_COUNT,
  900. };
  901. struct ec_params_pwm_set_duty {
  902. uint16_t duty; /* Duty cycle, EC_PWM_MAX_DUTY = 100% */
  903. uint8_t pwm_type; /* ec_pwm_type */
  904. uint8_t index; /* Type-specific index, or 0 if unique */
  905. } __packed;
  906. #define EC_CMD_PWM_GET_DUTY 0x26
  907. struct ec_params_pwm_get_duty {
  908. uint8_t pwm_type; /* ec_pwm_type */
  909. uint8_t index; /* Type-specific index, or 0 if unique */
  910. } __packed;
  911. struct ec_response_pwm_get_duty {
  912. uint16_t duty; /* Duty cycle, EC_PWM_MAX_DUTY = 100% */
  913. } __packed;
  914. /*****************************************************************************/
  915. /*
  916. * Lightbar commands. This looks worse than it is. Since we only use one HOST
  917. * command to say "talk to the lightbar", we put the "and tell it to do X" part
  918. * into a subcommand. We'll make separate structs for subcommands with
  919. * different input args, so that we know how much to expect.
  920. */
  921. #define EC_CMD_LIGHTBAR_CMD 0x28
  922. struct rgb_s {
  923. uint8_t r, g, b;
  924. };
  925. #define LB_BATTERY_LEVELS 4
  926. /* List of tweakable parameters. NOTE: It's __packed so it can be sent in a
  927. * host command, but the alignment is the same regardless. Keep it that way.
  928. */
  929. struct lightbar_params_v0 {
  930. /* Timing */
  931. int32_t google_ramp_up;
  932. int32_t google_ramp_down;
  933. int32_t s3s0_ramp_up;
  934. int32_t s0_tick_delay[2]; /* AC=0/1 */
  935. int32_t s0a_tick_delay[2]; /* AC=0/1 */
  936. int32_t s0s3_ramp_down;
  937. int32_t s3_sleep_for;
  938. int32_t s3_ramp_up;
  939. int32_t s3_ramp_down;
  940. /* Oscillation */
  941. uint8_t new_s0;
  942. uint8_t osc_min[2]; /* AC=0/1 */
  943. uint8_t osc_max[2]; /* AC=0/1 */
  944. uint8_t w_ofs[2]; /* AC=0/1 */
  945. /* Brightness limits based on the backlight and AC. */
  946. uint8_t bright_bl_off_fixed[2]; /* AC=0/1 */
  947. uint8_t bright_bl_on_min[2]; /* AC=0/1 */
  948. uint8_t bright_bl_on_max[2]; /* AC=0/1 */
  949. /* Battery level thresholds */
  950. uint8_t battery_threshold[LB_BATTERY_LEVELS - 1];
  951. /* Map [AC][battery_level] to color index */
  952. uint8_t s0_idx[2][LB_BATTERY_LEVELS]; /* AP is running */
  953. uint8_t s3_idx[2][LB_BATTERY_LEVELS]; /* AP is sleeping */
  954. /* Color palette */
  955. struct rgb_s color[8]; /* 0-3 are Google colors */
  956. } __packed;
  957. struct lightbar_params_v1 {
  958. /* Timing */
  959. int32_t google_ramp_up;
  960. int32_t google_ramp_down;
  961. int32_t s3s0_ramp_up;
  962. int32_t s0_tick_delay[2]; /* AC=0/1 */
  963. int32_t s0a_tick_delay[2]; /* AC=0/1 */
  964. int32_t s0s3_ramp_down;
  965. int32_t s3_sleep_for;
  966. int32_t s3_ramp_up;
  967. int32_t s3_ramp_down;
  968. int32_t tap_tick_delay;
  969. int32_t tap_display_time;
  970. /* Tap-for-battery params */
  971. uint8_t tap_pct_red;
  972. uint8_t tap_pct_green;
  973. uint8_t tap_seg_min_on;
  974. uint8_t tap_seg_max_on;
  975. uint8_t tap_seg_osc;
  976. uint8_t tap_idx[3];
  977. /* Oscillation */
  978. uint8_t osc_min[2]; /* AC=0/1 */
  979. uint8_t osc_max[2]; /* AC=0/1 */
  980. uint8_t w_ofs[2]; /* AC=0/1 */
  981. /* Brightness limits based on the backlight and AC. */
  982. uint8_t bright_bl_off_fixed[2]; /* AC=0/1 */
  983. uint8_t bright_bl_on_min[2]; /* AC=0/1 */
  984. uint8_t bright_bl_on_max[2]; /* AC=0/1 */
  985. /* Battery level thresholds */
  986. uint8_t battery_threshold[LB_BATTERY_LEVELS - 1];
  987. /* Map [AC][battery_level] to color index */
  988. uint8_t s0_idx[2][LB_BATTERY_LEVELS]; /* AP is running */
  989. uint8_t s3_idx[2][LB_BATTERY_LEVELS]; /* AP is sleeping */
  990. /* Color palette */
  991. struct rgb_s color[8]; /* 0-3 are Google colors */
  992. } __packed;
  993. struct ec_params_lightbar {
  994. uint8_t cmd; /* Command (see enum lightbar_command) */
  995. union {
  996. struct {
  997. /* no args */
  998. } dump, off, on, init, get_seq, get_params_v0, get_params_v1,
  999. version, get_brightness, get_demo;
  1000. struct {
  1001. uint8_t num;
  1002. } set_brightness, seq, demo;
  1003. struct {
  1004. uint8_t ctrl, reg, value;
  1005. } reg;
  1006. struct {
  1007. uint8_t led, red, green, blue;
  1008. } set_rgb;
  1009. struct {
  1010. uint8_t led;
  1011. } get_rgb;
  1012. struct lightbar_params_v0 set_params_v0;
  1013. struct lightbar_params_v1 set_params_v1;
  1014. };
  1015. } __packed;
  1016. struct ec_response_lightbar {
  1017. union {
  1018. struct {
  1019. struct {
  1020. uint8_t reg;
  1021. uint8_t ic0;
  1022. uint8_t ic1;
  1023. } vals[23];
  1024. } dump;
  1025. struct {
  1026. uint8_t num;
  1027. } get_seq, get_brightness, get_demo;
  1028. struct lightbar_params_v0 get_params_v0;
  1029. struct lightbar_params_v1 get_params_v1;
  1030. struct {
  1031. uint32_t num;
  1032. uint32_t flags;
  1033. } version;
  1034. struct {
  1035. uint8_t red, green, blue;
  1036. } get_rgb;
  1037. struct {
  1038. /* no return params */
  1039. } off, on, init, set_brightness, seq, reg, set_rgb,
  1040. demo, set_params_v0, set_params_v1;
  1041. };
  1042. } __packed;
  1043. /* Lightbar commands */
  1044. enum lightbar_command {
  1045. LIGHTBAR_CMD_DUMP = 0,
  1046. LIGHTBAR_CMD_OFF = 1,
  1047. LIGHTBAR_CMD_ON = 2,
  1048. LIGHTBAR_CMD_INIT = 3,
  1049. LIGHTBAR_CMD_SET_BRIGHTNESS = 4,
  1050. LIGHTBAR_CMD_SEQ = 5,
  1051. LIGHTBAR_CMD_REG = 6,
  1052. LIGHTBAR_CMD_SET_RGB = 7,
  1053. LIGHTBAR_CMD_GET_SEQ = 8,
  1054. LIGHTBAR_CMD_DEMO = 9,
  1055. LIGHTBAR_CMD_GET_PARAMS_V0 = 10,
  1056. LIGHTBAR_CMD_SET_PARAMS_V0 = 11,
  1057. LIGHTBAR_CMD_VERSION = 12,
  1058. LIGHTBAR_CMD_GET_BRIGHTNESS = 13,
  1059. LIGHTBAR_CMD_GET_RGB = 14,
  1060. LIGHTBAR_CMD_GET_DEMO = 15,
  1061. LIGHTBAR_CMD_GET_PARAMS_V1 = 16,
  1062. LIGHTBAR_CMD_SET_PARAMS_V1 = 17,
  1063. LIGHTBAR_NUM_CMDS
  1064. };
  1065. /*****************************************************************************/
  1066. /* LED control commands */
  1067. #define EC_CMD_LED_CONTROL 0x29
  1068. enum ec_led_id {
  1069. /* LED to indicate battery state of charge */
  1070. EC_LED_ID_BATTERY_LED = 0,
  1071. /*
  1072. * LED to indicate system power state (on or in suspend).
  1073. * May be on power button or on C-panel.
  1074. */
  1075. EC_LED_ID_POWER_LED,
  1076. /* LED on power adapter or its plug */
  1077. EC_LED_ID_ADAPTER_LED,
  1078. EC_LED_ID_COUNT
  1079. };
  1080. /* LED control flags */
  1081. #define EC_LED_FLAGS_QUERY (1 << 0) /* Query LED capability only */
  1082. #define EC_LED_FLAGS_AUTO (1 << 1) /* Switch LED back to automatic control */
  1083. enum ec_led_colors {
  1084. EC_LED_COLOR_RED = 0,
  1085. EC_LED_COLOR_GREEN,
  1086. EC_LED_COLOR_BLUE,
  1087. EC_LED_COLOR_YELLOW,
  1088. EC_LED_COLOR_WHITE,
  1089. EC_LED_COLOR_COUNT
  1090. };
  1091. struct ec_params_led_control {
  1092. uint8_t led_id; /* Which LED to control */
  1093. uint8_t flags; /* Control flags */
  1094. uint8_t brightness[EC_LED_COLOR_COUNT];
  1095. } __packed;
  1096. struct ec_response_led_control {
  1097. /*
  1098. * Available brightness value range.
  1099. *
  1100. * Range 0 means color channel not present.
  1101. * Range 1 means on/off control.
  1102. * Other values means the LED is control by PWM.
  1103. */
  1104. uint8_t brightness_range[EC_LED_COLOR_COUNT];
  1105. } __packed;
  1106. /*****************************************************************************/
  1107. /* Verified boot commands */
  1108. /*
  1109. * Note: command code 0x29 version 0 was VBOOT_CMD in Link EVT; it may be
  1110. * reused for other purposes with version > 0.
  1111. */
  1112. /* Verified boot hash command */
  1113. #define EC_CMD_VBOOT_HASH 0x2A
  1114. struct ec_params_vboot_hash {
  1115. uint8_t cmd; /* enum ec_vboot_hash_cmd */
  1116. uint8_t hash_type; /* enum ec_vboot_hash_type */
  1117. uint8_t nonce_size; /* Nonce size; may be 0 */
  1118. uint8_t reserved0; /* Reserved; set 0 */
  1119. uint32_t offset; /* Offset in flash to hash */
  1120. uint32_t size; /* Number of bytes to hash */
  1121. uint8_t nonce_data[64]; /* Nonce data; ignored if nonce_size=0 */
  1122. } __packed;
  1123. struct ec_response_vboot_hash {
  1124. uint8_t status; /* enum ec_vboot_hash_status */
  1125. uint8_t hash_type; /* enum ec_vboot_hash_type */
  1126. uint8_t digest_size; /* Size of hash digest in bytes */
  1127. uint8_t reserved0; /* Ignore; will be 0 */
  1128. uint32_t offset; /* Offset in flash which was hashed */
  1129. uint32_t size; /* Number of bytes hashed */
  1130. uint8_t hash_digest[64]; /* Hash digest data */
  1131. } __packed;
  1132. enum ec_vboot_hash_cmd {
  1133. EC_VBOOT_HASH_GET = 0, /* Get current hash status */
  1134. EC_VBOOT_HASH_ABORT = 1, /* Abort calculating current hash */
  1135. EC_VBOOT_HASH_START = 2, /* Start computing a new hash */
  1136. EC_VBOOT_HASH_RECALC = 3, /* Synchronously compute a new hash */
  1137. };
  1138. enum ec_vboot_hash_type {
  1139. EC_VBOOT_HASH_TYPE_SHA256 = 0, /* SHA-256 */
  1140. };
  1141. enum ec_vboot_hash_status {
  1142. EC_VBOOT_HASH_STATUS_NONE = 0, /* No hash (not started, or aborted) */
  1143. EC_VBOOT_HASH_STATUS_DONE = 1, /* Finished computing a hash */
  1144. EC_VBOOT_HASH_STATUS_BUSY = 2, /* Busy computing a hash */
  1145. };
  1146. /*
  1147. * Special values for offset for EC_VBOOT_HASH_START and EC_VBOOT_HASH_RECALC.
  1148. * If one of these is specified, the EC will automatically update offset and
  1149. * size to the correct values for the specified image (RO or RW).
  1150. */
  1151. #define EC_VBOOT_HASH_OFFSET_RO 0xfffffffe
  1152. #define EC_VBOOT_HASH_OFFSET_RW 0xfffffffd
  1153. /*****************************************************************************/
  1154. /*
  1155. * Motion sense commands. We'll make separate structs for sub-commands with
  1156. * different input args, so that we know how much to expect.
  1157. */
  1158. #define EC_CMD_MOTION_SENSE_CMD 0x2B
  1159. /* Motion sense commands */
  1160. enum motionsense_command {
  1161. /*
  1162. * Dump command returns all motion sensor data including motion sense
  1163. * module flags and individual sensor flags.
  1164. */
  1165. MOTIONSENSE_CMD_DUMP = 0,
  1166. /*
  1167. * Info command returns data describing the details of a given sensor,
  1168. * including enum motionsensor_type, enum motionsensor_location, and
  1169. * enum motionsensor_chip.
  1170. */
  1171. MOTIONSENSE_CMD_INFO = 1,
  1172. /*
  1173. * EC Rate command is a setter/getter command for the EC sampling rate
  1174. * of all motion sensors in milliseconds.
  1175. */
  1176. MOTIONSENSE_CMD_EC_RATE = 2,
  1177. /*
  1178. * Sensor ODR command is a setter/getter command for the output data
  1179. * rate of a specific motion sensor in millihertz.
  1180. */
  1181. MOTIONSENSE_CMD_SENSOR_ODR = 3,
  1182. /*
  1183. * Sensor range command is a setter/getter command for the range of
  1184. * a specified motion sensor in +/-G's or +/- deg/s.
  1185. */
  1186. MOTIONSENSE_CMD_SENSOR_RANGE = 4,
  1187. /*
  1188. * Setter/getter command for the keyboard wake angle. When the lid
  1189. * angle is greater than this value, keyboard wake is disabled in S3,
  1190. * and when the lid angle goes less than this value, keyboard wake is
  1191. * enabled. Note, the lid angle measurement is an approximate,
  1192. * un-calibrated value, hence the wake angle isn't exact.
  1193. */
  1194. MOTIONSENSE_CMD_KB_WAKE_ANGLE = 5,
  1195. /*
  1196. * Returns a single sensor data.
  1197. */
  1198. MOTIONSENSE_CMD_DATA = 6,
  1199. /*
  1200. * Perform low level calibration.. On sensors that support it, ask to
  1201. * do offset calibration.
  1202. */
  1203. MOTIONSENSE_CMD_PERFORM_CALIB = 10,
  1204. /*
  1205. * Sensor Offset command is a setter/getter command for the offset used
  1206. * for calibration. The offsets can be calculated by the host, or via
  1207. * PERFORM_CALIB command.
  1208. */
  1209. MOTIONSENSE_CMD_SENSOR_OFFSET = 11,
  1210. /* Number of motionsense sub-commands. */
  1211. MOTIONSENSE_NUM_CMDS
  1212. };
  1213. enum motionsensor_id {
  1214. EC_MOTION_SENSOR_ACCEL_BASE = 0,
  1215. EC_MOTION_SENSOR_ACCEL_LID = 1,
  1216. EC_MOTION_SENSOR_GYRO = 2,
  1217. /*
  1218. * Note, if more sensors are added and this count changes, the padding
  1219. * in ec_response_motion_sense dump command must be modified.
  1220. */
  1221. EC_MOTION_SENSOR_COUNT = 3
  1222. };
  1223. /* List of motion sensor types. */
  1224. enum motionsensor_type {
  1225. MOTIONSENSE_TYPE_ACCEL = 0,
  1226. MOTIONSENSE_TYPE_GYRO = 1,
  1227. MOTIONSENSE_TYPE_MAG = 2,
  1228. MOTIONSENSE_TYPE_PROX = 3,
  1229. MOTIONSENSE_TYPE_LIGHT = 4,
  1230. MOTIONSENSE_TYPE_ACTIVITY = 5,
  1231. MOTIONSENSE_TYPE_BARO = 6,
  1232. MOTIONSENSE_TYPE_MAX,
  1233. };
  1234. /* List of motion sensor locations. */
  1235. enum motionsensor_location {
  1236. MOTIONSENSE_LOC_BASE = 0,
  1237. MOTIONSENSE_LOC_LID = 1,
  1238. MOTIONSENSE_LOC_MAX,
  1239. };
  1240. /* List of motion sensor chips. */
  1241. enum motionsensor_chip {
  1242. MOTIONSENSE_CHIP_KXCJ9 = 0,
  1243. };
  1244. /* Module flag masks used for the dump sub-command. */
  1245. #define MOTIONSENSE_MODULE_FLAG_ACTIVE (1<<0)
  1246. /* Sensor flag masks used for the dump sub-command. */
  1247. #define MOTIONSENSE_SENSOR_FLAG_PRESENT (1<<0)
  1248. /*
  1249. * Send this value for the data element to only perform a read. If you
  1250. * send any other value, the EC will interpret it as data to set and will
  1251. * return the actual value set.
  1252. */
  1253. #define EC_MOTION_SENSE_NO_VALUE -1
  1254. #define EC_MOTION_SENSE_INVALID_CALIB_TEMP 0x8000
  1255. /* Set Calibration information */
  1256. #define MOTION_SENSE_SET_OFFSET 1
  1257. struct ec_response_motion_sensor_data {
  1258. /* Flags for each sensor. */
  1259. uint8_t flags;
  1260. /* Sensor number the data comes from */
  1261. uint8_t sensor_num;
  1262. /* Each sensor is up to 3-axis. */
  1263. union {
  1264. int16_t data[3];
  1265. struct {
  1266. uint16_t rsvd;
  1267. uint32_t timestamp;
  1268. } __packed;
  1269. struct {
  1270. uint8_t activity; /* motionsensor_activity */
  1271. uint8_t state;
  1272. int16_t add_info[2];
  1273. };
  1274. };
  1275. } __packed;
  1276. struct ec_params_motion_sense {
  1277. uint8_t cmd;
  1278. union {
  1279. /* Used for MOTIONSENSE_CMD_DUMP. */
  1280. struct {
  1281. /* no args */
  1282. } dump;
  1283. /*
  1284. * Used for MOTIONSENSE_CMD_EC_RATE and
  1285. * MOTIONSENSE_CMD_KB_WAKE_ANGLE.
  1286. */
  1287. struct {
  1288. /* Data to set or EC_MOTION_SENSE_NO_VALUE to read. */
  1289. int16_t data;
  1290. } ec_rate, kb_wake_angle;
  1291. /* Used for MOTIONSENSE_CMD_SENSOR_OFFSET */
  1292. struct {
  1293. uint8_t sensor_num;
  1294. /*
  1295. * bit 0: If set (MOTION_SENSE_SET_OFFSET), set
  1296. * the calibration information in the EC.
  1297. * If unset, just retrieve calibration information.
  1298. */
  1299. uint16_t flags;
  1300. /*
  1301. * Temperature at calibration, in units of 0.01 C
  1302. * 0x8000: invalid / unknown.
  1303. * 0x0: 0C
  1304. * 0x7fff: +327.67C
  1305. */
  1306. int16_t temp;
  1307. /*
  1308. * Offset for calibration.
  1309. * Unit:
  1310. * Accelerometer: 1/1024 g
  1311. * Gyro: 1/1024 deg/s
  1312. * Compass: 1/16 uT
  1313. */
  1314. int16_t offset[3];
  1315. } __packed sensor_offset;
  1316. /* Used for MOTIONSENSE_CMD_INFO. */
  1317. struct {
  1318. uint8_t sensor_num;
  1319. } info;
  1320. /*
  1321. * Used for MOTIONSENSE_CMD_SENSOR_ODR and
  1322. * MOTIONSENSE_CMD_SENSOR_RANGE.
  1323. */
  1324. struct {
  1325. /* Should be element of enum motionsensor_id. */
  1326. uint8_t sensor_num;
  1327. /* Rounding flag, true for round-up, false for down. */
  1328. uint8_t roundup;
  1329. uint16_t reserved;
  1330. /* Data to set or EC_MOTION_SENSE_NO_VALUE to read. */
  1331. int32_t data;
  1332. } sensor_odr, sensor_range;
  1333. };
  1334. } __packed;
  1335. struct ec_response_motion_sense {
  1336. union {
  1337. /* Used for MOTIONSENSE_CMD_DUMP. */
  1338. struct {
  1339. /* Flags representing the motion sensor module. */
  1340. uint8_t module_flags;
  1341. /* Number of sensors managed directly by the EC. */
  1342. uint8_t sensor_count;
  1343. /*
  1344. * Sensor data is truncated if response_max is too small
  1345. * for holding all the data.
  1346. */
  1347. struct ec_response_motion_sensor_data sensor[0];
  1348. } dump;
  1349. /* Used for MOTIONSENSE_CMD_INFO. */
  1350. struct {
  1351. /* Should be element of enum motionsensor_type. */
  1352. uint8_t type;
  1353. /* Should be element of enum motionsensor_location. */
  1354. uint8_t location;
  1355. /* Should be element of enum motionsensor_chip. */
  1356. uint8_t chip;
  1357. } info;
  1358. /* Used for MOTIONSENSE_CMD_DATA */
  1359. struct ec_response_motion_sensor_data data;
  1360. /*
  1361. * Used for MOTIONSENSE_CMD_EC_RATE, MOTIONSENSE_CMD_SENSOR_ODR,
  1362. * MOTIONSENSE_CMD_SENSOR_RANGE, and
  1363. * MOTIONSENSE_CMD_KB_WAKE_ANGLE.
  1364. */
  1365. struct {
  1366. /* Current value of the parameter queried. */
  1367. int32_t ret;
  1368. } ec_rate, sensor_odr, sensor_range, kb_wake_angle;
  1369. /* Used for MOTIONSENSE_CMD_SENSOR_OFFSET */
  1370. struct {
  1371. int16_t temp;
  1372. int16_t offset[3];
  1373. } sensor_offset, perform_calib;
  1374. };
  1375. } __packed;
  1376. /*****************************************************************************/
  1377. /* USB charging control commands */
  1378. /* Set USB port charging mode */
  1379. #define EC_CMD_USB_CHARGE_SET_MODE 0x30
  1380. struct ec_params_usb_charge_set_mode {
  1381. uint8_t usb_port_id;
  1382. uint8_t mode;
  1383. } __packed;
  1384. /*****************************************************************************/
  1385. /* Persistent storage for host */
  1386. /* Maximum bytes that can be read/written in a single command */
  1387. #define EC_PSTORE_SIZE_MAX 64
  1388. /* Get persistent storage info */
  1389. #define EC_CMD_PSTORE_INFO 0x40
  1390. struct ec_response_pstore_info {
  1391. /* Persistent storage size, in bytes */
  1392. uint32_t pstore_size;
  1393. /* Access size; read/write offset and size must be a multiple of this */
  1394. uint32_t access_size;
  1395. } __packed;
  1396. /*
  1397. * Read persistent storage
  1398. *
  1399. * Response is params.size bytes of data.
  1400. */
  1401. #define EC_CMD_PSTORE_READ 0x41
  1402. struct ec_params_pstore_read {
  1403. uint32_t offset; /* Byte offset to read */
  1404. uint32_t size; /* Size to read in bytes */
  1405. } __packed;
  1406. /* Write persistent storage */
  1407. #define EC_CMD_PSTORE_WRITE 0x42
  1408. struct ec_params_pstore_write {
  1409. uint32_t offset; /* Byte offset to write */
  1410. uint32_t size; /* Size to write in bytes */
  1411. uint8_t data[EC_PSTORE_SIZE_MAX];
  1412. } __packed;
  1413. /*****************************************************************************/
  1414. /* Real-time clock */
  1415. /* RTC params and response structures */
  1416. struct ec_params_rtc {
  1417. uint32_t time;
  1418. } __packed;
  1419. struct ec_response_rtc {
  1420. uint32_t time;
  1421. } __packed;
  1422. /* These use ec_response_rtc */
  1423. #define EC_CMD_RTC_GET_VALUE 0x44
  1424. #define EC_CMD_RTC_GET_ALARM 0x45
  1425. /* These all use ec_params_rtc */
  1426. #define EC_CMD_RTC_SET_VALUE 0x46
  1427. #define EC_CMD_RTC_SET_ALARM 0x47
  1428. /*****************************************************************************/
  1429. /* Port80 log access */
  1430. /* Maximum entries that can be read/written in a single command */
  1431. #define EC_PORT80_SIZE_MAX 32
  1432. /* Get last port80 code from previous boot */
  1433. #define EC_CMD_PORT80_LAST_BOOT 0x48
  1434. #define EC_CMD_PORT80_READ 0x48
  1435. enum ec_port80_subcmd {
  1436. EC_PORT80_GET_INFO = 0,
  1437. EC_PORT80_READ_BUFFER,
  1438. };
  1439. struct ec_params_port80_read {
  1440. uint16_t subcmd;
  1441. union {
  1442. struct {
  1443. uint32_t offset;
  1444. uint32_t num_entries;
  1445. } read_buffer;
  1446. };
  1447. } __packed;
  1448. struct ec_response_port80_read {
  1449. union {
  1450. struct {
  1451. uint32_t writes;
  1452. uint32_t history_size;
  1453. uint32_t last_boot;
  1454. } get_info;
  1455. struct {
  1456. uint16_t codes[EC_PORT80_SIZE_MAX];
  1457. } data;
  1458. };
  1459. } __packed;
  1460. struct ec_response_port80_last_boot {
  1461. uint16_t code;
  1462. } __packed;
  1463. /*****************************************************************************/
  1464. /* Thermal engine commands. Note that there are two implementations. We'll
  1465. * reuse the command number, but the data and behavior is incompatible.
  1466. * Version 0 is what originally shipped on Link.
  1467. * Version 1 separates the CPU thermal limits from the fan control.
  1468. */
  1469. #define EC_CMD_THERMAL_SET_THRESHOLD 0x50
  1470. #define EC_CMD_THERMAL_GET_THRESHOLD 0x51
  1471. /* The version 0 structs are opaque. You have to know what they are for
  1472. * the get/set commands to make any sense.
  1473. */
  1474. /* Version 0 - set */
  1475. struct ec_params_thermal_set_threshold {
  1476. uint8_t sensor_type;
  1477. uint8_t threshold_id;
  1478. uint16_t value;
  1479. } __packed;
  1480. /* Version 0 - get */
  1481. struct ec_params_thermal_get_threshold {
  1482. uint8_t sensor_type;
  1483. uint8_t threshold_id;
  1484. } __packed;
  1485. struct ec_response_thermal_get_threshold {
  1486. uint16_t value;
  1487. } __packed;
  1488. /* The version 1 structs are visible. */
  1489. enum ec_temp_thresholds {
  1490. EC_TEMP_THRESH_WARN = 0,
  1491. EC_TEMP_THRESH_HIGH,
  1492. EC_TEMP_THRESH_HALT,
  1493. EC_TEMP_THRESH_COUNT
  1494. };
  1495. /* Thermal configuration for one temperature sensor. Temps are in degrees K.
  1496. * Zero values will be silently ignored by the thermal task.
  1497. */
  1498. struct ec_thermal_config {
  1499. uint32_t temp_host[EC_TEMP_THRESH_COUNT]; /* levels of hotness */
  1500. uint32_t temp_fan_off; /* no active cooling needed */
  1501. uint32_t temp_fan_max; /* max active cooling needed */
  1502. } __packed;
  1503. /* Version 1 - get config for one sensor. */
  1504. struct ec_params_thermal_get_threshold_v1 {
  1505. uint32_t sensor_num;
  1506. } __packed;
  1507. /* This returns a struct ec_thermal_config */
  1508. /* Version 1 - set config for one sensor.
  1509. * Use read-modify-write for best results! */
  1510. struct ec_params_thermal_set_threshold_v1 {
  1511. uint32_t sensor_num;
  1512. struct ec_thermal_config cfg;
  1513. } __packed;
  1514. /* This returns no data */
  1515. /****************************************************************************/
  1516. /* Toggle automatic fan control */
  1517. #define EC_CMD_THERMAL_AUTO_FAN_CTRL 0x52
  1518. /* Get TMP006 calibration data */
  1519. #define EC_CMD_TMP006_GET_CALIBRATION 0x53
  1520. struct ec_params_tmp006_get_calibration {
  1521. uint8_t index;
  1522. } __packed;
  1523. struct ec_response_tmp006_get_calibration {
  1524. float s0;
  1525. float b0;
  1526. float b1;
  1527. float b2;
  1528. } __packed;
  1529. /* Set TMP006 calibration data */
  1530. #define EC_CMD_TMP006_SET_CALIBRATION 0x54
  1531. struct ec_params_tmp006_set_calibration {
  1532. uint8_t index;
  1533. uint8_t reserved[3]; /* Reserved; set 0 */
  1534. float s0;
  1535. float b0;
  1536. float b1;
  1537. float b2;
  1538. } __packed;
  1539. /* Read raw TMP006 data */
  1540. #define EC_CMD_TMP006_GET_RAW 0x55
  1541. struct ec_params_tmp006_get_raw {
  1542. uint8_t index;
  1543. } __packed;
  1544. struct ec_response_tmp006_get_raw {
  1545. int32_t t; /* In 1/100 K */
  1546. int32_t v; /* In nV */
  1547. };
  1548. /*****************************************************************************/
  1549. /* MKBP - Matrix KeyBoard Protocol */
  1550. /*
  1551. * Read key state
  1552. *
  1553. * Returns raw data for keyboard cols; see ec_response_mkbp_info.cols for
  1554. * expected response size.
  1555. *
  1556. * NOTE: This has been superseded by EC_CMD_MKBP_GET_NEXT_EVENT. If you wish
  1557. * to obtain the instantaneous state, use EC_CMD_MKBP_INFO with the type
  1558. * EC_MKBP_INFO_CURRENT and event EC_MKBP_EVENT_KEY_MATRIX.
  1559. */
  1560. #define EC_CMD_MKBP_STATE 0x60
  1561. /*
  1562. * Provide information about various MKBP things. See enum ec_mkbp_info_type.
  1563. */
  1564. #define EC_CMD_MKBP_INFO 0x61
  1565. struct ec_response_mkbp_info {
  1566. uint32_t rows;
  1567. uint32_t cols;
  1568. /* Formerly "switches", which was 0. */
  1569. uint8_t reserved;
  1570. } __packed;
  1571. struct ec_params_mkbp_info {
  1572. uint8_t info_type;
  1573. uint8_t event_type;
  1574. } __packed;
  1575. enum ec_mkbp_info_type {
  1576. /*
  1577. * Info about the keyboard matrix: number of rows and columns.
  1578. *
  1579. * Returns struct ec_response_mkbp_info.
  1580. */
  1581. EC_MKBP_INFO_KBD = 0,
  1582. /*
  1583. * For buttons and switches, info about which specifically are
  1584. * supported. event_type must be set to one of the values in enum
  1585. * ec_mkbp_event.
  1586. *
  1587. * For EC_MKBP_EVENT_BUTTON and EC_MKBP_EVENT_SWITCH, returns a 4 byte
  1588. * bitmask indicating which buttons or switches are present. See the
  1589. * bit inidices below.
  1590. */
  1591. EC_MKBP_INFO_SUPPORTED = 1,
  1592. /*
  1593. * Instantaneous state of buttons and switches.
  1594. *
  1595. * event_type must be set to one of the values in enum ec_mkbp_event.
  1596. *
  1597. * For EC_MKBP_EVENT_KEY_MATRIX, returns uint8_t key_matrix[13]
  1598. * indicating the current state of the keyboard matrix.
  1599. *
  1600. * For EC_MKBP_EVENT_HOST_EVENT, return uint32_t host_event, the raw
  1601. * event state.
  1602. *
  1603. * For EC_MKBP_EVENT_BUTTON, returns uint32_t buttons, indicating the
  1604. * state of supported buttons.
  1605. *
  1606. * For EC_MKBP_EVENT_SWITCH, returns uint32_t switches, indicating the
  1607. * state of supported switches.
  1608. */
  1609. EC_MKBP_INFO_CURRENT = 2,
  1610. };
  1611. /* Simulate key press */
  1612. #define EC_CMD_MKBP_SIMULATE_KEY 0x62
  1613. struct ec_params_mkbp_simulate_key {
  1614. uint8_t col;
  1615. uint8_t row;
  1616. uint8_t pressed;
  1617. } __packed;
  1618. /* Configure keyboard scanning */
  1619. #define EC_CMD_MKBP_SET_CONFIG 0x64
  1620. #define EC_CMD_MKBP_GET_CONFIG 0x65
  1621. /* flags */
  1622. enum mkbp_config_flags {
  1623. EC_MKBP_FLAGS_ENABLE = 1, /* Enable keyboard scanning */
  1624. };
  1625. enum mkbp_config_valid {
  1626. EC_MKBP_VALID_SCAN_PERIOD = 1 << 0,
  1627. EC_MKBP_VALID_POLL_TIMEOUT = 1 << 1,
  1628. EC_MKBP_VALID_MIN_POST_SCAN_DELAY = 1 << 3,
  1629. EC_MKBP_VALID_OUTPUT_SETTLE = 1 << 4,
  1630. EC_MKBP_VALID_DEBOUNCE_DOWN = 1 << 5,
  1631. EC_MKBP_VALID_DEBOUNCE_UP = 1 << 6,
  1632. EC_MKBP_VALID_FIFO_MAX_DEPTH = 1 << 7,
  1633. };
  1634. /* Configuration for our key scanning algorithm */
  1635. struct ec_mkbp_config {
  1636. uint32_t valid_mask; /* valid fields */
  1637. uint8_t flags; /* some flags (enum mkbp_config_flags) */
  1638. uint8_t valid_flags; /* which flags are valid */
  1639. uint16_t scan_period_us; /* period between start of scans */
  1640. /* revert to interrupt mode after no activity for this long */
  1641. uint32_t poll_timeout_us;
  1642. /*
  1643. * minimum post-scan relax time. Once we finish a scan we check
  1644. * the time until we are due to start the next one. If this time is
  1645. * shorter this field, we use this instead.
  1646. */
  1647. uint16_t min_post_scan_delay_us;
  1648. /* delay between setting up output and waiting for it to settle */
  1649. uint16_t output_settle_us;
  1650. uint16_t debounce_down_us; /* time for debounce on key down */
  1651. uint16_t debounce_up_us; /* time for debounce on key up */
  1652. /* maximum depth to allow for fifo (0 = no keyscan output) */
  1653. uint8_t fifo_max_depth;
  1654. } __packed;
  1655. struct ec_params_mkbp_set_config {
  1656. struct ec_mkbp_config config;
  1657. } __packed;
  1658. struct ec_response_mkbp_get_config {
  1659. struct ec_mkbp_config config;
  1660. } __packed;
  1661. /* Run the key scan emulation */
  1662. #define EC_CMD_KEYSCAN_SEQ_CTRL 0x66
  1663. enum ec_keyscan_seq_cmd {
  1664. EC_KEYSCAN_SEQ_STATUS = 0, /* Get status information */
  1665. EC_KEYSCAN_SEQ_CLEAR = 1, /* Clear sequence */
  1666. EC_KEYSCAN_SEQ_ADD = 2, /* Add item to sequence */
  1667. EC_KEYSCAN_SEQ_START = 3, /* Start running sequence */
  1668. EC_KEYSCAN_SEQ_COLLECT = 4, /* Collect sequence summary data */
  1669. };
  1670. enum ec_collect_flags {
  1671. /*
  1672. * Indicates this scan was processed by the EC. Due to timing, some
  1673. * scans may be skipped.
  1674. */
  1675. EC_KEYSCAN_SEQ_FLAG_DONE = 1 << 0,
  1676. };
  1677. struct ec_collect_item {
  1678. uint8_t flags; /* some flags (enum ec_collect_flags) */
  1679. };
  1680. struct ec_params_keyscan_seq_ctrl {
  1681. uint8_t cmd; /* Command to send (enum ec_keyscan_seq_cmd) */
  1682. union {
  1683. struct {
  1684. uint8_t active; /* still active */
  1685. uint8_t num_items; /* number of items */
  1686. /* Current item being presented */
  1687. uint8_t cur_item;
  1688. } status;
  1689. struct {
  1690. /*
  1691. * Absolute time for this scan, measured from the
  1692. * start of the sequence.
  1693. */
  1694. uint32_t time_us;
  1695. uint8_t scan[0]; /* keyscan data */
  1696. } add;
  1697. struct {
  1698. uint8_t start_item; /* First item to return */
  1699. uint8_t num_items; /* Number of items to return */
  1700. } collect;
  1701. };
  1702. } __packed;
  1703. struct ec_result_keyscan_seq_ctrl {
  1704. union {
  1705. struct {
  1706. uint8_t num_items; /* Number of items */
  1707. /* Data for each item */
  1708. struct ec_collect_item item[0];
  1709. } collect;
  1710. };
  1711. } __packed;
  1712. /*
  1713. * Command for retrieving the next pending MKBP event from the EC device
  1714. *
  1715. * The device replies with UNAVAILABLE if there aren't any pending events.
  1716. */
  1717. #define EC_CMD_GET_NEXT_EVENT 0x67
  1718. enum ec_mkbp_event {
  1719. /* Keyboard matrix changed. The event data is the new matrix state. */
  1720. EC_MKBP_EVENT_KEY_MATRIX = 0,
  1721. /* New host event. The event data is 4 bytes of host event flags. */
  1722. EC_MKBP_EVENT_HOST_EVENT = 1,
  1723. /* New Sensor FIFO data. The event data is fifo_info structure. */
  1724. EC_MKBP_EVENT_SENSOR_FIFO = 2,
  1725. /* The state of the non-matrixed buttons have changed. */
  1726. EC_MKBP_EVENT_BUTTON = 3,
  1727. /* The state of the switches have changed. */
  1728. EC_MKBP_EVENT_SWITCH = 4,
  1729. /* Number of MKBP events */
  1730. EC_MKBP_EVENT_COUNT,
  1731. };
  1732. union ec_response_get_next_data {
  1733. uint8_t key_matrix[13];
  1734. /* Unaligned */
  1735. uint32_t host_event;
  1736. uint32_t buttons;
  1737. uint32_t switches;
  1738. } __packed;
  1739. struct ec_response_get_next_event {
  1740. uint8_t event_type;
  1741. /* Followed by event data if any */
  1742. union ec_response_get_next_data data;
  1743. } __packed;
  1744. /* Bit indices for buttons and switches.*/
  1745. /* Buttons */
  1746. #define EC_MKBP_POWER_BUTTON 0
  1747. #define EC_MKBP_VOL_UP 1
  1748. #define EC_MKBP_VOL_DOWN 2
  1749. /* Switches */
  1750. #define EC_MKBP_LID_OPEN 0
  1751. #define EC_MKBP_TABLET_MODE 1
  1752. /*****************************************************************************/
  1753. /* Temperature sensor commands */
  1754. /* Read temperature sensor info */
  1755. #define EC_CMD_TEMP_SENSOR_GET_INFO 0x70
  1756. struct ec_params_temp_sensor_get_info {
  1757. uint8_t id;
  1758. } __packed;
  1759. struct ec_response_temp_sensor_get_info {
  1760. char sensor_name[32];
  1761. uint8_t sensor_type;
  1762. } __packed;
  1763. /*****************************************************************************/
  1764. /*
  1765. * Note: host commands 0x80 - 0x87 are reserved to avoid conflict with ACPI
  1766. * commands accidentally sent to the wrong interface. See the ACPI section
  1767. * below.
  1768. */
  1769. /*****************************************************************************/
  1770. /* Host event commands */
  1771. /*
  1772. * Host event mask params and response structures, shared by all of the host
  1773. * event commands below.
  1774. */
  1775. struct ec_params_host_event_mask {
  1776. uint32_t mask;
  1777. } __packed;
  1778. struct ec_response_host_event_mask {
  1779. uint32_t mask;
  1780. } __packed;
  1781. /* These all use ec_response_host_event_mask */
  1782. #define EC_CMD_HOST_EVENT_GET_B 0x87
  1783. #define EC_CMD_HOST_EVENT_GET_SMI_MASK 0x88
  1784. #define EC_CMD_HOST_EVENT_GET_SCI_MASK 0x89
  1785. #define EC_CMD_HOST_EVENT_GET_WAKE_MASK 0x8d
  1786. /* These all use ec_params_host_event_mask */
  1787. #define EC_CMD_HOST_EVENT_SET_SMI_MASK 0x8a
  1788. #define EC_CMD_HOST_EVENT_SET_SCI_MASK 0x8b
  1789. #define EC_CMD_HOST_EVENT_CLEAR 0x8c
  1790. #define EC_CMD_HOST_EVENT_SET_WAKE_MASK 0x8e
  1791. #define EC_CMD_HOST_EVENT_CLEAR_B 0x8f
  1792. /*****************************************************************************/
  1793. /* Switch commands */
  1794. /* Enable/disable LCD backlight */
  1795. #define EC_CMD_SWITCH_ENABLE_BKLIGHT 0x90
  1796. struct ec_params_switch_enable_backlight {
  1797. uint8_t enabled;
  1798. } __packed;
  1799. /* Enable/disable WLAN/Bluetooth */
  1800. #define EC_CMD_SWITCH_ENABLE_WIRELESS 0x91
  1801. #define EC_VER_SWITCH_ENABLE_WIRELESS 1
  1802. /* Version 0 params; no response */
  1803. struct ec_params_switch_enable_wireless_v0 {
  1804. uint8_t enabled;
  1805. } __packed;
  1806. /* Version 1 params */
  1807. struct ec_params_switch_enable_wireless_v1 {
  1808. /* Flags to enable now */
  1809. uint8_t now_flags;
  1810. /* Which flags to copy from now_flags */
  1811. uint8_t now_mask;
  1812. /*
  1813. * Flags to leave enabled in S3, if they're on at the S0->S3
  1814. * transition. (Other flags will be disabled by the S0->S3
  1815. * transition.)
  1816. */
  1817. uint8_t suspend_flags;
  1818. /* Which flags to copy from suspend_flags */
  1819. uint8_t suspend_mask;
  1820. } __packed;
  1821. /* Version 1 response */
  1822. struct ec_response_switch_enable_wireless_v1 {
  1823. /* Flags to enable now */
  1824. uint8_t now_flags;
  1825. /* Flags to leave enabled in S3 */
  1826. uint8_t suspend_flags;
  1827. } __packed;
  1828. /*****************************************************************************/
  1829. /* GPIO commands. Only available on EC if write protect has been disabled. */
  1830. /* Set GPIO output value */
  1831. #define EC_CMD_GPIO_SET 0x92
  1832. struct ec_params_gpio_set {
  1833. char name[32];
  1834. uint8_t val;
  1835. } __packed;
  1836. /* Get GPIO value */
  1837. #define EC_CMD_GPIO_GET 0x93
  1838. /* Version 0 of input params and response */
  1839. struct ec_params_gpio_get {
  1840. char name[32];
  1841. } __packed;
  1842. struct ec_response_gpio_get {
  1843. uint8_t val;
  1844. } __packed;
  1845. /* Version 1 of input params and response */
  1846. struct ec_params_gpio_get_v1 {
  1847. uint8_t subcmd;
  1848. union {
  1849. struct {
  1850. char name[32];
  1851. } get_value_by_name;
  1852. struct {
  1853. uint8_t index;
  1854. } get_info;
  1855. };
  1856. } __packed;
  1857. struct ec_response_gpio_get_v1 {
  1858. union {
  1859. struct {
  1860. uint8_t val;
  1861. } get_value_by_name, get_count;
  1862. struct {
  1863. uint8_t val;
  1864. char name[32];
  1865. uint32_t flags;
  1866. } get_info;
  1867. };
  1868. } __packed;
  1869. enum gpio_get_subcmd {
  1870. EC_GPIO_GET_BY_NAME = 0,
  1871. EC_GPIO_GET_COUNT = 1,
  1872. EC_GPIO_GET_INFO = 2,
  1873. };
  1874. /*****************************************************************************/
  1875. /* I2C commands. Only available when flash write protect is unlocked. */
  1876. /*
  1877. * TODO(crosbug.com/p/23570): These commands are deprecated, and will be
  1878. * removed soon. Use EC_CMD_I2C_XFER instead.
  1879. */
  1880. /* Read I2C bus */
  1881. #define EC_CMD_I2C_READ 0x94
  1882. struct ec_params_i2c_read {
  1883. uint16_t addr; /* 8-bit address (7-bit shifted << 1) */
  1884. uint8_t read_size; /* Either 8 or 16. */
  1885. uint8_t port;
  1886. uint8_t offset;
  1887. } __packed;
  1888. struct ec_response_i2c_read {
  1889. uint16_t data;
  1890. } __packed;
  1891. /* Write I2C bus */
  1892. #define EC_CMD_I2C_WRITE 0x95
  1893. struct ec_params_i2c_write {
  1894. uint16_t data;
  1895. uint16_t addr; /* 8-bit address (7-bit shifted << 1) */
  1896. uint8_t write_size; /* Either 8 or 16. */
  1897. uint8_t port;
  1898. uint8_t offset;
  1899. } __packed;
  1900. /*****************************************************************************/
  1901. /* Charge state commands. Only available when flash write protect unlocked. */
  1902. /* Force charge state machine to stop charging the battery or force it to
  1903. * discharge the battery.
  1904. */
  1905. #define EC_CMD_CHARGE_CONTROL 0x96
  1906. #define EC_VER_CHARGE_CONTROL 1
  1907. enum ec_charge_control_mode {
  1908. CHARGE_CONTROL_NORMAL = 0,
  1909. CHARGE_CONTROL_IDLE,
  1910. CHARGE_CONTROL_DISCHARGE,
  1911. };
  1912. struct ec_params_charge_control {
  1913. uint32_t mode; /* enum charge_control_mode */
  1914. } __packed;
  1915. /*****************************************************************************/
  1916. /* Console commands. Only available when flash write protect is unlocked. */
  1917. /* Snapshot console output buffer for use by EC_CMD_CONSOLE_READ. */
  1918. #define EC_CMD_CONSOLE_SNAPSHOT 0x97
  1919. /*
  1920. * Read next chunk of data from saved snapshot.
  1921. *
  1922. * Response is null-terminated string. Empty string, if there is no more
  1923. * remaining output.
  1924. */
  1925. #define EC_CMD_CONSOLE_READ 0x98
  1926. /*****************************************************************************/
  1927. /*
  1928. * Cut off battery power immediately or after the host has shut down.
  1929. *
  1930. * return EC_RES_INVALID_COMMAND if unsupported by a board/battery.
  1931. * EC_RES_SUCCESS if the command was successful.
  1932. * EC_RES_ERROR if the cut off command failed.
  1933. */
  1934. #define EC_CMD_BATTERY_CUT_OFF 0x99
  1935. #define EC_BATTERY_CUTOFF_FLAG_AT_SHUTDOWN (1 << 0)
  1936. struct ec_params_battery_cutoff {
  1937. uint8_t flags;
  1938. } __packed;
  1939. /*****************************************************************************/
  1940. /* USB port mux control. */
  1941. /*
  1942. * Switch USB mux or return to automatic switching.
  1943. */
  1944. #define EC_CMD_USB_MUX 0x9a
  1945. struct ec_params_usb_mux {
  1946. uint8_t mux;
  1947. } __packed;
  1948. /*****************************************************************************/
  1949. /* LDOs / FETs control. */
  1950. enum ec_ldo_state {
  1951. EC_LDO_STATE_OFF = 0, /* the LDO / FET is shut down */
  1952. EC_LDO_STATE_ON = 1, /* the LDO / FET is ON / providing power */
  1953. };
  1954. /*
  1955. * Switch on/off a LDO.
  1956. */
  1957. #define EC_CMD_LDO_SET 0x9b
  1958. struct ec_params_ldo_set {
  1959. uint8_t index;
  1960. uint8_t state;
  1961. } __packed;
  1962. /*
  1963. * Get LDO state.
  1964. */
  1965. #define EC_CMD_LDO_GET 0x9c
  1966. struct ec_params_ldo_get {
  1967. uint8_t index;
  1968. } __packed;
  1969. struct ec_response_ldo_get {
  1970. uint8_t state;
  1971. } __packed;
  1972. /*****************************************************************************/
  1973. /* Power info. */
  1974. /*
  1975. * Get power info.
  1976. */
  1977. #define EC_CMD_POWER_INFO 0x9d
  1978. struct ec_response_power_info {
  1979. uint32_t usb_dev_type;
  1980. uint16_t voltage_ac;
  1981. uint16_t voltage_system;
  1982. uint16_t current_system;
  1983. uint16_t usb_current_limit;
  1984. } __packed;
  1985. /*****************************************************************************/
  1986. /* I2C passthru command */
  1987. #define EC_CMD_I2C_PASSTHRU 0x9e
  1988. /* Read data; if not present, message is a write */
  1989. #define EC_I2C_FLAG_READ (1 << 15)
  1990. /* Mask for address */
  1991. #define EC_I2C_ADDR_MASK 0x3ff
  1992. #define EC_I2C_STATUS_NAK (1 << 0) /* Transfer was not acknowledged */
  1993. #define EC_I2C_STATUS_TIMEOUT (1 << 1) /* Timeout during transfer */
  1994. /* Any error */
  1995. #define EC_I2C_STATUS_ERROR (EC_I2C_STATUS_NAK | EC_I2C_STATUS_TIMEOUT)
  1996. struct ec_params_i2c_passthru_msg {
  1997. uint16_t addr_flags; /* I2C slave address (7 or 10 bits) and flags */
  1998. uint16_t len; /* Number of bytes to read or write */
  1999. } __packed;
  2000. struct ec_params_i2c_passthru {
  2001. uint8_t port; /* I2C port number */
  2002. uint8_t num_msgs; /* Number of messages */
  2003. struct ec_params_i2c_passthru_msg msg[];
  2004. /* Data to write for all messages is concatenated here */
  2005. } __packed;
  2006. struct ec_response_i2c_passthru {
  2007. uint8_t i2c_status; /* Status flags (EC_I2C_STATUS_...) */
  2008. uint8_t num_msgs; /* Number of messages processed */
  2009. uint8_t data[]; /* Data read by messages concatenated here */
  2010. } __packed;
  2011. /*****************************************************************************/
  2012. /* Power button hang detect */
  2013. #define EC_CMD_HANG_DETECT 0x9f
  2014. /* Reasons to start hang detection timer */
  2015. /* Power button pressed */
  2016. #define EC_HANG_START_ON_POWER_PRESS (1 << 0)
  2017. /* Lid closed */
  2018. #define EC_HANG_START_ON_LID_CLOSE (1 << 1)
  2019. /* Lid opened */
  2020. #define EC_HANG_START_ON_LID_OPEN (1 << 2)
  2021. /* Start of AP S3->S0 transition (booting or resuming from suspend) */
  2022. #define EC_HANG_START_ON_RESUME (1 << 3)
  2023. /* Reasons to cancel hang detection */
  2024. /* Power button released */
  2025. #define EC_HANG_STOP_ON_POWER_RELEASE (1 << 8)
  2026. /* Any host command from AP received */
  2027. #define EC_HANG_STOP_ON_HOST_COMMAND (1 << 9)
  2028. /* Stop on end of AP S0->S3 transition (suspending or shutting down) */
  2029. #define EC_HANG_STOP_ON_SUSPEND (1 << 10)
  2030. /*
  2031. * If this flag is set, all the other fields are ignored, and the hang detect
  2032. * timer is started. This provides the AP a way to start the hang timer
  2033. * without reconfiguring any of the other hang detect settings. Note that
  2034. * you must previously have configured the timeouts.
  2035. */
  2036. #define EC_HANG_START_NOW (1 << 30)
  2037. /*
  2038. * If this flag is set, all the other fields are ignored (including
  2039. * EC_HANG_START_NOW). This provides the AP a way to stop the hang timer
  2040. * without reconfiguring any of the other hang detect settings.
  2041. */
  2042. #define EC_HANG_STOP_NOW (1 << 31)
  2043. struct ec_params_hang_detect {
  2044. /* Flags; see EC_HANG_* */
  2045. uint32_t flags;
  2046. /* Timeout in msec before generating host event, if enabled */
  2047. uint16_t host_event_timeout_msec;
  2048. /* Timeout in msec before generating warm reboot, if enabled */
  2049. uint16_t warm_reboot_timeout_msec;
  2050. } __packed;
  2051. /*****************************************************************************/
  2052. /* Commands for battery charging */
  2053. /*
  2054. * This is the single catch-all host command to exchange data regarding the
  2055. * charge state machine (v2 and up).
  2056. */
  2057. #define EC_CMD_CHARGE_STATE 0xa0
  2058. /* Subcommands for this host command */
  2059. enum charge_state_command {
  2060. CHARGE_STATE_CMD_GET_STATE,
  2061. CHARGE_STATE_CMD_GET_PARAM,
  2062. CHARGE_STATE_CMD_SET_PARAM,
  2063. CHARGE_STATE_NUM_CMDS
  2064. };
  2065. /*
  2066. * Known param numbers are defined here. Ranges are reserved for board-specific
  2067. * params, which are handled by the particular implementations.
  2068. */
  2069. enum charge_state_params {
  2070. CS_PARAM_CHG_VOLTAGE, /* charger voltage limit */
  2071. CS_PARAM_CHG_CURRENT, /* charger current limit */
  2072. CS_PARAM_CHG_INPUT_CURRENT, /* charger input current limit */
  2073. CS_PARAM_CHG_STATUS, /* charger-specific status */
  2074. CS_PARAM_CHG_OPTION, /* charger-specific options */
  2075. /* How many so far? */
  2076. CS_NUM_BASE_PARAMS,
  2077. /* Range for CONFIG_CHARGER_PROFILE_OVERRIDE params */
  2078. CS_PARAM_CUSTOM_PROFILE_MIN = 0x10000,
  2079. CS_PARAM_CUSTOM_PROFILE_MAX = 0x1ffff,
  2080. /* Other custom param ranges go here... */
  2081. };
  2082. struct ec_params_charge_state {
  2083. uint8_t cmd; /* enum charge_state_command */
  2084. union {
  2085. struct {
  2086. /* no args */
  2087. } get_state;
  2088. struct {
  2089. uint32_t param; /* enum charge_state_param */
  2090. } get_param;
  2091. struct {
  2092. uint32_t param; /* param to set */
  2093. uint32_t value; /* value to set */
  2094. } set_param;
  2095. };
  2096. } __packed;
  2097. struct ec_response_charge_state {
  2098. union {
  2099. struct {
  2100. int ac;
  2101. int chg_voltage;
  2102. int chg_current;
  2103. int chg_input_current;
  2104. int batt_state_of_charge;
  2105. } get_state;
  2106. struct {
  2107. uint32_t value;
  2108. } get_param;
  2109. struct {
  2110. /* no return values */
  2111. } set_param;
  2112. };
  2113. } __packed;
  2114. /*
  2115. * Set maximum battery charging current.
  2116. */
  2117. #define EC_CMD_CHARGE_CURRENT_LIMIT 0xa1
  2118. struct ec_params_current_limit {
  2119. uint32_t limit; /* in mA */
  2120. } __packed;
  2121. /*
  2122. * Set maximum external power current.
  2123. */
  2124. #define EC_CMD_EXT_POWER_CURRENT_LIMIT 0xa2
  2125. struct ec_params_ext_power_current_limit {
  2126. uint32_t limit; /* in mA */
  2127. } __packed;
  2128. /* Inform the EC when entering a sleep state */
  2129. #define EC_CMD_HOST_SLEEP_EVENT 0xa9
  2130. enum host_sleep_event {
  2131. HOST_SLEEP_EVENT_S3_SUSPEND = 1,
  2132. HOST_SLEEP_EVENT_S3_RESUME = 2,
  2133. HOST_SLEEP_EVENT_S0IX_SUSPEND = 3,
  2134. HOST_SLEEP_EVENT_S0IX_RESUME = 4
  2135. };
  2136. struct ec_params_host_sleep_event {
  2137. uint8_t sleep_event;
  2138. } __packed;
  2139. /*****************************************************************************/
  2140. /* Smart battery pass-through */
  2141. /* Get / Set 16-bit smart battery registers */
  2142. #define EC_CMD_SB_READ_WORD 0xb0
  2143. #define EC_CMD_SB_WRITE_WORD 0xb1
  2144. /* Get / Set string smart battery parameters
  2145. * formatted as SMBUS "block".
  2146. */
  2147. #define EC_CMD_SB_READ_BLOCK 0xb2
  2148. #define EC_CMD_SB_WRITE_BLOCK 0xb3
  2149. struct ec_params_sb_rd {
  2150. uint8_t reg;
  2151. } __packed;
  2152. struct ec_response_sb_rd_word {
  2153. uint16_t value;
  2154. } __packed;
  2155. struct ec_params_sb_wr_word {
  2156. uint8_t reg;
  2157. uint16_t value;
  2158. } __packed;
  2159. struct ec_response_sb_rd_block {
  2160. uint8_t data[32];
  2161. } __packed;
  2162. struct ec_params_sb_wr_block {
  2163. uint8_t reg;
  2164. uint16_t data[32];
  2165. } __packed;
  2166. /*****************************************************************************/
  2167. /* Battery vendor parameters
  2168. *
  2169. * Get or set vendor-specific parameters in the battery. Implementations may
  2170. * differ between boards or batteries. On a set operation, the response
  2171. * contains the actual value set, which may be rounded or clipped from the
  2172. * requested value.
  2173. */
  2174. #define EC_CMD_BATTERY_VENDOR_PARAM 0xb4
  2175. enum ec_battery_vendor_param_mode {
  2176. BATTERY_VENDOR_PARAM_MODE_GET = 0,
  2177. BATTERY_VENDOR_PARAM_MODE_SET,
  2178. };
  2179. struct ec_params_battery_vendor_param {
  2180. uint32_t param;
  2181. uint32_t value;
  2182. uint8_t mode;
  2183. } __packed;
  2184. struct ec_response_battery_vendor_param {
  2185. uint32_t value;
  2186. } __packed;
  2187. /*****************************************************************************/
  2188. /* System commands */
  2189. /*
  2190. * TODO(crosbug.com/p/23747): This is a confusing name, since it doesn't
  2191. * necessarily reboot the EC. Rename to "image" or something similar?
  2192. */
  2193. #define EC_CMD_REBOOT_EC 0xd2
  2194. /* Command */
  2195. enum ec_reboot_cmd {
  2196. EC_REBOOT_CANCEL = 0, /* Cancel a pending reboot */
  2197. EC_REBOOT_JUMP_RO = 1, /* Jump to RO without rebooting */
  2198. EC_REBOOT_JUMP_RW = 2, /* Jump to RW without rebooting */
  2199. /* (command 3 was jump to RW-B) */
  2200. EC_REBOOT_COLD = 4, /* Cold-reboot */
  2201. EC_REBOOT_DISABLE_JUMP = 5, /* Disable jump until next reboot */
  2202. EC_REBOOT_HIBERNATE = 6 /* Hibernate EC */
  2203. };
  2204. /* Flags for ec_params_reboot_ec.reboot_flags */
  2205. #define EC_REBOOT_FLAG_RESERVED0 (1 << 0) /* Was recovery request */
  2206. #define EC_REBOOT_FLAG_ON_AP_SHUTDOWN (1 << 1) /* Reboot after AP shutdown */
  2207. struct ec_params_reboot_ec {
  2208. uint8_t cmd; /* enum ec_reboot_cmd */
  2209. uint8_t flags; /* See EC_REBOOT_FLAG_* */
  2210. } __packed;
  2211. /*
  2212. * Get information on last EC panic.
  2213. *
  2214. * Returns variable-length platform-dependent panic information. See panic.h
  2215. * for details.
  2216. */
  2217. #define EC_CMD_GET_PANIC_INFO 0xd3
  2218. /*****************************************************************************/
  2219. /*
  2220. * ACPI commands
  2221. *
  2222. * These are valid ONLY on the ACPI command/data port.
  2223. */
  2224. /*
  2225. * ACPI Read Embedded Controller
  2226. *
  2227. * This reads from ACPI memory space on the EC (EC_ACPI_MEM_*).
  2228. *
  2229. * Use the following sequence:
  2230. *
  2231. * - Write EC_CMD_ACPI_READ to EC_LPC_ADDR_ACPI_CMD
  2232. * - Wait for EC_LPC_CMDR_PENDING bit to clear
  2233. * - Write address to EC_LPC_ADDR_ACPI_DATA
  2234. * - Wait for EC_LPC_CMDR_DATA bit to set
  2235. * - Read value from EC_LPC_ADDR_ACPI_DATA
  2236. */
  2237. #define EC_CMD_ACPI_READ 0x80
  2238. /*
  2239. * ACPI Write Embedded Controller
  2240. *
  2241. * This reads from ACPI memory space on the EC (EC_ACPI_MEM_*).
  2242. *
  2243. * Use the following sequence:
  2244. *
  2245. * - Write EC_CMD_ACPI_WRITE to EC_LPC_ADDR_ACPI_CMD
  2246. * - Wait for EC_LPC_CMDR_PENDING bit to clear
  2247. * - Write address to EC_LPC_ADDR_ACPI_DATA
  2248. * - Wait for EC_LPC_CMDR_PENDING bit to clear
  2249. * - Write value to EC_LPC_ADDR_ACPI_DATA
  2250. */
  2251. #define EC_CMD_ACPI_WRITE 0x81
  2252. /*
  2253. * ACPI Query Embedded Controller
  2254. *
  2255. * This clears the lowest-order bit in the currently pending host events, and
  2256. * sets the result code to the 1-based index of the bit (event 0x00000001 = 1,
  2257. * event 0x80000000 = 32), or 0 if no event was pending.
  2258. */
  2259. #define EC_CMD_ACPI_QUERY_EVENT 0x84
  2260. /* Valid addresses in ACPI memory space, for read/write commands */
  2261. /* Memory space version; set to EC_ACPI_MEM_VERSION_CURRENT */
  2262. #define EC_ACPI_MEM_VERSION 0x00
  2263. /*
  2264. * Test location; writing value here updates test compliment byte to (0xff -
  2265. * value).
  2266. */
  2267. #define EC_ACPI_MEM_TEST 0x01
  2268. /* Test compliment; writes here are ignored. */
  2269. #define EC_ACPI_MEM_TEST_COMPLIMENT 0x02
  2270. /* Keyboard backlight brightness percent (0 - 100) */
  2271. #define EC_ACPI_MEM_KEYBOARD_BACKLIGHT 0x03
  2272. /* DPTF Target Fan Duty (0-100, 0xff for auto/none) */
  2273. #define EC_ACPI_MEM_FAN_DUTY 0x04
  2274. /*
  2275. * DPTF temp thresholds. Any of the EC's temp sensors can have up to two
  2276. * independent thresholds attached to them. The current value of the ID
  2277. * register determines which sensor is affected by the THRESHOLD and COMMIT
  2278. * registers. The THRESHOLD register uses the same EC_TEMP_SENSOR_OFFSET scheme
  2279. * as the memory-mapped sensors. The COMMIT register applies those settings.
  2280. *
  2281. * The spec does not mandate any way to read back the threshold settings
  2282. * themselves, but when a threshold is crossed the AP needs a way to determine
  2283. * which sensor(s) are responsible. Each reading of the ID register clears and
  2284. * returns one sensor ID that has crossed one of its threshold (in either
  2285. * direction) since the last read. A value of 0xFF means "no new thresholds
  2286. * have tripped". Setting or enabling the thresholds for a sensor will clear
  2287. * the unread event count for that sensor.
  2288. */
  2289. #define EC_ACPI_MEM_TEMP_ID 0x05
  2290. #define EC_ACPI_MEM_TEMP_THRESHOLD 0x06
  2291. #define EC_ACPI_MEM_TEMP_COMMIT 0x07
  2292. /*
  2293. * Here are the bits for the COMMIT register:
  2294. * bit 0 selects the threshold index for the chosen sensor (0/1)
  2295. * bit 1 enables/disables the selected threshold (0 = off, 1 = on)
  2296. * Each write to the commit register affects one threshold.
  2297. */
  2298. #define EC_ACPI_MEM_TEMP_COMMIT_SELECT_MASK (1 << 0)
  2299. #define EC_ACPI_MEM_TEMP_COMMIT_ENABLE_MASK (1 << 1)
  2300. /*
  2301. * Example:
  2302. *
  2303. * Set the thresholds for sensor 2 to 50 C and 60 C:
  2304. * write 2 to [0x05] -- select temp sensor 2
  2305. * write 0x7b to [0x06] -- C_TO_K(50) - EC_TEMP_SENSOR_OFFSET
  2306. * write 0x2 to [0x07] -- enable threshold 0 with this value
  2307. * write 0x85 to [0x06] -- C_TO_K(60) - EC_TEMP_SENSOR_OFFSET
  2308. * write 0x3 to [0x07] -- enable threshold 1 with this value
  2309. *
  2310. * Disable the 60 C threshold, leaving the 50 C threshold unchanged:
  2311. * write 2 to [0x05] -- select temp sensor 2
  2312. * write 0x1 to [0x07] -- disable threshold 1
  2313. */
  2314. /* DPTF battery charging current limit */
  2315. #define EC_ACPI_MEM_CHARGING_LIMIT 0x08
  2316. /* Charging limit is specified in 64 mA steps */
  2317. #define EC_ACPI_MEM_CHARGING_LIMIT_STEP_MA 64
  2318. /* Value to disable DPTF battery charging limit */
  2319. #define EC_ACPI_MEM_CHARGING_LIMIT_DISABLED 0xff
  2320. /* Current version of ACPI memory address space */
  2321. #define EC_ACPI_MEM_VERSION_CURRENT 1
  2322. /*****************************************************************************/
  2323. /*
  2324. * Special commands
  2325. *
  2326. * These do not follow the normal rules for commands. See each command for
  2327. * details.
  2328. */
  2329. /*
  2330. * Reboot NOW
  2331. *
  2332. * This command will work even when the EC LPC interface is busy, because the
  2333. * reboot command is processed at interrupt level. Note that when the EC
  2334. * reboots, the host will reboot too, so there is no response to this command.
  2335. *
  2336. * Use EC_CMD_REBOOT_EC to reboot the EC more politely.
  2337. */
  2338. #define EC_CMD_REBOOT 0xd1 /* Think "die" */
  2339. /*
  2340. * Resend last response (not supported on LPC).
  2341. *
  2342. * Returns EC_RES_UNAVAILABLE if there is no response available - for example,
  2343. * there was no previous command, or the previous command's response was too
  2344. * big to save.
  2345. */
  2346. #define EC_CMD_RESEND_RESPONSE 0xdb
  2347. /*
  2348. * This header byte on a command indicate version 0. Any header byte less
  2349. * than this means that we are talking to an old EC which doesn't support
  2350. * versioning. In that case, we assume version 0.
  2351. *
  2352. * Header bytes greater than this indicate a later version. For example,
  2353. * EC_CMD_VERSION0 + 1 means we are using version 1.
  2354. *
  2355. * The old EC interface must not use commands 0xdc or higher.
  2356. */
  2357. #define EC_CMD_VERSION0 0xdc
  2358. #endif /* !__ACPI__ */
  2359. /*****************************************************************************/
  2360. /*
  2361. * PD commands
  2362. *
  2363. * These commands are for PD MCU communication.
  2364. */
  2365. /* EC to PD MCU exchange status command */
  2366. #define EC_CMD_PD_EXCHANGE_STATUS 0x100
  2367. /* Status of EC being sent to PD */
  2368. struct ec_params_pd_status {
  2369. int8_t batt_soc; /* battery state of charge */
  2370. } __packed;
  2371. /* Status of PD being sent back to EC */
  2372. struct ec_response_pd_status {
  2373. int8_t status; /* PD MCU status */
  2374. uint32_t curr_lim_ma; /* input current limit */
  2375. } __packed;
  2376. /* Set USB type-C port role and muxes */
  2377. #define EC_CMD_USB_PD_CONTROL 0x101
  2378. enum usb_pd_control_role {
  2379. USB_PD_CTRL_ROLE_NO_CHANGE = 0,
  2380. USB_PD_CTRL_ROLE_TOGGLE_ON = 1, /* == AUTO */
  2381. USB_PD_CTRL_ROLE_TOGGLE_OFF = 2,
  2382. USB_PD_CTRL_ROLE_FORCE_SINK = 3,
  2383. USB_PD_CTRL_ROLE_FORCE_SOURCE = 4,
  2384. };
  2385. enum usb_pd_control_mux {
  2386. USB_PD_CTRL_MUX_NO_CHANGE = 0,
  2387. USB_PD_CTRL_MUX_NONE = 1,
  2388. USB_PD_CTRL_MUX_USB = 2,
  2389. USB_PD_CTRL_MUX_DP = 3,
  2390. USB_PD_CTRL_MUX_DOCK = 4,
  2391. USB_PD_CTRL_MUX_AUTO = 5,
  2392. };
  2393. struct ec_params_usb_pd_control {
  2394. uint8_t port;
  2395. uint8_t role;
  2396. uint8_t mux;
  2397. } __packed;
  2398. /*****************************************************************************/
  2399. /*
  2400. * Passthru commands
  2401. *
  2402. * Some platforms have sub-processors chained to each other. For example.
  2403. *
  2404. * AP <--> EC <--> PD MCU
  2405. *
  2406. * The top 2 bits of the command number are used to indicate which device the
  2407. * command is intended for. Device 0 is always the device receiving the
  2408. * command; other device mapping is board-specific.
  2409. *
  2410. * When a device receives a command to be passed to a sub-processor, it passes
  2411. * it on with the device number set back to 0. This allows the sub-processor
  2412. * to remain blissfully unaware of whether the command originated on the next
  2413. * device up the chain, or was passed through from the AP.
  2414. *
  2415. * In the above example, if the AP wants to send command 0x0002 to the PD MCU,
  2416. * AP sends command 0x4002 to the EC
  2417. * EC sends command 0x0002 to the PD MCU
  2418. * EC forwards PD MCU response back to the AP
  2419. */
  2420. /* Offset and max command number for sub-device n */
  2421. #define EC_CMD_PASSTHRU_OFFSET(n) (0x4000 * (n))
  2422. #define EC_CMD_PASSTHRU_MAX(n) (EC_CMD_PASSTHRU_OFFSET(n) + 0x3fff)
  2423. /*****************************************************************************/
  2424. /*
  2425. * Deprecated constants. These constants have been renamed for clarity. The
  2426. * meaning and size has not changed. Programs that use the old names should
  2427. * switch to the new names soon, as the old names may not be carried forward
  2428. * forever.
  2429. */
  2430. #define EC_HOST_PARAM_SIZE EC_PROTO2_MAX_PARAM_SIZE
  2431. #define EC_LPC_ADDR_OLD_PARAM EC_HOST_CMD_REGION1
  2432. #define EC_OLD_PARAM_SIZE EC_HOST_CMD_REGION_SIZE
  2433. #endif /* __CROS_EC_COMMANDS_H */