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