cros_ec: Sync with upstream Chrome OS EC
Subsystems (3)
v2 cover cros_ec: Sync with upstream Chrome OS EC
U-Boot's include/ec_commands.h is significantly behind the upstream
https://chromium.googlesource.com/a/chromiumos/platform/ec ChromeOS EC tree.
This series updates it and provides some fixes to resolve the resulting compilation errors and warnings.
Changes in v2:
- Drop patch 'bitops: Guard GENMASK and GENMASK_ULL against prior defines' by restructuring the __KERNEL__ gate in ec_commands.h instead, per Quentin's review
- Nest '!defined(__UBOOT__)' inside the existing '__KERNEL__' gate so U-Boot skips both <linux/limits.h> and the local BIT/GENMASK defines, avoiding redefinition against U-Boot's linux/bitops.h
- Pull in <linux/bitops.h> up front for U-Boot
Simon Glass (1):
cros_ec: Sync ec_commands.h from upstream Chrome OS EC
arch/x86/cpu/apollolake/cpu_spl.c | 2 +- cmd/cros_ec.c | 4 +- drivers/misc/cros_ec.c | 2 +- drivers/misc/cros_ec_sandbox.c | 2 +- include/cros_ec.h | 36 +- include/ec_commands.h | 7784 +++++++++++++++++++++++------ 6 files changed, 6299 insertions(+), 1531 deletions(-)
---
base-commit: 3cdd19089f1b1b7cd08530f33ff4708abcfd426c
branch: ec2
Signature · 1 line
2.43.0
PATCH v2 1/1 cros_ec: Sync ec_commands.h from upstream Chrome OS EC
Sync include/ec_commands.h from upstream commit 4f3d17aa34 ("skywalker: set SLEEP_TIMEOUT_MS to 50 seconds"). The new file makes two build assumptions that do not hold for U-Boot.
It hides '<stdint.h>' from __KERNEL__ builds, leaving UINT16_MAX (used by EC_RES_MAX) undefined for U-Boot; widen the gate to '!defined(__KERNEL__) || defined(__UBOOT__)'
It gates '<linux/limits.h>' on '#ifdef __KERNEL__'; the matching '#else' branch defines BIT()/BIT_ULL()/GENMASK()/GENMASK_ULL() locally, assuming kernel headers provide those macros otherwise. U-Boot defines __KERNEL__ too but has no <linux/limits.h>. Nest a '!defined(__UBOOT__)' check around the include so the __UBOOT__ path stays in the __KERNEL__ branch (no local BIT/GENMASK defines), which avoids redefinition warnings against U-Boot's linux/bitops.h. Pull in linux/bitops.h up front for U-Boot so the file's own BIT() and GENMASK() uses still resolve.
Adapt callers to two interface changes. The 'ec_current_image' enum tag is now 'ec_image' (EC_IMAGE_* constants unchanged); rename it in affected files to match. The VBNV-context interface was dropped upstream, but it still used in lab Chromebooks; keep those constants and structs in cros_ec.h
Likewise, MEC_EMI_BASE and MEC_EMI_SIZE are a U-Boot-local addition to ec_commands.h that the upstream sync removes; preserve them in cros_ec.h next to the VBNV block, and switch the only consumer (arch/x86/cpu/apollolake/cpu_spl.c) to include cros_ec.h
---
Changes in v2:
- Nest '!defined(__UBOOT__)' inside the existing '__KERNEL__' gate so U-Boot skips both <linux/limits.h> and the local BIT/GENMASK defines, avoiding redefinition against U-Boot's linux/bitops.h
- Pull in <linux/bitops.h> up front for U-Boot
arch/x86/cpu/apollolake/cpu_spl.c | 2 +- cmd/cros_ec.c | 4 +- drivers/misc/cros_ec.c | 2 +- drivers/misc/cros_ec_sandbox.c | 2 +- include/cros_ec.h | 36 +- include/ec_commands.h | 7784 +++++++++++++++++++++++------ 6 files changed, 6299 insertions(+), 1531 deletions(-)
arch/x86/cpu/apollolake/cpu_spl.c +1 -1
@@ -6,7 +6,7 @@*/ #include <dm.h> -#include <ec_commands.h> +#include <cros_ec.h> #include <init.h> #include <log.h> #include <spi_flash.h>
cmd/cros_ec.c +2 -2
@@ -13,7 +13,7 @@#include <dm/device-internal.h> #include <dm/uclass-internal.h> -/* Note: depends on enum ec_current_image */ +/* Note: depends on enum ec_image */ static const char *const ec_current_image_name[] = {"unknown" ,"RO" ,"RW" };/**
@@ -312,7 +312,7 @@ static int do_cros_ec(struct cmd_tbl *cmdtp, int flag, int argc,if (ret)printf ("Error: %d\n" , ret); }else if (0 ==strcmp ("curimage" , cmd)) { -enum ec_current_image image; +enum ec_image image;if (cros_ec_read_current_image (dev, &image)) {debug ("%s: Could not read KBC image\n" , __func__);
drivers/misc/cros_ec.c +1 -1
@@ -487,7 +487,7 @@ int cros_ec_read_build_info(struct udevice *dev, char **strp) }int cros_ec_read_current_image (struct udevice *dev, -enum ec_current_image *image) +enum ec_image *image) {struct ec_response_get_version *r;
drivers/misc/cros_ec_sandbox.c +1 -1
@@ -100,7 +100,7 @@ struct ec_state {struct fdt_cros_ec ec_config;uint8_t *flash_data;int flash_data_len; -enum ec_current_image current_image; +enum ec_image current_image;int matrix_count;struct ec_keymatrix_entry *matrix;/* the key matrix info */ uint8_t keyscan[KEYBOARD_COLS ];
include/cros_ec.h +35 -1
@@ -14,6 +14,40 @@#include <asm/gpio.h> #include <dm/of_extra.h> +/* +* Verified-boot NVRAM context interface the EC exposes via +* EC_CMD_VBNV_CONTEXT. Upstream cros_ec_commands.h dropped the +* whole vbnvcontext machinery, so keep the constants and request / +* response structs here for U-Boot. Both 'cros_ec vbnvcontext' and +* cros_ec_{read,write}_vbnvcontext() depend on these. +*/ +#define EC_CMD_VBNV_CONTEXT 0x0017 +#define EC_VER_VBNV_CONTEXT 1 +#define EC_VBNV_BLOCK_SIZE 16 +#define EC_VBNV_BLOCK_SIZE_V2 64 + +enum ec_vbnvcontext_op { +EC_VBNV_CONTEXT_OP_READ , +EC_VBNV_CONTEXT_OP_WRITE , +}; + +struct __ec_align4 ec_params_vbnvcontext { +uint32_t op; +uint8_t block[EC_VBNV_BLOCK_SIZE_V2 ]; +}; + +struct __ec_align4 ec_response_vbnvcontext { +uint8_t block[EC_VBNV_BLOCK_SIZE_V2 ]; +}; + +/* +* EMI register window used by Microchip MEC-style EC LPC interfaces. +* Upstream cros_ec_commands.h does not carry these, but apollolake's +* SPL needs them to set up the EC ioport range. +*/ +#define MEC_EMI_BASE 0x800 +#define MEC_EMI_SIZE 8 +/* Our configuration information */ struct cros_ec_dev {struct udevice *dev;/* Transport device */
@@ -101,7 +135,7 @@ int cros_ec_get_next_event(struct udevice *dev,* Return: 0 if ok, <0 on error */ int cros_ec_read_current_image (struct udevice *dev, -enum ec_current_image *image); +enum ec_image *image);/** * Read the hash of the CROS-EC device firmware.
include/ec_commands.h +6259 -1525
2,912 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.43.0
Part of the diff is not shown here. View the raw message.
Quoted 8 lines · Simon Glass
U-Boot's
include/ec_commands.his significantly behind the upstream
https://chromium.googlesource.com/a/chromiumos/platform/ec ChromeOS EC tree.This series updates it and provides some fixes to resolve the resulting compilation errors and warnings.
[...]
Applied to u-boot/next, thanks!
[1/1] cros_ec: Sync ec_commands.h from upstream Chrome OS EC
commit: a219f64c2794135b44ab9aa9b808c5c25d18262c
Signature · 1 line
Tom