summaryrefslogtreecommitdiff
path: root/src/ec
diff options
context:
space:
mode:
authorStefan Reinauer <reinauer@chromium.org>2013-08-29 15:57:11 -0700
committerIsaac Christensen <isaac.christensen@se-eng.com>2014-08-13 00:15:36 +0200
commitaaaf689007cb6d80d326e5a297899e6719bdac30 (patch)
treec6f5141f41fd03f10038ade0baccfa6027577f5f /src/ec
parentb8fad3d02986222fa162d455eca2ffe807b6a15a (diff)
downloadcoreboot-aaaf689007cb6d80d326e5a297899e6719bdac30.tar.xz
chromeos: On ARM platforms VBNV lives in the EC
This patch renames the x86 way of doing things to explicitly mention CMOS (which is not available on our ARM platforms) and adds an implementation to get VBNV through the Chrome EC. We might want to refine this further in the future to allow VBNV in the EC even on x86 platforms. Will be fixed when that appears. Also, not all ARM platforms running ChromeOS might use the Google EC in the future, in which case this code will need additional work. Signed-off-by: Stefan Reinauer <reinauer@google.com> Change-Id: Ice09d0e277dbb131f9ad763e762e8877007db901 Reviewed-on: https://chromium-review.googlesource.com/167540 Reviewed-by: David Hendrix <dhendrix@chromium.org> Tested-by: Stefan Reinauer <reinauer@google.com> Commit-Queue: Stefan Reinauer <reinauer@google.com> (cherry picked from commit 8df6cdbcacb082af88c069ef8b542b44ff21d97a) Signed-off-by: Isaac Christensen <isaac.christensen@se-eng.com> Reviewed-on: http://review.coreboot.org/6616 Tested-by: build bot (Jenkins) Reviewed-by: David Hendricks <dhendrix@chromium.org>
Diffstat (limited to 'src/ec')
-rw-r--r--src/ec/google/chromeec/ec.c34
-rw-r--r--src/ec/google/chromeec/ec.h1
2 files changed, 34 insertions, 1 deletions
diff --git a/src/ec/google/chromeec/ec.c b/src/ec/google/chromeec/ec.c
index ab4db545fc..24f9693735 100644
--- a/src/ec/google/chromeec/ec.c
+++ b/src/ec/google/chromeec/ec.c
@@ -18,6 +18,7 @@
*/
#include <stdint.h>
+#include <string.h>
#include <console/console.h>
#include <bootmode.h>
#include <arch/io.h>
@@ -26,7 +27,6 @@
#include <reset.h>
#include <elog.h>
#include <stdlib.h>
-#include <string.h>
#include "chip.h"
#include "ec.h"
@@ -154,6 +154,38 @@ u16 google_chromeec_get_board_version(void)
return board_v.board_version;
}
+
+int google_chromeec_vbnv_context(int is_read, uint8_t *data, int len)
+{
+ struct chromeec_command cec_cmd;
+ struct ec_params_vbnvcontext cmd_vbnvcontext;
+ struct ec_response_vbnvcontext rsp_vbnvcontext;
+
+ if (len != EC_VBNV_BLOCK_SIZE)
+ return -1;
+
+
+ cec_cmd.cmd_code = EC_CMD_VBNV_CONTEXT;
+ cec_cmd.cmd_version = EC_VER_VBNV_CONTEXT;
+ cec_cmd.cmd_data_in = &cmd_vbnvcontext;
+ cec_cmd.cmd_data_out = &rsp_vbnvcontext;
+ cec_cmd.cmd_size_in = sizeof(cmd_vbnvcontext);
+ cec_cmd.cmd_size_out = sizeof(rsp_vbnvcontext);
+
+ cmd_vbnvcontext.op = is_read ? EC_VBNV_CONTEXT_OP_READ :
+ EC_VBNV_CONTEXT_OP_WRITE;
+
+ if (!is_read)
+ memcpy(&cmd_vbnvcontext.block, data, EC_VBNV_BLOCK_SIZE);
+
+ google_chromeec_command(&cec_cmd);
+
+ if (is_read)
+ memcpy(data, &rsp_vbnvcontext.block, EC_VBNV_BLOCK_SIZE);
+
+ return cec_cmd.cmd_code;
+}
+
#endif /* ! __SMM__ */
#ifndef __PRE_RAM__
diff --git a/src/ec/google/chromeec/ec.h b/src/ec/google/chromeec/ec.h
index d033bab73a..cf77b692f7 100644
--- a/src/ec/google/chromeec/ec.h
+++ b/src/ec/google/chromeec/ec.h
@@ -46,6 +46,7 @@ u32 google_chromeec_get_events_b(void);
int google_chromeec_kbbacklight(int percent);
void google_chromeec_post(u8 postcode);
void google_chromeec_log_events(u32 mask);
+int google_chromeec_vbnv_context(int is_read, uint8_t *data, int len);
enum usb_charge_mode {
USB_CHARGE_MODE_DISABLED,