1
2
3
4
5
6
7
8#ifndef __CROS_EC_COMMANDS_H
9#define __CROS_EC_COMMANDS_H
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31#define EC_PROTO_VERSION 0x00000002
32
33
34#define EC_VER_MASK(version) (1UL << (version))
35
36
37#define EC_LPC_ADDR_ACPI_DATA 0x62
38#define EC_LPC_ADDR_ACPI_CMD 0x66
39
40
41#define EC_LPC_ADDR_HOST_DATA 0x200
42#define EC_LPC_ADDR_HOST_CMD 0x204
43
44
45
46#define EC_LPC_ADDR_HOST_ARGS 0x800
47#define EC_LPC_ADDR_HOST_PARAM 0x804
48
49
50#define EC_LPC_ADDR_HOST_PACKET 0x800
51#define EC_LPC_HOST_PACKET_SIZE 0x100
52
53
54
55#define EC_HOST_CMD_REGION0 0x800
56#define EC_HOST_CMD_REGION1 0x880
57#define EC_HOST_CMD_REGION_SIZE 0x80
58
59
60#define EC_LPC_CMDR_DATA (1 << 0)
61#define EC_LPC_CMDR_PENDING (1 << 1)
62#define EC_LPC_CMDR_BUSY (1 << 2)
63#define EC_LPC_CMDR_CMD (1 << 3)
64#define EC_LPC_CMDR_ACPI_BRST (1 << 4)
65#define EC_LPC_CMDR_SCI (1 << 5)
66#define EC_LPC_CMDR_SMI (1 << 6)
67
68#define EC_LPC_ADDR_MEMMAP 0x900
69#define EC_MEMMAP_SIZE 255
70#define EC_MEMMAP_TEXT_MAX 8
71
72
73#define EC_MEMMAP_TEMP_SENSOR 0x00
74#define EC_MEMMAP_FAN 0x10
75#define EC_MEMMAP_TEMP_SENSOR_B 0x18
76#define EC_MEMMAP_ID 0x20
77#define EC_MEMMAP_ID_VERSION 0x22
78#define EC_MEMMAP_THERMAL_VERSION 0x23
79#define EC_MEMMAP_BATTERY_VERSION 0x24
80#define EC_MEMMAP_SWITCHES_VERSION 0x25
81#define EC_MEMMAP_EVENTS_VERSION 0x26
82#define EC_MEMMAP_HOST_CMD_FLAGS 0x27
83#define EC_MEMMAP_SWITCHES 0x30
84#define EC_MEMMAP_HOST_EVENTS 0x34
85#define EC_MEMMAP_BATT_VOLT 0x40
86#define EC_MEMMAP_BATT_RATE 0x44
87#define EC_MEMMAP_BATT_CAP 0x48
88#define EC_MEMMAP_BATT_FLAG 0x4c
89#define EC_MEMMAP_BATT_DCAP 0x50
90#define EC_MEMMAP_BATT_DVLT 0x54
91#define EC_MEMMAP_BATT_LFCC 0x58
92#define EC_MEMMAP_BATT_CCNT 0x5c
93#define EC_MEMMAP_BATT_MFGR 0x60
94#define EC_MEMMAP_BATT_MODEL 0x68
95#define EC_MEMMAP_BATT_SERIAL 0x70
96#define EC_MEMMAP_BATT_TYPE 0x78
97
98
99#define EC_TEMP_SENSOR_ENTRIES 16
100
101
102
103
104
105#define EC_TEMP_SENSOR_B_ENTRIES 8
106#define EC_TEMP_SENSOR_NOT_PRESENT 0xff
107#define EC_TEMP_SENSOR_ERROR 0xfe
108#define EC_TEMP_SENSOR_NOT_POWERED 0xfd
109#define EC_TEMP_SENSOR_NOT_CALIBRATED 0xfc
110
111
112
113
114#define EC_TEMP_SENSOR_OFFSET 200
115
116#define EC_FAN_SPEED_ENTRIES 4
117#define EC_FAN_SPEED_NOT_PRESENT 0xffff
118#define EC_FAN_SPEED_STALLED 0xfffe
119
120
121#define EC_BATT_FLAG_AC_PRESENT 0x01
122#define EC_BATT_FLAG_BATT_PRESENT 0x02
123#define EC_BATT_FLAG_DISCHARGING 0x04
124#define EC_BATT_FLAG_CHARGING 0x08
125#define EC_BATT_FLAG_LEVEL_CRITICAL 0x10
126
127
128#define EC_SWITCH_LID_OPEN 0x01
129#define EC_SWITCH_POWER_BUTTON_PRESSED 0x02
130#define EC_SWITCH_WRITE_PROTECT_DISABLED 0x04
131
132#define EC_SWITCH_IGNORE1 0x08
133
134#define EC_SWITCH_DEDICATED_RECOVERY 0x10
135
136#define EC_SWITCH_IGNORE0 0x20
137
138
139
140#define EC_HOST_CMD_FLAG_LPC_ARGS_SUPPORTED 0x01
141
142#define EC_HOST_CMD_FLAG_VERSION_3 0x02
143
144
145#define EC_WIRELESS_SWITCH_WLAN 0x01
146#define EC_WIRELESS_SWITCH_BLUETOOTH 0x02
147#define EC_WIRELESS_SWITCH_WWAN 0x04
148
149
150
151
152
153
154#ifndef __ACPI__
155
156
157
158
159
160#ifndef __packed
161#define __packed __attribute__((packed))
162#endif
163
164
165
166#define EC_LPC_STATUS_TO_HOST 0x01
167
168#define EC_LPC_STATUS_FROM_HOST 0x02
169
170#define EC_LPC_STATUS_PROCESSING 0x04
171
172#define EC_LPC_STATUS_LAST_CMD 0x08
173
174#define EC_LPC_STATUS_BURST_MODE 0x10
175
176#define EC_LPC_STATUS_SCI_PENDING 0x20
177
178#define EC_LPC_STATUS_SMI_PENDING 0x40
179
180#define EC_LPC_STATUS_RESERVED 0x80
181
182
183
184
185
186#define EC_LPC_STATUS_BUSY_MASK \
187 (EC_LPC_STATUS_FROM_HOST | EC_LPC_STATUS_PROCESSING)
188
189
190enum ec_status {
191 EC_RES_SUCCESS = 0,
192 EC_RES_INVALID_COMMAND = 1,
193 EC_RES_ERROR = 2,
194 EC_RES_INVALID_PARAM = 3,
195 EC_RES_ACCESS_DENIED = 4,
196 EC_RES_INVALID_RESPONSE = 5,
197 EC_RES_INVALID_VERSION = 6,
198 EC_RES_INVALID_CHECKSUM = 7,
199 EC_RES_IN_PROGRESS = 8,
200 EC_RES_UNAVAILABLE = 9,
201 EC_RES_TIMEOUT = 10,
202 EC_RES_OVERFLOW = 11,
203 EC_RES_INVALID_HEADER = 12,
204 EC_RES_REQUEST_TRUNCATED = 13,
205 EC_RES_RESPONSE_TOO_BIG = 14
206};
207
208
209
210
211
212
213
214
215enum host_event_code {
216 EC_HOST_EVENT_LID_CLOSED = 1,
217 EC_HOST_EVENT_LID_OPEN = 2,
218 EC_HOST_EVENT_POWER_BUTTON = 3,
219 EC_HOST_EVENT_AC_CONNECTED = 4,
220 EC_HOST_EVENT_AC_DISCONNECTED = 5,
221 EC_HOST_EVENT_BATTERY_LOW = 6,
222 EC_HOST_EVENT_BATTERY_CRITICAL = 7,
223 EC_HOST_EVENT_BATTERY = 8,
224 EC_HOST_EVENT_THERMAL_THRESHOLD = 9,
225 EC_HOST_EVENT_THERMAL_OVERLOAD = 10,
226 EC_HOST_EVENT_THERMAL = 11,
227 EC_HOST_EVENT_USB_CHARGER = 12,
228 EC_HOST_EVENT_KEY_PRESSED = 13,
229
230
231
232
233
234 EC_HOST_EVENT_INTERFACE_READY = 14,
235
236 EC_HOST_EVENT_KEYBOARD_RECOVERY = 15,
237
238
239 EC_HOST_EVENT_THERMAL_SHUTDOWN = 16,
240
241 EC_HOST_EVENT_BATTERY_SHUTDOWN = 17,
242
243
244
245
246
247
248
249
250 EC_HOST_EVENT_INVALID = 32
251};
252
253#define EC_HOST_EVENT_MASK(event_code) (1UL << ((event_code) - 1))
254
255
256struct ec_lpc_host_args {
257 uint8_t flags;
258 uint8_t command_version;
259 uint8_t data_size;
260
261
262
263
264 uint8_t checksum;
265} __packed;
266
267
268
269
270
271
272
273
274
275
276
277#define EC_HOST_ARGS_FLAG_FROM_HOST 0x01
278
279
280
281
282
283
284
285#define EC_HOST_ARGS_FLAG_TO_HOST 0x02
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305#define EC_PROTO2_REQUEST_HEADER_BYTES 3
306#define EC_PROTO2_REQUEST_TRAILER_BYTES 1
307#define EC_PROTO2_REQUEST_OVERHEAD (EC_PROTO2_REQUEST_HEADER_BYTES + \
308 EC_PROTO2_REQUEST_TRAILER_BYTES)
309
310#define EC_PROTO2_RESPONSE_HEADER_BYTES 2
311#define EC_PROTO2_RESPONSE_TRAILER_BYTES 1
312#define EC_PROTO2_RESPONSE_OVERHEAD (EC_PROTO2_RESPONSE_HEADER_BYTES + \
313 EC_PROTO2_RESPONSE_TRAILER_BYTES)
314
315
316#define EC_PROTO2_MAX_PARAM_SIZE 0xfc
317
318
319#define EC_PROTO2_MAX_REQUEST_SIZE (EC_PROTO2_REQUEST_OVERHEAD + \
320 EC_PROTO2_MAX_PARAM_SIZE)
321#define EC_PROTO2_MAX_RESPONSE_SIZE (EC_PROTO2_RESPONSE_OVERHEAD + \
322 EC_PROTO2_MAX_PARAM_SIZE)
323
324
325
326
327
328
329
330#define EC_COMMAND_PROTOCOL_3 0xda
331
332#define EC_HOST_REQUEST_VERSION 3
333
334
335struct ec_host_request {
336
337
338
339
340
341 uint8_t struct_version;
342
343
344
345
346
347 uint8_t checksum;
348
349
350 uint16_t command;
351
352
353 uint8_t command_version;
354
355
356 uint8_t reserved;
357
358
359 uint16_t data_len;
360} __packed;
361
362#define EC_HOST_RESPONSE_VERSION 3
363
364
365struct ec_host_response {
366
367 uint8_t struct_version;
368
369
370
371
372
373 uint8_t checksum;
374
375
376 uint16_t result;
377
378
379 uint16_t data_len;
380
381
382 uint16_t reserved;
383} __packed;
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404#define EC_CMD_PROTO_VERSION 0x00
405
406struct ec_response_proto_version {
407 uint32_t version;
408} __packed;
409
410
411
412
413
414#define EC_CMD_HELLO 0x01
415
416struct ec_params_hello {
417 uint32_t in_data;
418} __packed;
419
420struct ec_response_hello {
421 uint32_t out_data;
422} __packed;
423
424
425#define EC_CMD_GET_VERSION 0x02
426
427enum ec_current_image {
428 EC_IMAGE_UNKNOWN = 0,
429 EC_IMAGE_RO,
430 EC_IMAGE_RW
431};
432
433struct ec_response_get_version {
434
435 char version_string_ro[32];
436 char version_string_rw[32];
437 char reserved[32];
438 uint32_t current_image;
439} __packed;
440
441
442#define EC_CMD_READ_TEST 0x03
443
444struct ec_params_read_test {
445 uint32_t offset;
446 uint32_t size;
447} __packed;
448
449struct ec_response_read_test {
450 uint32_t data[32];
451} __packed;
452
453
454
455
456
457
458#define EC_CMD_GET_BUILD_INFO 0x04
459
460
461#define EC_CMD_GET_CHIP_INFO 0x05
462
463struct ec_response_get_chip_info {
464
465 char vendor[32];
466 char name[32];
467 char revision[32];
468} __packed;
469
470
471#define EC_CMD_GET_BOARD_VERSION 0x06
472
473struct ec_response_board_version {
474 uint16_t board_version;
475} __packed;
476
477
478
479
480
481
482
483
484
485#define EC_CMD_READ_MEMMAP 0x07
486
487struct ec_params_read_memmap {
488 uint8_t offset;
489 uint8_t size;
490} __packed;
491
492
493#define EC_CMD_GET_CMD_VERSIONS 0x08
494
495struct ec_params_get_cmd_versions {
496 uint8_t cmd;
497} __packed;
498
499struct ec_response_get_cmd_versions {
500
501
502
503
504 uint32_t version_mask;
505} __packed;
506
507
508
509
510
511
512
513
514#define EC_CMD_GET_COMMS_STATUS 0x09
515
516
517enum ec_comms_status {
518 EC_COMMS_STATUS_PROCESSING = 1 << 0,
519};
520
521struct ec_response_get_comms_status {
522 uint32_t flags;
523} __packed;
524
525
526
527
528
529#define EC_CMD_TEST_PROTOCOL 0x0a
530
531
532struct ec_params_test_protocol {
533 uint32_t ec_result;
534 uint32_t ret_len;
535 uint8_t buf[32];
536} __packed;
537
538
539struct ec_response_test_protocol {
540 uint8_t buf[32];
541} __packed;
542
543
544#define EC_CMD_GET_PROTOCOL_INFO 0x0b
545
546
547
548#define EC_PROTOCOL_INFO_IN_PROGRESS_SUPPORTED (1 << 0)
549
550struct ec_response_get_protocol_info {
551
552
553
554 uint32_t protocol_versions;
555
556
557 uint16_t max_request_packet_size;
558
559
560 uint16_t max_response_packet_size;
561
562
563 uint32_t flags;
564} __packed;
565
566
567
568
569
570#define EC_CMD_FLASH_INFO 0x10
571
572struct ec_response_flash_info {
573
574 uint32_t flash_size;
575
576
577
578
579 uint32_t write_block_size;
580
581
582
583
584 uint32_t erase_block_size;
585
586
587
588
589 uint32_t protect_block_size;
590} __packed;
591
592
593
594
595
596
597#define EC_CMD_FLASH_READ 0x11
598
599struct ec_params_flash_read {
600 uint32_t offset;
601 uint32_t size;
602} __packed;
603
604
605#define EC_CMD_FLASH_WRITE 0x12
606#define EC_VER_FLASH_WRITE 1
607
608
609#define EC_FLASH_WRITE_VER0_SIZE 64
610
611struct ec_params_flash_write {
612 uint32_t offset;
613 uint32_t size;
614
615} __packed;
616
617
618#define EC_CMD_FLASH_ERASE 0x13
619
620struct ec_params_flash_erase {
621 uint32_t offset;
622 uint32_t size;
623} __packed;
624
625
626
627
628
629
630
631
632
633
634
635#define EC_CMD_FLASH_PROTECT 0x15
636#define EC_VER_FLASH_PROTECT 1
637
638
639
640#define EC_FLASH_PROTECT_RO_AT_BOOT (1 << 0)
641
642
643
644
645#define EC_FLASH_PROTECT_RO_NOW (1 << 1)
646
647#define EC_FLASH_PROTECT_ALL_NOW (1 << 2)
648
649#define EC_FLASH_PROTECT_GPIO_ASSERTED (1 << 3)
650
651#define EC_FLASH_PROTECT_ERROR_STUCK (1 << 4)
652
653
654
655
656
657#define EC_FLASH_PROTECT_ERROR_INCONSISTENT (1 << 5)
658
659#define EC_FLASH_PROTECT_ALL_AT_BOOT (1 << 6)
660
661struct ec_params_flash_protect {
662 uint32_t mask;
663 uint32_t flags;
664} __packed;
665
666struct ec_response_flash_protect {
667
668 uint32_t flags;
669
670
671
672
673
674 uint32_t valid_flags;
675
676 uint32_t writable_flags;
677} __packed;
678
679
680
681
682
683
684
685#define EC_CMD_FLASH_REGION_INFO 0x16
686#define EC_VER_FLASH_REGION_INFO 1
687
688enum ec_flash_region {
689
690 EC_FLASH_REGION_RO = 0,
691
692 EC_FLASH_REGION_RW,
693
694
695
696
697 EC_FLASH_REGION_WP_RO,
698
699 EC_FLASH_REGION_COUNT,
700};
701
702struct ec_params_flash_region_info {
703 uint32_t region;
704} __packed;
705
706struct ec_response_flash_region_info {
707 uint32_t offset;
708 uint32_t size;
709} __packed;
710
711
712#define EC_CMD_VBNV_CONTEXT 0x17
713#define EC_VER_VBNV_CONTEXT 1
714#define EC_VBNV_BLOCK_SIZE 16
715
716enum ec_vbnvcontext_op {
717 EC_VBNV_CONTEXT_OP_READ,
718 EC_VBNV_CONTEXT_OP_WRITE,
719};
720
721struct ec_params_vbnvcontext {
722 uint32_t op;
723 uint8_t block[EC_VBNV_BLOCK_SIZE];
724} __packed;
725
726struct ec_response_vbnvcontext {
727 uint8_t block[EC_VBNV_BLOCK_SIZE];
728} __packed;
729
730
731
732
733
734#define EC_CMD_PWM_GET_FAN_TARGET_RPM 0x20
735
736struct ec_response_pwm_get_fan_rpm {
737 uint32_t rpm;
738} __packed;
739
740
741#define EC_CMD_PWM_SET_FAN_TARGET_RPM 0x21
742
743struct ec_params_pwm_set_fan_target_rpm {
744 uint32_t rpm;
745} __packed;
746
747
748#define EC_CMD_PWM_GET_KEYBOARD_BACKLIGHT 0x22
749
750struct ec_response_pwm_get_keyboard_backlight {
751 uint8_t percent;
752 uint8_t enabled;
753} __packed;
754
755
756#define EC_CMD_PWM_SET_KEYBOARD_BACKLIGHT 0x23
757
758struct ec_params_pwm_set_keyboard_backlight {
759 uint8_t percent;
760} __packed;
761
762
763#define EC_CMD_PWM_SET_FAN_DUTY 0x24
764
765struct ec_params_pwm_set_fan_duty {
766 uint32_t percent;
767} __packed;
768
769
770
771
772
773
774
775
776#define EC_CMD_LIGHTBAR_CMD 0x28
777
778struct rgb_s {
779 uint8_t r, g, b;
780};
781
782#define LB_BATTERY_LEVELS 4
783
784
785
786struct lightbar_params {
787
788 int google_ramp_up;
789 int google_ramp_down;
790 int s3s0_ramp_up;
791 int s0_tick_delay[2];
792 int s0a_tick_delay[2];
793 int s0s3_ramp_down;
794 int s3_sleep_for;
795 int s3_ramp_up;
796 int s3_ramp_down;
797
798
799 uint8_t new_s0;
800 uint8_t osc_min[2];
801 uint8_t osc_max[2];
802 uint8_t w_ofs[2];
803
804
805 uint8_t bright_bl_off_fixed[2];
806 uint8_t bright_bl_on_min[2];
807 uint8_t bright_bl_on_max[2];
808
809
810 uint8_t battery_threshold[LB_BATTERY_LEVELS - 1];
811
812
813 uint8_t s0_idx[2][LB_BATTERY_LEVELS];
814 uint8_t s3_idx[2][LB_BATTERY_LEVELS];
815
816
817 struct rgb_s color[8];
818} __packed;
819
820struct ec_params_lightbar {
821 uint8_t cmd;
822 union {
823 struct {
824
825 } dump, off, on, init, get_seq, get_params;
826
827 struct num {
828 uint8_t num;
829 } brightness, seq, demo;
830
831 struct reg {
832 uint8_t ctrl, reg, value;
833 } reg;
834
835 struct rgb {
836 uint8_t led, red, green, blue;
837 } rgb;
838
839 struct lightbar_params set_params;
840 };
841} __packed;
842
843struct ec_response_lightbar {
844 union {
845 struct dump {
846 struct {
847 uint8_t reg;
848 uint8_t ic0;
849 uint8_t ic1;
850 } vals[23];
851 } dump;
852
853 struct get_seq {
854 uint8_t num;
855 } get_seq;
856
857 struct lightbar_params get_params;
858
859 struct {
860
861 } off, on, init, brightness, seq, reg, rgb, demo, set_params;
862 };
863} __packed;
864
865
866enum lightbar_command {
867 LIGHTBAR_CMD_DUMP = 0,
868 LIGHTBAR_CMD_OFF = 1,
869 LIGHTBAR_CMD_ON = 2,
870 LIGHTBAR_CMD_INIT = 3,
871 LIGHTBAR_CMD_BRIGHTNESS = 4,
872 LIGHTBAR_CMD_SEQ = 5,
873 LIGHTBAR_CMD_REG = 6,
874 LIGHTBAR_CMD_RGB = 7,
875 LIGHTBAR_CMD_GET_SEQ = 8,
876 LIGHTBAR_CMD_DEMO = 9,
877 LIGHTBAR_CMD_GET_PARAMS = 10,
878 LIGHTBAR_CMD_SET_PARAMS = 11,
879 LIGHTBAR_NUM_CMDS
880};
881
882
883
884
885#define EC_CMD_LED_CONTROL 0x29
886
887enum ec_led_id {
888 EC_LED_ID_BATTERY_LED = 0,
889 EC_LED_ID_POWER_BUTTON_LED,
890 EC_LED_ID_ADAPTER_LED,
891};
892
893
894#define EC_LED_FLAGS_QUERY (1 << 0)
895#define EC_LED_FLAGS_AUTO (1 << 1)
896
897enum ec_led_colors {
898 EC_LED_COLOR_RED = 0,
899 EC_LED_COLOR_GREEN,
900 EC_LED_COLOR_BLUE,
901 EC_LED_COLOR_YELLOW,
902 EC_LED_COLOR_WHITE,
903
904 EC_LED_COLOR_COUNT
905};
906
907struct ec_params_led_control {
908 uint8_t led_id;
909 uint8_t flags;
910
911 uint8_t brightness[EC_LED_COLOR_COUNT];
912} __packed;
913
914struct ec_response_led_control {
915
916
917
918
919
920
921
922 uint8_t brightness_range[EC_LED_COLOR_COUNT];
923} __packed;
924
925
926
927
928
929
930
931
932
933
934#define EC_CMD_VBOOT_HASH 0x2A
935
936struct ec_params_vboot_hash {
937 uint8_t cmd;
938 uint8_t hash_type;
939 uint8_t nonce_size;
940 uint8_t reserved0;
941 uint32_t offset;
942 uint32_t size;
943 uint8_t nonce_data[64];
944} __packed;
945
946struct ec_response_vboot_hash {
947 uint8_t status;
948 uint8_t hash_type;
949 uint8_t digest_size;
950 uint8_t reserved0;
951 uint32_t offset;
952 uint32_t size;
953 uint8_t hash_digest[64];
954} __packed;
955
956enum ec_vboot_hash_cmd {
957 EC_VBOOT_HASH_GET = 0,
958 EC_VBOOT_HASH_ABORT = 1,
959 EC_VBOOT_HASH_START = 2,
960 EC_VBOOT_HASH_RECALC = 3,
961};
962
963enum ec_vboot_hash_type {
964 EC_VBOOT_HASH_TYPE_SHA256 = 0,
965};
966
967enum ec_vboot_hash_status {
968 EC_VBOOT_HASH_STATUS_NONE = 0,
969 EC_VBOOT_HASH_STATUS_DONE = 1,
970 EC_VBOOT_HASH_STATUS_BUSY = 2,
971};
972
973
974
975
976
977
978#define EC_VBOOT_HASH_OFFSET_RO 0xfffffffe
979#define EC_VBOOT_HASH_OFFSET_RW 0xfffffffd
980
981
982
983
984
985#define EC_CMD_USB_CHARGE_SET_MODE 0x30
986
987struct ec_params_usb_charge_set_mode {
988 uint8_t usb_port_id;
989 uint8_t mode;
990} __packed;
991
992
993
994
995
996#define EC_PSTORE_SIZE_MAX 64
997
998
999#define EC_CMD_PSTORE_INFO 0x40
1000
1001struct ec_response_pstore_info {
1002
1003 uint32_t pstore_size;
1004
1005 uint32_t access_size;
1006} __packed;
1007
1008
1009
1010
1011
1012
1013#define EC_CMD_PSTORE_READ 0x41
1014
1015struct ec_params_pstore_read {
1016 uint32_t offset;
1017 uint32_t size;
1018} __packed;
1019
1020
1021#define EC_CMD_PSTORE_WRITE 0x42
1022
1023struct ec_params_pstore_write {
1024 uint32_t offset;
1025 uint32_t size;
1026 uint8_t data[EC_PSTORE_SIZE_MAX];
1027} __packed;
1028
1029
1030
1031
1032
1033struct ec_params_rtc {
1034 uint32_t time;
1035} __packed;
1036
1037struct ec_response_rtc {
1038 uint32_t time;
1039} __packed;
1040
1041
1042#define EC_CMD_RTC_GET_VALUE 0x44
1043#define EC_CMD_RTC_GET_ALARM 0x45
1044
1045
1046#define EC_CMD_RTC_SET_VALUE 0x46
1047#define EC_CMD_RTC_SET_ALARM 0x47
1048
1049
1050
1051
1052
1053#define EC_CMD_PORT80_LAST_BOOT 0x48
1054
1055struct ec_response_port80_last_boot {
1056 uint16_t code;
1057} __packed;
1058
1059
1060
1061
1062
1063#define EC_CMD_THERMAL_SET_THRESHOLD 0x50
1064
1065struct ec_params_thermal_set_threshold {
1066 uint8_t sensor_type;
1067 uint8_t threshold_id;
1068 uint16_t value;
1069} __packed;
1070
1071
1072#define EC_CMD_THERMAL_GET_THRESHOLD 0x51
1073
1074struct ec_params_thermal_get_threshold {
1075 uint8_t sensor_type;
1076 uint8_t threshold_id;
1077} __packed;
1078
1079struct ec_response_thermal_get_threshold {
1080 uint16_t value;
1081} __packed;
1082
1083
1084#define EC_CMD_THERMAL_AUTO_FAN_CTRL 0x52
1085
1086
1087#define EC_CMD_TMP006_GET_CALIBRATION 0x53
1088
1089struct ec_params_tmp006_get_calibration {
1090 uint8_t index;
1091} __packed;
1092
1093struct ec_response_tmp006_get_calibration {
1094 float s0;
1095 float b0;
1096 float b1;
1097 float b2;
1098} __packed;
1099
1100
1101#define EC_CMD_TMP006_SET_CALIBRATION 0x54
1102
1103struct ec_params_tmp006_set_calibration {
1104 uint8_t index;
1105 uint8_t reserved[3];
1106 float s0;
1107 float b0;
1108 float b1;
1109 float b2;
1110} __packed;
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121#define EC_CMD_MKBP_STATE 0x60
1122
1123
1124#define EC_CMD_MKBP_INFO 0x61
1125
1126struct ec_response_mkbp_info {
1127 uint32_t rows;
1128 uint32_t cols;
1129 uint8_t switches;
1130} __packed;
1131
1132
1133#define EC_CMD_MKBP_SIMULATE_KEY 0x62
1134
1135struct ec_params_mkbp_simulate_key {
1136 uint8_t col;
1137 uint8_t row;
1138 uint8_t pressed;
1139} __packed;
1140
1141
1142#define EC_CMD_MKBP_SET_CONFIG 0x64
1143#define EC_CMD_MKBP_GET_CONFIG 0x65
1144
1145
1146enum mkbp_config_flags {
1147 EC_MKBP_FLAGS_ENABLE = 1,
1148};
1149
1150enum mkbp_config_valid {
1151 EC_MKBP_VALID_SCAN_PERIOD = 1 << 0,
1152 EC_MKBP_VALID_POLL_TIMEOUT = 1 << 1,
1153 EC_MKBP_VALID_MIN_POST_SCAN_DELAY = 1 << 3,
1154 EC_MKBP_VALID_OUTPUT_SETTLE = 1 << 4,
1155 EC_MKBP_VALID_DEBOUNCE_DOWN = 1 << 5,
1156 EC_MKBP_VALID_DEBOUNCE_UP = 1 << 6,
1157 EC_MKBP_VALID_FIFO_MAX_DEPTH = 1 << 7,
1158};
1159
1160
1161struct ec_mkbp_config {
1162 uint32_t valid_mask;
1163 uint8_t flags;
1164 uint8_t valid_flags;
1165 uint16_t scan_period_us;
1166
1167 uint32_t poll_timeout_us;
1168
1169
1170
1171
1172
1173 uint16_t min_post_scan_delay_us;
1174
1175 uint16_t output_settle_us;
1176 uint16_t debounce_down_us;
1177 uint16_t debounce_up_us;
1178
1179 uint8_t fifo_max_depth;
1180} __packed;
1181
1182struct ec_params_mkbp_set_config {
1183 struct ec_mkbp_config config;
1184} __packed;
1185
1186struct ec_response_mkbp_get_config {
1187 struct ec_mkbp_config config;
1188} __packed;
1189
1190
1191#define EC_CMD_KEYSCAN_SEQ_CTRL 0x66
1192
1193enum ec_keyscan_seq_cmd {
1194 EC_KEYSCAN_SEQ_STATUS = 0,
1195 EC_KEYSCAN_SEQ_CLEAR = 1,
1196 EC_KEYSCAN_SEQ_ADD = 2,
1197 EC_KEYSCAN_SEQ_START = 3,
1198 EC_KEYSCAN_SEQ_COLLECT = 4,
1199};
1200
1201enum ec_collect_flags {
1202
1203
1204
1205
1206 EC_KEYSCAN_SEQ_FLAG_DONE = 1 << 0,
1207};
1208
1209struct ec_collect_item {
1210 uint8_t flags;
1211};
1212
1213struct ec_params_keyscan_seq_ctrl {
1214 uint8_t cmd;
1215 union {
1216 struct {
1217 uint8_t active;
1218 uint8_t num_items;
1219
1220 uint8_t cur_item;
1221 } status;
1222 struct {
1223
1224
1225
1226
1227 uint32_t time_us;
1228 uint8_t scan[0];
1229 } add;
1230 struct {
1231 uint8_t start_item;
1232 uint8_t num_items;
1233 } collect;
1234 };
1235} __packed;
1236
1237struct ec_result_keyscan_seq_ctrl {
1238 union {
1239 struct {
1240 uint8_t num_items;
1241
1242 struct ec_collect_item item[0];
1243 } collect;
1244 };
1245} __packed;
1246
1247
1248
1249
1250
1251#define EC_CMD_TEMP_SENSOR_GET_INFO 0x70
1252
1253struct ec_params_temp_sensor_get_info {
1254 uint8_t id;
1255} __packed;
1256
1257struct ec_response_temp_sensor_get_info {
1258 char sensor_name[32];
1259 uint8_t sensor_type;
1260} __packed;
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277struct ec_params_host_event_mask {
1278 uint32_t mask;
1279} __packed;
1280
1281struct ec_response_host_event_mask {
1282 uint32_t mask;
1283} __packed;
1284
1285
1286#define EC_CMD_HOST_EVENT_GET_B 0x87
1287#define EC_CMD_HOST_EVENT_GET_SMI_MASK 0x88
1288#define EC_CMD_HOST_EVENT_GET_SCI_MASK 0x89
1289#define EC_CMD_HOST_EVENT_GET_WAKE_MASK 0x8d
1290
1291
1292#define EC_CMD_HOST_EVENT_SET_SMI_MASK 0x8a
1293#define EC_CMD_HOST_EVENT_SET_SCI_MASK 0x8b
1294#define EC_CMD_HOST_EVENT_CLEAR 0x8c
1295#define EC_CMD_HOST_EVENT_SET_WAKE_MASK 0x8e
1296#define EC_CMD_HOST_EVENT_CLEAR_B 0x8f
1297
1298
1299
1300
1301
1302#define EC_CMD_SWITCH_ENABLE_BKLIGHT 0x90
1303
1304struct ec_params_switch_enable_backlight {
1305 uint8_t enabled;
1306} __packed;
1307
1308
1309#define EC_CMD_SWITCH_ENABLE_WIRELESS 0x91
1310
1311struct ec_params_switch_enable_wireless {
1312 uint8_t enabled;
1313} __packed;
1314
1315
1316
1317
1318
1319#define EC_CMD_GPIO_SET 0x92
1320
1321struct ec_params_gpio_set {
1322 char name[32];
1323 uint8_t val;
1324} __packed;
1325
1326
1327#define EC_CMD_GPIO_GET 0x93
1328
1329struct ec_params_gpio_get {
1330 char name[32];
1331} __packed;
1332struct ec_response_gpio_get {
1333 uint8_t val;
1334} __packed;
1335
1336
1337
1338
1339
1340#define EC_CMD_I2C_READ 0x94
1341
1342struct ec_params_i2c_read {
1343 uint16_t addr;
1344 uint8_t read_size;
1345 uint8_t port;
1346 uint8_t offset;
1347} __packed;
1348struct ec_response_i2c_read {
1349 uint16_t data;
1350} __packed;
1351
1352
1353#define EC_CMD_I2C_WRITE 0x95
1354
1355struct ec_params_i2c_write {
1356 uint16_t data;
1357 uint16_t addr;
1358 uint8_t write_size;
1359 uint8_t port;
1360 uint8_t offset;
1361} __packed;
1362
1363
1364
1365
1366
1367#define EC_CMD_CHARGE_FORCE_IDLE 0x96
1368
1369struct ec_params_force_idle {
1370 uint8_t enabled;
1371} __packed;
1372
1373
1374
1375
1376
1377#define EC_CMD_CONSOLE_SNAPSHOT 0x97
1378
1379
1380
1381
1382
1383
1384
1385#define EC_CMD_CONSOLE_READ 0x98
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395#define EC_CMD_BATTERY_CUT_OFF 0x99
1396
1397
1398
1399
1400
1401
1402
1403#define EC_CMD_USB_MUX 0x9a
1404
1405struct ec_params_usb_mux {
1406 uint8_t mux;
1407} __packed;
1408
1409
1410
1411
1412enum ec_ldo_state {
1413 EC_LDO_STATE_OFF = 0,
1414 EC_LDO_STATE_ON = 1,
1415};
1416
1417
1418
1419
1420#define EC_CMD_LDO_SET 0x9b
1421
1422struct ec_params_ldo_set {
1423 uint8_t index;
1424 uint8_t state;
1425} __packed;
1426
1427
1428
1429
1430#define EC_CMD_LDO_GET 0x9c
1431
1432struct ec_params_ldo_get {
1433 uint8_t index;
1434} __packed;
1435
1436struct ec_response_ldo_get {
1437 uint8_t state;
1438} __packed;
1439
1440
1441
1442
1443
1444
1445
1446#define EC_CMD_POWER_INFO 0x9d
1447
1448struct ec_response_power_info {
1449 uint32_t usb_dev_type;
1450 uint16_t voltage_ac;
1451 uint16_t voltage_system;
1452 uint16_t current_system;
1453 uint16_t usb_current_limit;
1454} __packed;
1455
1456
1457
1458
1459#define EC_CMD_I2C_PASSTHRU 0x9e
1460
1461
1462#define EC_I2C_FLAG_10BIT (1 << 16)
1463
1464
1465#define EC_I2C_FLAG_READ (1 << 15)
1466
1467
1468#define EC_I2C_ADDR_MASK 0x3ff
1469
1470#define EC_I2C_STATUS_NAK (1 << 0)
1471#define EC_I2C_STATUS_TIMEOUT (1 << 1)
1472
1473
1474#define EC_I2C_STATUS_ERROR (EC_I2C_STATUS_NAK | EC_I2C_STATUS_TIMEOUT)
1475
1476struct ec_params_i2c_passthru_msg {
1477 uint16_t addr_flags;
1478 uint16_t len;
1479} __packed;
1480
1481struct ec_params_i2c_passthru {
1482 uint8_t port;
1483 uint8_t num_msgs;
1484 struct ec_params_i2c_passthru_msg msg[];
1485
1486} __packed;
1487
1488struct ec_response_i2c_passthru {
1489 uint8_t i2c_status;
1490 uint8_t num_msgs;
1491 uint8_t data[];
1492} __packed;
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503#define EC_CMD_CHARGE_DUMP 0xa0
1504
1505
1506
1507
1508#define EC_CMD_CHARGE_CURRENT_LIMIT 0xa1
1509
1510struct ec_params_current_limit {
1511 uint32_t limit;
1512} __packed;
1513
1514
1515
1516
1517#define EC_CMD_EXT_POWER_CURRENT_LIMIT 0xa2
1518
1519struct ec_params_ext_power_current_limit {
1520 uint32_t limit;
1521} __packed;
1522
1523
1524
1525
1526
1527#define EC_CMD_SB_READ_WORD 0xb0
1528#define EC_CMD_SB_WRITE_WORD 0xb1
1529
1530
1531
1532
1533#define EC_CMD_SB_READ_BLOCK 0xb2
1534#define EC_CMD_SB_WRITE_BLOCK 0xb3
1535
1536struct ec_params_sb_rd {
1537 uint8_t reg;
1538} __packed;
1539
1540struct ec_response_sb_rd_word {
1541 uint16_t value;
1542} __packed;
1543
1544struct ec_params_sb_wr_word {
1545 uint8_t reg;
1546 uint16_t value;
1547} __packed;
1548
1549struct ec_response_sb_rd_block {
1550 uint8_t data[32];
1551} __packed;
1552
1553struct ec_params_sb_wr_block {
1554 uint8_t reg;
1555 uint16_t data[32];
1556} __packed;
1557
1558
1559
1560
1561
1562
1563#define EC_CMD_ENTERING_MODE 0xb6
1564
1565struct ec_params_entering_mode {
1566 int vboot_mode;
1567} __packed;
1568
1569#define VBOOT_MODE_NORMAL 0
1570#define VBOOT_MODE_DEVELOPER 1
1571#define VBOOT_MODE_RECOVERY 2
1572
1573
1574
1575
1576
1577
1578
1579
1580#define EC_CMD_REBOOT_EC 0xd2
1581
1582
1583enum ec_reboot_cmd {
1584 EC_REBOOT_CANCEL = 0,
1585 EC_REBOOT_JUMP_RO = 1,
1586 EC_REBOOT_JUMP_RW = 2,
1587
1588 EC_REBOOT_COLD = 4,
1589 EC_REBOOT_DISABLE_JUMP = 5,
1590 EC_REBOOT_HIBERNATE = 6
1591};
1592
1593
1594#define EC_REBOOT_FLAG_RESERVED0 (1 << 0)
1595#define EC_REBOOT_FLAG_ON_AP_SHUTDOWN (1 << 1)
1596
1597struct ec_params_reboot_ec {
1598 uint8_t cmd;
1599 uint8_t flags;
1600} __packed;
1601
1602
1603
1604
1605
1606
1607
1608#define EC_CMD_GET_PANIC_INFO 0xd3
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630#define EC_CMD_ACPI_READ 0x80
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645#define EC_CMD_ACPI_WRITE 0x81
1646
1647
1648
1649
1650
1651
1652
1653
1654#define EC_CMD_ACPI_QUERY_EVENT 0x84
1655
1656
1657
1658#define EC_ACPI_MEM_VERSION 0x00
1659
1660
1661
1662
1663#define EC_ACPI_MEM_TEST 0x01
1664
1665#define EC_ACPI_MEM_TEST_COMPLIMENT 0x02
1666
1667#define EC_ACPI_MEM_KEYBOARD_BACKLIGHT 0x03
1668
1669
1670#define EC_ACPI_MEM_VERSION_CURRENT 1
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690#define EC_CMD_REBOOT 0xd1
1691
1692
1693
1694
1695
1696
1697
1698
1699#define EC_CMD_RESEND_RESPONSE 0xdb
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711#define EC_CMD_VERSION0 0xdc
1712
1713#endif
1714
1715#endif
1716