summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Lin <tim2.lin@ite.corp-partner.google.com>2021-09-10 10:29:44 +0800
committerCommit Bot <commit-bot@chromium.org>2021-09-13 05:33:52 +0000
commit9365aa2ef2773e764655774e07230681297ed026 (patch)
tree9623e4653d5b948cb6a011dcd6f5445bf7eee322
parente7de2313be106dc09fdc2c67eda7c190be5fa3e4 (diff)
downloadchrome-ec-stabilize-14217.B-main.tar.gz
zephyr: shim/system: fix APIs of call BBRAM read and writestabilize-14217.B-main
The APIs of BBRAM read and write have been renamed and moved to drivers/bbram. The related call routines of shim/system.c need to be fixed. BUG=b:195843756 BRANCH=none TEST=the board of asurada and it8xxx2_evb can boot EC and access bbram successfully after adding this CL. zmake testall --> pass Change-Id: I98e51a278a24eeb4bbc92343fe6fc97e3e758e8a Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3153117 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Jack Rosenthal <jrosenth@chromium.org>
-rw-r--r--zephyr/include/drivers/cros_bbram.h193
-rw-r--r--zephyr/shim/src/system.c20
-rw-r--r--zephyr/test/system/test_system.c15
3 files changed, 14 insertions, 214 deletions
diff --git a/zephyr/include/drivers/cros_bbram.h b/zephyr/include/drivers/cros_bbram.h
deleted file mode 100644
index f96ef3dba4..0000000000
--- a/zephyr/include/drivers/cros_bbram.h
+++ /dev/null
@@ -1,193 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef ZEPHYR_INCLUDE_DRIVERS_CROS_BBRAM_H_
-#define ZEPHYR_INCLUDE_DRIVERS_CROS_BBRAM_H_
-
-#include <device.h>
-
-/**
- * Check if "Invalid Battery-Backed RAM". This may occur as a result to low
- * voltage at the VBAT pin.
- *
- * @return 0 if the Battery-Backed RAM data is valid.
- */
-typedef int (*cros_bbram_api_ibbr)(const struct device *dev);
-
-/**
- * Reset the IBBR status (calling cros_bbram_ibbr will return 0 after this).
- *
- * @return 0 after reset is complete.
- * @see cros_bbram_ibbr
- */
-typedef int (*cros_bbram_api_reset_ibbr)(const struct device *dev);
-
-/**
- * Check for V SBY power failure. This will return an error if the V SBY power
- * domain is turned on after it was off.
- *
- * @return 0 if V SBY power domain is in normal operation.
- */
-typedef int (*cros_bbram_api_vsby)(const struct device *dev);
-
-/**
- * Reset the V SBY status (calling cros_bbram_vsby will return 0 after this).
- *
- * @return 0 after reset is complete.
- * @see cros_bbram_vsby
- */
-typedef int (*cros_bbram_api_reset_vsby)(const struct device *dev);
-
-/**
- * Check for V CC1 power failure. This will return an error if the V CC1 power
- * domain is turned on after it was off.
- *
- * @return 0 if the V CC1 power domain is in normal operation.
- */
-typedef int (*cros_bbram_api_vcc1)(const struct device *dev);
-
-/**
- * Reset the V CC1 status (calling cros_bbram_vcc1 will return 0 after this).
- *
- * @return 0 after reset is complete.
- * @see cros_bbram_vcc1
- */
-typedef int (*cros_bbram_api_reset_vcc1)(const struct device *dev);
-
-typedef int (*cros_bbram_api_read)(const struct device *dev, int offset,
- int size, uint8_t *data);
-
-typedef int (*cros_bbram_api_write)(const struct device *dev, int offset,
- int size, uint8_t *data);
-
-__subsystem struct cros_bbram_driver_api {
- cros_bbram_api_ibbr ibbr;
- cros_bbram_api_reset_ibbr reset_ibbr;
- cros_bbram_api_vsby vsby;
- cros_bbram_api_reset_vsby reset_vsby;
- cros_bbram_api_vcc1 vcc1;
- cros_bbram_api_reset_vcc1 reset_vcc1;
- cros_bbram_api_read read;
- cros_bbram_api_write write;
-};
-
-__syscall int cros_bbram_get_ibbr(const struct device *dev);
-
-static inline int z_impl_cros_bbram_get_ibbr(const struct device *dev)
-{
- const struct cros_bbram_driver_api *api =
- (const struct cros_bbram_driver_api *)dev->api;
-
- if (!api->ibbr) {
- return -ENOTSUP;
- }
-
- return api->ibbr(dev);
-}
-
-__syscall int cros_bbram_reset_ibbr(const struct device *dev);
-
-static inline int z_impl_cros_bbram_reset_ibbr(const struct device *dev)
-{
- const struct cros_bbram_driver_api *api =
- (const struct cros_bbram_driver_api *)dev->api;
-
- if (!api->reset_ibbr) {
- return -ENOTSUP;
- }
-
- return api->reset_ibbr(dev);
-}
-
-__syscall int cros_bbram_get_vsby(const struct device *dev);
-
-static inline int z_impl_cros_bbram_get_vsby(const struct device *dev)
-{
- const struct cros_bbram_driver_api *api =
- (const struct cros_bbram_driver_api *)dev->api;
-
- if (!api->vsby) {
- return -ENOTSUP;
- }
-
- return api->vsby(dev);
-}
-
-__syscall int cros_bbram_reset_vsby(const struct device *dev);
-
-static inline int z_impl_cros_bbram_reset_vsby(const struct device *dev)
-{
- const struct cros_bbram_driver_api *api =
- (const struct cros_bbram_driver_api *)dev->api;
-
- if (!api->reset_vsby) {
- return -ENOTSUP;
- }
-
- return api->reset_vsby(dev);
-}
-
-__syscall int cros_bbram_get_vcc1(const struct device *dev);
-
-static inline int z_impl_cros_bbram_get_vcc1(const struct device *dev)
-{
- const struct cros_bbram_driver_api *api =
- (const struct cros_bbram_driver_api *)dev->api;
-
- if (!api->vcc1) {
- return -ENOTSUP;
- }
-
- return api->vcc1(dev);
-}
-
-__syscall int cros_bbram_reset_vcc1(const struct device *dev);
-
-static inline int z_impl_cros_bbram_reset_vcc1(const struct device *dev)
-{
- const struct cros_bbram_driver_api *api =
- (const struct cros_bbram_driver_api *)dev->api;
-
- if (!api->reset_vcc1) {
- return -ENOTSUP;
- }
-
- return api->reset_vcc1(dev);
-}
-
-__syscall int cros_bbram_read(const struct device *dev, int offset, int size,
- uint8_t *data);
-
-static inline int z_impl_cros_bbram_read(const struct device *dev, int offset,
- int size, uint8_t *data)
-{
- const struct cros_bbram_driver_api *api =
- (const struct cros_bbram_driver_api *)dev->api;
-
- if (!api->read) {
- return -ENOTSUP;
- }
-
- return api->read(dev, offset, size, data);
-}
-
-__syscall int cros_bbram_write(const struct device *dev, int offset, int size,
- uint8_t *data);
-
-static inline int z_impl_cros_bbram_write(const struct device *dev, int offset,
- int size, uint8_t *data)
-{
- const struct cros_bbram_driver_api *api =
- (const struct cros_bbram_driver_api *)dev->api;
-
- if (!api->write) {
- return -ENOTSUP;
- }
-
- return api->write(dev, offset, size, data);
-}
-
-#include <syscalls/cros_bbram.h>
-#endif /* ZEPHYR_INCLUDE_DRIVERS_CROS_BBRAM_H_ */
diff --git a/zephyr/shim/src/system.c b/zephyr/shim/src/system.c
index d6af88a9ff..2614a1fcb4 100644
--- a/zephyr/shim/src/system.c
+++ b/zephyr/shim/src/system.c
@@ -4,7 +4,7 @@
*/
#include <device.h>
-#include <drivers/cros_bbram.h>
+#include <drivers/bbram.h>
#include <drivers/cros_system.h>
#include <logging/log.h>
@@ -67,7 +67,7 @@ int system_get_bbram(enum system_bbram_idx idx, uint8_t *value)
if (rc)
return rc;
- rc = cros_bbram_read(bbram_dev, offset, size, value);
+ rc = bbram_read(bbram_dev, offset, size, value);
return rc ? EC_ERROR_INVAL : EC_SUCCESS;
}
@@ -79,8 +79,8 @@ void chip_save_reset_flags(uint32_t flags)
return;
}
- cros_bbram_write(bbram_dev, GET_BBRAM_OFFSET(saved_reset_flags),
- GET_BBRAM_SIZE(saved_reset_flags), (uint8_t *)&flags);
+ bbram_write(bbram_dev, GET_BBRAM_OFFSET(saved_reset_flags),
+ GET_BBRAM_SIZE(saved_reset_flags), (uint8_t *)&flags);
}
uint32_t chip_read_reset_flags(void)
@@ -92,8 +92,8 @@ uint32_t chip_read_reset_flags(void)
return 0;
}
- cros_bbram_read(bbram_dev, GET_BBRAM_OFFSET(saved_reset_flags),
- GET_BBRAM_SIZE(saved_reset_flags), (uint8_t *)&flags);
+ bbram_read(bbram_dev, GET_BBRAM_OFFSET(saved_reset_flags),
+ GET_BBRAM_SIZE(saved_reset_flags), (uint8_t *)&flags);
return flags;
}
@@ -105,8 +105,8 @@ int system_set_scratchpad(uint32_t value)
return -EC_ERROR_INVAL;
}
- return cros_bbram_write(bbram_dev, GET_BBRAM_OFFSET(scratchpad),
- GET_BBRAM_SIZE(scratchpad), (uint8_t *)&value);
+ return bbram_write(bbram_dev, GET_BBRAM_OFFSET(scratchpad),
+ GET_BBRAM_SIZE(scratchpad), (uint8_t *)&value);
}
int system_get_scratchpad(uint32_t *value)
@@ -116,8 +116,8 @@ int system_get_scratchpad(uint32_t *value)
return -EC_ERROR_INVAL;
}
- if (cros_bbram_read(bbram_dev, GET_BBRAM_OFFSET(scratchpad),
- GET_BBRAM_SIZE(scratchpad), (uint8_t *)value)) {
+ if (bbram_read(bbram_dev, GET_BBRAM_OFFSET(scratchpad),
+ GET_BBRAM_SIZE(scratchpad), (uint8_t *)value)) {
return -EC_ERROR_INVAL;
}
diff --git a/zephyr/test/system/test_system.c b/zephyr/test/system/test_system.c
index bb4f245644..e8eba44fc8 100644
--- a/zephyr/test/system/test_system.c
+++ b/zephyr/test/system/test_system.c
@@ -4,7 +4,7 @@
*/
#include <device.h>
-#include <drivers/cros_bbram.h>
+#include <drivers/bbram.h>
#include <logging/log.h>
#include <ztest.h>
@@ -21,8 +21,8 @@ LOG_MODULE_REGISTER(test);
static char mock_data[64] =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@";
-static int mock_bbram_read(const struct device *unused, int offset, int size,
- uint8_t *data)
+static int mock_bbram_read(const struct device *unused, size_t offset,
+ size_t size, uint8_t *data)
{
if (offset < 0 || offset + size >= ARRAY_SIZE(mock_data))
return -1;
@@ -30,15 +30,8 @@ static int mock_bbram_read(const struct device *unused, int offset, int size,
return EC_SUCCESS;
}
-static const struct cros_bbram_driver_api bbram_api = {
- .ibbr = NULL,
- .reset_ibbr = NULL,
- .vsby = NULL,
- .reset_vsby = NULL,
- .vcc1 = NULL,
- .reset_vcc1 = NULL,
+static const struct bbram_driver_api bbram_api = {
.read = mock_bbram_read,
- .write = NULL,
};
static const struct device bbram_dev_instance = {