1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23#ifndef __CROS_EC_COMMANDS_H
24#define __CROS_EC_COMMANDS_H
25
26
27
28
29
30
31
32
33#define EC_PROTO_VERSION 0x00000002
34
35
36#define EC_VER_MASK(version) (1UL << (version))
37
38
39#define EC_LPC_ADDR_ACPI_DATA 0x62
40#define EC_LPC_ADDR_ACPI_CMD 0x66
41
42
43#define EC_LPC_ADDR_HOST_DATA 0x200
44#define EC_LPC_ADDR_HOST_CMD 0x204
45
46
47
48#define EC_LPC_ADDR_HOST_ARGS 0x800
49#define EC_LPC_ADDR_HOST_PARAM 0x804
50
51
52#define EC_LPC_ADDR_HOST_PACKET 0x800
53#define EC_LPC_HOST_PACKET_SIZE 0x100
54
55
56
57#define EC_HOST_CMD_REGION0 0x800
58#define EC_HOST_CMD_REGION1 0x880
59#define EC_HOST_CMD_REGION_SIZE 0x80
60
61
62#define EC_LPC_CMDR_DATA (1 << 0)
63#define EC_LPC_CMDR_PENDING (1 << 1)
64#define EC_LPC_CMDR_BUSY (1 << 2)
65#define EC_LPC_CMDR_CMD (1 << 3)
66#define EC_LPC_CMDR_ACPI_BRST (1 << 4)
67#define EC_LPC_CMDR_SCI (1 << 5)
68#define EC_LPC_CMDR_SMI (1 << 6)
69
70#define EC_LPC_ADDR_MEMMAP 0x900
71#define EC_MEMMAP_SIZE 255
72#define EC_MEMMAP_TEXT_MAX 8
73
74
75#define EC_MEMMAP_TEMP_SENSOR 0x00
76#define EC_MEMMAP_FAN 0x10
77#define EC_MEMMAP_TEMP_SENSOR_B 0x18
78#define EC_MEMMAP_ID 0x20
79#define EC_MEMMAP_ID_VERSION 0x22
80#define EC_MEMMAP_THERMAL_VERSION 0x23
81#define EC_MEMMAP_BATTERY_VERSION 0x24
82#define EC_MEMMAP_SWITCHES_VERSION 0x25
83#define EC_MEMMAP_EVENTS_VERSION 0x26
84#define EC_MEMMAP_HOST_CMD_FLAGS 0x27
85
86#define EC_MEMMAP_SWITCHES 0x30
87
88#define EC_MEMMAP_HOST_EVENTS 0x34
89
90
91#define EC_MEMMAP_BATT_VOLT 0x40
92#define EC_MEMMAP_BATT_RATE 0x44
93#define EC_MEMMAP_BATT_CAP 0x48
94#define EC_MEMMAP_BATT_FLAG 0x4c
95#define EC_MEMMAP_BATT_DCAP 0x50
96#define EC_MEMMAP_BATT_DVLT 0x54
97#define EC_MEMMAP_BATT_LFCC 0x58
98#define EC_MEMMAP_BATT_CCNT 0x5c
99
100#define EC_MEMMAP_BATT_MFGR 0x60
101#define EC_MEMMAP_BATT_MODEL 0x68
102#define EC_MEMMAP_BATT_SERIAL 0x70
103#define EC_MEMMAP_BATT_TYPE 0x78
104#define EC_MEMMAP_ALS 0x80
105
106#define EC_MEMMAP_ACC_STATUS 0x90
107
108#define EC_MEMMAP_ACC_DATA 0x92
109#define EC_MEMMAP_GYRO_DATA 0xa0
110
111
112
113
114#define EC_MEMMAP_ACC_STATUS_SAMPLE_ID_MASK 0x0f
115#define EC_MEMMAP_ACC_STATUS_BUSY_BIT (1 << 4)
116#define EC_MEMMAP_ACC_STATUS_PRESENCE_BIT (1 << 7)
117
118
119#define EC_TEMP_SENSOR_ENTRIES 16
120
121
122
123
124
125#define EC_TEMP_SENSOR_B_ENTRIES 8
126
127
128#define EC_TEMP_SENSOR_NOT_PRESENT 0xff
129#define EC_TEMP_SENSOR_ERROR 0xfe
130#define EC_TEMP_SENSOR_NOT_POWERED 0xfd
131#define EC_TEMP_SENSOR_NOT_CALIBRATED 0xfc
132
133
134
135
136#define EC_TEMP_SENSOR_OFFSET 200
137
138
139
140
141#define EC_ALS_ENTRIES 2
142
143
144
145
146
147
148#define EC_TEMP_SENSOR_DEFAULT (296 - EC_TEMP_SENSOR_OFFSET)
149
150#define EC_FAN_SPEED_ENTRIES 4
151#define EC_FAN_SPEED_NOT_PRESENT 0xffff
152#define EC_FAN_SPEED_STALLED 0xfffe
153
154
155#define EC_BATT_FLAG_AC_PRESENT 0x01
156#define EC_BATT_FLAG_BATT_PRESENT 0x02
157#define EC_BATT_FLAG_DISCHARGING 0x04
158#define EC_BATT_FLAG_CHARGING 0x08
159#define EC_BATT_FLAG_LEVEL_CRITICAL 0x10
160
161
162#define EC_SWITCH_LID_OPEN 0x01
163#define EC_SWITCH_POWER_BUTTON_PRESSED 0x02
164#define EC_SWITCH_WRITE_PROTECT_DISABLED 0x04
165
166#define EC_SWITCH_IGNORE1 0x08
167
168#define EC_SWITCH_DEDICATED_RECOVERY 0x10
169
170#define EC_SWITCH_IGNORE0 0x20
171
172
173
174#define EC_HOST_CMD_FLAG_LPC_ARGS_SUPPORTED 0x01
175
176#define EC_HOST_CMD_FLAG_VERSION_3 0x02
177
178
179#define EC_WIRELESS_SWITCH_ALL ~0x00
180#define EC_WIRELESS_SWITCH_WLAN 0x01
181#define EC_WIRELESS_SWITCH_BLUETOOTH 0x02
182#define EC_WIRELESS_SWITCH_WWAN 0x04
183#define EC_WIRELESS_SWITCH_WLAN_POWER 0x08
184
185
186
187
188
189
190#ifndef __ACPI__
191
192
193
194
195
196#ifndef __packed
197#define __packed __attribute__((packed))
198#endif
199
200
201
202#define EC_LPC_STATUS_TO_HOST 0x01
203
204#define EC_LPC_STATUS_FROM_HOST 0x02
205
206#define EC_LPC_STATUS_PROCESSING 0x04
207
208#define EC_LPC_STATUS_LAST_CMD 0x08
209
210#define EC_LPC_STATUS_BURST_MODE 0x10
211
212#define EC_LPC_STATUS_SCI_PENDING 0x20
213
214#define EC_LPC_STATUS_SMI_PENDING 0x40
215
216#define EC_LPC_STATUS_RESERVED 0x80
217
218
219
220
221
222#define EC_LPC_STATUS_BUSY_MASK \
223 (EC_LPC_STATUS_FROM_HOST | EC_LPC_STATUS_PROCESSING)
224
225
226enum ec_status {
227 EC_RES_SUCCESS = 0,
228 EC_RES_INVALID_COMMAND = 1,
229 EC_RES_ERROR = 2,
230 EC_RES_INVALID_PARAM = 3,
231 EC_RES_ACCESS_DENIED = 4,
232 EC_RES_INVALID_RESPONSE = 5,
233 EC_RES_INVALID_VERSION = 6,
234 EC_RES_INVALID_CHECKSUM = 7,
235 EC_RES_IN_PROGRESS = 8,
236 EC_RES_UNAVAILABLE = 9,
237 EC_RES_TIMEOUT = 10,
238 EC_RES_OVERFLOW = 11,
239 EC_RES_INVALID_HEADER = 12,
240 EC_RES_REQUEST_TRUNCATED = 13,
241 EC_RES_RESPONSE_TOO_BIG = 14
242};
243
244
245
246
247
248
249
250
251enum host_event_code {
252 EC_HOST_EVENT_LID_CLOSED = 1,
253 EC_HOST_EVENT_LID_OPEN = 2,
254 EC_HOST_EVENT_POWER_BUTTON = 3,
255 EC_HOST_EVENT_AC_CONNECTED = 4,
256 EC_HOST_EVENT_AC_DISCONNECTED = 5,
257 EC_HOST_EVENT_BATTERY_LOW = 6,
258 EC_HOST_EVENT_BATTERY_CRITICAL = 7,
259 EC_HOST_EVENT_BATTERY = 8,
260 EC_HOST_EVENT_THERMAL_THRESHOLD = 9,
261 EC_HOST_EVENT_THERMAL_OVERLOAD = 10,
262 EC_HOST_EVENT_THERMAL = 11,
263 EC_HOST_EVENT_USB_CHARGER = 12,
264 EC_HOST_EVENT_KEY_PRESSED = 13,
265
266
267
268
269
270 EC_HOST_EVENT_INTERFACE_READY = 14,
271
272 EC_HOST_EVENT_KEYBOARD_RECOVERY = 15,
273
274
275 EC_HOST_EVENT_THERMAL_SHUTDOWN = 16,
276
277 EC_HOST_EVENT_BATTERY_SHUTDOWN = 17,
278
279
280 EC_HOST_EVENT_THROTTLE_START = 18,
281
282 EC_HOST_EVENT_THROTTLE_STOP = 19,
283
284
285 EC_HOST_EVENT_HANG_DETECT = 20,
286
287 EC_HOST_EVENT_HANG_REBOOT = 21,
288
289 EC_HOST_EVENT_PD_MCU = 22,
290
291
292 EC_HOST_EVENT_USB_MUX = 28,
293
294
295 EC_HOST_EVENT_RTC = 26,
296
297
298
299
300
301
302
303
304 EC_HOST_EVENT_INVALID = 32
305};
306
307#define EC_HOST_EVENT_MASK(event_code) (1UL << ((event_code) - 1))
308
309
310struct ec_lpc_host_args {
311 uint8_t flags;
312 uint8_t command_version;
313 uint8_t data_size;
314
315
316
317
318 uint8_t checksum;
319} __packed;
320
321
322
323
324
325
326
327
328
329
330
331#define EC_HOST_ARGS_FLAG_FROM_HOST 0x01
332
333
334
335
336
337
338
339#define EC_HOST_ARGS_FLAG_TO_HOST 0x02
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381#define EC_SPI_FRAME_START 0xec
382
383
384
385
386#define EC_SPI_PAST_END 0xed
387
388
389
390
391
392
393#define EC_SPI_RX_READY 0xf8
394
395
396
397
398
399#define EC_SPI_RECEIVING 0xf9
400
401
402#define EC_SPI_PROCESSING 0xfa
403
404
405
406
407
408#define EC_SPI_RX_BAD_DATA 0xfb
409
410
411
412
413
414
415#define EC_SPI_NOT_READY 0xfc
416
417
418
419
420
421
422#define EC_SPI_OLD_READY 0xfd
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442#define EC_PROTO2_REQUEST_HEADER_BYTES 3
443#define EC_PROTO2_REQUEST_TRAILER_BYTES 1
444#define EC_PROTO2_REQUEST_OVERHEAD (EC_PROTO2_REQUEST_HEADER_BYTES + \
445 EC_PROTO2_REQUEST_TRAILER_BYTES)
446
447#define EC_PROTO2_RESPONSE_HEADER_BYTES 2
448#define EC_PROTO2_RESPONSE_TRAILER_BYTES 1
449#define EC_PROTO2_RESPONSE_OVERHEAD (EC_PROTO2_RESPONSE_HEADER_BYTES + \
450 EC_PROTO2_RESPONSE_TRAILER_BYTES)
451
452
453#define EC_PROTO2_MAX_PARAM_SIZE 0xfc
454
455
456#define EC_PROTO2_MAX_REQUEST_SIZE (EC_PROTO2_REQUEST_OVERHEAD + \
457 EC_PROTO2_MAX_PARAM_SIZE)
458#define EC_PROTO2_MAX_RESPONSE_SIZE (EC_PROTO2_RESPONSE_OVERHEAD + \
459 EC_PROTO2_MAX_PARAM_SIZE)
460
461
462
463
464
465
466
467#define EC_COMMAND_PROTOCOL_3 0xda
468
469#define EC_HOST_REQUEST_VERSION 3
470
471
472struct ec_host_request {
473
474
475
476
477
478 uint8_t struct_version;
479
480
481
482
483
484 uint8_t checksum;
485
486
487 uint16_t command;
488
489
490 uint8_t command_version;
491
492
493 uint8_t reserved;
494
495
496 uint16_t data_len;
497} __packed;
498
499#define EC_HOST_RESPONSE_VERSION 3
500
501
502struct ec_host_response {
503
504 uint8_t struct_version;
505
506
507
508
509
510 uint8_t checksum;
511
512
513 uint16_t result;
514
515
516 uint16_t data_len;
517
518
519 uint16_t reserved;
520} __packed;
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541#define EC_CMD_PROTO_VERSION 0x00
542
543struct ec_response_proto_version {
544 uint32_t version;
545} __packed;
546
547
548
549
550
551#define EC_CMD_HELLO 0x01
552
553struct ec_params_hello {
554 uint32_t in_data;
555} __packed;
556
557struct ec_response_hello {
558 uint32_t out_data;
559} __packed;
560
561
562#define EC_CMD_GET_VERSION 0x02
563
564enum ec_current_image {
565 EC_IMAGE_UNKNOWN = 0,
566 EC_IMAGE_RO,
567 EC_IMAGE_RW
568};
569
570struct ec_response_get_version {
571
572 char version_string_ro[32];
573 char version_string_rw[32];
574 char reserved[32];
575 uint32_t current_image;
576} __packed;
577
578
579#define EC_CMD_READ_TEST 0x03
580
581struct ec_params_read_test {
582 uint32_t offset;
583 uint32_t size;
584} __packed;
585
586struct ec_response_read_test {
587 uint32_t data[32];
588} __packed;
589
590
591
592
593
594
595#define EC_CMD_GET_BUILD_INFO 0x04
596
597
598#define EC_CMD_GET_CHIP_INFO 0x05
599
600struct ec_response_get_chip_info {
601
602 char vendor[32];
603 char name[32];
604 char revision[32];
605} __packed;
606
607
608#define EC_CMD_GET_BOARD_VERSION 0x06
609
610struct ec_response_board_version {
611 uint16_t board_version;
612} __packed;
613
614
615
616
617
618
619
620
621
622#define EC_CMD_READ_MEMMAP 0x07
623
624struct ec_params_read_memmap {
625 uint8_t offset;
626 uint8_t size;
627} __packed;
628
629
630#define EC_CMD_GET_CMD_VERSIONS 0x08
631
632struct ec_params_get_cmd_versions {
633 uint8_t cmd;
634} __packed;
635
636struct ec_params_get_cmd_versions_v1 {
637 uint16_t cmd;
638} __packed;
639
640struct ec_response_get_cmd_versions {
641
642
643
644
645 uint32_t version_mask;
646} __packed;
647
648
649
650
651
652
653
654
655#define EC_CMD_GET_COMMS_STATUS 0x09
656
657
658enum ec_comms_status {
659 EC_COMMS_STATUS_PROCESSING = 1 << 0,
660};
661
662struct ec_response_get_comms_status {
663 uint32_t flags;
664} __packed;
665
666
667#define EC_CMD_TEST_PROTOCOL 0x0a
668
669
670struct ec_params_test_protocol {
671 uint32_t ec_result;
672 uint32_t ret_len;
673 uint8_t buf[32];
674} __packed;
675
676
677struct ec_response_test_protocol {
678 uint8_t buf[32];
679} __packed;
680
681
682#define EC_CMD_GET_PROTOCOL_INFO 0x0b
683
684
685
686#define EC_PROTOCOL_INFO_IN_PROGRESS_SUPPORTED (1 << 0)
687
688struct ec_response_get_protocol_info {
689
690
691
692 uint32_t protocol_versions;
693
694
695 uint16_t max_request_packet_size;
696
697
698 uint16_t max_response_packet_size;
699
700
701 uint32_t flags;
702} __packed;
703
704
705
706
707
708
709#define EC_GSV_SET 0x80000000
710
711
712
713#define EC_GSV_PARAM_MASK 0x00ffffff
714
715struct ec_params_get_set_value {
716 uint32_t flags;
717 uint32_t value;
718} __packed;
719
720struct ec_response_get_set_value {
721 uint32_t flags;
722 uint32_t value;
723} __packed;
724
725
726#define EC_CMD_GSV_PAUSE_IN_S5 0x0c
727
728
729
730#define EC_CMD_GET_FEATURES 0x0d
731
732
733enum ec_feature_code {
734
735
736
737
738 EC_FEATURE_LIMITED = 0,
739
740
741
742
743 EC_FEATURE_FLASH = 1,
744
745
746
747 EC_FEATURE_PWM_FAN = 2,
748
749
750
751 EC_FEATURE_PWM_KEYB = 3,
752
753
754
755 EC_FEATURE_LIGHTBAR = 4,
756
757 EC_FEATURE_LED = 5,
758
759
760
761
762 EC_FEATURE_MOTION_SENSE = 6,
763
764 EC_FEATURE_KEYB = 7,
765
766 EC_FEATURE_PSTORE = 8,
767
768 EC_FEATURE_PORT80 = 9,
769
770
771
772
773 EC_FEATURE_THERMAL = 10,
774
775 EC_FEATURE_BKLIGHT_SWITCH = 11,
776
777 EC_FEATURE_WIFI_SWITCH = 12,
778
779 EC_FEATURE_HOST_EVENTS = 13,
780
781 EC_FEATURE_GPIO = 14,
782
783 EC_FEATURE_I2C = 15,
784
785 EC_FEATURE_CHARGER = 16,
786
787 EC_FEATURE_BATTERY = 17,
788
789
790
791
792 EC_FEATURE_SMART_BATTERY = 18,
793
794 EC_FEATURE_HANG_DETECT = 19,
795
796 EC_FEATURE_PMU = 20,
797
798 EC_FEATURE_SUB_MCU = 21,
799
800 EC_FEATURE_USB_PD = 22,
801
802 EC_FEATURE_USB_MUX = 23,
803
804 EC_FEATURE_MOTION_SENSE_FIFO = 24,
805
806 EC_FEATURE_RTC = 27,
807
808 EC_FEATURE_CEC = 35,
809};
810
811#define EC_FEATURE_MASK_0(event_code) (1UL << (event_code % 32))
812#define EC_FEATURE_MASK_1(event_code) (1UL << (event_code - 32))
813struct ec_response_get_features {
814 uint32_t flags[2];
815} __packed;
816
817
818
819
820
821#define EC_CMD_FLASH_INFO 0x10
822
823
824struct ec_response_flash_info {
825
826 uint32_t flash_size;
827
828
829
830
831 uint32_t write_block_size;
832
833
834
835
836 uint32_t erase_block_size;
837
838
839
840
841 uint32_t protect_block_size;
842} __packed;
843
844
845
846#define EC_FLASH_INFO_ERASE_TO_0 (1 << 0)
847
848
849
850
851
852
853
854
855struct ec_response_flash_info_1 {
856
857 uint32_t flash_size;
858 uint32_t write_block_size;
859 uint32_t erase_block_size;
860 uint32_t protect_block_size;
861
862
863
864
865
866
867
868
869 uint32_t write_ideal_size;
870
871
872 uint32_t flags;
873} __packed;
874
875
876
877
878
879
880#define EC_CMD_FLASH_READ 0x11
881
882struct ec_params_flash_read {
883 uint32_t offset;
884 uint32_t size;
885} __packed;
886
887
888#define EC_CMD_FLASH_WRITE 0x12
889#define EC_VER_FLASH_WRITE 1
890
891
892#define EC_FLASH_WRITE_VER0_SIZE 64
893
894struct ec_params_flash_write {
895 uint32_t offset;
896 uint32_t size;
897
898} __packed;
899
900
901#define EC_CMD_FLASH_ERASE 0x13
902
903struct ec_params_flash_erase {
904 uint32_t offset;
905 uint32_t size;
906} __packed;
907
908
909
910
911
912
913
914
915
916
917
918#define EC_CMD_FLASH_PROTECT 0x15
919#define EC_VER_FLASH_PROTECT 1
920
921
922
923#define EC_FLASH_PROTECT_RO_AT_BOOT (1 << 0)
924
925
926
927
928#define EC_FLASH_PROTECT_RO_NOW (1 << 1)
929
930#define EC_FLASH_PROTECT_ALL_NOW (1 << 2)
931
932#define EC_FLASH_PROTECT_GPIO_ASSERTED (1 << 3)
933
934#define EC_FLASH_PROTECT_ERROR_STUCK (1 << 4)
935
936
937
938
939
940#define EC_FLASH_PROTECT_ERROR_INCONSISTENT (1 << 5)
941
942#define EC_FLASH_PROTECT_ALL_AT_BOOT (1 << 6)
943
944struct ec_params_flash_protect {
945 uint32_t mask;
946 uint32_t flags;
947} __packed;
948
949struct ec_response_flash_protect {
950
951 uint32_t flags;
952
953
954
955
956
957 uint32_t valid_flags;
958
959 uint32_t writable_flags;
960} __packed;
961
962
963
964
965
966
967
968#define EC_CMD_FLASH_REGION_INFO 0x16
969#define EC_VER_FLASH_REGION_INFO 1
970
971enum ec_flash_region {
972
973 EC_FLASH_REGION_RO = 0,
974
975 EC_FLASH_REGION_RW,
976
977
978
979
980 EC_FLASH_REGION_WP_RO,
981
982 EC_FLASH_REGION_COUNT,
983};
984
985struct ec_params_flash_region_info {
986 uint32_t region;
987} __packed;
988
989struct ec_response_flash_region_info {
990 uint32_t offset;
991 uint32_t size;
992} __packed;
993
994
995#define EC_CMD_VBNV_CONTEXT 0x17
996#define EC_VER_VBNV_CONTEXT 1
997#define EC_VBNV_BLOCK_SIZE 16
998
999enum ec_vbnvcontext_op {
1000 EC_VBNV_CONTEXT_OP_READ,
1001 EC_VBNV_CONTEXT_OP_WRITE,
1002};
1003
1004struct ec_params_vbnvcontext {
1005 uint32_t op;
1006 uint8_t block[EC_VBNV_BLOCK_SIZE];
1007} __packed;
1008
1009struct ec_response_vbnvcontext {
1010 uint8_t block[EC_VBNV_BLOCK_SIZE];
1011} __packed;
1012
1013
1014
1015
1016
1017#define EC_CMD_PWM_GET_FAN_TARGET_RPM 0x20
1018
1019struct ec_response_pwm_get_fan_rpm {
1020 uint32_t rpm;
1021} __packed;
1022
1023
1024#define EC_CMD_PWM_SET_FAN_TARGET_RPM 0x21
1025
1026struct ec_params_pwm_set_fan_target_rpm {
1027 uint32_t rpm;
1028} __packed;
1029
1030
1031#define EC_CMD_PWM_GET_KEYBOARD_BACKLIGHT 0x22
1032
1033struct ec_response_pwm_get_keyboard_backlight {
1034 uint8_t percent;
1035 uint8_t enabled;
1036} __packed;
1037
1038
1039#define EC_CMD_PWM_SET_KEYBOARD_BACKLIGHT 0x23
1040
1041struct ec_params_pwm_set_keyboard_backlight {
1042 uint8_t percent;
1043} __packed;
1044
1045
1046#define EC_CMD_PWM_SET_FAN_DUTY 0x24
1047
1048struct ec_params_pwm_set_fan_duty {
1049 uint32_t percent;
1050} __packed;
1051
1052#define EC_CMD_PWM_SET_DUTY 0x25
1053
1054#define EC_PWM_MAX_DUTY 0xffff
1055
1056enum ec_pwm_type {
1057
1058 EC_PWM_TYPE_GENERIC = 0,
1059
1060 EC_PWM_TYPE_KB_LIGHT,
1061
1062 EC_PWM_TYPE_DISPLAY_LIGHT,
1063 EC_PWM_TYPE_COUNT,
1064};
1065
1066struct ec_params_pwm_set_duty {
1067 uint16_t duty;
1068 uint8_t pwm_type;
1069 uint8_t index;
1070} __packed;
1071
1072#define EC_CMD_PWM_GET_DUTY 0x26
1073
1074struct ec_params_pwm_get_duty {
1075 uint8_t pwm_type;
1076 uint8_t index;
1077} __packed;
1078
1079struct ec_response_pwm_get_duty {
1080 uint16_t duty;
1081} __packed;
1082
1083
1084
1085
1086
1087
1088
1089
1090#define EC_CMD_LIGHTBAR_CMD 0x28
1091
1092struct rgb_s {
1093 uint8_t r, g, b;
1094};
1095
1096#define LB_BATTERY_LEVELS 4
1097
1098
1099
1100struct lightbar_params_v0 {
1101
1102 int32_t google_ramp_up;
1103 int32_t google_ramp_down;
1104 int32_t s3s0_ramp_up;
1105 int32_t s0_tick_delay[2];
1106 int32_t s0a_tick_delay[2];
1107 int32_t s0s3_ramp_down;
1108 int32_t s3_sleep_for;
1109 int32_t s3_ramp_up;
1110 int32_t s3_ramp_down;
1111
1112
1113 uint8_t new_s0;
1114 uint8_t osc_min[2];
1115 uint8_t osc_max[2];
1116 uint8_t w_ofs[2];
1117
1118
1119 uint8_t bright_bl_off_fixed[2];
1120 uint8_t bright_bl_on_min[2];
1121 uint8_t bright_bl_on_max[2];
1122
1123
1124 uint8_t battery_threshold[LB_BATTERY_LEVELS - 1];
1125
1126
1127 uint8_t s0_idx[2][LB_BATTERY_LEVELS];
1128 uint8_t s3_idx[2][LB_BATTERY_LEVELS];
1129
1130
1131 struct rgb_s color[8];
1132} __packed;
1133
1134struct lightbar_params_v1 {
1135
1136 int32_t google_ramp_up;
1137 int32_t google_ramp_down;
1138 int32_t s3s0_ramp_up;
1139 int32_t s0_tick_delay[2];
1140 int32_t s0a_tick_delay[2];
1141 int32_t s0s3_ramp_down;
1142 int32_t s3_sleep_for;
1143 int32_t s3_ramp_up;
1144 int32_t s3_ramp_down;
1145 int32_t tap_tick_delay;
1146 int32_t tap_display_time;
1147
1148
1149 uint8_t tap_pct_red;
1150 uint8_t tap_pct_green;
1151 uint8_t tap_seg_min_on;
1152 uint8_t tap_seg_max_on;
1153 uint8_t tap_seg_osc;
1154 uint8_t tap_idx[3];
1155
1156
1157 uint8_t osc_min[2];
1158 uint8_t osc_max[2];
1159 uint8_t w_ofs[2];
1160
1161
1162 uint8_t bright_bl_off_fixed[2];
1163 uint8_t bright_bl_on_min[2];
1164 uint8_t bright_bl_on_max[2];
1165
1166
1167 uint8_t battery_threshold[LB_BATTERY_LEVELS - 1];
1168
1169
1170 uint8_t s0_idx[2][LB_BATTERY_LEVELS];
1171 uint8_t s3_idx[2][LB_BATTERY_LEVELS];
1172
1173
1174 struct rgb_s color[8];
1175} __packed;
1176
1177
1178#define EC_LB_PROG_LEN 192
1179struct lightbar_program {
1180 uint8_t size;
1181 uint8_t data[EC_LB_PROG_LEN];
1182};
1183
1184struct ec_params_lightbar {
1185 uint8_t cmd;
1186 union {
1187 struct {
1188
1189 } dump, off, on, init, get_seq, get_params_v0, get_params_v1,
1190 version, get_brightness, get_demo, suspend, resume;
1191
1192 struct {
1193 uint8_t num;
1194 } set_brightness, seq, demo;
1195
1196 struct {
1197 uint8_t ctrl, reg, value;
1198 } reg;
1199
1200 struct {
1201 uint8_t led, red, green, blue;
1202 } set_rgb;
1203
1204 struct {
1205 uint8_t led;
1206 } get_rgb;
1207
1208 struct {
1209 uint8_t enable;
1210 } manual_suspend_ctrl;
1211
1212 struct lightbar_params_v0 set_params_v0;
1213 struct lightbar_params_v1 set_params_v1;
1214 struct lightbar_program set_program;
1215 };
1216} __packed;
1217
1218struct ec_response_lightbar {
1219 union {
1220 struct {
1221 struct {
1222 uint8_t reg;
1223 uint8_t ic0;
1224 uint8_t ic1;
1225 } vals[23];
1226 } dump;
1227
1228 struct {
1229 uint8_t num;
1230 } get_seq, get_brightness, get_demo;
1231
1232 struct lightbar_params_v0 get_params_v0;
1233 struct lightbar_params_v1 get_params_v1;
1234
1235 struct {
1236 uint32_t num;
1237 uint32_t flags;
1238 } version;
1239
1240 struct {
1241 uint8_t red, green, blue;
1242 } get_rgb;
1243
1244 struct {
1245
1246 } off, on, init, set_brightness, seq, reg, set_rgb,
1247 demo, set_params_v0, set_params_v1,
1248 set_program, manual_suspend_ctrl, suspend, resume;
1249 };
1250} __packed;
1251
1252
1253enum lightbar_command {
1254 LIGHTBAR_CMD_DUMP = 0,
1255 LIGHTBAR_CMD_OFF = 1,
1256 LIGHTBAR_CMD_ON = 2,
1257 LIGHTBAR_CMD_INIT = 3,
1258 LIGHTBAR_CMD_SET_BRIGHTNESS = 4,
1259 LIGHTBAR_CMD_SEQ = 5,
1260 LIGHTBAR_CMD_REG = 6,
1261 LIGHTBAR_CMD_SET_RGB = 7,
1262 LIGHTBAR_CMD_GET_SEQ = 8,
1263 LIGHTBAR_CMD_DEMO = 9,
1264 LIGHTBAR_CMD_GET_PARAMS_V0 = 10,
1265 LIGHTBAR_CMD_SET_PARAMS_V0 = 11,
1266 LIGHTBAR_CMD_VERSION = 12,
1267 LIGHTBAR_CMD_GET_BRIGHTNESS = 13,
1268 LIGHTBAR_CMD_GET_RGB = 14,
1269 LIGHTBAR_CMD_GET_DEMO = 15,
1270 LIGHTBAR_CMD_GET_PARAMS_V1 = 16,
1271 LIGHTBAR_CMD_SET_PARAMS_V1 = 17,
1272 LIGHTBAR_CMD_SET_PROGRAM = 18,
1273 LIGHTBAR_CMD_MANUAL_SUSPEND_CTRL = 19,
1274 LIGHTBAR_CMD_SUSPEND = 20,
1275 LIGHTBAR_CMD_RESUME = 21,
1276 LIGHTBAR_NUM_CMDS
1277};
1278
1279
1280
1281
1282#define EC_CMD_LED_CONTROL 0x29
1283
1284enum ec_led_id {
1285
1286 EC_LED_ID_BATTERY_LED = 0,
1287
1288
1289
1290
1291 EC_LED_ID_POWER_LED,
1292
1293 EC_LED_ID_ADAPTER_LED,
1294
1295 EC_LED_ID_COUNT
1296};
1297
1298
1299#define EC_LED_FLAGS_QUERY (1 << 0)
1300#define EC_LED_FLAGS_AUTO (1 << 1)
1301
1302enum ec_led_colors {
1303 EC_LED_COLOR_RED = 0,
1304 EC_LED_COLOR_GREEN,
1305 EC_LED_COLOR_BLUE,
1306 EC_LED_COLOR_YELLOW,
1307 EC_LED_COLOR_WHITE,
1308
1309 EC_LED_COLOR_COUNT
1310};
1311
1312struct ec_params_led_control {
1313 uint8_t led_id;
1314 uint8_t flags;
1315
1316 uint8_t brightness[EC_LED_COLOR_COUNT];
1317} __packed;
1318
1319struct ec_response_led_control {
1320
1321
1322
1323
1324
1325
1326
1327 uint8_t brightness_range[EC_LED_COLOR_COUNT];
1328} __packed;
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339#define EC_CMD_VBOOT_HASH 0x2A
1340
1341struct ec_params_vboot_hash {
1342 uint8_t cmd;
1343 uint8_t hash_type;
1344 uint8_t nonce_size;
1345 uint8_t reserved0;
1346 uint32_t offset;
1347 uint32_t size;
1348 uint8_t nonce_data[64];
1349} __packed;
1350
1351struct ec_response_vboot_hash {
1352 uint8_t status;
1353 uint8_t hash_type;
1354 uint8_t digest_size;
1355 uint8_t reserved0;
1356 uint32_t offset;
1357 uint32_t size;
1358 uint8_t hash_digest[64];
1359} __packed;
1360
1361enum ec_vboot_hash_cmd {
1362 EC_VBOOT_HASH_GET = 0,
1363 EC_VBOOT_HASH_ABORT = 1,
1364 EC_VBOOT_HASH_START = 2,
1365 EC_VBOOT_HASH_RECALC = 3,
1366};
1367
1368enum ec_vboot_hash_type {
1369 EC_VBOOT_HASH_TYPE_SHA256 = 0,
1370};
1371
1372enum ec_vboot_hash_status {
1373 EC_VBOOT_HASH_STATUS_NONE = 0,
1374 EC_VBOOT_HASH_STATUS_DONE = 1,
1375 EC_VBOOT_HASH_STATUS_BUSY = 2,
1376};
1377
1378
1379
1380
1381
1382
1383#define EC_VBOOT_HASH_OFFSET_RO 0xfffffffe
1384#define EC_VBOOT_HASH_OFFSET_RW 0xfffffffd
1385
1386
1387
1388
1389
1390
1391#define EC_CMD_MOTION_SENSE_CMD 0x2B
1392
1393
1394enum motionsense_command {
1395
1396
1397
1398
1399 MOTIONSENSE_CMD_DUMP = 0,
1400
1401
1402
1403
1404
1405
1406 MOTIONSENSE_CMD_INFO = 1,
1407
1408
1409
1410
1411
1412 MOTIONSENSE_CMD_EC_RATE = 2,
1413
1414
1415
1416
1417
1418 MOTIONSENSE_CMD_SENSOR_ODR = 3,
1419
1420
1421
1422
1423
1424 MOTIONSENSE_CMD_SENSOR_RANGE = 4,
1425
1426
1427
1428
1429
1430
1431
1432
1433 MOTIONSENSE_CMD_KB_WAKE_ANGLE = 5,
1434
1435
1436
1437
1438 MOTIONSENSE_CMD_DATA = 6,
1439
1440
1441
1442
1443
1444 MOTIONSENSE_CMD_PERFORM_CALIB = 10,
1445
1446
1447
1448
1449
1450
1451 MOTIONSENSE_CMD_SENSOR_OFFSET = 11,
1452
1453
1454 MOTIONSENSE_NUM_CMDS
1455};
1456
1457enum motionsensor_id {
1458 EC_MOTION_SENSOR_ACCEL_BASE = 0,
1459 EC_MOTION_SENSOR_ACCEL_LID = 1,
1460 EC_MOTION_SENSOR_GYRO = 2,
1461
1462
1463
1464
1465
1466 EC_MOTION_SENSOR_COUNT = 3
1467};
1468
1469
1470enum motionsensor_type {
1471 MOTIONSENSE_TYPE_ACCEL = 0,
1472 MOTIONSENSE_TYPE_GYRO = 1,
1473 MOTIONSENSE_TYPE_MAG = 2,
1474 MOTIONSENSE_TYPE_PROX = 3,
1475 MOTIONSENSE_TYPE_LIGHT = 4,
1476 MOTIONSENSE_TYPE_ACTIVITY = 5,
1477 MOTIONSENSE_TYPE_BARO = 6,
1478 MOTIONSENSE_TYPE_MAX,
1479};
1480
1481
1482enum motionsensor_location {
1483 MOTIONSENSE_LOC_BASE = 0,
1484 MOTIONSENSE_LOC_LID = 1,
1485 MOTIONSENSE_LOC_MAX,
1486};
1487
1488
1489enum motionsensor_chip {
1490 MOTIONSENSE_CHIP_KXCJ9 = 0,
1491};
1492
1493
1494#define MOTIONSENSE_MODULE_FLAG_ACTIVE (1<<0)
1495
1496
1497#define MOTIONSENSE_SENSOR_FLAG_PRESENT (1<<0)
1498
1499
1500
1501
1502
1503
1504#define EC_MOTION_SENSE_NO_VALUE -1
1505
1506#define EC_MOTION_SENSE_INVALID_CALIB_TEMP 0x8000
1507
1508
1509#define MOTION_SENSE_SET_OFFSET 1
1510
1511struct ec_response_motion_sensor_data {
1512
1513 uint8_t flags;
1514
1515 uint8_t sensor_num;
1516
1517 union {
1518 int16_t data[3];
1519 struct {
1520 uint16_t rsvd;
1521 uint32_t timestamp;
1522 } __packed;
1523 struct {
1524 uint8_t activity;
1525 uint8_t state;
1526 int16_t add_info[2];
1527 };
1528 };
1529} __packed;
1530
1531struct ec_params_motion_sense {
1532 uint8_t cmd;
1533 union {
1534
1535 struct {
1536
1537 } dump;
1538
1539
1540
1541
1542
1543 struct {
1544
1545 int16_t data;
1546 } ec_rate, kb_wake_angle;
1547
1548
1549 struct {
1550 uint8_t sensor_num;
1551
1552
1553
1554
1555
1556
1557 uint16_t flags;
1558
1559
1560
1561
1562
1563
1564
1565 int16_t temp;
1566
1567
1568
1569
1570
1571
1572
1573
1574 int16_t offset[3];
1575 } __packed sensor_offset;
1576
1577
1578 struct {
1579 uint8_t sensor_num;
1580 } info;
1581
1582
1583
1584
1585
1586 struct {
1587
1588 uint8_t sensor_num;
1589
1590
1591 uint8_t roundup;
1592
1593 uint16_t reserved;
1594
1595
1596 int32_t data;
1597 } sensor_odr, sensor_range;
1598 };
1599} __packed;
1600
1601struct ec_response_motion_sense {
1602 union {
1603
1604 struct {
1605
1606 uint8_t module_flags;
1607
1608
1609 uint8_t sensor_count;
1610
1611
1612
1613
1614
1615 struct ec_response_motion_sensor_data sensor[0];
1616 } dump;
1617
1618
1619 struct {
1620
1621 uint8_t type;
1622
1623
1624 uint8_t location;
1625
1626
1627 uint8_t chip;
1628 } info;
1629
1630
1631 struct ec_response_motion_sensor_data data;
1632
1633
1634
1635
1636
1637
1638 struct {
1639
1640 int32_t ret;
1641 } ec_rate, sensor_odr, sensor_range, kb_wake_angle;
1642
1643
1644 struct {
1645 int16_t temp;
1646 int16_t offset[3];
1647 } sensor_offset, perform_calib;
1648 };
1649} __packed;
1650
1651
1652
1653
1654
1655#define EC_CMD_USB_CHARGE_SET_MODE 0x30
1656
1657struct ec_params_usb_charge_set_mode {
1658 uint8_t usb_port_id;
1659 uint8_t mode;
1660} __packed;
1661
1662
1663
1664
1665
1666#define EC_PSTORE_SIZE_MAX 64
1667
1668
1669#define EC_CMD_PSTORE_INFO 0x40
1670
1671struct ec_response_pstore_info {
1672
1673 uint32_t pstore_size;
1674
1675 uint32_t access_size;
1676} __packed;
1677
1678
1679
1680
1681
1682
1683#define EC_CMD_PSTORE_READ 0x41
1684
1685struct ec_params_pstore_read {
1686 uint32_t offset;
1687 uint32_t size;
1688} __packed;
1689
1690
1691#define EC_CMD_PSTORE_WRITE 0x42
1692
1693struct ec_params_pstore_write {
1694 uint32_t offset;
1695 uint32_t size;
1696 uint8_t data[EC_PSTORE_SIZE_MAX];
1697} __packed;
1698
1699
1700
1701
1702
1703struct ec_params_rtc {
1704 uint32_t time;
1705} __packed;
1706
1707struct ec_response_rtc {
1708 uint32_t time;
1709} __packed;
1710
1711
1712#define EC_CMD_RTC_GET_VALUE 0x44
1713#define EC_CMD_RTC_GET_ALARM 0x45
1714
1715
1716#define EC_CMD_RTC_SET_VALUE 0x46
1717#define EC_CMD_RTC_SET_ALARM 0x47
1718
1719
1720#define EC_RTC_ALARM_CLEAR 0
1721
1722
1723
1724
1725
1726#define EC_PORT80_SIZE_MAX 32
1727
1728
1729#define EC_CMD_PORT80_LAST_BOOT 0x48
1730#define EC_CMD_PORT80_READ 0x48
1731
1732enum ec_port80_subcmd {
1733 EC_PORT80_GET_INFO = 0,
1734 EC_PORT80_READ_BUFFER,
1735};
1736
1737struct ec_params_port80_read {
1738 uint16_t subcmd;
1739 union {
1740 struct {
1741 uint32_t offset;
1742 uint32_t num_entries;
1743 } read_buffer;
1744 };
1745} __packed;
1746
1747struct ec_response_port80_read {
1748 union {
1749 struct {
1750 uint32_t writes;
1751 uint32_t history_size;
1752 uint32_t last_boot;
1753 } get_info;
1754 struct {
1755 uint16_t codes[EC_PORT80_SIZE_MAX];
1756 } data;
1757 };
1758} __packed;
1759
1760struct ec_response_port80_last_boot {
1761 uint16_t code;
1762} __packed;
1763
1764
1765
1766
1767
1768
1769
1770
1771#define EC_CMD_THERMAL_SET_THRESHOLD 0x50
1772#define EC_CMD_THERMAL_GET_THRESHOLD 0x51
1773
1774
1775
1776
1777
1778
1779struct ec_params_thermal_set_threshold {
1780 uint8_t sensor_type;
1781 uint8_t threshold_id;
1782 uint16_t value;
1783} __packed;
1784
1785
1786struct ec_params_thermal_get_threshold {
1787 uint8_t sensor_type;
1788 uint8_t threshold_id;
1789} __packed;
1790
1791struct ec_response_thermal_get_threshold {
1792 uint16_t value;
1793} __packed;
1794
1795
1796
1797enum ec_temp_thresholds {
1798 EC_TEMP_THRESH_WARN = 0,
1799 EC_TEMP_THRESH_HIGH,
1800 EC_TEMP_THRESH_HALT,
1801
1802 EC_TEMP_THRESH_COUNT
1803};
1804
1805
1806
1807
1808struct ec_thermal_config {
1809 uint32_t temp_host[EC_TEMP_THRESH_COUNT];
1810 uint32_t temp_fan_off;
1811 uint32_t temp_fan_max;
1812} __packed;
1813
1814
1815struct ec_params_thermal_get_threshold_v1 {
1816 uint32_t sensor_num;
1817} __packed;
1818
1819
1820
1821
1822struct ec_params_thermal_set_threshold_v1 {
1823 uint32_t sensor_num;
1824 struct ec_thermal_config cfg;
1825} __packed;
1826
1827
1828
1829
1830
1831#define EC_CMD_THERMAL_AUTO_FAN_CTRL 0x52
1832
1833
1834#define EC_CMD_TMP006_GET_CALIBRATION 0x53
1835
1836struct ec_params_tmp006_get_calibration {
1837 uint8_t index;
1838} __packed;
1839
1840struct ec_response_tmp006_get_calibration {
1841 float s0;
1842 float b0;
1843 float b1;
1844 float b2;
1845} __packed;
1846
1847
1848#define EC_CMD_TMP006_SET_CALIBRATION 0x54
1849
1850struct ec_params_tmp006_set_calibration {
1851 uint8_t index;
1852 uint8_t reserved[3];
1853 float s0;
1854 float b0;
1855 float b1;
1856 float b2;
1857} __packed;
1858
1859
1860#define EC_CMD_TMP006_GET_RAW 0x55
1861
1862struct ec_params_tmp006_get_raw {
1863 uint8_t index;
1864} __packed;
1865
1866struct ec_response_tmp006_get_raw {
1867 int32_t t;
1868 int32_t v;
1869};
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884#define EC_CMD_MKBP_STATE 0x60
1885
1886
1887
1888
1889#define EC_CMD_MKBP_INFO 0x61
1890
1891struct ec_response_mkbp_info {
1892 uint32_t rows;
1893 uint32_t cols;
1894
1895 uint8_t reserved;
1896} __packed;
1897
1898struct ec_params_mkbp_info {
1899 uint8_t info_type;
1900 uint8_t event_type;
1901} __packed;
1902
1903enum ec_mkbp_info_type {
1904
1905
1906
1907
1908
1909 EC_MKBP_INFO_KBD = 0,
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920 EC_MKBP_INFO_SUPPORTED = 1,
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939 EC_MKBP_INFO_CURRENT = 2,
1940};
1941
1942
1943#define EC_CMD_MKBP_SIMULATE_KEY 0x62
1944
1945struct ec_params_mkbp_simulate_key {
1946 uint8_t col;
1947 uint8_t row;
1948 uint8_t pressed;
1949} __packed;
1950
1951
1952#define EC_CMD_MKBP_SET_CONFIG 0x64
1953#define EC_CMD_MKBP_GET_CONFIG 0x65
1954
1955
1956enum mkbp_config_flags {
1957 EC_MKBP_FLAGS_ENABLE = 1,
1958};
1959
1960enum mkbp_config_valid {
1961 EC_MKBP_VALID_SCAN_PERIOD = 1 << 0,
1962 EC_MKBP_VALID_POLL_TIMEOUT = 1 << 1,
1963 EC_MKBP_VALID_MIN_POST_SCAN_DELAY = 1 << 3,
1964 EC_MKBP_VALID_OUTPUT_SETTLE = 1 << 4,
1965 EC_MKBP_VALID_DEBOUNCE_DOWN = 1 << 5,
1966 EC_MKBP_VALID_DEBOUNCE_UP = 1 << 6,
1967 EC_MKBP_VALID_FIFO_MAX_DEPTH = 1 << 7,
1968};
1969
1970
1971struct ec_mkbp_config {
1972 uint32_t valid_mask;
1973 uint8_t flags;
1974 uint8_t valid_flags;
1975 uint16_t scan_period_us;
1976
1977 uint32_t poll_timeout_us;
1978
1979
1980
1981
1982
1983 uint16_t min_post_scan_delay_us;
1984
1985 uint16_t output_settle_us;
1986 uint16_t debounce_down_us;
1987 uint16_t debounce_up_us;
1988
1989 uint8_t fifo_max_depth;
1990} __packed;
1991
1992struct ec_params_mkbp_set_config {
1993 struct ec_mkbp_config config;
1994} __packed;
1995
1996struct ec_response_mkbp_get_config {
1997 struct ec_mkbp_config config;
1998} __packed;
1999
2000
2001#define EC_CMD_KEYSCAN_SEQ_CTRL 0x66
2002
2003enum ec_keyscan_seq_cmd {
2004 EC_KEYSCAN_SEQ_STATUS = 0,
2005 EC_KEYSCAN_SEQ_CLEAR = 1,
2006 EC_KEYSCAN_SEQ_ADD = 2,
2007 EC_KEYSCAN_SEQ_START = 3,
2008 EC_KEYSCAN_SEQ_COLLECT = 4,
2009};
2010
2011enum ec_collect_flags {
2012
2013
2014
2015
2016 EC_KEYSCAN_SEQ_FLAG_DONE = 1 << 0,
2017};
2018
2019struct ec_collect_item {
2020 uint8_t flags;
2021};
2022
2023struct ec_params_keyscan_seq_ctrl {
2024 uint8_t cmd;
2025 union {
2026 struct {
2027 uint8_t active;
2028 uint8_t num_items;
2029
2030 uint8_t cur_item;
2031 } status;
2032 struct {
2033
2034
2035
2036
2037 uint32_t time_us;
2038 uint8_t scan[0];
2039 } add;
2040 struct {
2041 uint8_t start_item;
2042 uint8_t num_items;
2043 } collect;
2044 };
2045} __packed;
2046
2047struct ec_result_keyscan_seq_ctrl {
2048 union {
2049 struct {
2050 uint8_t num_items;
2051
2052 struct ec_collect_item item[0];
2053 } collect;
2054 };
2055} __packed;
2056
2057
2058
2059
2060
2061
2062#define EC_CMD_GET_NEXT_EVENT 0x67
2063
2064enum ec_mkbp_event {
2065
2066 EC_MKBP_EVENT_KEY_MATRIX = 0,
2067
2068
2069 EC_MKBP_EVENT_HOST_EVENT = 1,
2070
2071
2072 EC_MKBP_EVENT_SENSOR_FIFO = 2,
2073
2074
2075 EC_MKBP_EVENT_BUTTON = 3,
2076
2077
2078 EC_MKBP_EVENT_SWITCH = 4,
2079
2080
2081 EC_MKBP_EVENT_SYSRQ = 6,
2082
2083
2084 EC_MKBP_EVENT_CEC_EVENT = 8,
2085
2086
2087 EC_MKBP_EVENT_CEC_MESSAGE = 9,
2088
2089
2090 EC_MKBP_EVENT_COUNT,
2091};
2092
2093union ec_response_get_next_data {
2094 uint8_t key_matrix[13];
2095
2096
2097 uint32_t host_event;
2098
2099 uint32_t buttons;
2100 uint32_t switches;
2101 uint32_t sysrq;
2102} __packed;
2103
2104union ec_response_get_next_data_v1 {
2105 uint8_t key_matrix[16];
2106 uint32_t host_event;
2107 uint32_t buttons;
2108 uint32_t switches;
2109 uint32_t sysrq;
2110 uint32_t cec_events;
2111 uint8_t cec_message[16];
2112} __packed;
2113
2114struct ec_response_get_next_event {
2115 uint8_t event_type;
2116
2117 union ec_response_get_next_data data;
2118} __packed;
2119
2120struct ec_response_get_next_event_v1 {
2121 uint8_t event_type;
2122
2123 union ec_response_get_next_data_v1 data;
2124} __packed;
2125
2126
2127
2128#define EC_MKBP_POWER_BUTTON 0
2129#define EC_MKBP_VOL_UP 1
2130#define EC_MKBP_VOL_DOWN 2
2131
2132
2133#define EC_MKBP_LID_OPEN 0
2134#define EC_MKBP_TABLET_MODE 1
2135
2136
2137
2138
2139
2140#define EC_CMD_TEMP_SENSOR_GET_INFO 0x70
2141
2142struct ec_params_temp_sensor_get_info {
2143 uint8_t id;
2144} __packed;
2145
2146struct ec_response_temp_sensor_get_info {
2147 char sensor_name[32];
2148 uint8_t sensor_type;
2149} __packed;
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166struct ec_params_host_event_mask {
2167 uint32_t mask;
2168} __packed;
2169
2170struct ec_response_host_event_mask {
2171 uint32_t mask;
2172} __packed;
2173
2174
2175#define EC_CMD_HOST_EVENT_GET_B 0x87
2176#define EC_CMD_HOST_EVENT_GET_SMI_MASK 0x88
2177#define EC_CMD_HOST_EVENT_GET_SCI_MASK 0x89
2178#define EC_CMD_HOST_EVENT_GET_WAKE_MASK 0x8d
2179
2180
2181#define EC_CMD_HOST_EVENT_SET_SMI_MASK 0x8a
2182#define EC_CMD_HOST_EVENT_SET_SCI_MASK 0x8b
2183#define EC_CMD_HOST_EVENT_CLEAR 0x8c
2184#define EC_CMD_HOST_EVENT_SET_WAKE_MASK 0x8e
2185#define EC_CMD_HOST_EVENT_CLEAR_B 0x8f
2186
2187
2188
2189
2190
2191#define EC_CMD_SWITCH_ENABLE_BKLIGHT 0x90
2192
2193struct ec_params_switch_enable_backlight {
2194 uint8_t enabled;
2195} __packed;
2196
2197
2198#define EC_CMD_SWITCH_ENABLE_WIRELESS 0x91
2199#define EC_VER_SWITCH_ENABLE_WIRELESS 1
2200
2201
2202struct ec_params_switch_enable_wireless_v0 {
2203 uint8_t enabled;
2204} __packed;
2205
2206
2207struct ec_params_switch_enable_wireless_v1 {
2208
2209 uint8_t now_flags;
2210
2211
2212 uint8_t now_mask;
2213
2214
2215
2216
2217
2218
2219 uint8_t suspend_flags;
2220
2221
2222 uint8_t suspend_mask;
2223} __packed;
2224
2225
2226struct ec_response_switch_enable_wireless_v1 {
2227
2228 uint8_t now_flags;
2229
2230
2231 uint8_t suspend_flags;
2232} __packed;
2233
2234
2235
2236
2237
2238#define EC_CMD_GPIO_SET 0x92
2239
2240struct ec_params_gpio_set {
2241 char name[32];
2242 uint8_t val;
2243} __packed;
2244
2245
2246#define EC_CMD_GPIO_GET 0x93
2247
2248
2249struct ec_params_gpio_get {
2250 char name[32];
2251} __packed;
2252struct ec_response_gpio_get {
2253 uint8_t val;
2254} __packed;
2255
2256
2257struct ec_params_gpio_get_v1 {
2258 uint8_t subcmd;
2259 union {
2260 struct {
2261 char name[32];
2262 } get_value_by_name;
2263 struct {
2264 uint8_t index;
2265 } get_info;
2266 };
2267} __packed;
2268
2269struct ec_response_gpio_get_v1 {
2270 union {
2271 struct {
2272 uint8_t val;
2273 } get_value_by_name, get_count;
2274 struct {
2275 uint8_t val;
2276 char name[32];
2277 uint32_t flags;
2278 } get_info;
2279 };
2280} __packed;
2281
2282enum gpio_get_subcmd {
2283 EC_GPIO_GET_BY_NAME = 0,
2284 EC_GPIO_GET_COUNT = 1,
2285 EC_GPIO_GET_INFO = 2,
2286};
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297#define EC_CMD_I2C_READ 0x94
2298
2299struct ec_params_i2c_read {
2300 uint16_t addr;
2301 uint8_t read_size;
2302 uint8_t port;
2303 uint8_t offset;
2304} __packed;
2305struct ec_response_i2c_read {
2306 uint16_t data;
2307} __packed;
2308
2309
2310#define EC_CMD_I2C_WRITE 0x95
2311
2312struct ec_params_i2c_write {
2313 uint16_t data;
2314 uint16_t addr;
2315 uint8_t write_size;
2316 uint8_t port;
2317 uint8_t offset;
2318} __packed;
2319
2320
2321
2322
2323
2324
2325
2326#define EC_CMD_CHARGE_CONTROL 0x96
2327#define EC_VER_CHARGE_CONTROL 1
2328
2329enum ec_charge_control_mode {
2330 CHARGE_CONTROL_NORMAL = 0,
2331 CHARGE_CONTROL_IDLE,
2332 CHARGE_CONTROL_DISCHARGE,
2333};
2334
2335struct ec_params_charge_control {
2336 uint32_t mode;
2337} __packed;
2338
2339
2340
2341
2342
2343#define EC_CMD_CONSOLE_SNAPSHOT 0x97
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357#define EC_CMD_CONSOLE_READ 0x98
2358
2359enum ec_console_read_subcmd {
2360 CONSOLE_READ_NEXT = 0,
2361 CONSOLE_READ_RECENT
2362};
2363
2364struct ec_params_console_read_v1 {
2365 uint8_t subcmd;
2366} __packed;
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378#define EC_CMD_BATTERY_CUT_OFF 0x99
2379
2380#define EC_BATTERY_CUTOFF_FLAG_AT_SHUTDOWN (1 << 0)
2381
2382struct ec_params_battery_cutoff {
2383 uint8_t flags;
2384} __packed;
2385
2386
2387
2388
2389
2390
2391
2392#define EC_CMD_USB_MUX 0x9a
2393
2394struct ec_params_usb_mux {
2395 uint8_t mux;
2396} __packed;
2397
2398
2399
2400
2401enum ec_ldo_state {
2402 EC_LDO_STATE_OFF = 0,
2403 EC_LDO_STATE_ON = 1,
2404};
2405
2406
2407
2408
2409#define EC_CMD_LDO_SET 0x9b
2410
2411struct ec_params_ldo_set {
2412 uint8_t index;
2413 uint8_t state;
2414} __packed;
2415
2416
2417
2418
2419#define EC_CMD_LDO_GET 0x9c
2420
2421struct ec_params_ldo_get {
2422 uint8_t index;
2423} __packed;
2424
2425struct ec_response_ldo_get {
2426 uint8_t state;
2427} __packed;
2428
2429
2430
2431
2432
2433
2434
2435#define EC_CMD_POWER_INFO 0x9d
2436
2437struct ec_response_power_info {
2438 uint32_t usb_dev_type;
2439 uint16_t voltage_ac;
2440 uint16_t voltage_system;
2441 uint16_t current_system;
2442 uint16_t usb_current_limit;
2443} __packed;
2444
2445
2446
2447
2448#define EC_CMD_I2C_PASSTHRU 0x9e
2449
2450
2451#define EC_I2C_FLAG_READ (1 << 15)
2452
2453
2454#define EC_I2C_ADDR_MASK 0x3ff
2455
2456#define EC_I2C_STATUS_NAK (1 << 0)
2457#define EC_I2C_STATUS_TIMEOUT (1 << 1)
2458
2459
2460#define EC_I2C_STATUS_ERROR (EC_I2C_STATUS_NAK | EC_I2C_STATUS_TIMEOUT)
2461
2462struct ec_params_i2c_passthru_msg {
2463 uint16_t addr_flags;
2464 uint16_t len;
2465} __packed;
2466
2467struct ec_params_i2c_passthru {
2468 uint8_t port;
2469 uint8_t num_msgs;
2470 struct ec_params_i2c_passthru_msg msg[];
2471
2472} __packed;
2473
2474struct ec_response_i2c_passthru {
2475 uint8_t i2c_status;
2476 uint8_t num_msgs;
2477 uint8_t data[];
2478} __packed;
2479
2480
2481
2482
2483#define EC_CMD_HANG_DETECT 0x9f
2484
2485
2486
2487#define EC_HANG_START_ON_POWER_PRESS (1 << 0)
2488
2489
2490#define EC_HANG_START_ON_LID_CLOSE (1 << 1)
2491
2492
2493#define EC_HANG_START_ON_LID_OPEN (1 << 2)
2494
2495
2496#define EC_HANG_START_ON_RESUME (1 << 3)
2497
2498
2499
2500
2501#define EC_HANG_STOP_ON_POWER_RELEASE (1 << 8)
2502
2503
2504#define EC_HANG_STOP_ON_HOST_COMMAND (1 << 9)
2505
2506
2507#define EC_HANG_STOP_ON_SUSPEND (1 << 10)
2508
2509
2510
2511
2512
2513
2514
2515#define EC_HANG_START_NOW (1 << 30)
2516
2517
2518
2519
2520
2521
2522#define EC_HANG_STOP_NOW (1 << 31)
2523
2524struct ec_params_hang_detect {
2525
2526 uint32_t flags;
2527
2528
2529 uint16_t host_event_timeout_msec;
2530
2531
2532 uint16_t warm_reboot_timeout_msec;
2533} __packed;
2534
2535
2536
2537
2538
2539
2540
2541
2542#define EC_CMD_CHARGE_STATE 0xa0
2543
2544
2545enum charge_state_command {
2546 CHARGE_STATE_CMD_GET_STATE,
2547 CHARGE_STATE_CMD_GET_PARAM,
2548 CHARGE_STATE_CMD_SET_PARAM,
2549 CHARGE_STATE_NUM_CMDS
2550};
2551
2552
2553
2554
2555
2556enum charge_state_params {
2557 CS_PARAM_CHG_VOLTAGE,
2558 CS_PARAM_CHG_CURRENT,
2559 CS_PARAM_CHG_INPUT_CURRENT,
2560 CS_PARAM_CHG_STATUS,
2561 CS_PARAM_CHG_OPTION,
2562
2563 CS_NUM_BASE_PARAMS,
2564
2565
2566 CS_PARAM_CUSTOM_PROFILE_MIN = 0x10000,
2567 CS_PARAM_CUSTOM_PROFILE_MAX = 0x1ffff,
2568
2569
2570};
2571
2572struct ec_params_charge_state {
2573 uint8_t cmd;
2574 union {
2575 struct {
2576
2577 } get_state;
2578
2579 struct {
2580 uint32_t param;
2581 } get_param;
2582
2583 struct {
2584 uint32_t param;
2585 uint32_t value;
2586 } set_param;
2587 };
2588} __packed;
2589
2590struct ec_response_charge_state {
2591 union {
2592 struct {
2593 int ac;
2594 int chg_voltage;
2595 int chg_current;
2596 int chg_input_current;
2597 int batt_state_of_charge;
2598 } get_state;
2599
2600 struct {
2601 uint32_t value;
2602 } get_param;
2603 struct {
2604
2605 } set_param;
2606 };
2607} __packed;
2608
2609
2610
2611
2612
2613#define EC_CMD_CHARGE_CURRENT_LIMIT 0xa1
2614
2615struct ec_params_current_limit {
2616 uint32_t limit;
2617} __packed;
2618
2619
2620
2621
2622#define EC_CMD_EXTERNAL_POWER_LIMIT 0x00A2
2623
2624
2625struct ec_params_external_power_limit_v1 {
2626 uint16_t current_lim;
2627 uint16_t voltage_lim;
2628} __packed;
2629
2630#define EC_POWER_LIMIT_NONE 0xffff
2631
2632
2633#define EC_CMD_HOST_SLEEP_EVENT 0xa9
2634
2635enum host_sleep_event {
2636 HOST_SLEEP_EVENT_S3_SUSPEND = 1,
2637 HOST_SLEEP_EVENT_S3_RESUME = 2,
2638 HOST_SLEEP_EVENT_S0IX_SUSPEND = 3,
2639 HOST_SLEEP_EVENT_S0IX_RESUME = 4
2640};
2641
2642struct ec_params_host_sleep_event {
2643 uint8_t sleep_event;
2644} __packed;
2645
2646
2647
2648
2649
2650#define EC_CMD_SB_READ_WORD 0xb0
2651#define EC_CMD_SB_WRITE_WORD 0xb1
2652
2653
2654
2655
2656#define EC_CMD_SB_READ_BLOCK 0xb2
2657#define EC_CMD_SB_WRITE_BLOCK 0xb3
2658
2659struct ec_params_sb_rd {
2660 uint8_t reg;
2661} __packed;
2662
2663struct ec_response_sb_rd_word {
2664 uint16_t value;
2665} __packed;
2666
2667struct ec_params_sb_wr_word {
2668 uint8_t reg;
2669 uint16_t value;
2670} __packed;
2671
2672struct ec_response_sb_rd_block {
2673 uint8_t data[32];
2674} __packed;
2675
2676struct ec_params_sb_wr_block {
2677 uint8_t reg;
2678 uint16_t data[32];
2679} __packed;
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690#define EC_CMD_BATTERY_VENDOR_PARAM 0xb4
2691
2692enum ec_battery_vendor_param_mode {
2693 BATTERY_VENDOR_PARAM_MODE_GET = 0,
2694 BATTERY_VENDOR_PARAM_MODE_SET,
2695};
2696
2697struct ec_params_battery_vendor_param {
2698 uint32_t param;
2699 uint32_t value;
2700 uint8_t mode;
2701} __packed;
2702
2703struct ec_response_battery_vendor_param {
2704 uint32_t value;
2705} __packed;
2706
2707
2708
2709
2710
2711
2712
2713
2714#define EC_CMD_REBOOT_EC 0xd2
2715
2716
2717enum ec_reboot_cmd {
2718 EC_REBOOT_CANCEL = 0,
2719 EC_REBOOT_JUMP_RO = 1,
2720 EC_REBOOT_JUMP_RW = 2,
2721
2722 EC_REBOOT_COLD = 4,
2723 EC_REBOOT_DISABLE_JUMP = 5,
2724 EC_REBOOT_HIBERNATE = 6
2725};
2726
2727
2728#define EC_REBOOT_FLAG_RESERVED0 (1 << 0)
2729#define EC_REBOOT_FLAG_ON_AP_SHUTDOWN (1 << 1)
2730
2731struct ec_params_reboot_ec {
2732 uint8_t cmd;
2733 uint8_t flags;
2734} __packed;
2735
2736
2737
2738
2739
2740
2741
2742#define EC_CMD_GET_PANIC_INFO 0xd3
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764#define EC_CMD_ACPI_READ 0x80
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779#define EC_CMD_ACPI_WRITE 0x81
2780
2781
2782
2783
2784
2785
2786
2787
2788#define EC_CMD_ACPI_QUERY_EVENT 0x84
2789
2790
2791
2792
2793#define EC_ACPI_MEM_VERSION 0x00
2794
2795
2796
2797
2798#define EC_ACPI_MEM_TEST 0x01
2799
2800#define EC_ACPI_MEM_TEST_COMPLIMENT 0x02
2801
2802
2803#define EC_ACPI_MEM_KEYBOARD_BACKLIGHT 0x03
2804
2805#define EC_ACPI_MEM_FAN_DUTY 0x04
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822#define EC_ACPI_MEM_TEMP_ID 0x05
2823#define EC_ACPI_MEM_TEMP_THRESHOLD 0x06
2824#define EC_ACPI_MEM_TEMP_COMMIT 0x07
2825
2826
2827
2828
2829
2830
2831#define EC_ACPI_MEM_TEMP_COMMIT_SELECT_MASK (1 << 0)
2832#define EC_ACPI_MEM_TEMP_COMMIT_ENABLE_MASK (1 << 1)
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849#define EC_ACPI_MEM_CHARGING_LIMIT 0x08
2850
2851
2852#define EC_ACPI_MEM_CHARGING_LIMIT_STEP_MA 64
2853
2854#define EC_ACPI_MEM_CHARGING_LIMIT_DISABLED 0xff
2855
2856
2857#define EC_ACPI_MEM_VERSION_CURRENT 1
2858
2859
2860
2861
2862
2863
2864
2865
2866#define EC_MAX_CEC_MSG_LEN 16
2867
2868
2869#define EC_CMD_CEC_WRITE_MSG 0x00B8
2870
2871
2872
2873
2874
2875struct ec_params_cec_write {
2876 uint8_t msg[EC_MAX_CEC_MSG_LEN];
2877} __packed;
2878
2879
2880#define EC_CMD_CEC_SET 0x00BA
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890struct ec_params_cec_set {
2891 uint8_t cmd;
2892 uint8_t val;
2893} __packed;
2894
2895
2896#define EC_CMD_CEC_GET 0x00BB
2897
2898
2899
2900
2901
2902struct ec_params_cec_get {
2903 uint8_t cmd;
2904} __packed;
2905
2906
2907
2908
2909
2910
2911
2912
2913struct ec_response_cec_get {
2914 uint8_t val;
2915} __packed;
2916
2917
2918enum ec_cec_command {
2919
2920 CEC_CMD_ENABLE,
2921
2922 CEC_CMD_LOGICAL_ADDRESS,
2923};
2924
2925
2926enum mkbp_cec_event {
2927
2928 EC_MKBP_CEC_SEND_OK = BIT(0),
2929
2930 EC_MKBP_CEC_SEND_FAILED = BIT(1),
2931};
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950#define EC_CMD_REBOOT 0xd1
2951
2952
2953
2954
2955
2956
2957
2958
2959#define EC_CMD_RESEND_RESPONSE 0xdb
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971#define EC_CMD_VERSION0 0xdc
2972
2973#endif
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983#define EC_CMD_PD_EXCHANGE_STATUS 0x100
2984
2985
2986struct ec_params_pd_status {
2987 int8_t batt_soc;
2988} __packed;
2989
2990
2991struct ec_response_pd_status {
2992 int8_t status;
2993 uint32_t curr_lim_ma;
2994} __packed;
2995
2996
2997#define EC_CMD_USB_PD_CONTROL 0x101
2998
2999enum usb_pd_control_role {
3000 USB_PD_CTRL_ROLE_NO_CHANGE = 0,
3001 USB_PD_CTRL_ROLE_TOGGLE_ON = 1,
3002 USB_PD_CTRL_ROLE_TOGGLE_OFF = 2,
3003 USB_PD_CTRL_ROLE_FORCE_SINK = 3,
3004 USB_PD_CTRL_ROLE_FORCE_SOURCE = 4,
3005};
3006
3007enum usb_pd_control_mux {
3008 USB_PD_CTRL_MUX_NO_CHANGE = 0,
3009 USB_PD_CTRL_MUX_NONE = 1,
3010 USB_PD_CTRL_MUX_USB = 2,
3011 USB_PD_CTRL_MUX_DP = 3,
3012 USB_PD_CTRL_MUX_DOCK = 4,
3013 USB_PD_CTRL_MUX_AUTO = 5,
3014};
3015
3016enum usb_pd_control_swap {
3017 USB_PD_CTRL_SWAP_NONE = 0,
3018 USB_PD_CTRL_SWAP_DATA = 1,
3019 USB_PD_CTRL_SWAP_POWER = 2,
3020 USB_PD_CTRL_SWAP_VCONN = 3,
3021 USB_PD_CTRL_SWAP_COUNT
3022};
3023
3024struct ec_params_usb_pd_control {
3025 uint8_t port;
3026 uint8_t role;
3027 uint8_t mux;
3028 uint8_t swap;
3029} __packed;
3030
3031#define PD_CTRL_RESP_ENABLED_COMMS (1 << 0)
3032#define PD_CTRL_RESP_ENABLED_CONNECTED (1 << 1)
3033#define PD_CTRL_RESP_ENABLED_PD_CAPABLE (1 << 2)
3034
3035#define PD_CTRL_RESP_ROLE_POWER BIT(0)
3036#define PD_CTRL_RESP_ROLE_DATA BIT(1)
3037#define PD_CTRL_RESP_ROLE_VCONN BIT(2)
3038#define PD_CTRL_RESP_ROLE_DR_POWER BIT(3)
3039#define PD_CTRL_RESP_ROLE_DR_DATA BIT(4)
3040#define PD_CTRL_RESP_ROLE_USB_COMM BIT(5)
3041#define PD_CTRL_RESP_ROLE_EXT_POWERED BIT(6)
3042
3043struct ec_response_usb_pd_control_v1 {
3044 uint8_t enabled;
3045 uint8_t role;
3046 uint8_t polarity;
3047 char state[32];
3048} __packed;
3049
3050#define EC_CMD_USB_PD_PORTS 0x102
3051
3052
3053#define EC_USB_PD_MAX_PORTS 8
3054
3055struct ec_response_usb_pd_ports {
3056 uint8_t num_ports;
3057} __packed;
3058
3059#define EC_CMD_USB_PD_POWER_INFO 0x103
3060
3061#define PD_POWER_CHARGING_PORT 0xff
3062struct ec_params_usb_pd_power_info {
3063 uint8_t port;
3064} __packed;
3065
3066enum usb_chg_type {
3067 USB_CHG_TYPE_NONE,
3068 USB_CHG_TYPE_PD,
3069 USB_CHG_TYPE_C,
3070 USB_CHG_TYPE_PROPRIETARY,
3071 USB_CHG_TYPE_BC12_DCP,
3072 USB_CHG_TYPE_BC12_CDP,
3073 USB_CHG_TYPE_BC12_SDP,
3074 USB_CHG_TYPE_OTHER,
3075 USB_CHG_TYPE_VBUS,
3076 USB_CHG_TYPE_UNKNOWN,
3077};
3078enum usb_power_roles {
3079 USB_PD_PORT_POWER_DISCONNECTED,
3080 USB_PD_PORT_POWER_SOURCE,
3081 USB_PD_PORT_POWER_SINK,
3082 USB_PD_PORT_POWER_SINK_NOT_CHARGING,
3083};
3084
3085struct usb_chg_measures {
3086 uint16_t voltage_max;
3087 uint16_t voltage_now;
3088 uint16_t current_max;
3089 uint16_t current_lim;
3090} __packed;
3091
3092struct ec_response_usb_pd_power_info {
3093 uint8_t role;
3094 uint8_t type;
3095 uint8_t dualrole;
3096 uint8_t reserved1;
3097 struct usb_chg_measures meas;
3098 uint32_t max_power;
3099} __packed;
3100
3101struct ec_params_usb_pd_info_request {
3102 uint8_t port;
3103} __packed;
3104
3105
3106#define EC_CMD_USB_PD_DISCOVERY 0x0113
3107struct ec_params_usb_pd_discovery_entry {
3108 uint16_t vid;
3109 uint16_t pid;
3110 uint8_t ptype;
3111} __packed;
3112
3113
3114#define EC_CMD_PD_CHARGE_PORT_OVERRIDE 0x0114
3115
3116
3117enum usb_pd_override_ports {
3118 OVERRIDE_DONT_CHARGE = -2,
3119 OVERRIDE_OFF = -1,
3120
3121};
3122
3123struct ec_params_charge_port_override {
3124 int16_t override_port;
3125} __packed;
3126
3127
3128#define EC_CMD_PD_GET_LOG_ENTRY 0x0115
3129
3130struct ec_response_pd_log {
3131 uint32_t timestamp;
3132 uint8_t type;
3133 uint8_t size_port;
3134 uint16_t data;
3135 uint8_t payload[0];
3136} __packed;
3137
3138
3139#define PD_LOG_TIMESTAMP_SHIFT 10
3140
3141#define PD_LOG_SIZE_MASK 0x1f
3142#define PD_LOG_PORT_MASK 0xe0
3143#define PD_LOG_PORT_SHIFT 5
3144#define PD_LOG_PORT_SIZE(port, size) (((port) << PD_LOG_PORT_SHIFT) | \
3145 ((size) & PD_LOG_SIZE_MASK))
3146#define PD_LOG_PORT(size_port) ((size_port) >> PD_LOG_PORT_SHIFT)
3147#define PD_LOG_SIZE(size_port) ((size_port) & PD_LOG_SIZE_MASK)
3148
3149
3150
3151#define PD_EVENT_MCU_BASE 0x00
3152#define PD_EVENT_MCU_CHARGE (PD_EVENT_MCU_BASE+0)
3153#define PD_EVENT_MCU_CONNECT (PD_EVENT_MCU_BASE+1)
3154
3155#define PD_EVENT_MCU_BOARD_CUSTOM (PD_EVENT_MCU_BASE+2)
3156
3157#define PD_EVENT_ACC_BASE 0x20
3158#define PD_EVENT_ACC_RW_FAIL (PD_EVENT_ACC_BASE+0)
3159#define PD_EVENT_ACC_RW_ERASE (PD_EVENT_ACC_BASE+1)
3160
3161#define PD_EVENT_PS_BASE 0x40
3162#define PD_EVENT_PS_FAULT (PD_EVENT_PS_BASE+0)
3163
3164#define PD_EVENT_VIDEO_BASE 0x60
3165#define PD_EVENT_VIDEO_DP_MODE (PD_EVENT_VIDEO_BASE+0)
3166#define PD_EVENT_VIDEO_CODEC (PD_EVENT_VIDEO_BASE+1)
3167
3168#define PD_EVENT_NO_ENTRY 0xff
3169
3170
3171
3172
3173
3174
3175
3176#define CHARGE_FLAGS_DUAL_ROLE BIT(15)
3177
3178#define CHARGE_FLAGS_DELAYED_OVERRIDE BIT(14)
3179
3180#define CHARGE_FLAGS_OVERRIDE BIT(13)
3181
3182#define CHARGE_FLAGS_TYPE_SHIFT 3
3183#define CHARGE_FLAGS_TYPE_MASK (0xf << CHARGE_FLAGS_TYPE_SHIFT)
3184
3185#define CHARGE_FLAGS_ROLE_MASK (7 << 0)
3186
3187
3188
3189
3190#define PS_FAULT_OCP 1
3191#define PS_FAULT_FAST_OCP 2
3192#define PS_FAULT_OVP 3
3193#define PS_FAULT_DISCH 4
3194
3195
3196
3197
3198struct mcdp_version {
3199 uint8_t major;
3200 uint8_t minor;
3201 uint16_t build;
3202} __packed;
3203
3204struct mcdp_info {
3205 uint8_t family[2];
3206 uint8_t chipid[2];
3207 struct mcdp_version irom;
3208 struct mcdp_version fw;
3209} __packed;
3210
3211
3212#define MCDP_CHIPID(chipid) ((chipid[0] << 8) | chipid[1])
3213#define MCDP_FAMILY(family) ((family[0] << 8) | family[1])
3214
3215
3216#define EC_CMD_USB_PD_MUX_INFO 0x11a
3217
3218struct ec_params_usb_pd_mux_info {
3219 uint8_t port;
3220} __packed;
3221
3222
3223#define USB_PD_MUX_USB_ENABLED (1 << 0)
3224#define USB_PD_MUX_DP_ENABLED (1 << 1)
3225#define USB_PD_MUX_POLARITY_INVERTED (1 << 2)
3226#define USB_PD_MUX_HPD_IRQ (1 << 3)
3227
3228struct ec_response_usb_pd_mux_info {
3229 uint8_t flags;
3230} __packed;
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256#define EC_CMD_PASSTHRU_OFFSET(n) (0x4000 * (n))
3257#define EC_CMD_PASSTHRU_MAX(n) (EC_CMD_PASSTHRU_OFFSET(n) + 0x3fff)
3258
3259
3260
3261
3262
3263
3264
3265
3266#define EC_HOST_PARAM_SIZE EC_PROTO2_MAX_PARAM_SIZE
3267#define EC_LPC_ADDR_OLD_PARAM EC_HOST_CMD_REGION1
3268#define EC_OLD_PARAM_SIZE EC_HOST_CMD_REGION_SIZE
3269
3270#endif
3271