diff options
author | Jun Lin <CHLin56@nuvoton.com> | 2021-03-26 17:29:16 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-03-31 15:22:58 +0000 |
commit | 6f75875da06461dd65f13e2741e16034d27b0289 (patch) | |
tree | b01d31e859c9c04ee828b08e8d98262c9952351b /zephyr/include/drivers | |
parent | cf62c88b539f0ebc8935a8cf9c375002e7a9e33f (diff) | |
download | chrome-ec-6f75875da06461dd65f13e2741e16034d27b0289.tar.gz |
zephyr: npcx: support SHI driver
Add the support for SHI (Serial Host Interface) driver. This is used to
transfer host commands between EC and ARM-based AP.
BUG=b:182600858
BRANCH=none
TEST=Test host command "version" and "Hello" on npcx7_evb and the host
emulator.
Signed-off-by: Jun Lin <CHLin56@nuvoton.com>
Change-Id: I5f290fe910600162764f5728f094dd0f42d508ef
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2786887
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Commit-Queue: Jack Rosenthal <jrosenth@chromium.org>
Tested-by: Jack Rosenthal <jrosenth@chromium.org>
Diffstat (limited to 'zephyr/include/drivers')
-rw-r--r-- | zephyr/include/drivers/cros_shi.h | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/zephyr/include/drivers/cros_shi.h b/zephyr/include/drivers/cros_shi.h new file mode 100644 index 0000000000..aab3507dd3 --- /dev/null +++ b/zephyr/include/drivers/cros_shi.h @@ -0,0 +1,89 @@ +/* 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. + */ + +/** + * @file + * @brief Chrome OS-specific API for Serial Host Interface (SHI) + */ + +#ifndef ZEPHYR_INCLUDE_DRIVERS_CROS_SHI_H_ +#define ZEPHYR_INCLUDE_DRIVERS_CROS_SHI_H_ + +/** + * @brief CROS Serial Host Interface Driver APIs + * @defgroup cros_shi_interface CROS Serial Host Interface Driver APIs + * @ingroup io_interfaces + * @{ + */ + +#include <kernel.h> +#include <device.h> + +/** + * @cond INTERNAL_HIDDEN + * + * cros Serial Host Interface driver API definition and system call entry points + * + * (Internal use only.) + */ +typedef int (*cros_shi_api_enable)(const struct device *dev); + +typedef int (*cros_shi_api_disable)(const struct device *dev); + +/** @brief Driver API structure. */ +__subsystem struct cros_shi_driver_api { + cros_shi_api_enable enable; + cros_shi_api_disable disable; +}; + +/** + * @brief Enable SHI module. + * + * @param dev Pointer to the device structure for the driver instance. + * + * @retval non-negative if successful. + * @retval Negative errno code if failure. + */ +__syscall int cros_shi_enable(const struct device *dev); + +static inline int z_impl_cros_shi_enable(const struct device *dev) +{ + const struct cros_shi_driver_api *api = + (const struct cros_shi_driver_api *)dev->api; + + if (!api->enable) { + return -ENOTSUP; + } + + return api->enable(dev); +} + +/** + * @brief Disable SHI module. + * + * @param dev Pointer to the device structure for the driver instance. + * + * @retval no return if successful. + * @retval Negative errno code if failure. + */ +__syscall int cros_shi_disable(const struct device *dev); + +static inline int z_impl_cros_shi_disable(const struct device *dev) +{ + const struct cros_shi_driver_api *api = + (const struct cros_shi_driver_api *)dev->api; + + if (!api->disable) { + return -ENOTSUP; + } + + return api->disable(dev); +} + +/** + * @} + */ +#include <syscalls/cros_shi.h> +#endif /* ZEPHYR_INCLUDE_DRIVERS_CROS_SHI_H_ */ |