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
32
33
34
35
36
37#define EC_PROTO_VERSION 0x00000002
38
39
40#define EC_VER_MASK(version) (1UL << (version))
41
42
43#define EC_LPC_ADDR_ACPI_DATA 0x62
44#define EC_LPC_ADDR_ACPI_CMD 0x66
45
46
47#define EC_LPC_ADDR_HOST_DATA 0x200
48#define EC_LPC_ADDR_HOST_CMD 0x204
49
50
51
52#define EC_LPC_ADDR_HOST_ARGS 0x800
53#define EC_LPC_ADDR_HOST_PARAM 0x804
54
55
56#define EC_LPC_ADDR_HOST_PACKET 0x800
57#define EC_LPC_HOST_PACKET_SIZE 0x100
58
59
60
61#define EC_HOST_CMD_REGION0 0x800
62#define EC_HOST_CMD_REGION1 0x880
63#define EC_HOST_CMD_REGION_SIZE 0x80
64
65
66#define EC_LPC_CMDR_DATA (1 << 0)
67#define EC_LPC_CMDR_PENDING (1 << 1)
68#define EC_LPC_CMDR_BUSY (1 << 2)
69#define EC_LPC_CMDR_CMD (1 << 3)
70#define EC_LPC_CMDR_ACPI_BRST (1 << 4)
71#define EC_LPC_CMDR_SCI (1 << 5)
72#define EC_LPC_CMDR_SMI (1 << 6)
73
74#define EC_LPC_ADDR_MEMMAP 0x900
75#define EC_MEMMAP_SIZE 255
76#define EC_MEMMAP_TEXT_MAX 8
77
78
79#define EC_MEMMAP_TEMP_SENSOR 0x00
80#define EC_MEMMAP_FAN 0x10
81#define EC_MEMMAP_TEMP_SENSOR_B 0x18
82#define EC_MEMMAP_ID 0x20
83#define EC_MEMMAP_ID_VERSION 0x22
84#define EC_MEMMAP_THERMAL_VERSION 0x23
85#define EC_MEMMAP_BATTERY_VERSION 0x24
86#define EC_MEMMAP_SWITCHES_VERSION 0x25
87#define EC_MEMMAP_EVENTS_VERSION 0x26
88#define EC_MEMMAP_HOST_CMD_FLAGS 0x27
89
90#define EC_MEMMAP_SWITCHES 0x30
91
92#define EC_MEMMAP_HOST_EVENTS 0x34
93
94
95#define EC_MEMMAP_BATT_VOLT 0x40
96#define EC_MEMMAP_BATT_RATE 0x44
97#define EC_MEMMAP_BATT_CAP 0x48
98#define EC_MEMMAP_BATT_FLAG 0x4c
99#define EC_MEMMAP_BATT_DCAP 0x50
100#define EC_MEMMAP_BATT_DVLT 0x54
101#define EC_MEMMAP_BATT_LFCC 0x58
102#define EC_MEMMAP_BATT_CCNT 0x5c
103
104#define EC_MEMMAP_BATT_MFGR 0x60
105#define EC_MEMMAP_BATT_MODEL 0x68
106#define EC_MEMMAP_BATT_SERIAL 0x70
107#define EC_MEMMAP_BATT_TYPE 0x78
108#define EC_MEMMAP_ALS 0x80
109
110#define EC_MEMMAP_ACC_STATUS 0x90
111
112#define EC_MEMMAP_ACC_DATA 0x92
113
114
115
116#define EC_MEMMAP_GYRO_DATA 0xa0
117
118
119
120
121
122
123
124#define EC_MEMMAP_NO_ACPI 0xe0
125
126
127#define EC_MEMMAP_ACC_STATUS_SAMPLE_ID_MASK 0x0f
128#define EC_MEMMAP_ACC_STATUS_BUSY_BIT (1 << 4)
129#define EC_MEMMAP_ACC_STATUS_PRESENCE_BIT (1 << 7)
130
131
132#define EC_TEMP_SENSOR_ENTRIES 16
133
134
135
136
137
138#define EC_TEMP_SENSOR_B_ENTRIES 8
139
140
141#define EC_TEMP_SENSOR_NOT_PRESENT 0xff
142#define EC_TEMP_SENSOR_ERROR 0xfe
143#define EC_TEMP_SENSOR_NOT_POWERED 0xfd
144#define EC_TEMP_SENSOR_NOT_CALIBRATED 0xfc
145
146
147
148
149#define EC_TEMP_SENSOR_OFFSET 200
150
151
152
153
154#define EC_ALS_ENTRIES 2
155
156
157
158
159
160
161#define EC_TEMP_SENSOR_DEFAULT (296 - EC_TEMP_SENSOR_OFFSET)
162
163#define EC_FAN_SPEED_ENTRIES 4
164#define EC_FAN_SPEED_NOT_PRESENT 0xffff
165#define EC_FAN_SPEED_STALLED 0xfffe
166
167
168#define EC_BATT_FLAG_AC_PRESENT 0x01
169#define EC_BATT_FLAG_BATT_PRESENT 0x02
170#define EC_BATT_FLAG_DISCHARGING 0x04
171#define EC_BATT_FLAG_CHARGING 0x08
172#define EC_BATT_FLAG_LEVEL_CRITICAL 0x10
173
174
175#define EC_SWITCH_LID_OPEN 0x01
176#define EC_SWITCH_POWER_BUTTON_PRESSED 0x02
177#define EC_SWITCH_WRITE_PROTECT_DISABLED 0x04
178
179#define EC_SWITCH_IGNORE1 0x08
180
181#define EC_SWITCH_DEDICATED_RECOVERY 0x10
182
183#define EC_SWITCH_IGNORE0 0x20
184
185
186
187#define EC_HOST_CMD_FLAG_LPC_ARGS_SUPPORTED 0x01
188
189#define EC_HOST_CMD_FLAG_VERSION_3 0x02
190
191
192#define EC_WIRELESS_SWITCH_ALL ~0x00
193#define EC_WIRELESS_SWITCH_WLAN 0x01
194#define EC_WIRELESS_SWITCH_BLUETOOTH 0x02
195#define EC_WIRELESS_SWITCH_WWAN 0x04
196#define EC_WIRELESS_SWITCH_WLAN_POWER 0x08
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218#define EC_CMD_ACPI_READ 0x0080
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233#define EC_CMD_ACPI_WRITE 0x0081
234
235
236
237
238
239
240
241
242#define EC_CMD_ACPI_BURST_ENABLE 0x0082
243
244
245
246
247
248
249
250#define EC_CMD_ACPI_BURST_DISABLE 0x0083
251
252
253
254
255
256
257
258
259#define EC_CMD_ACPI_QUERY_EVENT 0x0084
260
261
262
263
264#define EC_ACPI_MEM_VERSION 0x00
265
266
267
268
269#define EC_ACPI_MEM_TEST 0x01
270
271#define EC_ACPI_MEM_TEST_COMPLIMENT 0x02
272
273
274#define EC_ACPI_MEM_KEYBOARD_BACKLIGHT 0x03
275
276#define EC_ACPI_MEM_FAN_DUTY 0x04
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293#define EC_ACPI_MEM_TEMP_ID 0x05
294#define EC_ACPI_MEM_TEMP_THRESHOLD 0x06
295#define EC_ACPI_MEM_TEMP_COMMIT 0x07
296
297
298
299
300
301
302#define EC_ACPI_MEM_TEMP_COMMIT_SELECT_MASK (1 << 0)
303#define EC_ACPI_MEM_TEMP_COMMIT_ENABLE_MASK (1 << 1)
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320#define EC_ACPI_MEM_CHARGING_LIMIT 0x08
321
322
323#define EC_ACPI_MEM_CHARGING_LIMIT_STEP_MA 64
324
325#define EC_ACPI_MEM_CHARGING_LIMIT_DISABLED 0xff
326
327
328
329
330
331#define EC_ACPI_MEM_DEVICE_ORIENTATION 0x09
332#define EC_ACPI_MEM_DEVICE_TABLET_MODE 0x01
333
334
335
336
337
338#define EC_ACPI_MEM_MAPPED_BEGIN 0x20
339#define EC_ACPI_MEM_MAPPED_SIZE 0xe0
340
341
342#define EC_ACPI_MEM_VERSION_CURRENT 2
343
344
345
346
347
348
349
350#ifndef __ACPI__
351
352
353
354
355
356#ifndef __packed
357#define __packed __attribute__((packed))
358#endif
359
360#ifndef __aligned
361#define __aligned(x) __attribute__((aligned(x)))
362#endif
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391#ifdef CONFIG_HOSTCMD_ALIGNED
392
393
394
395
396
397#define __ec_align1 __packed
398#define __ec_align2 __packed __aligned(2)
399#define __ec_align4 __packed __aligned(4)
400
401
402
403
404
405
406
407
408
409#define __ec_align_size1 __packed
410
411
412
413
414
415#define __ec_align_offset1 __packed
416#define __ec_align_offset2 __packed __aligned(2)
417
418
419
420
421
422
423
424
425
426#define __ec_todo_packed __packed
427#define __ec_todo_unpacked
428
429#else
430
431
432
433
434
435#define __ec_align1 __packed
436#define __ec_align2 __packed
437#define __ec_align4 __packed
438#define __ec_align_size1 __packed
439#define __ec_align_offset1 __packed
440#define __ec_align_offset2 __packed
441#define __ec_todo_packed __packed
442#define __ec_todo_unpacked
443
444#endif
445
446
447
448#define EC_LPC_STATUS_TO_HOST 0x01
449
450#define EC_LPC_STATUS_FROM_HOST 0x02
451
452#define EC_LPC_STATUS_PROCESSING 0x04
453
454#define EC_LPC_STATUS_LAST_CMD 0x08
455
456#define EC_LPC_STATUS_BURST_MODE 0x10
457
458#define EC_LPC_STATUS_SCI_PENDING 0x20
459
460#define EC_LPC_STATUS_SMI_PENDING 0x40
461
462#define EC_LPC_STATUS_RESERVED 0x80
463
464
465
466
467
468#define EC_LPC_STATUS_BUSY_MASK \
469 (EC_LPC_STATUS_FROM_HOST | EC_LPC_STATUS_PROCESSING)
470
471
472
473
474enum ec_status {
475 EC_RES_SUCCESS = 0,
476 EC_RES_INVALID_COMMAND = 1,
477 EC_RES_ERROR = 2,
478 EC_RES_INVALID_PARAM = 3,
479 EC_RES_ACCESS_DENIED = 4,
480 EC_RES_INVALID_RESPONSE = 5,
481 EC_RES_INVALID_VERSION = 6,
482 EC_RES_INVALID_CHECKSUM = 7,
483 EC_RES_IN_PROGRESS = 8,
484 EC_RES_UNAVAILABLE = 9,
485 EC_RES_TIMEOUT = 10,
486 EC_RES_OVERFLOW = 11,
487 EC_RES_INVALID_HEADER = 12,
488 EC_RES_REQUEST_TRUNCATED = 13,
489 EC_RES_RESPONSE_TOO_BIG = 14,
490 EC_RES_BUS_ERROR = 15,
491 EC_RES_BUSY = 16
492};
493
494
495
496
497
498
499
500
501enum host_event_code {
502 EC_HOST_EVENT_LID_CLOSED = 1,
503 EC_HOST_EVENT_LID_OPEN = 2,
504 EC_HOST_EVENT_POWER_BUTTON = 3,
505 EC_HOST_EVENT_AC_CONNECTED = 4,
506 EC_HOST_EVENT_AC_DISCONNECTED = 5,
507 EC_HOST_EVENT_BATTERY_LOW = 6,
508 EC_HOST_EVENT_BATTERY_CRITICAL = 7,
509 EC_HOST_EVENT_BATTERY = 8,
510 EC_HOST_EVENT_THERMAL_THRESHOLD = 9,
511
512 EC_HOST_EVENT_DEVICE = 10,
513 EC_HOST_EVENT_THERMAL = 11,
514 EC_HOST_EVENT_USB_CHARGER = 12,
515 EC_HOST_EVENT_KEY_PRESSED = 13,
516
517
518
519
520
521 EC_HOST_EVENT_INTERFACE_READY = 14,
522
523 EC_HOST_EVENT_KEYBOARD_RECOVERY = 15,
524
525
526 EC_HOST_EVENT_THERMAL_SHUTDOWN = 16,
527
528 EC_HOST_EVENT_BATTERY_SHUTDOWN = 17,
529
530
531 EC_HOST_EVENT_THROTTLE_START = 18,
532
533 EC_HOST_EVENT_THROTTLE_STOP = 19,
534
535
536 EC_HOST_EVENT_HANG_DETECT = 20,
537
538 EC_HOST_EVENT_HANG_REBOOT = 21,
539
540
541 EC_HOST_EVENT_PD_MCU = 22,
542
543
544 EC_HOST_EVENT_BATTERY_STATUS = 23,
545
546
547 EC_HOST_EVENT_PANIC = 24,
548
549
550 EC_HOST_EVENT_KEYBOARD_FASTBOOT = 25,
551
552
553 EC_HOST_EVENT_RTC = 26,
554
555
556 EC_HOST_EVENT_MKBP = 27,
557
558
559 EC_HOST_EVENT_USB_MUX = 28,
560
561
562 EC_HOST_EVENT_MODE_CHANGE = 29,
563
564
565 EC_HOST_EVENT_KEYBOARD_RECOVERY_HW_REINIT = 30,
566
567
568
569
570
571 EC_HOST_EVENT_EXTENDED = 31,
572
573
574
575
576
577
578
579
580 EC_HOST_EVENT_INVALID = 32
581};
582
583#define EC_HOST_EVENT_MASK(event_code) (1ULL << ((event_code) - 1))
584
585
586struct __ec_align4 ec_lpc_host_args {
587 uint8_t flags;
588 uint8_t command_version;
589 uint8_t data_size;
590
591
592
593
594 uint8_t checksum;
595};
596
597
598
599
600
601
602
603
604
605
606
607#define EC_HOST_ARGS_FLAG_FROM_HOST 0x01
608
609
610
611
612
613
614
615#define EC_HOST_ARGS_FLAG_TO_HOST 0x02
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657#define EC_SPI_FRAME_START 0xec
658
659
660
661
662#define EC_SPI_PAST_END 0xed
663
664
665
666
667
668
669#define EC_SPI_RX_READY 0xf8
670
671
672
673
674
675#define EC_SPI_RECEIVING 0xf9
676
677
678#define EC_SPI_PROCESSING 0xfa
679
680
681
682
683
684#define EC_SPI_RX_BAD_DATA 0xfb
685
686
687
688
689
690
691#define EC_SPI_NOT_READY 0xfc
692
693
694
695
696
697
698#define EC_SPI_OLD_READY 0xfd
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718#define EC_PROTO2_REQUEST_HEADER_BYTES 3
719#define EC_PROTO2_REQUEST_TRAILER_BYTES 1
720#define EC_PROTO2_REQUEST_OVERHEAD (EC_PROTO2_REQUEST_HEADER_BYTES + \
721 EC_PROTO2_REQUEST_TRAILER_BYTES)
722
723#define EC_PROTO2_RESPONSE_HEADER_BYTES 2
724#define EC_PROTO2_RESPONSE_TRAILER_BYTES 1
725#define EC_PROTO2_RESPONSE_OVERHEAD (EC_PROTO2_RESPONSE_HEADER_BYTES + \
726 EC_PROTO2_RESPONSE_TRAILER_BYTES)
727
728
729#define EC_PROTO2_MAX_PARAM_SIZE 0xfc
730
731
732#define EC_PROTO2_MAX_REQUEST_SIZE (EC_PROTO2_REQUEST_OVERHEAD + \
733 EC_PROTO2_MAX_PARAM_SIZE)
734#define EC_PROTO2_MAX_RESPONSE_SIZE (EC_PROTO2_RESPONSE_OVERHEAD + \
735 EC_PROTO2_MAX_PARAM_SIZE)
736
737
738
739
740
741
742
743#define EC_COMMAND_PROTOCOL_3 0xda
744
745#define EC_HOST_REQUEST_VERSION 3
746
747
748struct __ec_align4 ec_host_request {
749
750
751
752
753
754 uint8_t struct_version;
755
756
757
758
759
760 uint8_t checksum;
761
762
763 uint16_t command;
764
765
766 uint8_t command_version;
767
768
769 uint8_t reserved;
770
771
772 uint16_t data_len;
773};
774
775#define EC_HOST_RESPONSE_VERSION 3
776
777
778struct __ec_align4 ec_host_response {
779
780 uint8_t struct_version;
781
782
783
784
785
786 uint8_t checksum;
787
788
789 uint16_t result;
790
791
792 uint16_t data_len;
793
794
795 uint16_t reserved;
796};
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820#define EC_CMD_PROTO_VERSION 0x0000
821
822struct __ec_align4 ec_response_proto_version {
823 uint32_t version;
824};
825
826
827
828
829
830#define EC_CMD_HELLO 0x0001
831
832struct __ec_align4 ec_params_hello {
833 uint32_t in_data;
834};
835
836struct __ec_align4 ec_response_hello {
837 uint32_t out_data;
838};
839
840
841#define EC_CMD_GET_VERSION 0x0002
842
843enum ec_current_image {
844 EC_IMAGE_UNKNOWN = 0,
845 EC_IMAGE_RO,
846 EC_IMAGE_RW
847};
848
849struct __ec_align4 ec_response_get_version {
850
851 char version_string_ro[32];
852 char version_string_rw[32];
853 char reserved[32];
854 uint32_t current_image;
855};
856
857
858#define EC_CMD_READ_TEST 0x0003
859
860struct __ec_align4 ec_params_read_test {
861 uint32_t offset;
862 uint32_t size;
863};
864
865struct __ec_align4 ec_response_read_test {
866 uint32_t data[32];
867};
868
869
870
871
872
873
874#define EC_CMD_GET_BUILD_INFO 0x0004
875
876
877#define EC_CMD_GET_CHIP_INFO 0x0005
878
879struct __ec_align4 ec_response_get_chip_info {
880
881 char vendor[32];
882 char name[32];
883 char revision[32];
884};
885
886
887#define EC_CMD_GET_BOARD_VERSION 0x0006
888
889struct __ec_align2 ec_response_board_version {
890 uint16_t board_version;
891};
892
893
894
895
896
897
898
899
900
901#define EC_CMD_READ_MEMMAP 0x0007
902
903struct __ec_align1 ec_params_read_memmap {
904 uint8_t offset;
905 uint8_t size;
906};
907
908
909#define EC_CMD_GET_CMD_VERSIONS 0x0008
910
911struct __ec_align1 ec_params_get_cmd_versions {
912 uint8_t cmd;
913};
914
915struct __ec_align2 ec_params_get_cmd_versions_v1 {
916 uint16_t cmd;
917};
918
919struct __ec_align4 ec_response_get_cmd_versions {
920
921
922
923
924 uint32_t version_mask;
925};
926
927
928
929
930
931
932
933
934#define EC_CMD_GET_COMMS_STATUS 0x0009
935
936
937enum ec_comms_status {
938 EC_COMMS_STATUS_PROCESSING = 1 << 0,
939};
940
941struct __ec_align4 ec_response_get_comms_status {
942 uint32_t flags;
943};
944
945
946#define EC_CMD_TEST_PROTOCOL 0x000A
947
948
949struct __ec_align4 ec_params_test_protocol {
950 uint32_t ec_result;
951 uint32_t ret_len;
952 uint8_t buf[32];
953};
954
955
956struct __ec_align4 ec_response_test_protocol {
957 uint8_t buf[32];
958};
959
960
961#define EC_CMD_GET_PROTOCOL_INFO 0x000B
962
963
964
965#define EC_PROTOCOL_INFO_IN_PROGRESS_SUPPORTED (1 << 0)
966
967struct __ec_align4 ec_response_get_protocol_info {
968
969
970
971 uint32_t protocol_versions;
972
973
974 uint16_t max_request_packet_size;
975
976
977 uint16_t max_response_packet_size;
978
979
980 uint32_t flags;
981};
982
983
984
985
986
987
988#define EC_GSV_SET 0x80000000
989
990
991
992#define EC_GSV_PARAM_MASK 0x00ffffff
993
994struct __ec_align4 ec_params_get_set_value {
995 uint32_t flags;
996 uint32_t value;
997};
998
999struct __ec_align4 ec_response_get_set_value {
1000 uint32_t flags;
1001 uint32_t value;
1002};
1003
1004
1005#define EC_CMD_GSV_PAUSE_IN_S5 0x000C
1006
1007
1008
1009#define EC_CMD_GET_FEATURES 0x000D
1010
1011
1012enum ec_feature_code {
1013
1014
1015
1016
1017 EC_FEATURE_LIMITED = 0,
1018
1019
1020
1021
1022 EC_FEATURE_FLASH = 1,
1023
1024
1025
1026 EC_FEATURE_PWM_FAN = 2,
1027
1028
1029
1030 EC_FEATURE_PWM_KEYB = 3,
1031
1032
1033
1034 EC_FEATURE_LIGHTBAR = 4,
1035
1036 EC_FEATURE_LED = 5,
1037
1038
1039
1040
1041 EC_FEATURE_MOTION_SENSE = 6,
1042
1043 EC_FEATURE_KEYB = 7,
1044
1045 EC_FEATURE_PSTORE = 8,
1046
1047 EC_FEATURE_PORT80 = 9,
1048
1049
1050
1051
1052 EC_FEATURE_THERMAL = 10,
1053
1054 EC_FEATURE_BKLIGHT_SWITCH = 11,
1055
1056 EC_FEATURE_WIFI_SWITCH = 12,
1057
1058 EC_FEATURE_HOST_EVENTS = 13,
1059
1060 EC_FEATURE_GPIO = 14,
1061
1062 EC_FEATURE_I2C = 15,
1063
1064 EC_FEATURE_CHARGER = 16,
1065
1066 EC_FEATURE_BATTERY = 17,
1067
1068
1069
1070
1071 EC_FEATURE_SMART_BATTERY = 18,
1072
1073 EC_FEATURE_HANG_DETECT = 19,
1074
1075 EC_FEATURE_PMU = 20,
1076
1077 EC_FEATURE_SUB_MCU = 21,
1078
1079 EC_FEATURE_USB_PD = 22,
1080
1081 EC_FEATURE_USB_MUX = 23,
1082
1083 EC_FEATURE_MOTION_SENSE_FIFO = 24,
1084
1085 EC_FEATURE_VSTORE = 25,
1086
1087 EC_FEATURE_USBC_SS_MUX_VIRTUAL = 26,
1088
1089 EC_FEATURE_RTC = 27,
1090
1091 EC_FEATURE_FINGERPRINT = 28,
1092
1093 EC_FEATURE_TOUCHPAD = 29,
1094
1095 EC_FEATURE_RWSIG = 30,
1096
1097 EC_FEATURE_DEVICE_EVENT = 31,
1098
1099 EC_FEATURE_UNIFIED_WAKE_MASKS = 32,
1100};
1101
1102#define EC_FEATURE_MASK_0(event_code) (1UL << (event_code % 32))
1103#define EC_FEATURE_MASK_1(event_code) (1UL << (event_code - 32))
1104struct __ec_align4 ec_response_get_features {
1105 uint32_t flags[2];
1106};
1107
1108
1109
1110#define EC_CMD_GET_SKU_ID 0x000E
1111
1112
1113#define EC_CMD_SET_SKU_ID 0x000F
1114
1115struct __ec_align4 ec_sku_id_info {
1116 uint32_t sku_id;
1117};
1118
1119
1120
1121
1122
1123#define EC_CMD_FLASH_INFO 0x0010
1124#define EC_VER_FLASH_INFO 2
1125
1126
1127struct __ec_align4 ec_response_flash_info {
1128
1129 uint32_t flash_size;
1130
1131
1132
1133
1134 uint32_t write_block_size;
1135
1136
1137
1138
1139 uint32_t erase_block_size;
1140
1141
1142
1143
1144 uint32_t protect_block_size;
1145};
1146
1147
1148
1149#define EC_FLASH_INFO_ERASE_TO_0 (1 << 0)
1150
1151
1152
1153
1154
1155
1156#define EC_FLASH_INFO_SELECT_REQUIRED (1 << 1)
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172struct __ec_align4 ec_response_flash_info_1 {
1173
1174 uint32_t flash_size;
1175 uint32_t write_block_size;
1176 uint32_t erase_block_size;
1177 uint32_t protect_block_size;
1178
1179
1180
1181
1182
1183
1184
1185
1186 uint32_t write_ideal_size;
1187
1188
1189 uint32_t flags;
1190};
1191
1192struct __ec_align4 ec_params_flash_info_2 {
1193
1194 uint16_t num_banks_desc;
1195
1196 uint8_t reserved[2];
1197};
1198
1199struct ec_flash_bank {
1200
1201 uint16_t count;
1202
1203 uint8_t size_exp;
1204
1205 uint8_t write_size_exp;
1206
1207 uint8_t erase_size_exp;
1208
1209 uint8_t protect_size_exp;
1210
1211 uint8_t reserved[2];
1212};
1213
1214struct __ec_align4 ec_response_flash_info_2 {
1215
1216 uint32_t flash_size;
1217
1218 uint32_t flags;
1219
1220 uint32_t write_ideal_size;
1221
1222 uint16_t num_banks_total;
1223
1224 uint16_t num_banks_desc;
1225 struct ec_flash_bank banks[0];
1226};
1227
1228
1229
1230
1231
1232
1233#define EC_CMD_FLASH_READ 0x0011
1234
1235struct __ec_align4 ec_params_flash_read {
1236 uint32_t offset;
1237 uint32_t size;
1238};
1239
1240
1241#define EC_CMD_FLASH_WRITE 0x0012
1242#define EC_VER_FLASH_WRITE 1
1243
1244
1245#define EC_FLASH_WRITE_VER0_SIZE 64
1246
1247struct __ec_align4 ec_params_flash_write {
1248 uint32_t offset;
1249 uint32_t size;
1250
1251};
1252
1253
1254#define EC_CMD_FLASH_ERASE 0x0013
1255
1256
1257struct __ec_align4 ec_params_flash_erase {
1258 uint32_t offset;
1259 uint32_t size;
1260};
1261
1262
1263#define EC_VER_FLASH_WRITE 1
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280enum ec_flash_erase_cmd {
1281 FLASH_ERASE_SECTOR,
1282 FLASH_ERASE_SECTOR_ASYNC,
1283 FLASH_ERASE_GET_RESULT,
1284};
1285
1286struct __ec_align4 ec_params_flash_erase_v1 {
1287
1288 uint8_t cmd;
1289
1290 uint8_t reserved;
1291
1292 uint16_t flag;
1293
1294 struct ec_params_flash_erase params;
1295};
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307#define EC_CMD_FLASH_PROTECT 0x0015
1308#define EC_VER_FLASH_PROTECT 1
1309
1310
1311
1312#define EC_FLASH_PROTECT_RO_AT_BOOT (1 << 0)
1313
1314
1315
1316
1317#define EC_FLASH_PROTECT_RO_NOW (1 << 1)
1318
1319#define EC_FLASH_PROTECT_ALL_NOW (1 << 2)
1320
1321#define EC_FLASH_PROTECT_GPIO_ASSERTED (1 << 3)
1322
1323#define EC_FLASH_PROTECT_ERROR_STUCK (1 << 4)
1324
1325
1326
1327
1328
1329#define EC_FLASH_PROTECT_ERROR_INCONSISTENT (1 << 5)
1330
1331#define EC_FLASH_PROTECT_ALL_AT_BOOT (1 << 6)
1332
1333#define EC_FLASH_PROTECT_RW_AT_BOOT (1 << 7)
1334
1335#define EC_FLASH_PROTECT_RW_NOW (1 << 8)
1336
1337#define EC_FLASH_PROTECT_ROLLBACK_AT_BOOT (1 << 9)
1338
1339#define EC_FLASH_PROTECT_ROLLBACK_NOW (1 << 10)
1340
1341struct __ec_align4 ec_params_flash_protect {
1342 uint32_t mask;
1343 uint32_t flags;
1344};
1345
1346struct __ec_align4 ec_response_flash_protect {
1347
1348 uint32_t flags;
1349
1350
1351
1352
1353
1354 uint32_t valid_flags;
1355
1356 uint32_t writable_flags;
1357};
1358
1359
1360
1361
1362
1363
1364
1365#define EC_CMD_FLASH_REGION_INFO 0x0016
1366#define EC_VER_FLASH_REGION_INFO 1
1367
1368enum ec_flash_region {
1369
1370 EC_FLASH_REGION_RO = 0,
1371
1372 EC_FLASH_REGION_ACTIVE,
1373
1374
1375
1376
1377 EC_FLASH_REGION_WP_RO,
1378
1379 EC_FLASH_REGION_UPDATE,
1380
1381 EC_FLASH_REGION_COUNT,
1382};
1383
1384struct __ec_align4 ec_params_flash_region_info {
1385 uint32_t region;
1386};
1387
1388struct __ec_align4 ec_response_flash_region_info {
1389 uint32_t offset;
1390 uint32_t size;
1391};
1392
1393
1394#define EC_CMD_VBNV_CONTEXT 0x0017
1395#define EC_VER_VBNV_CONTEXT 1
1396#define EC_VBNV_BLOCK_SIZE 16
1397#define EC_VBNV_BLOCK_SIZE_V2 64
1398
1399enum ec_vbnvcontext_op {
1400 EC_VBNV_CONTEXT_OP_READ,
1401 EC_VBNV_CONTEXT_OP_WRITE,
1402};
1403
1404struct __ec_align4 ec_params_vbnvcontext {
1405 uint32_t op;
1406 uint8_t block[EC_VBNV_BLOCK_SIZE_V2];
1407};
1408
1409struct __ec_align4 ec_response_vbnvcontext {
1410 uint8_t block[EC_VBNV_BLOCK_SIZE_V2];
1411};
1412
1413
1414
1415#define EC_CMD_FLASH_SPI_INFO 0x0018
1416
1417struct __ec_align1 ec_response_flash_spi_info {
1418
1419 uint8_t jedec[3];
1420
1421
1422 uint8_t reserved0;
1423
1424
1425 uint8_t mfr_dev_id[2];
1426
1427
1428 uint8_t sr1, sr2;
1429};
1430
1431
1432
1433#define EC_CMD_FLASH_SELECT 0x0019
1434
1435struct __ec_align4 ec_params_flash_select {
1436
1437 uint8_t select;
1438};
1439
1440
1441
1442
1443
1444#define EC_CMD_PWM_GET_FAN_TARGET_RPM 0x0020
1445
1446struct __ec_align4 ec_response_pwm_get_fan_rpm {
1447 uint32_t rpm;
1448};
1449
1450
1451#define EC_CMD_PWM_SET_FAN_TARGET_RPM 0x0021
1452
1453
1454struct __ec_align4 ec_params_pwm_set_fan_target_rpm_v0 {
1455 uint32_t rpm;
1456};
1457
1458
1459struct __ec_align_size1 ec_params_pwm_set_fan_target_rpm_v1 {
1460 uint32_t rpm;
1461 uint8_t fan_idx;
1462};
1463
1464
1465
1466#define EC_CMD_PWM_GET_KEYBOARD_BACKLIGHT 0x0022
1467
1468struct __ec_align1 ec_response_pwm_get_keyboard_backlight {
1469 uint8_t percent;
1470 uint8_t enabled;
1471};
1472
1473
1474
1475#define EC_CMD_PWM_SET_KEYBOARD_BACKLIGHT 0x0023
1476
1477struct __ec_align1 ec_params_pwm_set_keyboard_backlight {
1478 uint8_t percent;
1479};
1480
1481
1482#define EC_CMD_PWM_SET_FAN_DUTY 0x0024
1483
1484
1485struct __ec_align4 ec_params_pwm_set_fan_duty_v0 {
1486 uint32_t percent;
1487};
1488
1489
1490struct __ec_align_size1 ec_params_pwm_set_fan_duty_v1 {
1491 uint32_t percent;
1492 uint8_t fan_idx;
1493};
1494
1495#define EC_CMD_PWM_SET_DUTY 0x0025
1496
1497#define EC_PWM_MAX_DUTY 0xffff
1498
1499enum ec_pwm_type {
1500
1501 EC_PWM_TYPE_GENERIC = 0,
1502
1503 EC_PWM_TYPE_KB_LIGHT,
1504
1505 EC_PWM_TYPE_DISPLAY_LIGHT,
1506 EC_PWM_TYPE_COUNT,
1507};
1508
1509struct __ec_align4 ec_params_pwm_set_duty {
1510 uint16_t duty;
1511 uint8_t pwm_type;
1512 uint8_t index;
1513};
1514
1515#define EC_CMD_PWM_GET_DUTY 0x0026
1516
1517struct __ec_align1 ec_params_pwm_get_duty {
1518 uint8_t pwm_type;
1519 uint8_t index;
1520};
1521
1522struct __ec_align2 ec_response_pwm_get_duty {
1523 uint16_t duty;
1524};
1525
1526
1527
1528
1529
1530
1531
1532
1533#define EC_CMD_LIGHTBAR_CMD 0x0028
1534
1535struct __ec_todo_unpacked rgb_s {
1536 uint8_t r, g, b;
1537};
1538
1539#define LB_BATTERY_LEVELS 4
1540
1541
1542
1543struct __ec_todo_packed lightbar_params_v0 {
1544
1545 int32_t google_ramp_up;
1546 int32_t google_ramp_down;
1547 int32_t s3s0_ramp_up;
1548 int32_t s0_tick_delay[2];
1549 int32_t s0a_tick_delay[2];
1550 int32_t s0s3_ramp_down;
1551 int32_t s3_sleep_for;
1552 int32_t s3_ramp_up;
1553 int32_t s3_ramp_down;
1554
1555
1556 uint8_t new_s0;
1557 uint8_t osc_min[2];
1558 uint8_t osc_max[2];
1559 uint8_t w_ofs[2];
1560
1561
1562 uint8_t bright_bl_off_fixed[2];
1563 uint8_t bright_bl_on_min[2];
1564 uint8_t bright_bl_on_max[2];
1565
1566
1567 uint8_t battery_threshold[LB_BATTERY_LEVELS - 1];
1568
1569
1570 uint8_t s0_idx[2][LB_BATTERY_LEVELS];
1571 uint8_t s3_idx[2][LB_BATTERY_LEVELS];
1572
1573
1574 struct rgb_s color[8];
1575};
1576
1577struct __ec_todo_packed lightbar_params_v1 {
1578
1579 int32_t google_ramp_up;
1580 int32_t google_ramp_down;
1581 int32_t s3s0_ramp_up;
1582 int32_t s0_tick_delay[2];
1583 int32_t s0a_tick_delay[2];
1584 int32_t s0s3_ramp_down;
1585 int32_t s3_sleep_for;
1586 int32_t s3_ramp_up;
1587 int32_t s3_ramp_down;
1588 int32_t s5_ramp_up;
1589 int32_t s5_ramp_down;
1590 int32_t tap_tick_delay;
1591 int32_t tap_gate_delay;
1592 int32_t tap_display_time;
1593
1594
1595 uint8_t tap_pct_red;
1596 uint8_t tap_pct_green;
1597 uint8_t tap_seg_min_on;
1598 uint8_t tap_seg_max_on;
1599 uint8_t tap_seg_osc;
1600 uint8_t tap_idx[3];
1601
1602
1603 uint8_t osc_min[2];
1604 uint8_t osc_max[2];
1605 uint8_t w_ofs[2];
1606
1607
1608 uint8_t bright_bl_off_fixed[2];
1609 uint8_t bright_bl_on_min[2];
1610 uint8_t bright_bl_on_max[2];
1611
1612
1613 uint8_t battery_threshold[LB_BATTERY_LEVELS - 1];
1614
1615
1616 uint8_t s0_idx[2][LB_BATTERY_LEVELS];
1617 uint8_t s3_idx[2][LB_BATTERY_LEVELS];
1618
1619
1620 uint8_t s5_idx;
1621
1622
1623 struct rgb_s color[8];
1624};
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635struct __ec_todo_packed lightbar_params_v2_timing {
1636
1637 int32_t google_ramp_up;
1638 int32_t google_ramp_down;
1639 int32_t s3s0_ramp_up;
1640 int32_t s0_tick_delay[2];
1641 int32_t s0a_tick_delay[2];
1642 int32_t s0s3_ramp_down;
1643 int32_t s3_sleep_for;
1644 int32_t s3_ramp_up;
1645 int32_t s3_ramp_down;
1646 int32_t s5_ramp_up;
1647 int32_t s5_ramp_down;
1648 int32_t tap_tick_delay;
1649 int32_t tap_gate_delay;
1650 int32_t tap_display_time;
1651};
1652
1653struct __ec_todo_packed lightbar_params_v2_tap {
1654
1655 uint8_t tap_pct_red;
1656 uint8_t tap_pct_green;
1657 uint8_t tap_seg_min_on;
1658 uint8_t tap_seg_max_on;
1659 uint8_t tap_seg_osc;
1660 uint8_t tap_idx[3];
1661};
1662
1663struct __ec_todo_packed lightbar_params_v2_oscillation {
1664
1665 uint8_t osc_min[2];
1666 uint8_t osc_max[2];
1667 uint8_t w_ofs[2];
1668};
1669
1670struct __ec_todo_packed lightbar_params_v2_brightness {
1671
1672 uint8_t bright_bl_off_fixed[2];
1673 uint8_t bright_bl_on_min[2];
1674 uint8_t bright_bl_on_max[2];
1675};
1676
1677struct __ec_todo_packed lightbar_params_v2_thresholds {
1678
1679 uint8_t battery_threshold[LB_BATTERY_LEVELS - 1];
1680};
1681
1682struct __ec_todo_packed lightbar_params_v2_colors {
1683
1684 uint8_t s0_idx[2][LB_BATTERY_LEVELS];
1685 uint8_t s3_idx[2][LB_BATTERY_LEVELS];
1686
1687
1688 uint8_t s5_idx;
1689
1690
1691 struct rgb_s color[8];
1692};
1693
1694
1695#define EC_LB_PROG_LEN 192
1696struct __ec_todo_unpacked lightbar_program {
1697 uint8_t size;
1698 uint8_t data[EC_LB_PROG_LEN];
1699};
1700
1701struct __ec_todo_packed ec_params_lightbar {
1702 uint8_t cmd;
1703 union {
1704 struct __ec_todo_unpacked {
1705
1706 } dump, off, on, init, get_seq, get_params_v0, get_params_v1,
1707 version, get_brightness, get_demo, suspend, resume,
1708 get_params_v2_timing, get_params_v2_tap,
1709 get_params_v2_osc, get_params_v2_bright,
1710 get_params_v2_thlds, get_params_v2_colors;
1711
1712 struct __ec_todo_unpacked {
1713 uint8_t num;
1714 } set_brightness, seq, demo;
1715
1716 struct __ec_todo_unpacked {
1717 uint8_t ctrl, reg, value;
1718 } reg;
1719
1720 struct __ec_todo_unpacked {
1721 uint8_t led, red, green, blue;
1722 } set_rgb;
1723
1724 struct __ec_todo_unpacked {
1725 uint8_t led;
1726 } get_rgb;
1727
1728 struct __ec_todo_unpacked {
1729 uint8_t enable;
1730 } manual_suspend_ctrl;
1731
1732 struct lightbar_params_v0 set_params_v0;
1733 struct lightbar_params_v1 set_params_v1;
1734
1735 struct lightbar_params_v2_timing set_v2par_timing;
1736 struct lightbar_params_v2_tap set_v2par_tap;
1737 struct lightbar_params_v2_oscillation set_v2par_osc;
1738 struct lightbar_params_v2_brightness set_v2par_bright;
1739 struct lightbar_params_v2_thresholds set_v2par_thlds;
1740 struct lightbar_params_v2_colors set_v2par_colors;
1741
1742 struct lightbar_program set_program;
1743 };
1744};
1745
1746struct __ec_todo_packed ec_response_lightbar {
1747 union {
1748 struct __ec_todo_unpacked {
1749 struct __ec_todo_unpacked {
1750 uint8_t reg;
1751 uint8_t ic0;
1752 uint8_t ic1;
1753 } vals[23];
1754 } dump;
1755
1756 struct __ec_todo_unpacked {
1757 uint8_t num;
1758 } get_seq, get_brightness, get_demo;
1759
1760 struct lightbar_params_v0 get_params_v0;
1761 struct lightbar_params_v1 get_params_v1;
1762
1763
1764 struct lightbar_params_v2_timing get_params_v2_timing;
1765 struct lightbar_params_v2_tap get_params_v2_tap;
1766 struct lightbar_params_v2_oscillation get_params_v2_osc;
1767 struct lightbar_params_v2_brightness get_params_v2_bright;
1768 struct lightbar_params_v2_thresholds get_params_v2_thlds;
1769 struct lightbar_params_v2_colors get_params_v2_colors;
1770
1771 struct __ec_todo_unpacked {
1772 uint32_t num;
1773 uint32_t flags;
1774 } version;
1775
1776 struct __ec_todo_unpacked {
1777 uint8_t red, green, blue;
1778 } get_rgb;
1779
1780 struct __ec_todo_unpacked {
1781
1782 } off, on, init, set_brightness, seq, reg, set_rgb,
1783 demo, set_params_v0, set_params_v1,
1784 set_program, manual_suspend_ctrl, suspend, resume,
1785 set_v2par_timing, set_v2par_tap,
1786 set_v2par_osc, set_v2par_bright, set_v2par_thlds,
1787 set_v2par_colors;
1788 };
1789};
1790
1791
1792enum lightbar_command {
1793 LIGHTBAR_CMD_DUMP = 0,
1794 LIGHTBAR_CMD_OFF = 1,
1795 LIGHTBAR_CMD_ON = 2,
1796 LIGHTBAR_CMD_INIT = 3,
1797 LIGHTBAR_CMD_SET_BRIGHTNESS = 4,
1798 LIGHTBAR_CMD_SEQ = 5,
1799 LIGHTBAR_CMD_REG = 6,
1800 LIGHTBAR_CMD_SET_RGB = 7,
1801 LIGHTBAR_CMD_GET_SEQ = 8,
1802 LIGHTBAR_CMD_DEMO = 9,
1803 LIGHTBAR_CMD_GET_PARAMS_V0 = 10,
1804 LIGHTBAR_CMD_SET_PARAMS_V0 = 11,
1805 LIGHTBAR_CMD_VERSION = 12,
1806 LIGHTBAR_CMD_GET_BRIGHTNESS = 13,
1807 LIGHTBAR_CMD_GET_RGB = 14,
1808 LIGHTBAR_CMD_GET_DEMO = 15,
1809 LIGHTBAR_CMD_GET_PARAMS_V1 = 16,
1810 LIGHTBAR_CMD_SET_PARAMS_V1 = 17,
1811 LIGHTBAR_CMD_SET_PROGRAM = 18,
1812 LIGHTBAR_CMD_MANUAL_SUSPEND_CTRL = 19,
1813 LIGHTBAR_CMD_SUSPEND = 20,
1814 LIGHTBAR_CMD_RESUME = 21,
1815 LIGHTBAR_CMD_GET_PARAMS_V2_TIMING = 22,
1816 LIGHTBAR_CMD_SET_PARAMS_V2_TIMING = 23,
1817 LIGHTBAR_CMD_GET_PARAMS_V2_TAP = 24,
1818 LIGHTBAR_CMD_SET_PARAMS_V2_TAP = 25,
1819 LIGHTBAR_CMD_GET_PARAMS_V2_OSCILLATION = 26,
1820 LIGHTBAR_CMD_SET_PARAMS_V2_OSCILLATION = 27,
1821 LIGHTBAR_CMD_GET_PARAMS_V2_BRIGHTNESS = 28,
1822 LIGHTBAR_CMD_SET_PARAMS_V2_BRIGHTNESS = 29,
1823 LIGHTBAR_CMD_GET_PARAMS_V2_THRESHOLDS = 30,
1824 LIGHTBAR_CMD_SET_PARAMS_V2_THRESHOLDS = 31,
1825 LIGHTBAR_CMD_GET_PARAMS_V2_COLORS = 32,
1826 LIGHTBAR_CMD_SET_PARAMS_V2_COLORS = 33,
1827 LIGHTBAR_NUM_CMDS
1828};
1829
1830
1831
1832
1833#define EC_CMD_LED_CONTROL 0x0029
1834
1835enum ec_led_id {
1836
1837 EC_LED_ID_BATTERY_LED = 0,
1838
1839
1840
1841
1842 EC_LED_ID_POWER_LED,
1843
1844 EC_LED_ID_ADAPTER_LED,
1845
1846 EC_LED_ID_LEFT_LED,
1847
1848 EC_LED_ID_RIGHT_LED,
1849
1850 EC_LED_ID_RECOVERY_HW_REINIT_LED,
1851
1852 EC_LED_ID_SYSRQ_DEBUG_LED,
1853
1854 EC_LED_ID_COUNT
1855};
1856
1857
1858#define EC_LED_FLAGS_QUERY (1 << 0)
1859#define EC_LED_FLAGS_AUTO (1 << 1)
1860
1861enum ec_led_colors {
1862 EC_LED_COLOR_RED = 0,
1863 EC_LED_COLOR_GREEN,
1864 EC_LED_COLOR_BLUE,
1865 EC_LED_COLOR_YELLOW,
1866 EC_LED_COLOR_WHITE,
1867 EC_LED_COLOR_AMBER,
1868
1869 EC_LED_COLOR_COUNT
1870};
1871
1872struct __ec_align1 ec_params_led_control {
1873 uint8_t led_id;
1874 uint8_t flags;
1875
1876 uint8_t brightness[EC_LED_COLOR_COUNT];
1877};
1878
1879struct __ec_align1 ec_response_led_control {
1880
1881
1882
1883
1884
1885
1886
1887 uint8_t brightness_range[EC_LED_COLOR_COUNT];
1888};
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899#define EC_CMD_VBOOT_HASH 0x002A
1900
1901struct __ec_align4 ec_params_vboot_hash {
1902 uint8_t cmd;
1903 uint8_t hash_type;
1904 uint8_t nonce_size;
1905 uint8_t reserved0;
1906 uint32_t offset;
1907 uint32_t size;
1908 uint8_t nonce_data[64];
1909};
1910
1911struct __ec_align4 ec_response_vboot_hash {
1912 uint8_t status;
1913 uint8_t hash_type;
1914 uint8_t digest_size;
1915 uint8_t reserved0;
1916 uint32_t offset;
1917 uint32_t size;
1918 uint8_t hash_digest[64];
1919};
1920
1921enum ec_vboot_hash_cmd {
1922 EC_VBOOT_HASH_GET = 0,
1923 EC_VBOOT_HASH_ABORT = 1,
1924 EC_VBOOT_HASH_START = 2,
1925 EC_VBOOT_HASH_RECALC = 3,
1926};
1927
1928enum ec_vboot_hash_type {
1929 EC_VBOOT_HASH_TYPE_SHA256 = 0,
1930};
1931
1932enum ec_vboot_hash_status {
1933 EC_VBOOT_HASH_STATUS_NONE = 0,
1934 EC_VBOOT_HASH_STATUS_DONE = 1,
1935 EC_VBOOT_HASH_STATUS_BUSY = 2,
1936};
1937
1938
1939
1940
1941
1942
1943#define EC_VBOOT_HASH_OFFSET_RO 0xfffffffe
1944#define EC_VBOOT_HASH_OFFSET_ACTIVE 0xfffffffd
1945#define EC_VBOOT_HASH_OFFSET_UPDATE 0xfffffffc
1946
1947
1948
1949
1950
1951
1952#define EC_CMD_MOTION_SENSE_CMD 0x002B
1953
1954
1955enum motionsense_command {
1956
1957
1958
1959
1960 MOTIONSENSE_CMD_DUMP = 0,
1961
1962
1963
1964
1965
1966
1967 MOTIONSENSE_CMD_INFO = 1,
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979 MOTIONSENSE_CMD_EC_RATE = 2,
1980
1981
1982
1983
1984
1985 MOTIONSENSE_CMD_SENSOR_ODR = 3,
1986
1987
1988
1989
1990
1991 MOTIONSENSE_CMD_SENSOR_RANGE = 4,
1992
1993
1994
1995
1996
1997
1998
1999
2000 MOTIONSENSE_CMD_KB_WAKE_ANGLE = 5,
2001
2002
2003
2004
2005 MOTIONSENSE_CMD_DATA = 6,
2006
2007
2008
2009
2010 MOTIONSENSE_CMD_FIFO_INFO = 7,
2011
2012
2013
2014
2015
2016 MOTIONSENSE_CMD_FIFO_FLUSH = 8,
2017
2018
2019
2020
2021 MOTIONSENSE_CMD_FIFO_READ = 9,
2022
2023
2024
2025
2026
2027 MOTIONSENSE_CMD_PERFORM_CALIB = 10,
2028
2029
2030
2031
2032
2033
2034
2035 MOTIONSENSE_CMD_SENSOR_OFFSET = 11,
2036
2037
2038
2039
2040
2041 MOTIONSENSE_CMD_LIST_ACTIVITIES = 12,
2042
2043
2044
2045
2046
2047 MOTIONSENSE_CMD_SET_ACTIVITY = 13,
2048
2049
2050
2051
2052 MOTIONSENSE_CMD_LID_ANGLE = 14,
2053
2054
2055
2056
2057
2058
2059 MOTIONSENSE_CMD_FIFO_INT_ENABLE = 15,
2060
2061
2062
2063
2064
2065 MOTIONSENSE_CMD_SPOOF = 16,
2066
2067
2068 MOTIONSENSE_NUM_CMDS
2069};
2070
2071
2072enum motionsensor_type {
2073 MOTIONSENSE_TYPE_ACCEL = 0,
2074 MOTIONSENSE_TYPE_GYRO = 1,
2075 MOTIONSENSE_TYPE_MAG = 2,
2076 MOTIONSENSE_TYPE_PROX = 3,
2077 MOTIONSENSE_TYPE_LIGHT = 4,
2078 MOTIONSENSE_TYPE_ACTIVITY = 5,
2079 MOTIONSENSE_TYPE_BARO = 6,
2080 MOTIONSENSE_TYPE_MAX,
2081};
2082
2083
2084enum motionsensor_location {
2085 MOTIONSENSE_LOC_BASE = 0,
2086 MOTIONSENSE_LOC_LID = 1,
2087 MOTIONSENSE_LOC_MAX,
2088};
2089
2090
2091enum motionsensor_chip {
2092 MOTIONSENSE_CHIP_KXCJ9 = 0,
2093 MOTIONSENSE_CHIP_LSM6DS0 = 1,
2094 MOTIONSENSE_CHIP_BMI160 = 2,
2095 MOTIONSENSE_CHIP_SI1141 = 3,
2096 MOTIONSENSE_CHIP_SI1142 = 4,
2097 MOTIONSENSE_CHIP_SI1143 = 5,
2098 MOTIONSENSE_CHIP_KX022 = 6,
2099 MOTIONSENSE_CHIP_L3GD20H = 7,
2100 MOTIONSENSE_CHIP_BMA255 = 8,
2101 MOTIONSENSE_CHIP_BMP280 = 9,
2102 MOTIONSENSE_CHIP_OPT3001 = 10,
2103};
2104
2105struct __ec_todo_packed ec_response_motion_sensor_data {
2106
2107 uint8_t flags;
2108
2109 uint8_t sensor_num;
2110
2111 union {
2112 int16_t data[3];
2113 struct __ec_todo_packed {
2114 uint16_t reserved;
2115 uint32_t timestamp;
2116 };
2117 struct __ec_todo_unpacked {
2118 uint8_t activity;
2119 uint8_t state;
2120 int16_t add_info[2];
2121 };
2122 };
2123};
2124
2125
2126struct __ec_todo_packed ec_response_motion_sense_fifo_info {
2127
2128 uint16_t size;
2129
2130 uint16_t count;
2131
2132 uint32_t timestamp;
2133
2134 uint16_t total_lost;
2135
2136 uint16_t lost[0];
2137};
2138
2139struct __ec_todo_packed ec_response_motion_sense_fifo_data {
2140 uint32_t number_data;
2141 struct ec_response_motion_sensor_data data[0];
2142};
2143
2144
2145enum motionsensor_activity {
2146 MOTIONSENSE_ACTIVITY_RESERVED = 0,
2147 MOTIONSENSE_ACTIVITY_SIG_MOTION = 1,
2148 MOTIONSENSE_ACTIVITY_DOUBLE_TAP = 2,
2149};
2150
2151struct __ec_todo_unpacked ec_motion_sense_activity {
2152 uint8_t sensor_num;
2153 uint8_t activity;
2154 uint8_t enable;
2155 uint8_t reserved;
2156 uint16_t parameters[3];
2157};
2158
2159
2160#define MOTIONSENSE_MODULE_FLAG_ACTIVE (1<<0)
2161
2162
2163#define MOTIONSENSE_SENSOR_FLAG_PRESENT (1<<0)
2164
2165
2166
2167
2168
2169#define MOTIONSENSE_SENSOR_FLAG_FLUSH (1<<0)
2170#define MOTIONSENSE_SENSOR_FLAG_TIMESTAMP (1<<1)
2171#define MOTIONSENSE_SENSOR_FLAG_WAKEUP (1<<2)
2172#define MOTIONSENSE_SENSOR_FLAG_TABLET_MODE (1<<3)
2173
2174
2175
2176
2177
2178
2179#define EC_MOTION_SENSE_NO_VALUE -1
2180
2181#define EC_MOTION_SENSE_INVALID_CALIB_TEMP 0x8000
2182
2183
2184
2185#define MOTION_SENSE_SET_OFFSET 1
2186
2187#define LID_ANGLE_UNRELIABLE 500
2188
2189enum motionsense_spoof_mode {
2190
2191 MOTIONSENSE_SPOOF_MODE_DISABLE = 0,
2192
2193
2194 MOTIONSENSE_SPOOF_MODE_CUSTOM,
2195
2196
2197 MOTIONSENSE_SPOOF_MODE_LOCK_CURRENT,
2198
2199
2200 MOTIONSENSE_SPOOF_MODE_QUERY,
2201};
2202
2203struct __ec_todo_packed ec_params_motion_sense {
2204 uint8_t cmd;
2205 union {
2206
2207 struct __ec_todo_unpacked {
2208
2209
2210
2211
2212
2213 uint8_t max_sensor_count;
2214 } dump;
2215
2216
2217
2218
2219 struct __ec_todo_unpacked {
2220
2221
2222
2223 int16_t data;
2224 } kb_wake_angle;
2225
2226
2227
2228 struct __ec_todo_unpacked {
2229 uint8_t sensor_num;
2230 } info, info_3, data, fifo_flush, perform_calib,
2231 list_activities;
2232
2233
2234
2235
2236
2237 struct __ec_todo_unpacked {
2238 uint8_t sensor_num;
2239
2240
2241 uint8_t roundup;
2242
2243 uint16_t reserved;
2244
2245
2246 int32_t data;
2247 } ec_rate, sensor_odr, sensor_range;
2248
2249
2250 struct __ec_todo_packed {
2251 uint8_t sensor_num;
2252
2253
2254
2255
2256
2257
2258 uint16_t flags;
2259
2260
2261
2262
2263
2264
2265
2266 int16_t temp;
2267
2268
2269
2270
2271
2272
2273
2274
2275 int16_t offset[3];
2276 } sensor_offset;
2277
2278
2279 struct __ec_todo_unpacked {
2280 } fifo_info;
2281
2282
2283 struct __ec_todo_unpacked {
2284
2285
2286
2287
2288 uint32_t max_data_vector;
2289 } fifo_read;
2290
2291 struct ec_motion_sense_activity set_activity;
2292
2293
2294 struct __ec_todo_unpacked {
2295 } lid_angle;
2296
2297
2298 struct __ec_todo_unpacked {
2299
2300
2301
2302
2303 int8_t enable;
2304 } fifo_int_enable;
2305
2306
2307 struct __ec_todo_packed {
2308 uint8_t sensor_id;
2309
2310
2311 uint8_t spoof_enable;
2312
2313
2314 uint8_t reserved;
2315
2316
2317 int16_t components[3];
2318 } spoof;
2319 };
2320};
2321
2322struct __ec_todo_packed ec_response_motion_sense {
2323 union {
2324
2325 struct __ec_todo_unpacked {
2326
2327 uint8_t module_flags;
2328
2329
2330 uint8_t sensor_count;
2331
2332
2333
2334
2335
2336 struct ec_response_motion_sensor_data sensor[0];
2337 } dump;
2338
2339
2340 struct __ec_todo_unpacked {
2341
2342 uint8_t type;
2343
2344
2345 uint8_t location;
2346
2347
2348 uint8_t chip;
2349 } info;
2350
2351
2352 struct __ec_todo_unpacked {
2353
2354 uint8_t type;
2355
2356
2357 uint8_t location;
2358
2359
2360 uint8_t chip;
2361
2362
2363 uint32_t min_frequency;
2364
2365
2366 uint32_t max_frequency;
2367
2368
2369 uint32_t fifo_max_event_count;
2370 } info_3;
2371
2372
2373 struct ec_response_motion_sensor_data data;
2374
2375
2376
2377
2378
2379
2380
2381
2382 struct __ec_todo_unpacked {
2383
2384 int32_t ret;
2385 } ec_rate, sensor_odr, sensor_range, kb_wake_angle,
2386 fifo_int_enable, spoof;
2387
2388
2389 struct __ec_todo_unpacked {
2390 int16_t temp;
2391 int16_t offset[3];
2392 } sensor_offset, perform_calib;
2393
2394 struct ec_response_motion_sense_fifo_info fifo_info, fifo_flush;
2395
2396 struct ec_response_motion_sense_fifo_data fifo_read;
2397
2398 struct __ec_todo_packed {
2399 uint16_t reserved;
2400 uint32_t enabled;
2401 uint32_t disabled;
2402 } list_activities;
2403
2404 struct __ec_todo_unpacked {
2405 } set_activity;
2406
2407
2408 struct __ec_todo_unpacked {
2409
2410
2411
2412
2413 uint16_t value;
2414 } lid_angle;
2415 };
2416};
2417
2418
2419
2420
2421
2422#define EC_CMD_FORCE_LID_OPEN 0x002C
2423
2424struct __ec_align1 ec_params_force_lid_open {
2425 uint8_t enabled;
2426};
2427
2428
2429
2430#define EC_CMD_CONFIG_POWER_BUTTON 0x002D
2431
2432enum ec_config_power_button_flags {
2433
2434 EC_POWER_BUTTON_ENABLE_PULSE = (1 << 0),
2435};
2436
2437struct __ec_align1 ec_params_config_power_button {
2438
2439 uint8_t flags;
2440};
2441
2442
2443
2444
2445
2446#define EC_CMD_USB_CHARGE_SET_MODE 0x0030
2447
2448struct __ec_align1 ec_params_usb_charge_set_mode {
2449 uint8_t usb_port_id;
2450 uint8_t mode;
2451};
2452
2453
2454
2455
2456
2457#define EC_PSTORE_SIZE_MAX 64
2458
2459
2460#define EC_CMD_PSTORE_INFO 0x0040
2461
2462struct __ec_align4 ec_response_pstore_info {
2463
2464 uint32_t pstore_size;
2465
2466 uint32_t access_size;
2467};
2468
2469
2470
2471
2472
2473
2474#define EC_CMD_PSTORE_READ 0x0041
2475
2476struct __ec_align4 ec_params_pstore_read {
2477 uint32_t offset;
2478 uint32_t size;
2479};
2480
2481
2482#define EC_CMD_PSTORE_WRITE 0x0042
2483
2484struct __ec_align4 ec_params_pstore_write {
2485 uint32_t offset;
2486 uint32_t size;
2487 uint8_t data[EC_PSTORE_SIZE_MAX];
2488};
2489
2490
2491
2492
2493
2494struct __ec_align4 ec_params_rtc {
2495 uint32_t time;
2496};
2497
2498struct __ec_align4 ec_response_rtc {
2499 uint32_t time;
2500};
2501
2502
2503#define EC_CMD_RTC_GET_VALUE 0x0044
2504#define EC_CMD_RTC_GET_ALARM 0x0045
2505
2506
2507#define EC_CMD_RTC_SET_VALUE 0x0046
2508#define EC_CMD_RTC_SET_ALARM 0x0047
2509
2510
2511#define EC_RTC_ALARM_CLEAR 0
2512
2513
2514
2515
2516
2517#define EC_PORT80_SIZE_MAX 32
2518
2519
2520#define EC_CMD_PORT80_LAST_BOOT 0x0048
2521#define EC_CMD_PORT80_READ 0x0048
2522
2523enum ec_port80_subcmd {
2524 EC_PORT80_GET_INFO = 0,
2525 EC_PORT80_READ_BUFFER,
2526};
2527
2528struct __ec_todo_packed ec_params_port80_read {
2529 uint16_t subcmd;
2530 union {
2531 struct __ec_todo_unpacked {
2532 uint32_t offset;
2533 uint32_t num_entries;
2534 } read_buffer;
2535 };
2536};
2537
2538struct __ec_todo_packed ec_response_port80_read {
2539 union {
2540 struct __ec_todo_unpacked {
2541 uint32_t writes;
2542 uint32_t history_size;
2543 uint32_t last_boot;
2544 } get_info;
2545 struct __ec_todo_unpacked {
2546 uint16_t codes[EC_PORT80_SIZE_MAX];
2547 } data;
2548 };
2549};
2550
2551struct __ec_align2 ec_response_port80_last_boot {
2552 uint16_t code;
2553};
2554
2555
2556
2557
2558
2559#define EC_VSTORE_SLOT_SIZE 64
2560
2561
2562#define EC_VSTORE_SLOT_MAX 32
2563
2564
2565#define EC_CMD_VSTORE_INFO 0x0049
2566struct __ec_align_size1 ec_response_vstore_info {
2567
2568 uint32_t slot_locked;
2569
2570 uint8_t slot_count;
2571};
2572
2573
2574
2575
2576
2577
2578#define EC_CMD_VSTORE_READ 0x004A
2579
2580struct __ec_align1 ec_params_vstore_read {
2581 uint8_t slot;
2582};
2583
2584struct __ec_align1 ec_response_vstore_read {
2585 uint8_t data[EC_VSTORE_SLOT_SIZE];
2586};
2587
2588
2589
2590
2591#define EC_CMD_VSTORE_WRITE 0x004B
2592
2593struct __ec_align1 ec_params_vstore_write {
2594 uint8_t slot;
2595 uint8_t data[EC_VSTORE_SLOT_SIZE];
2596};
2597
2598
2599
2600
2601
2602
2603
2604
2605#define EC_CMD_THERMAL_SET_THRESHOLD 0x0050
2606#define EC_CMD_THERMAL_GET_THRESHOLD 0x0051
2607
2608
2609
2610
2611
2612
2613struct __ec_align2 ec_params_thermal_set_threshold {
2614 uint8_t sensor_type;
2615 uint8_t threshold_id;
2616 uint16_t value;
2617};
2618
2619
2620struct __ec_align1 ec_params_thermal_get_threshold {
2621 uint8_t sensor_type;
2622 uint8_t threshold_id;
2623};
2624
2625struct __ec_align2 ec_response_thermal_get_threshold {
2626 uint16_t value;
2627};
2628
2629
2630
2631enum ec_temp_thresholds {
2632 EC_TEMP_THRESH_WARN = 0,
2633 EC_TEMP_THRESH_HIGH,
2634 EC_TEMP_THRESH_HALT,
2635
2636 EC_TEMP_THRESH_COUNT
2637};
2638
2639
2640
2641
2642
2643
2644
2645
2646struct __ec_align4 ec_thermal_config {
2647 uint32_t temp_host[EC_TEMP_THRESH_COUNT];
2648 uint32_t temp_fan_off;
2649 uint32_t temp_fan_max;
2650};
2651
2652
2653struct __ec_align4 ec_params_thermal_get_threshold_v1 {
2654 uint32_t sensor_num;
2655};
2656
2657
2658
2659
2660struct __ec_align4 ec_params_thermal_set_threshold_v1 {
2661 uint32_t sensor_num;
2662 struct ec_thermal_config cfg;
2663};
2664
2665
2666
2667
2668
2669#define EC_CMD_THERMAL_AUTO_FAN_CTRL 0x0052
2670
2671
2672struct __ec_align1 ec_params_auto_fan_ctrl_v1 {
2673 uint8_t fan_idx;
2674};
2675
2676
2677#define EC_CMD_TMP006_GET_CALIBRATION 0x0053
2678#define EC_CMD_TMP006_SET_CALIBRATION 0x0054
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690struct __ec_align1 ec_params_tmp006_get_calibration {
2691 uint8_t index;
2692};
2693
2694
2695struct __ec_align4 ec_response_tmp006_get_calibration_v0 {
2696 float s0;
2697 float b0;
2698 float b1;
2699 float b2;
2700};
2701
2702struct __ec_align4 ec_params_tmp006_set_calibration_v0 {
2703 uint8_t index;
2704 uint8_t reserved[3];
2705 float s0;
2706 float b0;
2707 float b1;
2708 float b2;
2709};
2710
2711
2712struct __ec_align4 ec_response_tmp006_get_calibration_v1 {
2713 uint8_t algorithm;
2714 uint8_t num_params;
2715 uint8_t reserved[2];
2716 float val[0];
2717};
2718
2719struct __ec_align4 ec_params_tmp006_set_calibration_v1 {
2720 uint8_t index;
2721 uint8_t algorithm;
2722 uint8_t num_params;
2723 uint8_t reserved;
2724 float val[0];
2725};
2726
2727
2728
2729#define EC_CMD_TMP006_GET_RAW 0x0055
2730
2731struct __ec_align1 ec_params_tmp006_get_raw {
2732 uint8_t index;
2733};
2734
2735struct __ec_align4 ec_response_tmp006_get_raw {
2736 int32_t t;
2737 int32_t v;
2738};
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753#define EC_CMD_MKBP_STATE 0x0060
2754
2755
2756
2757
2758#define EC_CMD_MKBP_INFO 0x0061
2759
2760struct __ec_align_size1 ec_response_mkbp_info {
2761 uint32_t rows;
2762 uint32_t cols;
2763
2764 uint8_t reserved;
2765};
2766
2767struct __ec_align1 ec_params_mkbp_info {
2768 uint8_t info_type;
2769 uint8_t event_type;
2770};
2771
2772enum ec_mkbp_info_type {
2773
2774
2775
2776
2777
2778 EC_MKBP_INFO_KBD = 0,
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789 EC_MKBP_INFO_SUPPORTED = 1,
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808 EC_MKBP_INFO_CURRENT = 2,
2809};
2810
2811
2812#define EC_CMD_MKBP_SIMULATE_KEY 0x0062
2813
2814struct __ec_align1 ec_params_mkbp_simulate_key {
2815 uint8_t col;
2816 uint8_t row;
2817 uint8_t pressed;
2818};
2819
2820
2821#define EC_CMD_MKBP_SET_CONFIG 0x0064
2822#define EC_CMD_MKBP_GET_CONFIG 0x0065
2823
2824
2825enum mkbp_config_flags {
2826 EC_MKBP_FLAGS_ENABLE = 1,
2827};
2828
2829enum mkbp_config_valid {
2830 EC_MKBP_VALID_SCAN_PERIOD = 1 << 0,
2831 EC_MKBP_VALID_POLL_TIMEOUT = 1 << 1,
2832 EC_MKBP_VALID_MIN_POST_SCAN_DELAY = 1 << 3,
2833 EC_MKBP_VALID_OUTPUT_SETTLE = 1 << 4,
2834 EC_MKBP_VALID_DEBOUNCE_DOWN = 1 << 5,
2835 EC_MKBP_VALID_DEBOUNCE_UP = 1 << 6,
2836 EC_MKBP_VALID_FIFO_MAX_DEPTH = 1 << 7,
2837};
2838
2839
2840
2841
2842
2843
2844
2845struct __ec_align_size1 ec_mkbp_config {
2846 uint32_t valid_mask;
2847 uint8_t flags;
2848 uint8_t valid_flags;
2849 uint16_t scan_period_us;
2850
2851 uint32_t poll_timeout_us;
2852
2853
2854
2855
2856
2857 uint16_t min_post_scan_delay_us;
2858
2859 uint16_t output_settle_us;
2860 uint16_t debounce_down_us;
2861 uint16_t debounce_up_us;
2862
2863 uint8_t fifo_max_depth;
2864};
2865
2866struct __ec_align_size1 ec_params_mkbp_set_config {
2867 struct ec_mkbp_config config;
2868};
2869
2870struct __ec_align_size1 ec_response_mkbp_get_config {
2871 struct ec_mkbp_config config;
2872};
2873
2874
2875#define EC_CMD_KEYSCAN_SEQ_CTRL 0x0066
2876
2877enum ec_keyscan_seq_cmd {
2878 EC_KEYSCAN_SEQ_STATUS = 0,
2879 EC_KEYSCAN_SEQ_CLEAR = 1,
2880 EC_KEYSCAN_SEQ_ADD = 2,
2881 EC_KEYSCAN_SEQ_START = 3,
2882 EC_KEYSCAN_SEQ_COLLECT = 4,
2883};
2884
2885enum ec_collect_flags {
2886
2887
2888
2889
2890 EC_KEYSCAN_SEQ_FLAG_DONE = 1 << 0,
2891};
2892
2893struct __ec_align1 ec_collect_item {
2894 uint8_t flags;
2895};
2896
2897struct __ec_todo_packed ec_params_keyscan_seq_ctrl {
2898 uint8_t cmd;
2899 union {
2900 struct __ec_align1 {
2901 uint8_t active;
2902 uint8_t num_items;
2903
2904 uint8_t cur_item;
2905 } status;
2906 struct __ec_todo_unpacked {
2907
2908
2909
2910
2911 uint32_t time_us;
2912 uint8_t scan[0];
2913 } add;
2914 struct __ec_align1 {
2915 uint8_t start_item;
2916 uint8_t num_items;
2917 } collect;
2918 };
2919};
2920
2921struct __ec_todo_packed ec_result_keyscan_seq_ctrl {
2922 union {
2923 struct __ec_todo_unpacked {
2924 uint8_t num_items;
2925
2926 struct ec_collect_item item[0];
2927 } collect;
2928 };
2929};
2930
2931
2932
2933
2934
2935
2936#define EC_CMD_GET_NEXT_EVENT 0x0067
2937
2938enum ec_mkbp_event {
2939
2940 EC_MKBP_EVENT_KEY_MATRIX = 0,
2941
2942
2943 EC_MKBP_EVENT_HOST_EVENT = 1,
2944
2945
2946 EC_MKBP_EVENT_SENSOR_FIFO = 2,
2947
2948
2949 EC_MKBP_EVENT_BUTTON = 3,
2950
2951
2952 EC_MKBP_EVENT_SWITCH = 4,
2953
2954
2955 EC_MKBP_EVENT_FINGERPRINT = 5,
2956
2957
2958
2959
2960
2961 EC_MKBP_EVENT_SYSRQ = 6,
2962
2963
2964 EC_MKBP_EVENT_COUNT,
2965};
2966
2967union __ec_align_offset1 ec_response_get_next_data {
2968 uint8_t key_matrix[13];
2969
2970
2971 uint32_t host_event;
2972
2973 struct __ec_todo_unpacked {
2974
2975 uint8_t reserved[3];
2976 struct ec_response_motion_sense_fifo_info info;
2977 } sensor_fifo;
2978
2979 uint32_t buttons;
2980
2981 uint32_t switches;
2982
2983 uint32_t fp_events;
2984
2985 uint32_t sysrq;
2986};
2987
2988struct __ec_align1 ec_response_get_next_event {
2989 uint8_t event_type;
2990
2991 union ec_response_get_next_data data;
2992};
2993
2994
2995
2996#define EC_MKBP_POWER_BUTTON 0
2997#define EC_MKBP_VOL_UP 1
2998#define EC_MKBP_VOL_DOWN 2
2999#define EC_MKBP_RECOVERY 3
3000
3001
3002#define EC_MKBP_LID_OPEN 0
3003#define EC_MKBP_TABLET_MODE 1
3004
3005
3006#define EC_CMD_KEYBOARD_FACTORY_TEST 0x0068
3007
3008struct __ec_align2 ec_response_keyboard_factory_test {
3009 uint16_t shorted;
3010};
3011
3012
3013#define EC_MKBP_FP_RAW_EVENT(fp_events) ((fp_events) & 0x00FFFFFF)
3014#define EC_MKBP_FP_FINGER_DOWN (1 << 29)
3015#define EC_MKBP_FP_FINGER_UP (1 << 30)
3016#define EC_MKBP_FP_IMAGE_READY (1 << 31)
3017
3018
3019
3020
3021
3022#define EC_CMD_TEMP_SENSOR_GET_INFO 0x0070
3023
3024struct __ec_align1 ec_params_temp_sensor_get_info {
3025 uint8_t id;
3026};
3027
3028struct __ec_align1 ec_response_temp_sensor_get_info {
3029 char sensor_name[32];
3030 uint8_t sensor_type;
3031};
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050struct __ec_align4 ec_params_host_event_mask {
3051 uint32_t mask;
3052};
3053
3054struct __ec_align4 ec_response_host_event_mask {
3055 uint32_t mask;
3056};
3057
3058
3059#define EC_CMD_HOST_EVENT_GET_B 0x0087
3060#define EC_CMD_HOST_EVENT_GET_SMI_MASK 0x0088
3061#define EC_CMD_HOST_EVENT_GET_SCI_MASK 0x0089
3062#define EC_CMD_HOST_EVENT_GET_WAKE_MASK 0x008D
3063
3064
3065#define EC_CMD_HOST_EVENT_SET_SMI_MASK 0x008A
3066#define EC_CMD_HOST_EVENT_SET_SCI_MASK 0x008B
3067#define EC_CMD_HOST_EVENT_CLEAR 0x008C
3068#define EC_CMD_HOST_EVENT_SET_WAKE_MASK 0x008E
3069#define EC_CMD_HOST_EVENT_CLEAR_B 0x008F
3070
3071
3072
3073
3074
3075
3076struct __ec_align4 ec_params_host_event {
3077
3078
3079 uint8_t action;
3080
3081
3082
3083
3084
3085 uint8_t mask_type;
3086
3087
3088 uint16_t reserved;
3089
3090
3091 uint64_t value;
3092};
3093
3094
3095
3096
3097
3098
3099struct __ec_align4 ec_response_host_event {
3100
3101
3102 uint64_t value;
3103};
3104
3105enum ec_host_event_action {
3106
3107
3108
3109
3110 EC_HOST_EVENT_GET,
3111
3112
3113 EC_HOST_EVENT_SET,
3114
3115
3116 EC_HOST_EVENT_CLEAR,
3117};
3118
3119enum ec_host_event_mask_type {
3120
3121
3122 EC_HOST_EVENT_MAIN,
3123
3124
3125 EC_HOST_EVENT_B,
3126
3127
3128 EC_HOST_EVENT_SCI_MASK,
3129
3130
3131 EC_HOST_EVENT_SMI_MASK,
3132
3133
3134 EC_HOST_EVENT_ALWAYS_REPORT_MASK,
3135
3136
3137 EC_HOST_EVENT_ACTIVE_WAKE_MASK,
3138
3139
3140 EC_HOST_EVENT_LAZY_WAKE_MASK_S0IX,
3141
3142
3143 EC_HOST_EVENT_LAZY_WAKE_MASK_S3,
3144
3145
3146 EC_HOST_EVENT_LAZY_WAKE_MASK_S5,
3147};
3148
3149#define EC_CMD_HOST_EVENT 0x00A4
3150
3151
3152
3153
3154
3155#define EC_CMD_SWITCH_ENABLE_BKLIGHT 0x0090
3156
3157struct __ec_align1 ec_params_switch_enable_backlight {
3158 uint8_t enabled;
3159};
3160
3161
3162#define EC_CMD_SWITCH_ENABLE_WIRELESS 0x0091
3163#define EC_VER_SWITCH_ENABLE_WIRELESS 1
3164
3165
3166struct __ec_align1 ec_params_switch_enable_wireless_v0 {
3167 uint8_t enabled;
3168};
3169
3170
3171struct __ec_align1 ec_params_switch_enable_wireless_v1 {
3172
3173 uint8_t now_flags;
3174
3175
3176 uint8_t now_mask;
3177
3178
3179
3180
3181
3182
3183 uint8_t suspend_flags;
3184
3185
3186 uint8_t suspend_mask;
3187};
3188
3189
3190struct __ec_align1 ec_response_switch_enable_wireless_v1 {
3191
3192 uint8_t now_flags;
3193
3194
3195 uint8_t suspend_flags;
3196};
3197
3198
3199
3200
3201
3202#define EC_CMD_GPIO_SET 0x0092
3203
3204struct __ec_align1 ec_params_gpio_set {
3205 char name[32];
3206 uint8_t val;
3207};
3208
3209
3210#define EC_CMD_GPIO_GET 0x0093
3211
3212
3213struct __ec_align1 ec_params_gpio_get {
3214 char name[32];
3215};
3216
3217struct __ec_align1 ec_response_gpio_get {
3218 uint8_t val;
3219};
3220
3221
3222struct __ec_align1 ec_params_gpio_get_v1 {
3223 uint8_t subcmd;
3224 union {
3225 struct __ec_align1 {
3226 char name[32];
3227 } get_value_by_name;
3228 struct __ec_align1 {
3229 uint8_t index;
3230 } get_info;
3231 };
3232};
3233
3234struct __ec_todo_packed ec_response_gpio_get_v1 {
3235 union {
3236 struct __ec_align1 {
3237 uint8_t val;
3238 } get_value_by_name, get_count;
3239 struct __ec_todo_unpacked {
3240 uint8_t val;
3241 char name[32];
3242 uint32_t flags;
3243 } get_info;
3244 };
3245};
3246
3247enum gpio_get_subcmd {
3248 EC_GPIO_GET_BY_NAME = 0,
3249 EC_GPIO_GET_COUNT = 1,
3250 EC_GPIO_GET_INFO = 2,
3251};
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264#define EC_CMD_I2C_READ 0x0094
3265
3266struct __ec_align_size1 ec_params_i2c_read {
3267 uint16_t addr;
3268 uint8_t read_size;
3269 uint8_t port;
3270 uint8_t offset;
3271};
3272
3273struct __ec_align2 ec_response_i2c_read {
3274 uint16_t data;
3275};
3276
3277
3278#define EC_CMD_I2C_WRITE 0x0095
3279
3280struct __ec_align_size1 ec_params_i2c_write {
3281 uint16_t data;
3282 uint16_t addr;
3283 uint8_t write_size;
3284 uint8_t port;
3285 uint8_t offset;
3286};
3287
3288
3289
3290
3291
3292
3293
3294#define EC_CMD_CHARGE_CONTROL 0x0096
3295#define EC_VER_CHARGE_CONTROL 1
3296
3297enum ec_charge_control_mode {
3298 CHARGE_CONTROL_NORMAL = 0,
3299 CHARGE_CONTROL_IDLE,
3300 CHARGE_CONTROL_DISCHARGE,
3301};
3302
3303struct __ec_align4 ec_params_charge_control {
3304 uint32_t mode;
3305};
3306
3307
3308
3309
3310
3311#define EC_CMD_CONSOLE_SNAPSHOT 0x0097
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325#define EC_CMD_CONSOLE_READ 0x0098
3326
3327enum ec_console_read_subcmd {
3328 CONSOLE_READ_NEXT = 0,
3329 CONSOLE_READ_RECENT
3330};
3331
3332struct __ec_align1 ec_params_console_read_v1 {
3333 uint8_t subcmd;
3334};
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345#define EC_CMD_BATTERY_CUT_OFF 0x0099
3346
3347#define EC_BATTERY_CUTOFF_FLAG_AT_SHUTDOWN (1 << 0)
3348
3349struct __ec_align1 ec_params_battery_cutoff {
3350 uint8_t flags;
3351};
3352
3353
3354
3355
3356
3357
3358
3359#define EC_CMD_USB_MUX 0x009A
3360
3361struct __ec_align1 ec_params_usb_mux {
3362 uint8_t mux;
3363};
3364
3365
3366
3367
3368enum ec_ldo_state {
3369 EC_LDO_STATE_OFF = 0,
3370 EC_LDO_STATE_ON = 1,
3371};
3372
3373
3374
3375
3376#define EC_CMD_LDO_SET 0x009B
3377
3378struct __ec_align1 ec_params_ldo_set {
3379 uint8_t index;
3380 uint8_t state;
3381};
3382
3383
3384
3385
3386#define EC_CMD_LDO_GET 0x009C
3387
3388struct __ec_align1 ec_params_ldo_get {
3389 uint8_t index;
3390};
3391
3392struct __ec_align1 ec_response_ldo_get {
3393 uint8_t state;
3394};
3395
3396
3397
3398
3399
3400
3401
3402#define EC_CMD_POWER_INFO 0x009D
3403
3404struct __ec_align4 ec_response_power_info {
3405 uint32_t usb_dev_type;
3406 uint16_t voltage_ac;
3407 uint16_t voltage_system;
3408 uint16_t current_system;
3409 uint16_t usb_current_limit;
3410};
3411
3412
3413
3414
3415#define EC_CMD_I2C_PASSTHRU 0x009E
3416
3417
3418#define EC_I2C_FLAG_READ (1 << 15)
3419
3420
3421#define EC_I2C_ADDR_MASK 0x3ff
3422
3423#define EC_I2C_STATUS_NAK (1 << 0)
3424#define EC_I2C_STATUS_TIMEOUT (1 << 1)
3425
3426
3427#define EC_I2C_STATUS_ERROR (EC_I2C_STATUS_NAK | EC_I2C_STATUS_TIMEOUT)
3428
3429struct __ec_align2 ec_params_i2c_passthru_msg {
3430 uint16_t addr_flags;
3431 uint16_t len;
3432};
3433
3434struct __ec_align2 ec_params_i2c_passthru {
3435 uint8_t port;
3436 uint8_t num_msgs;
3437 struct ec_params_i2c_passthru_msg msg[];
3438
3439};
3440
3441struct __ec_align1 ec_response_i2c_passthru {
3442 uint8_t i2c_status;
3443 uint8_t num_msgs;
3444 uint8_t data[];
3445};
3446
3447
3448
3449
3450#define EC_CMD_HANG_DETECT 0x009F
3451
3452
3453
3454#define EC_HANG_START_ON_POWER_PRESS (1 << 0)
3455
3456
3457#define EC_HANG_START_ON_LID_CLOSE (1 << 1)
3458
3459
3460#define EC_HANG_START_ON_LID_OPEN (1 << 2)
3461
3462
3463#define EC_HANG_START_ON_RESUME (1 << 3)
3464
3465
3466
3467
3468#define EC_HANG_STOP_ON_POWER_RELEASE (1 << 8)
3469
3470
3471#define EC_HANG_STOP_ON_HOST_COMMAND (1 << 9)
3472
3473
3474#define EC_HANG_STOP_ON_SUSPEND (1 << 10)
3475
3476
3477
3478
3479
3480
3481
3482#define EC_HANG_START_NOW (1 << 30)
3483
3484
3485
3486
3487
3488
3489#define EC_HANG_STOP_NOW (1 << 31)
3490
3491struct __ec_align4 ec_params_hang_detect {
3492
3493 uint32_t flags;
3494
3495
3496 uint16_t host_event_timeout_msec;
3497
3498
3499 uint16_t warm_reboot_timeout_msec;
3500};
3501
3502
3503
3504
3505
3506
3507
3508
3509#define EC_CMD_CHARGE_STATE 0x00A0
3510
3511
3512enum charge_state_command {
3513 CHARGE_STATE_CMD_GET_STATE,
3514 CHARGE_STATE_CMD_GET_PARAM,
3515 CHARGE_STATE_CMD_SET_PARAM,
3516 CHARGE_STATE_NUM_CMDS
3517};
3518
3519
3520
3521
3522
3523enum charge_state_params {
3524 CS_PARAM_CHG_VOLTAGE,
3525 CS_PARAM_CHG_CURRENT,
3526 CS_PARAM_CHG_INPUT_CURRENT,
3527 CS_PARAM_CHG_STATUS,
3528 CS_PARAM_CHG_OPTION,
3529 CS_PARAM_LIMIT_POWER,
3530
3531
3532
3533
3534
3535 CS_NUM_BASE_PARAMS,
3536
3537
3538 CS_PARAM_CUSTOM_PROFILE_MIN = 0x10000,
3539 CS_PARAM_CUSTOM_PROFILE_MAX = 0x1ffff,
3540
3541
3542};
3543
3544struct __ec_todo_packed ec_params_charge_state {
3545 uint8_t cmd;
3546 union {
3547 struct __ec_align1 {
3548
3549 } get_state;
3550
3551 struct __ec_todo_unpacked {
3552 uint32_t param;
3553 } get_param;
3554
3555 struct __ec_todo_unpacked {
3556 uint32_t param;
3557 uint32_t value;
3558 } set_param;
3559 };
3560};
3561
3562struct __ec_align4 ec_response_charge_state {
3563 union {
3564 struct __ec_align4 {
3565 int ac;
3566 int chg_voltage;
3567 int chg_current;
3568 int chg_input_current;
3569 int batt_state_of_charge;
3570 } get_state;
3571
3572 struct __ec_align4 {
3573 uint32_t value;
3574 } get_param;
3575 struct __ec_align4 {
3576
3577 } set_param;
3578 };
3579};
3580
3581
3582
3583
3584
3585#define EC_CMD_CHARGE_CURRENT_LIMIT 0x00A1
3586
3587struct __ec_align4 ec_params_current_limit {
3588 uint32_t limit;
3589};
3590
3591
3592
3593
3594#define EC_CMD_EXTERNAL_POWER_LIMIT 0x00A2
3595
3596
3597struct __ec_align2 ec_params_external_power_limit_v1 {
3598 uint16_t current_lim;
3599 uint16_t voltage_lim;
3600};
3601
3602#define EC_POWER_LIMIT_NONE 0xffff
3603
3604
3605
3606
3607#define EC_CMD_OVERRIDE_DEDICATED_CHARGER_LIMIT 0x00A3
3608
3609struct __ec_align2 ec_params_dedicated_charger_limit {
3610 uint16_t current_lim;
3611 uint16_t voltage_lim;
3612};
3613
3614
3615
3616
3617
3618#define EC_CMD_HIBERNATION_DELAY 0x00A8
3619
3620struct __ec_align4 ec_params_hibernation_delay {
3621
3622
3623
3624
3625 uint32_t seconds;
3626};
3627
3628struct __ec_align4 ec_response_hibernation_delay {
3629
3630
3631
3632
3633 uint32_t time_g3;
3634
3635
3636
3637
3638
3639 uint32_t time_remaining;
3640
3641
3642
3643
3644
3645 uint32_t hibernate_delay;
3646};
3647
3648
3649#define EC_CMD_HOST_SLEEP_EVENT 0x00A9
3650
3651enum host_sleep_event {
3652 HOST_SLEEP_EVENT_S3_SUSPEND = 1,
3653 HOST_SLEEP_EVENT_S3_RESUME = 2,
3654 HOST_SLEEP_EVENT_S0IX_SUSPEND = 3,
3655 HOST_SLEEP_EVENT_S0IX_RESUME = 4
3656};
3657
3658struct __ec_align1 ec_params_host_sleep_event {
3659 uint8_t sleep_event;
3660};
3661
3662
3663
3664#define EC_CMD_DEVICE_EVENT 0x00AA
3665
3666enum ec_device_event {
3667 EC_DEVICE_EVENT_TRACKPAD,
3668 EC_DEVICE_EVENT_DSP,
3669 EC_DEVICE_EVENT_WIFI,
3670};
3671
3672enum ec_device_event_param {
3673
3674 EC_DEVICE_EVENT_PARAM_GET_CURRENT_EVENTS,
3675
3676 EC_DEVICE_EVENT_PARAM_GET_ENABLED_EVENTS,
3677
3678 EC_DEVICE_EVENT_PARAM_SET_ENABLED_EVENTS,
3679};
3680
3681#define EC_DEVICE_EVENT_MASK(event_code) (1UL << (event_code % 32))
3682
3683struct __ec_align_size1 ec_params_device_event {
3684 uint32_t event_mask;
3685 uint8_t param;
3686};
3687
3688struct __ec_align4 ec_response_device_event {
3689 uint32_t event_mask;
3690};
3691
3692
3693
3694
3695
3696#define EC_CMD_SB_READ_WORD 0x00B0
3697#define EC_CMD_SB_WRITE_WORD 0x00B1
3698
3699
3700
3701
3702#define EC_CMD_SB_READ_BLOCK 0x00B2
3703#define EC_CMD_SB_WRITE_BLOCK 0x00B3
3704
3705struct __ec_align1 ec_params_sb_rd {
3706 uint8_t reg;
3707};
3708
3709struct __ec_align2 ec_response_sb_rd_word {
3710 uint16_t value;
3711};
3712
3713struct __ec_align1 ec_params_sb_wr_word {
3714 uint8_t reg;
3715 uint16_t value;
3716};
3717
3718struct __ec_align1 ec_response_sb_rd_block {
3719 uint8_t data[32];
3720};
3721
3722struct __ec_align1 ec_params_sb_wr_block {
3723 uint8_t reg;
3724 uint16_t data[32];
3725};
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736#define EC_CMD_BATTERY_VENDOR_PARAM 0x00B4
3737
3738enum ec_battery_vendor_param_mode {
3739 BATTERY_VENDOR_PARAM_MODE_GET = 0,
3740 BATTERY_VENDOR_PARAM_MODE_SET,
3741};
3742
3743struct __ec_align_size1 ec_params_battery_vendor_param {
3744 uint32_t param;
3745 uint32_t value;
3746 uint8_t mode;
3747};
3748
3749struct __ec_align4 ec_response_battery_vendor_param {
3750 uint32_t value;
3751};
3752
3753
3754
3755
3756
3757#define EC_CMD_SB_FW_UPDATE 0x00B5
3758
3759enum ec_sb_fw_update_subcmd {
3760 EC_SB_FW_UPDATE_PREPARE = 0x0,
3761 EC_SB_FW_UPDATE_INFO = 0x1,
3762 EC_SB_FW_UPDATE_BEGIN = 0x2,
3763 EC_SB_FW_UPDATE_WRITE = 0x3,
3764 EC_SB_FW_UPDATE_END = 0x4,
3765 EC_SB_FW_UPDATE_STATUS = 0x5,
3766 EC_SB_FW_UPDATE_PROTECT = 0x6,
3767 EC_SB_FW_UPDATE_MAX = 0x7,
3768};
3769
3770#define SB_FW_UPDATE_CMD_WRITE_BLOCK_SIZE 32
3771#define SB_FW_UPDATE_CMD_STATUS_SIZE 2
3772#define SB_FW_UPDATE_CMD_INFO_SIZE 8
3773
3774struct __ec_align4 ec_sb_fw_update_header {
3775 uint16_t subcmd;
3776 uint16_t fw_id;
3777};
3778
3779struct __ec_align4 ec_params_sb_fw_update {
3780 struct ec_sb_fw_update_header hdr;
3781 union {
3782
3783
3784
3785
3786
3787
3788 struct __ec_align4 {
3789
3790 } dummy;
3791
3792
3793 struct __ec_align4 {
3794 uint8_t data[SB_FW_UPDATE_CMD_WRITE_BLOCK_SIZE];
3795 } write;
3796 };
3797};
3798
3799struct __ec_align1 ec_response_sb_fw_update {
3800 union {
3801
3802 struct __ec_align1 {
3803 uint8_t data[SB_FW_UPDATE_CMD_INFO_SIZE];
3804 } info;
3805
3806
3807 struct __ec_align1 {
3808 uint8_t data[SB_FW_UPDATE_CMD_STATUS_SIZE];
3809 } status;
3810 };
3811};
3812
3813
3814
3815
3816
3817
3818#define EC_CMD_ENTERING_MODE 0x00B6
3819
3820struct __ec_align4 ec_params_entering_mode {
3821 int vboot_mode;
3822};
3823
3824#define VBOOT_MODE_NORMAL 0
3825#define VBOOT_MODE_DEVELOPER 1
3826#define VBOOT_MODE_RECOVERY 2
3827
3828
3829
3830
3831
3832
3833#define EC_CMD_I2C_PASSTHRU_PROTECT 0x00B7
3834
3835enum ec_i2c_passthru_protect_subcmd {
3836 EC_CMD_I2C_PASSTHRU_PROTECT_STATUS = 0x0,
3837 EC_CMD_I2C_PASSTHRU_PROTECT_ENABLE = 0x1,
3838};
3839
3840struct __ec_align1 ec_params_i2c_passthru_protect {
3841 uint8_t subcmd;
3842 uint8_t port;
3843};
3844
3845struct __ec_align1 ec_response_i2c_passthru_protect {
3846 uint8_t status;
3847};
3848
3849
3850
3851
3852
3853
3854
3855
3856#define EC_CMD_REBOOT_EC 0x00D2
3857
3858
3859enum ec_reboot_cmd {
3860 EC_REBOOT_CANCEL = 0,
3861 EC_REBOOT_JUMP_RO = 1,
3862 EC_REBOOT_JUMP_RW = 2,
3863
3864 EC_REBOOT_COLD = 4,
3865 EC_REBOOT_DISABLE_JUMP = 5,
3866 EC_REBOOT_HIBERNATE = 6,
3867 EC_REBOOT_HIBERNATE_CLEAR_AP_OFF = 7,
3868};
3869
3870
3871#define EC_REBOOT_FLAG_RESERVED0 (1 << 0)
3872#define EC_REBOOT_FLAG_ON_AP_SHUTDOWN (1 << 1)
3873#define EC_REBOOT_FLAG_SWITCH_RW_SLOT (1 << 2)
3874
3875struct __ec_align1 ec_params_reboot_ec {
3876 uint8_t cmd;
3877 uint8_t flags;
3878};
3879
3880
3881
3882
3883
3884
3885
3886#define EC_CMD_GET_PANIC_INFO 0x00D3
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905#define EC_CMD_REBOOT 0x00D1
3906
3907
3908
3909
3910
3911
3912
3913
3914#define EC_CMD_RESEND_RESPONSE 0x00DB
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926#define EC_CMD_VERSION0 0x00DC
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936#define EC_CMD_PD_EXCHANGE_STATUS 0x0100
3937#define EC_VER_PD_EXCHANGE_STATUS 2
3938
3939enum pd_charge_state {
3940 PD_CHARGE_NO_CHANGE = 0,
3941 PD_CHARGE_NONE,
3942 PD_CHARGE_5V,
3943 PD_CHARGE_MAX
3944};
3945
3946
3947#define EC_STATUS_HIBERNATING (1 << 0)
3948
3949struct __ec_align1 ec_params_pd_status {
3950 uint8_t status;
3951 int8_t batt_soc;
3952 uint8_t charge_state;
3953};
3954
3955
3956#define PD_STATUS_HOST_EVENT (1 << 0)
3957#define PD_STATUS_IN_RW (1 << 1)
3958#define PD_STATUS_JUMPED_TO_IMAGE (1 << 2)
3959#define PD_STATUS_TCPC_ALERT_0 (1 << 3)
3960#define PD_STATUS_TCPC_ALERT_1 (1 << 4)
3961#define PD_STATUS_TCPC_ALERT_2 (1 << 5)
3962#define PD_STATUS_TCPC_ALERT_3 (1 << 6)
3963#define PD_STATUS_EC_INT_ACTIVE (PD_STATUS_TCPC_ALERT_0 | \
3964 PD_STATUS_TCPC_ALERT_1 | \
3965 PD_STATUS_HOST_EVENT)
3966struct __ec_align_size1 ec_response_pd_status {
3967 uint32_t curr_lim_ma;
3968 uint16_t status;
3969 int8_t active_charge_port;
3970};
3971
3972
3973#define EC_CMD_PD_HOST_EVENT_STATUS 0x0104
3974
3975
3976#define PD_EVENT_UPDATE_DEVICE (1 << 0)
3977#define PD_EVENT_POWER_CHANGE (1 << 1)
3978#define PD_EVENT_IDENTITY_RECEIVED (1 << 2)
3979#define PD_EVENT_DATA_SWAP (1 << 3)
3980struct __ec_align4 ec_response_host_event_status {
3981 uint32_t status;
3982};
3983
3984
3985#define EC_CMD_USB_PD_CONTROL 0x0101
3986
3987enum usb_pd_control_role {
3988 USB_PD_CTRL_ROLE_NO_CHANGE = 0,
3989 USB_PD_CTRL_ROLE_TOGGLE_ON = 1,
3990 USB_PD_CTRL_ROLE_TOGGLE_OFF = 2,
3991 USB_PD_CTRL_ROLE_FORCE_SINK = 3,
3992 USB_PD_CTRL_ROLE_FORCE_SOURCE = 4,
3993 USB_PD_CTRL_ROLE_COUNT
3994};
3995
3996enum usb_pd_control_mux {
3997 USB_PD_CTRL_MUX_NO_CHANGE = 0,
3998 USB_PD_CTRL_MUX_NONE = 1,
3999 USB_PD_CTRL_MUX_USB = 2,
4000 USB_PD_CTRL_MUX_DP = 3,
4001 USB_PD_CTRL_MUX_DOCK = 4,
4002 USB_PD_CTRL_MUX_AUTO = 5,
4003 USB_PD_CTRL_MUX_COUNT
4004};
4005
4006enum usb_pd_control_swap {
4007 USB_PD_CTRL_SWAP_NONE = 0,
4008 USB_PD_CTRL_SWAP_DATA = 1,
4009 USB_PD_CTRL_SWAP_POWER = 2,
4010 USB_PD_CTRL_SWAP_VCONN = 3,
4011 USB_PD_CTRL_SWAP_COUNT
4012};
4013
4014struct __ec_align1 ec_params_usb_pd_control {
4015 uint8_t port;
4016 uint8_t role;
4017 uint8_t mux;
4018 uint8_t swap;
4019};
4020
4021#define PD_CTRL_RESP_ENABLED_COMMS (1 << 0)
4022#define PD_CTRL_RESP_ENABLED_CONNECTED (1 << 1)
4023#define PD_CTRL_RESP_ENABLED_PD_CAPABLE (1 << 2)
4024
4025#define PD_CTRL_RESP_ROLE_POWER (1 << 0)
4026#define PD_CTRL_RESP_ROLE_DATA (1 << 1)
4027#define PD_CTRL_RESP_ROLE_VCONN (1 << 2)
4028#define PD_CTRL_RESP_ROLE_DR_POWER (1 << 3)
4029#define PD_CTRL_RESP_ROLE_DR_DATA (1 << 4)
4030#define PD_CTRL_RESP_ROLE_USB_COMM (1 << 5)
4031#define PD_CTRL_RESP_ROLE_EXT_POWERED (1 << 6)
4032
4033struct __ec_align1 ec_response_usb_pd_control {
4034 uint8_t enabled;
4035 uint8_t role;
4036 uint8_t polarity;
4037 uint8_t state;
4038};
4039
4040struct __ec_align1 ec_response_usb_pd_control_v1 {
4041 uint8_t enabled;
4042 uint8_t role;
4043 uint8_t polarity;
4044 char state[32];
4045};
4046
4047#define EC_CMD_USB_PD_PORTS 0x0102
4048
4049
4050#define EC_USB_PD_MAX_PORTS 8
4051
4052struct __ec_align1 ec_response_usb_pd_ports {
4053 uint8_t num_ports;
4054};
4055
4056#define EC_CMD_USB_PD_POWER_INFO 0x0103
4057
4058#define PD_POWER_CHARGING_PORT 0xff
4059struct __ec_align1 ec_params_usb_pd_power_info {
4060 uint8_t port;
4061};
4062
4063enum usb_chg_type {
4064 USB_CHG_TYPE_NONE,
4065 USB_CHG_TYPE_PD,
4066 USB_CHG_TYPE_C,
4067 USB_CHG_TYPE_PROPRIETARY,
4068 USB_CHG_TYPE_BC12_DCP,
4069 USB_CHG_TYPE_BC12_CDP,
4070 USB_CHG_TYPE_BC12_SDP,
4071 USB_CHG_TYPE_OTHER,
4072 USB_CHG_TYPE_VBUS,
4073 USB_CHG_TYPE_UNKNOWN,
4074};
4075enum usb_power_roles {
4076 USB_PD_PORT_POWER_DISCONNECTED,
4077 USB_PD_PORT_POWER_SOURCE,
4078 USB_PD_PORT_POWER_SINK,
4079 USB_PD_PORT_POWER_SINK_NOT_CHARGING,
4080};
4081
4082struct __ec_align2 usb_chg_measures {
4083 uint16_t voltage_max;
4084 uint16_t voltage_now;
4085 uint16_t current_max;
4086 uint16_t current_lim;
4087};
4088
4089struct __ec_align4 ec_response_usb_pd_power_info {
4090 uint8_t role;
4091 uint8_t type;
4092 uint8_t dualrole;
4093 uint8_t reserved1;
4094 struct usb_chg_measures meas;
4095 uint32_t max_power;
4096};
4097
4098
4099#define EC_CMD_USB_PD_FW_UPDATE 0x0110
4100
4101enum usb_pd_fw_update_cmds {
4102 USB_PD_FW_REBOOT,
4103 USB_PD_FW_FLASH_ERASE,
4104 USB_PD_FW_FLASH_WRITE,
4105 USB_PD_FW_ERASE_SIG,
4106};
4107
4108struct __ec_align4 ec_params_usb_pd_fw_update {
4109 uint16_t dev_id;
4110 uint8_t cmd;
4111 uint8_t port;
4112 uint32_t size;
4113
4114};
4115
4116
4117#define EC_CMD_USB_PD_RW_HASH_ENTRY 0x0111
4118
4119#define PD_RW_HASH_SIZE 20
4120struct __ec_align1 ec_params_usb_pd_rw_hash_entry {
4121 uint16_t dev_id;
4122 uint8_t dev_rw_hash[PD_RW_HASH_SIZE];
4123 uint8_t reserved;
4124
4125
4126 uint32_t current_image;
4127};
4128
4129
4130#define EC_CMD_USB_PD_DEV_INFO 0x0112
4131
4132struct __ec_align1 ec_params_usb_pd_info_request {
4133 uint8_t port;
4134};
4135
4136
4137#define EC_CMD_USB_PD_DISCOVERY 0x0113
4138struct __ec_align_size1 ec_params_usb_pd_discovery_entry {
4139 uint16_t vid;
4140 uint16_t pid;
4141 uint8_t ptype;
4142};
4143
4144
4145#define EC_CMD_PD_CHARGE_PORT_OVERRIDE 0x0114
4146
4147
4148enum usb_pd_override_ports {
4149 OVERRIDE_DONT_CHARGE = -2,
4150 OVERRIDE_OFF = -1,
4151
4152};
4153
4154struct __ec_align2 ec_params_charge_port_override {
4155 int16_t override_port;
4156};
4157
4158
4159#define EC_CMD_PD_GET_LOG_ENTRY 0x0115
4160
4161struct __ec_align4 ec_response_pd_log {
4162 uint32_t timestamp;
4163 uint8_t type;
4164 uint8_t size_port;
4165 uint16_t data;
4166 uint8_t payload[0];
4167};
4168
4169
4170
4171#define PD_LOG_TIMESTAMP_SHIFT 10
4172
4173#define PD_LOG_SIZE_MASK 0x1f
4174#define PD_LOG_PORT_MASK 0xe0
4175#define PD_LOG_PORT_SHIFT 5
4176#define PD_LOG_PORT_SIZE(port, size) (((port) << PD_LOG_PORT_SHIFT) | \
4177 ((size) & PD_LOG_SIZE_MASK))
4178#define PD_LOG_PORT(size_port) ((size_port) >> PD_LOG_PORT_SHIFT)
4179#define PD_LOG_SIZE(size_port) ((size_port) & PD_LOG_SIZE_MASK)
4180
4181
4182
4183#define PD_EVENT_MCU_BASE 0x00
4184#define PD_EVENT_MCU_CHARGE (PD_EVENT_MCU_BASE+0)
4185#define PD_EVENT_MCU_CONNECT (PD_EVENT_MCU_BASE+1)
4186
4187#define PD_EVENT_MCU_BOARD_CUSTOM (PD_EVENT_MCU_BASE+2)
4188
4189#define PD_EVENT_ACC_BASE 0x20
4190#define PD_EVENT_ACC_RW_FAIL (PD_EVENT_ACC_BASE+0)
4191#define PD_EVENT_ACC_RW_ERASE (PD_EVENT_ACC_BASE+1)
4192
4193#define PD_EVENT_PS_BASE 0x40
4194#define PD_EVENT_PS_FAULT (PD_EVENT_PS_BASE+0)
4195
4196#define PD_EVENT_VIDEO_BASE 0x60
4197#define PD_EVENT_VIDEO_DP_MODE (PD_EVENT_VIDEO_BASE+0)
4198#define PD_EVENT_VIDEO_CODEC (PD_EVENT_VIDEO_BASE+1)
4199
4200#define PD_EVENT_NO_ENTRY 0xff
4201
4202
4203
4204
4205
4206
4207
4208#define CHARGE_FLAGS_DUAL_ROLE (1 << 15)
4209
4210#define CHARGE_FLAGS_DELAYED_OVERRIDE (1 << 14)
4211
4212#define CHARGE_FLAGS_OVERRIDE (1 << 13)
4213
4214#define CHARGE_FLAGS_TYPE_SHIFT 3
4215#define CHARGE_FLAGS_TYPE_MASK (0xf << CHARGE_FLAGS_TYPE_SHIFT)
4216
4217#define CHARGE_FLAGS_ROLE_MASK (7 << 0)
4218
4219
4220
4221
4222#define PS_FAULT_OCP 1
4223#define PS_FAULT_FAST_OCP 2
4224#define PS_FAULT_OVP 3
4225#define PS_FAULT_DISCH 4
4226
4227
4228
4229
4230struct __ec_align4 mcdp_version {
4231 uint8_t major;
4232 uint8_t minor;
4233 uint16_t build;
4234};
4235
4236struct __ec_align4 mcdp_info {
4237 uint8_t family[2];
4238 uint8_t chipid[2];
4239 struct mcdp_version irom;
4240 struct mcdp_version fw;
4241};
4242
4243
4244#define MCDP_CHIPID(chipid) ((chipid[0] << 8) | chipid[1])
4245#define MCDP_FAMILY(family) ((family[0] << 8) | family[1])
4246
4247
4248#define EC_CMD_USB_PD_GET_AMODE 0x0116
4249struct __ec_align_size1 ec_params_usb_pd_get_mode_request {
4250 uint16_t svid_idx;
4251 uint8_t port;
4252};
4253
4254struct __ec_align4 ec_params_usb_pd_get_mode_response {
4255 uint16_t svid;
4256 uint16_t opos;
4257 uint32_t vdo[6];
4258};
4259
4260#define EC_CMD_USB_PD_SET_AMODE 0x0117
4261
4262enum pd_mode_cmd {
4263 PD_EXIT_MODE = 0,
4264 PD_ENTER_MODE = 1,
4265
4266 PD_MODE_CMD_COUNT,
4267};
4268
4269struct __ec_align4 ec_params_usb_pd_set_mode_request {
4270 uint32_t cmd;
4271 uint16_t svid;
4272 uint8_t opos;
4273 uint8_t port;
4274};
4275
4276
4277#define EC_CMD_PD_WRITE_LOG_ENTRY 0x0118
4278
4279struct __ec_align1 ec_params_pd_write_log_entry {
4280 uint8_t type;
4281 uint8_t port;
4282};
4283
4284
4285
4286#define EC_CMD_PD_CONTROL 0x0119
4287
4288enum ec_pd_control_cmd {
4289 PD_SUSPEND = 0,
4290 PD_RESUME,
4291 PD_RESET,
4292 PD_CONTROL_DISABLE
4293};
4294
4295struct __ec_align1 ec_params_pd_control {
4296 uint8_t chip;
4297 uint8_t subcmd;
4298};
4299
4300
4301#define EC_CMD_USB_PD_MUX_INFO 0x011A
4302
4303struct __ec_align1 ec_params_usb_pd_mux_info {
4304 uint8_t port;
4305};
4306
4307
4308#define USB_PD_MUX_USB_ENABLED (1 << 0)
4309#define USB_PD_MUX_DP_ENABLED (1 << 1)
4310#define USB_PD_MUX_POLARITY_INVERTED (1 << 2)
4311#define USB_PD_MUX_HPD_IRQ (1 << 3)
4312
4313struct __ec_align1 ec_response_usb_pd_mux_info {
4314 uint8_t flags;
4315};
4316
4317#define EC_CMD_PD_CHIP_INFO 0x011B
4318
4319struct __ec_align1 ec_params_pd_chip_info {
4320 uint8_t port;
4321 uint8_t renew;
4322};
4323
4324struct __ec_align2 ec_response_pd_chip_info {
4325 uint16_t vendor_id;
4326 uint16_t product_id;
4327 uint16_t device_id;
4328 union {
4329 uint8_t fw_version_string[8];
4330 uint64_t fw_version_number;
4331 };
4332};
4333
4334
4335#define EC_CMD_RWSIG_CHECK_STATUS 0x011C
4336
4337struct __ec_align4 ec_response_rwsig_check_status {
4338 uint32_t status;
4339};
4340
4341
4342#define EC_CMD_RWSIG_ACTION 0x011D
4343
4344enum rwsig_action {
4345 RWSIG_ACTION_ABORT = 0,
4346 RWSIG_ACTION_CONTINUE = 1,
4347};
4348
4349struct __ec_align4 ec_params_rwsig_action {
4350 uint32_t action;
4351};
4352
4353
4354#define EC_CMD_EFS_VERIFY 0x011E
4355
4356struct __ec_align1 ec_params_efs_verify {
4357 uint8_t region;
4358};
4359
4360
4361
4362
4363
4364
4365#define EC_CMD_GET_CROS_BOARD_INFO 0x011F
4366
4367
4368
4369
4370#define EC_CMD_SET_CROS_BOARD_INFO 0x0120
4371
4372enum cbi_data_tag {
4373 CBI_TAG_BOARD_VERSION = 0,
4374 CBI_TAG_OEM_ID = 1,
4375 CBI_TAG_SKU_ID = 2,
4376 CBI_TAG_COUNT,
4377};
4378
4379
4380
4381
4382
4383
4384
4385#define CBI_GET_RELOAD (1 << 0)
4386
4387struct __ec_align4 ec_params_get_cbi {
4388 uint32_t type;
4389 uint32_t flag;
4390};
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400#define CBI_SET_NO_SYNC (1 << 0)
4401#define CBI_SET_INIT (1 << 1)
4402
4403struct __ec_align1 ec_params_set_cbi {
4404 uint32_t tag;
4405 uint32_t flag;
4406 uint32_t size;
4407 uint8_t data[];
4408};
4409
4410
4411
4412
4413
4414
4415
4416
4417#define EC_CMD_CR51_BASE 0x0300
4418#define EC_CMD_CR51_LAST 0x03FF
4419
4420
4421
4422
4423
4424#define EC_CMD_FP_PASSTHRU 0x0400
4425
4426#define EC_FP_FLAG_NOT_COMPLETE 0x1
4427
4428struct __ec_align2 ec_params_fp_passthru {
4429 uint16_t len;
4430 uint16_t flags;
4431 uint8_t data[];
4432};
4433
4434
4435#define EC_CMD_FP_SENSOR_CONFIG 0x0401
4436
4437#define EC_FP_SENSOR_CONFIG_MAX_REGS 16
4438
4439struct __ec_align2 ec_params_fp_sensor_config {
4440 uint8_t count;
4441
4442
4443
4444
4445
4446 uint8_t len[EC_FP_SENSOR_CONFIG_MAX_REGS];
4447 uint8_t data[];
4448};
4449
4450
4451#define EC_CMD_FP_MODE 0x0402
4452
4453
4454#define FP_MODE_DEEPSLEEP (1<<0)
4455
4456#define FP_MODE_FINGER_DOWN (1<<1)
4457
4458#define FP_MODE_FINGER_UP (1<<2)
4459
4460#define FP_MODE_CAPTURE (1<<3)
4461
4462#define FP_MODE_DONT_CHANGE (1<<31)
4463
4464struct __ec_align4 ec_params_fp_mode {
4465 uint32_t mode;
4466
4467};
4468
4469struct __ec_align4 ec_response_fp_mode {
4470 uint32_t mode;
4471
4472};
4473
4474
4475#define EC_CMD_FP_INFO 0x0403
4476
4477struct __ec_align2 ec_response_fp_info {
4478
4479 uint32_t vendor_id;
4480 uint32_t product_id;
4481 uint32_t model_id;
4482 uint32_t version;
4483
4484 uint32_t frame_size;
4485 uint32_t pixel_format;
4486 uint16_t width;
4487 uint16_t height;
4488 uint16_t bpp;
4489};
4490
4491
4492#define EC_CMD_FP_FRAME 0x0404
4493
4494struct __ec_align4 ec_params_fp_frame {
4495 uint32_t offset;
4496 uint32_t size;
4497};
4498
4499
4500
4501
4502
4503#define EC_CMD_TP_SELF_TEST 0x0500
4504
4505
4506#define EC_CMD_TP_FRAME_INFO 0x0501
4507
4508struct __ec_align4 ec_response_tp_frame_info {
4509 uint32_t n_frames;
4510 uint32_t frame_sizes[0];
4511};
4512
4513
4514#define EC_CMD_TP_FRAME_SNAPSHOT 0x0502
4515
4516
4517#define EC_CMD_TP_FRAME_GET 0x0503
4518
4519struct __ec_align4 ec_params_tp_frame_get {
4520 uint32_t frame_index;
4521 uint32_t offset;
4522 uint32_t size;
4523};
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551#define EC_CMD_BOARD_SPECIFIC_BASE 0x3E00
4552#define EC_CMD_BOARD_SPECIFIC_LAST 0x3FFF
4553
4554
4555
4556
4557
4558#define EC_PRIVATE_HOST_COMMAND_VALUE(command) \
4559 (EC_CMD_BOARD_SPECIFIC_BASE + (command))
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585#define EC_CMD_PASSTHRU_OFFSET(n) (0x4000 * (n))
4586#define EC_CMD_PASSTHRU_MAX(n) (EC_CMD_PASSTHRU_OFFSET(n) + 0x3fff)
4587
4588
4589
4590
4591
4592
4593
4594
4595#define EC_HOST_PARAM_SIZE EC_PROTO2_MAX_PARAM_SIZE
4596#define EC_LPC_ADDR_OLD_PARAM EC_HOST_CMD_REGION1
4597#define EC_OLD_PARAM_SIZE EC_HOST_CMD_REGION_SIZE
4598
4599#endif
4600
4601#endif
4602