Lines Matching refs:ec
114 struct ec_state *ec = &s_state; in cros_ec_read_state() local
119 ec->current_image = EC_IMAGE_RO; in cros_ec_read_state()
124 ec->current_image = fdtdec_get_int(blob, node, "current-image", in cros_ec_read_state()
127 if (prop && len == sizeof(ec->vbnv_context)) in cros_ec_read_state()
128 memcpy(ec->vbnv_context, prop, len); in cros_ec_read_state()
132 ec->flash_data_len = len; in cros_ec_read_state()
133 ec->flash_data = malloc(len); in cros_ec_read_state()
134 if (!ec->flash_data) in cros_ec_read_state()
136 memcpy(ec->flash_data, prop, len); in cros_ec_read_state()
154 struct ec_state *ec = g_state; in cros_ec_write_state() local
157 fdt_setprop_u32(blob, node, "current-image", ec->current_image); in cros_ec_write_state()
158 fdt_setprop(blob, node, "vbnv-context", ec->vbnv_context, in cros_ec_write_state()
159 sizeof(ec->vbnv_context)); in cros_ec_write_state()
160 return state_setprop(node, "flash-data", ec->flash_data, in cros_ec_write_state()
161 ec->ec_config.flash.length); in cros_ec_write_state()
179 static int get_image_used(struct ec_state *ec, struct fmap_entry *entry) in get_image_used() argument
189 size > 0 && ec->flash_data[entry->offset + size] != 0xea; in get_image_used()
206 static int keyscan_read_fdt_matrix(struct ec_state *ec, ofnode node) in keyscan_read_fdt_matrix() argument
213 ec->matrix_count = len / 4; in keyscan_read_fdt_matrix()
214 ec->matrix = calloc(ec->matrix_count, sizeof(*ec->matrix)); in keyscan_read_fdt_matrix()
215 if (!ec->matrix) { in keyscan_read_fdt_matrix()
221 for (upto = 0; upto < ec->matrix_count; upto++) { in keyscan_read_fdt_matrix()
222 struct ec_keymatrix_entry *matrix = &ec->matrix[upto]; in keyscan_read_fdt_matrix()
239 if (upto != ec->matrix_count) { in keyscan_read_fdt_matrix()
255 static int cros_ec_keyscan(struct ec_state *ec, uint8_t *scan) in cros_ec_keyscan() argument
263 memset(ec->keyscan, '\0', bytes); in cros_ec_keyscan()
267 for (i = 0, matrix = ec->matrix; i < ec->matrix_count; i++, matrix++) { in cros_ec_keyscan()
279 ec->keyscan[matrix->col] |= 1 << matrix->row; in cros_ec_keyscan()
283 memcpy(scan, ec->keyscan, bytes); in cros_ec_keyscan()
297 static int process_cmd(struct ec_state *ec, in process_cmd() argument
312 if (ec->test_flags & CROSECT_BREAK_HELLO) in process_cmd()
322 resp->current_image = ec->current_image; in process_cmd()
334 memcpy(resp->block, ec->vbnv_context, in process_cmd()
340 memcpy(ec->vbnv_context, req->block, in process_cmd()
360 ec->current_image = EC_IMAGE_RW; in process_cmd()
373 if (ec->recovery_req) { in process_cmd()
377 if (ec->test_flags & CROSECT_LID_OPEN) in process_cmd()
387 ec->test_flags &= ~CROSECT_LID_OPEN; in process_cmd()
397 entry = &ec->ec_config.region[EC_FLASH_REGION_ACTIVE]; in process_cmd()
403 len = get_image_used(ec, entry); in process_cmd()
405 ec->flash_data + entry->offset, in process_cmd()
454 entry = &ec->ec_config.region[req->region]; in process_cmd()
470 memset(ec->flash_data + req->offset, in process_cmd()
471 ec->ec_config.flash_erase_value, in process_cmd()
479 memcpy(ec->flash_data + req->offset, req + 1, req->size); in process_cmd()
484 len = cros_ec_keyscan(ec, resp_data); in process_cmd()
493 cros_ec_keyscan(ec, resp->data.key_matrix); in process_cmd()
523 if (ec->slot[i].locked) in process_cmd()
535 slot = &ec->slot[req->slot]; in process_cmd()
548 slot = &ec->slot[req->slot]; in process_cmd()
564 struct ec_state *ec = dev_get_priv(dev->dev); in cros_ec_sandbox_packet() local
571 len = process_cmd(ec, req_hdr, req_data, resp_hdr, resp_data); in cros_ec_sandbox_packet()
589 struct ec_state *ec = dev_get_priv(dev); in cros_ec_check_keyboard() local
598 ec->recovery_req = true; in cros_ec_check_keyboard()
606 struct ec_state *ec = dev_get_priv(dev); in cros_ec_sandbox_get_switches() local
608 return ec->test_flags & CROSECT_LID_OPEN ? EC_SWITCH_LID_OPEN : 0; in cros_ec_sandbox_get_switches()
613 struct ec_state *ec = dev_get_priv(dev); in sandbox_cros_ec_set_test_flags() local
615 ec->test_flags = flags; in sandbox_cros_ec_set_test_flags()
620 struct ec_state *ec = dev_get_priv(dev); in cros_ec_probe() local
626 memcpy(ec, &s_state, sizeof(*ec)); in cros_ec_probe()
627 err = cros_ec_decode_ec_flash(dev, &ec->ec_config); in cros_ec_probe()
644 } else if (keyscan_read_fdt_matrix(ec, node)) { in cros_ec_probe()
650 if (ec->flash_data && in cros_ec_probe()
651 ec->flash_data_len != ec->ec_config.flash.length) { in cros_ec_probe()
653 ec->flash_data_len, ec->ec_config.flash.length); in cros_ec_probe()
654 free(ec->flash_data); in cros_ec_probe()
655 ec->flash_data = NULL; in cros_ec_probe()
659 if (!ec->flash_data) { in cros_ec_probe()
660 ec->flash_data_len = ec->ec_config.flash.length; in cros_ec_probe()
661 ec->flash_data = malloc(ec->flash_data_len); in cros_ec_probe()
662 if (!ec->flash_data) in cros_ec_probe()
667 g_state = ec; in cros_ec_probe()