X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=drivers%2Fmisc%2Fcros_ec_sandbox.c;h=9fd6cc2086ccab1b50c18700f0f2a593848e3f24;hb=b11f634b1c1be6ab419758c6596c673445e5ac70;hp=429f1a9b269dadfd1a113ffcd8d2366df0b9e06c;hpb=72ef8bfd6dd83412577f9c5da8a5b6bec5c22182;p=platform%2Fkernel%2Fu-boot.git diff --git a/drivers/misc/cros_ec_sandbox.c b/drivers/misc/cros_ec_sandbox.c index 429f1a9..9fd6cc2 100644 --- a/drivers/misc/cros_ec_sandbox.c +++ b/drivers/misc/cros_ec_sandbox.c @@ -11,10 +11,11 @@ #include #include #include -#include +#include #include #include #include +#include #include #include #include @@ -115,7 +116,7 @@ static int cros_ec_read_state(const void *blob, int node) prop = fdt_getprop(blob, node, "flash-data", &len); if (prop) { ec->flash_data_len = len; - ec->flash_data = os_malloc(len); + ec->flash_data = malloc(len); if (!ec->flash_data) return -ENOMEM; memcpy(ec->flash_data, prop, len); @@ -313,13 +314,15 @@ static int process_cmd(struct ec_state *ec, switch (req->op) { case EC_VBNV_CONTEXT_OP_READ: + /* TODO(sjg@chromium.org): Support full-size context */ memcpy(resp->block, ec->vbnv_context, - sizeof(resp->block)); - len = sizeof(*resp); + EC_VBNV_BLOCK_SIZE); + len = 16; break; case EC_VBNV_CONTEXT_OP_WRITE: - memcpy(ec->vbnv_context, resp->block, - sizeof(resp->block)); + /* TODO(sjg@chromium.org): Support full-size context */ + memcpy(ec->vbnv_context, req->block, + EC_VBNV_BLOCK_SIZE); len = 0; break; default: @@ -457,6 +460,14 @@ static int process_cmd(struct ec_state *ec, case EC_CMD_ENTERING_MODE: len = 0; break; + case EC_CMD_GET_NEXT_EVENT: { + struct ec_response_get_next_event *resp = resp_data; + + resp->event_type = EC_MKBP_EVENT_KEY_MATRIX; + cros_ec_keyscan(ec, resp->data.key_matrix); + len = sizeof(*resp); + break; + } default: printf(" ** Unknown EC command %#02x\n", req_hdr->command); return -1; @@ -509,8 +520,8 @@ void cros_ec_check_keyboard(struct udevice *dev) int cros_ec_probe(struct udevice *dev) { - struct ec_state *ec = dev->priv; - struct cros_ec_dev *cdev = dev->uclass_priv; + struct ec_state *ec = dev_get_priv(dev); + struct cros_ec_dev *cdev = dev_get_uclass_priv(dev); struct udevice *keyb_dev; ofnode node; int err; @@ -543,14 +554,14 @@ int cros_ec_probe(struct udevice *dev) ec->flash_data_len != ec->ec_config.flash.length) { printf("EC data length is %x, expected %x, discarding data\n", ec->flash_data_len, ec->ec_config.flash.length); - os_free(ec->flash_data); + free(ec->flash_data); ec->flash_data = NULL; } /* Otherwise allocate the memory */ if (!ec->flash_data) { ec->flash_data_len = ec->ec_config.flash.length; - ec->flash_data = os_malloc(ec->flash_data_len); + ec->flash_data = malloc(ec->flash_data_len); if (!ec->flash_data) return -ENOMEM; } @@ -569,11 +580,11 @@ static const struct udevice_id cros_ec_ids[] = { { } }; -U_BOOT_DRIVER(cros_ec_sandbox) = { - .name = "cros_ec_sandbox", +U_BOOT_DRIVER(google_cros_ec_sandbox) = { + .name = "google_cros_ec_sandbox", .id = UCLASS_CROS_EC, .of_match = cros_ec_ids, .probe = cros_ec_probe, - .priv_auto_alloc_size = sizeof(struct ec_state), + .priv_auto = sizeof(struct ec_state), .ops = &cros_ec_ops, };