diff options
author | Wealian Liao <whliao@nuvoton.corp-partner.google.com> | 2021-02-25 17:53:06 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-03-10 07:48:09 +0000 |
commit | e87743f8373dd517efd87ae01a9e66e59cd3799f (patch) | |
tree | 40f5a0fd0cacbba531840c6646e767eb90ede980 /zephyr/include/drivers | |
parent | 304ac382935378e95ba1f37b98230d8219b18ac0 (diff) | |
download | chrome-ec-e87743f8373dd517efd87ae01a9e66e59cd3799f.tar.gz |
zephyr: add bbram system call
This CL include the following:
1. Adds BBRAM system call.
2. BBRAM read/write data isn't really for characters. Change to use
uint8_t.
BUG=None.
BRANCH=None.
TEST=build & boot EC on volteer
Signed-off-by: Wealian Liao <whliao@nuvoton.corp-partner.google.com>
Change-Id: Iff92071e1808c4dacb24bf46e663898120369821
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2731177
Reviewed-by: Keith Short <keithshort@chromium.org>
Diffstat (limited to 'zephyr/include/drivers')
-rw-r--r-- | zephyr/include/drivers/cros_bbram.h | 153 |
1 files changed, 135 insertions, 18 deletions
diff --git a/zephyr/include/drivers/cros_bbram.h b/zephyr/include/drivers/cros_bbram.h index 24dda79251..f96ef3dba4 100644 --- a/zephyr/include/drivers/cros_bbram.h +++ b/zephyr/include/drivers/cros_bbram.h @@ -14,7 +14,7 @@ * * @return 0 if the Battery-Backed RAM data is valid. */ -typedef int (*cros_bbram_ibbr)(const struct device *dev); +typedef int (*cros_bbram_api_ibbr)(const struct device *dev); /** * Reset the IBBR status (calling cros_bbram_ibbr will return 0 after this). @@ -22,7 +22,7 @@ typedef int (*cros_bbram_ibbr)(const struct device *dev); * @return 0 after reset is complete. * @see cros_bbram_ibbr */ -typedef int (*cros_bbram_reset_ibbr)(const struct device *dev); +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 @@ -30,7 +30,7 @@ typedef int (*cros_bbram_reset_ibbr)(const struct device *dev); * * @return 0 if V SBY power domain is in normal operation. */ -typedef int (*cros_bbram_vsby)(const struct device *dev); +typedef int (*cros_bbram_api_vsby)(const struct device *dev); /** * Reset the V SBY status (calling cros_bbram_vsby will return 0 after this). @@ -38,7 +38,7 @@ typedef int (*cros_bbram_vsby)(const struct device *dev); * @return 0 after reset is complete. * @see cros_bbram_vsby */ -typedef int (*cros_bbram_reset_vsby)(const struct device *dev); +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 @@ -46,7 +46,7 @@ typedef int (*cros_bbram_reset_vsby)(const struct device *dev); * * @return 0 if the V CC1 power domain is in normal operation. */ -typedef int (*cros_bbram_vcc1)(const struct device *dev); +typedef int (*cros_bbram_api_vcc1)(const struct device *dev); /** * Reset the V CC1 status (calling cros_bbram_vcc1 will return 0 after this). @@ -54,23 +54,140 @@ typedef int (*cros_bbram_vcc1)(const struct device *dev); * @return 0 after reset is complete. * @see cros_bbram_vcc1 */ -typedef int (*cros_bbram_reset_vcc1)(const struct device *dev); +typedef int (*cros_bbram_api_reset_vcc1)(const struct device *dev); -typedef int (*cros_bbram_read)(const struct device *dev, int offset, int size, - char *data); +typedef int (*cros_bbram_api_read)(const struct device *dev, int offset, + int size, uint8_t *data); -typedef int (*cros_bbram_write)(const struct device *dev, int offset, int size, - char *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_ibbr ibbr; - cros_bbram_reset_ibbr reset_ibbr; - cros_bbram_vsby vsby; - cros_bbram_reset_vsby reset_vsby; - cros_bbram_vcc1 vcc1; - cros_bbram_reset_vcc1 reset_vcc1; - cros_bbram_read read; - cros_bbram_write write; + 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_ */ |