summaryrefslogtreecommitdiff
path: root/zephyr/include/drivers/cros_flash.h
diff options
context:
space:
mode:
authorJack Rosenthal <jrosenth@chromium.org>2021-11-04 12:11:58 -0600
committerCommit Bot <commit-bot@chromium.org>2021-11-05 04:22:34 +0000
commit252457d4b21f46889eebad61d4c0a65331919cec (patch)
tree01856c4d31d710b20e85a74c8d7b5836e35c3b98 /zephyr/include/drivers/cros_flash.h
parent08f5a1e6fc2c9467230444ac9b582dcf4d9f0068 (diff)
downloadchrome-ec-release-R98-14388.B-ish.tar.gz
In the interest of making long-term branch maintenance incur as little technical debt on us as possible, we should not maintain any files on the branch we are not actually using. This has the added effect of making it extremely clear when merging CLs from the main branch when changes have the possibility to affect us. The follow-on CL adds a convenience script to actually pull updates from the main branch and generate a CL for the update. BUG=b:204206272 BRANCH=ish TEST=make BOARD=arcada_ish && make BOARD=drallion_ish Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: I17e4694c38219b5a0823e0a3e55a28d1348f4b18 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3262038 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Tom Hughes <tomhughes@chromium.org>
Diffstat (limited to 'zephyr/include/drivers/cros_flash.h')
-rw-r--r--zephyr/include/drivers/cros_flash.h288
1 files changed, 0 insertions, 288 deletions
diff --git a/zephyr/include/drivers/cros_flash.h b/zephyr/include/drivers/cros_flash.h
deleted file mode 100644
index 7f48cf7285..0000000000
--- a/zephyr/include/drivers/cros_flash.h
+++ /dev/null
@@ -1,288 +0,0 @@
-/*
- * Copyright 2020 Google LLC
- *
- * SPDX-License-Identifier: Apache-2.0
- */
-
-/**
- * @file
- * @brief Chrome OS-specific API for flash memory access
- * This exists only support the interface expected by the Chrome OS EC. It seems
- * better to implement this so we can make use of most of the existing code in
- * its keyboard_scan.c file and thus make sure we operate the same way.
- *
- * It provides raw access to flash memory module.
- */
-
-#ifndef ZEPHYR_INCLUDE_DRIVERS_CROS_FLASH_H_
-#define ZEPHYR_INCLUDE_DRIVERS_CROS_FLASH_H_
-
-#include <kernel.h>
-#include <device.h>
-
-/**
- * @brief CROS Flash Driver APIs
- * @defgroup cros_flash_interface CROS Flash Driver APIs
- * @ingroup io_interfaces
- * @{
- */
-
-/**
- * @cond INTERNAL_HIDDEN
- *
- * cros keyboard raw driver API definition and system call entry points
- *
- * (Internal use only.)
- */
-typedef int (*cros_flash_api_init)(const struct device *dev);
-
-typedef int (*cros_flash_api_physical_read)(const struct device *dev,
- int offset, int size, char *data);
-
-typedef int (*cros_flash_api_physical_write)(const struct device *dev,
- int offset, int size,
- const char *data);
-
-typedef int (*cros_flash_api_physical_erase)(const struct device *dev,
- int offset, int size);
-
-typedef int (*cros_flash_api_physical_get_protect)(const struct device *dev,
- int bank);
-
-typedef uint32_t
-(*cros_flash_api_physical_get_protect_flags)(const struct device *dev);
-
-typedef int (*cros_flash_api_physical_protect_at_boot)(const struct device *dev,
- uint32_t new_flags);
-
-typedef int (*cros_flash_api_physical_protect_now)(const struct device *dev,
- int all);
-
-__subsystem struct cros_flash_driver_api {
- cros_flash_api_init init;
- cros_flash_api_physical_read physical_read;
- cros_flash_api_physical_write physical_write;
- cros_flash_api_physical_erase physical_erase;
- cros_flash_api_physical_get_protect physical_get_protect;
- cros_flash_api_physical_get_protect_flags physical_get_protect_flags;
- cros_flash_api_physical_protect_at_boot physical_protect_at_boot;
- cros_flash_api_physical_protect_now physical_protect_now;
-};
-
-/**
- * @endcond
- */
-
-/**
- * @brief Initialize physical flash.
- *
- * @param dev Pointer to the device structure for the flash driver instance.
- *
- * @return 0 If successful.
- * @retval -ENOTSUP Not supported api function.
- */
-__syscall int cros_flash_init(const struct device *dev);
-
-static inline int z_impl_cros_flash_init(const struct device *dev)
-{
- const struct cros_flash_driver_api *api =
- (const struct cros_flash_driver_api *)dev->api;
-
- if (!api->init) {
- return -ENOTSUP;
- }
-
- return api->init(dev);
-}
-
-/**
- * @brief Read from physical flash.
- *
- * @param dev Pointer to the device structure for the flash driver instance.
- * @param offset Flash offset to read.
- * @param size Number of bytes to read.
- * @param data Destination buffer for data. Must be 32-bit aligned.
- *
- * @return 0 If successful.
- * @retval -ENOTSUP Not supported api function.
- */
-__syscall int cros_flash_physical_read(const struct device *dev, int offset,
- int size, char *data);
-
-static inline int z_impl_cros_flash_physical_read(const struct device *dev,
- int offset, int size,
- char *data)
-{
- const struct cros_flash_driver_api *api =
- (const struct cros_flash_driver_api *)dev->api;
-
- if (!api->physical_read) {
- return -ENOTSUP;
- }
-
- return api->physical_read(dev, offset, size, data);
-}
-
-/**
- * @brief Write to physical flash.
- *
- * Offset and size must be a multiple of CONFIG_FLASH_WRITE_SIZE.
- *
- * @param dev Pointer to the device structure for the flash driver instance.
- * @param offset Flash offset to write.
- * @param size Number of bytes to write.
- * @param data Destination buffer for data. Must be 32-bit aligned.
- *
- * @return 0 If successful.
- * @retval -ENOTSUP Not supported api function.
- */
-__syscall int cros_flash_physical_write(const struct device *dev, int offset,
- int size, const char *data);
-
-static inline int z_impl_cros_flash_physical_write(const struct device *dev,
- int offset, int size,
- const char *data)
-{
- const struct cros_flash_driver_api *api =
- (const struct cros_flash_driver_api *)dev->api;
-
- if (!api->physical_write) {
- return -ENOTSUP;
- }
-
- return api->physical_write(dev, offset, size, data);
-}
-
-/**
- * @brief Erase physical flash.
- *
- * Offset and size must be a multiple of CONFIG_FLASH_ERASE_SIZE.
- *
- * @param dev Pointer to the device structure for the flash driver instance.
- * @param offset Flash offset to erase.
- * @param size Number of bytes to erase.
- *
- * @return 0 If successful.
- * @retval -ENOTSUP Not supported api function.
- */
-__syscall int cros_flash_physical_erase(const struct device *dev, int offset,
- int size);
-
-static inline int z_impl_cros_flash_physical_erase(const struct device *dev,
- int offset, int size)
-{
- const struct cros_flash_driver_api *api =
- (const struct cros_flash_driver_api *)dev->api;
-
- if (!api->physical_erase) {
- return -ENOTSUP;
- }
-
- return api->physical_erase(dev, offset, size);
-}
-
-/**
- * @brief Read physical write protect setting for a flash bank.
- *
- * @param dev Pointer to the device structure for the flash driver instance.
- * @param bank Bank index to check.
- *
- * @return non-zero if bank is protected until reboot.
- * @retval -ENOTSUP Not supported api function.
- */
-__syscall int cros_flash_physical_get_protect(const struct device *dev,
- int bank);
-
-static inline int
-z_impl_cros_flash_physical_get_protect(const struct device *dev, int bank)
-{
- const struct cros_flash_driver_api *api =
- (const struct cros_flash_driver_api *)dev->api;
-
- if (!api->physical_get_protect) {
- return -ENOTSUP;
- }
-
- return api->physical_get_protect(dev, bank);
-}
-
-/**
- * @brief Return flash protect state flags from the physical layer.
- *
- * @param dev Pointer to the device structure for the flash driver instance.
- *
- * @retval -ENOTSUP Not supported api function.
- */
-__syscall
-uint32_t cros_flash_physical_get_protect_flags(const struct device *dev);
-
-static inline uint32_t
-z_impl_cros_flash_physical_get_protect_flags(const struct device *dev)
-{
- const struct cros_flash_driver_api *api =
- (const struct cros_flash_driver_api *)dev->api;
-
- if (!api->physical_get_protect_flags) {
- return -ENOTSUP;
- }
-
- return api->physical_get_protect_flags(dev);
-}
-
-/**
- * @brief Enable/disable protecting firmware/pstate at boot.
- *
- * @param dev Pointer to the device structure for the flash driver instance.
- * @param new_flags to protect (only EC_FLASH_PROTECT_*_AT_BOOT are
- * taken care of)
- *
- * @return 0 If successful.
- * @retval -ENOTSUP Not supported api function.
- */
-__syscall int cros_flash_physical_protect_at_boot(const struct device *dev,
- uint32_t new_flags);
-
-static inline int
-z_impl_cros_flash_physical_protect_at_boot(const struct device *dev,
- uint32_t new_flags)
-{
- const struct cros_flash_driver_api *api =
- (const struct cros_flash_driver_api *)dev->api;
-
- if (!api->physical_protect_at_boot) {
- return -ENOTSUP;
- }
-
- return api->physical_protect_at_boot(dev, new_flags);
-}
-
-/**
- * @brief Protect now physical flash.
- *
- * @param dev Pointer to the device structure for the flash driver instance.
- * @param all Protect all (=1) or just read-only and pstate (=0).
- *
- * @return 0 If successful.
- * @retval -ENOTSUP Not supported api function.
- */
-__syscall int cros_flash_physical_protect_now(const struct device *dev,
- int all);
-
-static inline int
-z_impl_cros_flash_physical_protect_now(const struct device *dev, int all)
-{
- const struct cros_flash_driver_api *api =
- (const struct cros_flash_driver_api *)dev->api;
-
- if (!api->physical_protect_now) {
- return -ENOTSUP;
- }
-
- return api->physical_protect_now(dev, all);
-}
-
-/**
- * @}
- */
-#include <syscalls/cros_flash.h>
-#endif /* ZEPHYR_INCLUDE_DRIVERS_CROS_FLASH_H_ */