Lines Matching full:ec
24 * Ultimately it shold be possible to connect an Chrome OS EC emulation
32 * into key scan data, passed back from the EC as key scan messages. The
37 * 3. Save/restore of EC state, so that the vboot context, flash memory
39 * since the EC is supposed to continue running even if the AP resets.
42 * to enter recovery mode. The EC passes this to U-Boot through the normal
48 * 6. Hashing of the EC image, again to support software sync.
51 * the EC image in with U-Boot (Vic has demonstrated a prototype for this).
67 * struct ec_state - Information about the EC state
69 * @vbnv_context: Vboot context data stored by EC
70 * @ec_config: FDT config information about the EC (e.g. flashmap)
73 * @current_image: Current image the EC is running
92 * cros_ec_read_state() - read the sandbox EC state from the state file
95 * not this function sets up an empty EC.
102 struct ec_state *ec = &s_state; in cros_ec_read_state() local
107 ec->current_image = EC_IMAGE_RO; in cros_ec_read_state()
112 ec->current_image = fdtdec_get_int(blob, node, "current-image", in cros_ec_read_state()
115 if (prop && len == sizeof(ec->vbnv_context)) in cros_ec_read_state()
116 memcpy(ec->vbnv_context, prop, len); in cros_ec_read_state()
120 ec->flash_data_len = len; in cros_ec_read_state()
121 ec->flash_data = os_malloc(len); in cros_ec_read_state()
122 if (!ec->flash_data) in cros_ec_read_state()
124 memcpy(ec->flash_data, prop, len); in cros_ec_read_state()
125 debug("%s: Loaded EC flash data size %#x\n", __func__, len); in cros_ec_read_state()
142 struct ec_state *ec = g_state; in cros_ec_write_state() local
145 fdt_setprop_u32(blob, node, "current-image", ec->current_image); in cros_ec_write_state()
146 fdt_setprop(blob, node, "vbnv-context", ec->vbnv_context, in cros_ec_write_state()
147 sizeof(ec->vbnv_context)); in cros_ec_write_state()
148 return state_setprop(node, "flash-data", ec->flash_data, in cros_ec_write_state()
149 ec->ec_config.flash.length); in cros_ec_write_state()
152 SANDBOX_STATE_IO(cros_ec, "google,cros-ec", cros_ec_read_state,
160 * that used by the real EC code base.
162 * @param ec Current emulated EC state
167 static int get_image_used(struct ec_state *ec, struct fmap_entry *entry) in get_image_used() argument
173 * last byte of the image. See ec.lds.S for how this is inserted at in get_image_used()
177 size > 0 && ec->flash_data[entry->offset + size] != 0xea; in get_image_used()
190 * @param ec Current emulated EC state
194 static int keyscan_read_fdt_matrix(struct ec_state *ec, ofnode node) in keyscan_read_fdt_matrix() argument
201 ec->matrix_count = len / 4; in keyscan_read_fdt_matrix()
202 ec->matrix = calloc(ec->matrix_count, sizeof(*ec->matrix)); in keyscan_read_fdt_matrix()
203 if (!ec->matrix) { in keyscan_read_fdt_matrix()
209 for (upto = 0; upto < ec->matrix_count; upto++) { in keyscan_read_fdt_matrix()
210 struct ec_keymatrix_entry *matrix = &ec->matrix[upto]; in keyscan_read_fdt_matrix()
227 if (upto != ec->matrix_count) { in keyscan_read_fdt_matrix()
238 * @param ec Current emulated EC state
243 static int cros_ec_keyscan(struct ec_state *ec, uint8_t *scan) in cros_ec_keyscan() argument
251 memset(ec->keyscan, '\0', bytes); in cros_ec_keyscan()
255 for (i = 0, matrix = ec->matrix; i < ec->matrix_count; i++, matrix++) { in cros_ec_keyscan()
267 ec->keyscan[matrix->col] |= 1 << matrix->row; in cros_ec_keyscan()
271 memcpy(scan, ec->keyscan, bytes); in cros_ec_keyscan()
276 * Process an emulated EC command
278 * @param ec Current emulated EC state
285 static int process_cmd(struct ec_state *ec, in process_cmd() argument
292 debug("EC command %#0x\n", req_hdr->command); in process_cmd()
308 resp->current_image = ec->current_image; in process_cmd()
319 memcpy(resp->block, ec->vbnv_context, in process_cmd()
324 memcpy(ec->vbnv_context, resp->block, in process_cmd()
344 ec->current_image = EC_IMAGE_RW; in process_cmd()
357 if (ec->recovery_req) { in process_cmd()
371 entry = &ec->ec_config.region[EC_FLASH_REGION_RW]; in process_cmd()
377 len = get_image_used(ec, entry); in process_cmd()
379 ec->flash_data + entry->offset, in process_cmd()
428 entry = &ec->ec_config.region[req->region]; in process_cmd()
432 printf("EC flash region %d: offset=%#x, size=%#x\n", in process_cmd()
444 memset(ec->flash_data + req->offset, in process_cmd()
445 ec->ec_config.flash_erase_value, in process_cmd()
453 memcpy(ec->flash_data + req->offset, req + 1, req->size); in process_cmd()
458 len = cros_ec_keyscan(ec, resp_data); in process_cmd()
464 printf(" ** Unknown EC command %#02x\n", req_hdr->command); in process_cmd()
474 struct ec_state *ec = dev_get_priv(dev->dev); in cros_ec_sandbox_packet() local
481 len = process_cmd(ec, req_hdr, req_data, resp_hdr, resp_data); in cros_ec_sandbox_packet()
499 struct ec_state *ec = dev_get_priv(dev->dev); in cros_ec_check_keyboard() local
502 printf("Press keys for EC to detect on reset (ESC=recovery)..."); in cros_ec_check_keyboard()
508 ec->recovery_req = true; in cros_ec_check_keyboard()
509 printf(" - EC requests recovery\n"); in cros_ec_check_keyboard()
515 struct ec_state *ec = dev->priv; in cros_ec_probe() local
521 memcpy(ec, &s_state, sizeof(*ec)); in cros_ec_probe()
522 err = cros_ec_decode_ec_flash(dev, &ec->ec_config); in cros_ec_probe()
524 debug("%s: Cannot device EC flash\n", __func__); in cros_ec_probe()
539 } else if (keyscan_read_fdt_matrix(ec, node)) { in cros_ec_probe()
544 /* If we loaded EC data, check that the length matches */ in cros_ec_probe()
545 if (ec->flash_data && in cros_ec_probe()
546 ec->flash_data_len != ec->ec_config.flash.length) { in cros_ec_probe()
547 printf("EC data length is %x, expected %x, discarding data\n", in cros_ec_probe()
548 ec->flash_data_len, ec->ec_config.flash.length); in cros_ec_probe()
549 os_free(ec->flash_data); in cros_ec_probe()
550 ec->flash_data = NULL; in cros_ec_probe()
554 if (!ec->flash_data) { in cros_ec_probe()
555 ec->flash_data_len = ec->ec_config.flash.length; in cros_ec_probe()
556 ec->flash_data = os_malloc(ec->flash_data_len); in cros_ec_probe()
557 if (!ec->flash_data) in cros_ec_probe()
562 g_state = ec; in cros_ec_probe()
571 { .compatible = "google,cros-ec-sandbox" },