coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
ec.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <stdint.h>
4 #include <string.h>
5 #include <assert.h>
6 #include <console/console.h>
7 #include <delay.h>
8 #include <device/device.h>
9 #include <device/path.h>
10 #include <elog.h>
11 #include <rtc.h>
13 #include <stdlib.h>
14 #include <timer.h>
15 
16 #include "ec.h"
17 
18 #define INVALID_HCMD 0xFF
19 
20 /*
21  * Map UHEPI masks to non UHEPI commands in order to support old EC FW
22  * which does not support UHEPI command.
23  */
24 static const struct {
28 } event_map[] = {
29  [EC_HOST_EVENT_MAIN] = {
32  },
33  [EC_HOST_EVENT_B] = {
36  },
40  },
44  },
47  },
51  },
55  },
59  },
63  },
64 };
65 
67 {
68  int csum;
69 
70  for (csum = 0; size > 0; data++, size--)
71  csum += *data;
72  return (uint8_t)(csum & 0xff);
73 }
74 
76 {
78  .percent = percent % 101,
79  };
81  struct chromeec_command cmd = {
83  .cmd_version = 0,
84  .cmd_data_in = &params,
85  .cmd_data_out = &resp,
86  .cmd_size_in = sizeof(params),
87  .cmd_size_out = sizeof(resp),
88  .cmd_dev_index = 0,
89  };
90 
92  printk(BIOS_DEBUG, "Google Chrome set keyboard backlight: %x status (%x)\n",
93  resp.percent, cmd.cmd_code);
94  return cmd.cmd_code;
95 }
96 
98 {
99  /* backlight is a percent. postcode is a uint8_t.
100  * Convert the uint8_t to %.
101  */
102  postcode = (postcode/4) + (postcode/8);
103  google_chromeec_kbbacklight(postcode);
104 }
105 
106 /*
107  * Query the EC for specified mask indicating enabled events.
108  * The EC maintains separate event masks for SMI, SCI and WAKE.
109  */
111  uint64_t *value)
112 {
113  int ret;
114  struct ec_params_host_event params = {
115  .action = action,
116  .mask_type = mask,
117  };
118  struct ec_response_host_event resp = {};
119  struct chromeec_command cmd = {
121  .cmd_version = 0,
122  .cmd_data_in = &params,
123  .cmd_size_in = sizeof(params),
124  .cmd_data_out = &resp,
125  .cmd_size_out = sizeof(resp),
126  .cmd_dev_index = 0,
127  };
128 
129  if (action != EC_HOST_EVENT_GET)
130  params.value = *value;
131  else
132  *value = 0;
133 
134  ret = google_chromeec_command(&cmd);
135 
136  if (action != EC_HOST_EVENT_GET)
137  return ret;
138  if (ret == 0)
139  *value = resp.value;
140  return ret;
141 }
142 
144  uint64_t *value)
145 {
146  int ret = -1;
147  struct ec_params_host_event_mask params = {};
148  struct ec_response_host_event_mask resp = {};
149  struct chromeec_command cmd = {
150  .cmd_code = hcmd,
151  .cmd_version = 0,
152  .cmd_data_in = &params,
153  .cmd_size_in = sizeof(params),
154  .cmd_data_out = &resp,
155  .cmd_size_out = sizeof(resp),
156  .cmd_dev_index = 0,
157  };
158 
159  if (hcmd == INVALID_HCMD)
160  return ret;
161 
162  if (action != EC_HOST_EVENT_GET)
163  params.mask = (uint32_t)*value;
164  else
165  *value = 0;
166 
167  ret = google_chromeec_command(&cmd);
168 
169  if (action != EC_HOST_EVENT_GET)
170  return ret;
171  if (ret == 0)
172  *value = resp.mask;
173 
174  return ret;
175 }
176 
178 {
179 #define UHEPI_SUPPORTED 1
180 #define UHEPI_NOT_SUPPORTED 2
181 
182  static int uhepi_support;
183 
184  if (!uhepi_support) {
185  uhepi_support = google_chromeec_check_feature
188  printk(BIOS_DEBUG, "Chrome EC: UHEPI %s\n",
189  uhepi_support == UHEPI_SUPPORTED ?
190  "supported" : "not supported");
191  }
192  return uhepi_support == UHEPI_SUPPORTED;
193 }
194 
196 {
197  uint64_t value = 0;
198 
201  } else {
206  }
207  return value;
208 }
209 
211 {
215 
220 }
221 
223 {
227 
232 }
233 
235 {
236  printk(BIOS_DEBUG, "Chrome EC: Set S3 LAZY WAKE mask to 0x%016llx\n",
237  mask);
240 }
241 
243 {
244  printk(BIOS_DEBUG, "Chrome EC: Set S5 LAZY WAKE mask to 0x%016llx\n",
245  mask);
248 }
249 
251 {
252  printk(BIOS_DEBUG, "Chrome EC: Set S0iX LAZY WAKE mask to 0x%016llx\n",
253  mask);
256 }
258  uint64_t s3_mask, uint64_t s0ix_mask)
259 {
261  printk(BIOS_DEBUG, "Error: Set S5 LAZY WAKE mask failed\n");
263  printk(BIOS_DEBUG, "Error: Set S3 LAZY WAKE mask failed\n");
264  /*
265  * Make sure S0Ix is supported before trying to set up the EC's
266  * S0Ix lazy wake mask.
267  */
268  if (s0ix_mask && google_chromeec_set_s0ix_lazy_wake_mask(s0ix_mask))
269  printk(BIOS_DEBUG, "Error: Set S0iX LAZY WAKE mask failed\n");
270 }
271 
273 {
275 }
276 
278 {
280  "Chrome EC: clear events_b mask to 0x%016llx\n", mask);
282 }
283 
285 {
286  struct chromeec_command cmd = {
288  .cmd_version = 0,
289  .cmd_data_in = NULL,
290  .cmd_size_in = 0,
291  .cmd_data_out = event,
292  .cmd_size_out = sizeof(*event),
293  .cmd_dev_index = 0,
294  };
295 
296  return google_chromeec_command(&cmd);
297 }
298 
299 /* Get the current device event mask */
301 {
302  struct ec_params_device_event params = {
304  };
305  struct ec_response_device_event resp = {};
306  struct chromeec_command cmd = {
308  .cmd_version = 0,
309  .cmd_data_in = &params,
310  .cmd_size_in = sizeof(params),
311  .cmd_data_out = &resp,
312  .cmd_size_out = sizeof(resp),
313  .cmd_dev_index = 0,
314  };
315 
316  if (google_chromeec_command(&cmd) == 0)
317  return resp.event_mask;
318 
319  return 0;
320 }
321 
322 /* Set the current device event mask */
324 {
325  struct ec_params_device_event params = {
326  .event_mask = (uint32_t)mask,
328  };
329  struct ec_response_device_event resp = {};
330  struct chromeec_command cmd = {
332  .cmd_version = 0,
333  .cmd_data_in = &params,
334  .cmd_size_in = sizeof(params),
335  .cmd_data_out = &resp,
336  .cmd_size_out = sizeof(resp),
337  .cmd_dev_index = 0,
338  };
339 
340  return google_chromeec_command(&cmd);
341 }
342 
343 /* Read and clear pending device events */
345 {
346  struct ec_params_device_event params = {
348  };
349  struct ec_response_device_event resp = {};
350  struct chromeec_command cmd = {
352  .cmd_version = 0,
353  .cmd_data_in = &params,
354  .cmd_size_in = sizeof(params),
355  .cmd_data_out = &resp,
356  .cmd_size_out = sizeof(resp),
357  .cmd_dev_index = 0,
358  };
359 
360  if (google_chromeec_command(&cmd) == 0)
361  return resp.event_mask;
362 
363  return 0;
364 }
365 
367 {
368  uint64_t events;
369  int i;
370 
371  if (!CONFIG(ELOG) || !mask)
372  return;
373 
375  return;
376 
378  printk(BIOS_INFO, "EC Device Events: 0x%016llx\n", events);
379 
380  for (i = 0; i < sizeof(events) * 8; i++) {
381  if (EC_DEVICE_EVENT_MASK(i) & events)
383  }
384 }
385 
387 {
388  uint64_t events;
389  int i;
390 
391  if (!CONFIG(ELOG))
392  return;
393 
394  events = google_chromeec_get_events_b() & mask;
395 
396  /*
397  * This loop starts at 1 because the EC_HOST_EVENT_MASK macro subtracts
398  * 1 from its argument before applying the left-shift operator. This
399  * prevents a left-shift of -1 happening, and covers the entire 64-bit
400  * range of the event mask.
401  */
402  for (i = 1; i <= sizeof(events) * 8; i++) {
403  if (EC_HOST_EVENT_MASK(i) & events)
405  }
406 
408 }
409 
411  bool is_s3_wakeup)
412 {
413  if (is_s3_wakeup) {
414  google_chromeec_log_events(info->log_events |
415  info->s3_wake_events);
416 
417  /* Log and clear device events that may wake the system. */
418  google_chromeec_log_device_events(info->s3_device_events);
419 
420  /* Disable SMI and wake events. */
422 
423  /* Restore SCI event mask. */
424  google_chromeec_set_sci_mask(info->sci_events);
425 
426  } else {
427  google_chromeec_set_smi_mask(info->smi_events);
428 
429  google_chromeec_log_events(info->log_events |
430  info->s5_wake_events);
431 
434  (info->s5_wake_events,
435  info->s3_wake_events,
436  info->s0ix_wake_events);
437  }
438 
439  /* Clear wake event mask. */
441 }
442 
444 {
445  struct ec_response_get_features resp = {};
446  struct chromeec_command cmd = {
448  .cmd_version = 0,
449  .cmd_size_in = 0,
450  .cmd_data_out = &resp,
451  .cmd_size_out = sizeof(resp),
452  .cmd_dev_index = 0,
453  };
454 
455  if (google_chromeec_command(&cmd) != 0)
456  return -1;
457 
458  if (feature >= 8 * sizeof(resp.flags))
459  return -1;
460 
461  return resp.flags[feature / 32] & EC_FEATURE_MASK_0(feature);
462 }
463 
465 {
467  .cmd = command,
468  };
469  struct ec_response_get_cmd_versions resp = {};
470  struct chromeec_command cmd = {
472  .cmd_version = 1,
473  .cmd_size_in = sizeof(params),
474  .cmd_data_in = &params,
475  .cmd_size_out = sizeof(resp),
476  .cmd_data_out = &resp,
477  .cmd_dev_index = 0,
478  };
479 
480  if (google_chromeec_command(&cmd) != 0)
481  return -1;
482 
483  *pmask = resp.version_mask;
484  return 0;
485 }
486 
488  struct ec_response_vboot_hash *resp)
489 {
490  struct ec_params_vboot_hash params = {
491  .cmd = EC_VBOOT_HASH_GET,
492  .offset = offset,
493  };
494  struct chromeec_command cmd = {
496  .cmd_version = 0,
497  .cmd_size_in = sizeof(params),
498  .cmd_data_in = &params,
499  .cmd_size_out = sizeof(*resp),
500  .cmd_data_out = resp,
501  .cmd_dev_index = 0,
502  };
503 
504  if (google_chromeec_command(&cmd) != 0)
505  return -1;
506 
507  return 0;
508 }
509 
511  uint32_t hash_offset,
512  struct ec_response_vboot_hash *resp)
513 {
514  struct ec_params_vboot_hash params = {
515  .cmd = EC_VBOOT_HASH_START,
516  .hash_type = hash_type,
517  .nonce_size = 0,
518  .offset = hash_offset,
519  };
520  struct chromeec_command cmd = {
522  .cmd_version = 0,
523  .cmd_size_in = sizeof(params),
524  .cmd_data_in = &params,
525  .cmd_size_out = sizeof(*resp),
526  .cmd_data_out = resp,
527  .cmd_dev_index = 0,
528  };
529 
530  if (google_chromeec_command(&cmd) != 0)
531  return -1;
532 
533  return 0;
534 }
535 
537  struct ec_response_flash_protect *resp)
538 {
540  .mask = mask,
541  .flags = flags,
542  };
543  struct chromeec_command cmd = {
545  .cmd_version = EC_VER_FLASH_PROTECT,
546  .cmd_size_in = sizeof(params),
547  .cmd_data_in = &params,
548  .cmd_size_out = sizeof(*resp),
549  .cmd_data_out = resp,
550  .cmd_dev_index = 0,
551  };
552 
553  if (google_chromeec_command(&cmd) != 0)
554  return -1;
555 
556  return 0;
557 }
558 
560  uint32_t *offset, uint32_t *size)
561 {
563  .region = region,
564  };
565  struct ec_response_flash_region_info resp = {};
566  struct chromeec_command cmd = {
568  .cmd_version = EC_VER_FLASH_REGION_INFO,
569  .cmd_size_in = sizeof(params),
570  .cmd_data_in = &params,
571  .cmd_size_out = sizeof(resp),
572  .cmd_data_out = &resp,
573  .cmd_dev_index = 0,
574  };
575 
576  if (google_chromeec_command(&cmd) != 0)
577  return -1;
578 
579  if (offset)
580  *offset = resp.offset;
581  if (size)
582  *size = resp.size;
583 
584  return 0;
585 }
586 
588 {
589  struct ec_params_flash_erase params = {
590  .offset = offset,
591  .size = size,
592  };
593  struct chromeec_command cmd = {
595  .cmd_version = 0,
596  .cmd_size_in = sizeof(params),
597  .cmd_data_in = &params,
598  .cmd_size_out = 0,
599  .cmd_data_out = NULL,
600  .cmd_dev_index = 0,
601  };
602 
603  if (google_chromeec_command(&cmd) != 0)
604  return -1;
605 
606  return 0;
607 }
608 
610 {
611  struct chromeec_command cmd;
612 
614  cmd.cmd_version = 0;
615  cmd.cmd_size_in = 0;
616  cmd.cmd_data_in = NULL;
617  cmd.cmd_size_out = sizeof(*info);
618  cmd.cmd_data_out = info;
619  cmd.cmd_dev_index = 0;
620 
621  if (google_chromeec_command(&cmd) != 0)
622  return -1;
623 
624  return 0;
625 }
626 
627 /*
628  * Write a block into EC flash. Expects params_data to be a buffer where
629  * the first N bytes are a struct ec_params_flash_write, and the rest of it
630  * is the data to write to flash.
631 */
633  uint32_t bufsize)
634 {
635  struct chromeec_command cmd = {
637  .cmd_version = EC_VER_FLASH_WRITE,
638  .cmd_size_out = 0,
639  .cmd_data_out = NULL,
640  .cmd_size_in = bufsize,
641  .cmd_data_in = params_data,
642  .cmd_dev_index = 0,
643  };
644 
645  assert(params_data);
646 
647  return google_chromeec_command(&cmd);
648 }
649 
650 /*
651  * EFS verification of flash.
652  */
654 {
655  struct ec_params_efs_verify params = {
656  .region = region,
657  };
658  struct chromeec_command cmd = {
660  .cmd_version = 0,
661  .cmd_size_in = sizeof(params),
662  .cmd_data_in = &params,
663  .cmd_size_out = 0,
664  .cmd_data_out = NULL,
665  .cmd_dev_index = 0,
666  };
667  int rv;
668 
669  /* It's okay if the EC doesn't support EFS */
670  rv = google_chromeec_command(&cmd);
671  if (rv != 0 && (cmd.cmd_code == EC_RES_INVALID_COMMAND))
672  return 0;
673  else if (rv != 0)
674  return -1;
675 
676  return 0;
677 }
678 
680 {
682  .flags = flags,
683  };
684  struct chromeec_command cmd = {
686  .cmd_version = 1,
687  .cmd_size_in = sizeof(params),
688  .cmd_data_in = &params,
689  .cmd_data_out = NULL,
690  .cmd_size_out = 0,
691  .cmd_dev_index = 0,
692  };
693 
694  if (google_chromeec_command(&cmd) != 0)
695  return -1;
696 
697  return 0;
698 }
699 
701 {
702  struct ec_params_charge_state params = {
704  .get_param.param = CS_PARAM_LIMIT_POWER,
705  };
706  struct ec_response_charge_state resp = {};
707  struct chromeec_command cmd = {
709  .cmd_version = 0,
710  .cmd_size_in = sizeof(params),
711  .cmd_data_in = &params,
712  .cmd_size_out = sizeof(resp),
713  .cmd_data_out = &resp,
714  .cmd_dev_index = 0,
715  };
716  int rv;
717 
718  rv = google_chromeec_command(&cmd);
719 
720  if (rv != 0 && (cmd.cmd_code == EC_RES_INVALID_COMMAND ||
721  cmd.cmd_code == EC_RES_INVALID_PARAM)) {
722  printk(BIOS_INFO, "PARAM_LIMIT_POWER not supported by EC.\n");
723  *limit_power = 0;
724  return 0;
725  } else if (rv != 0) {
726  return -1;
727  }
728 
729  *limit_power = resp.get_param.value;
730 
731  return 0;
732 }
733 
735  struct ec_response_get_protocol_info *resp)
736 {
737  struct chromeec_command cmd = {
739  .cmd_version = 0,
740  .cmd_size_in = 0,
741  .cmd_data_in = NULL,
742  .cmd_data_out = resp,
743  .cmd_size_out = sizeof(*resp),
744  .cmd_dev_index = 0,
745  };
746 
747  if (google_chromeec_command(&cmd))
748  return -1;
749 
750  return 0;
751 }
752 
754 {
755  struct ec_sku_id_info params = {
756  .sku_id = skuid
757  };
758  struct chromeec_command cmd = {
760  .cmd_version = 0,
761  .cmd_size_in = sizeof(params),
762  .cmd_data_in = &params,
763  .cmd_data_out = NULL,
764  .cmd_size_out = 0,
765  .cmd_dev_index = 0,
766  };
767 
768  if (google_chromeec_command(&cmd) != 0)
769  return -1;
770 
771  return 0;
772 }
773 
774 #if CONFIG(EC_GOOGLE_CHROMEEC_RTC)
775 int rtc_get(struct rtc_time *time)
776 {
777  struct ec_response_rtc resp = {};
778  struct chromeec_command cmd = {
780  .cmd_version = 0,
781  .cmd_size_in = 0,
782  .cmd_data_out = &resp,
783  .cmd_size_out = sizeof(resp),
784  .cmd_dev_index = 0,
785  };
786 
787  if (google_chromeec_command(&cmd) != 0)
788  return -1;
789 
790  return rtc_to_tm(resp.time, time);
791 }
792 #endif
793 
794 int google_chromeec_reboot(int dev_idx, enum ec_reboot_cmd type, uint8_t flags)
795 {
796  struct ec_params_reboot_ec params = {
797  .cmd = type,
798  .flags = flags,
799  };
800  struct ec_response_get_version resp = {};
801  struct chromeec_command cmd = {
803  .cmd_version = 0,
804  .cmd_data_in = &params,
805  .cmd_data_out = &resp,
806  .cmd_size_in = sizeof(params),
807  .cmd_size_out = 0, /* ignore response, if any */
808  .cmd_dev_index = dev_idx,
809  };
810 
811  return google_chromeec_command(&cmd);
812 }
813 
814 static int cbi_get_uint32(uint32_t *id, uint32_t tag)
815 {
816  struct ec_params_get_cbi params = {
817  .tag = tag,
818  };
819  uint32_t r = 0;
820  struct chromeec_command cmd = {
822  .cmd_version = 0,
823  .cmd_data_in = &params,
824  .cmd_data_out = &r,
825  .cmd_size_in = sizeof(params),
826  .cmd_size_out = sizeof(r),
827  .cmd_dev_index = 0,
828  };
829  int rv;
830 
831  rv = google_chromeec_command(&cmd);
832  if (rv != 0)
833  return rv;
834 
835  *id = r;
836  return 0;
837 }
838 
840 {
841  return cbi_get_uint32(id, CBI_TAG_SKU_ID);
842 }
843 
845 {
847 
849  return -1;
850 
852  /*
853  * If SSFC is configured to be part of FW_CONFIG, add it at the most significant
854  * 32 bits.
855  */
856  if (CONFIG(EC_GOOGLE_CHROMEEC_INCLUDE_SSFC_IN_FW_CONFIG)) {
857  uint32_t ssfc;
858 
859  if (!google_chromeec_cbi_get_ssfc(&ssfc))
860  *fw_config |= (uint64_t)ssfc << 32;
861  }
862  return 0;
863 }
864 
866 {
867  return cbi_get_uint32(id, CBI_TAG_OEM_ID);
868 }
869 
871 {
873 }
874 
876 {
877  return cbi_get_uint32(ssfc, CBI_TAG_SSFC);
878 }
879 
880 static int cbi_get_string(char *buf, size_t bufsize, uint32_t tag)
881 {
882  struct ec_params_get_cbi params = {
883  .tag = tag,
884  };
885  struct chromeec_command cmd = {
887  .cmd_version = 0,
888  .cmd_data_in = &params,
889  .cmd_data_out = buf,
890  .cmd_size_in = sizeof(params),
891  .cmd_size_out = bufsize,
892  };
893  int rv;
894 
895  rv = google_chromeec_command(&cmd);
896  if (rv != 0)
897  return rv;
898 
899  /* Ensure NUL termination. */
900  buf[bufsize - 1] = '\0';
901 
902  return 0;
903 }
904 
905 int google_chromeec_cbi_get_dram_part_num(char *buf, size_t bufsize)
906 {
907  return cbi_get_string(buf, bufsize, CBI_TAG_DRAM_PART_NUM);
908 }
909 
910 int google_chromeec_cbi_get_oem_name(char *buf, size_t bufsize)
911 {
912  return cbi_get_string(buf, bufsize, CBI_TAG_OEM_NAME);
913 }
914 
916 {
917  struct ec_response_board_version resp;
918  struct chromeec_command cmd = {
920  .cmd_version = 0,
921  .cmd_size_in = 0,
922  .cmd_size_out = sizeof(resp),
923  .cmd_data_out = &resp,
924  .cmd_dev_index = 0,
925  };
926 
927  if (google_chromeec_command(&cmd))
928  return -1;
929 
930  *version = resp.board_version;
931  return 0;
932 }
933 
935 {
936  struct ec_sku_id_info resp;
937  struct chromeec_command cmd = {
939  .cmd_version = 0,
940  .cmd_size_in = 0,
941  .cmd_size_out = sizeof(resp),
942  .cmd_data_out = &resp,
943  .cmd_dev_index = 0,
944  };
945 
946  if (google_chromeec_command(&cmd) != 0)
947  return 0;
948 
949  return resp.sku_id;
950 }
951 
952 int google_chromeec_vbnv_context(int is_read, uint8_t *data, int len)
953 {
954  struct ec_params_vbnvcontext params = {
955  .op = is_read ? EC_VBNV_CONTEXT_OP_READ :
957  };
958  struct ec_response_vbnvcontext resp = {};
959  struct chromeec_command cmd = {
961  .cmd_version = EC_VER_VBNV_CONTEXT,
962  .cmd_data_in = &params,
963  .cmd_data_out = &resp,
964  .cmd_size_in = sizeof(params),
965  .cmd_size_out = is_read ? sizeof(resp) : 0,
966  .cmd_dev_index = 0,
967  };
968  int retries = 3;
969 
970  if (len != EC_VBNV_BLOCK_SIZE)
971  return -1;
972 
973  if (!is_read)
974  memcpy(&params.block, data, EC_VBNV_BLOCK_SIZE);
975 retry:
976 
977  if (google_chromeec_command(&cmd)) {
978  printk(BIOS_ERR, "failed to %s vbnv_ec context: %d\n",
979  is_read ? "read" : "write", (int)cmd.cmd_code);
980  mdelay(10); /* just in case */
981  if (--retries)
982  goto retry;
983  }
984 
985  if (is_read)
986  memcpy(data, &resp.block, EC_VBNV_BLOCK_SIZE);
987 
988  return cmd.cmd_code;
989 }
990 
992  struct ec_response_uptime_info *resp)
993 {
994  struct chromeec_command cmd = {
996  .cmd_version = 0,
997  .cmd_data_in = NULL,
998  .cmd_size_in = 0,
999  .cmd_data_out = resp,
1000  .cmd_size_out = sizeof(*resp),
1001  .cmd_dev_index = 0,
1002  };
1003 
1005  return cmd.cmd_code;
1006 }
1007 
1009 {
1010  int i;
1011  struct ec_response_uptime_info resp;
1012 
1014  return false;
1015 
1017  return true;
1018 
1019  /* Find the last valid entry */
1020  for (i = ARRAY_SIZE(resp.recent_ap_reset) - 1; i >= 0; i--) {
1021  if (resp.recent_ap_reset[i].reset_time_ms == 0)
1022  continue;
1023  return (resp.recent_ap_reset[i].reset_cause ==
1025  }
1026 
1027  return false;
1028 }
1029 
1031  uint8_t *buffer, int len, int is_read)
1032 {
1033  union {
1034  struct ec_params_i2c_passthru p;
1035  uint8_t outbuf[EC_HOST_PARAM_SIZE];
1036  } params;
1037  union {
1038  struct ec_response_i2c_passthru r;
1039  uint8_t inbuf[EC_HOST_PARAM_SIZE];
1040  } response;
1041  struct ec_params_i2c_passthru *p = &params.p;
1042  struct ec_response_i2c_passthru *r = &response.r;
1043  struct ec_params_i2c_passthru_msg *msg = p->msg;
1044  struct chromeec_command cmd;
1045  uint8_t *pdata;
1046  int read_len, write_len;
1047  int size;
1048  int rv;
1049 
1050  p->port = 0;
1051 
1052  if (alen != 1) {
1053  printk(BIOS_ERR, "Unsupported address length %d\n", alen);
1054  return -1;
1055  }
1056  if (is_read) {
1057  read_len = len;
1058  write_len = alen;
1059  p->num_msgs = 2;
1060  } else {
1061  read_len = 0;
1062  write_len = alen + len;
1063  p->num_msgs = 1;
1064  }
1065 
1066  size = sizeof(*p) + p->num_msgs * sizeof(*msg);
1067  if (size + write_len > sizeof(params)) {
1068  printk(BIOS_ERR, "Params too large for buffer\n");
1069  return -1;
1070  }
1071  if (sizeof(*r) + read_len > sizeof(response)) {
1072  printk(BIOS_ERR, "Read length too big for buffer\n");
1073  return -1;
1074  }
1075 
1076  /* Create a message to write the register address and optional data */
1077  pdata = (uint8_t *)p + size;
1078  msg->addr_flags = chip;
1079  msg->len = write_len;
1080  pdata[0] = addr;
1081  if (!is_read)
1082  memcpy(pdata + 1, buffer, len);
1083  msg++;
1084 
1085  if (read_len) {
1086  msg->addr_flags = chip | EC_I2C_FLAG_READ;
1087  msg->len = read_len;
1088  }
1089 
1091  cmd.cmd_version = 0;
1092  cmd.cmd_data_in = p;
1093  cmd.cmd_size_in = size + write_len;
1094  cmd.cmd_data_out = r;
1095  cmd.cmd_size_out = sizeof(*r) + read_len;
1096  cmd.cmd_dev_index = 0;
1097  rv = google_chromeec_command(&cmd);
1098  if (rv != 0)
1099  return rv;
1100 
1101  /* Parse response */
1102  if (r->i2c_status & EC_I2C_STATUS_ERROR) {
1103  printk(BIOS_ERR, "Transfer failed with status=0x%x\n",
1104  r->i2c_status);
1105  return -1;
1106  }
1107 
1108  if (cmd.cmd_size_out < sizeof(*r) + read_len) {
1109  printk(BIOS_ERR, "Truncated read response\n");
1110  return -1;
1111  }
1112 
1113  if (read_len)
1114  memcpy(buffer, r->data, read_len);
1115 
1116  return 0;
1117 }
1118 
1120 {
1121  printk(BIOS_DEBUG, "Chrome EC: Set SCI mask to 0x%016llx\n", mask);
1123 }
1124 
1126 {
1127  printk(BIOS_DEBUG, "Chrome EC: Set SMI mask to 0x%016llx\n", mask);
1129 }
1130 
1132 {
1133  printk(BIOS_DEBUG, "Chrome EC: Set WAKE mask to 0x%016llx\n", mask);
1136 }
1137 
1139 {
1141 }
1142 
1144 {
1146  .usb_port_id = port_id,
1147  .mode = mode,
1148  };
1149  struct chromeec_command cmd = {
1151  .cmd_version = 0,
1152  .cmd_size_in = sizeof(params),
1153  .cmd_data_in = &params,
1154  .cmd_size_out = 0,
1155  .cmd_data_out = NULL,
1156  .cmd_dev_index = 0,
1157  };
1158 
1159  return google_chromeec_command(&cmd);
1160 }
1161 
1162 /* Get charger voltage and current. Also returns type of charger */
1164  uint16_t *current_max, uint16_t *voltage_max)
1165 {
1167  .port = PD_POWER_CHARGING_PORT,
1168  };
1169  struct ec_response_usb_pd_power_info resp = {};
1170  struct chromeec_command cmd = {
1172  .cmd_version = 0,
1173  .cmd_data_in = &params,
1174  .cmd_size_in = sizeof(params),
1175  .cmd_data_out = &resp,
1176  .cmd_size_out = sizeof(resp),
1177  .cmd_dev_index = 0,
1178  };
1179  struct usb_chg_measures m;
1180  int rv;
1181 
1182  rv = google_chromeec_command(&cmd);
1183  if (rv != 0)
1184  return rv;
1185 
1186  /* values are given in milliAmps and milliVolts */
1187  *type = resp.type;
1188  m = resp.meas;
1189  *voltage_max = m.voltage_max;
1190  *current_max = m.current_max;
1191  return 0;
1192 }
1193 
1195  uint16_t voltage_lim)
1196 {
1198  .current_lim = current_lim,
1199  .voltage_lim = voltage_lim,
1200  };
1201  struct chromeec_command cmd = {
1203  .cmd_version = 0,
1204  .cmd_data_in = &params,
1205  .cmd_size_in = sizeof(params),
1206  .cmd_data_out = NULL,
1207  .cmd_size_out = 0,
1208  .cmd_dev_index = 0,
1209  };
1210 
1211  return google_chromeec_command(&cmd);
1212 }
1213 
1215 {
1216  struct ec_params_usb_pd_control params = {
1217  .port = port,
1218  .role = role,
1220  .swap = USB_PD_CTRL_SWAP_NONE,
1221  };
1222  struct ec_response_usb_pd_control resp;
1223  struct chromeec_command cmd = {
1225  .cmd_version = 0,
1226  .cmd_data_in = &params,
1227  .cmd_size_in = sizeof(params),
1228  .cmd_data_out = &resp,
1229  .cmd_size_out = sizeof(resp),
1230  .cmd_dev_index = 0,
1231  };
1232 
1233  return google_chromeec_command(&cmd);
1234 }
1235 
1237 {
1238  struct ec_params_hello params = {
1239  .in_data = 0x10203040,
1240  };
1241  struct ec_response_hello resp = {};
1242  struct chromeec_command cmd = {
1244  .cmd_version = 0,
1245  .cmd_data_in = &params,
1246  .cmd_data_out = &resp,
1247  .cmd_size_in = sizeof(params),
1248  .cmd_size_out = sizeof(resp),
1249  .cmd_dev_index = 0,
1250  };
1251 
1252  int rv = google_chromeec_command(&cmd);
1253  if (rv)
1254  return -1;
1255 
1256  if (resp.out_data != (params.in_data + 0x01020304))
1257  return -1;
1258 
1259  return 0;
1260 }
1261 
1262 /*
1263  * Convert a reset cause ID to human-readable string, providing total coverage
1264  * of the 'cause' space. The returned string points to static storage and must
1265  * not be free()ed.
1266  */
1267 static const char *reset_cause_to_str(uint16_t cause)
1268 {
1269  /* See also ChromiumOS EC include/chipset.h for details. */
1270  static const char * const reset_causes[] = {
1271  "(reset unknown)",
1272  "reset: board custom",
1273  "reset: ap hang detected",
1274  "reset: console command",
1275  "reset: keyboard sysreset",
1276  "reset: keyboard warm reboot",
1277  "reset: debug warm reboot",
1278  "reset: at AP's request",
1279  "reset: during EC initialization",
1280  "reset: AP watchdog",
1281  };
1282 
1283  static const size_t shutdown_cause_begin = 1 << 15;
1284  static const char * const shutdown_causes[] = {
1285  "shutdown: power failure",
1286  "shutdown: during EC initialization",
1287  "shutdown: board custom",
1288  "shutdown: battery voltage startup inhibit",
1289  "shutdown: power wait asserted",
1290  "shutdown: critical battery",
1291  "shutdown: by console command",
1292  "shutdown: entering G3",
1293  "shutdown: thermal",
1294  "shutdown: power button",
1295  };
1296 
1297  if (cause < ARRAY_SIZE(reset_causes))
1298  return reset_causes[cause];
1299 
1300  if (cause < shutdown_cause_begin)
1301  return "(reset unknown)";
1302 
1303  if (cause < shutdown_cause_begin + ARRAY_SIZE(shutdown_causes))
1304  return shutdown_causes[cause - shutdown_cause_begin];
1305 
1306  return "(shutdown unknown)";
1307 }
1308 
1309 /*
1310  * Copy the EC's information about resets of the AP and its own uptime for
1311  * debugging purposes.
1312  */
1314 {
1315  /* See also ec_commands.h EC_RESET_FLAG_* for details. */
1316  static const char * const reset_flag_strings[] = {
1317  "other",
1318  "reset-pin",
1319  "brownout",
1320  "power-on",
1321  "watchdog",
1322  "soft",
1323  "hibernate",
1324  "rtc-alarm",
1325  "wake-pin",
1326  "low-battery",
1327  "sysjump",
1328  "hard",
1329  "ap-off",
1330  "preserved",
1331  "usb-resume",
1332  "rdd",
1333  "rbox",
1334  "security",
1335  "ap-watchdog",
1336  };
1337  struct ec_response_uptime_info cmd_resp;
1338  int i, flag, flag_count;
1339 
1340  if (google_chromeec_get_uptime_info(&cmd_resp)) {
1341  /*
1342  * Deliberately say nothing for EC's that don't support this
1343  * command
1344  */
1345  return;
1346  }
1347 
1348  printk(BIOS_DEBUG, "Google Chrome EC uptime: %d.%03d seconds\n",
1351 
1352  printk(BIOS_DEBUG, "Google Chrome AP resets since EC boot: %d\n",
1353  cmd_resp.ap_resets_since_ec_boot);
1354 
1355  printk(BIOS_DEBUG, "Google Chrome most recent AP reset causes:\n");
1356  for (i = 0; i != ARRAY_SIZE(cmd_resp.recent_ap_reset); ++i) {
1357  if (cmd_resp.recent_ap_reset[i].reset_time_ms == 0)
1358  continue;
1359 
1360  printk(BIOS_DEBUG, "\t%d.%03d: %d %s\n",
1361  cmd_resp.recent_ap_reset[i].reset_time_ms /
1362  MSECS_PER_SEC,
1363  cmd_resp.recent_ap_reset[i].reset_time_ms %
1364  MSECS_PER_SEC,
1365  cmd_resp.recent_ap_reset[i].reset_cause,
1367  cmd_resp.recent_ap_reset[i].reset_cause));
1368  }
1369 
1370  printk(BIOS_DEBUG, "Google Chrome EC reset flags at last EC boot: ");
1371  flag_count = 0;
1372  for (flag = 0; flag != ARRAY_SIZE(reset_flag_strings); ++flag) {
1373  if ((cmd_resp.ec_reset_flags & (1 << flag)) != 0) {
1374  if (flag_count)
1375  printk(BIOS_DEBUG, " | ");
1376  printk(BIOS_DEBUG, "%s", reset_flag_strings[flag]);
1377  flag_count++;
1378  }
1379  }
1380  printk(BIOS_DEBUG, "\n");
1381 }
1382 
1383 /* Cache and retrieve the EC image type (ro or rw) */
1385 {
1386  static enum ec_image ec_image_type = EC_IMAGE_UNKNOWN;
1387 
1388  if (ec_image_type != EC_IMAGE_UNKNOWN)
1389  return ec_image_type;
1390 
1391  struct ec_response_get_version resp = {};
1392  struct chromeec_command cmd = {
1394  .cmd_version = 0,
1395  .cmd_data_out = &resp,
1396  .cmd_size_in = 0,
1397  .cmd_size_out = sizeof(resp),
1398  .cmd_dev_index = 0,
1399  };
1400 
1402 
1403  if (cmd.cmd_code) {
1405  "Google Chrome EC: version command failed!\n");
1406  } else {
1407  printk(BIOS_DEBUG, "Google Chrome EC: version:\n");
1408  printk(BIOS_DEBUG, " ro: %s\n", resp.version_string_ro);
1409  printk(BIOS_DEBUG, " rw: %s\n", resp.version_string_rw);
1410  printk(BIOS_DEBUG, " running image: %d\n",
1411  resp.current_image);
1412  ec_image_type = resp.current_image;
1413  }
1414 
1415  /* Will still be UNKNOWN if command failed */
1416  return ec_image_type;
1417 }
1418 
1419 int google_chromeec_get_num_pd_ports(unsigned int *num_ports)
1420 {
1421  struct ec_response_charge_port_count resp = {};
1422  struct chromeec_command cmd = {
1424  .cmd_version = 0,
1425  .cmd_data_out = &resp,
1426  .cmd_size_in = 0,
1427  .cmd_size_out = sizeof(resp),
1428  .cmd_dev_index = 0,
1429  };
1430  int rv;
1431 
1432  rv = google_chromeec_command(&cmd);
1433  if (rv)
1434  return rv;
1435 
1436  *num_ports = resp.port_count;
1437  return 0;
1438 }
1439 
1441  struct usb_pd_port_caps *port_caps)
1442 {
1444  .port = port,
1445  };
1446  struct ec_response_get_pd_port_caps resp = {};
1447  struct chromeec_command cmd = {
1449  .cmd_version = 0,
1450  .cmd_data_in = &params,
1451  .cmd_size_in = sizeof(params),
1452  .cmd_data_out = &resp,
1453  .cmd_size_out = sizeof(resp),
1454  .cmd_dev_index = 0,
1455  };
1456  int rv;
1457 
1458  rv = google_chromeec_command(&cmd);
1459  if (rv)
1460  return rv;
1461 
1466 
1467  return 0;
1468 }
1469 
1471 {
1473 }
1474 
1476 {
1478 }
1479 
1480 /* Returns data role and type of device connected */
1481 static int google_chromeec_usb_pd_get_info(int port, bool *ufp, bool *dbg_acc,
1482  bool *active_cable, uint8_t *dp_mode)
1483 {
1484  struct ec_params_usb_pd_control pd_control = {
1485  .port = port,
1488  .swap = USB_PD_CTRL_SWAP_NONE,
1489  };
1490  struct ec_response_usb_pd_control_v2 resp = {};
1491  struct chromeec_command cmd = {
1493  .cmd_version = 2,
1494  .cmd_data_in = &pd_control,
1495  .cmd_size_in = sizeof(pd_control),
1496  .cmd_data_out = &resp,
1497  .cmd_size_out = sizeof(resp),
1498  .cmd_dev_index = 0,
1499  };
1500 
1501  if (google_chromeec_command(&cmd) < 0)
1502  return -1;
1503 
1504  *ufp = (resp.cc_state == PD_CC_DFP_ATTACHED);
1505  *dbg_acc = (resp.cc_state == PD_CC_DFP_DEBUG_ACC);
1506  *active_cable = !!(resp.control_flags & USB_PD_CTRL_ACTIVE_CABLE);
1507  *dp_mode = resp.dp_mode;
1508 
1509  return 0;
1510 }
1511 
1513 {
1515  return 0;
1516 
1517  struct ec_params_typec_control typec_control = {
1518  .port = port,
1520  .mode_to_enter = TYPEC_MODE_DP,
1521  };
1522 
1523  struct chromeec_command cmd = {
1525  .cmd_version = 0,
1526  .cmd_data_in = &typec_control,
1527  .cmd_size_in = sizeof(typec_control),
1528  .cmd_data_out = NULL,
1529  .cmd_size_out = 0,
1530  .cmd_dev_index = 0,
1531  };
1532 
1533  if (google_chromeec_command(&cmd) < 0)
1534  return -1;
1535 
1536  return 0;
1537 }
1538 
1539 /**
1540  * Check for the current mux state in EC. Flags representing the mux state found
1541  * in ec_commands.h
1542  */
1544 {
1545  struct ec_params_usb_pd_mux_info req_mux = {
1546  .port = port,
1547  };
1548  struct ec_response_usb_pd_mux_info resp_mux = {};
1549  struct chromeec_command cmd = {
1551  .cmd_version = 0,
1552  .cmd_data_in = &req_mux,
1553  .cmd_size_in = sizeof(req_mux),
1554  .cmd_data_out = &resp_mux,
1555  .cmd_size_out = sizeof(resp_mux),
1556  .cmd_dev_index = 0,
1557  };
1558 
1559  if (port < 0)
1560  return -1;
1561 
1562  if (google_chromeec_command(&cmd) < 0)
1563  return -1;
1564 
1565  *flags = resp_mux.flags;
1566  return 0;
1567 }
1568 
1569 /*
1570  * Obtain any USB-C mux data needed for the specified port
1571  * in: physical port number of the type-c port
1572  * out: struct usbc_mux_info mux_info stores USB-C mux data
1573  * Return: 0 on success, -1 on error
1574 */
1576 {
1577  uint8_t mux_flags;
1578  uint8_t dp_pin_mode;
1579  bool ufp, dbg_acc, active_cable;
1580 
1581  if (google_chromeec_usb_get_pd_mux_info(port, &mux_flags) < 0) {
1582  printk(BIOS_ERR, "Port C%d: get_pd_mux_info failed\n", port);
1583  return -1;
1584  }
1585 
1586  if (google_chromeec_usb_pd_get_info(port, &ufp, &dbg_acc,
1587  &active_cable, &dp_pin_mode) < 0) {
1588  printk(BIOS_ERR, "Port C%d: pd_control failed\n", port);
1589  return -1;
1590  }
1591 
1592  mux_info->usb = !!(mux_flags & USB_PD_MUX_USB_ENABLED);
1593  mux_info->dp = !!(mux_flags & USB_PD_MUX_DP_ENABLED);
1594  mux_info->polarity = !!(mux_flags & USB_PD_MUX_POLARITY_INVERTED);
1595  mux_info->hpd_irq = !!(mux_flags & USB_PD_MUX_HPD_IRQ);
1596  mux_info->hpd_lvl = !!(mux_flags & USB_PD_MUX_HPD_LVL);
1597  mux_info->ufp = !!ufp;
1598  mux_info->dbg_acc = !!dbg_acc;
1599  mux_info->cable = !!active_cable;
1600  mux_info->dp_pin_mode = dp_pin_mode;
1601 
1602  return 0;
1603 }
1604 
1605 /**
1606  * Check if EC/TCPM is in an alternate mode or not.
1607  *
1608  * @param svid SVID of the alternate mode to check
1609  * @return 0: Not in the mode. -1: Error.
1610  * >=1: bitmask of the ports that are in the mode.
1611  */
1613 {
1614  struct ec_response_usb_pd_ports resp;
1615  struct chromeec_command cmd = {
1617  .cmd_version = 0,
1618  .cmd_data_in = NULL,
1619  .cmd_size_in = 0,
1620  .cmd_data_out = &resp,
1621  .cmd_size_out = sizeof(resp),
1622  .cmd_dev_index = 0,
1623  };
1624  int i;
1625  int ret = 0;
1626 
1627  if (google_chromeec_command(&cmd) < 0)
1628  return -1;
1629 
1630  for (i = 0; i < resp.num_ports; i++) {
1633  int svid_idx = 0;
1634 
1635  do {
1636  /* Reset cmd in each iteration in case
1637  google_chromeec_command changes it. */
1638  params.port = i;
1639  params.svid_idx = svid_idx;
1641  cmd.cmd_version = 0;
1642  cmd.cmd_data_in = &params;
1643  cmd.cmd_size_in = sizeof(params);
1644  cmd.cmd_data_out = &resp2;
1645  cmd.cmd_size_out = sizeof(resp2);
1646  cmd.cmd_dev_index = 0;
1647 
1648  if (google_chromeec_command(&cmd) < 0)
1649  return -1;
1650  if (resp2.svid == svid)
1651  ret |= BIT(i);
1652  svid_idx++;
1653  } while (resp2.svid);
1654  }
1655 
1656  return ret;
1657 }
1658 
1659 #define USB_SID_DISPLAYPORT 0xff01
1660 
1661 /**
1662  * Wait for DisplayPort to be ready
1663  *
1664  * @param timeout_ms Wait aborts after <timeout_ms> ms.
1665  * @return -1: Error. 0: Timeout.
1666  * >=1: Bitmask of the ports that DP device is connected
1667  */
1669 {
1670  struct stopwatch sw;
1671  int ret = 0;
1672 
1673  printk(BIOS_INFO, "Waiting for DisplayPort\n");
1674  stopwatch_init_msecs_expire(&sw, timeout_ms);
1675  while (1) {
1677  if (ret > 0)
1678  break;
1679 
1680  if (ret < 0) {
1681  printk(BIOS_ERR, "Can't get alternate mode!\n");
1682  return ret;
1683  }
1684 
1685  if (stopwatch_expired(&sw)) {
1687  "DisplayPort not ready after %ldms. Abort.\n",
1688  timeout_ms);
1689  return 0;
1690  }
1691  mdelay(200);
1692  }
1693  printk(BIOS_INFO, "DisplayPort ready after %lu ms\n",
1695 
1696  return ret;
1697 }
1698 
1699 int google_chromeec_wait_for_dp_hpd(int port, long timeout_ms)
1700 {
1701  uint8_t mux_flags;
1702  struct stopwatch sw;
1703 
1704  stopwatch_init_msecs_expire(&sw, timeout_ms);
1705  do {
1707  if (stopwatch_expired(&sw)) {
1708  printk(BIOS_WARNING, "HPD not ready after %ldms. Abort.\n", timeout_ms);
1709  return -1;
1710  }
1711  mdelay(100);
1712  } while (!(mux_flags & USB_PD_MUX_HPD_LVL) || !(mux_flags & USB_PD_MUX_DP_ENABLED));
1713  printk(BIOS_INFO, "HPD ready after %lu ms\n", stopwatch_duration_msecs(&sw));
1714 
1715  return 0;
1716 }
1717 
1719 {
1720  struct chromeec_command cmd = {
1722  .cmd_version = 0,
1723  .cmd_data_in = NULL,
1724  .cmd_size_in = 0,
1725  .cmd_data_out = keybd,
1726  .cmd_size_out = sizeof(*keybd),
1727  .cmd_dev_index = 0,
1728  };
1729 
1730  if (google_chromeec_command(&cmd))
1731  return -1;
1732 
1733  return 0;
1734 }
1735 
1737 {
1738  struct chromeec_command cmd = {
1740  .cmd_version = 0,
1741  .cmd_data_in = NULL,
1742  .cmd_size_in = 0,
1743  .cmd_data_out = NULL,
1744  .cmd_size_out = 0,
1745  .cmd_dev_index = 0,
1746  };
1747 
1748  if (google_chromeec_command(&cmd))
1749  return -1;
1750 
1751  return 0;
1752 }
1753 
1755 {
1757  .index = index,
1758  .enable = enable,
1759  };
1760  struct chromeec_command cmd = {
1762  .cmd_version = 0,
1763  .cmd_data_in = &params,
1764  .cmd_size_in = sizeof(params),
1765  .cmd_data_out = NULL,
1766  .cmd_size_out = 0,
1767  .cmd_dev_index = 0,
1768  };
1769 
1770  if (google_chromeec_command(&cmd))
1771  return -1;
1772 
1773  return 0;
1774 }
1775 
1777 {
1779  .index = index,
1780  };
1781  struct ec_response_regulator_is_enabled resp = {};
1782  struct chromeec_command cmd = {
1784  .cmd_version = 0,
1785  .cmd_data_in = &params,
1786  .cmd_size_in = sizeof(params),
1787  .cmd_data_out = &resp,
1788  .cmd_size_out = sizeof(resp),
1789  .cmd_dev_index = 0,
1790  };
1791 
1792  if (google_chromeec_command(&cmd))
1793  return -1;
1794 
1795  *enabled = resp.enabled;
1796 
1797  return 0;
1798 }
1799 
1801  uint32_t max_mv)
1802 {
1804  .index = index,
1805  .min_mv = min_mv,
1806  .max_mv = max_mv,
1807  };
1808  struct chromeec_command cmd = {
1810  .cmd_version = 0,
1811  .cmd_data_in = &params,
1812  .cmd_size_in = sizeof(params),
1813  .cmd_data_out = NULL,
1814  .cmd_size_out = 0,
1815  .cmd_dev_index = 0,
1816  };
1817 
1818  if (google_chromeec_command(&cmd))
1819  return -1;
1820 
1821  return 0;
1822 }
1823 
1825 {
1827  .index = index,
1828  };
1829  struct ec_response_regulator_get_voltage resp = {};
1830  struct chromeec_command cmd = {
1832  .cmd_version = 0,
1833  .cmd_data_in = &params,
1834  .cmd_size_in = sizeof(params),
1835  .cmd_data_out = &resp,
1836  .cmd_size_out = sizeof(resp),
1837  .cmd_dev_index = 0,
1838  };
1839 
1840  if (google_chromeec_command(&cmd))
1841  return -1;
1842 
1843  *voltage_mv = resp.voltage_mv;
1844  return 0;
1845 }
pte_t value
Definition: mmu.c:91
void * memcpy(void *dest, const void *src, size_t n)
Definition: memcpy.c:7
int rtc_get(struct rtc_time *time)
Definition: as3722rtc.c:62
#define assert(statement)
Definition: assert.h:74
static struct sdram_info params
Definition: sdram_configs.c:83
#define ARRAY_SIZE(a)
Definition: helpers.h:12
#define retry(attempts, condition,...)
Definition: helpers.h:126
static u32 addr
Definition: cirrus.c:14
#define ELOG_TYPE_EC_EVENT
Definition: elog.h:90
#define ELOG_TYPE_EC_DEVICE_EVENT
Definition: elog.h:286
#define printk(level,...)
Definition: stdlib.h:16
void mdelay(unsigned int msecs)
Definition: delay.c:2
int elog_add_event_byte(u8 event_type, u8 data)
Definition: elog.c:868
static struct smmstore_params_info info
Definition: ramstage.c:12
@ CONFIG
Definition: dsi_common.h:201
static int cbi_get_uint32(uint32_t *id, uint32_t tag)
Definition: ec.c:814
int google_chromeec_flash_erase(uint32_t offset, uint32_t size)
Erase a region of EC flash.
Definition: ec.c:587
static int google_chromeec_clear_mask(uint8_t type, uint64_t mask)
Definition: ec.c:210
int google_chromeec_get_pd_port_caps(int port, struct usb_pd_port_caps *port_caps)
Get role-based capabilities for a USB-PD port.
Definition: ec.c:1440
int google_chromeec_set_device_enabled_events(uint64_t mask)
Definition: ec.c:323
int google_chromeec_cbi_get_fw_config(uint64_t *fw_config)
Definition: ec.c:844
#define INVALID_HCMD
Definition: ec.c:18
int google_chromeec_get_vboot_hash(uint32_t offset, struct ec_response_vboot_hash *resp)
Return the EC's vboot image hash.
Definition: ec.c:487
int google_chromeec_clear_events_b(uint64_t mask)
Definition: ec.c:277
uint8_t google_chromeec_calc_checksum(const uint8_t *data, int size)
Definition: ec.c:66
int google_chromeec_wait_for_displayport(long timeout_ms)
Wait for DisplayPort to be ready.
Definition: ec.c:1668
uint8_t get_cmd
Definition: ec.c:27
int google_chromeec_get_protocol_info(struct ec_response_get_protocol_info *resp)
Get information about the protocol that the EC speaks.
Definition: ec.c:734
int google_chromeec_get_cmd_versions(int command, uint32_t *pmask)
Get available versions of the specified command.
Definition: ec.c:464
int google_chromeec_typec_control_enter_dp_mode(int port)
Definition: ec.c:1512
int google_chromeec_cbi_get_board_version(uint32_t *version)
Definition: ec.c:870
int google_chromeec_set_wake_mask(uint64_t mask)
Definition: ec.c:1131
int google_chromeec_flash_info(struct ec_response_flash_info *info)
Return information about the entire flash.
Definition: ec.c:609
static const char * reset_cause_to_str(uint16_t cause)
Definition: ec.c:1267
static int google_chromeec_uhepi_cmd(uint8_t mask, uint8_t action, uint64_t *value)
Definition: ec.c:110
int google_chromeec_regulator_is_enabled(uint32_t index, uint8_t *enabled)
Query if the regulator is enabled.
Definition: ec.c:1776
int google_chromeec_hello(void)
Performs light verification of the EC<->AP communication channel.
Definition: ec.c:1236
int google_chromeec_get_board_version(uint32_t *version)
google_chromeec_get_board_version() - Get the board version
Definition: ec.c:915
static int cbi_get_string(char *buf, size_t bufsize, uint32_t tag)
Definition: ec.c:880
void google_chromeec_post(uint8_t postcode)
Definition: ec.c:97
static int google_chromeec_set_s3_lazy_wake_mask(uint64_t mask)
Definition: ec.c:234
int google_chromeec_flash_region_info(enum ec_flash_region region, uint32_t *offset, uint32_t *size)
Get offset and size of the specified EC flash region.
Definition: ec.c:559
bool google_chromeec_get_ap_watchdog_flag(void)
Definition: ec.c:1008
uint32_t google_chromeec_get_sku_id(void)
Definition: ec.c:934
int google_chromeec_reboot(int dev_idx, enum ec_reboot_cmd type, uint8_t flags)
Definition: ec.c:794
uint64_t google_chromeec_get_events_b(void)
Definition: ec.c:272
int google_chromeec_read_limit_power_request(int *limit_power)
Check if the EC is requesting the system to limit input power.
Definition: ec.c:700
static void google_chromeec_log_uptimeinfo(void)
Definition: ec.c:1313
static int google_chromeec_pd_get_amode(uint16_t svid)
Check if EC/TCPM is in an alternate mode or not.
Definition: ec.c:1612
int google_chromeec_check_feature(int feature)
Definition: ec.c:443
static int google_chromeec_set_s0ix_lazy_wake_mask(uint64_t mask)
Definition: ec.c:250
int google_chromeec_flash_protect(uint32_t mask, uint32_t flags, struct ec_response_flash_protect *resp)
Protect/un-protect EC flash regions.
Definition: ec.c:536
int google_chromeec_flash_write_block(const uint8_t *params_data, uint32_t bufsize)
Write a block into EC flash.
Definition: ec.c:632
#define USB_SID_DISPLAYPORT
Definition: ec.c:1659
int google_chromeec_cbi_get_dram_part_num(char *buf, size_t bufsize)
Definition: ec.c:905
int google_ec_running_ro(void)
Definition: ec.c:1475
uint64_t google_chromeec_get_device_current_events(void)
Definition: ec.c:344
int google_chromeec_regulator_set_voltage(uint32_t index, uint32_t min_mv, uint32_t max_mv)
Set voltage for the voltage regulator within the range specified.
Definition: ec.c:1800
void google_chromeec_log_events(uint64_t mask)
Definition: ec.c:386
static uint64_t google_chromeec_get_mask(uint8_t type)
Definition: ec.c:195
int google_chromeec_start_vboot_hash(enum ec_vboot_hash_type hash_type, uint32_t hash_offset, struct ec_response_vboot_hash *resp)
Calculate image hash for vboot.
Definition: ec.c:510
int google_chromeec_set_sku_id(uint32_t skuid)
Definition: ec.c:753
uint8_t set_cmd
Definition: ec.c:25
int google_chromeec_cbi_get_oem_id(uint32_t *id)
Get data from Cros Board Info.
Definition: ec.c:865
static int google_chromeec_set_s5_lazy_wake_mask(uint64_t mask)
Definition: ec.c:242
static int google_chromeec_handle_non_uhepi_cmd(uint8_t hcmd, uint8_t action, uint64_t *value)
Definition: ec.c:143
int google_chromeec_usb_get_pd_mux_info(int port, uint8_t *flags)
Check for the current mux state in EC.
Definition: ec.c:1543
int google_chromeec_get_num_pd_ports(unsigned int *num_ports)
Get number of PD-capable USB ports from EC.
Definition: ec.c:1419
static uint16_t google_chromeec_get_uptime_info(struct ec_response_uptime_info *resp)
Definition: ec.c:991
#define UHEPI_SUPPORTED
uint64_t google_chromeec_get_wake_mask(void)
Definition: ec.c:1138
int google_chromeec_get_keybd_config(struct ec_response_keybd_config *keybd)
Get the keyboard configuration / layout information from EC.
Definition: ec.c:1718
static void google_chromeec_set_lazy_wake_masks(uint64_t s5_mask, uint64_t s3_mask, uint64_t s0ix_mask)
Definition: ec.c:257
int google_chromeec_wait_for_dp_hpd(int port, long timeout_ms)
Definition: ec.c:1699
enum ec_image google_chromeec_get_current_image(void)
Definition: ec.c:1384
int google_chromeec_i2c_xfer(uint8_t chip, uint8_t addr, int alen, uint8_t *buffer, int len, int is_read)
Definition: ec.c:1030
int google_chromeec_get_usb_pd_power_info(enum usb_chg_type *type, uint16_t *current_max, uint16_t *voltage_max)
Definition: ec.c:1163
#define UHEPI_NOT_SUPPORTED
int google_chromeec_get_usbc_mux_info(int port, struct usbc_mux_info *mux_info)
Definition: ec.c:1575
int google_chromeec_get_mkbp_event(struct ec_response_get_next_event *event)
Definition: ec.c:284
int google_chromeec_set_smi_mask(uint64_t mask)
Definition: ec.c:1125
int google_chromeec_set_usb_pd_role(uint8_t port, enum usb_pd_control_role role)
Definition: ec.c:1214
static void google_chromeec_log_device_events(uint64_t mask)
Definition: ec.c:366
int google_chromeec_kbbacklight(int percent)
Definition: ec.c:75
void google_chromeec_events_init(const struct google_chromeec_event_info *info, bool is_s3_wakeup)
Definition: ec.c:410
int google_chromeec_cbi_get_ssfc(uint32_t *ssfc)
Definition: ec.c:875
uint64_t google_chromeec_get_device_enabled_events(void)
Definition: ec.c:300
int google_chromeec_override_dedicated_charger_limit(uint16_t current_lim, uint16_t voltage_lim)
Definition: ec.c:1194
bool google_chromeec_is_uhepi_supported(void)
Definition: ec.c:177
static int google_chromeec_usb_pd_get_info(int port, bool *ufp, bool *dbg_acc, bool *active_cable, uint8_t *dp_mode)
Definition: ec.c:1481
int google_chromeec_cbi_get_sku_id(uint32_t *id)
Definition: ec.c:839
int google_chromeec_vbnv_context(int is_read, uint8_t *data, int len)
Definition: ec.c:952
int google_chromeec_battery_cutoff(uint8_t flags)
Command EC to perform battery cutoff.
Definition: ec.c:679
int google_chromeec_ap_reset(void)
Send EC command to perform AP reset.
Definition: ec.c:1736
int google_chromeec_regulator_enable(uint32_t index, uint8_t enable)
Configure the regulator as enabled / disabled.
Definition: ec.c:1754
static const struct @109 event_map[]
int google_chromeec_set_usb_charge_mode(uint8_t port_id, enum usb_charge_mode mode)
Definition: ec.c:1143
int google_chromeec_efs_verify(enum ec_flash_region region)
Verify flash using EFS if available.
Definition: ec.c:653
uint8_t clear_cmd
Definition: ec.c:26
void google_chromeec_init(void)
Definition: ec.c:1470
int google_chromeec_regulator_get_voltage(uint32_t index, uint32_t *voltage_mv)
Get the currently configured voltage for the voltage regulator.
Definition: ec.c:1824
int google_chromeec_cbi_get_oem_name(char *buf, size_t bufsize)
Definition: ec.c:910
static int __unused google_chromeec_set_mask(uint8_t type, uint64_t mask)
Definition: ec.c:222
int google_chromeec_set_sci_mask(uint64_t mask)
Definition: ec.c:1119
int google_chromeec_command(struct chromeec_command *cec_command)
Send a command to a CrOS EC.
Definition: ec_i2c.c:176
static struct usb_pd_port_caps port_caps
Definition: ec_acpi.c:121
#define EC_CMD_GET_KEYBD_CONFIG
Definition: ec_commands.h:6396
#define PD_POWER_CHARGING_PORT
Definition: ec_commands.h:5613
#define EC_CMD_USB_PD_PORTS
Definition: ec_commands.h:5602
@ EC_VBNV_CONTEXT_OP_WRITE
Definition: ec_commands.h:1870
@ EC_VBNV_CONTEXT_OP_READ
Definition: ec_commands.h:1869
#define EC_CMD_TYPEC_CONTROL
Definition: ec_commands.h:6624
#define EC_RESET_FLAG_AP_WATCHDOG
Definition: ec_commands.h:6044
#define EC_CMD_GET_PROTOCOL_INFO
Definition: ec_commands.h:1327
#define EC_VER_FLASH_WRITE
Definition: ec_commands.h:1665
#define EC_DEVICE_EVENT_MASK(event_code)
Definition: ec_commands.h:4841
@ CBI_TAG_OEM_ID
Definition: ec_commands.h:5976
@ CBI_TAG_OEM_NAME
Definition: ec_commands.h:5979
@ CBI_TAG_SSFC
Definition: ec_commands.h:5984
@ CBI_TAG_SKU_ID
Definition: ec_commands.h:5977
@ CBI_TAG_FW_CONFIG
Definition: ec_commands.h:5981
@ CBI_TAG_BOARD_VERSION
Definition: ec_commands.h:5975
@ CBI_TAG_DRAM_PART_NUM
Definition: ec_commands.h:5978
#define EC_CMD_REGULATOR_GET_VOLTAGE
Definition: ec_commands.h:6576
#define EC_VER_FLASH_PROTECT
Definition: ec_commands.h:1742
#define EC_CMD_GET_CMD_VERSIONS
Definition: ec_commands.h:1260
#define EC_CMD_OVERRIDE_DEDICATED_CHARGER_LIMIT
Definition: ec_commands.h:4707
#define EC_CMD_USB_PD_POWER_INFO
Definition: ec_commands.h:5611
@ PD_CC_DFP_ATTACHED
Definition: ec_commands.h:5576
@ PD_CC_DFP_DEBUG_ACC
Definition: ec_commands.h:5577
#define USB_PD_MUX_DP_ENABLED
Definition: ec_commands.h:5883
#define EC_CMD_FLASH_REGION_INFO
Definition: ec_commands.h:1809
#define EC_CMD_GET_SKU_ID
Definition: ec_commands.h:1519
@ CHARGE_STATE_CMD_GET_PARAM
Definition: ec_commands.h:4605
#define EC_CMD_FLASH_ERASE
Definition: ec_commands.h:1682
#define EC_CMD_USB_CHARGE_SET_MODE
Definition: ec_commands.h:3236
#define EC_CMD_I2C_PASSTHRU
Definition: ec_commands.h:4506
#define EC_CMD_HOST_EVENT_GET_B
Definition: ec_commands.h:4055
ec_flash_region
Definition: ec_commands.h:1812
#define EC_CMD_FLASH_PROTECT
Definition: ec_commands.h:1741
#define EC_CMD_GET_NEXT_EVENT
Definition: ec_commands.h:3780
#define EC_CMD_USB_PD_MUX_INFO
Definition: ec_commands.h:5874
#define USB_PD_MUX_POLARITY_INVERTED
Definition: ec_commands.h:5884
#define BIT(nr)
Definition: ec_commands.h:45
#define EC_CMD_HOST_EVENT_GET_WAKE_MASK
Definition: ec_commands.h:4058
#define EC_CMD_PWM_SET_KEYBOARD_BACKLIGHT
Definition: ec_commands.h:2035
#define EC_CMD_FLASH_INFO
Definition: ec_commands.h:1532
#define EC_CMD_GET_VERSION
Definition: ec_commands.h:1130
#define EC_CMD_EFS_VERIFY
Definition: ec_commands.h:5956
@ USB_PD_CTRL_MUX_NO_CHANGE
Definition: ec_commands.h:5515
#define USB_PD_MUX_HPD_IRQ
Definition: ec_commands.h:5885
#define EC_CMD_VBNV_CONTEXT
Definition: ec_commands.h:1864
#define EC_CMD_GET_PD_PORT_CAPS
Definition: ec_commands.h:6292
#define EC_CMD_FLASH_WRITE
Definition: ec_commands.h:1664
usb_pd_control_role
Definition: ec_commands.h:5504
@ USB_PD_CTRL_ROLE_NO_CHANGE
Definition: ec_commands.h:5505
#define EC_CMD_REGULATOR_IS_ENABLED
Definition: ec_commands.h:6544
@ CHIPSET_RESET_AP_WATCHDOG
Definition: ec_commands.h:6085
#define EC_HOST_PARAM_SIZE
Definition: ec_commands.h:7554
ec_reboot_cmd
Definition: ec_commands.h:5367
#define EC_HOST_EVENT_MASK(event_code)
Definition: ec_commands.h:738
#define EC_CMD_GET_BOARD_VERSION
Definition: ec_commands.h:1229
#define EC_CMD_REBOOT_EC
Definition: ec_commands.h:5364
@ EC_DEVICE_EVENT_PARAM_SET_ENABLED_EVENTS
Definition: ec_commands.h:4838
@ EC_DEVICE_EVENT_PARAM_GET_CURRENT_EVENTS
Definition: ec_commands.h:4834
@ EC_DEVICE_EVENT_PARAM_GET_ENABLED_EVENTS
Definition: ec_commands.h:4836
#define EC_VER_FLASH_REGION_INFO
Definition: ec_commands.h:1810
#define EC_CMD_GET_FEATURES
Definition: ec_commands.h:1377
@ TYPEC_MODE_DP
Definition: ec_commands.h:6635
#define EC_VBNV_BLOCK_SIZE
Definition: ec_commands.h:1866
#define EC_CMD_GET_CROS_BOARD_INFO
Definition: ec_commands.h:5967
#define EC_CMD_HOST_EVENT_GET_SCI_MASK
Definition: ec_commands.h:4057
#define EC_CMD_HOST_EVENT_SET_WAKE_MASK
Definition: ec_commands.h:4064
usb_charge_mode
Definition: ec_commands.h:3238
#define EC_CMD_USB_PD_CONTROL
Definition: ec_commands.h:5502
ec_image
Definition: ec_commands.h:1141
@ EC_IMAGE_UNKNOWN
Definition: ec_commands.h:1142
@ EC_IMAGE_RO
Definition: ec_commands.h:1143
#define EC_CMD_SET_SKU_ID
Definition: ec_commands.h:1522
usb_chg_type
Definition: ec_commands.h:5618
#define EC_CMD_HOST_EVENT_CLEAR
Definition: ec_commands.h:4063
#define EC_CMD_VBOOT_HASH
Definition: ec_commands.h:2466
#define USB_PD_MUX_HPD_LVL
Definition: ec_commands.h:5887
#define EC_CMD_CHARGE_STATE
Definition: ec_commands.h:4600
#define EC_CMD_AP_RESET
Definition: ec_commands.h:6210
ec_vboot_hash_type
Definition: ec_commands.h:2495
@ EC_HOST_EVENT_GET
Definition: ec_commands.h:4110
@ EC_HOST_EVENT_SET
Definition: ec_commands.h:4113
@ EC_HOST_EVENT_CLEAR
Definition: ec_commands.h:4116
@ USB_PD_CTRL_SWAP_NONE
Definition: ec_commands.h:5525
#define EC_CMD_HOST_EVENT_SET_SMI_MASK
Definition: ec_commands.h:4061
#define EC_CMD_HOST_EVENT_SET_SCI_MASK
Definition: ec_commands.h:4062
#define EC_I2C_FLAG_READ
Definition: ec_commands.h:4509
@ EC_FEATURE_DEVICE_EVENT
Definition: ec_commands.h:1465
@ EC_FEATURE_UNIFIED_WAKE_MASKS
Definition: ec_commands.h:1467
@ EC_FEATURE_TYPEC_REQUIRE_AP_MODE_ENTRY
Definition: ec_commands.h:1498
#define USB_PD_CTRL_ACTIVE_CABLE
Definition: ec_commands.h:5581
#define EC_VER_VBNV_CONTEXT
Definition: ec_commands.h:1865
@ EC_RES_INVALID_PARAM
Definition: ec_commands.h:624
@ EC_RES_INVALID_COMMAND
Definition: ec_commands.h:622
#define EC_CMD_REGULATOR_ENABLE
Definition: ec_commands.h:6532
@ TYPEC_CONTROL_COMMAND_ENTER_MODE
Definition: ec_commands.h:6629
#define EC_I2C_STATUS_ERROR
Definition: ec_commands.h:4518
#define EC_CMD_DEVICE_EVENT
Definition: ec_commands.h:4823
#define EC_CMD_GET_UPTIME_INFO
Definition: ec_commands.h:6023
@ EC_HOST_EVENT_SMI_MASK
Definition: ec_commands.h:4131
@ EC_HOST_EVENT_ACTIVE_WAKE_MASK
Definition: ec_commands.h:4137
@ EC_HOST_EVENT_ALWAYS_REPORT_MASK
Definition: ec_commands.h:4134
@ EC_HOST_EVENT_LAZY_WAKE_MASK_S3
Definition: ec_commands.h:4143
@ EC_HOST_EVENT_B
Definition: ec_commands.h:4125
@ EC_HOST_EVENT_LAZY_WAKE_MASK_S0IX
Definition: ec_commands.h:4140
@ EC_HOST_EVENT_LAZY_WAKE_MASK_S5
Definition: ec_commands.h:4146
@ EC_HOST_EVENT_SCI_MASK
Definition: ec_commands.h:4128
@ EC_HOST_EVENT_MAIN
Definition: ec_commands.h:4122
#define EC_CMD_RTC_GET_VALUE
Definition: ec_commands.h:3318
@ EC_VBOOT_HASH_START
Definition: ec_commands.h:2491
@ EC_VBOOT_HASH_GET
Definition: ec_commands.h:2489
#define EC_CMD_HOST_EVENT
Definition: ec_commands.h:4149
#define EC_FEATURE_MASK_0(event_code)
Definition: ec_commands.h:1510
#define EC_CMD_HELLO
Definition: ec_commands.h:1111
#define EC_CMD_HOST_EVENT_GET_SMI_MASK
Definition: ec_commands.h:4056
#define EC_CMD_USB_PD_GET_AMODE
Definition: ec_commands.h:5820
@ CS_PARAM_LIMIT_POWER
Definition: ec_commands.h:4620
#define EC_CMD_BATTERY_CUT_OFF
Definition: ec_commands.h:4383
#define EC_CMD_HOST_EVENT_CLEAR_B
Definition: ec_commands.h:4065
#define EC_CMD_REGULATOR_SET_VOLTAGE
Definition: ec_commands.h:6562
static size_t offset
Definition: flashconsole.c:16
static struct tpm_chip chip
Definition: tis.c:17
port
Definition: i915.h:29
#define __unused
Definition: helpers.h:38
int rtc_to_tm(int tim, struct rtc_time *tm)
Definition: rtc.c:46
static int stopwatch_expired(struct stopwatch *sw)
Definition: timer.h:152
static long stopwatch_duration_msecs(struct stopwatch *sw)
Definition: timer.h:182
static void stopwatch_init_msecs_expire(struct stopwatch *sw, long ms)
Definition: timer.h:133
#define MSECS_PER_SEC
Definition: timer.h:9
unsigned int type
Definition: edid.c:57
unsigned int version[2]
Definition: edid.c:55
#define BIOS_INFO
BIOS_INFO - Expected events.
Definition: loglevel.h:113
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
Definition: loglevel.h:128
#define BIOS_ERR
BIOS_ERR - System in incomplete state.
Definition: loglevel.h:72
#define BIOS_WARNING
BIOS_WARNING - Bad configuration.
Definition: loglevel.h:86
static uint8_t * buf
Definition: uart.c:7
enum board_config config
Definition: memory.c:448
u8 buffer[C2P_BUFFER_MAXSIZE]
Definition: psp_smm.c:18
#define USB_PD_MUX_USB_ENABLED
Definition: retimer.h:8
static const int mask[4]
Definition: gpio.c:308
#define NULL
Definition: stddef.h:19
unsigned short uint16_t
Definition: stdint.h:11
unsigned int uint32_t
Definition: stdint.h:14
unsigned long long uint64_t
Definition: stdint.h:17
unsigned char uint8_t
Definition: stdint.h:8
uint8_t cmd_version
Definition: ec.h:150
uint16_t cmd_size_in
Definition: ec.h:153
int cmd_dev_index
Definition: ec.h:156
void * cmd_data_out
Definition: ec.h:152
const void * cmd_data_in
Definition: ec.h:151
uint16_t cmd_size_out
Definition: ec.h:154
uint16_t cmd_code
Definition: ec.h:149
struct ec_params_flash_erase - Parameters for the flash erase command, v0.
Definition: ec_commands.h:1689
struct ec_params_flash_protect - Parameters for the flash protect command.
Definition: ec_commands.h:1783
struct ec_params_flash_region_info - Parameters for the flash region info command.
Definition: ec_commands.h:1846
struct ec_params_get_cmd_versions_v1 - Parameters for the get command versions (v1) @cmd: Command to ...
Definition: ec_commands.h:1275
struct ec_params_hello - Parameters to the hello command.
Definition: ec_commands.h:1117
struct ec_params_i2c_passthru_msg msg[]
Definition: ec_commands.h:4528
struct ec_response_board_version - Response to the board version command.
Definition: ec_commands.h:1235
struct ec_response_charge_state::@143::__ec_align4 get_param
struct ec_response_flash_info - Response to the flash info command.
Definition: ec_commands.h:1547
struct ec_response_flash_protect - Response to the flash protect command.
Definition: ec_commands.h:1797
struct ec_response_get_cmd_version - Response to the get command versions.
Definition: ec_commands.h:1284
struct ec_response_get_protocol_info - Response to the get protocol info.
Definition: ec_commands.h:1341
struct ec_response_get_version - Response to the v0 get version command.
Definition: ec_commands.h:1157
struct ec_response_hello - Response to the hello command.
Definition: ec_commands.h:1125
uint16_t reset_cause
Definition: ec_commands.h:6145
uint32_t reset_time_ms
Definition: ec_commands.h:6155
uint32_t ap_resets_since_ec_boot
Definition: ec_commands.h:6134
struct ec_response_uptime_info::ap_reset_log_entry recent_ap_reset[4]
struct usb_chg_measures meas
Definition: ec_commands.h:5650
uint8_t block[EC_VBNV_BLOCK_SIZE]
Definition: ec_commands.h:1879
uint32_t sku_id
Definition: ec_commands.h:1525
struct fw_config - Firmware configuration field and option.
Definition: fw_config.h:20
Definition: region.h:76
Definition: rtc.h:6
uint16_t current_max
Definition: ec_commands.h:5641
uint16_t voltage_max
Definition: ec_commands.h:5639
uint16_t current_lim
Definition: ec_commands.h:5642
enum ec_pd_power_role_caps power_role_cap
Definition: ec.h:339
enum ec_pd_try_power_role_caps try_power_role_cap
Definition: ec.h:340
enum ec_pd_port_location port_location
Definition: ec.h:342
enum ec_pd_data_role_caps data_role_cap
Definition: ec.h:341
bool dbg_acc
Definition: usbc_mux.h:15
bool polarity
Definition: usbc_mux.h:11
bool hpd_irq
Definition: usbc_mux.h:13
bool cable
Definition: usbc_mux.h:10
uint8_t dp_pin_mode
Definition: usbc_mux.h:16
bool usb
Definition: usbc_mux.h:9
bool hpd_lvl
Definition: usbc_mux.h:12
#define m(clkreg, src_bits, pmcreg, dst_bits)