1 /*
2  * Arm SCP/MCP Software
3  * Copyright (c) 2017-2021, Arm Limited and Contributors. All rights reserved.
4  *
5  * SPDX-License-Identifier: BSD-3-Clause
6  */
7 
8 #ifndef MOD_MOCK_PSU_H
9 #define MOD_MOCK_PSU_H
10 
11 #include <fwk_id.h>
12 #include <fwk_module_idx.h>
13 
14 #include <stdbool.h>
15 #include <stdint.h>
16 
17 /*!
18  * \ingroup GroupModules
19  * \defgroup GroupMockPsu Mock Power Supply Driver
20  *
21  * \details The `mock_psu` module provides a mock power supply driver for use
22  *      alongside the `psu` interface on systems that do not provide a real
23  *      power supply.
24  *
25  *      In addition to the standard synchronous mode of operation, mock PSUs
26  *      support an emulated form of asynchronous operation. This mode reproduces
27  *      the behaviour of some real devices which cannot respond to requests
28  *      immediately, and is useful for testing interfaces that must support
29  *      devices of this kind.
30  *
31  *      To enable the asynchronous operation mode, see the documentation for
32  *      ::mod_mock_psu_element_cfg::async_alarm_id.
33  *
34  * \{
35  */
36 
37 /*!
38  * \brief Element configuration.
39  */
40 struct mod_mock_psu_element_cfg {
41     /*!
42      * \brief Alarm entity identifier used for asynchronous driver emulation.
43      *
44      * \details This identifies the entity of a timer alarm, which must
45      *      implement ::mod_timer_alarm_api.
46      *
47      * \note This field may be set to ::FWK_ID_NONE, in which case asynchronous
48      *      driver emulation is not enabled.
49      */
50     fwk_id_t async_alarm_id;
51 
52     /*!
53      * \brief Alarm API identifier used for asynchronous driver emulation.
54      *
55      * \details This identifies the API of a timer alarm, which must
56      *      implement ::mod_timer_alarm_api.
57      *
58      * \note This field may be set to ::FWK_ID_NONE if asynchronous driver
59      *      emulation is not enabled.
60      */
61     fwk_id_t async_alarm_api_id;
62 
63     /*!
64      * \brief Driver response entity identifier used for asynchronous driver
65      *      emulation.
66      *
67      * \details This identifies the entity of a driver response entity, which
68      *      must implement ::mod_psu_driver_response_api.
69      *
70      * \note This field may be set to ::FWK_ID_NONE if asynchronous driver
71      *      emulation is not enabled.
72      */
73     fwk_id_t async_response_id;
74 
75     /*!
76      * \brief Driver response API identifier used for asynchronous driver
77      *      emulation.
78      *
79      * \details This identifies the API of a driver response entity, which must
80      *      implement ::mod_psu_driver_response_api.
81      *
82      * \note This field may be set to ::FWK_ID_NONE if asynchronous driver
83      *      emulation is not enabled.
84      */
85     fwk_id_t async_response_api_id;
86 
87     /*!
88      * \brief Default state of the mock device's supply (enabled or disabled).
89      */
90     bool default_enabled;
91 
92     /*!
93      * \brief Default voltage, in millivolts (mV), of the device's supply.
94      */
95     uint32_t default_voltage;
96 };
97 
98 /*!
99  * \brief API indices.
100  */
101 enum mod_mock_psu_api_idx {
102     /*!
103      * \brief Driver API index.
104      *
105      * \note This API implements the ::mod_psu_driver_api interface.
106      *
107      * \warning Binding to this API must occur through an element of this
108      *      module.
109      */
110     MOD_MOCK_PSU_API_IDX_DRIVER,
111 
112     /*!
113      * \brief Number of defined APIs.
114      */
115     MOD_MOCK_PSU_API_IDX_COUNT
116 };
117 
118 /*!
119  * \brief Driver API identifier.
120  *
121  * \note This identifier corresponds to the ::MOD_MOCK_PSU_API_IDX_DRIVER API
122  *      index.
123  */
124 static const fwk_id_t mod_mock_psu_api_id_driver =
125     FWK_ID_API_INIT(FWK_MODULE_IDX_MOCK_PSU, MOD_MOCK_PSU_API_IDX_DRIVER);
126 
127 /*!
128  * \}
129  */
130 
131 #endif /* MOD_MOCK_PSU_H */
132