summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMulin Chao <mlchao@nuvoton.com>2021-03-31 22:17:22 -0700
committerCommit Bot <commit-bot@chromium.org>2021-04-08 00:20:52 +0000
commite97174705337e55327ce6454e626e31e323e70c6 (patch)
treeebdde6a6f25a040cb3f47646f48919bb461d4493
parent93c2031f3d887e8b221a3b303a73390771793e97 (diff)
downloadchrome-ec-e97174705337e55327ce6454e626e31e323e70c6.tar.gz
zephyr: Add chip info API in cros_system driver
Add the following chip_info API in cros_system driver for getting the chip information: 1. cros_system_chip_vendor() 2. cros_system_chip_name() 3. cros_system_chip_revision() BUG=none BRANCH=none TEST=build & boot ec on volteer Signed-off-by: Mulin Chao <mlchao@nuvoton.com> Signed-off-by: Wealian Liao <whliao@nuvoton.corp-partner.google.com> Change-Id: I06718ff26f9cbee26cc9dbdcbbd02a0cc901d397 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2807477 Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Commit-Queue: Jack Rosenthal <jrosenth@chromium.org>
-rw-r--r--zephyr/include/drivers/cros_system.h89
1 files changed, 89 insertions, 0 deletions
diff --git a/zephyr/include/drivers/cros_system.h b/zephyr/include/drivers/cros_system.h
index 9010be2829..fcd3ef3b6a 100644
--- a/zephyr/include/drivers/cros_system.h
+++ b/zephyr/include/drivers/cros_system.h
@@ -61,11 +61,35 @@ typedef int (*cros_system_hibernate_api)(const struct device *dev,
uint32_t seconds,
uint32_t microseconds);
+/**
+ * @typedef cros_system_chip_vendor_api
+ * @brief Callback API for getting the chip vendor.
+ * See cros_system_chip_vendor() for argument descriptions
+ */
+typedef const char *(*cros_system_chip_vendor_api)(const struct device *dev);
+
+/**
+ * @typedef cros_system_chip_name_api
+ * @brief Callback API for getting the chip name.
+ * See cros_system_chip_name() for argument descriptions
+ */
+typedef const char *(*cros_system_chip_name_api)(const struct device *dev);
+
+/**
+ * @typedef cros_system_chip_revision_api
+ * @brief Callback API for getting the chip revision.
+ * See cros_system_chip_revision() for argument descriptions
+ */
+typedef const char *(*cros_system_chip_revision_api)(const struct device *dev);
+
/** @brief Driver API structure. */
__subsystem struct cros_system_driver_api {
cros_system_get_reset_cause_api get_reset_cause;
cros_system_soc_reset_api soc_reset;
cros_system_hibernate_api hibernate;
+ cros_system_chip_vendor_api chip_vendor;
+ cros_system_chip_name_api chip_name;
+ cros_system_chip_revision_api chip_revision;
};
/**
@@ -140,6 +164,71 @@ static inline int z_impl_cros_system_hibernate(const struct device *dev,
}
/**
+ * @brief Get the chip vendor.
+ *
+ * @param dev Pointer to the device structure for the driver instance.
+ * @retval Chip vendor string if successful.
+ * @retval Null string if failure.
+ */
+__syscall const char *cros_system_chip_vendor(const struct device *dev);
+
+static inline const char *
+z_impl_cros_system_chip_vendor(const struct device *dev)
+{
+ const struct cros_system_driver_api *api =
+ (const struct cros_system_driver_api *)dev->api;
+
+ if (!api->chip_vendor) {
+ return "";
+ }
+
+ return api->chip_vendor(dev);
+}
+
+/**
+ * @brief Get the chip name.
+ *
+ * @param dev Pointer to the device structure for the driver instance.
+ * @retval Chip name string if successful.
+ * @retval Null string if failure.
+ */
+__syscall const char *cros_system_chip_name(const struct device *dev);
+
+static inline const char *z_impl_cros_system_chip_name(const struct device *dev)
+{
+ const struct cros_system_driver_api *api =
+ (const struct cros_system_driver_api *)dev->api;
+
+ if (!api->chip_name) {
+ return "";
+ }
+
+ return api->chip_name(dev);
+}
+
+/**
+ * @brief Get the chip revision.
+ *
+ * @param dev Pointer to the device structure for the driver instance.
+ * @retval Chip revision string if successful.
+ * @retval Null string if failure.
+ */
+__syscall const char *cros_system_chip_revision(const struct device *dev);
+
+static inline const char *
+z_impl_cros_system_chip_revision(const struct device *dev)
+{
+ const struct cros_system_driver_api *api =
+ (const struct cros_system_driver_api *)dev->api;
+
+ if (!api->chip_revision) {
+ return "";
+ }
+
+ return api->chip_revision(dev);
+}
+
+/**
* @}
*/
#include <syscalls/cros_system.h>