1 /*
2  * Arm SCP/MCP Software
3  * Copyright (c) 2023, Arm Limited and Contributors. All rights reserved.
4  *
5  * SPDX-License-Identifier: BSD-3-Clause
6  *
7  * Description:
8  *     Power meter module header.
9  */
10 
11 #ifndef MOD_POWER_METER_H
12 #define MOD_POWER_METER_H
13 
14 #include <fwk_id.h>
15 
16 /*!
17  * \addtogroup GroupModules Modules
18  * \{
19  */
20 
21 /*!
22  * \defgroup GroupPowerMeter Power meter
23  *
24  * \details Responsible for power measurements
25  *
26  * \{
27  */
28 
29 /*!
30  * \brief Power meter device configuration.
31  */
32 struct mod_power_meter_dev_config {
33     /*!
34      * \brief Module or element identifier of the driver
35      */
36     fwk_id_t driver_id;
37     /*!
38      * \brief API identifier of the driver.
39      */
40     fwk_id_t driver_api_id;
41 };
42 
43 /*!
44  * \brief Power meter driver interface.
45  */
46 struct mod_power_meter_driver_api {
47     /*!
48      * \brief Get the power measurement.
49      *
50      * \param id Specific power meter device ID.
51      * \param[out] power Power measured by the power meter device.
52      *
53      * \retval ::FWK_SUCCESS The cap is returned successfully.
54      */
55     int (*get_power)(fwk_id_t id, uint32_t *power);
56 };
57 
58 /*!
59  * \brief Power meter interface.
60  */
61 struct mod_power_meter_api {
62     /*!
63      * \brief Get the power measurement.
64      *
65      * \param id Specific power meter device ID.
66      * \param[out] power Power measured by the power meter device.
67      *
68      * \retval ::FWK_SUCCESS The cap is returned successfully.
69      */
70     int (*get_power)(fwk_id_t id, uint32_t *power);
71 
72     /*!
73      * \brief Set the power change notification hysteresis.
74      *
75      * \details The hysteresis is needed to avoid multiple unneeded
76      *     notifications for a fluctuating power measurement.
77      *
78      * \param id Specific power meter device ID.
79      * \param threshold_low The lower threshold of the measured power to trigger
80      *     a notification.
81      *
82      * \param threshold_high The higher threshold of the measured power to
83      *     trigger a notification.
84      *
85      * \retval ::FWK_SUCCESS The threshold values are set successfully.
86      */
87     int (*set_power_change_notif_thresholds)(
88         fwk_id_t id,
89         uint32_t threshold_low,
90         uint32_t threshold_high);
91 };
92 
93 /*!
94  * \brief API indices.
95  */
96 enum mod_power_meter_api_idx {
97     /*! Get power measurements */
98     MOD_POWER_METER_API_IDX_MEASUREMENT,
99 
100     /*! Number of defined APIs. */
101     MOD_POWER_METER_API_IDX_COUNT,
102 };
103 
104 /*!
105  * \brief Power meter notification indices.
106  */
107 enum mod_power_meter_notification_idx {
108     /*! Measured power changed notification. */
109     MOD_POWER_METER_NOTIFICATION_IDX_MEASUREMENTS_CHANGED,
110 
111     /*! Number of defined notifications. */
112     MOD_POWER_METER_NOTIFICATION_IDX_COUNT,
113 };
114 
115 /*!
116  * \}
117  */
118 
119 /*!
120  * \}
121  */
122 #endif /* MOD_POWER_METER_H */
123