diff options
Diffstat (limited to 'module/mock_clock/include/mod_mock_clock.h')
-rw-r--r-- | module/mock_clock/include/mod_mock_clock.h | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/module/mock_clock/include/mod_mock_clock.h b/module/mock_clock/include/mod_mock_clock.h new file mode 100644 index 00000000..e4ff156a --- /dev/null +++ b/module/mock_clock/include/mod_mock_clock.h @@ -0,0 +1,102 @@ +/* + * Arm SCP/MCP Software + * Copyright (c) 2020, Arm Limited and Contributors. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef MOD_MOCK_CLOCK_H +#define MOD_MOCK_CLOCK_H + +#include <fwk_id.h> +#include <fwk_module_idx.h> + +#include <stdbool.h> +#include <stdint.h> + +/*! + * \ingroup GroupModules + * \defgroup GroupMockClock Mock Clock Driver + * + * \details The `mock_clock` module provides a mock clock driver for use + * alongside the `clock` interface on systems that do not provide a real + * clock driver. + * + * \warning When using this module to mock a pre-existing driver + * for any reason, this driver must be forced to bind to the + * ::MOD_MOCK_CLOCK_API_TYPE_RESPONSE_DRIVER API through its module + * configuration. This will avoid any conflict between the pre-existing + * driver and the mocked one. + * \{ + */ + +/*! + * \brief Rate lookup table entry. + */ +struct mod_mock_clock_rate { + /*! Rate of the clock in Hertz. */ + uint32_t rate; + + /*! The clock divider used to attain the rate. */ + unsigned int divider; +}; + +/*! + * \brief Element configuration. + */ +struct mod_mock_clock_element_cfg { + /*! Pointer to the clock's rate lookup table. */ + const struct mod_mock_clock_rate *rate_table; + + /*! The number of rates in the rate lookup table. */ + unsigned int rate_count; +}; + +/*! + * \brief API indices. + * + * \warning The mock clock implements the clock driver API only. The response + * driver API only acts as a pointer to be bound to. + */ +enum mod_mock_clock_api_type { + /*! + * \brief Clock driver. + * + * \note This API implements the mod_clock::mod_clock_driver_api interface. + * + * \warning Binding to this API must occur through an element of this + * module. + */ + MOD_MOCK_CLOCK_API_TYPE_DRIVER, + + /*! + * \brief Clock driver response. + * + * \note This API implements the mod_clock::mod_clock_driver_response_api + * interface. + * + * \warning Binding to this API must occur through an element of this + * module. + */ + MOD_MOCK_CLOCK_API_TYPE_RESPONSE_DRIVER, + + /*! + * \brief Number of defined APIs. + */ + MOD_MOCK_CLOCK_API_COUNT, +}; + +/*! + * \brief Driver API identifier. + * + * \note This identifier corresponds to the ::MOD_MOCK_CLOCK_API_TYPE_DRIVER API + * index. + */ +static const fwk_id_t mod_mock_clock_api_id_driver = + FWK_ID_API_INIT(FWK_MODULE_IDX_MOCK_CLOCK, MOD_MOCK_CLOCK_API_TYPE_DRIVER); + +/*! + * \} + */ + +#endif /* MOD_MOCK_CLOCK_H */ |